target/mips: Remove target-specific endianness knowledge
cover target/mips: Remove target-specific endianness knowledge
Get vCPU endianness from CP0::BE bit.
Propagate endianness at the board level, using QOM property. Remove target-specific endianness knowledge from target/.
Philippe Mathieu-Daudé (12):
target/mips: Declare cpu_is_bigendian_env() in 'internal.h' target/mips: Introduce mo_endian_env() helper
target/mips: Replace MO_TE by mo_endian_env() in get_pte() target/mips: Convert mips16e decr_and_load/store() macros to functions target/mips: Introduce mo_endian() helper
target/mips: Explode MO_TExx -> MO_TE | MO_xx
target/mips: Replace MO_TE by mo_endian()
target/mips: Expose MIPSCPU::is_big_endian property hw/mips/cps: Set the vCPU 'cpu-big-endian' property hw/mips: Have mips_cpu_create_with_clock() take an endianness argument target/mips: Remove target-specific code in mips_cpu_reset_hold() hw/mips/malta: Remove TARGET_BIG_ENDIAN #ifdef'ry
include/hw/mips/cps.h | 1 + target/mips/cpu.h | 7 +- target/mips/internal.h | 11 ++ target/mips/tcg/translate.h | 5 + hw/mips/cps.c | 4 + hw/mips/fuloong2e.c | 2 +- hw/mips/jazz.c | 2 +- hw/mips/loongson3_virt.c | 2 +- hw/mips/malta.c | 9 +- hw/mips/mipssim.c | 2 +- target/mips/cpu.c | 17 ++- target/mips/tcg/ldst_helper.c | 15 +-- target/mips/tcg/msa_helper.c | 2 +- target/mips/tcg/mxu_translate.c | 18 ++-- target/mips/tcg/sysemu/tlb_helper.c | 2 +- target/mips/tcg/translate.c | 120 +++++++++++----------- target/mips/tcg/tx79_translate.c | 8 +- target/mips/tcg/micromips_translate.c.inc | 22 ++-- target/mips/tcg/mips16e_translate.c.inc | 109 ++++++++++---------- target/mips/tcg/nanomips_translate.c.inc | 32 +++--- 20 files changed, 212 insertions(+), 178 deletions(-)
Signature · 1 line
2.45.2
PATCH 1/12 target/mips: Declare cpu_is_bigendian_env() in 'internal.h'
In order to re-use cpu_is_bigendian(), declare it on "internal.h" after renaming it as cpu_is_bigendian_env().
--- target/mips/internal.h | 6 ++++++ target/mips/tcg/ldst_helper.c | 15 +++++---------- 2 files changed, 11 insertions(+), 10 deletions(-)
target/mips/internal.h +6 -0
@@ -9,6 +9,7 @@#define MIPS_INTERNAL_H #include "exec/memattrs.h" +#include "exec/memop.h" #ifdef CONFIG_TCG #include "tcg/tcg-internal.h" #endif
@@ -287,6 +288,11 @@ static inline int mips_vp_active(CPUMIPSState *env)return 1 ; } +static inline bool cpu_is_bigendian_env (CPUMIPSState *env) +{ +return extract32 (env->CP0_Config0,CP0C0_BE ,1 ); +} +static inline void compute_hflags (CPUMIPSState *env) { env->hflags &= ~(MIPS_HFLAG_COP1X | MIPS_HFLAG_64 | MIPS_HFLAG_CP0 |
target/mips/tcg/ldst_helper.c +5 -10
@@ -53,11 +53,6 @@ HELPER_LD_ATOMIC(lld, ldq, 0x7, (target_ulong))#endif /* !CONFIG_USER_ONLY */ -static inline bool cpu_is_bigendian (CPUMIPSState *env) -{ -return extract32 (env->CP0_Config0,CP0C0_BE ,1 ); -} -static inline target_ulong get_lmask (CPUMIPSState *env,target_ulong value,unsigned bits) {
@@ -65,7 +60,7 @@ static inline target_ulong get_lmask(CPUMIPSState *env, value &= mask; -if (!cpu_is_bigendian (env)) { +if (!cpu_is_bigendian_env (env)) { value ^= mask; }
@@ -76,7 +71,7 @@ void helper_swl(CPUMIPSState *env, target_ulong arg1, target_ulong arg2, int mem_idx) {target_ulong lmask =get_lmask (env, arg2,32 ); -int dir =cpu_is_bigendian (env) ?1 :-1 ; +int dir =cpu_is_bigendian_env (env) ?1 :-1 ;cpu_stb_mmuidx_ra (env, arg2, (uint8_t )(arg1 >>24 ), mem_idx,GETPC ());
@@ -100,7 +95,7 @@ void helper_swr(CPUMIPSState *env, target_ulong arg1, target_ulong arg2, int mem_idx) {target_ulong lmask =get_lmask (env, arg2,32 ); -int dir =cpu_is_bigendian (env) ?1 :-1 ; +int dir =cpu_is_bigendian_env (env) ?1 :-1 ;cpu_stb_mmuidx_ra (env, arg2, (uint8_t )arg1, mem_idx,GETPC ());
@@ -130,7 +125,7 @@ void helper_sdl(CPUMIPSState *env, target_ulong arg1, target_ulong arg2, int mem_idx) {target_ulong lmask =get_lmask (env, arg2,64 ); -int dir =cpu_is_bigendian (env) ?1 :-1 ; +int dir =cpu_is_bigendian_env (env) ?1 :-1 ;cpu_stb_mmuidx_ra (env, arg2, (uint8_t )(arg1 >>56 ), mem_idx,GETPC ());
@@ -174,7 +169,7 @@ void helper_sdr(CPUMIPSState *env, target_ulong arg1, target_ulong arg2, int mem_idx) {target_ulong lmask =get_lmask (env, arg2,64 ); -int dir =cpu_is_bigendian (env) ?1 :-1 ; +int dir =cpu_is_bigendian_env (env) ?1 :-1 ;cpu_stb_mmuidx_ra (env, arg2, (uint8_t )arg1, mem_idx,GETPC ());
Signature · 1 line
2.45.2
Re: [PATCH 01/12] target/mips: Declare cpu_is_bigendian_env() in 'internal.h'
Quoted 22 lines · Philippe Mathieu-Daudé
In order to re-use
cpu_is_bigendian(), declare it on "internal.h" after renaming it ascpu_is_bigendian_env().Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/mips/internal.h | 6 ++++++ target/mips/tcg/ldst_helper.c | 15 +++++---------- 2 files changed, 11 insertions(+), 10 deletions(-)target/mips/internal.h +1
-0@@ -9,6 +9,7 @@#define MIPS_INTERNAL_H #include "exec/memattrs.h" +#include "exec/memop.h" #ifdef CONFIG_TCG #include "tcg/tcg-internal.h" #endif
target/mips/internal.h static inline int mips_vp_active(CPUMIPSState *env) · line 294
Quoted 7 lines
target/mips/internal.h +4
-0@@ -287,6 +288,11 @@ static inline int mips_vp_active(CPUMIPSState *env)return 1 ; } +static inline bool cpu_is_bigendian_env (CPUMIPSState *env) +{ +return extract32 (env->CP0_Config0,CP0C0_BE ,1 ); +}
Using the cpu_is_bigendian name for DisasContext is the error I think.
r~
PATCH 2/12 target/mips: Introduce mo_endian_env() helper
In reply to Philippe Mathieu-DaudéIntroduce mo_endian_env() which returns the endian MemOp corresponding to the vCPU env.
--- target/mips/internal.h | 5 +++++ 1 file changed, 5 insertions(+)
target/mips/internal.h +5 -0
@@ -293,6 +293,11 @@ static inline bool cpu_is_bigendian_env(CPUMIPSState *env)return extract32 (env->CP0_Config0,CP0C0_BE ,1 ); } +static inline MemOp mo_endian_env (CPUMIPSState *env) +{ +return cpu_is_bigendian_env (env) ?MO_BE :MO_LE ; +} +static inline void compute_hflags (CPUMIPSState *env) { env->hflags &= ~(MIPS_HFLAG_COP1X | MIPS_HFLAG_64 | MIPS_HFLAG_CP0 |
Signature · 1 line
2.45.2
PATCH 3/12 target/mips: Replace MO_TE by mo_endian_env() in get_pte()
In reply to Philippe Mathieu-DaudéReplace compile-time MO_TE evaluation by runtime mo_endian_env() one, which expand target endianness from vCPU env.
--- target/mips/tcg/sysemu/tlb_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/mips/tcg/sysemu/tlb_helper.c +1 -1
@@ -601,7 +601,7 @@ static bool get_pte(CPUMIPSState *env, uint64_t vaddr, MemOp op,return false; } - oi =make_memop_idx (op |MO_TE , ptw_mmu_idx); + oi =make_memop_idx (op |mo_endian_env (env), ptw_mmu_idx);if (op ==MO_64 ) { *pte =cpu_ldq_mmu (env, vaddr, oi,0 ); }else {
Signature · 1 line
2.45.2
PATCH 4/12 target/mips: Convert mips16e decr_and_load/store() macros to functions
In reply to Philippe Mathieu-DaudéFunctions are easier to rework than macros. Besides, there is no gain here in inlining these.
--- target/mips/tcg/mips16e_translate.c.inc | 101 +++++++++++++----------- 1 file changed, 53 insertions(+), 48 deletions(-)
target/mips/tcg/mips16e_translate.c.inc +53 -48
@@ -122,11 +122,23 @@ enum { static int xlat(int r) { - static int map[] = { 16, 17, 2, 3, 4, 5, 6, 7 }; + static const int map[] = { 16, 17, 2, 3, 4, 5, 6, 7 }; return map[r]; } +static void decr_and_store(DisasContext *ctx, unsigned regidx, TCGv t0) +{ + TCGv t1 = tcg_temp_new(); + TCGv t2 = tcg_temp_new(); + + tcg_gen_movi_tl(t2, -4); + gen_op_addr_add(ctx, t0, t0, t2); + gen_load_gpr(t1, regidx); + tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, MO_TEUL | + ctx->default_tcg_memop_mask); +} + static void gen_mips16_save(DisasContext *ctx, int xsregs, int aregs, int do_ra, int do_s0, int do_s1,
@@ -196,46 +208,38 @@ static void gen_mips16_save(DisasContext *ctx, gen_load_gpr(t0, 29); -#define DECR_AND_STORE(reg) do { \ - tcg_gen_movi_tl(t2, -4); \ - gen_op_addr_add(ctx, t0, t0, t2); \ - gen_load_gpr(t1, reg); \ - tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, MO_TEUL | \ - ctx->default_tcg_memop_mask); \ - } while (0) - if (do_ra) { - DECR_AND_STORE(31); + decr_and_store(ctx, 31, t0); } switch (xsregs) { case 7: - DECR_AND_STORE(30); + decr_and_store(ctx, 30, t0); /* Fall through */ case 6: - DECR_AND_STORE(23); + decr_and_store(ctx, 23, t0); /* Fall through */ case 5: - DECR_AND_STORE(22); + decr_and_store(ctx, 22, t0); /* Fall through */ case 4: - DECR_AND_STORE(21); + decr_and_store(ctx, 21, t0); /* Fall through */ case 3: - DECR_AND_STORE(20); + decr_and_store(ctx, 20, t0); /* Fall through */ case 2: - DECR_AND_STORE(19); + decr_and_store(ctx, 19, t0); /* Fall through */ case 1: - DECR_AND_STORE(18); + decr_and_store(ctx, 18, t0); } if (do_s1) { - DECR_AND_STORE(17); + decr_and_store(ctx, 17, t0); } if (do_s0) { - DECR_AND_STORE(16); + decr_and_store(ctx, 16, t0); } switch (aregs) {
@@ -270,23 +274,34 @@ static void gen_mips16_save(DisasContext *ctx, } if (astatic > 0) { - DECR_AND_STORE(7); + decr_and_store(ctx, 7, t0); if (astatic > 1) { - DECR_AND_STORE(6); + decr_and_store(ctx, 6, t0); if (astatic > 2) { - DECR_AND_STORE(5); + decr_and_store(ctx, 5, t0); if (astatic > 3) { - DECR_AND_STORE(4); + decr_and_store(ctx, 4, t0); } } } } -#undef DECR_AND_STORE tcg_gen_movi_tl(t2, -framesize); gen_op_addr_add(ctx, cpu_gpr[29], cpu_gpr[29], t2); } +static void decr_and_load(DisasContext *ctx, unsigned regidx, TCGv t0) +{ + TCGv t1 = tcg_temp_new(); + TCGv t2 = tcg_temp_new(); + + tcg_gen_movi_tl(t2, -4); + gen_op_addr_add(ctx, t0, t0, t2); + tcg_gen_qemu_ld_tl(t1, t0, ctx->mem_idx, MO_TESL | + ctx->default_tcg_memop_mask); + gen_store_gpr(t1, regidx); +} + static void gen_mips16_restore(DisasContext *ctx, int xsregs, int aregs, int do_ra, int do_s0, int do_s1,
@@ -294,52 +309,43 @@ static void gen_mips16_restore(DisasContext *ctx, { int astatic; TCGv t0 = tcg_temp_new(); - TCGv t1 = tcg_temp_new(); TCGv t2 = tcg_temp_new(); tcg_gen_movi_tl(t2, framesize); gen_op_addr_add(ctx, t0, cpu_gpr[29], t2); -#define DECR_AND_LOAD(reg) do { \ - tcg_gen_movi_tl(t2, -4); \ - gen_op_addr_add(ctx, t0, t0, t2); \ - tcg_gen_qemu_ld_tl(t1, t0, ctx->mem_idx, MO_TESL | \ - ctx->default_tcg_memop_mask); \ - gen_store_gpr(t1, reg); \ - } while (0) - if (do_ra) { - DECR_AND_LOAD(31); + decr_and_load(ctx, 31, t0); } switch (xsregs) { case 7: - DECR_AND_LOAD(30); + decr_and_load(ctx, 30, t0); /* Fall through */ case 6: - DECR_AND_LOAD(23); + decr_and_load(ctx, 23, t0); /* Fall through */ case 5: - DECR_AND_LOAD(22); + decr_and_load(ctx, 22, t0); /* Fall through */ case 4: - DECR_AND_LOAD(21); + decr_and_load(ctx, 21, t0); /* Fall through */ case 3: - DECR_AND_LOAD(20); + decr_and_load(ctx, 20, t0); /* Fall through */ case 2: - DECR_AND_LOAD(19); + decr_and_load(ctx, 19, t0); /* Fall through */ case 1: - DECR_AND_LOAD(18); + decr_and_load(ctx, 18, t0); } if (do_s1) { - DECR_AND_LOAD(17); + decr_and_load(ctx, 17, t0); } if (do_s0) { - DECR_AND_LOAD(16); + decr_and_load(ctx, 16, t0); } switch (aregs) {
@@ -374,18 +380,17 @@ static void gen_mips16_restore(DisasContext *ctx, } if (astatic > 0) { - DECR_AND_LOAD(7); + decr_and_load(ctx, 7, t0); if (astatic > 1) { - DECR_AND_LOAD(6); + decr_and_load(ctx, 6, t0); if (astatic > 2) { - DECR_AND_LOAD(5); + decr_and_load(ctx, 5, t0); if (astatic > 3) { - DECR_AND_LOAD(4); + decr_and_load(ctx, 4, t0); } } } } -#undef DECR_AND_LOAD tcg_gen_movi_tl(t2, framesize); gen_op_addr_add(ctx, cpu_gpr[29], cpu_gpr[29], t2);
Signature · 1 line
2.45.2
Re: [PATCH 04/12] target/mips: Convert mips16e decr_and_load/store() macros to functions
Quoted 19 lines · Philippe Mathieu-Daudé
Functions are easier to rework than macros. Besides, there is no gain here in inlining these.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/mips/tcg/mips16e_translate.c.inc | 101 +++++++++++++----------- 1 file changed, 53 insertions(+), 48 deletions(-)target/mips/tcg/mips16e_translate.c.inc +1
-1@@ -122,11 +122,23 @@ enum { static int xlat(int r) { - static int map[] = { 16, 17, 2, 3, 4, 5, 6, 7 }; + static const int map[] = { 16, 17, 2, 3, 4, 5, 6, 7 };
target/mips/tcg/mips16e_translate.c.inc enum { · line 136
Quoted 10 lines
target/mips/tcg/mips16e_translate.c.inc +7
-0return map[r]; } +static void decr_and_store(DisasContext *ctx, unsigned regidx, TCGv t0) +{ + TCGv t1 = tcg_temp_new(); + TCGv t2 = tcg_temp_new(); + + tcg_gen_movi_tl(t2, -4); + gen_op_addr_add(ctx, t0, t0, t2);
Code movement, so:
However, for cleanup, pass tcg_constant_tl(-4) instead of moving -4 into t2.
r~
PATCH 5/12 target/mips: Introduce mo_endian() helper
In reply to Philippe Mathieu-DaudéIntroduce mo_endian() which returns the endian MemOp corresponding to the vCPU DisasContext.
--- target/mips/tcg/translate.h | 5 +++++ 1 file changed, 5 insertions(+)
target/mips/tcg/translate.h +5 -0
@@ -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
Signature · 1 line
2.45.2
Re: [PATCH 05/12] target/mips: Introduce mo_endian() helper
Quoted 13 lines · Philippe Mathieu-Daudé
Introduce
mo_endian()which returns the endian MemOp corresponding to the vCPU DisasContext.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/mips/tcg/translate.h | 5 +++++ 1 file changed, 5 insertions(+)target/mips/tcg/translate.h +0
-0
target/mips/tcg/translate.h static inline bool cpu_is_bigendian(DisasContext *ctx) · line 246
Quoted 7 lines
target/mips/tcg/translate.h +4
-0@@ -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~
PATCH 6/12 target/mips: Explode MO_TExx -> MO_TE | MO_xx
In reply to Philippe Mathieu-DaudéExtract the implicit MO_TE definition in order to replace it by runtime variable in the next commit.
Mechanical change using:
$ for n in UW UL UQ UO SW SL SQ; do \
sed -i -e "s/MO_TE$n/MO_TE | MO_$n/" \
$(git grep -l MO_TE$n target/mips); \
done--- target/mips/tcg/mxu_translate.c | 8 +- target/mips/tcg/translate.c | 120 +++++++++++----------- target/mips/tcg/tx79_translate.c | 8 +- target/mips/tcg/micromips_translate.c.inc | 22 ++-- target/mips/tcg/mips16e_translate.c.inc | 12 +-- target/mips/tcg/nanomips_translate.c.inc | 32 +++--- 6 files changed, 101 insertions(+), 101 deletions(-)
target/mips/tcg/mxu_translate.c +4 -4
@@ -1533,7 +1533,7 @@ static void gen_mxu_s32ldxx(DisasContext *ctx, bool reversed, bool postinc)tcg_gen_add_tl (t0, t0, t1);tcg_gen_qemu_ld_tl (t1, t0, ctx->mem_idx, - (MO_TESL ^ (reversed ?MO_BSWAP :0 )) | + (MO_TE |MO_SL ^ (reversed ?MO_BSWAP :0 )) | ctx->default_tcg_memop_mask);gen_store_mxu_gpr (t1, XRa);
@@ -1569,7 +1569,7 @@ static void gen_mxu_s32stxx(DisasContext *ctx, bool reversed, bool postinc)gen_load_mxu_gpr (t1, XRa);tcg_gen_qemu_st_tl (t1, t0, ctx->mem_idx, - (MO_TESL ^ (reversed ?MO_BSWAP :0 )) | + (MO_TE |MO_SL ^ (reversed ?MO_BSWAP :0 )) | ctx->default_tcg_memop_mask);if (postinc) {
@@ -1605,7 +1605,7 @@ static void gen_mxu_s32ldxvx(DisasContext *ctx, bool reversed,tcg_gen_add_tl (t0, t0, t1);tcg_gen_qemu_ld_tl (t1, t0, ctx->mem_idx, - (MO_TESL ^ (reversed ?MO_BSWAP :0 )) | + (MO_TE |MO_SL ^ (reversed ?MO_BSWAP :0 )) | ctx->default_tcg_memop_mask);gen_store_mxu_gpr (t1, XRa);
@@ -1675,7 +1675,7 @@ static void gen_mxu_s32stxvx(DisasContext *ctx, bool reversed,gen_load_mxu_gpr (t1, XRa);tcg_gen_qemu_st_tl (t1, t0, ctx->mem_idx, - (MO_TESL ^ (reversed ?MO_BSWAP :0 )) | + (MO_TE |MO_SL ^ (reversed ?MO_BSWAP :0 )) | ctx->default_tcg_memop_mask);if (postinc) {
target/mips/tcg/translate.c +60 -60
451 lines not on this page · raw message
target/mips/tcg/tx79_translate.c +4 -4
@@ -340,12 +340,12 @@ static bool trans_LQ(DisasContext *ctx, arg_i *a)tcg_gen_andi_tl (addr, addr, ~0xf );/* Lower half */ -tcg_gen_qemu_ld_i64 (t0, addr, ctx->mem_idx,MO_TEUQ ); +tcg_gen_qemu_ld_i64 (t0, addr, ctx->mem_idx,MO_TE |MO_UQ );gen_store_gpr (t0, a->rt);/* Upper half */ tcg_gen_addi_i64 (addr, addr,8 ); -tcg_gen_qemu_ld_i64 (t0, addr, ctx->mem_idx,MO_TEUQ ); +tcg_gen_qemu_ld_i64 (t0, addr, ctx->mem_idx,MO_TE |MO_UQ );gen_store_gpr_hi (t0, a->rt);return true; }
@@ -364,12 +364,12 @@ static bool trans_SQ(DisasContext *ctx, arg_i *a)/* Lower half */ gen_load_gpr (t0, a->rt); -tcg_gen_qemu_st_i64 (t0, addr, ctx->mem_idx,MO_TEUQ ); +tcg_gen_qemu_st_i64 (t0, addr, ctx->mem_idx,MO_TE |MO_UQ );/* Upper half */ tcg_gen_addi_i64 (addr, addr,8 );gen_load_gpr_hi (t0, a->rt); -tcg_gen_qemu_st_i64 (t0, addr, ctx->mem_idx,MO_TEUQ ); +tcg_gen_qemu_st_i64 (t0, addr, ctx->mem_idx,MO_TE |MO_UQ );return true; }
target/mips/tcg/micromips_translate.c.inc +11 -11
@@ -977,23 +977,23 @@ static void gen_ldst_pair(DisasContext *ctx, uint32_t opc, int rd, gen_reserved_instruction(ctx); return; } - tcg_gen_qemu_ld_tl(t1, t0, ctx->mem_idx, MO_TESL | + tcg_gen_qemu_ld_tl(t1, t0, ctx->mem_idx, MO_TE | MO_SL | ctx->default_tcg_memop_mask); gen_store_gpr(t1, rd); tcg_gen_movi_tl(t1, 4); gen_op_addr_add(ctx, t0, t0, t1); - tcg_gen_qemu_ld_tl(t1, t0, ctx->mem_idx, MO_TESL | + tcg_gen_qemu_ld_tl(t1, t0, ctx->mem_idx, MO_TE | MO_SL | ctx->default_tcg_memop_mask); gen_store_gpr(t1, rd + 1); break; case SWP: gen_load_gpr(t1, rd); - tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, MO_TEUL | + tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, MO_TE | MO_UL | ctx->default_tcg_memop_mask); tcg_gen_movi_tl(t1, 4); gen_op_addr_add(ctx, t0, t0, t1); gen_load_gpr(t1, rd + 1); - tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, MO_TEUL | + tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, MO_TE | MO_UL | ctx->default_tcg_memop_mask); break; #ifdef TARGET_MIPS64
@@ -1002,23 +1002,23 @@ static void gen_ldst_pair(DisasContext *ctx, uint32_t opc, int rd, gen_reserved_instruction(ctx); return; } - tcg_gen_qemu_ld_tl(t1, t0, ctx->mem_idx, MO_TEUQ | + tcg_gen_qemu_ld_tl(t1, t0, ctx->mem_idx, MO_TE | MO_UQ | ctx->default_tcg_memop_mask); gen_store_gpr(t1, rd); tcg_gen_movi_tl(t1, 8); gen_op_addr_add(ctx, t0, t0, t1); - tcg_gen_qemu_ld_tl(t1, t0, ctx->mem_idx, MO_TEUQ | + tcg_gen_qemu_ld_tl(t1, t0, ctx->mem_idx, MO_TE | MO_UQ | ctx->default_tcg_memop_mask); gen_store_gpr(t1, rd + 1); break; case SDP: gen_load_gpr(t1, rd); - tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, MO_TEUQ | + tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, MO_TE | MO_UQ | ctx->default_tcg_memop_mask); tcg_gen_movi_tl(t1, 8); gen_op_addr_add(ctx, t0, t0, t1); gen_load_gpr(t1, rd + 1); - tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, MO_TEUQ | + tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, MO_TE | MO_UQ | ctx->default_tcg_memop_mask); break; #endif
@@ -2572,13 +2572,13 @@ static void decode_micromips32_opc(CPUMIPSState *env, DisasContext *ctx) gen_st(ctx, mips32_op, rt, rs, offset); break; case SC: - gen_st_cond(ctx, rt, rs, offset, MO_TESL, false); + gen_st_cond(ctx, rt, rs, offset, MO_TE | MO_SL, false); break; #if defined(TARGET_MIPS64) case SCD: check_insn(ctx, ISA_MIPS3); check_mips_64(ctx); - gen_st_cond(ctx, rt, rs, offset, MO_TEUQ, false); + gen_st_cond(ctx, rt, rs, offset, MO_TE | MO_UQ, false); break; #endif case LD_EVA:
@@ -2659,7 +2659,7 @@ static void decode_micromips32_opc(CPUMIPSState *env, DisasContext *ctx) mips32_op = OPC_SHE; goto do_st_lr; case SCE: - gen_st_cond(ctx, rt, rs, offset, MO_TESL, true); + gen_st_cond(ctx, rt, rs, offset, MO_TE | MO_SL, true); break; case SWE: mips32_op = OPC_SWE;
target/mips/tcg/mips16e_translate.c.inc +6 -6
@@ -135,7 +135,7 @@ static void decr_and_store(DisasContext *ctx, unsigned regidx, TCGv t0) tcg_gen_movi_tl(t2, -4); gen_op_addr_add(ctx, t0, t0, t2); gen_load_gpr(t1, regidx); - tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, MO_TEUL | + tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, MO_TE | MO_UL | ctx->default_tcg_memop_mask); }
@@ -184,25 +184,25 @@ static void gen_mips16_save(DisasContext *ctx, case 4: gen_base_offset_addr(ctx, t0, 29, 12); gen_load_gpr(t1, 7); - tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, MO_TEUL | + tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, MO_TE | MO_UL | ctx->default_tcg_memop_mask); /* Fall through */ case 3: gen_base_offset_addr(ctx, t0, 29, 8); gen_load_gpr(t1, 6); - tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, MO_TEUL | + tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, MO_TE | MO_UL | ctx->default_tcg_memop_mask); /* Fall through */ case 2: gen_base_offset_addr(ctx, t0, 29, 4); gen_load_gpr(t1, 5); - tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, MO_TEUL | + tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, MO_TE | MO_UL | ctx->default_tcg_memop_mask); /* Fall through */ case 1: gen_base_offset_addr(ctx, t0, 29, 0); gen_load_gpr(t1, 4); - tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, MO_TEUL | + tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, MO_TE | MO_UL | ctx->default_tcg_memop_mask); }
@@ -297,7 +297,7 @@ static void decr_and_load(DisasContext *ctx, unsigned regidx, TCGv t0) tcg_gen_movi_tl(t2, -4); gen_op_addr_add(ctx, t0, t0, t2); - tcg_gen_qemu_ld_tl(t1, t0, ctx->mem_idx, MO_TESL | + tcg_gen_qemu_ld_tl(t1, t0, ctx->mem_idx, MO_TE | MO_SL | ctx->default_tcg_memop_mask); gen_store_gpr(t1, regidx); }
target/mips/tcg/nanomips_translate.c.inc +16 -16
@@ -998,7 +998,7 @@ static void gen_llwp(DisasContext *ctx, uint32_t base, int16_t offset, TCGv tmp2 = tcg_temp_new(); gen_base_offset_addr(ctx, taddr, base, offset); - tcg_gen_qemu_ld_i64(tval, taddr, ctx->mem_idx, MO_TEUQ | MO_ALIGN); + tcg_gen_qemu_ld_i64(tval, taddr, ctx->mem_idx, MO_TE | MO_UQ | MO_ALIGN); if (cpu_is_bigendian(ctx)) { tcg_gen_extr_i64_tl(tmp2, tmp1, tval); } else {
@@ -1075,7 +1075,7 @@ static void gen_save(DisasContext *ctx, uint8_t rt, uint8_t count, gen_base_offset_addr(ctx, va, 29, this_offset); gen_load_gpr(t0, this_rt); tcg_gen_qemu_st_tl(t0, va, ctx->mem_idx, - (MO_TEUL | ctx->default_tcg_memop_mask)); + (MO_TE | MO_UL | ctx->default_tcg_memop_mask)); counter++; }
@@ -1095,7 +1095,7 @@ static void gen_restore(DisasContext *ctx, uint8_t rt, uint8_t count, int this_rt = use_gp ? 28 : (rt & 0x10) | ((rt + counter) & 0x1f); int this_offset = u - ((counter + 1) << 2); gen_base_offset_addr(ctx, va, 29, this_offset); - tcg_gen_qemu_ld_tl(t0, va, ctx->mem_idx, MO_TESL | + tcg_gen_qemu_ld_tl(t0, va, ctx->mem_idx, MO_TE | MO_SL | ctx->default_tcg_memop_mask); tcg_gen_ext32s_tl(t0, t0); gen_store_gpr(t0, this_rt);
@@ -2647,13 +2647,13 @@ static void gen_p_lsx(DisasContext *ctx, int rd, int rs, int rt) case NM_LHX: /*case NM_LHXS:*/ tcg_gen_qemu_ld_tl(t0, t0, ctx->mem_idx, - MO_TESW | ctx->default_tcg_memop_mask); + MO_TE | MO_SW | ctx->default_tcg_memop_mask); gen_store_gpr(t0, rd); break; case NM_LWX: /*case NM_LWXS:*/ tcg_gen_qemu_ld_tl(t0, t0, ctx->mem_idx, - MO_TESL | ctx->default_tcg_memop_mask); + MO_TE | MO_SL | ctx->default_tcg_memop_mask); gen_store_gpr(t0, rd); break; case NM_LBUX:
@@ -2663,7 +2663,7 @@ static void gen_p_lsx(DisasContext *ctx, int rd, int rs, int rt) case NM_LHUX: /*case NM_LHUXS:*/ tcg_gen_qemu_ld_tl(t0, t0, ctx->mem_idx, - MO_TEUW | ctx->default_tcg_memop_mask); + MO_TE | MO_UW | ctx->default_tcg_memop_mask); gen_store_gpr(t0, rd); break; case NM_SBX:
@@ -2676,14 +2676,14 @@ static void gen_p_lsx(DisasContext *ctx, int rd, int rs, int rt) check_nms(ctx); gen_load_gpr(t1, rd); tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, - MO_TEUW | ctx->default_tcg_memop_mask); + MO_TE | MO_UW | ctx->default_tcg_memop_mask); break; case NM_SWX: /*case NM_SWXS:*/ check_nms(ctx); gen_load_gpr(t1, rd); tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, - MO_TEUL | ctx->default_tcg_memop_mask); + MO_TE | MO_UL | ctx->default_tcg_memop_mask); break; case NM_LWC1X: /*case NM_LWC1XS:*/
@@ -3737,7 +3737,7 @@ static int decode_nanomips_32_48_opc(CPUMIPSState *env, DisasContext *ctx) tcg_gen_movi_tl(t0, addr); tcg_gen_qemu_ld_tl(cpu_gpr[rt], t0, ctx->mem_idx, - MO_TESL | ctx->default_tcg_memop_mask); + MO_TE | MO_SL | ctx->default_tcg_memop_mask); } break; case NM_SWPC48:
@@ -3754,7 +3754,7 @@ static int decode_nanomips_32_48_opc(CPUMIPSState *env, DisasContext *ctx) gen_load_gpr(t1, rt); tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, - MO_TEUL | ctx->default_tcg_memop_mask); + MO_TE | MO_UL | ctx->default_tcg_memop_mask); } break; default:
@@ -4132,13 +4132,13 @@ static int decode_nanomips_32_48_opc(CPUMIPSState *env, DisasContext *ctx) switch (extract32(ctx->opcode, 11, 4)) { case NM_UALH: - tcg_gen_qemu_ld_tl(t0, t0, ctx->mem_idx, MO_TESW | + tcg_gen_qemu_ld_tl(t0, t0, ctx->mem_idx, MO_TE | MO_SW | MO_UNALN); gen_store_gpr(t0, rt); break; case NM_UASH: gen_load_gpr(t1, rt); - tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, MO_TEUW | + tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, MO_TE | MO_UW | MO_UNALN); break; }
@@ -4161,7 +4161,7 @@ static int decode_nanomips_32_48_opc(CPUMIPSState *env, DisasContext *ctx) case NM_P_SC: switch (ctx->opcode & 0x03) { case NM_SC: - gen_st_cond(ctx, rt, rs, s, MO_TESL, false); + gen_st_cond(ctx, rt, rs, s, MO_TE | MO_SL, false); break; case NM_SCWP: check_xnp(ctx);
@@ -4274,7 +4274,7 @@ static int decode_nanomips_32_48_opc(CPUMIPSState *env, DisasContext *ctx) check_xnp(ctx); check_eva(ctx); check_cp0_enabled(ctx); - gen_st_cond(ctx, rt, rs, s, MO_TESL, true); + gen_st_cond(ctx, rt, rs, s, MO_TE | MO_SL, true); break; case NM_SCWPE: check_xnp(ctx);
@@ -4317,7 +4317,7 @@ static int decode_nanomips_32_48_opc(CPUMIPSState *env, DisasContext *ctx) switch (extract32(ctx->opcode, 11, 1)) { case NM_LWM: tcg_gen_qemu_ld_tl(t1, va, ctx->mem_idx, - memop | MO_TESL); + memop | MO_TE | MO_SL); gen_store_gpr(t1, this_rt); if ((this_rt == rs) && (counter != (count - 1))) {
@@ -4328,7 +4328,7 @@ static int decode_nanomips_32_48_opc(CPUMIPSState *env, DisasContext *ctx) this_rt = (rt == 0) ? 0 : this_rt; gen_load_gpr(t1, this_rt); tcg_gen_qemu_st_tl(t1, va, ctx->mem_idx, - memop | MO_TEUL); + memop | MO_TE | MO_UL); break; } counter++;
Signature · 1 line
2.45.2
Re: [PATCH 06/12] target/mips: Explode MO_TExx -> MO_TE | MO_xx
Quoted 26 lines · Philippe Mathieu-Daudé
Extract the implicit
MO_TEdefinition in order to replace it by runtime variable in the next commit.Mechanical change using:
$ for n in UW UL UQ UO SW SL SQ; do \ sed -i -e "s/MO_TE$n/MO_TE | MO_$n/" \ $(git grep -l MO_TE$n target/mips); \ doneSigned-off-by Philippe Mathieu-Daudé <[email protected]>--- target/mips/tcg/mxu_translate.c | 8 +- target/mips/tcg/translate.c | 120 +++++++++++----------- target/mips/tcg/tx79_translate.c | 8 +- target/mips/tcg/micromips_translate.c.inc | 22 ++-- target/mips/tcg/mips16e_translate.c.inc | 12 +-- target/mips/tcg/nanomips_translate.c.inc | 32 +++--- 6 files changed, 101 insertions(+), 101 deletions(-)target/mips/tcg/mxu_translate.c +0
-0
target/mips/tcg/mxu_translate.c static void gen_mxu_s32ldxx(DisasContext *ctx, bool reversed, bool postinc) · line 1536
Quoted 5 lines
target/mips/tcg/mxu_translate.c +1
-1@@ -1533,7 +1533,7 @@ static void gen_mxu_s32ldxx(DisasContext *ctx, bool reversed, bool postinc)tcg_gen_add_tl (t0, t0, t1); tcg_gen_qemu_ld_tl(t1, t0, ctx->mem_idx, - (MO_TESL ^ (reversed ? MO_BSWAP : 0)) | + (MO_TE | MO_SL ^ (reversed ? MO_BSWAP : 0)) |
Hmm either I need to use parenthesis here or swap the arguments.
Quoted 29 lines
target/mips/tcg/mxu_translate.c +3
-3ctx->default_tcg_memop_mask);gen_store_mxu_gpr (t1, XRa);@@ -1569,7 +1569,7 @@ static void gen_mxu_s32stxx(DisasContext *ctx, bool reversed, bool postinc)gen_load_mxu_gpr (t1, XRa);tcg_gen_qemu_st_tl (t1, t0, ctx->mem_idx, - (MO_TESL ^ (reversed ?MO_BSWAP :0 )) | + (MO_TE |MO_SL ^ (reversed ?MO_BSWAP :0 )) | ctx->default_tcg_memop_mask);if (postinc) {@@ -1605,7 +1605,7 @@ static void gen_mxu_s32ldxvx(DisasContext *ctx, bool reversed,tcg_gen_add_tl (t0, t0, t1);tcg_gen_qemu_ld_tl (t1, t0, ctx->mem_idx, - (MO_TESL ^ (reversed ?MO_BSWAP :0 )) | + (MO_TE |MO_SL ^ (reversed ?MO_BSWAP :0 )) | ctx->default_tcg_memop_mask);gen_store_mxu_gpr (t1, XRa);@@ -1675,7 +1675,7 @@ static void gen_mxu_s32stxvx(DisasContext *ctx, bool reversed,gen_load_mxu_gpr (t1, XRa);tcg_gen_qemu_st_tl (t1, t0, ctx->mem_idx, - (MO_TESL ^ (reversed ?MO_BSWAP :0 )) | + (MO_TE |MO_SL ^ (reversed ?MO_BSWAP :0 )) | ctx->default_tcg_memop_mask);
PATCH 7/12 target/mips: Replace MO_TE by mo_endian()
In reply to Philippe Mathieu-DaudéReplace compile-time MO_TE evaluation by runtime mo_endian() one, which expand target endianness from DisasContext.
Mechanical change using:
$ sed -i -e 's/MO_TE/mo_endian(ctx)/' \
$(git grep -l MO_TE target/mips)--- target/mips/tcg/msa_helper.c | 2 +- target/mips/tcg/mxu_translate.c | 18 ++-- target/mips/tcg/translate.c | 120 +++++++++++----------- target/mips/tcg/tx79_translate.c | 8 +- target/mips/tcg/micromips_translate.c.inc | 22 ++-- target/mips/tcg/mips16e_translate.c.inc | 12 +-- target/mips/tcg/nanomips_translate.c.inc | 32 +++--- 7 files changed, 107 insertions(+), 107 deletions(-)
target/mips/tcg/msa_helper.c +1 -1
@@ -8213,7 +8213,7 @@ void helper_msa_ffint_u_df(CPUMIPSState *env, uint32_t df, uint32_t wd,#if !defined(CONFIG_USER_ONLY )#define MEMOP_IDX (DF ) \ - MemOpIdx oi = make_memop_idx(MO_TE | DF | MO_UNALN, \ + MemOpIdx oi = make_memop_idx(mo_endian(dc) | DF | MO_UNALN, \ mips_env_mmu_index(env));#else #define MEMOP_IDX (DF )
target/mips/tcg/mxu_translate.c +9 -9
@@ -1533,7 +1533,7 @@ static void gen_mxu_s32ldxx(DisasContext *ctx, bool reversed, bool postinc)tcg_gen_add_tl (t0, t0, t1);tcg_gen_qemu_ld_tl (t1, t0, ctx->mem_idx, - (MO_TE |MO_SL ^ (reversed ?MO_BSWAP :0 )) | + ((mo_endian (ctx) |MO_SL ) ^ (reversed ?MO_BSWAP :0 )) | ctx->default_tcg_memop_mask);gen_store_mxu_gpr (t1, XRa);
@@ -1569,7 +1569,7 @@ static void gen_mxu_s32stxx(DisasContext *ctx, bool reversed, bool postinc)gen_load_mxu_gpr (t1, XRa);tcg_gen_qemu_st_tl (t1, t0, ctx->mem_idx, - (MO_TE |MO_SL ^ (reversed ?MO_BSWAP :0 )) | + ((mo_endian (ctx) |MO_SL ) ^ (reversed ?MO_BSWAP :0 )) | ctx->default_tcg_memop_mask);if (postinc) {
@@ -1605,7 +1605,7 @@ static void gen_mxu_s32ldxvx(DisasContext *ctx, bool reversed,tcg_gen_add_tl (t0, t0, t1);tcg_gen_qemu_ld_tl (t1, t0, ctx->mem_idx, - (MO_TE |MO_SL ^ (reversed ?MO_BSWAP :0 )) | + ((mo_endian (ctx) |MO_SL ) ^ (reversed ?MO_BSWAP :0 )) | ctx->default_tcg_memop_mask);gen_store_mxu_gpr (t1, XRa);
@@ -1675,7 +1675,7 @@ static void gen_mxu_s32stxvx(DisasContext *ctx, bool reversed,gen_load_mxu_gpr (t1, XRa);tcg_gen_qemu_st_tl (t1, t0, ctx->mem_idx, - (MO_TE |MO_SL ^ (reversed ?MO_BSWAP :0 )) | + ((mo_endian (ctx) |MO_SL ) ^ (reversed ?MO_BSWAP :0 )) | ctx->default_tcg_memop_mask);if (postinc) {
@@ -4803,19 +4803,19 @@ static void decode_opc_mxu__pool17(DisasContext *ctx)switch (opcode) {case OPC_MXU_LXW : -gen_mxu_lxx (ctx, strd2,MO_TE |MO_UL ); +gen_mxu_lxx (ctx, strd2,mo_endian (ctx) |MO_UL );break ;case OPC_MXU_LXB : -gen_mxu_lxx (ctx, strd2,MO_TE |MO_SB ); +gen_mxu_lxx (ctx, strd2,mo_endian (ctx) |MO_SB );break ;case OPC_MXU_LXH : -gen_mxu_lxx (ctx, strd2,MO_TE |MO_SW ); +gen_mxu_lxx (ctx, strd2,mo_endian (ctx) |MO_SW );break ;case OPC_MXU_LXBU : -gen_mxu_lxx (ctx, strd2,MO_TE |MO_UB ); +gen_mxu_lxx (ctx, strd2,mo_endian (ctx) |MO_UB );break ;case OPC_MXU_LXHU : -gen_mxu_lxx (ctx, strd2,MO_TE |MO_UW ); +gen_mxu_lxx (ctx, strd2,mo_endian (ctx) |MO_UW );break ;default :MIPS_INVAL ("decode_opc_mxu" );
target/mips/tcg/translate.c +60 -60
451 lines not on this page · raw message
target/mips/tcg/tx79_translate.c +4 -4
@@ -340,12 +340,12 @@ static bool trans_LQ(DisasContext *ctx, arg_i *a)tcg_gen_andi_tl (addr, addr, ~0xf );/* Lower half */ -tcg_gen_qemu_ld_i64 (t0, addr, ctx->mem_idx,MO_TE |MO_UQ ); +tcg_gen_qemu_ld_i64 (t0, addr, ctx->mem_idx,mo_endian (ctx) |MO_UQ );gen_store_gpr (t0, a->rt);/* Upper half */ tcg_gen_addi_i64 (addr, addr,8 ); -tcg_gen_qemu_ld_i64 (t0, addr, ctx->mem_idx,MO_TE |MO_UQ ); +tcg_gen_qemu_ld_i64 (t0, addr, ctx->mem_idx,mo_endian (ctx) |MO_UQ );gen_store_gpr_hi (t0, a->rt);return true; }
@@ -364,12 +364,12 @@ static bool trans_SQ(DisasContext *ctx, arg_i *a)/* Lower half */ gen_load_gpr (t0, a->rt); -tcg_gen_qemu_st_i64 (t0, addr, ctx->mem_idx,MO_TE |MO_UQ ); +tcg_gen_qemu_st_i64 (t0, addr, ctx->mem_idx,mo_endian (ctx) |MO_UQ );/* Upper half */ tcg_gen_addi_i64 (addr, addr,8 );gen_load_gpr_hi (t0, a->rt); -tcg_gen_qemu_st_i64 (t0, addr, ctx->mem_idx,MO_TE |MO_UQ ); +tcg_gen_qemu_st_i64 (t0, addr, ctx->mem_idx,mo_endian (ctx) |MO_UQ );return true; }
target/mips/tcg/micromips_translate.c.inc +11 -11
@@ -977,23 +977,23 @@ static void gen_ldst_pair(DisasContext *ctx, uint32_t opc, int rd, gen_reserved_instruction(ctx); return; } - tcg_gen_qemu_ld_tl(t1, t0, ctx->mem_idx, MO_TE | MO_SL | + tcg_gen_qemu_ld_tl(t1, t0, ctx->mem_idx, mo_endian(ctx) | MO_SL | ctx->default_tcg_memop_mask); gen_store_gpr(t1, rd); tcg_gen_movi_tl(t1, 4); gen_op_addr_add(ctx, t0, t0, t1); - tcg_gen_qemu_ld_tl(t1, t0, ctx->mem_idx, MO_TE | MO_SL | + tcg_gen_qemu_ld_tl(t1, t0, ctx->mem_idx, mo_endian(ctx) | MO_SL | ctx->default_tcg_memop_mask); gen_store_gpr(t1, rd + 1); break; case SWP: gen_load_gpr(t1, rd); - tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, MO_TE | MO_UL | + tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, mo_endian(ctx) | MO_UL | ctx->default_tcg_memop_mask); tcg_gen_movi_tl(t1, 4); gen_op_addr_add(ctx, t0, t0, t1); gen_load_gpr(t1, rd + 1); - tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, MO_TE | MO_UL | + tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, mo_endian(ctx) | MO_UL | ctx->default_tcg_memop_mask); break; #ifdef TARGET_MIPS64
@@ -1002,23 +1002,23 @@ static void gen_ldst_pair(DisasContext *ctx, uint32_t opc, int rd, gen_reserved_instruction(ctx); return; } - tcg_gen_qemu_ld_tl(t1, t0, ctx->mem_idx, MO_TE | MO_UQ | + tcg_gen_qemu_ld_tl(t1, t0, ctx->mem_idx, mo_endian(ctx) | MO_UQ | ctx->default_tcg_memop_mask); gen_store_gpr(t1, rd); tcg_gen_movi_tl(t1, 8); gen_op_addr_add(ctx, t0, t0, t1); - tcg_gen_qemu_ld_tl(t1, t0, ctx->mem_idx, MO_TE | MO_UQ | + tcg_gen_qemu_ld_tl(t1, t0, ctx->mem_idx, mo_endian(ctx) | MO_UQ | ctx->default_tcg_memop_mask); gen_store_gpr(t1, rd + 1); break; case SDP: gen_load_gpr(t1, rd); - tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, MO_TE | MO_UQ | + tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, mo_endian(ctx) | MO_UQ | ctx->default_tcg_memop_mask); tcg_gen_movi_tl(t1, 8); gen_op_addr_add(ctx, t0, t0, t1); gen_load_gpr(t1, rd + 1); - tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, MO_TE | MO_UQ | + tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, mo_endian(ctx) | MO_UQ | ctx->default_tcg_memop_mask); break; #endif
@@ -2572,13 +2572,13 @@ static void decode_micromips32_opc(CPUMIPSState *env, DisasContext *ctx) gen_st(ctx, mips32_op, rt, rs, offset); break; case SC: - gen_st_cond(ctx, rt, rs, offset, MO_TE | MO_SL, false); + gen_st_cond(ctx, rt, rs, offset, mo_endian(ctx) | MO_SL, false); break; #if defined(TARGET_MIPS64) case SCD: check_insn(ctx, ISA_MIPS3); check_mips_64(ctx); - gen_st_cond(ctx, rt, rs, offset, MO_TE | MO_UQ, false); + gen_st_cond(ctx, rt, rs, offset, mo_endian(ctx) | MO_UQ, false); break; #endif case LD_EVA:
@@ -2659,7 +2659,7 @@ static void decode_micromips32_opc(CPUMIPSState *env, DisasContext *ctx) mips32_op = OPC_SHE; goto do_st_lr; case SCE: - gen_st_cond(ctx, rt, rs, offset, MO_TE | MO_SL, true); + gen_st_cond(ctx, rt, rs, offset, mo_endian(ctx) | MO_SL, true); break; case SWE: mips32_op = OPC_SWE;
target/mips/tcg/mips16e_translate.c.inc +6 -6
@@ -135,7 +135,7 @@ static void decr_and_store(DisasContext *ctx, unsigned regidx, TCGv t0) tcg_gen_movi_tl(t2, -4); gen_op_addr_add(ctx, t0, t0, t2); gen_load_gpr(t1, regidx); - tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, MO_TE | MO_UL | + tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, mo_endian(ctx) | MO_UL | ctx->default_tcg_memop_mask); }
@@ -184,25 +184,25 @@ static void gen_mips16_save(DisasContext *ctx, case 4: gen_base_offset_addr(ctx, t0, 29, 12); gen_load_gpr(t1, 7); - tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, MO_TE | MO_UL | + tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, mo_endian(ctx) | MO_UL | ctx->default_tcg_memop_mask); /* Fall through */ case 3: gen_base_offset_addr(ctx, t0, 29, 8); gen_load_gpr(t1, 6); - tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, MO_TE | MO_UL | + tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, mo_endian(ctx) | MO_UL | ctx->default_tcg_memop_mask); /* Fall through */ case 2: gen_base_offset_addr(ctx, t0, 29, 4); gen_load_gpr(t1, 5); - tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, MO_TE | MO_UL | + tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, mo_endian(ctx) | MO_UL | ctx->default_tcg_memop_mask); /* Fall through */ case 1: gen_base_offset_addr(ctx, t0, 29, 0); gen_load_gpr(t1, 4); - tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, MO_TE | MO_UL | + tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, mo_endian(ctx) | MO_UL | ctx->default_tcg_memop_mask); }
@@ -297,7 +297,7 @@ static void decr_and_load(DisasContext *ctx, unsigned regidx, TCGv t0) tcg_gen_movi_tl(t2, -4); gen_op_addr_add(ctx, t0, t0, t2); - tcg_gen_qemu_ld_tl(t1, t0, ctx->mem_idx, MO_TE | MO_SL | + tcg_gen_qemu_ld_tl(t1, t0, ctx->mem_idx, mo_endian(ctx) | MO_SL | ctx->default_tcg_memop_mask); gen_store_gpr(t1, regidx); }
target/mips/tcg/nanomips_translate.c.inc +16 -16
@@ -998,7 +998,7 @@ static void gen_llwp(DisasContext *ctx, uint32_t base, int16_t offset, TCGv tmp2 = tcg_temp_new(); gen_base_offset_addr(ctx, taddr, base, offset); - tcg_gen_qemu_ld_i64(tval, taddr, ctx->mem_idx, MO_TE | MO_UQ | MO_ALIGN); + tcg_gen_qemu_ld_i64(tval, taddr, ctx->mem_idx, mo_endian(ctx) | MO_UQ | MO_ALIGN); if (cpu_is_bigendian(ctx)) { tcg_gen_extr_i64_tl(tmp2, tmp1, tval); } else {
@@ -1075,7 +1075,7 @@ static void gen_save(DisasContext *ctx, uint8_t rt, uint8_t count, gen_base_offset_addr(ctx, va, 29, this_offset); gen_load_gpr(t0, this_rt); tcg_gen_qemu_st_tl(t0, va, ctx->mem_idx, - (MO_TE | MO_UL | ctx->default_tcg_memop_mask)); + (mo_endian(ctx) | MO_UL | ctx->default_tcg_memop_mask)); counter++; }
@@ -1095,7 +1095,7 @@ static void gen_restore(DisasContext *ctx, uint8_t rt, uint8_t count, int this_rt = use_gp ? 28 : (rt & 0x10) | ((rt + counter) & 0x1f); int this_offset = u - ((counter + 1) << 2); gen_base_offset_addr(ctx, va, 29, this_offset); - tcg_gen_qemu_ld_tl(t0, va, ctx->mem_idx, MO_TE | MO_SL | + tcg_gen_qemu_ld_tl(t0, va, ctx->mem_idx, mo_endian(ctx) | MO_SL | ctx->default_tcg_memop_mask); tcg_gen_ext32s_tl(t0, t0); gen_store_gpr(t0, this_rt);
@@ -2647,13 +2647,13 @@ static void gen_p_lsx(DisasContext *ctx, int rd, int rs, int rt) case NM_LHX: /*case NM_LHXS:*/ tcg_gen_qemu_ld_tl(t0, t0, ctx->mem_idx, - MO_TE | MO_SW | ctx->default_tcg_memop_mask); + mo_endian(ctx) | MO_SW | ctx->default_tcg_memop_mask); gen_store_gpr(t0, rd); break; case NM_LWX: /*case NM_LWXS:*/ tcg_gen_qemu_ld_tl(t0, t0, ctx->mem_idx, - MO_TE | MO_SL | ctx->default_tcg_memop_mask); + mo_endian(ctx) | MO_SL | ctx->default_tcg_memop_mask); gen_store_gpr(t0, rd); break; case NM_LBUX:
@@ -2663,7 +2663,7 @@ static void gen_p_lsx(DisasContext *ctx, int rd, int rs, int rt) case NM_LHUX: /*case NM_LHUXS:*/ tcg_gen_qemu_ld_tl(t0, t0, ctx->mem_idx, - MO_TE | MO_UW | ctx->default_tcg_memop_mask); + mo_endian(ctx) | MO_UW | ctx->default_tcg_memop_mask); gen_store_gpr(t0, rd); break; case NM_SBX:
@@ -2676,14 +2676,14 @@ static void gen_p_lsx(DisasContext *ctx, int rd, int rs, int rt) check_nms(ctx); gen_load_gpr(t1, rd); tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, - MO_TE | MO_UW | ctx->default_tcg_memop_mask); + mo_endian(ctx) | MO_UW | ctx->default_tcg_memop_mask); break; case NM_SWX: /*case NM_SWXS:*/ check_nms(ctx); gen_load_gpr(t1, rd); tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, - MO_TE | MO_UL | ctx->default_tcg_memop_mask); + mo_endian(ctx) | MO_UL | ctx->default_tcg_memop_mask); break; case NM_LWC1X: /*case NM_LWC1XS:*/
@@ -3737,7 +3737,7 @@ static int decode_nanomips_32_48_opc(CPUMIPSState *env, DisasContext *ctx) tcg_gen_movi_tl(t0, addr); tcg_gen_qemu_ld_tl(cpu_gpr[rt], t0, ctx->mem_idx, - MO_TE | MO_SL | ctx->default_tcg_memop_mask); + mo_endian(ctx) | MO_SL | ctx->default_tcg_memop_mask); } break; case NM_SWPC48:
@@ -3754,7 +3754,7 @@ static int decode_nanomips_32_48_opc(CPUMIPSState *env, DisasContext *ctx) gen_load_gpr(t1, rt); tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, - MO_TE | MO_UL | ctx->default_tcg_memop_mask); + mo_endian(ctx) | MO_UL | ctx->default_tcg_memop_mask); } break; default:
@@ -4132,13 +4132,13 @@ static int decode_nanomips_32_48_opc(CPUMIPSState *env, DisasContext *ctx) switch (extract32(ctx->opcode, 11, 4)) { case NM_UALH: - tcg_gen_qemu_ld_tl(t0, t0, ctx->mem_idx, MO_TE | MO_SW | + tcg_gen_qemu_ld_tl(t0, t0, ctx->mem_idx, mo_endian(ctx) | MO_SW | MO_UNALN); gen_store_gpr(t0, rt); break; case NM_UASH: gen_load_gpr(t1, rt); - tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, MO_TE | MO_UW | + tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, mo_endian(ctx) | MO_UW | MO_UNALN); break; }
@@ -4161,7 +4161,7 @@ static int decode_nanomips_32_48_opc(CPUMIPSState *env, DisasContext *ctx) case NM_P_SC: switch (ctx->opcode & 0x03) { case NM_SC: - gen_st_cond(ctx, rt, rs, s, MO_TE | MO_SL, false); + gen_st_cond(ctx, rt, rs, s, mo_endian(ctx) | MO_SL, false); break; case NM_SCWP: check_xnp(ctx);
@@ -4274,7 +4274,7 @@ static int decode_nanomips_32_48_opc(CPUMIPSState *env, DisasContext *ctx) check_xnp(ctx); check_eva(ctx); check_cp0_enabled(ctx); - gen_st_cond(ctx, rt, rs, s, MO_TE | MO_SL, true); + gen_st_cond(ctx, rt, rs, s, mo_endian(ctx) | MO_SL, true); break; case NM_SCWPE: check_xnp(ctx);
@@ -4317,7 +4317,7 @@ static int decode_nanomips_32_48_opc(CPUMIPSState *env, DisasContext *ctx) switch (extract32(ctx->opcode, 11, 1)) { case NM_LWM: tcg_gen_qemu_ld_tl(t1, va, ctx->mem_idx, - memop | MO_TE | MO_SL); + memop | mo_endian(ctx) | MO_SL); gen_store_gpr(t1, this_rt); if ((this_rt == rs) && (counter != (count - 1))) {
@@ -4328,7 +4328,7 @@ static int decode_nanomips_32_48_opc(CPUMIPSState *env, DisasContext *ctx) this_rt = (rt == 0) ? 0 : this_rt; gen_load_gpr(t1, this_rt); tcg_gen_qemu_st_tl(t1, va, ctx->mem_idx, - memop | MO_TE | MO_UL); + memop | mo_endian(ctx) | MO_UL); break; } counter++;
Signature · 1 line
2.45.2
PATCH 8/12 target/mips: Expose MIPSCPU::is_big_endian property
In reply to Philippe Mathieu-DaudéAdd the "big-endian" property and set the CP0C0_BE bit in CP0_Config0.
--- target/mips/cpu.h | 3 +++ target/mips/cpu.c | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-)
target/mips/cpu.h +3 -0
@@ -1209,6 +1209,9 @@ struct ArchCPU {Clock *clock;Clock *count_div;/* Divider for CP0_Count clock */ + +/* Properties */ +bool is_big_endian; };/**
target/mips/cpu.c +8 -1
@@ -200,7 +200,8 @@ static void mips_cpu_reset_hold(Object *obj, ResetType type)/* Reset registers to their default values */ env->CP0_PRid = env->cpu_model->CP0_PRid; - env->CP0_Config0 = env->cpu_model->CP0_Config0; + env->CP0_Config0 =deposit32 (env->cpu_model->CP0_Config0, +CP0C0_BE ,1 , cpu->is_big_endian);#if TARGET_BIG_ENDIAN env->CP0_Config0 |= (1 <<CP0C0_BE );#endif
@@ -541,6 +542,11 @@ static const struct SysemuCPUOps mips_sysemu_ops = { };#endif +static Property mips_cpu_properties[] = { +DEFINE_PROP_BOOL ("big-endian" ,MIPSCPU , is_big_endian,TARGET_BIG_ENDIAN ), +DEFINE_PROP_END_OF_LIST (), +}; +#ifdef CONFIG_TCG #include "hw/core/tcg-cpu-ops.h" /*
@@ -571,6 +577,7 @@ static void mips_cpu_class_init(ObjectClass *c, void *data)DeviceClass *dc =DEVICE_CLASS (c);ResettableClass *rc =RESETTABLE_CLASS (c); +device_class_set_props (dc, mips_cpu_properties);device_class_set_parent_realize (dc, mips_cpu_realizefn, &mcc->parent_realize); resettable_class_set_parent_phases(rc, NULL, mips_cpu_reset_hold, NULL,
Signature · 1 line
2.45.2
Re: [PATCH 08/12] target/mips: Expose MIPSCPU::is_big_endian property
Quoted 27 lines · Philippe Mathieu-Daudé
Add the "big-endian" property and set the
CP0C0_BEbit inCP0_Config0.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/mips/cpu.h | 3 +++ target/mips/cpu.c | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-)target/mips/cpu.h +3
-0@@ -1209,6 +1209,9 @@ struct ArchCPU {Clock *clock;Clock *count_div;/* Divider for CP0_Count clock */ + +/* Properties */ +bool is_big_endian; };/** target/mips/cpu.c +0
-0
target/mips/cpu.c static void mips_cpu_reset_hold(Object *obj, ResetType type) · line 207
Quoted 9 lines
target/mips/cpu.c +2
-1@@ -200,7 +200,8 @@ static void mips_cpu_reset_hold(Object *obj, ResetType type)/* Reset registers to their default values */ env->CP0_PRid = env->cpu_model->CP0_PRid; - env->CP0_Config0 = env->cpu_model->CP0_Config0; + env->CP0_Config0 =deposit32 (env->cpu_model->CP0_Config0, +CP0C0_BE ,1 , cpu->is_big_endian);#if TARGET_BIG_ENDIAN env->CP0_Config0 |= (1 <<CP0C0_BE );#endif
Missed removing this ifdef.
r~
PATCH 9/12 hw/mips/cps: Set the vCPU 'cpu-big-endian' property
In reply to Philippe Mathieu-DaudéHave the CPS expose a 'cpu-big-endian' property so it can set it to the vCPUs it creates.
Note, since the number of vCPUs created is dynamic, we can not use QOM aliases.
--- include/hw/mips/cps.h | 1 + hw/mips/cps.c | 4 ++++ hw/mips/malta.c | 2 ++ 3 files changed, 7 insertions(+)
include/hw/mips/cps.h +1 -0
@@ -38,6 +38,7 @@ struct MIPSCPSState {uint32_t num_vp;uint32_t num_irq;char *cpu_type; +bool cpu_is_bigendian;MemoryRegion container;MIPSGCRState gcr;
hw/mips/cps.c +4 -0
@@ -77,6 +77,9 @@ static void mips_cps_realize(DeviceState *dev, Error **errp)MIPSCPU *cpu =MIPS_CPU (object_new (s->cpu_type));CPUMIPSState *env = &cpu->env; +object_property_set_bool (OBJECT (cpu),"big-endian" , s->cpu_is_bigendian, + &error_abort); +/* All VPs are halted on reset. Leave powering up to CPC. */ object_property_set_bool (OBJECT (cpu),"start-powered-off" , true, &error_abort);
@@ -167,6 +170,7 @@ static Property mips_cps_properties[] = {DEFINE_PROP_UINT32 ("num-vp" , MIPSCPSState, num_vp,1 ),DEFINE_PROP_UINT32 ("num-irq" , MIPSCPSState, num_irq,256 ),DEFINE_PROP_STRING ("cpu-type" , MIPSCPSState, cpu_type), +DEFINE_PROP_BOOL ("cpu-big-endian" , MIPSCPSState, cpu_is_bigendian, false), DEFINE_PROP_END_OF_LIST() };
hw/mips/malta.c +2 -0
@@ -1055,6 +1055,8 @@ static void create_cps(MachineState *ms, MaltaState *s,object_initialize_child (OBJECT (s),"cps" , &s->cps,TYPE_MIPS_CPS );object_property_set_str (OBJECT (&s->cps),"cpu-type" , ms->cpu_type, &error_fatal); +object_property_set_bool (OBJECT (&s->cps),"cpu-big-endian" , +TARGET_BIG_ENDIAN , &error_abort);object_property_set_uint (OBJECT (&s->cps),"num-vp" , ms->smp.cpus, &error_fatal);qdev_connect_clock_in (DEVICE (&s->cps),"clk-in" , s->cpuclk);
Signature · 1 line
2.45.2
PATCH 10/12 hw/mips: Have mips_cpu_create_with_clock() take an endianness argument
In reply to Philippe Mathieu-Daudémips_cpu_create_with_clock() creates a vCPU. Pass it the vCPU endianness requested by argument. Update the board call sites.
--- target/mips/cpu.h | 4 +++- hw/mips/fuloong2e.c | 2 +- hw/mips/jazz.c | 2 +- hw/mips/loongson3_virt.c | 2 +- hw/mips/malta.c | 3 ++- hw/mips/mipssim.c | 2 +- target/mips/cpu.c | 5 ++++- 7 files changed, 13 insertions(+), 7 deletions(-)
target/mips/cpu.h +3 -1
@@ -1376,12 +1376,14 @@ static inline void cpu_get_tb_cpu_state(CPUMIPSState *env, vaddr *pc,* mips_cpu_create_with_clock: * @typename: a MIPS CPU type. * @cpu_refclk: this cpu input clock (an output clock of another device) +* @is_big_endian: whether this CPU is configured in big endianness * * Instantiates a MIPS CPU, set the input clock of the CPU to @cpu_refclk, * then realizes the CPU. * * Returns: A #CPUState or %NULL if an error occurred. */ -MIPSCPU *mips_cpu_create_with_clock (const char *cpu_type,Clock *cpu_refclk); +MIPSCPU *mips_cpu_create_with_clock (const char *cpu_type,Clock *cpu_refclk, +bool is_big_endian);#endif /* MIPS_CPU_H */
hw/mips/fuloong2e.c +1 -1
@@ -230,7 +230,7 @@ static void mips_fuloong2e_init(MachineState *machine)clock_set_hz (cpuclk,533080000 );/* ~533 MHz */ /* init CPUs */ - cpu =mips_cpu_create_with_clock (machine->cpu_type, cpuclk); + cpu =mips_cpu_create_with_clock (machine->cpu_type, cpuclk, false); env = &cpu->env;qemu_register_reset (main_cpu_reset, cpu);
hw/mips/jazz.c +1 -1
@@ -212,7 +212,7 @@ static void mips_jazz_init(MachineState *machine, * ext_clk[jazz_model].pll_mult);/* init CPUs */ - cpu =mips_cpu_create_with_clock (machine->cpu_type, cpuclk); + cpu =mips_cpu_create_with_clock (machine->cpu_type, cpuclk,TARGET_BIG_ENDIAN ); env = &cpu->env;qemu_register_reset (main_cpu_reset, cpu);
hw/mips/loongson3_virt.c +1 -1
@@ -567,7 +567,7 @@ static void mips_loongson3_virt_init(MachineState *machine)int ip;/* init CPUs */ - cpu =mips_cpu_create_with_clock (machine->cpu_type, cpuclk); + cpu =mips_cpu_create_with_clock (machine->cpu_type, cpuclk, false);/* Init internal devices */ cpu_mips_irq_init_cpu (cpu);
hw/mips/malta.c +2 -1
@@ -1035,7 +1035,8 @@ static void create_cpu_without_cps(MachineState *ms, MaltaState *s,int i;for (i =0 ; i < ms->smp.cpus; i++) { - cpu =mips_cpu_create_with_clock (ms->cpu_type, s->cpuclk); + cpu =mips_cpu_create_with_clock (ms->cpu_type, s->cpuclk, +TARGET_BIG_ENDIAN );/* Init internal devices */ cpu_mips_irq_init_cpu (cpu);
hw/mips/mipssim.c +1 -1
@@ -160,7 +160,7 @@ mips_mipssim_init(MachineState *machine)#endif /* Init CPUs. */ - cpu =mips_cpu_create_with_clock (machine->cpu_type, cpuclk); + cpu =mips_cpu_create_with_clock (machine->cpu_type, cpuclk,TARGET_BIG_ENDIAN ); env = &cpu->env; reset_info =g_new0 (ResetData,1 );
target/mips/cpu.c +4 -1
@@ -646,12 +646,15 @@ static void mips_cpu_register_types(void)type_init (mips_cpu_register_types)/* Could be used by generic CPU object */ -MIPSCPU *mips_cpu_create_with_clock(const char *cpu_type, Clock *cpu_refclk) +MIPSCPU *mips_cpu_create_with_clock(const char *cpu_type, Clock *cpu_refclk, +bool is_big_endian) {DeviceState *cpu; cpu =DEVICE (object_new (cpu_type));qdev_connect_clock_in (cpu,"clk-in" , cpu_refclk); +object_property_set_bool (OBJECT (cpu),"big-endian" , is_big_endian, + &error_abort);qdev_realize (cpu,NULL , &error_abort);return MIPS_CPU (cpu);
Signature · 1 line
2.45.2
PATCH 11/12 target/mips: Remove target-specific code in mips_cpu_reset_hold()
In reply to Philippe Mathieu-DaudéSince all code creating vCPUs now set the 'cpu-big-endian' property, we can remove the target-specific #ifdef'ry in mips_cpu_reset_hold():
the CP0C0_BE bit is set using the property cpu->is_big_endian value.
--- target/mips/cpu.c | 3 --- 1 file changed, 3 deletions(-)
target/mips/cpu.c +0 -3
@@ -202,9 +202,6 @@ static void mips_cpu_reset_hold(Object *obj, ResetType type) env->CP0_PRid = env->cpu_model->CP0_PRid; env->CP0_Config0 =deposit32 (env->cpu_model->CP0_Config0,CP0C0_BE ,1 , cpu->is_big_endian); -#if TARGET_BIG_ENDIAN - env->CP0_Config0 |= (1 <<CP0C0_BE ); -#endif env->CP0_Config1 = env->cpu_model->CP0_Config1; env->CP0_Config2 = env->cpu_model->CP0_Config2; env->CP0_Config3 = env->cpu_model->CP0_Config3;
Signature · 1 line
2.45.2
Re: [PATCH 11/12] target/mips: Remove target-specific code in mips_cpu_reset_hold()
Quoted 14 lines · Philippe Mathieu-Daudé
Since all code creating vCPUs now set the 'cpu-big-endian' property, we can remove the target-specific #ifdef'ry in
mips_cpu_reset_hold():
theCP0C0_BEbit is set using the propertycpu->is_big_endianvalue.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/mips/cpu.c | 3 --- 1 file changed, 3 deletions(-)target/mips/cpu.c +0
-0
target/mips/cpu.c static void mips_cpu_reset_hold(Object *obj, ResetType type) · line 207
Quoted 9 lines
target/mips/cpu.c +0
-3@@ -202,9 +202,6 @@ static void mips_cpu_reset_hold(Object *obj, ResetType type) env->CP0_PRid = env->cpu_model->CP0_PRid; env->CP0_Config0 =deposit32 (env->cpu_model->CP0_Config0,CP0C0_BE ,1 , cpu->is_big_endian); -#if TARGET_BIG_ENDIAN - env->CP0_Config0 |= (1 <<CP0C0_BE ); -#endif env->CP0_Config1 = env->cpu_model->CP0_Config1; env->CP0_Config2 = env->cpu_model->CP0_Config2; env->CP0_Config3 = env->cpu_model->CP0_Config3;
I think this must be merged into patch 8, or patch 8 doesn't work.
r~
Re: [PATCH 11/12] target/mips: Remove target-specific code in mips_cpu_reset_hold()
Quoted 19 lines · Richard Henderson
Quoted 18 lines · Philippe Mathieu-Daudé
Since all code creating vCPUs now set the 'cpu-big-endian' property, we can remove the target-specific #ifdef'ry in
mips_cpu_reset_hold():
theCP0C0_BEbit is set using the propertycpu->is_big_endianvalue.Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
target/mips/cpu.c| 3 ---1 file changed, 3 deletions(-)target/mips/cpu.c +0
-0@@ -202,9 +202,6 @@ static void mips_cpu_reset_hold(Object *obj, ResetType type) env->CP0_PRid = env->cpu_model->CP0_PRid; env->CP0_Config0 = deposit32(env->cpu_model->CP0_Config0, CP0C0_BE, 1, cpu->is_big_endian);
Quoted 8 lines
Quoted 6 lines
target/mips/cpu.c +0
-3-#if TARGET_BIG_ENDIAN - env->CP0_Config0 |= (1 << CP0C0_BE); -#endif env->CP0_Config1 = env->cpu_model->CP0_Config1; env->CP0_Config2 = env->cpu_model->CP0_Config2;
env->CP0_Config3=env->cpu_model->CP0_Config3;I think this must be merged into patch 8, or patch 8 doesn't work.
Correct.
PATCH 12/12 hw/mips/malta: Remove TARGET_BIG_ENDIAN #ifdef'ry
In reply to Philippe Mathieu-DaudéMove code evaluation from preprocessor to compiler so the if() ladder is always processed. Mostly to unify style in not using TARGET_BIG_ENDIAN #ifdef anymore.
--- hw/mips/malta.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
hw/mips/malta.c +1 -3
@@ -1196,8 +1196,7 @@ void mips_malta_init(MachineState *machine)* In little endian mode the 32bit words in the bios are swapped, * a neat trick which allows bi-endian firmware. */ -#if !TARGET_BIG_ENDIAN - { +if (!TARGET_BIG_ENDIAN ) {uint32_t *end, *addr;const size_t swapsize =MIN (bios_size,0x3e0000 ); addr =rom_ptr (FLASH_ADDRESS , swapsize);
@@ -1210,7 +1209,6 @@ void mips_malta_init(MachineState *machine) addr++; } } -#endif }/*
Signature · 1 line
2.45.2
Quoted 3 lines · 在2024年9月30日九月 上午10:10,Philippe Mathieu-Daudé写道:
Get vCPU endianness from
CP0::BEbit.
Propagate endianness at the board level, using QOM property. Remove target-specific endianness knowledge from target/.
For the series:
Will this lead us to bi-endian QEMU executable?
Thanks
- Jiaxun
Quoted 39 lines
Philippe Mathieu-Daudé (12):
target/mips: Declarecpu_is_bigendian_env()in 'internal.h' target/mips: Introducemo_endian_env()helper
target/mips: ReplaceMO_TEbymo_endian_env()inget_pte()target/mips: Convert mips16e decr_and_load/store() macros to functions target/mips: Introducemo_endian()helper
target/mips: ExplodeMO_TExx->MO_TE|MO_xx
target/mips: ReplaceMO_TEbymo_endian()
target/mips: ExposeMIPSCPU::is_big_endianproperty hw/mips/cps: Set the vCPU 'cpu-big-endian' property hw/mips: Havemips_cpu_create_with_clock()take an endianness argument target/mips: Remove target-specific code inmips_cpu_reset_hold()hw/mips/malta: RemoveTARGET_BIG_ENDIAN#ifdef'ryinclude/hw/mips/cps.h | 1 + target/mips/cpu.h | 7 +- target/mips/internal.h | 11 ++ target/mips/tcg/translate.h | 5 + hw/mips/cps.c | 4 + hw/mips/fuloong2e.c | 2 +- hw/mips/jazz.c | 2 +- hw/mips/loongson3_virt.c | 2 +- hw/mips/malta.c | 9 +- hw/mips/mipssim.c | 2 +- target/mips/cpu.c | 17 ++- target/mips/tcg/ldst_helper.c | 15 +-- target/mips/tcg/msa_helper.c | 2 +- target/mips/tcg/mxu_translate.c | 18 ++-- target/mips/tcg/sysemu/tlb_helper.c | 2 +- target/mips/tcg/translate.c | 120 +++++++++++----------- target/mips/tcg/tx79_translate.c | 8 +- target/mips/tcg/micromips_translate.c.inc | 22 ++-- target/mips/tcg/mips16e_translate.c.inc | 109 ++++++++++---------- target/mips/tcg/nanomips_translate.c.inc | 32 +++--- 20 files changed, 212 insertions(+), 178 deletions(-)Signature · 1 line
2.45.2
Signature · 1 line
- Jiaxun