18 #ifndef LLVM_CODEGEN_MACHINEFUNCTION_H 19 #define LLVM_CODEGEN_MACHINEFUNCTION_H 57 class DILocalVariable;
61 class LLVMTargetMachine;
62 class MachineConstantPool;
63 class MachineFrameInfo;
64 class MachineFunction;
65 class MachineJumpTableInfo;
66 class MachineModuleInfo;
67 class MachineRegisterInfo;
71 class PseudoSourceValueManager;
74 class TargetRegisterClass;
75 class TargetSubtargetInfo;
76 struct WasmEHFuncInfo;
87 template <
class Iterator>
104 template<
typename Ty>
106 return new (Allocator.
Allocate<Ty>()) Ty(MF);
158 LastProperty = Selected,
162 return Properties[
static_cast<unsigned>(
P)];
166 Properties.
set(static_cast<unsigned>(
P));
171 Properties.
reset(static_cast<unsigned>(P));
182 Properties |= MFP.Properties;
187 Properties.
reset(MFP.Properties);
194 return !V.Properties.
test(Properties);
202 BitVector(static_cast<unsigned>(Property::LastProperty)+1);
223 : LandingPadBlock(MBB) {}
260 std::vector<MachineBasicBlock*> MBBNumbering;
291 bool ExposesReturnsTwice =
false;
294 bool HasInlineAsm =
false;
297 bool HasWinCFI =
false;
304 std::unique_ptr<PseudoSourceValueManager> PSVManager;
308 std::vector<MCCFIInstruction> FrameInstructions;
314 std::vector<LandingPadInfo> LandingPads;
326 std::vector<std::pair<MCSymbol *, MDNode *>> CodeViewAnnotations;
328 bool CallsEHReturn =
false;
329 bool CallsUnwindInit =
false;
330 bool HasEHScopes =
false;
331 bool HasEHFunclets =
false;
332 bool HasLocalEscape =
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();
409 assert(TheDelegate == delegate &&
410 "Only the current delegate can perform reset!");
411 TheDelegate =
nullptr;
417 assert(delegate && !TheDelegate &&
418 "Attempted to set delegate to null, or to change it without " 419 "first resetting it!");
421 TheDelegate = delegate;
453 return *
static_cast<const STC *
>(STI);
502 if (Alignment < A) Alignment =
A;
509 return ExposesReturnsTwice;
515 ExposesReturnsTwice =
B;
540 template<
typename Ty>
543 MFInfo = Ty::template create<Ty>(
Allocator, *
this);
544 return static_cast<Ty*
>(MFInfo);
547 template<
typename Ty>
557 assert(N < MBBNumbering.size() &&
"Illegal block number");
558 assert(MBBNumbering[N] &&
"Block was removed from the machine function!");
559 return MBBNumbering[
N];
563 bool shouldSplitStack()
const;
584 void viewCFG()
const;
591 void viewCFGOnly()
const;
599 bool verify(
Pass *p =
nullptr,
const char *Banner =
nullptr,
600 bool AbortOnError =
true)
const;
611 return &MachineFunction::BasicBlocks;
631 unsigned size()
const {
return (
unsigned)BasicBlocks.size();}
632 bool empty()
const {
return BasicBlocks.empty(); }
641 BasicBlocks.
insert(MBBI, MBB);
644 BasicBlocks.
splice(InsertPt, BasicBlocks, MBBI);
647 BasicBlocks.
splice(InsertPt, BasicBlocks, MBB);
650 BasicBlocks.
splice(InsertPt, BasicBlocks, MBBI, MBBE);
658 template <
typename Comp>
660 BasicBlocks.sort(comp);
667 InstrCount += MBB.size();
677 MBBNumbering.push_back(MBB);
678 return (
unsigned)MBBNumbering.size()-1;
685 assert(N < MBBNumbering.size() &&
"Illegal basic block #");
686 MBBNumbering[
N] =
nullptr;
727 const MDNode *Ranges =
nullptr,
750 return OperandRecycler.
allocate(Cap, Allocator);
767 MachineInstr::ExtraInfo *
770 MCSymbol *PostInstrSymbol =
nullptr);
782 bool isLinkerPrivate =
false)
const;
792 return FrameInstructions;
796 FrameInstructions.push_back(Inst);
797 return FrameInstructions.size() - 1;
823 bool TidyIfNoBeginLabels =
true);
861 int getFilterIDFor(std::vector<unsigned> &TyIds);
868 WasmLPadToIndexMap[LPad] =
Index;
873 return WasmLPadToIndexMap.
count(LPad);
878 assert(hasWasmLandingPadIndex(LPad));
879 return WasmLPadToIndexMap.
lookup(LPad);
884 assert(hasCallSiteLandingPad(Sym) &&
885 "missing call site number for landing pad!");
886 return LPadToCallSiteMap[Sym];
891 return !LPadToCallSiteMap[Sym].
empty();
896 CallSiteMap[BeginLabel] = Site;
901 assert(hasCallSiteBeginLabel(BeginLabel) &&
902 "Missing call site number for EH_LABEL!");
903 return CallSiteMap.
lookup(BeginLabel);
908 return CallSiteMap.
count(BeginLabel);
913 CodeViewAnnotations.push_back({Label, MD});
917 return CodeViewAnnotations;
941 return VariableDbgInfos;
999 return &G.
Graph->front();
1005 return &G.
Graph->front();
1011 #endif // LLVM_CODEGEN_MACHINEFUNCTION_H void push_front(MachineBasicBlock *MBB)
Pass interface - Implemented by all 'passes'.
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. ...
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.
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 ...
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.
Describe properties that are true of each instruction in the target description file.
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...
#define LLVM_NODISCARD
LLVM_NODISCARD - Warn if a type or return value is discarded.
The address of a basic block.
A description of a memory reference used in the backend.
amdgpu Simplify well known AMD library false Value Value const Twine & Name
MachineJumpTableInfo * getJumpTableInfo()
SmallVector< MCSymbol *, 1 > EndLabels
static unsigned addLiveIn(MachineFunction &MF, unsigned PReg, const TargetRegisterClass *RC)
SmallVector< SEHHandler, 1 > SEHHandlers
static StringRef getName(Value *V)
unsigned getAlignment() const
getAlignment - Return the alignment (log2, not bytes) of the function.
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
LLVM_NODISCARD unsigned addFrameInst(const MCCFIInstruction &Inst)
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.
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.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
const MachineFrameInfo & getFrameInfo() const
VariableDbgInfo(const DILocalVariable *Var, const DIExpression *Expr, int Slot, const DILocation *Loc)
const_iterator begin() const
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.
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)
LLVM_ATTRIBUTE_RETURNS_NONNULL LLVM_ATTRIBUTE_RETURNS_NOALIAS void * Allocate(size_t Size, size_t Alignment)
Allocate space at the specified alignment.
const_reverse_iterator rend() const
const MachineRegisterInfo & getRegInfo() const
void ensureAlignment(unsigned A)
ensureAlignment - Make sure the function is at least 1 << A bytes aligned.
bool verifyRequiredProperties(const MachineFunctionProperties &V) const
void splice(iterator where, iplist_impl &L2)
std::vector< int > TypeIds
void setSubtarget(const TargetSubtargetInfo *ST)
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...
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)
bool hasLocalEscape() const
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.
void setHasLocalEscape(bool V)
This class contains a discriminated union of information about pointers in memory operands...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
bool verify(const TargetRegisterInfo &TRI) const
Check that information hold by this instance make sense for the given TRI.
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()
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)
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)
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)
void emplace_back(ArgTypes &&... Args)
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...
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.
void push_back(MachineBasicBlock *MBB)
Synchronized with respect to all concurrently executing threads.
const BlockAddress * RecoverBA
Address of block to recover at. Null for a finally handler.
void setAlignment(unsigned A)
setAlignment - Set the alignment (log2, not bytes) of the function.
static NodeRef getEntryNode(Inverse< const MachineFunction *> G)
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.