diff mbox series

[v2,1/2] tcg: Add tcg_gen_{ld,st}_i128

Message ID 20231013175109.124308-2-richard.henderson@linaro.org
State Superseded
Headers show
Series tcg: Streamline vector load/store | expand

Commit Message

Richard Henderson Oct. 13, 2023, 5:51 p.m. UTC
Do not require the translators to jump through concat and
extract of i64 in order to move values to and from  env.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 include/tcg/tcg-op-common.h |  3 +++
 tcg/tcg-op.c                | 22 ++++++++++++++++++++++
 2 files changed, 25 insertions(+)

Comments

Philippe Mathieu-Daudé Oct. 17, 2023, 11:48 a.m. UTC | #1
On 13/10/23 19:51, Richard Henderson wrote:
> Do not require the translators to jump through concat and
> extract of i64 in order to move values to and from  env.

(extra space)

> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   include/tcg/tcg-op-common.h |  3 +++
>   tcg/tcg-op.c                | 22 ++++++++++++++++++++++
>   2 files changed, 25 insertions(+)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Song Gao Oct. 18, 2023, 1:19 a.m. UTC | #2
在 2023/10/14 上午1:51, Richard Henderson 写道:
> Do not require the translators to jump through concat and
> extract of i64 in order to move values to and from  env.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   include/tcg/tcg-op-common.h |  3 +++
>   tcg/tcg-op.c                | 22 ++++++++++++++++++++++
>   2 files changed, 25 insertions(+)
Reviewed-by: Song Gao <gaosong@loongson.cn>

Thanks.
Song Gao
> diff --git a/include/tcg/tcg-op-common.h b/include/tcg/tcg-op-common.h
> index 2048f92b5e..56d4e9cb9f 100644
> --- a/include/tcg/tcg-op-common.h
> +++ b/include/tcg/tcg-op-common.h
> @@ -747,6 +747,9 @@ void tcg_gen_mov_i128(TCGv_i128 dst, TCGv_i128 src);
>   void tcg_gen_extr_i128_i64(TCGv_i64 lo, TCGv_i64 hi, TCGv_i128 arg);
>   void tcg_gen_concat_i64_i128(TCGv_i128 ret, TCGv_i64 lo, TCGv_i64 hi);
>   
> +void tcg_gen_ld_i128(TCGv_i128 ret, TCGv_ptr base, tcg_target_long offset);
> +void tcg_gen_st_i128(TCGv_i128 val, TCGv_ptr base, tcg_target_long offset);
> +
>   static inline void tcg_gen_concat32_i64(TCGv_i64 ret, TCGv_i64 lo, TCGv_i64 hi)
>   {
>       tcg_gen_deposit_i64(ret, lo, hi, 32, 32);
> diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c
> index 393dbcd01c..12bcedf42f 100644
> --- a/tcg/tcg-op.c
> +++ b/tcg/tcg-op.c
> @@ -2880,6 +2880,28 @@ void tcg_gen_mov_i128(TCGv_i128 dst, TCGv_i128 src)
>       }
>   }
>   
> +void tcg_gen_ld_i128(TCGv_i128 ret, TCGv_ptr base, tcg_target_long offset)
> +{
> +    if (HOST_BIG_ENDIAN) {
> +        tcg_gen_ld_i64(TCGV128_HIGH(ret), base, offset);
> +        tcg_gen_ld_i64(TCGV128_LOW(ret), base, offset + 8);
> +    } else {
> +        tcg_gen_ld_i64(TCGV128_LOW(ret), base, offset);
> +        tcg_gen_ld_i64(TCGV128_HIGH(ret), base, offset + 8);
> +    }
> +}
> +
> +void tcg_gen_st_i128(TCGv_i128 val, TCGv_ptr base, tcg_target_long offset)
> +{
> +    if (HOST_BIG_ENDIAN) {
> +        tcg_gen_st_i64(TCGV128_HIGH(val), base, offset);
> +        tcg_gen_st_i64(TCGV128_LOW(val), base, offset + 8);
> +    } else {
> +        tcg_gen_st_i64(TCGV128_LOW(val), base, offset);
> +        tcg_gen_st_i64(TCGV128_HIGH(val), base, offset + 8);
> +    }
> +}
> +
>   /* QEMU specific operations.  */
>   
>   void tcg_gen_exit_tb(const TranslationBlock *tb, unsigned idx)
Philippe Mathieu-Daudé Oct. 18, 2023, 5:03 a.m. UTC | #3
On 18/10/23 03:19, gaosong wrote:
> 在 2023/10/14 上午1:51, Richard Henderson 写道:
>> Do not require the translators to jump through concat and
>> extract of i64 in order to move values to and from  env.
>>
>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>> ---
>>   include/tcg/tcg-op-common.h |  3 +++
>>   tcg/tcg-op.c                | 22 ++++++++++++++++++++++
>>   2 files changed, 25 insertions(+)
> Reviewed-by: Song Gao <gaosong@loongson.cn>

And per 
https://lore.kernel.org/qemu-devel/88015945-49f7-195b-7e78-08d9281d10d6@loongson.cn/:

Tested-by: Song Gao <gaosong@loongson.cn>
diff mbox series

Patch

diff --git a/include/tcg/tcg-op-common.h b/include/tcg/tcg-op-common.h
index 2048f92b5e..56d4e9cb9f 100644
--- a/include/tcg/tcg-op-common.h
+++ b/include/tcg/tcg-op-common.h
@@ -747,6 +747,9 @@  void tcg_gen_mov_i128(TCGv_i128 dst, TCGv_i128 src);
 void tcg_gen_extr_i128_i64(TCGv_i64 lo, TCGv_i64 hi, TCGv_i128 arg);
 void tcg_gen_concat_i64_i128(TCGv_i128 ret, TCGv_i64 lo, TCGv_i64 hi);
 
+void tcg_gen_ld_i128(TCGv_i128 ret, TCGv_ptr base, tcg_target_long offset);
+void tcg_gen_st_i128(TCGv_i128 val, TCGv_ptr base, tcg_target_long offset);
+
 static inline void tcg_gen_concat32_i64(TCGv_i64 ret, TCGv_i64 lo, TCGv_i64 hi)
 {
     tcg_gen_deposit_i64(ret, lo, hi, 32, 32);
diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c
index 393dbcd01c..12bcedf42f 100644
--- a/tcg/tcg-op.c
+++ b/tcg/tcg-op.c
@@ -2880,6 +2880,28 @@  void tcg_gen_mov_i128(TCGv_i128 dst, TCGv_i128 src)
     }
 }
 
+void tcg_gen_ld_i128(TCGv_i128 ret, TCGv_ptr base, tcg_target_long offset)
+{
+    if (HOST_BIG_ENDIAN) {
+        tcg_gen_ld_i64(TCGV128_HIGH(ret), base, offset);
+        tcg_gen_ld_i64(TCGV128_LOW(ret), base, offset + 8);
+    } else {
+        tcg_gen_ld_i64(TCGV128_LOW(ret), base, offset);
+        tcg_gen_ld_i64(TCGV128_HIGH(ret), base, offset + 8);
+    }
+}
+
+void tcg_gen_st_i128(TCGv_i128 val, TCGv_ptr base, tcg_target_long offset)
+{
+    if (HOST_BIG_ENDIAN) {
+        tcg_gen_st_i64(TCGV128_HIGH(val), base, offset);
+        tcg_gen_st_i64(TCGV128_LOW(val), base, offset + 8);
+    } else {
+        tcg_gen_st_i64(TCGV128_LOW(val), base, offset);
+        tcg_gen_st_i64(TCGV128_HIGH(val), base, offset + 8);
+    }
+}
+
 /* QEMU specific operations.  */
 
 void tcg_gen_exit_tb(const TranslationBlock *tb, unsigned idx)