15#ifndef LLVM_CODEGEN_MACHINEOUTLINER_H
16#define LLVM_CODEGEN_MACHINEOUTLINER_H
22#include <initializer_list>
41 unsigned StartIdx = 0;
57 unsigned CallOverhead = 0;
73 bool FromEndOfBlockToStartOfSeqWasSet =
false;
76 bool InSeqWasSet =
false;
80 assert(
MBB->getParent()->getRegInfo().tracksLiveness() &&
81 "Candidate's Machine Function must track liveness");
83 if (FromEndOfBlockToStartOfSeqWasSet)
85 FromEndOfBlockToStartOfSeqWasSet =
true;
86 FromEndOfBlockToStartOfSeq.
init(
TRI);
97 assert(
MBB->getParent()->getRegInfo().tracksLiveness() &&
98 "Candidate's Machine Function must track liveness");
104 for (
auto &
MI : *
this)
127 unsigned getEndIdx()
const {
return StartIdx + Len - 1; }
161 if (!FromEndOfBlockToStartOfSeqWasSet)
162 initFromEndOfBlockToStartOfSeq(
TRI);
170 if (!FromEndOfBlockToStartOfSeqWasSet)
171 initFromEndOfBlockToStartOfSeq(
TRI);
204 : StartIdx(StartIdx), Len(Len), FirstInst(FirstInst), LastInst(LastInst),
243 unsigned CallOverhead = 0;
245 CallOverhead +=
C.getCallOverhead();
259 return (NotOutlinedCost < OutlinedCost) ? 0
260 : NotOutlinedCost - OutlinedCost;
301 unsigned CallOverhead =
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
unsigned const TargetRegisterInfo * TRI
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
A set of register units used to track register liveness.
bool available(MCPhysReg Reg) const
Returns true if no part of physical register Reg is live.
void init(const TargetRegisterInfo &TRI)
Initialize and clear the set.
void stepBackward(const MachineInstr &MI)
Updates liveness when stepping backwards over the instruction MI.
void addLiveOuts(const MachineBasicBlock &MBB)
Adds registers living out of block MBB.
void accumulate(const MachineInstr &MI)
Adds all register units used, defined or clobbered in MI.
Representation of each machine instruction.
Wrapper class representing virtual and physical registers.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
@ C
The default llvm calling convention, compatible with C.
InstrType
Represents how an instruction should be mapped by the outliner.
This is an optimization pass for GlobalISel generic memory operations.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
An individual sequence of instructions to be replaced with a call to an outlined function.
unsigned Flags
Target-specific flags for this Candidate's MBB.
bool isAnyUnavailableAcrossOrOutOfSeq(std::initializer_list< Register > Regs, const TargetRegisterInfo &TRI)
unsigned getCallOverhead() const
Returns the call overhead of this candidate if it is in the list.
void setCallInfo(unsigned CID, unsigned CO)
Set the CallConstructionID and CallOverhead of this candidate to CID and CO respectively.
unsigned Benefit
The number of instructions that would be saved by outlining every candidate of this type.
MachineBasicBlock * getMBB() const
MachineFunction * getMF() const
MachineBasicBlock::iterator begin()
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...
unsigned getEndIdx() const
Return the end index of this candidate.
Candidate(unsigned StartIdx, unsigned Len, MachineBasicBlock::iterator &FirstInst, MachineBasicBlock::iterator &LastInst, MachineBasicBlock *MBB, unsigned FunctionIdx, unsigned Flags)
unsigned CallConstructionID
Identifier denoting the instructions to emit to call an outlined function from this point.
bool isAvailableInsideSeq(Register Reg, const TargetRegisterInfo &TRI)
unsigned getStartIdx() const
Return the start index of this candidate.
MachineBasicBlock::iterator end()
bool isAvailableAcrossAndOutOfSeq(Register Reg, const TargetRegisterInfo &TRI)
unsigned getLength() const
Return the number of instructions in this Candidate.
unsigned FunctionIdx
The index of this Candidate's OutlinedFunction in the list of OutlinedFunctions.
The information necessary to create an outlined function that is matched globally.
unsigned GlobalOccurrenceCount
GlobalOutlinedFunction(std::unique_ptr< OutlinedFunction > OF, unsigned GlobalOccurrenceCount)
unsigned getOccurrenceCount() const override
Return the number of times that appear globally.
unsigned getOutliningCost() const override
Return the outlining cost using the global occurrence count with the same cost as the first (unique) ...
GlobalOutlinedFunction()=delete
~GlobalOutlinedFunction()=default
The information necessary to create an outlined function for some class of candidate.
virtual unsigned getOccurrenceCount() const
Return the number of candidates for this OutlinedFunction.
virtual unsigned getOutliningCost() const
Return the number of bytes it would take to outline this function.
unsigned getBenefit() const
Return the number of instructions that would be saved by outlining this function.
unsigned getNotOutlinedCost() const
Return the size in bytes of the unoutlined sequences.
OutlinedFunction()=delete
MachineFunction * MF
The actual outlined function created.
unsigned FrameConstructionID
Target-defined identifier for constructing a frame for this function.
unsigned getNumInstrs() const
Return the number of instructions in this sequence.
OutlinedFunction(std::vector< Candidate > &Candidates, unsigned SequenceSize, unsigned FrameOverhead, unsigned FrameConstructionID)
unsigned FrameOverhead
Target-defined overhead of constructing a frame for this function.
unsigned SequenceSize
Represents the size of a sequence in bytes.
virtual ~OutlinedFunction()=default
std::vector< Candidate > Candidates