emit_arm64_a32: Fix A32SetCpsrNZC for immediate carry
This commit is contained in:
parent
33b3376fb1
commit
735f5b787a
1 changed files with 23 additions and 9 deletions
|
@ -313,17 +313,31 @@ template<>
|
||||||
void EmitIR<IR::Opcode::A32SetCpsrNZC>(oaknut::CodeGenerator& code, EmitContext& ctx, IR::Inst* inst) {
|
void EmitIR<IR::Opcode::A32SetCpsrNZC>(oaknut::CodeGenerator& code, EmitContext& ctx, IR::Inst* inst) {
|
||||||
auto args = ctx.reg_alloc.GetArgumentInfo(inst);
|
auto args = ctx.reg_alloc.GetArgumentInfo(inst);
|
||||||
|
|
||||||
auto Wnz = ctx.reg_alloc.ReadW(args[0]);
|
|
||||||
auto Wc = ctx.reg_alloc.ReadW(args[1]);
|
|
||||||
RegAlloc::Realize(Wnz, Wc);
|
|
||||||
|
|
||||||
// TODO: Track latent value
|
// TODO: Track latent value
|
||||||
|
|
||||||
code.LDR(Wscratch0, Xstate, offsetof(A32JitState, cpsr_nzcv));
|
if (args[1].IsImmediate()) {
|
||||||
code.AND(Wscratch0, Wscratch0, 0x10000000);
|
const u32 carry = args[1].GetImmediateU1() ? 0x2000'0000 : 0;
|
||||||
code.ORR(Wscratch0, Wscratch0, Wnz);
|
auto Wnz = ctx.reg_alloc.ReadW(args[0]);
|
||||||
code.ORR(Wscratch0, Wscratch0, Wc);
|
RegAlloc::Realize(Wnz);
|
||||||
code.STR(Wscratch0, Xstate, offsetof(A32JitState, cpsr_nzcv));
|
|
||||||
|
code.LDR(Wscratch0, Xstate, offsetof(A32JitState, cpsr_nzcv));
|
||||||
|
code.AND(Wscratch0, Wscratch0, 0x10000000);
|
||||||
|
code.ORR(Wscratch0, Wscratch0, Wnz);
|
||||||
|
if (carry) {
|
||||||
|
code.ORR(Wscratch0, Wscratch0, carry);
|
||||||
|
}
|
||||||
|
code.STR(Wscratch0, Xstate, offsetof(A32JitState, cpsr_nzcv));
|
||||||
|
} else {
|
||||||
|
auto Wnz = ctx.reg_alloc.ReadW(args[0]);
|
||||||
|
auto Wc = ctx.reg_alloc.ReadW(args[1]);
|
||||||
|
RegAlloc::Realize(Wnz, Wc);
|
||||||
|
|
||||||
|
code.LDR(Wscratch0, Xstate, offsetof(A32JitState, cpsr_nzcv));
|
||||||
|
code.AND(Wscratch0, Wscratch0, 0x10000000);
|
||||||
|
code.ORR(Wscratch0, Wscratch0, Wnz);
|
||||||
|
code.ORR(Wscratch0, Wscratch0, Wc);
|
||||||
|
code.STR(Wscratch0, Xstate, offsetof(A32JitState, cpsr_nzcv));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
|
|
Loading…
Reference in a new issue