34#define DEBUG_TYPE "regalloc"
38 cl::desc(
"Limit all regclasses to N registers"));
50 if (STI.getRegisterInfo() != TRI || Reverse != Rev) {
52 TRI = STI.getRegisterInfo();
60 bool CSRChanged =
true;
63 size_t LastSize = LastCalleeSavedRegs.size();
64 for (
unsigned I = 0;; ++
I) {
66 CSRChanged =
I != LastSize;
73 if (CSR[
I] != LastCalleeSavedRegs[
I]) {
82 LastCalleeSavedRegs.clear();
88 CalleeSavedAliases[U] = *
I;
89 LastCalleeSavedRegs.push_back(*
I);
100 CSRHintsForAllocOrder[(*AI).id()] =
101 STI.ignoreCSRForAllocationOrder(mf, *AI);
102 if (IgnoreCSRForAllocOrder != CSRHintsForAllocOrder) {
104 IgnoreCSRForAllocOrder = CSRHintsForAllocOrder;
111 if (RR != Reserved) {
119 PSetLimits.reset(
new unsigned[NumPSets]);
120 std::fill(&PSetLimits[0], &PSetLimits[NumPSets], 0);
129 assert(RC &&
"no register class given");
130 RCInfo &RCI = RegClass[RC->
getID()];
143 unsigned LastCostChange = 0;
148 std::vector<MCPhysReg> ReverseOrder;
153 for (
unsigned PhysReg : RawOrder) {
155 if (Reserved.
test(PhysReg))
158 MinCost = std::min(MinCost,
Cost);
161 !STI.ignoreCSRForAllocationOrder(*MF, PhysReg))
165 if (
Cost != LastCost)
167 RCI.Order[
N++] = PhysReg;
171 RCI.NumRegs =
N + CSRAlias.
size();
172 assert(RCI.NumRegs <= NumRegs &&
"Allocation order larger than regclass");
175 for (
unsigned PhysReg : CSRAlias) {
177 if (
Cost != LastCost)
179 RCI.Order[
N++] = PhysReg;
191 RCI.ProperSubClass =
true;
193 RCI.MinCost = MinCost;
194 RCI.LastCostChange = LastCostChange;
198 for (
unsigned I = 0;
I != RCI.NumRegs; ++
I)
200 dbgs() << (RCI.ProperSubClass ?
" ] (sub-class)\n" :
" ]\n");
212 unsigned NumRCUnits = 0;
215 for (; *PSetID != -1; ++PSetID) {
216 if ((
unsigned)*PSetID ==
Idx)
225 if (!RC || NUnits > NumRCUnits) {
230 assert(RC &&
"Failed to find register class");
238 if (NAllocatableRegs == 0)
239 return RegPressureSetLimit;
240 unsigned NReserved = RC->
getNumRegs() - NAllocatableRegs;
unsigned const MachineRegisterInfo * MRI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file implements the BitVector class.
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
static cl::opt< unsigned > StressRA("stress-regalloc", cl::Hidden, cl::init(0), cl::value_desc("N"), cl::desc("Limit all regclasses to N registers"))
This file defines the SmallVector class.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
bool test(unsigned Idx) const
MCRegAliasIterator enumerates all registers aliasing Reg.
unsigned getNumRegUnits() const
Return the number of (native) register units in the target.
iterator_range< MCRegUnitIterator > regunits(MCRegister Reg) const
Returns an iterator range over all regunits for Reg.
unsigned getNumRegs() const
Return the number of registers this target has (useful for sizing arrays holding per register informa...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
const BitVector & getReservedRegs() const
getReservedRegs - Returns a reference to the frozen set of reserved registers.
unsigned getNumAllocatableRegs(const TargetRegisterClass *RC) const
getNumAllocatableRegs - Returns the number of actually allocatable registers in RC in the current fun...
LLVM_ABI void runOnMachineFunction(const MachineFunction &MF, bool Rev=false)
runOnFunction - Prepare to answer questions about MF.
MCRegister getLastCalleeSavedAlias(MCRegister PhysReg) const
getLastCalleeSavedAlias - Returns the last callee saved register that overlaps PhysReg,...
LLVM_ABI RegisterClassInfo()
LLVM_ABI unsigned computePSetLimit(unsigned Idx) const
This is not accurate because two overlapping register sets may have some nonoverlapping reserved regi...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
unsigned getNumRegs() const
Return the number of registers in this class.
unsigned getID() const
Return the register class ID number.
ArrayRef< MCPhysReg > getRawAllocationOrder(const MachineFunction &MF, bool Rev=false) const
Returns the preferred order for allocating registers from this register class in MF.
virtual unsigned getNumRegPressureSets() const =0
Get the number of dimensions of register pressure.
iterator_range< regclass_iterator > regclasses() const
ArrayRef< uint8_t > getRegisterCosts(const MachineFunction &MF) const
Get a list of cost values for all registers that correspond to the index returned by RegisterCostTabl...
unsigned getNumRegClasses() const
virtual const int * getRegClassPressureSets(const TargetRegisterClass *RC) const =0
Get the dimensions of register pressure impacted by this register class.
virtual const RegClassWeight & getRegClassWeight(const TargetRegisterClass *RC) const =0
Get the weight in units of pressure for this register class.
virtual const TargetRegisterClass * getLargestLegalSuperClass(const TargetRegisterClass *RC, const MachineFunction &) const
Returns the largest super class of RC that is legal to use in the current sub-target and has the same...
virtual unsigned getRegPressureSetLimit(const MachineFunction &MF, unsigned Idx) const =0
Get the register unit pressure limit for this dimension.
const char * getRegClassName(const TargetRegisterClass *Class) const
Returns the name of the register class.
@ C
The default llvm calling convention, compatible with C.
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
void append_range(Container &C, Range &&R)
Wrapper function to append range R to container C.
auto reverse(ContainerTy &&C)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ABI Printable printReg(Register Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubIdx=0, const MachineRegisterInfo *MRI=nullptr)
Prints virtual and physical registers with or without a TRI instance.