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))
111 TRI, VirtReg, PhysReg, [&](
unsigned Unit,
const LiveRange &Range) {
113 Matrix[
Unit].unify(VirtReg, Range);
130 Matrix[
Unit].extract(VirtReg, Range);
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.
This class represents lattice values for constants.
bool empty() const
empty - Tests whether there are no bits in this bitvector.
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
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.
bool test(unsigned Idx) const
A live range for subregisters.
This represents a simple continuous liveness interval for a value.
STATISTIC(NumFunctions, "Total number of functions")
VNInfo - Value Number Information.
bool checkRegMaskInterference(LiveInterval &LI, BitVector &UsableRegs)
Test if LI is live across any register mask instructions, and compute a bit mask of physical register...
unsigned getNumRegUnits() const
Return the number of (native) register units in the target.
This class represents the liveness of a register, stack slot, etc.
#define INITIALIZE_PASS_DEPENDENCY(depName)
bool isValid() const
Returns true if this iterator is not yet at the end.
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.
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.
Printable printReg(unsigned Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubIdx=0, const MachineRegisterInfo *MRI=nullptr)
Prints virtual and physical registers with or without a TRI instance.
A helper class for register coalescers.
iterator_range< subrange_iterator > subranges()
Register unit interference.
bool hasSubRanges() const
Returns true if subregister liveness information is available.
Printable printRegUnit(unsigned Unit, const TargetRegisterInfo *TRI)
Create Printable object to print register units on a raw_ostream.
bool isPhysRegUsed(unsigned PhysReg) const
Returns true if the given PhysReg has any live intervals assigned.
void assign(LiveInterval &VirtReg, unsigned PhysReg)
Assign VirtReg to PhysReg.
iterator addSegment(Segment S)
Add the specified Segment to this range, merging segments as appropriate.
void init(unsigned NewUserTag, const LiveRange &NewLR, const LiveIntervalUnion &NewLiveUnion)
void invalidateVirtRegs()
Invalidate cached interference queries after modifying virtual register live ranges.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
Represent the analysis usage information of a pass.
INITIALIZE_PASS_BEGIN(LiveRegMatrix, "liveregmatrix", "Live Register Matrix", false, false) INITIALIZE_PASS_END(LiveRegMatrix
void unassign(LiveInterval &VirtReg)
Unassign VirtReg from its PhysReg.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE, "Assign register bank of generic virtual registers", false, false) RegBankSelect
constexpr bool empty(const T &RangeOrContainer)
Test whether RangeOrContainer is empty. Similar to C++17 std::empty.
void assignVirt2Phys(unsigned virtReg, MCPhysReg physReg)
creates a mapping for the specified virtual register to the specified physical register ...
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 clearVirt(unsigned virtReg)
clears the specified virtual register's, physical register mapping
bool isValid() const
isValid - returns true if this iterator is not yet at the end.
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)
bool overlaps(const LiveRange &other) const
overlaps - Return true if the intersection of the two live ranges is not empty.
bool hasPhys(unsigned virtReg) const
returns true if the specified virtual register is mapped to a physical register
AnalysisUsage & addRequiredTransitive()
unsigned getPhys(unsigned virtReg) const
returns the physical register mapped to the specified virtual register
SlotIndexes * getSlotIndexes() const
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.
SlotIndex - An opaque wrapper around machine indexes.
Virtual register interference.
LiveRange & getRegUnit(unsigned Unit)
Return the live range for register unit Unit.