LLVM 20.0.0git
|
#include "llvm/CodeGen/LiveRegMatrix.h"
Public Types | |
enum | InterferenceKind { IK_Free = 0 , IK_VirtReg , IK_RegUnit , IK_RegMask } |
Public Member Functions | |
LiveRegMatrix (LiveRegMatrix &&Other) | |
void | init (MachineFunction &MF, LiveIntervals &LIS, VirtRegMap &VRM) |
void | invalidateVirtRegs () |
Invalidate cached interference queries after modifying virtual register live ranges. | |
InterferenceKind | checkInterference (const LiveInterval &VirtReg, MCRegister PhysReg) |
Check for interference before assigning VirtReg to PhysReg. | |
bool | checkInterference (SlotIndex Start, SlotIndex End, MCRegister PhysReg) |
Check for interference in the segment [Start, End) that may prevent assignment to PhysReg. | |
LaneBitmask | checkInterferenceLanes (SlotIndex Start, SlotIndex End, MCRegister PhysReg) |
Check for interference in the segment [Start, End) that may prevent assignment to PhysReg, like checkInterference. | |
void | assign (const LiveInterval &VirtReg, MCRegister PhysReg) |
Assign VirtReg to PhysReg. | |
void | unassign (const LiveInterval &VirtReg) |
Unassign VirtReg from its PhysReg. | |
bool | isPhysRegUsed (MCRegister PhysReg) const |
Returns true if the given PhysReg has any live intervals assigned. | |
bool | checkRegMaskInterference (const LiveInterval &VirtReg, MCRegister PhysReg=MCRegister::NoRegister) |
Check for regmask interference only. | |
bool | checkRegUnitInterference (const LiveInterval &VirtReg, MCRegister PhysReg) |
Check for regunit interference only. | |
LiveIntervalUnion::Query & | query (const LiveRange &LR, MCRegister RegUnit) |
Query a line of the assigned virtual register matrix directly. | |
LiveIntervalUnion * | getLiveUnions () |
Directly access the live interval unions per regunit. | |
Register | getOneVReg (unsigned PhysReg) const |
Friends | |
class | LiveRegMatrixWrapperLegacy |
class | LiveRegMatrixAnalysis |
Definition at line 40 of file LiveRegMatrix.h.
Enumerator | |
---|---|
IK_Free | No interference, go ahead and assign. |
IK_VirtReg | Virtual register interference. There are interfering virtual registers assigned to PhysReg or its aliases. This interference could be resolved by unassigning those other virtual registers. |
IK_RegUnit | Register unit interference. A fixed live range is in the way, typically argument registers for a call. This can't be resolved by unassigning other virtual registers. |
IK_RegMask | RegMask interference. The live range is crossing an instruction with a regmask operand that doesn't preserve PhysReg. This typically means VirtReg is live across a call, and PhysReg isn't call-preserved. |
Definition at line 87 of file LiveRegMatrix.h.
|
inline |
Definition at line 66 of file LiveRegMatrix.h.
void LiveRegMatrix::assign | ( | const LiveInterval & | VirtReg, |
MCRegister | PhysReg | ||
) |
Assign VirtReg to PhysReg.
This will mark VirtReg's live range as occupied in the LiveRegMatrix and update VirtRegMap. The live range is expected to be available in PhysReg.
Definition at line 111 of file LiveRegMatrix.cpp.
References assert(), llvm::VirtRegMap::assignVirt2Phys(), llvm::dbgs(), foreachUnit(), llvm::VirtRegMap::hasPhys(), LLVM_DEBUG, llvm::printReg(), llvm::printRegUnit(), Range, and llvm::LiveInterval::reg().
Referenced by llvm::RegAllocBase::allocatePhysRegs().
LiveRegMatrix::InterferenceKind LiveRegMatrix::checkInterference | ( | const LiveInterval & | VirtReg, |
MCRegister | PhysReg | ||
) |
Check for interference before assigning VirtReg to PhysReg.
If this function returns IK_Free, it is legal to assign(VirtReg, PhysReg). When there is more than one kind of interference, the InterferenceKind with the highest enum value is returned.
Definition at line 193 of file LiveRegMatrix.cpp.
References llvm::LiveIntervalUnion::Query::checkInterference(), checkRegMaskInterference(), checkRegUnitInterference(), llvm::LiveRange::empty(), foreachUnit(), IK_Free, IK_RegMask, IK_RegUnit, IK_VirtReg, and query().
bool LiveRegMatrix::checkInterference | ( | SlotIndex | Start, |
SlotIndex | End, | ||
MCRegister | PhysReg | ||
) |
Check for interference in the segment [Start, End) that may prevent assignment to PhysReg.
If this function returns true, there is interference in the segment [Start, End) of some other interval already assigned to PhysReg. If this function returns false, PhysReg is free at the segment [Start, End).
Definition at line 217 of file LiveRegMatrix.cpp.
References llvm::LiveRange::addSegment(), llvm::LiveIntervalUnion::Query::checkInterference(), End, llvm::MCRegisterInfo::regunits(), and llvm::LiveIntervalUnion::Query::reset().
LaneBitmask LiveRegMatrix::checkInterferenceLanes | ( | SlotIndex | Start, |
SlotIndex | End, | ||
MCRegister | PhysReg | ||
) |
Check for interference in the segment [Start, End) that may prevent assignment to PhysReg, like checkInterference.
Returns a lane mask of which lanes of the physical register interfere in the segment [Start, End) of some other interval already assigned to PhysReg.
If this function returns LaneBitmask::getNone(), PhysReg is completely free at the segment [Start, End).
Definition at line 247 of file LiveRegMatrix.cpp.
References llvm::LiveRange::addSegment(), llvm::LiveIntervalUnion::Query::checkInterference(), End, llvm::MCRegUnitMaskIterator::isValid(), and llvm::LiveIntervalUnion::Query::reset().
bool LiveRegMatrix::checkRegMaskInterference | ( | const LiveInterval & | VirtReg, |
MCRegister | PhysReg = MCRegister::NoRegister |
||
) |
Check for regmask interference only.
Return true if VirtReg crosses a regmask operand that clobbers PhysReg. If PhysReg is null, check if VirtReg crosses any regmask operands.
Definition at line 153 of file LiveRegMatrix.cpp.
References llvm::LiveIntervals::checkRegMaskInterference(), llvm::BitVector::clear(), llvm::BitVector::empty(), llvm::LiveInterval::reg(), and llvm::BitVector::test().
Referenced by checkInterference().
bool LiveRegMatrix::checkRegUnitInterference | ( | const LiveInterval & | VirtReg, |
MCRegister | PhysReg | ||
) |
Check for regunit interference only.
Return true if VirtReg overlaps a fixed assignment of one of PhysRegs's register units.
Definition at line 171 of file LiveRegMatrix.cpp.
References llvm::LiveRange::empty(), foreachUnit(), llvm::LiveIntervals::getRegUnit(), llvm::LiveIntervals::getSlotIndexes(), Range, and llvm::LiveInterval::reg().
Referenced by checkInterference().
|
inline |
Directly access the live interval unions per regunit.
This returns an array indexed by the regunit number.
Definition at line 171 of file LiveRegMatrix.h.
References Matrix.
Referenced by llvm::RegAllocEvictionAdvisor::canReassign(), and llvm::RAGreedy::runOnMachineFunction().
Definition at line 282 of file LiveRegMatrix.cpp.
References getOneVReg(), llvm::MCRegister::NoRegister, llvm::LiveInterval::reg(), and llvm::MCRegisterInfo::regunits().
Referenced by getOneVReg().
void LiveRegMatrix::init | ( | MachineFunction & | MF, |
LiveIntervals & | LIS, | ||
VirtRegMap & | VRM | ||
) |
Definition at line 60 of file LiveRegMatrix.cpp.
References llvm::MCRegisterInfo::getNumRegUnits(), llvm::TargetSubtargetInfo::getRegisterInfo(), llvm::MachineFunction::getSubtarget(), llvm::LiveIntervalUnion::Array::init(), invalidateVirtRegs(), and llvm::LiveIntervalUnion::Array::size().
Referenced by llvm::LiveRegMatrixAnalysis::run(), and llvm::LiveRegMatrixWrapperLegacy::runOnMachineFunction().
|
inline |
Invalidate cached interference queries after modifying virtual register live ranges.
Interference checks may return stale information unless caches are invalidated.
Definition at line 85 of file LiveRegMatrix.h.
Referenced by llvm::RegAllocBase::allocatePhysRegs(), and init().
bool LiveRegMatrix::isPhysRegUsed | ( | MCRegister | PhysReg | ) | const |
Returns true if the given PhysReg
has any live intervals assigned.
Definition at line 145 of file LiveRegMatrix.cpp.
References llvm::MCRegisterInfo::regunits().
Referenced by llvm::RegAllocEvictionAdvisor::isUnusedCalleeSavedReg().
LiveIntervalUnion::Query & LiveRegMatrix::query | ( | const LiveRange & | LR, |
MCRegister | RegUnit | ||
) |
Query a line of the assigned virtual register matrix directly.
Use MCRegUnitIterator to enumerate all regunits in the desired PhysReg. This returns a reference to an internal Query data structure that is only valid until the next query() call.
Definition at line 185 of file LiveRegMatrix.cpp.
References llvm::LiveIntervalUnion::Query::init().
Referenced by checkInterference().
void LiveRegMatrix::unassign | ( | const LiveInterval & | VirtReg | ) |
Unassign VirtReg from its PhysReg.
Assuming that VirtReg was previously assigned to a PhysReg, this undoes the assignment and updates VirtRegMap accordingly.
Definition at line 128 of file LiveRegMatrix.cpp.
References llvm::VirtRegMap::clearVirt(), llvm::dbgs(), foreachUnit(), llvm::VirtRegMap::getPhys(), LLVM_DEBUG, llvm::printReg(), llvm::printRegUnit(), Range, and llvm::LiveInterval::reg().
|
friend |
Definition at line 42 of file LiveRegMatrix.h.
|
friend |
Definition at line 41 of file LiveRegMatrix.h.