[PATCH v2 05/23] target/loongarch: Use target_ulong for iocsrrd helper results

Jiaxun Yang posted 23 patches 3 months, 1 week ago
There is a newer version of this series
[PATCH v2 05/23] target/loongarch: Use target_ulong for iocsrrd helper results
Posted by Jiaxun Yang 3 months, 1 week ago
Those results are all targeting TCGv values, which means they should
be in target_ulong type.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
 target/loongarch/helper.h           | 8 ++++----
 target/loongarch/tcg/iocsr_helper.c | 8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/target/loongarch/helper.h b/target/loongarch/helper.h
index b3b64a021536255a3f9decfc10ff61fe8380e2ae..409d93a5b0808f0e32b8c0e2e17cebac9feaf8ed 100644
--- a/target/loongarch/helper.h
+++ b/target/loongarch/helper.h
@@ -104,10 +104,10 @@ DEF_HELPER_2(csrwr_estat, i64, env, tl)
 DEF_HELPER_2(csrwr_asid, i64, env, tl)
 DEF_HELPER_2(csrwr_tcfg, i64, env, tl)
 DEF_HELPER_2(csrwr_ticlr, i64, env, tl)
-DEF_HELPER_2(iocsrrd_b, i64, env, tl)
-DEF_HELPER_2(iocsrrd_h, i64, env, tl)
-DEF_HELPER_2(iocsrrd_w, i64, env, tl)
-DEF_HELPER_2(iocsrrd_d, i64, env, tl)
+DEF_HELPER_2(iocsrrd_b, tl, env, tl)
+DEF_HELPER_2(iocsrrd_h, tl, env, tl)
+DEF_HELPER_2(iocsrrd_w, tl, env, tl)
+DEF_HELPER_2(iocsrrd_d, tl, env, tl)
 DEF_HELPER_3(iocsrwr_b, void, env, tl, tl)
 DEF_HELPER_3(iocsrwr_h, void, env, tl, tl)
 DEF_HELPER_3(iocsrwr_w, void, env, tl, tl)
diff --git a/target/loongarch/tcg/iocsr_helper.c b/target/loongarch/tcg/iocsr_helper.c
index db30de2523fff01bcc8923eb12c7fca7bedca7bf..23d819de0ef9790eb82741f1e8a0e20dc139bf4b 100644
--- a/target/loongarch/tcg/iocsr_helper.c
+++ b/target/loongarch/tcg/iocsr_helper.c
@@ -15,25 +15,25 @@
 #define GET_MEMTXATTRS(cas) \
         ((MemTxAttrs){.requester_id = env_cpu(cas)->cpu_index})
 
-uint64_t helper_iocsrrd_b(CPULoongArchState *env, target_ulong r_addr)
+target_ulong helper_iocsrrd_b(CPULoongArchState *env, target_ulong r_addr)
 {
     return (int8_t)address_space_ldub(env->address_space_iocsr, r_addr,
                                       GET_MEMTXATTRS(env), NULL);
 }
 
-uint64_t helper_iocsrrd_h(CPULoongArchState *env, target_ulong r_addr)
+target_ulong helper_iocsrrd_h(CPULoongArchState *env, target_ulong r_addr)
 {
     return (int16_t)address_space_lduw(env->address_space_iocsr, r_addr,
                                        GET_MEMTXATTRS(env), NULL);
 }
 
-uint64_t helper_iocsrrd_w(CPULoongArchState *env, target_ulong r_addr)
+target_ulong helper_iocsrrd_w(CPULoongArchState *env, target_ulong r_addr)
 {
     return (int32_t)address_space_ldl(env->address_space_iocsr, r_addr,
                                       GET_MEMTXATTRS(env), NULL);
 }
 
-uint64_t helper_iocsrrd_d(CPULoongArchState *env, target_ulong r_addr)
+target_ulong helper_iocsrrd_d(CPULoongArchState *env, target_ulong r_addr)
 {
     return address_space_ldq(env->address_space_iocsr, r_addr,
                              GET_MEMTXATTRS(env), NULL);

-- 
2.43.0
Re: [PATCH v2 05/23] target/loongarch: Use target_ulong for iocsrrd helper results
Posted by Philippe Mathieu-Daudé 3 months, 1 week ago
On 26/12/24 22:19, Jiaxun Yang wrote:
> Those results are all targeting TCGv values, which means they should
> be in target_ulong type.
> 
> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> ---
>   target/loongarch/helper.h           | 8 ++++----
>   target/loongarch/tcg/iocsr_helper.c | 8 ++++----
>   2 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/target/loongarch/helper.h b/target/loongarch/helper.h
> index b3b64a021536255a3f9decfc10ff61fe8380e2ae..409d93a5b0808f0e32b8c0e2e17cebac9feaf8ed 100644
> --- a/target/loongarch/helper.h
> +++ b/target/loongarch/helper.h
> @@ -104,10 +104,10 @@ DEF_HELPER_2(csrwr_estat, i64, env, tl)
>   DEF_HELPER_2(csrwr_asid, i64, env, tl)
>   DEF_HELPER_2(csrwr_tcfg, i64, env, tl)
>   DEF_HELPER_2(csrwr_ticlr, i64, env, tl)
> -DEF_HELPER_2(iocsrrd_b, i64, env, tl)
> -DEF_HELPER_2(iocsrrd_h, i64, env, tl)
> -DEF_HELPER_2(iocsrrd_w, i64, env, tl)
> -DEF_HELPER_2(iocsrrd_d, i64, env, tl)
> +DEF_HELPER_2(iocsrrd_b, tl, env, tl)
> +DEF_HELPER_2(iocsrrd_h, tl, env, tl)
> +DEF_HELPER_2(iocsrrd_w, tl, env, tl)
> +DEF_HELPER_2(iocsrrd_d, tl, env, tl)
>   DEF_HELPER_3(iocsrwr_b, void, env, tl, tl)
>   DEF_HELPER_3(iocsrwr_h, void, env, tl, tl)
>   DEF_HELPER_3(iocsrwr_w, void, env, tl, tl)
> diff --git a/target/loongarch/tcg/iocsr_helper.c b/target/loongarch/tcg/iocsr_helper.c
> index db30de2523fff01bcc8923eb12c7fca7bedca7bf..23d819de0ef9790eb82741f1e8a0e20dc139bf4b 100644
> --- a/target/loongarch/tcg/iocsr_helper.c
> +++ b/target/loongarch/tcg/iocsr_helper.c
> @@ -15,25 +15,25 @@
>   #define GET_MEMTXATTRS(cas) \
>           ((MemTxAttrs){.requester_id = env_cpu(cas)->cpu_index})
>   
> -uint64_t helper_iocsrrd_b(CPULoongArchState *env, target_ulong r_addr)
> +target_ulong helper_iocsrrd_b(CPULoongArchState *env, target_ulong r_addr)
>   {
>       return (int8_t)address_space_ldub(env->address_space_iocsr, r_addr,
>                                         GET_MEMTXATTRS(env), NULL);
>   }
>   
> -uint64_t helper_iocsrrd_h(CPULoongArchState *env, target_ulong r_addr)
> +target_ulong helper_iocsrrd_h(CPULoongArchState *env, target_ulong r_addr)
>   {
>       return (int16_t)address_space_lduw(env->address_space_iocsr, r_addr,
>                                          GET_MEMTXATTRS(env), NULL);
>   }
>   
> -uint64_t helper_iocsrrd_w(CPULoongArchState *env, target_ulong r_addr)
> +target_ulong helper_iocsrrd_w(CPULoongArchState *env, target_ulong r_addr)
>   {
>       return (int32_t)address_space_ldl(env->address_space_iocsr, r_addr,
>                                         GET_MEMTXATTRS(env), NULL);
>   }
>   
> -uint64_t helper_iocsrrd_d(CPULoongArchState *env, target_ulong r_addr)
> +target_ulong helper_iocsrrd_d(CPULoongArchState *env, target_ulong r_addr)
>   {
>       return address_space_ldq(env->address_space_iocsr, r_addr,
>                                GET_MEMTXATTRS(env), NULL);
> 

We could reduce code duplication adding address_space_ldn().

Anyhow, for this patch:
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>


Re: [PATCH v2 05/23] target/loongarch: Use target_ulong for iocsrrd helper results
Posted by Richard Henderson 3 months, 1 week ago
On 12/26/24 13:19, Jiaxun Yang wrote:
> Those results are all targeting TCGv values, which means they should
> be in target_ulong type.
> 
> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> ---
>   target/loongarch/helper.h           | 8 ++++----
>   target/loongarch/tcg/iocsr_helper.c | 8 ++++----
>   2 files changed, 8 insertions(+), 8 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~