16 #ifndef LLVM_MACHINEOUTLINER_H 17 #define LLVM_MACHINEOUTLINER_H 57 unsigned CallOverhead;
92 unsigned getEndIdx()
const {
return StartIdx + Len - 1; }
97 CallConstructionID = CID;
103 return InCandidateList ? CallOverhead : 0;
123 unsigned FunctionIdx)
124 : StartIdx(StartIdx), Len(Len), FirstInst(FirstInst), LastInst(LastInst),
125 MBB(MBB), FunctionIdx(FunctionIdx) {}
140 "Candidate's Machine Function must track liveness");
151 UsedInSequence.
init(TRI);
163 unsigned OccurrenceCount = 0;
195 assert(OccurrenceCount > 0 &&
"Can't decrement an empty function!");
197 return getOccurrenceCount();
203 unsigned CallOverhead = 0;
204 for (std::shared_ptr<Candidate> &
C : Candidates)
205 CallOverhead +=
C->getCallOverhead();
206 return CallOverhead + SequenceSize + FrameOverhead;
215 unsigned NotOutlinedCost = getNotOutlinedCost();
216 unsigned OutlinedCost = getOutliningCost();
217 return (NotOutlinedCost < OutlinedCost) ? 0
218 : NotOutlinedCost - OutlinedCost;
222 unsigned SequenceSize,
unsigned FrameOverhead,
223 unsigned FrameConstructionID)
224 : SequenceSize(SequenceSize), FrameOverhead(FrameOverhead),
225 FrameConstructionID(FrameConstructionID) {
226 OccurrenceCount = Cands.size();
228 Candidates.push_back(std::make_shared<outliner::Candidate>(
C));
230 unsigned B = getBenefit();
231 for (std::shared_ptr<Candidate> &
C : Candidates)
std::vector< unsigned > Sequence
The sequence of integers corresponding to the instructions in this function.
unsigned getNotOutlinedCost()
Return the size in bytes of the unoutlined sequences.
unsigned getOutliningCost()
Return the number of bytes it would take to outline this function.
Compute iterated dominance frontiers using a linear time algorithm.
void initLRU(const TargetRegisterInfo &TRI)
Compute the registers that are live across this Candidate.
unsigned FrameOverhead
Target-defined overhead of constructing a frame for this function.
unsigned decrement()
Decrement the occurrence count of this OutlinedFunction and return the new count. ...
unsigned getStartIdx() const
Return the start index of this candidate.
LiveRegUnits LRU
Contains physical register liveness information for the MBB containing this Candidate.
unsigned getBenefit()
Return the number of instructions that would be saved by outlining this function. ...
unsigned const TargetRegisterInfo * TRI
An individual sequence of instructions to be replaced with a call to an outlined function.
bool InCandidateList
Set to false if the candidate overlapped with another candidate.
void addLiveOuts(const MachineBasicBlock &MBB)
Adds registers living out of block MBB.
unsigned SequenceSize
Represents the size of a sequence in bytes.
unsigned FrameConstructionID
Target-defined identifier for constructing a frame for this function.
MachineInstrBundleIterator< MachineInstr, true > reverse_iterator
unsigned getEndIdx() const
Return the end index of this candidate.
unsigned getOccurrenceCount()
Return the number of candidates for this OutlinedFunction.
unsigned getLength() const
Return the number of instructions in this Candidate.
unsigned Name
A number assigned to this function which appears at the end of its name.
reverse_iterator rbegin()
std::vector< std::shared_ptr< Candidate > > Candidates
MachineBasicBlock::iterator & back()
void init(const TargetRegisterInfo &TRI)
Initialize and clear the set.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
InstrType
Represents how an instruction should be mapped by the outliner.
LiveRegUnits UsedInSequence
Contains the accumulated register liveness information for the instructions in this Candidate...
unsigned CallConstructionID
Identifier denoting the instructions to emit to call an outlined function from this point...
The information necessary to create an outlined function for some class of candidate.
void setCallInfo(unsigned CID, unsigned CO)
Set the CallConstructionID and CallOverhead of this candidate to CID and CO respectively.
unsigned getCallOverhead() const
Returns the call overhead of this candidate if it is in the list.
void stepBackward(const MachineInstr &MI)
Updates liveness when stepping backwards over the instruction MI.
bool operator<(const Candidate &RHS) const
Used to ensure that Candidates are outlined in an order that preserves the start and end indices of o...
MachineBasicBlock::iterator & front()
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
This file implements the LivePhysRegs utility for tracking liveness of physical registers.
unsigned Benefit
The number of instructions that would be saved by outlining every candidate of this type...
void accumulate(const MachineInstr &MI)
Adds all register units used, defined or clobbered in MI.
Representation of each machine instruction.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
bool tracksLiveness() const
tracksLiveness - Returns true when tracking register liveness accurately.
unsigned FunctionIdx
The index of this Candidate's OutlinedFunction in the list of OutlinedFunctions.
A set of register units used to track register liveness.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Candidate(unsigned StartIdx, unsigned Len, MachineBasicBlock::iterator &FirstInst, MachineBasicBlock::iterator &LastInst, MachineBasicBlock *MBB, unsigned FunctionIdx)
OutlinedFunction(std::vector< Candidate > &Cands, unsigned SequenceSize, unsigned FrameOverhead, unsigned FrameConstructionID)
UnaryPredicate for_each(R &&Range, UnaryPredicate P)
Provide wrappers to std::for_each which take ranges instead of having to pass begin/end explicitly...
MachineFunction * getMF() const
MachineBasicBlock * getMBB() const