mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-03-25 01:45:08 +00:00
target/mips: Style improvements in translate.c
Fixes mostly errors and warnings reported by 'checkpatch.pl -f'. Backports commit 71375b59241a27b75d287b9216e5e82e43d763d8 from qemu
This commit is contained in:
parent
cf6adb51e0
commit
551b3db088
|
@ -1156,10 +1156,10 @@ enum {
|
|||
OPC_MSUB_PS = 0x2E | OPC_CP3,
|
||||
OPC_NMADD_S = 0x30 | OPC_CP3,
|
||||
OPC_NMADD_D = 0x31 | OPC_CP3,
|
||||
OPC_NMADD_PS= 0x36 | OPC_CP3,
|
||||
OPC_NMADD_PS = 0x36 | OPC_CP3,
|
||||
OPC_NMSUB_S = 0x38 | OPC_CP3,
|
||||
OPC_NMSUB_D = 0x39 | OPC_CP3,
|
||||
OPC_NMSUB_PS= 0x3E | OPC_CP3,
|
||||
OPC_NMSUB_PS = 0x3E | OPC_CP3,
|
||||
};
|
||||
|
||||
/* MSA Opcodes */
|
||||
|
@ -2445,43 +2445,43 @@ enum {
|
|||
TCGv_i32 helper_tmp = tcg_const_i32(tcg_ctx, arg); \
|
||||
gen_helper_##name(tcg_ctx, tcg_ctx->cpu_env, helper_tmp); \
|
||||
tcg_temp_free_i32(tcg_ctx, helper_tmp); \
|
||||
} while(0)
|
||||
} while (0)
|
||||
|
||||
#define gen_helper_0e1i(tcg_ctx, name, arg1, arg2) do { \
|
||||
TCGv_i32 helper_tmp = tcg_const_i32(tcg_ctx, arg2); \
|
||||
gen_helper_##name(tcg_ctx, tcg_ctx->cpu_env, arg1, helper_tmp); \
|
||||
tcg_temp_free_i32(tcg_ctx, helper_tmp); \
|
||||
} while(0)
|
||||
} while (0)
|
||||
|
||||
#define gen_helper_1e0i(tcg_ctx, name, ret, arg1) do { \
|
||||
TCGv_i32 helper_tmp = tcg_const_i32(tcg_ctx, arg1); \
|
||||
gen_helper_##name(tcg_ctx, ret, tcg_ctx->cpu_env, helper_tmp); \
|
||||
tcg_temp_free_i32(tcg_ctx, helper_tmp); \
|
||||
} while(0)
|
||||
} while (0)
|
||||
|
||||
#define gen_helper_1e1i(tcg_ctx, name, ret, arg1, arg2) do { \
|
||||
TCGv_i32 helper_tmp = tcg_const_i32(tcg_ctx, arg2); \
|
||||
gen_helper_##name(tcg_ctx, ret, tcg_ctx->cpu_env, arg1, helper_tmp); \
|
||||
tcg_temp_free_i32(tcg_ctx, helper_tmp); \
|
||||
} while(0)
|
||||
} while (0)
|
||||
|
||||
#define gen_helper_0e2i(tcg_ctx, name, arg1, arg2, arg3) do { \
|
||||
TCGv_i32 helper_tmp = tcg_const_i32(tcg_ctx, arg3); \
|
||||
gen_helper_##name(tcg_ctx, tcg_ctx->cpu_env, arg1, arg2, helper_tmp); \
|
||||
tcg_temp_free_i32(tcg_ctx, helper_tmp); \
|
||||
} while(0)
|
||||
} while (0)
|
||||
|
||||
#define gen_helper_1e2i(tcg_ctx, name, ret, arg1, arg2, arg3) do { \
|
||||
TCGv_i32 helper_tmp = tcg_const_i32(tcg_ctx, arg3); \
|
||||
gen_helper_##name(tcg_ctx, ret, tcg_ctx->cpu_env, arg1, arg2, helper_tmp); \
|
||||
tcg_temp_free_i32(tcg_ctx, helper_tmp); \
|
||||
} while(0)
|
||||
} while (0)
|
||||
|
||||
#define gen_helper_0e3i(tcg_ctx, name, arg1, arg2, arg3, arg4) do { \
|
||||
TCGv_i32 helper_tmp = tcg_const_i32(tcg_ctx, arg4); \
|
||||
gen_helper_##name(tcg_ctx, tcg_ctx->cpu_env, arg1, arg2, arg3, helper_tmp); \
|
||||
tcg_temp_free_i32(tcg_ctx, helper_tmp); \
|
||||
} while(0)
|
||||
} while (0)
|
||||
|
||||
typedef struct DisasContext {
|
||||
DisasContextBase base;
|
||||
|
@ -3186,8 +3186,8 @@ static inline void gen_cmp ## type ## _ ## fmt(DisasContext *ctx, int n, \
|
|||
int ft, int fs, int cc) \
|
||||
{ \
|
||||
TCGContext *tcg_ctx = ctx->uc->tcg_ctx; \
|
||||
TCGv_i##bits fp0 = tcg_temp_new_i##bits (tcg_ctx); \
|
||||
TCGv_i##bits fp1 = tcg_temp_new_i##bits (tcg_ctx); \
|
||||
TCGv_i##bits fp0 = tcg_temp_new_i##bits(tcg_ctx); \
|
||||
TCGv_i##bits fp1 = tcg_temp_new_i##bits(tcg_ctx); \
|
||||
switch (ifmt) { \
|
||||
case FMT_PS: \
|
||||
check_ps(ctx); \
|
||||
|
@ -3204,8 +3204,8 @@ static inline void gen_cmp ## type ## _ ## fmt(DisasContext *ctx, int n, \
|
|||
} \
|
||||
break; \
|
||||
} \
|
||||
gen_ldcmp_fpr##bits (ctx, fp0, fs); \
|
||||
gen_ldcmp_fpr##bits (ctx, fp1, ft); \
|
||||
gen_ldcmp_fpr##bits(ctx, fp0, fs); \
|
||||
gen_ldcmp_fpr##bits(ctx, fp1, ft); \
|
||||
switch (n) { \
|
||||
case 0: \
|
||||
gen_helper_0e2i(tcg_ctx, cmp ## type ## _ ## fmt ## _f, fp0, fp1, cc); \
|
||||
|
@ -3258,8 +3258,8 @@ static inline void gen_cmp ## type ## _ ## fmt(DisasContext *ctx, int n, \
|
|||
default: \
|
||||
abort(); \
|
||||
} \
|
||||
tcg_temp_free_i##bits (tcg_ctx, fp0); \
|
||||
tcg_temp_free_i##bits (tcg_ctx, fp1); \
|
||||
tcg_temp_free_i##bits(tcg_ctx, fp0); \
|
||||
tcg_temp_free_i##bits(tcg_ctx, fp1); \
|
||||
}
|
||||
|
||||
FOP_CONDS(, 0, d, FMT_D, 64)
|
||||
|
@ -3353,8 +3353,8 @@ static inline void gen_r6_cmp_ ## fmt(DisasContext * ctx, int n, \
|
|||
abort(); \
|
||||
} \
|
||||
STORE; \
|
||||
tcg_temp_free_i ## bits (tcg_ctx, fp0); \
|
||||
tcg_temp_free_i ## bits (tcg_ctx, fp1); \
|
||||
tcg_temp_free_i ## bits(tcg_ctx, fp0); \
|
||||
tcg_temp_free_i ## bits(tcg_ctx, fp1); \
|
||||
}
|
||||
|
||||
FOP_CONDNS(d, FMT_D, 64, gen_store_fpr64(ctx, fp0, fd))
|
||||
|
@ -3365,7 +3365,7 @@ FOP_CONDNS(s, FMT_S, 32, gen_store_fpr32(ctx, fp0, fd))
|
|||
|
||||
/* load/store instructions. */
|
||||
#ifdef CONFIG_USER_ONLY
|
||||
#define OP_LD_ATOMIC(insn,fname) \
|
||||
#define OP_LD_ATOMIC(insn, fname) \
|
||||
static inline void op_ld_##insn(TCGv ret, TCGv arg1, int mem_idx, \
|
||||
DisasContext *ctx) \
|
||||
{ \
|
||||
|
@ -3378,7 +3378,7 @@ static inline void op_ld_##insn(TCGv ret, TCGv arg1, int mem_idx,
|
|||
tcg_temp_free(tcg_ctx, t0); \
|
||||
}
|
||||
#else
|
||||
#define OP_LD_ATOMIC(insn,fname) \
|
||||
#define OP_LD_ATOMIC(insn, fname) \
|
||||
static inline void op_ld_##insn(TCGv ret, TCGv arg1, int mem_idx, \
|
||||
DisasContext *ctx) \
|
||||
{ \
|
||||
|
@ -3386,9 +3386,9 @@ static inline void op_ld_##insn(TCGv ret, TCGv arg1, int mem_idx, \
|
|||
gen_helper_1e1i(tcg_ctx, insn, ret, arg1, mem_idx); \
|
||||
}
|
||||
#endif
|
||||
OP_LD_ATOMIC(ll,ld32s);
|
||||
OP_LD_ATOMIC(ll, ld32s);
|
||||
#if defined(TARGET_MIPS64)
|
||||
OP_LD_ATOMIC(lld,ld64);
|
||||
OP_LD_ATOMIC(lld, ld64);
|
||||
#endif
|
||||
#undef OP_LD_ATOMIC
|
||||
|
||||
|
@ -4254,7 +4254,10 @@ static void gen_arith(DisasContext *ctx, uint32_t opc,
|
|||
tcg_temp_free(tcg_ctx, t2);
|
||||
tcg_gen_brcondi_tl(tcg_ctx, TCG_COND_GE, t1, 0, l1);
|
||||
tcg_temp_free(tcg_ctx, t1);
|
||||
/* operands of different sign, first operand and result different sign */
|
||||
/*
|
||||
* Operands of different sign, first operand and result different
|
||||
* sign.
|
||||
*/
|
||||
generate_exception(ctx, EXCP_OVERFLOW);
|
||||
gen_set_label(tcg_ctx, l1);
|
||||
gen_store_gpr(ctx, t0, rd);
|
||||
|
@ -5836,7 +5839,7 @@ static void gen_loongson_multimedia(DisasContext *ctx, int rd, int rs, int rt)
|
|||
}
|
||||
|
||||
/* Traps */
|
||||
static void gen_trap (DisasContext *ctx, uint32_t opc,
|
||||
static void gen_trap(DisasContext *ctx, uint32_t opc,
|
||||
int rs, int rt, int16_t imm)
|
||||
{
|
||||
TCGContext *tcg_ctx = ctx->uc->tcg_ctx;
|
||||
|
@ -5962,7 +5965,7 @@ static inline void gen_goto_tb(DisasContext *ctx, int n, target_ulong dest)
|
|||
}
|
||||
|
||||
/* Branches (before delay slot) */
|
||||
static void gen_compute_branch (DisasContext *ctx, uint32_t opc,
|
||||
static void gen_compute_branch(DisasContext *ctx, uint32_t opc,
|
||||
int insn_bytes,
|
||||
int rs, int rt, int32_t offset,
|
||||
int delayslot_size)
|
||||
|
@ -7614,7 +7617,7 @@ static void gen_mfc0(DisasContext *ctx, TCGv arg, int reg, int sel)
|
|||
case 7:
|
||||
CP0_CHECK(ctx->kscrexist & (1 << sel));
|
||||
tcg_gen_ld_tl(tcg_ctx, arg, tcg_ctx->cpu_env,
|
||||
offsetof(CPUMIPSState, CP0_KScratch[sel-2]));
|
||||
offsetof(CPUMIPSState, CP0_KScratch[sel - 2]));
|
||||
tcg_gen_ext32s_tl(tcg_ctx, arg, arg);
|
||||
register_name = "KScratch";
|
||||
break;
|
||||
|
@ -9957,7 +9960,8 @@ static void gen_mftr(CPUMIPSState *env, DisasContext *ctx, int rt, int rd,
|
|||
default:
|
||||
gen_mfc0(ctx, t0, rt, sel);
|
||||
}
|
||||
} else switch (sel) {
|
||||
} else {
|
||||
switch (sel) {
|
||||
/* GPR registers. */
|
||||
case 0:
|
||||
gen_helper_1e0i(tcg_ctx, mftgpr, t0, rt);
|
||||
|
@ -10036,6 +10040,7 @@ static void gen_mftr(CPUMIPSState *env, DisasContext *ctx, int rt, int rd,
|
|||
default:
|
||||
goto die;
|
||||
}
|
||||
}
|
||||
LOG_DISAS("mftr (reg %d u %d sel %d h %d)\n", rt, u, sel, h);
|
||||
gen_store_gpr(ctx, t0, rd);
|
||||
tcg_temp_free(tcg_ctx, t0);
|
||||
|
@ -10160,7 +10165,8 @@ static void gen_mttr(CPUMIPSState *env, DisasContext *ctx, int rd, int rt,
|
|||
default:
|
||||
gen_mtc0(ctx, t0, rd, sel);
|
||||
}
|
||||
} else switch (sel) {
|
||||
} else {
|
||||
switch (sel) {
|
||||
/* GPR registers. */
|
||||
case 0:
|
||||
gen_helper_0e1i(tcg_ctx, mttgpr, t0, rd);
|
||||
|
@ -10246,6 +10252,7 @@ static void gen_mttr(CPUMIPSState *env, DisasContext *ctx, int rd, int rt,
|
|||
default:
|
||||
goto die;
|
||||
}
|
||||
}
|
||||
LOG_DISAS("mttr (reg %d u %d sel %d h %d)\n", rd, u, sel, h);
|
||||
tcg_temp_free(tcg_ctx, t0);
|
||||
return;
|
||||
|
@ -10493,7 +10500,7 @@ static void gen_compute_branch1(DisasContext *ctx, uint32_t op,
|
|||
{
|
||||
TCGv_i32 t1 = tcg_temp_new_i32(tcg_ctx);
|
||||
tcg_gen_shri_i32(tcg_ctx, t0, tcg_ctx->fpu_fcr31, get_fp_bit(cc));
|
||||
tcg_gen_shri_i32(tcg_ctx, t1, tcg_ctx->fpu_fcr31, get_fp_bit(cc+1));
|
||||
tcg_gen_shri_i32(tcg_ctx, t1, tcg_ctx->fpu_fcr31, get_fp_bit(cc + 1));
|
||||
tcg_gen_nand_i32(tcg_ctx, t0, t0, t1);
|
||||
tcg_temp_free_i32(tcg_ctx, t1);
|
||||
tcg_gen_andi_i32(tcg_ctx, t0, t0, 1);
|
||||
|
@ -10504,7 +10511,7 @@ static void gen_compute_branch1(DisasContext *ctx, uint32_t op,
|
|||
{
|
||||
TCGv_i32 t1 = tcg_temp_new_i32(tcg_ctx);
|
||||
tcg_gen_shri_i32(tcg_ctx, t0, tcg_ctx->fpu_fcr31, get_fp_bit(cc));
|
||||
tcg_gen_shri_i32(tcg_ctx, t1, tcg_ctx->fpu_fcr31, get_fp_bit(cc+1));
|
||||
tcg_gen_shri_i32(tcg_ctx, t1, tcg_ctx->fpu_fcr31, get_fp_bit(cc + 1));
|
||||
tcg_gen_or_i32(tcg_ctx, t0, t0, t1);
|
||||
tcg_temp_free_i32(tcg_ctx, t1);
|
||||
tcg_gen_andi_i32(tcg_ctx, t0, t0, 1);
|
||||
|
@ -10515,11 +10522,11 @@ static void gen_compute_branch1(DisasContext *ctx, uint32_t op,
|
|||
{
|
||||
TCGv_i32 t1 = tcg_temp_new_i32(tcg_ctx);
|
||||
tcg_gen_shri_i32(tcg_ctx, t0, tcg_ctx->fpu_fcr31, get_fp_bit(cc));
|
||||
tcg_gen_shri_i32(tcg_ctx, t1, tcg_ctx->fpu_fcr31, get_fp_bit(cc+1));
|
||||
tcg_gen_shri_i32(tcg_ctx, t1, tcg_ctx->fpu_fcr31, get_fp_bit(cc + 1));
|
||||
tcg_gen_and_i32(tcg_ctx, t0, t0, t1);
|
||||
tcg_gen_shri_i32(tcg_ctx, t1, tcg_ctx->fpu_fcr31, get_fp_bit(cc+2));
|
||||
tcg_gen_shri_i32(tcg_ctx, t1, tcg_ctx->fpu_fcr31, get_fp_bit(cc + 2));
|
||||
tcg_gen_and_i32(tcg_ctx, t0, t0, t1);
|
||||
tcg_gen_shri_i32(tcg_ctx, t1, tcg_ctx->fpu_fcr31, get_fp_bit(cc+3));
|
||||
tcg_gen_shri_i32(tcg_ctx, t1, tcg_ctx->fpu_fcr31, get_fp_bit(cc + 3));
|
||||
tcg_gen_nand_i32(tcg_ctx, t0, t0, t1);
|
||||
tcg_temp_free_i32(tcg_ctx, t1);
|
||||
tcg_gen_andi_i32(tcg_ctx, t0, t0, 1);
|
||||
|
@ -10530,11 +10537,11 @@ static void gen_compute_branch1(DisasContext *ctx, uint32_t op,
|
|||
{
|
||||
TCGv_i32 t1 = tcg_temp_new_i32(tcg_ctx);
|
||||
tcg_gen_shri_i32(tcg_ctx, t0, tcg_ctx->fpu_fcr31, get_fp_bit(cc));
|
||||
tcg_gen_shri_i32(tcg_ctx, t1, tcg_ctx->fpu_fcr31, get_fp_bit(cc+1));
|
||||
tcg_gen_shri_i32(tcg_ctx, t1, tcg_ctx->fpu_fcr31, get_fp_bit(cc + 1));
|
||||
tcg_gen_or_i32(tcg_ctx, t0, t0, t1);
|
||||
tcg_gen_shri_i32(tcg_ctx, t1, tcg_ctx->fpu_fcr31, get_fp_bit(cc+2));
|
||||
tcg_gen_shri_i32(tcg_ctx, t1, tcg_ctx->fpu_fcr31, get_fp_bit(cc + 2));
|
||||
tcg_gen_or_i32(tcg_ctx, t0, t0, t1);
|
||||
tcg_gen_shri_i32(tcg_ctx, t1, tcg_ctx->fpu_fcr31, get_fp_bit(cc+3));
|
||||
tcg_gen_shri_i32(tcg_ctx, t1, tcg_ctx->fpu_fcr31, get_fp_bit(cc + 3));
|
||||
tcg_gen_or_i32(tcg_ctx, t0, t0, t1);
|
||||
tcg_temp_free_i32(tcg_ctx, t1);
|
||||
tcg_gen_andi_i32(tcg_ctx, t0, t0, 1);
|
||||
|
@ -11005,7 +11012,7 @@ static inline void gen_movcf_ps(DisasContext *ctx, int fs, int fd,
|
|||
gen_store_fpr32(ctx, t0, fd);
|
||||
gen_set_label(tcg_ctx, l1);
|
||||
|
||||
tcg_gen_andi_i32(tcg_ctx, t0, tcg_ctx->fpu_fcr31, 1 << get_fp_bit(cc+1));
|
||||
tcg_gen_andi_i32(tcg_ctx, t0, tcg_ctx->fpu_fcr31, 1 << get_fp_bit(cc + 1));
|
||||
tcg_gen_brcondi_i32(tcg_ctx, cond, t0, 0, l2);
|
||||
gen_load_fpr32h(ctx, t0, fs);
|
||||
gen_store_fpr32h(ctx, t0, fd);
|
||||
|
@ -11624,9 +11631,9 @@ static void gen_farith(DisasContext *ctx, enum fopcode op1,
|
|||
case OPC_CMP_NGT_S:
|
||||
check_insn_opc_removed(ctx, ISA_MIPS32R6);
|
||||
if (ctx->opcode & (1 << 6)) {
|
||||
gen_cmpabs_s(ctx, func-48, ft, fs, cc);
|
||||
gen_cmpabs_s(ctx, func - 48, ft, fs, cc);
|
||||
} else {
|
||||
gen_cmp_s(ctx, func-48, ft, fs, cc);
|
||||
gen_cmp_s(ctx, func - 48, ft, fs, cc);
|
||||
}
|
||||
break;
|
||||
case OPC_ADD_D:
|
||||
|
@ -12106,9 +12113,9 @@ static void gen_farith(DisasContext *ctx, enum fopcode op1,
|
|||
case OPC_CMP_NGT_D:
|
||||
check_insn_opc_removed(ctx, ISA_MIPS32R6);
|
||||
if (ctx->opcode & (1 << 6)) {
|
||||
gen_cmpabs_d(ctx, func-48, ft, fs, cc);
|
||||
gen_cmpabs_d(ctx, func - 48, ft, fs, cc);
|
||||
} else {
|
||||
gen_cmp_d(ctx, func-48, ft, fs, cc);
|
||||
gen_cmp_d(ctx, func - 48, ft, fs, cc);
|
||||
}
|
||||
break;
|
||||
case OPC_CVT_S_D:
|
||||
|
@ -12508,9 +12515,9 @@ static void gen_farith(DisasContext *ctx, enum fopcode op1,
|
|||
case OPC_CMP_LE_PS:
|
||||
case OPC_CMP_NGT_PS:
|
||||
if (ctx->opcode & (1 << 6)) {
|
||||
gen_cmpabs_ps(ctx, func-48, ft, fs, cc);
|
||||
gen_cmpabs_ps(ctx, func - 48, ft, fs, cc);
|
||||
} else {
|
||||
gen_cmp_ps(ctx, func-48, ft, fs, cc);
|
||||
gen_cmp_ps(ctx, func - 48, ft, fs, cc);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -15058,11 +15065,11 @@ static int mmreg2(int r)
|
|||
|
||||
/* Signed immediate */
|
||||
#define SIMM(op, start, width) \
|
||||
((int32_t)(((op >> start) & ((~0U) >> (32-width))) \
|
||||
<< (32-width)) \
|
||||
>> (32-width))
|
||||
((int32_t)(((op >> start) & ((~0U) >> (32 - width))) \
|
||||
<< (32 - width)) \
|
||||
>> (32 - width))
|
||||
/* Zero-extended immediate */
|
||||
#define ZIMM(op, start, width) ((op >> start) & ((~0U) >> (32-width)))
|
||||
#define ZIMM(op, start, width) ((op >> start) & ((~0U) >> (32 - width)))
|
||||
|
||||
static void gen_addiur1sp(DisasContext *ctx)
|
||||
{
|
||||
|
@ -15761,7 +15768,10 @@ static void gen_pool32axf(CPUMIPSState *env, DisasContext *ctx, int rt, int rs)
|
|||
save_cpu_state(ctx, 1);
|
||||
gen_helper_di(tcg_ctx, t0, tcg_ctx->cpu_env);
|
||||
gen_store_gpr(ctx, t0, rs);
|
||||
/* Stop translation as we may have switched the execution mode */
|
||||
/*
|
||||
* Stop translation as we may have switched the execution
|
||||
* mode.
|
||||
*/
|
||||
ctx->base.is_jmp = DISAS_STOP;
|
||||
tcg_temp_free(tcg_ctx, t0);
|
||||
}
|
||||
|
@ -30345,7 +30355,7 @@ static void fpu_dump_state(CPUMIPSState *env, FILE *f, fprintf_function fpu_fpri
|
|||
(double)tmp.fs[FP_ENDIAN_IDX], \
|
||||
(double)tmp.fs[!FP_ENDIAN_IDX]); \
|
||||
} \
|
||||
} while(0)
|
||||
} while (0)
|
||||
|
||||
|
||||
fpu_fprintf(f, "CP1 FCR0 0x%08x FCR31 0x%08x SR.FR %d fp_status 0x%02x\n",
|
||||
|
|
Loading…
Reference in a new issue