mirror of
https://github.com/xemu-project/xemu.git
synced 2025-01-21 19:37:44 +00:00
target/mips: Replace TARGET_WORDS_BIGENDIAN by cpu_is_bigendian()
Add the inlined cpu_is_bigendian() function in "translate.h". Replace the TARGET_WORDS_BIGENDIAN #ifdef'ry by calls to cpu_is_bigendian(). Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20210818164321.2474534-6-f4bug@amsat.org>
This commit is contained in:
parent
0cfd392d7b
commit
bf78469cc8
@ -999,11 +999,11 @@ static void gen_llwp(DisasContext *ctx, uint32_t base, int16_t offset,
|
||||
|
||||
gen_base_offset_addr(ctx, taddr, base, offset);
|
||||
tcg_gen_qemu_ld64(tval, taddr, ctx->mem_idx);
|
||||
#ifdef TARGET_WORDS_BIGENDIAN
|
||||
tcg_gen_extr_i64_tl(tmp2, tmp1, tval);
|
||||
#else
|
||||
tcg_gen_extr_i64_tl(tmp1, tmp2, tval);
|
||||
#endif
|
||||
if (cpu_is_bigendian(ctx)) {
|
||||
tcg_gen_extr_i64_tl(tmp2, tmp1, tval);
|
||||
} else {
|
||||
tcg_gen_extr_i64_tl(tmp1, tmp2, tval);
|
||||
}
|
||||
gen_store_gpr(tmp1, reg1);
|
||||
tcg_temp_free(tmp1);
|
||||
gen_store_gpr(tmp2, reg2);
|
||||
@ -1035,11 +1035,11 @@ static void gen_scwp(DisasContext *ctx, uint32_t base, int16_t offset,
|
||||
gen_load_gpr(tmp1, reg1);
|
||||
gen_load_gpr(tmp2, reg2);
|
||||
|
||||
#ifdef TARGET_WORDS_BIGENDIAN
|
||||
tcg_gen_concat_tl_i64(tval, tmp2, tmp1);
|
||||
#else
|
||||
tcg_gen_concat_tl_i64(tval, tmp1, tmp2);
|
||||
#endif
|
||||
if (cpu_is_bigendian(ctx)) {
|
||||
tcg_gen_concat_tl_i64(tval, tmp2, tmp1);
|
||||
} else {
|
||||
tcg_gen_concat_tl_i64(tval, tmp1, tmp2);
|
||||
}
|
||||
|
||||
tcg_gen_ld_i64(llval, cpu_env, offsetof(CPUMIPSState, llval_wp));
|
||||
tcg_gen_atomic_cmpxchg_i64(val, taddr, llval, tval,
|
||||
|
@ -2048,9 +2048,9 @@ static void gen_ld(DisasContext *ctx, uint32_t opc,
|
||||
*/
|
||||
tcg_gen_qemu_ld_tl(t1, t0, mem_idx, MO_UB);
|
||||
tcg_gen_andi_tl(t1, t0, 7);
|
||||
#ifndef TARGET_WORDS_BIGENDIAN
|
||||
tcg_gen_xori_tl(t1, t1, 7);
|
||||
#endif
|
||||
if (!cpu_is_bigendian(ctx)) {
|
||||
tcg_gen_xori_tl(t1, t1, 7);
|
||||
}
|
||||
tcg_gen_shli_tl(t1, t1, 3);
|
||||
tcg_gen_andi_tl(t0, t0, ~7);
|
||||
tcg_gen_qemu_ld_tl(t0, t0, mem_idx, MO_TEQ);
|
||||
@ -2072,9 +2072,9 @@ static void gen_ld(DisasContext *ctx, uint32_t opc,
|
||||
*/
|
||||
tcg_gen_qemu_ld_tl(t1, t0, mem_idx, MO_UB);
|
||||
tcg_gen_andi_tl(t1, t0, 7);
|
||||
#ifdef TARGET_WORDS_BIGENDIAN
|
||||
tcg_gen_xori_tl(t1, t1, 7);
|
||||
#endif
|
||||
if (cpu_is_bigendian(ctx)) {
|
||||
tcg_gen_xori_tl(t1, t1, 7);
|
||||
}
|
||||
tcg_gen_shli_tl(t1, t1, 3);
|
||||
tcg_gen_andi_tl(t0, t0, ~7);
|
||||
tcg_gen_qemu_ld_tl(t0, t0, mem_idx, MO_TEQ);
|
||||
@ -2153,9 +2153,9 @@ static void gen_ld(DisasContext *ctx, uint32_t opc,
|
||||
*/
|
||||
tcg_gen_qemu_ld_tl(t1, t0, mem_idx, MO_UB);
|
||||
tcg_gen_andi_tl(t1, t0, 3);
|
||||
#ifndef TARGET_WORDS_BIGENDIAN
|
||||
tcg_gen_xori_tl(t1, t1, 3);
|
||||
#endif
|
||||
if (!cpu_is_bigendian(ctx)) {
|
||||
tcg_gen_xori_tl(t1, t1, 3);
|
||||
}
|
||||
tcg_gen_shli_tl(t1, t1, 3);
|
||||
tcg_gen_andi_tl(t0, t0, ~3);
|
||||
tcg_gen_qemu_ld_tl(t0, t0, mem_idx, MO_TEUL);
|
||||
@ -2181,9 +2181,9 @@ static void gen_ld(DisasContext *ctx, uint32_t opc,
|
||||
*/
|
||||
tcg_gen_qemu_ld_tl(t1, t0, mem_idx, MO_UB);
|
||||
tcg_gen_andi_tl(t1, t0, 3);
|
||||
#ifdef TARGET_WORDS_BIGENDIAN
|
||||
tcg_gen_xori_tl(t1, t1, 3);
|
||||
#endif
|
||||
if (cpu_is_bigendian(ctx)) {
|
||||
tcg_gen_xori_tl(t1, t1, 3);
|
||||
}
|
||||
tcg_gen_shli_tl(t1, t1, 3);
|
||||
tcg_gen_andi_tl(t0, t0, ~3);
|
||||
tcg_gen_qemu_ld_tl(t0, t0, mem_idx, MO_TEUL);
|
||||
@ -4400,9 +4400,9 @@ static void gen_loongson_lswc2(DisasContext *ctx, int rt,
|
||||
t1 = tcg_temp_new();
|
||||
tcg_gen_qemu_ld_tl(t1, t0, ctx->mem_idx, MO_UB);
|
||||
tcg_gen_andi_tl(t1, t0, 3);
|
||||
#ifndef TARGET_WORDS_BIGENDIAN
|
||||
tcg_gen_xori_tl(t1, t1, 3);
|
||||
#endif
|
||||
if (!cpu_is_bigendian(ctx)) {
|
||||
tcg_gen_xori_tl(t1, t1, 3);
|
||||
}
|
||||
tcg_gen_shli_tl(t1, t1, 3);
|
||||
tcg_gen_andi_tl(t0, t0, ~3);
|
||||
tcg_gen_qemu_ld_tl(t0, t0, ctx->mem_idx, MO_TEUL);
|
||||
@ -4430,9 +4430,9 @@ static void gen_loongson_lswc2(DisasContext *ctx, int rt,
|
||||
t1 = tcg_temp_new();
|
||||
tcg_gen_qemu_ld_tl(t1, t0, ctx->mem_idx, MO_UB);
|
||||
tcg_gen_andi_tl(t1, t0, 3);
|
||||
#ifdef TARGET_WORDS_BIGENDIAN
|
||||
tcg_gen_xori_tl(t1, t1, 3);
|
||||
#endif
|
||||
if (cpu_is_bigendian(ctx)) {
|
||||
tcg_gen_xori_tl(t1, t1, 3);
|
||||
}
|
||||
tcg_gen_shli_tl(t1, t1, 3);
|
||||
tcg_gen_andi_tl(t0, t0, ~3);
|
||||
tcg_gen_qemu_ld_tl(t0, t0, ctx->mem_idx, MO_TEUL);
|
||||
@ -4462,9 +4462,9 @@ static void gen_loongson_lswc2(DisasContext *ctx, int rt,
|
||||
t1 = tcg_temp_new();
|
||||
tcg_gen_qemu_ld_tl(t1, t0, ctx->mem_idx, MO_UB);
|
||||
tcg_gen_andi_tl(t1, t0, 7);
|
||||
#ifndef TARGET_WORDS_BIGENDIAN
|
||||
tcg_gen_xori_tl(t1, t1, 7);
|
||||
#endif
|
||||
if (!cpu_is_bigendian(ctx)) {
|
||||
tcg_gen_xori_tl(t1, t1, 7);
|
||||
}
|
||||
tcg_gen_shli_tl(t1, t1, 3);
|
||||
tcg_gen_andi_tl(t0, t0, ~7);
|
||||
tcg_gen_qemu_ld_tl(t0, t0, ctx->mem_idx, MO_TEQ);
|
||||
@ -4484,9 +4484,9 @@ static void gen_loongson_lswc2(DisasContext *ctx, int rt,
|
||||
t1 = tcg_temp_new();
|
||||
tcg_gen_qemu_ld_tl(t1, t0, ctx->mem_idx, MO_UB);
|
||||
tcg_gen_andi_tl(t1, t0, 7);
|
||||
#ifdef TARGET_WORDS_BIGENDIAN
|
||||
tcg_gen_xori_tl(t1, t1, 7);
|
||||
#endif
|
||||
if (cpu_is_bigendian(ctx)) {
|
||||
tcg_gen_xori_tl(t1, t1, 7);
|
||||
}
|
||||
tcg_gen_shli_tl(t1, t1, 3);
|
||||
tcg_gen_andi_tl(t0, t0, ~7);
|
||||
tcg_gen_qemu_ld_tl(t0, t0, ctx->mem_idx, MO_TEQ);
|
||||
@ -11409,17 +11409,17 @@ static void gen_flt3_arith(DisasContext *ctx, uint32_t opc,
|
||||
gen_set_label(l1);
|
||||
tcg_gen_brcondi_tl(TCG_COND_NE, t0, 4, l2);
|
||||
tcg_temp_free(t0);
|
||||
#ifdef TARGET_WORDS_BIGENDIAN
|
||||
gen_load_fpr32(ctx, fp, fs);
|
||||
gen_load_fpr32h(ctx, fph, ft);
|
||||
gen_store_fpr32h(ctx, fp, fd);
|
||||
gen_store_fpr32(ctx, fph, fd);
|
||||
#else
|
||||
gen_load_fpr32h(ctx, fph, fs);
|
||||
gen_load_fpr32(ctx, fp, ft);
|
||||
gen_store_fpr32(ctx, fph, fd);
|
||||
gen_store_fpr32h(ctx, fp, fd);
|
||||
#endif
|
||||
if (cpu_is_bigendian(ctx)) {
|
||||
gen_load_fpr32(ctx, fp, fs);
|
||||
gen_load_fpr32h(ctx, fph, ft);
|
||||
gen_store_fpr32h(ctx, fp, fd);
|
||||
gen_store_fpr32(ctx, fph, fd);
|
||||
} else {
|
||||
gen_load_fpr32h(ctx, fph, fs);
|
||||
gen_load_fpr32(ctx, fp, ft);
|
||||
gen_store_fpr32(ctx, fph, fd);
|
||||
gen_store_fpr32h(ctx, fp, fd);
|
||||
}
|
||||
gen_set_label(l2);
|
||||
tcg_temp_free_i32(fp);
|
||||
tcg_temp_free_i32(fph);
|
||||
|
@ -224,4 +224,9 @@ bool decode_ext_vr54xx(DisasContext *ctx, uint32_t insn);
|
||||
static bool trans_##NAME(DisasContext *ctx, arg_##NAME *a) \
|
||||
{ return FUNC(ctx, a, __VA_ARGS__); }
|
||||
|
||||
static inline bool cpu_is_bigendian(DisasContext *ctx)
|
||||
{
|
||||
return extract32(ctx->CP0_Config0, CP0C0_BE, 1);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user