20 #ifndef LLVM_CODEGEN_LIVEINTERVALS_H 21 #define LLVM_CODEGEN_LIVEINTERVALS_H 46 class MachineBlockFrequencyInfo;
47 class MachineDominatorTree;
48 class MachineFunction;
50 class MachineRegisterInfo;
52 class TargetInstrInfo;
117 return *VirtRegIntervals[
Reg];
127 return VirtRegIntervals.
inBounds(Reg) && VirtRegIntervals[
Reg];
133 VirtRegIntervals.
grow(Reg);
134 VirtRegIntervals[
Reg] = createInterval(Reg);
135 return *VirtRegIntervals[
Reg];
140 computeVirtRegInterval(LI);
146 delete VirtRegIntervals[
Reg];
147 VirtRegIntervals[
Reg] =
nullptr;
208 "Use pruneValue on the main LiveRange and on each subrange");
262 "Blocks must be added in order.");
263 RegMaskBlocks.
push_back(std::make_pair(RegMaskSlots.
size(), 0));
322 bool UpdateFlags =
false);
356 std::pair<unsigned, unsigned>
P = RegMaskBlocks[MBBNum];
367 std::pair<unsigned, unsigned>
P = RegMaskBlocks[MBBNum];
398 RegUnitRanges[
Unit] = LR =
new LiveRange(UseSegmentSetForPhysRegs);
399 computeRegUnitRange(*LR, Unit);
407 return RegUnitRanges[
Unit];
411 return RegUnitRanges[
Unit];
417 delete RegUnitRanges[
Unit];
418 RegUnitRanges[
Unit] =
nullptr;
441 void computeVirtRegs();
444 void computeRegMasks();
459 void dumpInstrs()
const;
461 void computeLiveInRegUnits();
466 void extendSegmentsToUses(
LiveRange &Segments,
A common definition of LaneBitmask for use in TableGen and CodeGen.
void extendToIndices(LiveRange &LR, ArrayRef< SlotIndex > Indices)
static float getSpillWeight(bool isDef, bool isUse, const MachineBlockFrequencyInfo *MBFI, const MachineInstr &MI)
Calculate the spill weight to assign to a single instruction.
void RemoveMachineInstrFromMaps(MachineInstr &MI)
This class represents lattice values for constants.
bool hasPHIKill(const LiveInterval &LI, const VNInfo *VNI) const
Returns true if VNI is killed by any PHI-def values in LI.
void removePhysRegDefAt(unsigned Reg, SlotIndex Pos)
Remove value numbers and related live segments starting at position Pos that are part of any liverang...
A Module instance is used to store all the information related to an LLVM module. ...
bool runOnMachineFunction(MachineFunction &) override
Pass entry point; Calculates LiveIntervals.
void push_back(const T &Elt)
LiveInterval - This class represents the liveness of a register, or stack slot.
ArrayRef< const uint32_t * > getRegMaskBits() const
Returns an array of register mask pointers corresponding to getRegMaskSlots().
void removeMachineInstrFromMaps(MachineInstr &MI)
Removes machine instruction (bundle) MI from the mapping.
MachineBlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate machine basic b...
A live range for subregisters.
This represents a simple continuous liveness interval for a value.
ArrayRef< SlotIndex > getRegMaskSlots() const
Returns a sorted array of slot indices of all instructions with register mask operands.
VNInfo - Value Number Information.
void print(raw_ostream &O, const Module *=nullptr) const override
Implement the dump method.
bool checkRegMaskInterference(LiveInterval &LI, BitVector &UsableRegs)
Test if LI is live across any register mask instructions, and compute a bit mask of physical register...
ArrayRef< SlotIndex > getRegMaskSlotsInBlock(unsigned MBBNum) const
Returns a sorted array of slot indices of all instructions with register mask operands in the basic b...
LiveInterval::Segment addSegmentToEndOfBlock(unsigned reg, MachineInstr &startInst)
Given a register and an instruction, adds a live segment from that instruction to the end of its MBB...
This class represents the liveness of a register, stack slot, etc.
LLVM_ATTRIBUTE_UNUSED void pruneValue(LiveInterval &, SlotIndex, SmallVectorImpl< SlotIndex > *)
This function should not be used.
bool isNotInMIMap(const MachineInstr &Instr) const
Returns true if the specified machine instr has been removed or was never entered in the map...
void pruneValue(LiveRange &LR, SlotIndex Kill, SmallVectorImpl< SlotIndex > *EndPoints)
If LR has a live value at Kill, prune its live range by removing any liveness reachable from Kill...
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
bool isLiveInToMBB(const LiveRange &LR, const MachineBasicBlock *mbb) const
VNInfo::Allocator & getVNInfoAllocator()
const LiveInterval & getInterval(unsigned Reg) const
static constexpr LaneBitmask getAll()
SlotIndex getInstructionIndex(const MachineInstr &MI) const
Returns the base index for the given instruction.
void InsertMachineInstrRangeInMaps(MachineBasicBlock::iterator B, MachineBasicBlock::iterator E)
SlotIndex ReplaceMachineInstrInMaps(MachineInstr &MI, MachineInstr &NewMI)
void extendToIndices(LiveRange &LR, ArrayRef< SlotIndex > Indices, ArrayRef< SlotIndex > Undefs)
Extend the live range LR to reach all points in Indices.
void insertMBBInMaps(MachineBasicBlock *MBB)
MachineInstr * getInstructionFromIndex(SlotIndex index) const
Returns the instruction associated with the given index.
MachineBasicBlock * getMBBFromIndex(SlotIndex index) const
Returns the basic block which the given index falls in.
void constructMainRangeFromSubranges(LiveInterval &LI)
For live interval LI with correct SubRanges construct matching information for the main live range...
SlotIndex InsertMachineInstrInMaps(MachineInstr &MI)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
AliasAnalysis * getAliasAnalysis() const
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
bool inBounds(IndexT n) const
LiveRange * getCachedRegUnit(unsigned Unit)
Return the live range for register unit Unit if it has already been computed, or nullptr if it hasn't...
TargetInstrInfo - Interface to description of machine instruction set.
SlotIndex insertMachineInstrInMaps(MachineInstr &MI, bool Late=false)
Insert the given machine instruction into the mapping.
MachineInstr * getInstructionFromIndex(SlotIndex index) const
Returns the instruction for the given index, or null if the given index has no instruction associated...
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
bool hasInterval(unsigned Reg) const
void insertMBBInMaps(MachineBasicBlock *mbb)
Add the given MachineBasicBlock into the maps.
Allocate memory in an ever growing pool, as if by bump-pointer.
void removeInterval(unsigned Reg)
Interval removal.
bool liveAt(SlotIndex index) const
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
void splitSeparateComponents(LiveInterval &LI, SmallVectorImpl< LiveInterval *> &SplitLIs)
Split separate components in LiveInterval LI into separate intervals.
bool hasIndex(const MachineInstr &instr) const
Returns true if the given machine instr is mapped to an index, otherwise returns false.
SlotIndex getMBBStartIdx(unsigned Num) const
Returns the first index in the given basic block number.
Represent the analysis usage information of a pass.
bool shrinkToUses(LiveInterval *li, SmallVectorImpl< MachineInstr *> *dead=nullptr)
After removing some uses of a register, shrink its live range to just the remaining uses...
MachineBasicBlock * getMBBFromIndex(SlotIndex index) const
SlotIndex getMBBStartIdx(const MachineBasicBlock *mbb) const
Return the first index in the given basic block.
SlotIndex getMBBEndIdx(unsigned Num) const
Returns the last index in the given basic block number.
void repairIntervalsInRange(MachineBasicBlock *MBB, MachineBasicBlock::iterator Begin, MachineBasicBlock::iterator End, ArrayRef< unsigned > OrigRegs)
Update live intervals for instructions in a range of iterators.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
void removeRegUnit(unsigned Unit)
Remove computed live range for register unit Unit.
Toolkit used by handleMove to trim or extend live intervals.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
LiveInterval & getInterval(unsigned Reg)
cl::opt< bool > UseSegmentSetForPhysRegs
SlotIndex getMBBEndIdx(const MachineBasicBlock *mbb) const
Return the last index in the given basic block.
LiveInterval & createEmptyInterval(unsigned Reg)
Interval creation.
SlotIndex getInstructionIndex(const MachineInstr &Instr) const
Returns the base index of the given instruction.
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
Representation of each machine instruction.
void addKillFlags(const VirtRegMap *)
Add kill flags to any instruction that kills a virtual register.
SlotIndexes * getSlotIndexes() const
~LiveIntervals() override
MachineBasicBlock * intervalIsInOneMBB(const LiveInterval &LI) const
If LI is confined to a single basic block, return a pointer to that block.
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool isLiveOutOfMBB(const LiveRange &LR, const MachineBasicBlock *mbb) const
void handleMoveIntoBundle(MachineInstr &MI, MachineInstr &BundleStart, bool UpdateFlags=false)
Update intervals for operands of MI so that they begin/end on the SlotIndex for BundleStart.
This class implements an extremely fast bulk output stream that can only output to a stream...
#define LLVM_ATTRIBUTE_UNUSED
SlotIndex - An opaque wrapper around machine indexes.
const LiveRange * getCachedRegUnit(unsigned Unit) const
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
LiveRange & getRegUnit(unsigned Unit)
Return the live range for register unit Unit.
ArrayRef< const uint32_t * > getRegMaskBitsInBlock(unsigned MBBNum) const
Returns an array of mask pointers corresponding to getRegMaskSlotsInBlock(MBBNum).
void handleMove(MachineInstr &MI, bool UpdateFlags=false)
Call this method to notify LiveIntervals that instruction MI has been moved within a basic block...
LiveInterval & createAndComputeVirtRegInterval(unsigned Reg)
void removeVRegDefAt(LiveInterval &LI, SlotIndex Pos)
Remove value number and related live segments of LI and its subranges that start at position Pos...
SlotIndex replaceMachineInstrInMaps(MachineInstr &MI, MachineInstr &NewMI)
ReplaceMachineInstrInMaps - Replacing a machine instr with a new one in maps used by register allocat...