From cf93ab3d3120f89f5d2a706f9c4e6e6d52dc9f17 Mon Sep 17 00:00:00 2001 From: MerryMage Date: Sat, 25 Feb 2017 17:16:23 +0000 Subject: [PATCH] reg_alloc: Remove old register allocator interface --- src/backend_x64/reg_alloc.cpp | 34 ---------------------- src/backend_x64/reg_alloc.h | 53 +---------------------------------- 2 files changed, 1 insertion(+), 86 deletions(-) diff --git a/src/backend_x64/reg_alloc.cpp b/src/backend_x64/reg_alloc.cpp index b2dd8276..8794ce3b 100644 --- a/src/backend_x64/reg_alloc.cpp +++ b/src/backend_x64/reg_alloc.cpp @@ -33,17 +33,6 @@ static u64 ImmediateToU64(const IR::Value& imm) { } } -static Xbyak::Reg HostLocToX64(HostLoc hostloc) { - if (HostLocIsGPR(hostloc)) { - DEBUG_ASSERT(hostloc != HostLoc::RSP && hostloc != HostLoc::R15); - return HostLocToReg64(hostloc); - } - if (HostLocIsXMM(hostloc)) { - return HostLocToXmm(hostloc); - } - ASSERT_MSG(false, "This should never happen."); -} - static bool IsSameHostLocClass(HostLoc a, HostLoc b) { return (HostLocIsGPR(a) && HostLocIsGPR(b)) || (HostLocIsXMM(a) && HostLocIsXMM(b)) @@ -145,19 +134,6 @@ void RegAlloc::RegisterAddDef(IR::Inst* def_inst, const IR::Value& use_inst) { DefineValue(def_inst, location); } -std::tuple RegAlloc::UseDefOpArgHostLocReg(IR::Value use_value, IR::Inst* def_inst, HostLocList desired_locations) { - DEBUG_ASSERT(std::all_of(desired_locations.begin(), desired_locations.end(), HostLocIsRegister)); - DEBUG_ASSERT_MSG(!ValueLocation(def_inst), "def_inst has already been defined"); - DEBUG_ASSERT_MSG(use_value.IsImmediate() || ValueLocation(use_value.GetInst()), "use_inst has not been defined"); - - // TODO: IsLastUse optimization - - OpArg use_oparg = UseOpArg(use_value, any_gpr); - HostLoc def_reg = ScratchHostLocReg(desired_locations); - DefineValue(def_inst, def_reg); - return std::make_tuple(use_oparg, def_reg); -} - HostLoc RegAlloc::UseHostLocReg(IR::Value use_value, HostLocList desired_locations) { if (!use_value.IsImmediate()) { return UseHostLocReg(use_value.GetInst(), desired_locations); @@ -192,16 +168,6 @@ HostLoc RegAlloc::UseHostLocReg(IR::Inst* use_inst, HostLocList desired_location return destination_location; } -OpArg RegAlloc::UseOpArg(IR::Value use_value, HostLocList desired_locations) { - if (use_value.IsImmediate()) { - ASSERT_MSG(false, "UseOpArg does not support immediates"); - return {}; // return a None - } - - // TODO: Reimplement properly - return HostLocToX64(UseHostLocReg(use_value.GetInst(), desired_locations)); -} - HostLoc RegAlloc::UseScratchHostLocReg(IR::Value use_value, HostLocList desired_locations) { if (!use_value.IsImmediate()) { return UseScratchHostLocReg(use_value.GetInst(), desired_locations); diff --git a/src/backend_x64/reg_alloc.h b/src/backend_x64/reg_alloc.h index e854ddfe..219342bb 100644 --- a/src/backend_x64/reg_alloc.h +++ b/src/backend_x64/reg_alloc.h @@ -150,57 +150,6 @@ public: RegisterAddDef(inst, arg.value); } - /// Late-def - Xbyak::Reg64 DefGpr(IR::Inst* def_inst, HostLocList desired_locations = any_gpr) { - HostLoc location = ScratchHostLocReg(desired_locations); - DefineValue(def_inst, location); - return HostLocToReg64(location); - } - Xbyak::Xmm DefXmm(IR::Inst* def_inst, HostLocList desired_locations = any_xmm) { - HostLoc location = ScratchHostLocReg(desired_locations); - DefineValue(def_inst, location); - return HostLocToXmm(location); - } - void RegisterAddDef(IR::Inst* def_inst, const IR::Value& use_inst); - /// Early-use, Late-def - Xbyak::Reg64 UseDefGpr(IR::Value use_value, IR::Inst* def_inst, HostLocList desired_locations = any_gpr) { - HostLoc location = UseScratchHostLocReg(use_value, desired_locations); - DefineValue(def_inst, location); - return HostLocToReg64(location); - } - Xbyak::Xmm UseDefXmm(IR::Value use_value, IR::Inst* def_inst, HostLocList desired_locations = any_xmm) { - HostLoc location = UseScratchHostLocReg(use_value, desired_locations); - DefineValue(def_inst, location); - return HostLocToXmm(location); - } - std::tuple UseDefOpArgGpr(IR::Value use_value, IR::Inst* def_inst, HostLocList desired_locations = any_gpr) { - OpArg op; - HostLoc host_loc; - std::tie(op, host_loc) = UseDefOpArgHostLocReg(use_value, def_inst, desired_locations); - return std::make_tuple(op, HostLocToReg64(host_loc)); - } - std::tuple UseDefOpArgXmm(IR::Value use_value, IR::Inst* def_inst, HostLocList desired_locations = any_xmm) { - OpArg op; - HostLoc host_loc; - std::tie(op, host_loc) = UseDefOpArgHostLocReg(use_value, def_inst, desired_locations); - return std::make_tuple(op, HostLocToXmm(host_loc)); - } - /// Early-use - Xbyak::Reg64 UseGpr(IR::Value use_value, HostLocList desired_locations = any_gpr) { - return HostLocToReg64(UseHostLocReg(use_value, desired_locations)); - } - Xbyak::Xmm UseXmm(IR::Value use_value, HostLocList desired_locations = any_xmm) { - return HostLocToXmm(UseHostLocReg(use_value, desired_locations)); - } - OpArg UseOpArg(IR::Value use_value, HostLocList desired_locations); - /// Early-use, Destroyed - Xbyak::Reg64 UseScratchGpr(IR::Value use_value, HostLocList desired_locations = any_gpr) { - return HostLocToReg64(UseScratchHostLocReg(use_value, desired_locations)); - } - Xbyak::Xmm UseScratchXmm(IR::Value use_value, HostLocList desired_locations = any_xmm) { - return HostLocToXmm(UseScratchHostLocReg(use_value, desired_locations)); - } - /// Early-def, Late-use, single-use Xbyak::Reg64 ScratchGpr(HostLocList desired_locations = any_gpr) { return HostLocToReg64(ScratchHostLocReg(desired_locations)); } @@ -226,8 +175,8 @@ private: boost::optional ValueLocation(const IR::Inst* value) const; void DefineValue(IR::Inst* def_inst, HostLoc host_loc); + void RegisterAddDef(IR::Inst* def_inst, const IR::Value& use_inst); - std::tuple UseDefOpArgHostLocReg(IR::Value use_value, IR::Inst* def_inst, HostLocList desired_locations); HostLoc UseHostLocReg(IR::Value use_value, HostLocList desired_locations); HostLoc UseHostLocReg(IR::Inst* use_inst, HostLocList desired_locations); HostLoc UseScratchHostLocReg(IR::Value use_value, HostLocList desired_locations);