35 #define DEBUG_TYPE "regalloc" 39 cl::desc(
"Limit all regclasses to N registers"));
55 assert(TRI &&
"no register info set");
59 if (Update || CSR != CalleeSavedRegs) {
62 CalleeSavedAliases.assign(TRI->
getNumRegs(), 0);
65 CalleeSavedAliases[*AI] = *
I;
69 CalleeSavedRegs = CSR;
73 if (Reserved.
size() != RR.
size() || RR != Reserved) {
81 PSetLimits.reset(
new unsigned[NumPSets]);
82 std::fill(&PSetLimits[0], &PSetLimits[NumPSets], 0);
91 assert(RC &&
"no register class given");
92 RCInfo &RCI = RegClass[RC->
getID()];
103 unsigned MinCost = 0xff;
104 unsigned LastCost = ~0u;
105 unsigned LastCostChange = 0;
110 for (
unsigned i = 0; i != RawOrder.
size(); ++i) {
111 unsigned PhysReg = RawOrder[i];
113 if (Reserved.
test(PhysReg))
116 MinCost = std::min(MinCost, Cost);
118 if (CalleeSavedAliases[PhysReg] &&
119 !STI.ignoreCSRForAllocationOrder(*MF, PhysReg))
123 if (Cost != LastCost)
125 RCI.Order[N++] = PhysReg;
129 RCI.NumRegs = N + CSRAlias.
size();
130 assert(RCI.NumRegs <= NumRegs &&
"Allocation order larger than regclass");
133 for (
unsigned i = 0,
e = CSRAlias.
size(); i !=
e; ++i) {
134 unsigned PhysReg = CSRAlias[i];
136 if (Cost != LastCost)
138 RCI.Order[N++] = PhysReg;
150 RCI.ProperSubClass =
true;
152 RCI.MinCost = uint8_t(MinCost);
153 RCI.LastCostChange = LastCostChange;
157 for (
unsigned I = 0;
I != RCI.NumRegs; ++
I)
159 dbgs() << (RCI.ProperSubClass ?
" ] (sub-class)\n" :
" ]\n");
171 unsigned NumRCUnits = 0;
174 for (; *PSetID != -1; ++PSetID) {
175 if ((
unsigned)*PSetID == Idx)
184 if (!RC || NUnits > NumRCUnits) {
189 assert(RC &&
"Failed to find register class");
virtual unsigned getNumRegPressureSets() const =0
Get the number of dimensions of register pressure.
This class represents lattice values for constants.
unsigned getNumRegs() const
Return the number of registers in this class.
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
ArrayRef< MCPhysReg > getRawAllocationOrder(const MachineFunction &MF) const
Returns the preferred order for allocating registers from this register class in MF.
void push_back(const T &Elt)
unsigned getCostPerUse(unsigned RegNo) const
Return the additional cost of using this register instead of other registers in its class...
bool test(unsigned Idx) const
unsigned computePSetLimit(unsigned Idx) const
This is not accurate because two overlapping register sets may have some nonoverlapping reserved regi...
virtual const int * getRegClassPressureSets(const TargetRegisterClass *RC) const =0
Get the dimensions of register pressure impacted by this register class.
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.
const char * getRegClassName(const TargetRegisterClass *Class) const
Returns the name of the register class.
iterator_range< regclass_iterator > regclasses() const
unsigned getID() const
Return the register class ID number.
unsigned getNumRegClasses() const
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
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...
unsigned getNumRegs() const
Return the number of registers this target has (useful for sizing arrays holding per register informa...
initializer< Ty > init(const Ty &Val)
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
size_t size() const
size - Get the array size.
MCRegAliasIterator enumerates all registers aliasing Reg.
unsigned getNumAllocatableRegs(const TargetRegisterClass *RC) const
getNumAllocatableRegs - Returns the number of actually allocatable registers in RC in the current fun...
void runOnMachineFunction(const MachineFunction &MF)
runOnFunction - Prepare to answer questions about MF.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
virtual const RegClassWeight & getRegClassWeight(const TargetRegisterClass *RC) const =0
Get the weight in units of pressure for this register class.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
const BitVector & getReservedRegs() const
getReservedRegs - Returns a reference to the frozen set of reserved registers.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
virtual unsigned getRegPressureSetLimit(const MachineFunction &MF, unsigned Idx) const =0
Get the register unit pressure limit for this dimension.
size_type size() const
size - Returns the number of bits in this bitvector.
static cl::opt< unsigned > StressRA("stress-regalloc", cl::Hidden, cl::init(0), cl::value_desc("N"), cl::desc("Limit all regclasses to N registers"))
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
const MCPhysReg * getCalleeSavedRegs() const
Returns list of callee saved registers.