target/mips: Introduce mo_endian() helper

Introduce mo_endian() which returns the endian MemOp
corresponding to the vCPU DisasContext.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Tested-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20241010215015.44326-10-philmd@linaro.org>
This commit is contained in:
Philippe Mathieu-Daudé 2024-09-26 18:40:58 +02:00
parent d74fbe0fbd
commit 96ccd8534f

View File

@ -240,6 +240,11 @@ static inline bool disas_is_bigendian(DisasContext *ctx)
return extract32(ctx->CP0_Config0, CP0C0_BE, 1);
}
static inline MemOp mo_endian(DisasContext *dc)
{
return disas_is_bigendian(dc) ? MO_BE : MO_LE;
}
static inline MemOp mo_endian_rev(DisasContext *dc, bool reversed)
{
return disas_is_bigendian(dc) ^ reversed ? MO_BE : MO_LE;