提交 2fbac54b 编写于 作者: F Filip Navara 提交者: Aurelien Jarno

target-arm: get rid of gen_set_psr_T0 and replace it by gen_set_psr/gen_set_psr_im

Signed-off-by: NFilip Navara <filip.navara@gmail.com>
Signed-off-by: NAurelien Jarno <aurelien@aurel32.net>
上级 c67b6b71
...@@ -3415,8 +3415,8 @@ static uint32_t msr_mask(CPUState *env, DisasContext *s, int flags, int spsr) { ...@@ -3415,8 +3415,8 @@ static uint32_t msr_mask(CPUState *env, DisasContext *s, int flags, int spsr) {
return mask; return mask;
} }
/* Returns nonzero if access to the PSR is not permitted. */ /* Returns nonzero if access to the PSR is not permitted. Marks t0 as dead. */
static int gen_set_psr_T0(DisasContext *s, uint32_t mask, int spsr) static int gen_set_psr(DisasContext *s, uint32_t mask, int spsr, TCGv t0)
{ {
TCGv tmp; TCGv tmp;
if (spsr) { if (spsr) {
...@@ -3426,16 +3426,26 @@ static int gen_set_psr_T0(DisasContext *s, uint32_t mask, int spsr) ...@@ -3426,16 +3426,26 @@ static int gen_set_psr_T0(DisasContext *s, uint32_t mask, int spsr)
tmp = load_cpu_field(spsr); tmp = load_cpu_field(spsr);
tcg_gen_andi_i32(tmp, tmp, ~mask); tcg_gen_andi_i32(tmp, tmp, ~mask);
tcg_gen_andi_i32(cpu_T[0], cpu_T[0], mask); tcg_gen_andi_i32(t0, t0, mask);
tcg_gen_or_i32(tmp, tmp, cpu_T[0]); tcg_gen_or_i32(tmp, tmp, t0);
store_cpu_field(tmp, spsr); store_cpu_field(tmp, spsr);
} else { } else {
gen_set_cpsr(cpu_T[0], mask); gen_set_cpsr(t0, mask);
} }
dead_tmp(t0);
gen_lookup_tb(s); gen_lookup_tb(s);
return 0; return 0;
} }
/* Returns nonzero if access to the PSR is not permitted. */
static int gen_set_psr_im(DisasContext *s, uint32_t mask, int spsr, uint32_t val)
{
TCGv tmp;
tmp = new_tmp();
tcg_gen_movi_i32(tmp, val);
return gen_set_psr(s, mask, spsr, tmp);
}
/* Generate an old-style exception return. Marks pc as dead. */ /* Generate an old-style exception return. Marks pc as dead. */
static void gen_exception_return(DisasContext *s, TCGv pc) static void gen_exception_return(DisasContext *s, TCGv pc)
{ {
...@@ -5883,8 +5893,7 @@ static void disas_arm_insn(CPUState * env, DisasContext *s) ...@@ -5883,8 +5893,7 @@ static void disas_arm_insn(CPUState * env, DisasContext *s)
val |= (insn & 0x1f); val |= (insn & 0x1f);
} }
if (mask) { if (mask) {
gen_op_movl_T0_im(val); gen_set_psr_im(s, mask, 0, val);
gen_set_psr_T0(s, mask, 0);
} }
return; return;
} }
...@@ -5924,9 +5933,8 @@ static void disas_arm_insn(CPUState * env, DisasContext *s) ...@@ -5924,9 +5933,8 @@ static void disas_arm_insn(CPUState * env, DisasContext *s)
shift = ((insn >> 8) & 0xf) * 2; shift = ((insn >> 8) & 0xf) * 2;
if (shift) if (shift)
val = (val >> shift) | (val << (32 - shift)); val = (val >> shift) | (val << (32 - shift));
gen_op_movl_T0_im(val);
i = ((insn & (1 << 22)) != 0); i = ((insn & (1 << 22)) != 0);
if (gen_set_psr_T0(s, msr_mask(env, s, (insn >> 16) & 0xf, i), i)) if (gen_set_psr_im(s, msr_mask(env, s, (insn >> 16) & 0xf, i), i, val))
goto illegal_op; goto illegal_op;
} }
} }
...@@ -5940,9 +5948,9 @@ static void disas_arm_insn(CPUState * env, DisasContext *s) ...@@ -5940,9 +5948,9 @@ static void disas_arm_insn(CPUState * env, DisasContext *s)
case 0x0: /* move program status register */ case 0x0: /* move program status register */
if (op1 & 1) { if (op1 & 1) {
/* PSR = reg */ /* PSR = reg */
gen_movl_T0_reg(s, rm); tmp = load_reg(s, rm);
i = ((op1 & 2) != 0); i = ((op1 & 2) != 0);
if (gen_set_psr_T0(s, msr_mask(env, s, (insn >> 16) & 0xf, i), i)) if (gen_set_psr(s, msr_mask(env, s, (insn >> 16) & 0xf, i), i, tmp))
goto illegal_op; goto illegal_op;
} else { } else {
/* reg = PSR */ /* reg = PSR */
...@@ -7647,10 +7655,10 @@ static int disas_thumb2_insn(CPUState *env, DisasContext *s, uint16_t insn_hw1) ...@@ -7647,10 +7655,10 @@ static int disas_thumb2_insn(CPUState *env, DisasContext *s, uint16_t insn_hw1)
case 1: /* msr spsr. */ case 1: /* msr spsr. */
if (IS_M(env)) if (IS_M(env))
goto illegal_op; goto illegal_op;
gen_movl_T0_reg(s, rn); tmp = load_reg(s, rn);
if (gen_set_psr_T0(s, if (gen_set_psr(s,
msr_mask(env, s, (insn >> 8) & 0xf, op == 1), msr_mask(env, s, (insn >> 8) & 0xf, op == 1),
op == 1)) op == 1, tmp))
goto illegal_op; goto illegal_op;
break; break;
case 2: /* cps, nop-hint. */ case 2: /* cps, nop-hint. */
...@@ -7677,8 +7685,7 @@ static int disas_thumb2_insn(CPUState *env, DisasContext *s, uint16_t insn_hw1) ...@@ -7677,8 +7685,7 @@ static int disas_thumb2_insn(CPUState *env, DisasContext *s, uint16_t insn_hw1)
imm |= (insn & 0x1f); imm |= (insn & 0x1f);
} }
if (offset) { if (offset) {
gen_op_movl_T0_im(imm); gen_set_psr_im(s, offset, 0, imm);
gen_set_psr_T0(s, offset, 0);
} }
break; break;
case 3: /* Special control operations. */ case 3: /* Special control operations. */
...@@ -8566,10 +8573,7 @@ static void disas_thumb_insn(CPUState *env, DisasContext *s) ...@@ -8566,10 +8573,7 @@ static void disas_thumb_insn(CPUState *env, DisasContext *s)
shift = CPSR_A | CPSR_I | CPSR_F; shift = CPSR_A | CPSR_I | CPSR_F;
else else
shift = 0; shift = 0;
gen_set_psr_im(s, shift, 0, ((insn & 7) << 6) & shift);
val = ((insn & 7) << 6) & shift;
gen_op_movl_T0_im(val);
gen_set_psr_T0(s, shift, 0);
} }
break; break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册