18 #ifndef LLVM_CODEGEN_MACHINEFUNCTION_H
19 #define LLVM_CODEGEN_MACHINEFUNCTION_H
41 class MachineRegisterInfo;
42 class MachineFrameInfo;
43 class MachineConstantPool;
44 class MachineJumpTableInfo;
45 class MachineModuleInfo;
48 class PseudoSourceValueManager;
50 class TargetSubtargetInfo;
51 class TargetRegisterClass;
52 struct MachinePointerInfo;
63 template <
class Iterator>
82 return new (Allocator.
Allocate<Ty>()) Ty(MF);
138 return Properties[
static_cast<unsigned>(
P)];
141 Properties.
set(static_cast<unsigned>(P));
145 Properties.
reset(static_cast<unsigned>(P));
154 Properties |= MFP.Properties;
158 Properties.
reset(MFP.Properties);
164 return !V.Properties.
test(Properties);
227 std::vector<MachineBasicBlock*> MBBNumbering;
248 unsigned FunctionNumber;
258 bool ExposesReturnsTwice =
false;
261 bool HasInlineAsm =
false;
271 std::unique_ptr<PseudoSourceValueManager> PSVManager;
275 std::vector<MCCFIInstruction> FrameInstructions;
281 std::vector<LandingPadInfo> LandingPads;
289 bool CallsEHReturn =
false;
290 bool CallsUnwindInit =
false;
291 bool HasEHFunclets =
false;
294 std::vector<const GlobalValue *> TypeInfos;
297 std::vector<unsigned> FilterIds;
300 std::vector<unsigned> FilterEnds;
329 : Var(Var), Expr(Expr), Slot(Slot), Loc(Loc) {}
377 return *
static_cast<const STC *
>(STI);
425 if (Alignment < A) Alignment =
A;
432 return ExposesReturnsTwice;
438 ExposesReturnsTwice =
B;
464 template<
typename Ty>
467 MFInfo = Ty::template create<Ty>(Allocator, *
this);
468 return static_cast<Ty*
>(MFInfo);
471 template<
typename Ty>
482 assert(N < MBBNumbering.size() &&
"Illegal block number");
483 assert(MBBNumbering[N] &&
"Block was removed from the machine function!");
484 return MBBNumbering[
N];
528 bool verify(
Pass *p =
nullptr,
const char *Banner =
nullptr,
529 bool AbortOnError =
true)
const;
540 return &MachineFunction::BasicBlocks;
560 unsigned size()
const {
return (
unsigned)BasicBlocks.size();}
561 bool empty()
const {
return BasicBlocks.empty(); }
570 BasicBlocks.
insert(MBBI, MBB);
573 BasicBlocks.
splice(InsertPt, BasicBlocks, MBBI);
576 BasicBlocks.
splice(InsertPt, BasicBlocks, MBB);
579 BasicBlocks.
splice(InsertPt, BasicBlocks, MBBI, MBBE);
587 template <
typename Comp>
589 BasicBlocks.sort(comp);
600 MBBNumbering.push_back(MBB);
601 return (
unsigned)MBBNumbering.size()-1;
608 assert(N < MBBNumbering.size() &&
"Illegal basic block #");
609 MBBNumbering[
N] =
nullptr;
645 const MDNode *Ranges =
nullptr,
655 int64_t
Offset, uint64_t Size);
662 return OperandRecycler.
allocate(Cap, Allocator);
674 unsigned Size = (NumRegister + 31) / 32;
676 for (
unsigned i = 0;
i != Size; ++
i)
710 bool isLinkerPrivate =
false)
const;
720 return FrameInstructions;
724 FrameInstructions.push_back(Inst);
725 return FrameInstructions.size() - 1;
788 "missing call site number for landing pad!");
789 return LPadToCallSiteMap[Sym];
794 return !LPadToCallSiteMap[Sym].empty();
799 CallSiteMap[BeginLabel] = Site;
805 "Missing call site number for EH_LABEL!");
806 return CallSiteMap.lookup(BeginLabel);
811 return CallSiteMap.count(BeginLabel);
864 return nodes_iterator(F->
begin());
867 return nodes_iterator(F->
end());
878 return nodes_iterator(F->
begin());
881 return nodes_iterator(F->
end());
void push_front(MachineBasicBlock *MBB)
Pass interface - Implemented by all 'passes'.
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...
unsigned getAlignment() const
getAlignment - Return the alignment (log2, not bytes) of the function.
bool verify(Pass *p=nullptr, const char *Banner=nullptr, bool AbortOnError=true) const
Run the current MachineFunction through the machine code verifier, useful for debugger use...
bool hasCallSiteLandingPad(MCSymbol *Sym)
Return true if the landing pad Eh symbol has an associated call site.
void setVariableDbgInfo(const DILocalVariable *Var, const DIExpression *Expr, unsigned Slot, const DILocation *Loc)
Collect information used to emit debugging information of a variable.
static BasicBlockListType MachineFunction::* getSublistAccess(MachineBasicBlock *)
Support for MachineBasicBlock::getNextNode().
iterator erase(iterator where)
MachineFunctionProperties & reset(Property P)
void setHasWinCFI(bool v)
void RenumberBlocks(MachineBasicBlock *MBBFrom=nullptr)
RenumberBlocks - This discards all of the MachineBasicBlock numbers and recomputes them...
MCSymbol * addLandingPad(MachineBasicBlock *LandingPad)
Add a new panding pad. Returns the label ID for the landing pad entry.
void addNodeToList(NodeTy *)
When an MBB is added to an MF, we need to update the parent pointer of the MBB, the MBB numbering...
bool hasProperty(Property P) const
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 ...
aarch64 AArch64 CCMP Pass
void transferNodesFromList(ilist_callback_traits &OldList, Iterator, Iterator)
static nodes_iterator nodes_end(MachineFunction *F)
void setHasEHFunclets(bool V)
const Function * FilterOrFinally
Filter or finally function. Null indicates a catch-all.
void addLandingPadInfo(const LandingPadInst &I, MachineBasicBlock &MBB)
Extract the exception handling information from the landingpad instruction and add them to the specif...
unsigned addLiveIn(unsigned PReg, const TargetRegisterClass *RC)
addLiveIn - Add the specified physical register as a live-in value and create a corresponding virtual...
Describe properties that are true of each instruction in the target description file.
bool callsEHReturn() const
bool hasInlineAsm() const
Returns true if the function contains any inline assembly.
ArrayRecycler< MachineOperand >::Capacity OperandCapacity
const std::vector< LandingPadInfo > & getLandingPads() const
Return a reference to the landing pad info for the current function.
const std::vector< unsigned > & getFilterIds() const
Return a reference to the typeids encoding filters used in the current function.
const Function * getFunction() const
getFunction - Return the LLVM function that this machine code represents
MCSymbol * LandingPadLabel
const std::vector< const GlobalValue * > & getTypeInfos() const
Return a reference to the C++ typeinfo for the current function.
unsigned getTypeIDFor(const GlobalValue *TI)
Return the type id for the specified typeinfo. This is function wide.
unsigned getFunctionNumber() const
getFunctionNumber - Return a unique ID for the current function.
MachineInstr * CreateMachineInstr(const MCInstrDesc &MCID, const DebugLoc &DL, bool NoImp=false)
CreateMachineInstr - Allocate a new MachineInstr.
static nodes_iterator nodes_begin(const MachineFunction *F)
void DeleteMachineBasicBlock(MachineBasicBlock *MBB)
DeleteMachineBasicBlock - Delete the given MachineBasicBlock.
VariableDbgInfoMapTy & getVariableDbgInfo()
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
MachineJumpTableInfo * getOrCreateJumpTableInfo(unsigned JTEntryKind)
getOrCreateJumpTableInfo - Get the JumpTableInfo for this function, if it does already exist...
void viewCFG() const
viewCFG - This function is meant for use from the debugger.
static nodes_iterator nodes_begin(MachineFunction *F)
MachineFunctionInfo - This class can be derived from and used by targets to hold private target-speci...
pointer_iterator< MachineFunction::iterator > nodes_iterator
The address of a basic block.
VariableDbgInfo(const DILocalVariable *Var, const DIExpression *Expr, unsigned Slot, const DILocation *Loc)
void addSEHCleanupHandler(MachineBasicBlock *LandingPad, const Function *Cleanup)
A description of a memory reference used in the backend.
unsigned getNumBlockIDs() const
getNumBlockIDs - Return the number of MBB ID's allocated.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineJumpTableInfo * getJumpTableInfo()
MachineFunctionProperties & set(const MachineFunctionProperties &MFP)
SmallVector< MCSymbol *, 1 > EndLabels
const_reverse_iterator rend() const
SmallVector< SEHHandler, 1 > SEHHandlers
void addCatchTypeInfo(MachineBasicBlock *LandingPad, ArrayRef< const GlobalValue * > TyInfo)
Provide the catch typeinfo for a landing pad.
const STC & getSubtarget() const
getSubtarget - This method returns a pointer to the specified type of TargetSubtargetInfo.
const MachineFunctionProperties & getProperties() const
Get the function properties.
void addFilterTypeInfo(MachineBasicBlock *LandingPad, ArrayRef< const GlobalValue * > TyInfo)
Provide the filter typeinfo for a landing pad.
MachineMemOperand ** mmo_iterator
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
std::pair< MachineInstr::mmo_iterator, MachineInstr::mmo_iterator > extractLoadMemRefs(MachineInstr::mmo_iterator Begin, MachineInstr::mmo_iterator End)
extractLoadMemRefs - Allocate an array and populate it with just the load information from the given ...
int getFilterIDFor(std::vector< unsigned > &TyIds)
Return the id of the filter encoded by TyIds. This is function wide.
LLVM_NODISCARD unsigned addFrameInst(const MCCFIInstruction &Inst)
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.
SmallVector< VariableDbgInfo, 4 > VariableDbgInfoMapTy
const MachineBasicBlock & front() const
This structure is used to retain landing pad info for the current function.
void erase(MachineBasicBlock *MBBI)
void setCallSiteBeginLabel(MCSymbol *BeginLabel, unsigned Site)
Map the begin label for a call site.
const MachineJumpTableInfo * getJumpTableInfo() const
getJumpTableInfo - Return the jump table info object for the current function.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
static GCRegistry::Add< OcamlGC > B("ocaml","ocaml 3.10-compatible GC")
MCContext & getContext() const
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
BasicBlockListType::reverse_iterator reverse_iterator
PseudoSourceValueManager & getPSVManager() const
MachineBasicBlock * CreateMachineBasicBlock(const BasicBlock *bb=nullptr)
CreateMachineBasicBlock - Allocate a new MachineBasicBlock.
const DILocalVariable * Var
const MachineRegisterInfo & getRegInfo() const
BasicBlockListType::const_reverse_iterator const_reverse_iterator
Use delete by default for iplist and ilist.
LLVM Basic Block Representation.
void addInvoke(MachineBasicBlock *LandingPad, MCSymbol *BeginLabel, MCSymbol *EndLabel)
Provide the begin and end labels of an invoke style call and associate it with a try landing pad bloc...
void addSEHCatchHandler(MachineBasicBlock *LandingPad, const Function *Filter, const BlockAddress *RecoverLabel)
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.
SmallVector< MCSymbol *, 1 > BeginLabels
static NodeRef getEntryNode(MachineFunction *F)
static NodeRef getEntryNode(Inverse< const MachineFunction * > G)
const VariableDbgInfoMapTy & getVariableDbgInfo() const
LLVM_ATTRIBUTE_RETURNS_NONNULL LLVM_ATTRIBUTE_RETURNS_NOALIAS void * Allocate(size_t Size, size_t Alignment)
Allocate space at the specified alignment.
void ensureAlignment(unsigned A)
ensureAlignment - Make sure the function is at least 1 << A bytes aligned.
void viewCFGOnly() const
viewCFGOnly - This function is meant for use from the debugger.
Greedy Register Allocator
virtual ~MachineFunctionInfo()
void splice(iterator where, iplist_impl &L2)
bool shouldSplitStack() const
Should we be emitting segmented stack stuff for the function.
std::vector< int > TypeIds
void setSubtarget(const TargetSubtargetInfo *ST)
void print(raw_ostream &OS) const
Print the MachineFunctionProperties in human-readable form.
static const unsigned End
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
const std::vector< MCCFIInstruction > & getFrameInstructions() const
Returns a reference to a list of cfi instructions in the function's prologue.
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.
void DeleteMachineInstr(MachineInstr *MI)
DeleteMachineInstr - Delete the given MachineInstr.
uint32_t * allocateRegisterMask(unsigned NumRegister)
Allocate and initialize a register mask with NumRegister bits.
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...
const char * createExternalSymbolName(StringRef Name)
Allocate a string and populate it with the given external symbol name.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
void dump() const
dump - Print the current MachineFunction to cerr, useful for debugger use.
void addCleanup(MachineBasicBlock *LandingPad)
Add a cleanup action for a landing pad.
Iterator for intrusive lists based on ilist_node.
MCSymbol * getPICBaseSymbol() const
getPICBaseSymbol - Return a function-local symbol to represent the PIC base.
Recycler - This class manages a linked-list of deallocated nodes and facilitates reusing deallocated ...
BasicBlockListType::const_iterator const_iterator
void splice(iterator InsertPt, iterator MBBI)
MachineInstr * CloneMachineInstr(const MachineInstr *Orig)
CloneMachineInstr - Create a new MachineInstr which is a copy of the 'Orig' instruction, identical in all ways except the instruction has no parent, prev, or next.
void removeNodeFromList(NodeTy *)
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...
bool test(unsigned Idx) const
MachineBasicBlock * getBlockNumbered(unsigned N) const
getBlockNumbered - MachineBasicBlocks are automatically numbered when they are inserted into the mach...
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
bool verifyRequiredProperties(const MachineFunctionProperties &V) const
void setCallsEHReturn(bool b)
MachineFunctionProperties & getProperties()
const_iterator end() const
static void deleteNode(NodeTy *V)
const MachineConstantPool * getConstantPool() const
void splice(iterator InsertPt, MachineBasicBlock *MBB)
MCSymbol * getJTISymbol(unsigned JTI, MCContext &Ctx, bool isLinkerPrivate=false) const
getJTISymbol - Return the MCSymbol for the specified non-empty jump table.
MachineFunctionProperties & reset()
Reset all the properties.
void setCallSiteLandingPad(MCSymbol *Sym, ArrayRef< unsigned > Sites)
Map the landing pad's EH symbol to the call site indexes.
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags f, uint64_t s, unsigned base_alignment, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr, SynchronizationScope SynchScope=CrossThread, AtomicOrdering Ordering=AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering=AtomicOrdering::NotAtomic)
getMachineMemOperand - Allocate a new MachineMemOperand.
Target - Wrapper for Target specific information.
void push_back(pointer val)
bool hasEHFunclets() const
static unsigned size(MachineFunction *F)
MachineBasicBlock * LandingPadBlock
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.
Representation of each machine instruction.
pointer remove(iterator &IT)
static NodeRef getEntryNode(Inverse< MachineFunction * > G)
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)
void emplace_back(ArgTypes &&...Args)
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)
const MachineFrameInfo & getFrameInfo() const
bool callsUnwindInit() const
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
MachineBasicBlock & front()
void print(raw_ostream &OS, const SlotIndexes *=nullptr) const
print - Print out the MachineFunction in a format suitable for debugging to the specified stream...
const WinEHFuncInfo * getWinEHFuncInfo() const
getWinEHFuncInfo - Return information about how the current function uses Windows exception handling...
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.
bool hasCallSiteBeginLabel(MCSymbol *BeginLabel) const
Return true if the begin label has a call site number associated with it.
pointer_iterator< MachineFunction::const_iterator > nodes_iterator
#define LLVM_NODISCARD
LLVM_NODISCARD - Warn if a type or return value is discarded.
static NodeRef getEntryNode(const MachineFunction *F)
const Ty * getInfo() const
std::pair< MachineInstr::mmo_iterator, MachineInstr::mmo_iterator > extractStoreMemRefs(MachineInstr::mmo_iterator Begin, MachineInstr::mmo_iterator End)
extractStoreMemRefs - Allocate an array and populate it with just the store information from the give...
void erase(iterator MBBI)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void insert(iterator MBBI, MachineBasicBlock *MBB)
static nodes_iterator nodes_end(const MachineFunction *F)
MachineFunctionProperties & reset(const MachineFunctionProperties &MFP)
LandingPadInfo & getOrCreateLandingPadInfo(MachineBasicBlock *LandingPad)
Find or create an LandingPadInfo for the specified MachineBasicBlock.
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)
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.
void setAlignment(unsigned A)
setAlignment - Set the alignment (log2, not bytes) of the function.
BasicBlockListType::iterator iterator
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.
Primary interface to the complete machine description for the target machine.
const MachineBasicBlock & back() const
const_reverse_iterator rbegin() 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.
MachineModuleInfo & getMMI() const
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
unsigned getCallSiteBeginLabel(MCSymbol *BeginLabel) const
Get the call site number for a begin label.
const_iterator begin() const
const DIExpression * Expr
static GCRegistry::Add< ErlangGC > A("erlang","erlang-compatible garbage collector")
reverse_iterator rbegin()
VariableDbgInfoMapTy VariableDbgInfos
MachineInstr::mmo_iterator allocateMemRefsArray(unsigned long Num)
allocateMemRefsArray - Allocate an array to hold MachineMemOperand pointers.
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.
void tidyLandingPads(DenseMap< MCSymbol *, uintptr_t > *LPMap=nullptr)
Remap landing pad labels and remove any deleted landing pads.