backend/arm64/reg_alloc: Use NZCV instead of magic numbers
This commit is contained in:
parent
ba00b3586c
commit
16701ae6d5
2 changed files with 5 additions and 5 deletions
|
@ -25,7 +25,7 @@ oaknut::Label EmitA32Cond(oaknut::CodeGenerator& code, EmitContext&, IR::Cond co
|
||||||
oaknut::Label pass;
|
oaknut::Label pass;
|
||||||
// TODO: Flags in host flags
|
// TODO: Flags in host flags
|
||||||
code.LDR(Wscratch0, Xstate, offsetof(A32JitState, cpsr_nzcv));
|
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);
|
code.B(static_cast<oaknut::Cond>(cond), pass);
|
||||||
return pass;
|
return pass;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
code.LDR(oaknut::XReg{new_location_index}, SP, spill_offset + new_location_index * spill_slot_size);
|
||||||
break;
|
break;
|
||||||
case HostLoc::Kind::Flags:
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -301,13 +301,13 @@ void RegAlloc::ReadWriteFlags(Argument& read, IR::Inst* write) {
|
||||||
if (!flags.values.empty()) {
|
if (!flags.values.empty()) {
|
||||||
SpillFlags();
|
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) {
|
} else if (current_location->kind == HostLoc::Kind::Spill) {
|
||||||
if (!flags.values.empty()) {
|
if (!flags.values.empty()) {
|
||||||
SpillFlags();
|
SpillFlags();
|
||||||
}
|
}
|
||||||
code.LDR(Wscratch0, SP, spill_offset + current_location->index * spill_slot_size);
|
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 {
|
} else {
|
||||||
ASSERT_FALSE("Invalid current location for flags");
|
ASSERT_FALSE("Invalid current location for flags");
|
||||||
}
|
}
|
||||||
|
@ -321,7 +321,7 @@ void RegAlloc::SpillFlags() {
|
||||||
}
|
}
|
||||||
const int new_location_index = AllocateRegister(gprs, gpr_order);
|
const int new_location_index = AllocateRegister(gprs, gpr_order);
|
||||||
SpillGpr(new_location_index);
|
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, {});
|
gprs[new_location_index] = std::exchange(flags, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue