18 #ifndef LLVM_CODEGEN_MACHINEFUNCTION_H 19 #define LLVM_CODEGEN_MACHINEFUNCTION_H 57 class DILocalVariable;
61 class MachineConstantPool;
62 class MachineFrameInfo;
63 class MachineFunction;
64 class MachineJumpTableInfo;
65 class MachineModuleInfo;
66 class MachineRegisterInfo;
70 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;
304 std::unique_ptr<PseudoSourceValueManager> PSVManager;
308 std::vector<MCCFIInstruction> FrameInstructions;
314 std::vector<LandingPadInfo> LandingPads;
323 std::vector<std::pair<MCSymbol *, MDNode *>> CodeViewAnnotations;
325 bool CallsEHReturn =
false;
326 bool CallsUnwindInit =
false;
327 bool HasEHScopes =
false;
328 bool HasEHFunclets =
false;
331 std::vector<const GlobalValue *> TypeInfos;
334 std::vector<unsigned> FilterIds;
337 std::vector<unsigned> FilterEnds;
364 : Var(Var), Expr(Expr), Slot(Slot), Loc(Loc) {}
411 return *
static_cast<const STC *
>(STI);
460 if (Alignment < A) Alignment = A;
467 return ExposesReturnsTwice;
473 ExposesReturnsTwice =
B;
499 template<
typename Ty>
502 MFInfo = Ty::template create<Ty>(
Allocator, *
this);
503 return static_cast<Ty*
>(MFInfo);
506 template<
typename Ty>
516 assert(N < MBBNumbering.size() &&
"Illegal block number");
517 assert(MBBNumbering[N] &&
"Block was removed from the machine function!");
518 return MBBNumbering[
N];
522 bool shouldSplitStack()
const;
543 void viewCFG()
const;
550 void viewCFGOnly()
const;
558 bool verify(
Pass *p =
nullptr,
const char *Banner =
nullptr,
559 bool AbortOnError =
true)
const;
570 return &MachineFunction::BasicBlocks;
590 unsigned size()
const {
return (
unsigned)BasicBlocks.size();}
591 bool empty()
const {
return BasicBlocks.empty(); }
600 BasicBlocks.
insert(MBBI, MBB);
603 BasicBlocks.
splice(InsertPt, BasicBlocks, MBBI);
606 BasicBlocks.
splice(InsertPt, BasicBlocks, MBB);
609 BasicBlocks.
splice(InsertPt, BasicBlocks, MBBI, MBBE);
617 template <
typename Comp>
619 BasicBlocks.sort(comp);
628 MBBNumbering.push_back(MBB);
629 return (
unsigned)MBBNumbering.size()-1;
636 assert(N < MBBNumbering.size() &&
"Illegal basic block #");
637 MBBNumbering[
N] =
nullptr;
678 const MDNode *Ranges =
nullptr,
701 return OperandRecycler.
allocate(Cap, Allocator);
721 MachineInstr::mmo_iterator>
722 extractLoadMemRefs(MachineInstr::mmo_iterator Begin,
723 MachineInstr::mmo_iterator End);
728 MachineInstr::mmo_iterator>
729 extractStoreMemRefs(MachineInstr::mmo_iterator Begin,
730 MachineInstr::mmo_iterator End);
742 bool isLinkerPrivate =
false)
const;
752 return FrameInstructions;
756 FrameInstructions.push_back(Inst);
757 return FrameInstructions.size() - 1;
815 int getFilterIDFor(std::vector<unsigned> &TyIds);
822 assert(hasCallSiteLandingPad(Sym) &&
823 "missing call site number for landing pad!");
824 return LPadToCallSiteMap[Sym];
829 return !LPadToCallSiteMap[Sym].
empty();
834 CallSiteMap[BeginLabel] = Site;
839 assert(hasCallSiteBeginLabel(BeginLabel) &&
840 "Missing call site number for EH_LABEL!");
841 return CallSiteMap.
lookup(BeginLabel);
846 return CallSiteMap.
count(BeginLabel);
851 CodeViewAnnotations.push_back({Label, MD});
855 return CodeViewAnnotations;
879 return VariableDbgInfos;
946 return &G.
Graph->front();
952 return &G.
Graph->front();
958 #endif // LLVM_CODEGEN_MACHINEFUNCTION_H void push_front(MachineBasicBlock *MBB)
Pass interface - Implemented by all 'passes'.
ArrayRef< std::pair< MCSymbol *, MDNode * > > getCodeViewAnnotations() const
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.
Compute iterated dominance frontiers using a linear time algorithm.
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.
void addLandingPadInfo(const LandingPadInst &I, MachineBasicBlock &MBB)
Extract the exception handling information from the landingpad instruction and add them to the specif...
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
#define LLVM_NODISCARD
LLVM_NODISCARD - Warn if a type or return value is discarded.
MachineModuleInfo & getMMI() const
static NodeRef getEntryNode(Inverse< MachineFunction *> G)
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.
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)
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
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)
MachineMemOperand ** mmo_iterator
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...
The landingpad instruction holds all of the information necessary to generate correct exception handl...
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)
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)
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...
#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...
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.
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.
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...
static NodeRef getEntryNode(const MachineFunction *F)
Synchronized with respect to all concurrently executing threads.
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.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
void push_back(MachineBasicBlock *MBB)
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
Primary interface to the complete machine description for the target machine.
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.