|
LLVM
3.7.0
|
SplitEditor - Edit machine code and LiveIntervals for live range splitting. More...
#include <SplitKit.h>
Public Types | |
| enum | ComplementSpillMode { SM_Partition, SM_Size, SM_Speed } |
| ComplementSpillMode - Select how the complement live range should be created. More... | |
Public Member Functions | |
| SplitEditor (SplitAnalysis &SA, LiveIntervals &, VirtRegMap &, MachineDominatorTree &, MachineBlockFrequencyInfo &) | |
| Create a new SplitEditor for editing the LiveInterval analyzed by SA. More... | |
| void | reset (LiveRangeEdit &, ComplementSpillMode=SM_Partition) |
| reset - Prepare for a new split. More... | |
| unsigned | openIntv () |
| Create a new virtual register and live interval. More... | |
| unsigned | currentIntv () const |
| currentIntv - Return the current interval index. More... | |
| void | selectIntv (unsigned Idx) |
| selectIntv - Select a previously opened interval index. More... | |
| SlotIndex | enterIntvBefore (SlotIndex Idx) |
| enterIntvBefore - Enter the open interval before the instruction at Idx. More... | |
| SlotIndex | enterIntvAfter (SlotIndex Idx) |
| enterIntvAfter - Enter the open interval after the instruction at Idx. More... | |
| SlotIndex | enterIntvAtEnd (MachineBasicBlock &MBB) |
| enterIntvAtEnd - Enter the open interval at the end of MBB. More... | |
| void | useIntv (const MachineBasicBlock &MBB) |
| useIntv - indicate that all instructions in MBB should use OpenLI. More... | |
| void | useIntv (SlotIndex Start, SlotIndex End) |
| useIntv - indicate that all instructions in range should use OpenLI. More... | |
| SlotIndex | leaveIntvAfter (SlotIndex Idx) |
| leaveIntvAfter - Leave the open interval after the instruction at Idx. More... | |
| SlotIndex | leaveIntvBefore (SlotIndex Idx) |
| leaveIntvBefore - Leave the open interval before the instruction at Idx. More... | |
| SlotIndex | leaveIntvAtTop (MachineBasicBlock &MBB) |
| leaveIntvAtTop - Leave the interval at the top of MBB. More... | |
| void | overlapIntv (SlotIndex Start, SlotIndex End) |
| overlapIntv - Indicate that all instructions in range should use the open interval, but also let the complement interval be live. More... | |
| void | finish (SmallVectorImpl< unsigned > *LRMap=nullptr) |
| finish - after all the new live ranges have been created, compute the remaining live range, and rewrite instructions to use the new registers. More... | |
| void | dump () const |
| dump - print the current interval mapping to dbgs(). More... | |
| void | splitSingleBlock (const SplitAnalysis::BlockInfo &BI) |
| splitSingleBlock - Split CurLI into a separate live interval around the uses in a single block. More... | |
| void | splitLiveThroughBlock (unsigned MBBNum, unsigned IntvIn, SlotIndex LeaveBefore, unsigned IntvOut, SlotIndex EnterAfter) |
| splitLiveThroughBlock - Split CurLI in the given block such that it enters the block in IntvIn and leaves it in IntvOut. More... | |
| void | splitRegInBlock (const SplitAnalysis::BlockInfo &BI, unsigned IntvIn, SlotIndex LeaveBefore) |
| splitRegInBlock - Split CurLI in the given block such that it enters the block in IntvIn and leaves it on the stack (or not at all). More... | |
| void | splitRegOutBlock (const SplitAnalysis::BlockInfo &BI, unsigned IntvOut, SlotIndex EnterAfter) |
| splitRegOutBlock - Split CurLI in the given block such that it enters the block on the stack (or isn't live-in at all) and leaves it in IntvOut. More... | |
SplitEditor - Edit machine code and LiveIntervals for live range splitting.
Definition at line 211 of file SplitKit.h.
ComplementSpillMode - Select how the complement live range should be created.
SplitEditor automatically creates interval 0 to contain anything that isn't added to another interval. This complement interval can get quite complicated, and it can sometimes be an advantage to allow it to overlap the other intervals. If it is going to spill anyway, no registers are wasted by keeping a value in two places at the same time.
Definition at line 229 of file SplitKit.h.
| SplitEditor::SplitEditor | ( | SplitAnalysis & | SA, |
| LiveIntervals & | lis, | ||
| VirtRegMap & | vrm, | ||
| MachineDominatorTree & | mdt, | ||
| MachineBlockFrequencyInfo & | mbfi | ||
| ) |
Create a new SplitEditor for editing the LiveInterval analyzed by SA.
Newly created intervals will be appended to newIntervals.
Definition at line 318 of file SplitKit.cpp.
|
inline |
currentIntv - Return the current interval index.
Definition at line 365 of file SplitKit.h.
| void SplitEditor::dump | ( | ) | const |
dump - print the current interval mapping to dbgs().
Definition at line 347 of file SplitKit.cpp.
References llvm::IntervalMap< KeyT, ValT, N, Traits >::begin(), llvm::IntervalMap< SlotIndex, unsigned >::const_iterator, llvm::dbgs(), llvm::IntervalMap< KeyT, ValT, N, Traits >::empty(), and I.
Referenced by enterIntvAtEnd(), leaveIntvAtTop(), overlapIntv(), and useIntv().
enterIntvAfter - Enter the open interval after the instruction at Idx.
Return the beginning of the new live range.
Definition at line 483 of file SplitKit.cpp.
References llvm::dbgs(), DEBUG, llvm::VNInfo::def, llvm::SlotIndex::getBoundaryIndex(), llvm::LiveIntervals::getInstructionFromIndex(), llvm::MachineInstr::getParent(), llvm::LiveRangeEdit::getParent(), llvm::LiveRange::getVNInfoAt(), llvm::VNInfo::id, and llvm::AArch64CC::MI.
Referenced by splitLiveThroughBlock(), and splitRegOutBlock().
| SlotIndex SplitEditor::enterIntvAtEnd | ( | MachineBasicBlock & | MBB | ) |
enterIntvAtEnd - Enter the open interval at the end of MBB.
Use the open interval from the inserted copy to the MBB end. Return the beginning of the new live range.
Definition at line 501 of file SplitKit.cpp.
References llvm::dbgs(), DEBUG, llvm::VNInfo::def, dump(), llvm::SplitAnalysis::getLastSplitPointIter(), llvm::LiveIntervals::getMBBEndIdx(), llvm::MachineBasicBlock::getNumber(), llvm::LiveRangeEdit::getParent(), llvm::SlotIndex::getPrevSlot(), llvm::LiveRange::getVNInfoAt(), and llvm::IntervalMap< KeyT, ValT, N, Traits >::insert().
Referenced by splitLiveThroughBlock().
enterIntvBefore - Enter the open interval before the instruction at Idx.
If the parent interval is not live before Idx, a COPY is not inserted. Return the beginning of the new live range.
Definition at line 466 of file SplitKit.cpp.
References llvm::dbgs(), DEBUG, llvm::VNInfo::def, llvm::SlotIndex::getBaseIndex(), llvm::LiveIntervals::getInstructionFromIndex(), llvm::MachineInstr::getParent(), llvm::LiveRangeEdit::getParent(), llvm::LiveRange::getVNInfoAt(), llvm::VNInfo::id, and llvm::AArch64CC::MI.
Referenced by splitLiveThroughBlock(), splitRegInBlock(), splitRegOutBlock(), and splitSingleBlock().
| void SplitEditor::finish | ( | SmallVectorImpl< unsigned > * | LRMap = nullptr | ) |
finish - after all the new live ranges have been created, compute the remaining live range, and rewrite instructions to use the new registers.
| LRMap | When not null, this vector will map each live range in Edit back to the indices returned by openIntv. There may be extra indices created by dead code elimination. |
Definition at line 1021 of file SplitKit.cpp.
References llvm::LiveRangeEdit::begin(), llvm::LiveRangeEdit::calculateRegClassAndHint(), llvm::ConnectedVNInfoEqClasses::Classify(), llvm::SmallVectorImpl< T >::clear(), llvm::LiveRangeEdit::createEmptyInterval(), llvm::dbgs(), DEBUG, llvm::VNInfo::def, llvm::LiveRangeEdit::didRematerialize(), llvm::ConnectedVNInfoEqClasses::Distribute(), llvm::LiveRangeEdit::end(), llvm::LiveRangeEdit::get(), llvm::LiveIntervals::getInterval(), llvm::VirtRegMap::getMachineFunction(), llvm::LiveRangeEdit::getParent(), I, llvm::VNInfo::isUnused(), llvm_unreachable, llvm::IntervalMap< KeyT, ValT, N, Traits >::lookup(), llvm::SplitAnalysis::Loops, llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), llvm::LiveRange::RenumberValues(), llvm::SmallVectorImpl< T >::resize(), llvm::SmallVectorTemplateCommon< T, typename >::size(), llvm::LiveRangeEdit::size(), SM_Partition, SM_Size, SM_Speed, and llvm::LiveRange::valnos.
leaveIntvAfter - Leave the open interval after the instruction at Idx.
Return the end of the live range.
Definition at line 531 of file SplitKit.cpp.
References llvm::dbgs(), DEBUG, llvm::VNInfo::def, llvm::SlotIndex::getBoundaryIndex(), llvm::LiveIntervals::getInstructionFromIndex(), llvm::SlotIndex::getNextSlot(), llvm::MachineInstr::getParent(), llvm::LiveRangeEdit::getParent(), llvm::LiveRangeEdit::getReg(), llvm::LiveRange::getVNInfoAt(), llvm::VNInfo::id, llvm::SlotIndex::isSameInstr(), llvm::AArch64CC::MI, and llvm::MachineInstr::readsVirtualRegister().
Referenced by splitRegInBlock(), and splitSingleBlock().
| SlotIndex SplitEditor::leaveIntvAtTop | ( | MachineBasicBlock & | MBB | ) |
leaveIntvAtTop - Leave the interval at the top of MBB.
Add liveness from the MBB top to the copy. Return the end of the live range.
Definition at line 581 of file SplitKit.cpp.
References llvm::MachineBasicBlock::begin(), llvm::dbgs(), DEBUG, llvm::VNInfo::def, dump(), llvm::LiveIntervals::getMBBStartIdx(), llvm::MachineBasicBlock::getNumber(), llvm::LiveRangeEdit::getParent(), llvm::LiveRange::getVNInfoAt(), llvm::IntervalMap< KeyT, ValT, N, Traits >::insert(), and llvm::MachineBasicBlock::SkipPHIsAndLabels().
Referenced by splitLiveThroughBlock().
leaveIntvBefore - Leave the open interval before the instruction at Idx.
Return the end of the live range.
Definition at line 562 of file SplitKit.cpp.
References llvm::dbgs(), DEBUG, llvm::VNInfo::def, llvm::SlotIndex::getBaseIndex(), llvm::LiveIntervals::getInstructionFromIndex(), llvm::SlotIndex::getNextSlot(), llvm::MachineInstr::getParent(), llvm::LiveRangeEdit::getParent(), llvm::LiveRange::getVNInfoAt(), llvm::VNInfo::id, and llvm::AArch64CC::MI.
Referenced by splitLiveThroughBlock(), splitRegInBlock(), and splitSingleBlock().
| unsigned SplitEditor::openIntv | ( | ) |
Create a new virtual register and live interval.
Return the interval index, starting from 1. Interval index 0 is the implicit complement interval.
Definition at line 448 of file SplitKit.cpp.
References llvm::LiveRangeEdit::createEmptyInterval(), llvm::LiveRangeEdit::empty(), and llvm::LiveRangeEdit::size().
Referenced by splitRegInBlock(), splitRegOutBlock(), and splitSingleBlock().
overlapIntv - Indicate that all instructions in range should use the open interval, but also let the complement interval be live.
This doubles the register pressure, but is sometimes required to deal with register uses after the last valid split point.
The Start index should be a return value from a leaveIntv* call, and End should be in the same basic block. The parent interval must have the same value across the range.
Definition at line 599 of file SplitKit.cpp.
References llvm::dbgs(), DEBUG, dump(), llvm::LiveIntervals::getMBBFromIndex(), llvm::LiveRangeEdit::getParent(), llvm::LiveRange::getVNInfoAt(), llvm::LiveRange::getVNInfoBefore(), and llvm::IntervalMap< KeyT, ValT, N, Traits >::insert().
Referenced by splitRegInBlock(), and splitSingleBlock().
| void SplitEditor::reset | ( | LiveRangeEdit & | LRE, |
| ComplementSpillMode | SM = SM_Partition |
||
| ) |
reset - Prepare for a new split.
Definition at line 327 of file SplitKit.cpp.
References llvm::LiveRangeEdit::anyRematerializable(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::clear(), llvm::IntervalMap< KeyT, ValT, N, Traits >::clear(), llvm::VirtRegMap::getMachineFunction(), llvm::LiveIntervals::getSlotIndexes(), llvm::LiveIntervals::getVNInfoAllocator(), and llvm::LiveRangeCalc::reset().
| void SplitEditor::selectIntv | ( | unsigned | Idx | ) |
selectIntv - Select a previously opened interval index.
Definition at line 459 of file SplitKit.cpp.
References llvm::dbgs(), DEBUG, and size.
Referenced by splitLiveThroughBlock(), splitRegInBlock(), and splitRegOutBlock().
| void SplitEditor::splitLiveThroughBlock | ( | unsigned | MBBNum, |
| unsigned | IntvIn, | ||
| SlotIndex | LeaveBefore, | ||
| unsigned | IntvOut, | ||
| SlotIndex | EnterAfter | ||
| ) |
splitLiveThroughBlock - Split CurLI in the given block such that it enters the block in IntvIn and leaves it in IntvOut.
There may be uses in the block, but they will be ignored when placing split points.
| MBBNum | Block number. |
| IntvIn | Interval index entering the block. |
| LeaveBefore | When set, leave IntvIn before this point. |
| IntvOut | Interval index leaving the block. |
| EnterAfter | When set, enter IntvOut after this point. |
Definition at line 1155 of file SplitKit.cpp.
References llvm::dbgs(), DEBUG, enterIntvAfter(), enterIntvAtEnd(), enterIntvBefore(), llvm::SlotIndex::getBaseIndex(), llvm::MachineFunction::getBlockNumbered(), llvm::SlotIndex::getBoundaryIndex(), llvm::SplitAnalysis::getLastSplitPoint(), llvm::VirtRegMap::getMachineFunction(), llvm::SlotIndexes::getMBBRange(), llvm::LiveIntervals::getSlotIndexes(), leaveIntvAtTop(), leaveIntvBefore(), selectIntv(), and useIntv().
| void SplitEditor::splitRegInBlock | ( | const SplitAnalysis::BlockInfo & | BI, |
| unsigned | IntvIn, | ||
| SlotIndex | LeaveBefore | ||
| ) |
splitRegInBlock - Split CurLI in the given block such that it enters the block in IntvIn and leaves it on the stack (or not at all).
Split points are placed in a way that avoids putting uses in the stack interval. This may require creating a local interval when there is interference.
| BI | Block descriptor. |
| IntvIn | Interval index entering the block. Not 0. |
| LeaveBefore | When set, leave IntvIn before this point. |
Definition at line 1259 of file SplitKit.cpp.
References llvm::dbgs(), DEBUG, enterIntvBefore(), llvm::SplitAnalysis::BlockInfo::FirstInstr, llvm::SlotIndex::getBoundaryIndex(), llvm::SplitAnalysis::getLastSplitPoint(), llvm::SlotIndexes::getMBBRange(), llvm::MachineBasicBlock::getNumber(), llvm::LiveIntervals::getSlotIndexes(), llvm::SplitAnalysis::BlockInfo::LastInstr, leaveIntvAfter(), leaveIntvBefore(), llvm::SplitAnalysis::BlockInfo::LiveIn, llvm::SplitAnalysis::BlockInfo::LiveOut, llvm::SplitAnalysis::BlockInfo::MBB, fuzzer::min(), openIntv(), overlapIntv(), selectIntv(), and useIntv().
| void SplitEditor::splitRegOutBlock | ( | const SplitAnalysis::BlockInfo & | BI, |
| unsigned | IntvOut, | ||
| SlotIndex | EnterAfter | ||
| ) |
splitRegOutBlock - Split CurLI in the given block such that it enters the block on the stack (or isn't live-in at all) and leaves it in IntvOut.
Split points are placed to avoid interference and such that the uses are not in the stack interval. This may require creating a local interval when there is interference.
| BI | Block descriptor. |
| IntvOut | Interval index leaving the block. |
| EnterAfter | When set, enter IntvOut after this point. |
Definition at line 1351 of file SplitKit.cpp.
References llvm::dbgs(), DEBUG, enterIntvAfter(), enterIntvBefore(), llvm::SplitAnalysis::BlockInfo::FirstInstr, llvm::SlotIndex::getBaseIndex(), llvm::SplitAnalysis::getLastSplitPoint(), llvm::SlotIndexes::getMBBRange(), llvm::MachineBasicBlock::getNumber(), llvm::LiveIntervals::getSlotIndexes(), llvm::SplitAnalysis::BlockInfo::LastInstr, llvm::SplitAnalysis::BlockInfo::LiveIn, llvm::SplitAnalysis::BlockInfo::LiveOut, llvm::SplitAnalysis::BlockInfo::MBB, fuzzer::min(), openIntv(), selectIntv(), and useIntv().
| void SplitEditor::splitSingleBlock | ( | const SplitAnalysis::BlockInfo & | BI | ) |
splitSingleBlock - Split CurLI into a separate live interval around the uses in a single block.
This is intended to be used as part of a larger split, and doesn't call finish().
Definition at line 1128 of file SplitKit.cpp.
References enterIntvBefore(), llvm::SplitAnalysis::BlockInfo::FirstInstr, llvm::SplitAnalysis::getLastSplitPoint(), llvm::MachineBasicBlock::getNumber(), llvm::SplitAnalysis::BlockInfo::LastInstr, leaveIntvAfter(), leaveIntvBefore(), llvm::SplitAnalysis::BlockInfo::LiveOut, llvm::SplitAnalysis::BlockInfo::MBB, fuzzer::min(), openIntv(), overlapIntv(), and useIntv().
| void SplitEditor::useIntv | ( | const MachineBasicBlock & | MBB | ) |
useIntv - indicate that all instructions in MBB should use OpenLI.
Definition at line 520 of file SplitKit.cpp.
References llvm::LiveIntervals::getMBBEndIdx(), and llvm::LiveIntervals::getMBBStartIdx().
Referenced by splitLiveThroughBlock(), splitRegInBlock(), splitRegOutBlock(), and splitSingleBlock().
useIntv - indicate that all instructions in range should use OpenLI.
Definition at line 524 of file SplitKit.cpp.
References llvm::dbgs(), DEBUG, dump(), and llvm::IntervalMap< KeyT, ValT, N, Traits >::insert().
1.8.6