From 70d91378595b0414274f9b660a6e7751ae447354 Mon Sep 17 00:00:00 2001 From: Merry Date: Sun, 24 Jul 2022 20:11:02 +0100 Subject: [PATCH] backend/arm64/reg_alloc: Handle immediates in PrepareForCall --- src/dynarmic/backend/arm64/reg_alloc.cpp | 11 ++++++++--- src/dynarmic/backend/arm64/reg_alloc.h | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/dynarmic/backend/arm64/reg_alloc.cpp b/src/dynarmic/backend/arm64/reg_alloc.cpp index fb1ce492..0e7126b0 100644 --- a/src/dynarmic/backend/arm64/reg_alloc.cpp +++ b/src/dynarmic/backend/arm64/reg_alloc.cpp @@ -167,7 +167,7 @@ void RegAlloc::PrepareForCall(IR::Inst* result, std::optional, 4> args{arg0, arg1, arg2, arg3}; for (int i = 0; i < 4; i++) { if (args[i]) { - LoadCopyInto(args[i]->get().value.GetInst(), oaknut::XReg{i}); + LoadCopyInto(args[i]->get().value, oaknut::XReg{i}); } } @@ -416,8 +416,13 @@ int RegAlloc::FindFreeSpill() const { return static_cast(iter - spills.begin()); } -void RegAlloc::LoadCopyInto(IR::Inst* inst, oaknut::XReg reg) { - const auto current_location = ValueLocation(inst); +void RegAlloc::LoadCopyInto(const IR::Value& value, oaknut::XReg reg) { + if (value.IsImmediate()) { + code.MOV(reg, value.GetImmediateAsU64()); + return; + } + + const auto current_location = ValueLocation(value.GetInst()); ASSERT(current_location); ASSERT(gprs[reg.index()].IsCompletelyEmpty()); switch (current_location->kind) { diff --git a/src/dynarmic/backend/arm64/reg_alloc.h b/src/dynarmic/backend/arm64/reg_alloc.h index 7857c625..151ffa2b 100644 --- a/src/dynarmic/backend/arm64/reg_alloc.h +++ b/src/dynarmic/backend/arm64/reg_alloc.h @@ -261,7 +261,7 @@ private: void SpillFpr(int index); int FindFreeSpill() const; - void LoadCopyInto(IR::Inst* inst, oaknut::XReg reg); + void LoadCopyInto(const IR::Value& value, oaknut::XReg reg); std::optional ValueLocation(const IR::Inst* value) const; HostLocInfo& ValueInfo(HostLoc host_loc);