diff mbox series

[05/12] target/mips: Introduce mo_endian() helper

Message ID 20240930091101.40591-6-philmd@linaro.org (mailing list archive)
State New, archived
Headers show
Series target/mips: Remove target-specific endianness knowledge | expand

Commit Message

Philippe Mathieu-Daudé Sept. 30, 2024, 9:10 a.m. UTC
Introduce mo_endian() which returns the endian MemOp
corresponding to the vCPU DisasContext.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/mips/tcg/translate.h | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Richard Henderson Oct. 3, 2024, 10:56 p.m. UTC | #1
On 9/30/24 02:10, Philippe Mathieu-Daudé wrote:
> Introduce mo_endian() which returns the endian MemOp
> corresponding to the vCPU DisasContext.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   target/mips/tcg/translate.h | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/target/mips/tcg/translate.h b/target/mips/tcg/translate.h
> index 2b6646b339..54955437ef 100644
> --- a/target/mips/tcg/translate.h
> +++ b/target/mips/tcg/translate.h
> @@ -240,4 +240,9 @@ static inline bool cpu_is_bigendian(DisasContext *ctx)
>       return extract32(ctx->CP0_Config0, CP0C0_BE, 1);
>   }
>   
> +static inline MemOp mo_endian(DisasContext *dc)
> +{
> +    return cpu_is_bigendian(dc) ? MO_BE : MO_LE;
> +}

Based on patch 6, I think you'd better pass 'bool reversed' to this function.
Then

     disas_is_bigendian(dc) ^ reversed ? MO_BE : MO_LE;

r~
diff mbox series

Patch

diff --git a/target/mips/tcg/translate.h b/target/mips/tcg/translate.h
index 2b6646b339..54955437ef 100644
--- a/target/mips/tcg/translate.h
+++ b/target/mips/tcg/translate.h
@@ -240,4 +240,9 @@  static inline bool cpu_is_bigendian(DisasContext *ctx)
     return extract32(ctx->CP0_Config0, CP0C0_BE, 1);
 }
 
+static inline MemOp mo_endian(DisasContext *dc)
+{
+    return cpu_is_bigendian(dc) ? MO_BE : MO_LE;
+}
+
 #endif