reg_alloc: Remove old register allocator interface
This commit is contained in:
parent
08a467bf9a
commit
cf93ab3d31
2 changed files with 1 additions and 86 deletions
|
@ -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) {
|
static bool IsSameHostLocClass(HostLoc a, HostLoc b) {
|
||||||
return (HostLocIsGPR(a) && HostLocIsGPR(b))
|
return (HostLocIsGPR(a) && HostLocIsGPR(b))
|
||||||
|| (HostLocIsXMM(a) && HostLocIsXMM(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);
|
DefineValue(def_inst, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::tuple<OpArg, HostLoc> 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) {
|
HostLoc RegAlloc::UseHostLocReg(IR::Value use_value, HostLocList desired_locations) {
|
||||||
if (!use_value.IsImmediate()) {
|
if (!use_value.IsImmediate()) {
|
||||||
return UseHostLocReg(use_value.GetInst(), desired_locations);
|
return UseHostLocReg(use_value.GetInst(), desired_locations);
|
||||||
|
@ -192,16 +168,6 @@ HostLoc RegAlloc::UseHostLocReg(IR::Inst* use_inst, HostLocList desired_location
|
||||||
return destination_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) {
|
HostLoc RegAlloc::UseScratchHostLocReg(IR::Value use_value, HostLocList desired_locations) {
|
||||||
if (!use_value.IsImmediate()) {
|
if (!use_value.IsImmediate()) {
|
||||||
return UseScratchHostLocReg(use_value.GetInst(), desired_locations);
|
return UseScratchHostLocReg(use_value.GetInst(), desired_locations);
|
||||||
|
|
|
@ -150,57 +150,6 @@ public:
|
||||||
RegisterAddDef(inst, arg.value);
|
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<OpArg, Xbyak::Reg64> 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<OpArg, Xbyak::Xmm> 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) {
|
Xbyak::Reg64 ScratchGpr(HostLocList desired_locations = any_gpr) {
|
||||||
return HostLocToReg64(ScratchHostLocReg(desired_locations));
|
return HostLocToReg64(ScratchHostLocReg(desired_locations));
|
||||||
}
|
}
|
||||||
|
@ -226,8 +175,8 @@ private:
|
||||||
boost::optional<HostLoc> ValueLocation(const IR::Inst* value) const;
|
boost::optional<HostLoc> ValueLocation(const IR::Inst* value) const;
|
||||||
|
|
||||||
void DefineValue(IR::Inst* def_inst, HostLoc host_loc);
|
void DefineValue(IR::Inst* def_inst, HostLoc host_loc);
|
||||||
|
void RegisterAddDef(IR::Inst* def_inst, const IR::Value& use_inst);
|
||||||
|
|
||||||
std::tuple<OpArg, HostLoc> UseDefOpArgHostLocReg(IR::Value use_value, IR::Inst* def_inst, HostLocList desired_locations);
|
|
||||||
HostLoc UseHostLocReg(IR::Value use_value, HostLocList desired_locations);
|
HostLoc UseHostLocReg(IR::Value use_value, HostLocList desired_locations);
|
||||||
HostLoc UseHostLocReg(IR::Inst* use_inst, HostLocList desired_locations);
|
HostLoc UseHostLocReg(IR::Inst* use_inst, HostLocList desired_locations);
|
||||||
HostLoc UseScratchHostLocReg(IR::Value use_value, HostLocList desired_locations);
|
HostLoc UseScratchHostLocReg(IR::Value use_value, HostLocList desired_locations);
|
||||||
|
|
Loading…
Reference in a new issue