From 16701ae6d5cbcf0d519d32c3523e51ad69df5284 Mon Sep 17 00:00:00 2001 From: Merry Date: Sat, 23 Jul 2022 17:14:15 +0100 Subject: [PATCH] backend/arm64/reg_alloc: Use NZCV instead of magic numbers --- src/dynarmic/backend/arm64/emit_arm64_a32.cpp | 2 +- src/dynarmic/backend/arm64/reg_alloc.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/dynarmic/backend/arm64/emit_arm64_a32.cpp b/src/dynarmic/backend/arm64/emit_arm64_a32.cpp index 65ef6e68..af864ba1 100644 --- a/src/dynarmic/backend/arm64/emit_arm64_a32.cpp +++ b/src/dynarmic/backend/arm64/emit_arm64_a32.cpp @@ -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(0b11'011'0100'0010'000), Xscratch0); + code.MSR(oaknut::SystemReg::NZCV, Xscratch0); code.B(static_cast(cond), pass); return pass; } diff --git a/src/dynarmic/backend/arm64/reg_alloc.cpp b/src/dynarmic/backend/arm64/reg_alloc.cpp index c92e6d7f..a8e25501 100644 --- a/src/dynarmic/backend/arm64/reg_alloc.cpp +++ b/src/dynarmic/backend/arm64/reg_alloc.cpp @@ -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(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(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(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(0b11'011'0100'0010'000)); + code.MRS(oaknut::XReg{new_location_index}, oaknut::SystemReg::NZCV); gprs[new_location_index] = std::exchange(flags, {}); }