17 #ifndef LLVM_CODEGEN_MACHINEFUNCTION_H 18 #define LLVM_CODEGEN_MACHINEFUNCTION_H 53 class DILocalVariable;
57 class LLVMTargetMachine;
58 class MachineConstantPool;
59 class MachineFrameInfo;
60 class MachineFunction;
61 class MachineJumpTableInfo;
62 class MachineModuleInfo;
63 class MachineRegisterInfo;
68 class PseudoSourceValueManager;
71 class TargetRegisterClass;
72 class TargetSubtargetInfo;
73 struct WasmEHFuncInfo;
84 template <
class Iterator>
86 assert(
this == &OldList &&
"never transfer MBBs between functions");
101 template<
typename Ty>
103 return new (Allocator.
Allocate<Ty>()) Ty(MF);
155 LastProperty = Selected,
159 return Properties[
static_cast<unsigned>(
P)];
163 Properties.
set(static_cast<unsigned>(
P));
168 Properties.
reset(static_cast<unsigned>(P));
179 Properties |= MFP.Properties;
184 Properties.
reset(MFP.Properties);
191 return !V.Properties.
test(Properties);
199 BitVector(static_cast<unsigned>(Property::LastProperty)+1);
220 : LandingPadBlock(MBB) {}
257 std::vector<MachineBasicBlock*> MBBNumbering;
288 bool ExposesReturnsTwice =
false;
291 bool HasInlineAsm =
false;
294 bool HasWinCFI =
false;
301 std::unique_ptr<PseudoSourceValueManager> PSVManager;
305 std::vector<MCCFIInstruction> FrameInstructions;
309 std::vector<MCSymbol *> LongjmpTargets;
315 std::vector<LandingPadInfo> LandingPads;
327 std::vector<std::pair<MCSymbol *, MDNode *>> CodeViewAnnotations;
329 bool CallsEHReturn =
false;
330 bool CallsUnwindInit =
false;
331 bool HasEHScopes =
false;
332 bool HasEHFunclets =
false;
335 std::vector<const GlobalValue *> TypeInfos;
338 std::vector<unsigned> FilterIds;
341 std::vector<unsigned> FilterEnds;
368 : Var(Var), Expr(Expr), Slot(Slot), Loc(Loc) {}
372 virtual void anchor();
390 assert(Arg < (1 << 16) &&
"Arg out of range");
432 assert(TheDelegate == delegate &&
433 "Only the current delegate can perform reset!");
434 TheDelegate =
nullptr;
440 assert(delegate && !TheDelegate &&
441 "Attempted to set delegate to null, or to change it without " 442 "first resetting it!");
444 TheDelegate = delegate;
475 return *
static_cast<const STC *
>(STI);
532 return ExposesReturnsTwice;
538 ExposesReturnsTwice =
B;
557 bool needsFrameMoves()
const;
566 template<
typename Ty>
569 MFInfo = Ty::template create<Ty>(
Allocator, *
this);
570 return static_cast<Ty*
>(MFInfo);
573 template<
typename Ty>
587 assert(N < MBBNumbering.size() &&
"Illegal block number");
588 assert(MBBNumbering[N] &&
"Block was removed from the machine function!");
589 return MBBNumbering[
N];
593 bool shouldSplitStack()
const;
614 void viewCFG()
const;
621 void viewCFGOnly()
const;
629 bool verify(
Pass *p =
nullptr,
const char *Banner =
nullptr,
630 bool AbortOnError =
true)
const;
641 return &MachineFunction::BasicBlocks;
661 unsigned size()
const {
return (
unsigned)BasicBlocks.size();}
662 bool empty()
const {
return BasicBlocks.empty(); }
671 BasicBlocks.
insert(MBBI, MBB);
674 BasicBlocks.
splice(InsertPt, BasicBlocks, MBBI);
677 BasicBlocks.
splice(InsertPt, BasicBlocks, MBB);
680 BasicBlocks.
splice(InsertPt, BasicBlocks, MBBI, MBBE);
688 template <
typename Comp>
690 BasicBlocks.sort(comp);
697 InstrCount += MBB.size();
707 MBBNumbering.push_back(MBB);
708 return (
unsigned)MBBNumbering.size()-1;
715 assert(N < MBBNumbering.size() &&
"Illegal basic block #");
716 MBBNumbering[
N] =
nullptr;
757 const MDNode *Ranges =
nullptr,
786 return OperandRecycler.
allocate(Cap, Allocator);
805 MachineInstr::ExtraInfo *createMIExtraInfo(
807 MCSymbol *PostInstrSymbol =
nullptr,
MDNode *HeapAllocMarker =
nullptr);
819 bool isLinkerPrivate =
false)
const;
829 return FrameInstructions;
838 return LongjmpTargets;
865 bool TidyIfNoBeginLabels =
true);
903 int getFilterIDFor(std::vector<unsigned> &TyIds);
910 WasmLPadToIndexMap[LPad] =
Index;
915 return WasmLPadToIndexMap.
count(LPad);
920 assert(hasWasmLandingPadIndex(LPad));
921 return WasmLPadToIndexMap.
lookup(LPad);
926 assert(hasCallSiteLandingPad(Sym) &&
927 "missing call site number for landing pad!");
928 return LPadToCallSiteMap[Sym];
933 return !LPadToCallSiteMap[Sym].
empty();
938 CallSiteMap[BeginLabel] = Site;
943 assert(hasCallSiteBeginLabel(BeginLabel) &&
944 "Missing call site number for EH_LABEL!");
945 return CallSiteMap.
lookup(BeginLabel);
950 return CallSiteMap.
count(BeginLabel);
955 CodeViewAnnotations.push_back({Label, MD});
959 return CodeViewAnnotations;
983 return VariableDbgInfos;
989 CallSitesInfo[CallI] = std::move(
CallInfo);
993 return CallSitesInfo;
1070 return &G.
Graph->front();
1076 return &G.
Graph->front();
1082 #endif // LLVM_CODEGEN_MACHINEFUNCTION_H void push_front(MachineBasicBlock *MBB)
Pass interface - Implemented by all 'passes'.
std::reverse_iterator< const_iterator > const_reverse_iterator
ArrayRef< std::pair< MCSymbol *, MDNode * > > getCodeViewAnnotations() const
unsigned getInstructionCount() const
Return the number of MachineInstrs in this MachineFunction.
A parsed version of the target data layout string in and methods for querying it. ...
reference emplace_back(ArgTypes &&... Args)
The MachineConstantPool class keeps track of constants referenced by a function which must be spilled...
bool hasCallSiteLandingPad(MCSymbol *Sym)
Return true if the landing pad Eh symbol has an associated call site.
bool isCall(QueryType Type=AnyInBundle) const
typename SuperClass::const_iterator const_iterator
static BasicBlockListType MachineFunction::* getSublistAccess(MachineBasicBlock *)
Support for MachineBasicBlock::getNextNode().
unsigned getFunctionNumber() const
getFunctionNumber - Return a unique ID for the current function.
Atomic ordering constants.
iterator erase(iterator where)
const std::vector< MCCFIInstruction > & getFrameInstructions() const
Returns a reference to a list of cfi instructions in the function's prologue.
This class represents lattice values for constants.
MachineFunctionProperties & reset(Property P)
void setHasWinCFI(bool v)
void setCallsUnwindInit(bool b)
T * allocate(Capacity Cap, AllocatorType &Allocator)
Allocate an array of at least the requested capacity.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Align getAlignment() const
getAlignment - Return the alignment of the function.
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
void transferNodesFromList(ilist_callback_traits &OldList, Iterator, Iterator)
unsigned getNumBlockIDs() const
getNumBlockIDs - Return the number of MBB ID's allocated.
static nodes_iterator nodes_end(MachineFunction *F)
void setHasEHFunclets(bool V)
const Function * FilterOrFinally
Filter or finally function. Null indicates a catch-all.
const MachineFunctionProperties & getProperties() const
Get the function properties.
static void Cleanup(DenseMap< Instruction *, Instruction *> &NewPredicates, SetVector< Instruction *> &MaybeDead, Loop *L)
Describe properties that are true of each instruction in the target description file.
const CallSiteInfoMap & getCallSitesInfo() const
unsigned getCallSiteBeginLabel(MCSymbol *BeginLabel) const
Get the call site number for a begin label.
bool test(unsigned Idx) const
Template traits for intrusive list.
MachineModuleInfo & getMMI() const
static unsigned InstrCount
static NodeRef getEntryNode(Inverse< MachineFunction *> G)
void resetDelegate(Delegate *delegate)
Reset the currently registered delegate - otherwise assert.
static nodes_iterator nodes_begin(const MachineFunction *F)
const MachineConstantPool * getConstantPool() const
VariableDbgInfoMapTy & getVariableDbgInfo()
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
const std::vector< unsigned > & getFilterIds() const
Return a reference to the typeids encoding filters used in the current function.
static nodes_iterator nodes_begin(MachineFunction *F)
MachineFunctionInfo - This class can be derived from and used by targets to hold private target-speci...
The address of a basic block.
void setAlignment(Align A)
setAlignment - Set the alignment of the function.
A description of a memory reference used in the backend.
MachineJumpTableInfo * getJumpTableInfo()
SmallVector< MCSymbol *, 1 > EndLabels
static unsigned addLiveIn(MachineFunction &MF, unsigned PReg, const TargetRegisterClass *RC)
SmallVector< SEHHandler, 1 > SEHHandlers
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
static StringRef getName(Value *V)
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
const_iterator end() const
SmallVectorImpl< unsigned > & getCallSiteLandingPad(MCSymbol *Sym)
Get the call site indexes for a landing pad EH symbol.
AtomicOrdering
Atomic ordering for LLVM's memory model.
Structure used to represent pair of argument number after call lowering and register used to transfer...
Context object for machine code objects.
This structure is used to retain landing pad info for the current function.
void erase(MachineBasicBlock *MBBI)
PseudoSourceValueManager & getPSVManager() const
void setCallSiteBeginLabel(MCSymbol *BeginLabel, unsigned Site)
Map the begin label for a call site.
const MachineFrameInfo & getFrameInfo() const
VariableDbgInfo(const DILocalVariable *Var, const DIExpression *Expr, int Slot, const DILocation *Loc)
const_iterator begin() const
ArgRegPair(unsigned R, unsigned Arg)
const DILocalVariable * Var
bool hasCallSiteBeginLabel(MCSymbol *BeginLabel) const
Return true if the begin label has a call site number associated with it.
BasicBlockListType::iterator iterator
ArrayRecycler< MachineOperand >::Capacity OperandCapacity
MCContext & getContext() const
Use delete by default for iplist and ilist.
void setHasEHScopes(bool V)
void setDelegate(Delegate *delegate)
Set the delegate.
initializer< Ty > init(const Ty &Val)
typename MachineBasicBlock *::UnknownGraphTypeError NodeRef
MachineBasicBlock * getBlockNumbered(unsigned N) const
getBlockNumbered - MachineBasicBlocks are automatically numbered when they are inserted into the mach...
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
LLVM Basic Block Representation.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
void ensureAlignment(Align A)
ensureAlignment - Make sure the function is at least A bytes aligned.
Allocate memory in an ever growing pool, as if by bump-pointer.
void push_front(pointer val)
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
bool hasEHFunclets() const
SmallVector< MCSymbol *, 1 > BeginLabels
static NodeRef getEntryNode(MachineFunction *F)
std::reverse_iterator< iterator > reverse_iterator
const_reverse_iterator rend() const
const MachineRegisterInfo & getRegInfo() const
bool verifyRequiredProperties(const MachineFunctionProperties &V) const
void splice(iterator where, iplist_impl &L2)
std::vector< int > TypeIds
void addCallArgsForwardingRegs(const MachineInstr *CallI, CallSiteInfoImpl &&CallInfo)
This class describes a target machine that is implemented with the LLVM target-independent code gener...
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
void setHasInlineAsm(bool B)
Set a flag that indicates that the function contains inline assembly.
void splice(iterator InsertPt, iterator MBBI, iterator MBBE)
WinEHFuncInfo * getWinEHFuncInfo()
MachineConstantPool * getConstantPool()
getConstantPool - Return the constant pool object for the current function.
const Ty * getInfo() const
const MachineBasicBlock & front() const
MachineBasicBlock & back()
An intrusive list with ownership and callbacks specified/controlled by ilist_traits, only with API safe for polymorphic types.
This class contains a discriminated union of information about pointers in memory operands...
bool verify(const TargetRegisterInfo &TRI) const
Check that information hold by this instance make sense for the given TRI.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Synchronized with respect to all concurrently executing threads.
const STC & getSubtarget() const
getSubtarget - This method returns a pointer to the specified type of TargetSubtargetInfo.
const std::vector< LandingPadInfo > & getLandingPads() const
Return a reference to the landing pad info for the current function.
print lazy value Lazy Value Info Printer Pass
Iterator for intrusive lists based on ilist_node.
Recycler - This class manages a linked-list of deallocated nodes and facilitates reusing deallocated ...
void splice(iterator InsertPt, iterator MBBI)
WasmEHFuncInfo * getWasmEHFuncInfo()
const std::vector< MCSymbol * > & getLongjmpTargets() const
Returns a reference to a list of symbols immediately following calls to _setjmp in the function...
MachineOperand class - Representation of each machine instruction operand.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
unsigned getWasmLandingPadIndex(const MachineBasicBlock *LPad) const
Get the index in wasm EH for a given landing pad.
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
void setCallsEHReturn(bool b)
MachineFunctionProperties & getProperties()
const WinEHFuncInfo * getWinEHFuncInfo() const
getWinEHFuncInfo - Return information about how the current function uses Windows exception handling...
bool callsUnwindInit() const
static void deleteNode(NodeTy *V)
void addLongjmpTarget(MCSymbol *Target)
Add the specified symbol to the list of valid longjmp targets for Windows Control Flow Guard...
const Function & getFunction() const
Return the LLVM function that this machine code represents.
bool callsEHReturn() const
void splice(iterator InsertPt, MachineBasicBlock *MBB)
MachineFunctionProperties & reset()
Reset all the properties.
Target - Wrapper for Target specific information.
void push_back(pointer val)
LLVM_ATTRIBUTE_RETURNS_NONNULL LLVM_ATTRIBUTE_RETURNS_NOALIAS void * Allocate(size_t Size, Align Alignment)
Allocate space at the specified alignment.
typename SuperClass::iterator iterator
static void clear(coro::Shape &Shape)
static unsigned size(MachineFunction *F)
MachineBasicBlock * LandingPadBlock
FunctionNumber(functionNumber)
Flags
Flags values. These may be or'd together.
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
MachineFunctionProperties & set(Property P)
TargetSubtargetInfo - Generic base class for all target subtargets.
const WasmEHFuncInfo * getWasmEHFuncInfo() const
getWasmEHFuncInfo - Return information about how the current function uses Wasm exception handling...
Representation of each machine instruction.
pointer remove(iterator &IT)
static Ty * create(BumpPtrAllocator &Allocator, MachineFunction &MF)
Factory function: default behavior is to call new using the supplied allocator.
void reset()
Reset the instance as if it was just created.
iterator insert(iterator where, pointer New)
static unsigned size(const MachineFunction *F)
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
bool exposesReturnsTwice() const
exposesReturnsTwice - Returns true if the function calls setjmp or any other similar functions with a...
LandingPadInfo(MachineBasicBlock *MBB)
bool hasInlineAsm() const
Returns true if the function contains any inline assembly.
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
const MachineBasicBlock & back() const
MachineBasicBlock & front()
void setExposesReturnsTwice(bool B)
setCallsSetJmp - Set a flag that indicates if there's a call to a "returns twice" function...
void removeFromMBBNumbering(unsigned N)
removeFromMBBNumbering - Remove the specific machine basic block from our tracker, this is only really to be used by the MachineBasicBlock implementation.
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
bool hasWasmLandingPadIndex(const MachineBasicBlock *LPad) const
Returns true if the landing pad has an associate index in wasm EH.
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
LLVM_NODISCARD bool empty() const
ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
#define LLVM_NODISCARD
LLVM_NODISCARD - Warn if a type or return value is discarded.
void setWasmLandingPadIndex(const MachineBasicBlock *LPad, unsigned Index)
Map the landing pad to its index. Used for Wasm exception handling.
static NodeRef getEntryNode(const MachineFunction *F)
void erase(iterator MBBI)
const_reverse_iterator rbegin() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool hasProperty(Property P) const
void insert(iterator MBBI, MachineBasicBlock *MBB)
static nodes_iterator nodes_end(const MachineFunction *F)
MachineFunctionProperties & reset(const MachineFunctionProperties &MFP)
unsigned addToMBBNumbering(MachineBasicBlock *MBB)
Adds the MBB to the internal numbering.
void deallocateOperandArray(OperandCapacity Cap, MachineOperand *Array)
Dellocate an array of MachineOperands and recycle the memory.
static MachineMemOperand * getMachineMemOperand(MachineFunction &MF, FrameIndexSDNode &FI)
void push_back(MachineBasicBlock *MBB)
const BlockAddress * RecoverBA
Address of block to recover at. Null for a finally handler.
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
static NodeRef getEntryNode(Inverse< const MachineFunction *> G)
DenormalMode
Represent handled modes for denormal (aka subnormal) modes in the floating point environment.
This class implements an extremely fast bulk output stream that can only output to a stream...
Callbacks do nothing by default in iplist and ilist.
const VariableDbgInfoMapTy & getVariableDbgInfo() const
void deallocate(Capacity Cap, T *Ptr)
Deallocate an array with the specified Capacity.
Manages creation of pseudo source values.
StringRef - Represent a constant reference to a string, i.e.
void addCodeViewAnnotation(MCSymbol *Label, MDNode *MD)
Record annotations associated with a particular label.
const std::vector< const GlobalValue * > & getTypeInfos() const
Return a reference to the C++ typeinfo for the current function.
const MachineJumpTableInfo * getJumpTableInfo() const
getJumpTableInfo - Return the jump table info object for the current function.
const DIExpression * Expr
void setVariableDbgInfo(const DILocalVariable *Var, const DIExpression *Expr, int Slot, const DILocation *Loc)
Collect information used to emit debugging information of a variable.
reverse_iterator rbegin()
VariableDbgInfoMapTy VariableDbgInfos
MachineOperand * allocateOperandArray(OperandCapacity Cap)
Allocate an array of MachineOperands.
Properties which a MachineFunction may have at a given point in time.
This class contains meta information specific to a module.