20 #ifndef LLVM_CODEGEN_LIVEINTERVALANALYSIS_H
21 #define LLVM_CODEGEN_LIVEINTERVALANALYSIS_H
44 class MachineDominatorTree;
45 class MachineLoopInfo;
46 class TargetRegisterInfo;
47 class MachineRegisterInfo;
48 class TargetInstrInfo;
49 class TargetRegisterClass;
51 class MachineBlockFrequencyInfo;
112 return *VirtRegIntervals[
Reg];
122 return VirtRegIntervals.inBounds(Reg) && VirtRegIntervals[
Reg];
127 assert(!
hasInterval(Reg) &&
"Interval already exists!");
128 VirtRegIntervals.grow(Reg);
129 VirtRegIntervals[
Reg] = createInterval(Reg);
130 return *VirtRegIntervals[
Reg];
135 computeVirtRegInterval(LI);
141 delete VirtRegIntervals[
Reg];
142 VirtRegIntervals[
Reg] =
nullptr;
238 "Blocks must be added in order.");
239 RegMaskBlocks.
push_back(std::make_pair(RegMaskSlots.size(), 0));
306 bool UpdateFlags =
false);
342 std::pair<unsigned, unsigned>
P = RegMaskBlocks[MBBNum];
353 std::pair<unsigned, unsigned>
P = RegMaskBlocks[MBBNum];
385 computeRegUnitRange(*LR, Unit);
393 return RegUnitRanges[
Unit];
397 return RegUnitRanges[
Unit];
411 void computeVirtRegs();
414 void computeRegMasks();
429 void dumpInstrs()
const;
431 void computeLiveInRegUnits();
443 unsigned Reg,
unsigned LaneMask = ~0u);
void push_back(const T &Elt)
ArrayRef< SlotIndex > getRegMaskSlots() const
getRegMaskSlots - Returns a sorted array of slot indices of all instructions with register mask opera...
cl::opt< bool > UseSegmentSetForPhysRegs
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. ...
int getNumber() const
getNumber - MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a M...
bool runOnMachineFunction(MachineFunction &) override
runOnMachineFunction - pass entry point
LiveInterval - This class represents the liveness of a register, or stack slot.
SlotIndex getInstructionIndex(const MachineInstr *instr) const
Returns the base index of the given instruction.
MachineBasicBlock * getMBBFromIndex(SlotIndex index) const
SlotIndex getMBBEndIdx(const MachineBasicBlock *mbb) const
Return the last index in the given basic block.
bool isLiveOutOfMBB(const LiveRange &LR, const MachineBasicBlock *mbb) const
bool isLiveInToMBB(const LiveRange &LR, const MachineBasicBlock *mbb) const
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.
VNInfo - Value Number Information.
void print(raw_ostream &O, const Module *=nullptr) const override
print - Implement the dump method.
bool checkRegMaskInterference(LiveInterval &LI, BitVector &UsableRegs)
checkRegMaskInterference - Test if LI is live across any register mask instructions, and compute a bit mask of physical registers that are not clobbered by any of them.
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
This class represents the liveness of a register, stack slot, etc.
bool isNotInMIMap(const MachineInstr *Instr) const
isNotInMIMap - returns true if the specified machine instr has been removed or was never entered in t...
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...
MachineBasicBlock * intervalIsInOneMBB(const LiveInterval &LI) const
intervalIsInOneMBB - If LI is confined to a single basic block, return a pointer to that block...
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
ArrayRef< SlotIndex > getRegMaskSlotsInBlock(unsigned MBBNum) const
getRegMaskSlotsInBlock - Returns a sorted array of slot indices of all instructions with register mas...
ArrayRef< const uint32_t * > getRegMaskBits() const
getRegMaskBits() - Returns an array of register mask pointers corresponding to getRegMaskSlots().
VNInfo::Allocator & getVNInfoAllocator()
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
bool findLiveInMBBs(SlotIndex Start, SlotIndex End, SmallVectorImpl< MachineBasicBlock * > &MBBs) const
Reg
All possible values of the reg field in the ModR/M byte.
void InsertMachineInstrRangeInMaps(MachineBasicBlock::iterator B, MachineBasicBlock::iterator E)
void insertMBBInMaps(MachineBasicBlock *MBB)
bool shrinkToUses(LiveInterval *li, SmallVectorImpl< MachineInstr * > *dead=nullptr)
shrinkToUses - After removing some uses of a register, shrink its live range to just the remaining us...
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
LiveRange * getCachedRegUnit(unsigned Unit)
getCachedRegUnit - Return the live range for Unit if it has already been computed, or NULL if it hasn't been computed yet.
TargetInstrInfo - Interface to description of machine instruction set.
bool hasPHIKill(const LiveInterval &LI, const VNInfo *VNI) const
Returns true if VNI is killed by any PHI-def values in LI.
bundle_iterator< MachineInstr, instr_iterator > iterator
void RemoveMachineInstrFromMaps(MachineInstr *MI)
SlotIndexes * getSlotIndexes() const
void insertMBBInMaps(MachineBasicBlock *mbb)
Add the given MachineBasicBlock into the maps.
Allocate memory in an ever growing pool, as if by bump-pointer.
bool findLiveInMBBs(SlotIndex start, SlotIndex end, SmallVectorImpl< MachineBasicBlock * > &mbbs) const
void removeInterval(unsigned Reg)
const LiveRange * getCachedRegUnit(unsigned Unit) const
bundle_iterator - MachineBasicBlock iterator that automatically skips over MIs that are inside bundle...
Represent the analysis usage information of a pass.
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...
static float getSpillWeight(bool isDef, bool isUse, const MachineBlockFrequencyInfo *MBFI, const MachineInstr *Instr)
void repairIntervalsInRange(MachineBasicBlock *MBB, MachineBasicBlock::iterator Begin, MachineBasicBlock::iterator End, ArrayRef< unsigned > OrigRegs)
repairIntervalsInRange - Update live intervals for instructions in a range of iterators.
void handleMove(MachineInstr *MI, bool UpdateFlags=false)
handleMove - call this method to notify LiveIntervals that instruction 'mi' has been moved within a b...
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
bool liveAt(SlotIndex index) const
SlotIndex getInstructionIndex(const MachineInstr *MI) const
Returns the base index for the given instruction.
MachineInstr * getInstructionFromIndex(SlotIndex index) const
Returns the instruction for the given index, or null if the given index has no instruction associated...
ArrayRef< const uint32_t * > getRegMaskBitsInBlock(unsigned MBBNum) const
getRegMaskBitsInBlock - Returns an array of mask pointers corresponding to getRegMaskSlotsInBlock(MBB...
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...
bool hasIndex(const MachineInstr *instr) const
Returns true if the given machine instr is mapped to an index, otherwise returns false.
MachineBasicBlock * getMBBFromIndex(SlotIndex index) const
Returns the basic block which the given index falls in.
LiveInterval & getInterval(unsigned Reg)
SlotIndex InsertMachineInstrInMaps(MachineInstr *MI)
SlotIndex getMBBEndIdx(unsigned Num) const
Returns the last index in the given basic block number.
LiveInterval & createEmptyInterval(unsigned Reg)
void ReplaceMachineInstrInMaps(MachineInstr *MI, MachineInstr *NewMI)
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 replaceMachineInstrInMaps(MachineInstr *mi, MachineInstr *newMI)
ReplaceMachineInstrInMaps - Replacing a machine instr with a new one in maps used by register allocat...
void addKillFlags(const VirtRegMap *)
addKillFlags - Add kill flags to any instruction that kills a virtual register.
void handleMoveIntoBundle(MachineInstr *MI, MachineInstr *BundleStart, bool UpdateFlags=false)
moveIntoBundle - Update intervals for operands of MI so that they begin/end on the SlotIndex for Bund...
void removeMachineInstrFromMaps(MachineInstr *mi)
Remove the given machine instruction from the mapping.
SlotIndex getMBBStartIdx(unsigned Num) const
Returns the first index in the given basic block number.
bool hasInterval(unsigned Reg) const
~LiveIntervals() override
std::vector< uint8_t > Unit
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
AliasAnalysis * getAliasAnalysis() const
MachineInstr * getInstructionFromIndex(SlotIndex index) const
Returns the instruction associated with the given index.
This class implements an extremely fast bulk output stream that can only output to a stream...
SlotIndex getMBBStartIdx(const MachineBasicBlock *mbb) const
Return the first index in the given basic block.
const LiveInterval & getInterval(unsigned Reg) const
SlotIndex - An opaque wrapper around machine indexes.
SlotIndex insertMachineInstrInMaps(MachineInstr *mi, bool Late=false)
Insert the given machine instruction into the mapping.
void extendToIndices(LiveRange &LR, ArrayRef< SlotIndex > Indices)
extendToIndices - Extend the live range of LI to reach all points in Indices.
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
LiveRange & getRegUnit(unsigned Unit)
getRegUnit - Return the live range for Unit.
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...