33 #define DEBUG_TYPE "regalloc"
35 STATISTIC(NumAssigned ,
"Number of registers assigned");
36 STATISTIC(NumUnassigned ,
"Number of registers unassigned");
40 "Live Register Matrix",
false,
false)
48 void LiveRegMatrix::getAnalysisUsage(
AnalysisUsage &AU)
const {
57 LIS = &getAnalysis<LiveIntervals>();
58 VRM = &getAnalysis<VirtRegMap>();
61 if (NumRegUnits != Matrix.
size())
63 Matrix.
init(LIUAlloc, NumRegUnits);
70 void LiveRegMatrix::releaseMemory() {
71 for (
unsigned i = 0, e = Matrix.
size(); i != e; ++i) {
79 template <
typename Callable>
85 unsigned Unit = (*Units).first;
88 if ((S.LaneMask & Mask).any()) {
97 if (Func(*Units, VRegInterval))
106 <<
" to " <<
PrintReg(PhysReg, TRI) <<
':');
107 assert(!VRM->hasPhys(VirtReg.
reg) &&
"Duplicate VirtReg assignment");
108 VRM->assignVirt2Phys(VirtReg.
reg, PhysReg);
113 Matrix[
Unit].unify(VirtReg, Range);
122 unsigned PhysReg = VRM->getPhys(VirtReg.
reg);
124 <<
" from " <<
PrintReg(PhysReg, TRI) <<
':');
125 VRM->clearVirt(VirtReg.
reg);
130 Matrix[
Unit].extract(VirtReg, Range);
140 if (!Matrix[*
Unit].empty())
151 if (RegMaskVirtReg != VirtReg.
reg || RegMaskTag != UserTag) {
152 RegMaskVirtReg = VirtReg.
reg;
153 RegMaskTag = UserTag;
154 RegMaskUsable.
clear();
161 return !RegMaskUsable.
empty() && (!PhysReg || !RegMaskUsable.
test(PhysReg));
181 Q.
init(UserTag, LR, Matrix[RegUnit]);
199 bool Interference =
foreachUnit(TRI, VirtReg, PhysReg,
A common definition of LaneBitmask for use in TableGen and CodeGen.
No interference, go ahead and assign.
bool isValid() const
Returns true if this iterator is not yet at the end.
STATISTIC(NumFunctions,"Total number of functions")
bool isValid() const
isValid - returns true if this iterator is not yet at the end.
InterferenceKind checkInterference(LiveInterval &VirtReg, unsigned PhysReg)
Check for interference before assigning VirtReg to PhysReg.
LiveInterval - This class represents the liveness of a register, or stack slot.
A live range for subregisters.
bool checkRegMaskInterference(LiveInterval &LI, BitVector &UsableRegs)
Test if LI is live across any register mask instructions, and compute a bit mask of physical register...
This class represents the liveness of a register, stack slot, etc.
#define INITIALIZE_PASS_DEPENDENCY(depName)
void clear()
clear - Removes all bits from the bitvector. Does not change capacity.
Query interferences between a single live virtual register and a live interval union.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MCRegUnitMaskIterator enumerates a list of register units and their associated lane masks for Reg...
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
LiveIntervalUnion::Query & query(const LiveRange &LR, unsigned RegUnit)
Query a line of the assigned virtual register matrix directly.
A helper class for register coalescers.
iterator_range< subrange_iterator > subranges()
Register unit interference.
void assign(LiveInterval &VirtReg, unsigned PhysReg)
Assign VirtReg to PhysReg.
void init(unsigned NewUserTag, const LiveRange &NewLR, const LiveIntervalUnion &NewLiveUnion)
Printable PrintReg(unsigned Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubRegIdx=0)
Prints virtual and physical registers with or without a TRI instance.
void invalidateVirtRegs()
Invalidate cached interference queries after modifying virtual register live ranges.
SlotIndexes * getSlotIndexes() const
bool empty() const
empty - Tests whether there are no bits in this bitvector.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
bool overlaps(const LiveRange &other) const
overlaps - Return true if the intersection of the two live ranges is not empty.
Represent the analysis usage information of a pass.
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE,"Assign register bank of generic virtual registers", false, false) RegBankSelect
bool isPhysRegUsed(unsigned PhysReg) const
Returns true if the given PhysReg has any live intervals assigned.
void unassign(LiveInterval &VirtReg)
Unassign VirtReg from its PhysReg.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Printable PrintRegUnit(unsigned Unit, const TargetRegisterInfo *TRI)
Create Printable object to print register units on a raw_ostream.
bool test(unsigned Idx) const
bool checkRegUnitInterference(LiveInterval &VirtReg, unsigned PhysReg)
Check for regunit interference only.
void init(LiveIntervalUnion::Allocator &, unsigned Size)
Promote Memory to Register
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void setPreservesAll()
Set by analyses that do not transform their input at all.
static bool foreachUnit(const TargetRegisterInfo *TRI, LiveInterval &VRegInterval, unsigned PhysReg, Callable Func)
unsigned getNumRegUnits() const
Return the number of (native) register units in the target.
AnalysisUsage & addRequiredTransitive()
std::vector< uint8_t > Unit
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
bool checkRegMaskInterference(LiveInterval &VirtReg, unsigned PhysReg=0)
Check for regmask interference only.
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
bool hasSubRanges() const
Returns true if subregister liveness information is available.
Virtual register interference.
LiveRange & getRegUnit(unsigned Unit)
Return the live range for register unit Unit.
INITIALIZE_PASS_BEGIN(LiveRegMatrix,"liveregmatrix","Live Register Matrix", false, false) INITIALIZE_PASS_END(LiveRegMatrix