backend/arm64/reg_alloc: Use NZCV instead of magic numbers

This commit is contained in:
Merry 2022-07-23 17:14:15 +01:00 committed by merry
parent ba00b3586c
commit 16701ae6d5
2 changed files with 5 additions and 5 deletions

View file

@ -25,7 +25,7 @@ oaknut::Label EmitA32Cond(oaknut::CodeGenerator& code, EmitContext&, IR::Cond co
oaknut::Label pass;
// TODO: Flags in host flags
code.LDR(Wscratch0, Xstate, offsetof(A32JitState, cpsr_nzcv));
code.MSR(static_cast<oaknut::SystemReg>(0b11'011'0100'0010'000), Xscratch0);
code.MSR(oaknut::SystemReg::NZCV, Xscratch0);
code.B(static_cast<oaknut::Cond>(cond), pass);
return pass;
}

View file

@ -183,7 +183,7 @@ int RegAlloc::RealizeReadImpl(const IR::Inst* value) {
code.LDR(oaknut::XReg{new_location_index}, SP, spill_offset + new_location_index * spill_slot_size);
break;
case HostLoc::Kind::Flags:
code.MRS(oaknut::XReg{new_location_index}, static_cast<oaknut::SystemReg>(0b11'011'0100'0010'000));
code.MRS(oaknut::XReg{new_location_index}, oaknut::SystemReg::NZCV);
break;
}
@ -301,13 +301,13 @@ void RegAlloc::ReadWriteFlags(Argument& read, IR::Inst* write) {
if (!flags.values.empty()) {
SpillFlags();
}
code.MSR(static_cast<oaknut::SystemReg>(0b11'011'0100'0010'000), oaknut::XReg{current_location->index});
code.MSR(oaknut::SystemReg::NZCV, oaknut::XReg{current_location->index});
} else if (current_location->kind == HostLoc::Kind::Spill) {
if (!flags.values.empty()) {
SpillFlags();
}
code.LDR(Wscratch0, SP, spill_offset + current_location->index * spill_slot_size);
code.MSR(static_cast<oaknut::SystemReg>(0b11'011'0100'0010'000), Xscratch0);
code.MSR(oaknut::SystemReg::NZCV, Xscratch0);
} else {
ASSERT_FALSE("Invalid current location for flags");
}
@ -321,7 +321,7 @@ void RegAlloc::SpillFlags() {
}
const int new_location_index = AllocateRegister(gprs, gpr_order);
SpillGpr(new_location_index);
code.MRS(oaknut::XReg{new_location_index}, static_cast<oaknut::SystemReg>(0b11'011'0100'0010'000));
code.MRS(oaknut::XReg{new_location_index}, oaknut::SystemReg::NZCV);
gprs[new_location_index] = std::exchange(flags, {});
}