48 #define DEBUG_TYPE "codegen"
52 cl::desc(
"Force the alignment of all functions."),
55 void MachineFunctionInitializer::anchor() {}
60 case P::FailedISel:
return "FailedISel";
61 case P::IsSSA:
return "IsSSA";
62 case P::Legalized:
return "Legalized";
63 case P::NoPHIs:
return "NoPHIs";
64 case P::NoVRegs:
return "NoVRegs";
65 case P::RegBankSelected:
return "RegBankSelected";
66 case P::Selected:
return "Selected";
67 case P::TracksLiveness:
return "TracksLiveness";
77 OS << Separator << getPropertyName(static_cast<Property>(
I));
102 : Fn(F),
Target(TM), STI(TM.getSubtargetImpl(*F)), Ctx(mmi.getContext()),
104 FunctionNumber = FunctionNum;
108 void MachineFunction::init() {
136 Alignment = std::max(Alignment,
142 JumpTableInfo =
nullptr;
150 "Can't create a MachineFunction using a Module with a "
151 "Target-incompatible DataLayout attached\n");
153 PSVManager = llvm::make_unique<PseudoSourceValueManager>();
160 void MachineFunction::clear() {
167 I->Insts.clearAndLeakNodesUnsafely();
169 InstructionRecycler.clear(Allocator);
170 OperandRecycler.
clear(Allocator);
171 BasicBlockRecycler.clear(Allocator);
173 RegInfo->~MachineRegisterInfo();
181 FrameInfo->~MachineFrameInfo();
188 JumpTableInfo->~MachineJumpTableInfo();
193 WinEHInfo->~WinEHFuncInfo();
206 if (JumpTableInfo)
return JumpTableInfo;
208 JumpTableInfo =
new (Allocator)
210 return JumpTableInfo;
223 if (
empty()) { MBBNumbering.clear();
return; }
231 unsigned BlockNo = 0;
233 BlockNo = std::prev(MBBI)->getNumber() + 1;
235 for (; MBBI !=
E; ++MBBI, ++BlockNo) {
236 if (MBBI->getNumber() != (int)BlockNo) {
238 if (MBBI->getNumber() != -1) {
239 assert(MBBNumbering[MBBI->getNumber()] == &*MBBI &&
240 "MBB number mismatch!");
241 MBBNumbering[MBBI->getNumber()] =
nullptr;
245 if (MBBNumbering[BlockNo])
246 MBBNumbering[BlockNo]->setNumber(-1);
248 MBBNumbering[BlockNo] = &*MBBI;
249 MBBI->setNumber(BlockNo);
255 assert(BlockNo <= MBBNumbering.size() &&
"Mismatch!");
256 MBBNumbering.resize(BlockNo);
263 return new (InstructionRecycler.Allocate<
MachineInstr>(Allocator))
271 return new (InstructionRecycler.Allocate<
MachineInstr>(Allocator))
288 InstructionRecycler.Deallocate(Allocator, MI);
303 MBB->~MachineBasicBlock();
304 BasicBlockRecycler.Deallocate(Allocator, MBB);
309 unsigned base_alignment,
const AAMDNodes &AAInfo,
const MDNode *Ranges,
312 return new (Allocator)
314 SynchScope, Ordering, FailureOrdering);
319 int64_t
Offset, uint64_t Size) {
321 return new (Allocator)
327 return new (Allocator)
340 std::pair<MachineInstr::mmo_iterator, MachineInstr::mmo_iterator>
353 if ((*I)->isLoad()) {
354 if (!(*I)->isStore())
362 (*I)->
getSize(), (*I)->getBaseAlignment(),
363 (*I)->getAAInfo(),
nullptr,
364 (*I)->getSynchScope(), (*I)->getOrdering(),
365 (*I)->getFailureOrdering());
366 Result[Index] = JustLoad;
371 return std::make_pair(Result, Result + Num);
374 std::pair<MachineInstr::mmo_iterator, MachineInstr::mmo_iterator>
387 if ((*I)->isStore()) {
396 (*I)->
getSize(), (*I)->getBaseAlignment(),
397 (*I)->getAAInfo(),
nullptr,
398 (*I)->getSynchScope(), (*I)->getOrdering(),
399 (*I)->getFailureOrdering());
400 Result[Index] = JustStore;
405 return std::make_pair(Result, Result + Num);
410 std::copy(Name.
begin(), Name.
end(), Dest);
411 Dest[Name.
size()] = 0;
415 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
427 OS <<
"# Machine code for function " <<
getName() <<
": ";
432 FrameInfo->
print(*
this, OS);
436 JumpTableInfo->
print(OS);
444 OS <<
"Function Live Ins: ";
449 OS <<
" in " <<
PrintReg(
I->second, TRI);
450 if (std::next(
I) !=
E)
458 for (
const auto &BB : *
this) {
460 BB.print(OS, MST, Indexes);
463 OS <<
"\n# End machine code for function " <<
getName() <<
".\n\n";
473 return (
"CFG for '" + F->
getName() +
"' function").str();
485 OSS <<
": " << BB->getName();
490 if (OutStr[0] ==
'\n') OutStr.erase(OutStr.begin());
493 for (
unsigned i = 0;
i != OutStr.length(); ++
i)
494 if (OutStr[
i] ==
'\n') {
496 OutStr.insert(OutStr.begin()+
i+1,
'l');
508 errs() <<
"MachineFunction::viewCFG is only available in debug builds on "
509 <<
"systems with Graphviz or gv!\n";
518 errs() <<
"MachineFunction::viewCFGOnly is only available in debug builds on "
519 <<
"systems with Graphviz or gv!\n";
539 "Register class mismatch!");
551 bool isLinkerPrivate)
const {
553 assert(JumpTableInfo &&
"No jump tables");
554 assert(JTI < JumpTableInfo->getJumpTables().
size() &&
"Invalid JTI!");
576 unsigned N = LandingPads.size();
577 for (
unsigned i = 0;
i <
N; ++
i) {
584 return LandingPads[
N];
598 return LandingPadLabel;
604 for (
unsigned N = TyInfo.
size();
N; --
N)
611 std::vector<unsigned> IdsInFilter(TyInfo.
size());
612 for (
unsigned I = 0,
E = TyInfo.
size();
I !=
E; ++
I)
618 for (
unsigned i = 0;
i != LandingPads.size(); ) {
628 LandingPads.erase(LandingPads.begin() +
i);
632 for (
unsigned j = 0, e = LandingPads[
i].BeginLabels.size(); j != e; ++j) {
636 (LPMap && (*LPMap)[BeginLabel] != 0)) &&
638 (LPMap && (*LPMap)[EndLabel] != 0)))
continue;
647 if (LandingPads[
i].BeginLabels.empty()) {
648 LandingPads.erase(LandingPads.begin() +
i);
687 LPadToCallSiteMap[Sym].append(Sites.
begin(), Sites.
end());
691 for (
unsigned i = 0,
N = TypeInfos.size();
i !=
N; ++
i)
692 if (TypeInfos[
i] == TI)
return i + 1;
694 TypeInfos.push_back(TI);
695 return TypeInfos.size();
702 for (std::vector<unsigned>::iterator
I = FilterEnds.begin(),
703 E = FilterEnds.end();
I !=
E; ++
I) {
704 unsigned i = *
I, j = TyIds.size();
707 if (FilterIds[--i] != TyIds[--j])
718 int FilterID = -(1 + FilterIds.size());
719 FilterIds.reserve(FilterIds.size() + TyIds.size() + 1);
720 FilterIds.insert(FilterIds.end(), TyIds.begin(), TyIds.end());
721 FilterEnds.push_back(FilterIds.size());
722 FilterIds.push_back(0);
728 if (
const auto *PF = dyn_cast<Function>(
745 Constant *CVal = cast<Constant>(Val);
749 FilterList.
push_back(cast<GlobalValue>((*II)->stripPointerCasts()));
764 if (!StackRealignable)
765 assert(Align <= StackAlignment &&
766 "For targets without stack realignment, Align is out of limit!");
767 if (MaxAlignment < Align) MaxAlignment = Align;
772 unsigned StackAlign) {
773 if (!ShouldClamp || Align <= StackAlign)
775 DEBUG(
dbgs() <<
"Warning: requested alignment " << Align
776 <<
" exceeds the stack alignment " << StackAlign
777 <<
" when stack realignment is off" <<
'\n');
785 assert(Size != 0 &&
"Cannot allocate zero size stack objects!");
787 Objects.push_back(StackObject(Size, Alignment, 0,
false, isSS, Alloca,
789 int Index = (int)Objects.size() - NumFixedObjects - 1;
790 assert(Index >= 0 &&
"Bad frame index!");
798 unsigned Alignment) {
801 int Index = (int)Objects.size() - NumFixedObjects - 1;
811 HasVarSizedObjects =
true;
813 Objects.push_back(StackObject(0, Alignment, 0,
false,
false, Alloca,
true));
815 return (
int)Objects.size()-NumFixedObjects-1;
823 bool Immutable,
bool isAliased) {
824 assert(Size != 0 &&
"Cannot allocate zero size fixed stack objects!");
831 unsigned Align =
MinAlign(SPOffset, ForcedRealign ? 1 : StackAlignment);
833 Objects.insert(Objects.begin(), StackObject(Size, Align, SPOffset, Immutable,
835 nullptr, isAliased));
836 return -++NumFixedObjects;
844 unsigned Align =
MinAlign(SPOffset, ForcedRealign ? 1 : StackAlignment);
846 Objects.insert(Objects.begin(), StackObject(Size, Align, SPOffset, Immutable,
850 return -++NumFixedObjects;
885 if (FixedOff > Offset) Offset = FixedOff;
893 Offset = (Offset+Align-1)/Align*Align;
895 MaxAlign = std::max(Align, MaxAlign);
915 StackAlign = std::max(StackAlign, MaxAlign);
916 unsigned AlignMask = StackAlign - 1;
917 Offset = (Offset + AlignMask) & ~uint64_t(AlignMask);
923 if (Objects.empty())
return;
928 OS <<
"Frame Objects:\n";
930 for (
unsigned i = 0, e = Objects.size();
i != e; ++
i) {
931 const StackObject &SO = Objects[
i];
932 OS <<
" fi#" << (int)(
i-NumFixedObjects) <<
": ";
933 if (SO.Size == ~0ULL) {
938 OS <<
"variable sized";
940 OS <<
"size=" << SO.Size;
941 OS <<
", align=" << SO.Alignment;
943 if (
i < NumFixedObjects)
945 if (
i < NumFixedObjects || SO.SPOffset != -1) {
946 int64_t Off = SO.SPOffset - ValOffset;
947 OS <<
", at location [SP";
958 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1009 const std::vector<MachineBasicBlock*> &DestBBs) {
1010 assert(!DestBBs.empty() &&
"Cannot create an empty jump table!");
1012 return JumpTables.size()-1;
1019 assert(Old != New &&
"Not making a change?");
1020 bool MadeChange =
false;
1021 for (
size_t i = 0, e = JumpTables.size();
i != e; ++
i)
1031 assert(Old != New &&
"Not making a change?");
1032 bool MadeChange =
false;
1034 for (
size_t j = 0, e = JTE.
MBBs.size(); j != e; ++j)
1035 if (JTE.
MBBs[j] == Old) {
1043 if (JumpTables.empty())
return;
1045 OS <<
"Jump Tables:\n";
1047 for (
unsigned i = 0, e = JumpTables.size();
i != e; ++
i) {
1048 OS <<
" jt#" <<
i <<
": ";
1049 for (
unsigned j = 0, f = JumpTables[i].MBBs.size(); j != f; ++j)
1050 OS <<
" BB#" << JumpTables[i].MBBs[j]->getNumber();
1056 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1065 void MachineConstantPoolValue::anchor() { }
1069 return Val.MachineCPVal->getType();
1070 return Val.ConstVal->getType();
1076 return Val.ConstVal->needsRelocation();
1101 for (
unsigned i = 0, e =
Constants.size();
i != e; ++
i)
1102 if (
Constants[
i].isMachineConstantPoolEntry()) {
1107 MachineCPVsSharingEntries.begin(),
E = MachineCPVsSharingEntries.end();
1109 if (Deleted.
count(*
I) == 0)
1119 if (A == B)
return true;
1126 if (isa<StructType>(A->
getType()) || isa<ArrayType>(A->
getType()) ||
1141 if (isa<PointerType>(A->
getType()))
1143 const_cast<Constant *>(A), IntTy, DL);
1144 else if (A->
getType() != IntTy)
1147 if (isa<PointerType>(B->
getType()))
1149 const_cast<Constant *>(B), IntTy, DL);
1150 else if (B->
getType() != IntTy)
1160 unsigned Alignment) {
1161 assert(Alignment &&
"Alignment must be specified!");
1162 if (Alignment > PoolAlignment) PoolAlignment = Alignment;
1167 for (
unsigned i = 0, e =
Constants.size();
i != e; ++
i)
1168 if (!
Constants[
i].isMachineConstantPoolEntry() &&
1170 if ((
unsigned)
Constants[
i].getAlignment() < Alignment)
1180 unsigned Alignment) {
1181 assert(Alignment &&
"Alignment must be specified!");
1182 if (Alignment > PoolAlignment) PoolAlignment = Alignment;
1189 MachineCPVsSharingEntries.insert(V);
1190 return (
unsigned)Idx;
1200 OS <<
"Constant Pool:\n";
1201 for (
unsigned i = 0, e =
Constants.size();
i != e; ++
i) {
1202 OS <<
" cp#" <<
i <<
": ";
1203 if (
Constants[i].isMachineConstantPoolEntry())
1204 Constants[i].Val.MachineCPVal->print(OS);
1206 Constants[
i].Val.ConstVal->printAsOperand(OS,
false);
1207 OS <<
", align=" <<
Constants[
i].getAlignment();
1212 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
Constant * ConstantFoldCastOperand(unsigned Opcode, Constant *C, Type *DestTy, const DataLayout &DL)
Attempt to constant fold a cast with the specified operand.
unsigned getStackAlignment() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
void push_back(const T &Elt)
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
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...
SectionKind getSectionKind(const DataLayout *DL) const
StringRef getPrivateGlobalPrefix() const
size_type size() const
size - Returns the number of bits in this bitvector.
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
Flags getFlags() const
Return the raw flags of the source value,.
static SectionKind getMergeableConst32()
BitVector getPristineRegs(const MachineFunction &MF) const
Return a set of physical registers that are pristine.
iterator erase(iterator where)
unsigned getPrefFunctionAlignment() const
Return the preferred function alignment.
MachineFunctionProperties & reset(Property P)
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds...
bool isValid() const
isValid - returns true if this iterator is not yet at the end.
void RenumberBlocks(MachineBasicBlock *MBBFrom=nullptr)
RenumberBlocks - This discards all of the MachineBasicBlock numbers and recomputes them...
livein_iterator livein_end() const
MCSymbol * addLandingPad(MachineBasicBlock *LandingPad)
Add a new panding pad. Returns the label ID for the landing pad entry.
StringRef getLinkerPrivateGlobalPrefix() const
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
Constant * getClause(unsigned Idx) const
Get the value of the clause at index Idx.
unsigned createVirtualRegister(const TargetRegisterClass *RegClass)
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
void addLiveIn(unsigned Reg, unsigned vreg=0)
addLiveIn - Add the specified register as a live-in.
const Function * FilterOrFinally
Filter or finally function. Null indicates a catch-all.
Implements a dense probed hash-table based set.
void addLandingPadInfo(const LandingPadInst &I, MachineBasicBlock &MBB)
Extract the exception handling information from the landingpad instruction and add them to the specif...
bool hasSubClassEq(const TargetRegisterClass *RC) const
Returns true if RC is a sub-class of or equal to this class.
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.
void print(raw_ostream &OS, const SlotIndexes *=nullptr) const
EK_Inline - Jump table entries are emitted inline at their point of use.
std::string getNodeLabel(const MachineBasicBlock *Node, const MachineFunction *Graph)
bool adjustsStack() const
Return true if this function adjusts the stack – e.g., when calling another function.
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
static SectionKind getMergeableConst8()
static SectionKind getMergeableConst16()
A raw_ostream that writes to an SmallVector or SmallString.
const Function * getParent() const
Return the enclosing method, or null if none.
const Function * getFunction() const
getFunction - Return the LLVM function that this machine code represents
MCSymbol * LandingPadLabel
Manage lifetime of a slot tracker for printing IR.
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.
void DeleteMachineBasicBlock(MachineBasicBlock *MBB)
DeleteMachineBasicBlock - Delete the given MachineBasicBlock.
static SectionKind getMergeableConst4()
bool ReplaceMBBInJumpTable(unsigned Idx, MachineBasicBlock *Old, MachineBasicBlock *New)
ReplaceMBBInJumpTable - If Old is a target of the jump tables, update the jump table to branch to New...
bool isStackRealignable() const
isStackRealignable - This method returns whether the stack can be realigned.
StringRef getName() const
Return a constant reference to the value's name.
MachineJumpTableInfo * getOrCreateJumpTableInfo(unsigned JTEntryKind)
getOrCreateJumpTableInfo - Get the JumpTableInfo for this function, if it does already exist...
unsigned getMaxAlignment() const
Return the alignment in bytes that this function must be aligned to, which is greater than the defaul...
const std::vector< CalleeSavedInfo > & getCalleeSavedInfo() const
Returns a reference to call saved info vector for the current function.
void viewCFG() const
viewCFG - This function is meant for use from the debugger.
JTEntryKind
JTEntryKind - This enum indicates how each entry of the jump table is represented and emitted...
The address of a basic block.
AtomicOrdering getOrdering() const
Return the atomic ordering requirements for this memory operation.
DOTGraphTraits(bool isSimple=false)
void addSEHCleanupHandler(MachineBasicBlock *LandingPad, const Function *Cleanup)
A description of a memory reference used in the backend.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
SmallVector< MCSymbol *, 1 > EndLabels
unsigned getPointerABIAlignment(unsigned AS=0) const
Layout pointer alignment FIXME: The defaults need to be removed once all of the backends/clients are ...
static unsigned clampStackAlignment(bool ShouldClamp, unsigned Align, unsigned StackAlign)
Clamp the alignment if requested and emit a warning.
A Use represents the edge between a Value definition and its users.
SmallVector< SEHHandler, 1 > SEHHandlers
void addCatchTypeInfo(MachineBasicBlock *LandingPad, ArrayRef< const GlobalValue * > TyInfo)
Provide the catch typeinfo for a landing pad.
const TargetRegisterClass * getRegClass(unsigned Reg) const
Return the register class of the specified virtual register.
const MachineFunctionProperties & getProperties() const
Get the function properties.
Constant * getPersonalityFn() const
Get the personality function associated with this function.
void addFilterTypeInfo(MachineBasicBlock *LandingPad, ArrayRef< const GlobalValue * > TyInfo)
Provide the filter typeinfo for a landing pad.
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.
void Deallocate(const void *Ptr, size_t Size)
int CreateFixedSpillStackObject(uint64_t Size, int64_t SPOffset, bool Immutable=false)
Create a spill slot at a fixed location on the stack.
AtomicOrdering
Atomic ordering for LLVM's memory model.
static bool isSimple(Instruction *I)
Context object for machine code objects.
This structure is used to retain landing pad info for the current function.
unsigned getNumRegs() const
Return the number of registers this target has (useful for sizing arrays holding per register informa...
void print(const MachineFunction &MF, raw_ostream &OS) const
Used by the MachineFunction printer to print information about stack objects.
int getObjectIndexBegin() const
Return the minimum frame object index.
unsigned createJumpTableIndex(const std::vector< MachineBasicBlock * > &DestBBs)
createJumpTableIndex - Create a new jump table.
EK_LabelDifference32 - Each entry is the address of the block minus the address of the jump table...
virtual int getExistingMachineCPValue(MachineConstantPool *CP, unsigned Alignment)=0
static std::string getGraphName(const MachineFunction *F)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
EK_BlockAddress - Each entry is a plain address of block, e.g.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
unsigned getNumClauses() const
Get the number of clauses for this landing pad.
static GCRegistry::Add< OcamlGC > B("ocaml","ocaml 3.10-compatible GC")
This class is a data container for one entry in a MachineConstantPool.
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
Printable PrintReg(unsigned Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubRegIdx=0)
Prints virtual and physical registers with or without a TRI instance.
virtual const MCPhysReg * getCalleeSavedRegs(const MachineFunction *MF) const =0
Return a null-terminated list of all of the callee-saved registers on this target.
size_t size() const
size - Get the array size.
MachineBasicBlock * CreateMachineBasicBlock(const BasicBlock *bb=nullptr)
CreateMachineBasicBlock - Allocate a new MachineBasicBlock.
unsigned getTransientStackAlignment() const
getTransientStackAlignment - This method returns the number of bytes to which the stack pointer must ...
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
unsigned estimateStackSize(const MachineFunction &MF) const
Estimate and return the size of the stack frame.
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
bool isMachineConstantPoolEntry() const
isMachineConstantPoolEntry - Return true if the MachineConstantPoolEntry is indeed a target specific ...
static unsigned getFnStackAlignment(const TargetSubtargetInfo *STI, const Function *Fn)
unsigned getEntrySize(const DataLayout &TD) const
getEntrySize - Return the size of each entry in the jump table.
constexpr uint64_t MinAlign(uint64_t A, uint64_t B)
MinAlign - A and B are either alignments or offsets.
unsigned getEntryAlignment(const DataLayout &TD) const
getEntryAlignment - Return the alignment of each entry in the jump table.
EK_GPRel64BlockAddress - Each entry is an address of block, encoded with a relocation as gp-relative...
initializer< Ty > init(const Ty &Val)
unsigned getABIIntegerTypeAlignment(unsigned BitWidth) const
Returns the minimum ABI-required alignment for an integer type of the specified bitwidth.
The landingpad instruction holds all of the information necessary to generate correct exception handl...
MCSymbol * createTempSymbol(bool CanBeUnnamed=true)
Create and return a new assembler temporary symbol with a unique but unspecified name.
EK_Custom32 - Each entry is a 32-bit value that is custom lowered by the TargetLowering::LowerCustomJ...
unsigned const MachineRegisterInfo * MRI
Constant * stripPointerCasts()
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...
The instances of the Type class are immutable: once they are created, they are never changed...
void addSEHCatchHandler(MachineBasicBlock *LandingPad, const Function *Filter, const BlockAddress *RecoverLabel)
static cl::opt< unsigned > AlignAllFunctions("align-all-functions", cl::desc("Force the alignment of all functions."), cl::init(0), cl::Hidden)
SynchronizationScope getSynchScope() const
Return the synchronization scope for this memory operation.
void addPersonality(const Function *Personality)
Provide the personality function for the exception information.
This is an important base class in LLVM.
SmallVector< MCSymbol *, 1 > BeginLabels
LLVM_ATTRIBUTE_RETURNS_NONNULL LLVM_ATTRIBUTE_RETURNS_NOALIAS void * Allocate(size_t Size, size_t Alignment)
Allocate space at the specified alignment.
static bool CanShareConstantPoolEntry(const Constant *A, const Constant *B, const DataLayout &DL)
Test whether the given two constants can be allocated the same constant pool entry.
std::pair< iterator, bool > insert(const ValueT &V)
unsigned getLiveInVirtReg(unsigned PReg) const
getLiveInVirtReg - If PReg is a live-in physical register, return the corresponding live-in physical ...
bool hasPersonalityFn() const
Check whether this function has a personality function.
void viewCFGOnly() const
viewCFGOnly - This function is meant for use from the debugger.
EHPersonality classifyEHPersonality(const Value *Pers)
See if the given exception handling personality function is one that we understand.
virtual ~MachineFunctionInfo()
bool shouldSplitStack() const
Should we be emitting segmented stack stuff for the function.
std::vector< int > TypeIds
void print(raw_ostream &OS) const
Print the MachineFunctionProperties in human-readable form.
static const unsigned End
SectionKind - This is a simple POD value that classifies the properties of a section.
self_iterator getIterator()
const PseudoSourceValue * getPseudoValue() const
void ViewGraph(const GraphType &G, const Twine &Name, bool ShortNames=false, const Twine &Title="", GraphProgram::Name Program=GraphProgram::DOT)
ViewGraph - Emit a dot graph, run 'dot', run gv on the postscript file, then cleanup.
int CreateFixedObject(uint64_t Size, int64_t SPOffset, bool Immutable, bool isAliased=false)
Create a new object at a fixed location on the stack.
bool isCalleeSavedInfoValid() const
Has the callee saved info been calculated yet?
std::vector< MachineBasicBlock * > MBBs
MBBs - The vector of basic blocks from which to create the jump table.
void incorporateFunction(const Function &F)
Incorporate the given function.
void DeleteMachineInstr(MachineInstr *MI)
DeleteMachineInstr - Delete the given MachineInstr.
int CreateSpillStackObject(uint64_t Size, unsigned Alignment)
Create a new statically sized stack object that represents a spill slot, returning a nonnegative iden...
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
MCSubRegIterator enumerates all sub-registers of Reg.
LLVMContext & getContext() const
All values hold a context through their type.
Abstract base class for all machine specific constantpool value subclasses.
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.
virtual bool hasReservedCallFrame(const MachineFunction &MF) const
hasReservedCallFrame - Under normal circumstances, when a frame pointer is not required, we reserve argument space for call sites in the function immediately on entry to the current function.
int64_t getObjectOffset(int ObjectIdx) const
Return the assigned stack offset of the specified object from the incoming stack pointer.
bool isDeadObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a dead object.
void print(raw_ostream &OS) const
print - Used by the MachineFunction printer to print information about constant pool objects...
DOTGraphTraits - Template class that can be specialized to customize how graphs are converted to 'dot...
virtual const TargetFrameLowering * getFrameLowering() const
static IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
Iterator for intrusive lists based on ilist_node.
void print(raw_ostream &OS) const
print - Used by the MachineFunction printer to print information about jump tables.
MCSymbol * getPICBaseSymbol() const
getPICBaseSymbol - Return a function-local symbol to represent the PIC base.
uint64_t getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
bool isFuncletEHPersonality(EHPersonality Pers)
Returns true if this is a personality function that invokes handler funclets (which must return to it...
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.
static const char * Separator
bool ReplaceMBBInJumpTables(MachineBasicBlock *Old, MachineBasicBlock *New)
ReplaceMBBInJumpTables - If Old is the target of any jump tables, update the jump tables to branch to...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
unsigned getObjectAlignment(int ObjectIdx) const
Return the alignment of the specified stack object.
Module.h This file contains the declarations for the Module class.
Type * getType() const
All values are typed, get the type of this value.
int getOffsetOfLocalArea() const
getOffsetOfLocalArea - This method returns the offset of the local area from the stack pointer on ent...
virtual const TargetLowering * getTargetLowering() const
unsigned getMaxCallFrameSize() const
Return the maximum size of a call frame that must be allocated for an outgoing function call...
Information about stack frame layout on the target.
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
static SectionKind getReadOnlyWithRel()
Value * stripPointerCasts()
Strip off pointer casts, all-zero GEPs, and aliases.
livein_iterator livein_begin() const
bool isDefined(bool SetUsed=true) const
isDefined - Check if this symbol is defined (i.e., it has an address).
void clear(AllocatorType &Allocator)
Release all the tracked allocations to the allocator.
static void deleteNode(NodeTy *V)
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
MCSymbol * getJTISymbol(unsigned JTI, MCContext &Ctx, bool isLinkerPrivate=false) const
getJTISymbol - Return the MCSymbol for the specified non-empty jump table.
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.
const Value * getValue() const
Return the base address of the memory access.
MachineJumpTableEntry - One jump table in the jump table info.
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.
static const char * getPropertyName(MachineFunctionProperties::Property Prop)
Representation of each machine instruction.
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
void ensureMaxAlignment(unsigned Align)
Make sure the function is at least Align bytes aligned.
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
size_type count(const ValueT &V) const
Return 1 if the specified key is in the set, 0 otherwise.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
unsigned getMinFunctionAlignment() const
Return the minimum function alignment.
bool isCatch(unsigned Idx) const
Return 'true' if the clause and index Idx is a catch clause.
void print(raw_ostream &OS, const SlotIndexes *=nullptr) const
print - Print out the MachineFunction in a format suitable for debugging to the specified stream...
uint64_t getTypeStoreSize(Type *Ty) const
Returns the maximum number of bytes that may be overwritten by storing the specified type...
bool hasVarSizedObjects() const
This method may be called any time after instruction selection is complete to determine if the stack ...
int CreateStackObject(uint64_t Size, unsigned Alignment, bool isSS, const AllocaInst *Alloca=nullptr)
Create a new statically sized stack object, returning a nonnegative identifier to represent it...
JTEntryKind getEntryKind() const
std::vector< std::pair< unsigned, unsigned > >::const_iterator livein_iterator
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...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool needsRelocation() const
This method classifies the entry according to whether or not it may generate a relocation entry...
A raw_ostream that writes to an std::string.
void dump(const MachineFunction &MF) const
dump - Print the function to stderr.
LandingPadInfo & getOrCreateLandingPadInfo(MachineBasicBlock *LandingPad)
Find or create an LandingPadInfo for the specified MachineBasicBlock.
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
int64_t getOffset() const
For normal values, this is a byte offset added to the base address.
void deallocateOperandArray(OperandCapacity Cap, MachineOperand *Array)
Dellocate an array of MachineOperands and recycle the memory.
bool livein_empty() const
const BlockAddress * RecoverBA
Address of block to recover at. Null for a finally handler.
static const Function * getParent(const Value *V)
BasicBlockListType::iterator iterator
uint64_t getSize() const
Return the size in bytes of the memory reference.
This class implements an extremely fast bulk output stream that can only output to a stream...
void dump() const
dump - Call print(cerr) to be called from the debugger.
DefaultDOTGraphTraits - This class provides the default implementations of all of the DOTGraphTraits ...
Primary interface to the complete machine description for the target machine.
bool isCleanup() const
Return 'true' if this landingpad instruction is a cleanup.
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
StringRef - Represent a constant reference to a string, i.e.
MachineModuleInfo & getMMI() const
EK_GPRel32BlockAddress - Each entry is an address of block, encoded with a relocation as gp-relative...
bool needsStackRealignment(const MachineFunction &MF) const
True if storage within the function requires the stack pointer to be aligned more than the normal cal...
int getObjectIndexEnd() const
Return one past the maximum frame object index.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
union llvm::MachineConstantPoolEntry::@35 Val
The constant itself.
AtomicOrdering getFailureOrdering() const
For cmpxchg atomic operations, return the atomic ordering requirements when store does not occur...
unsigned getPointerSize(unsigned AS=0) const
Layout pointer size FIXME: The defaults need to be removed once all of the backends/clients are updat...
int CreateVariableSizedObject(unsigned Alignment, const AllocaInst *Alloca)
Notify the MachineFrameInfo object that a variable sized object has been created. ...
static GCRegistry::Add< ErlangGC > A("erlang","erlang-compatible garbage collector")
static SectionKind getReadOnly()
MachineInstr::mmo_iterator allocateMemRefsArray(unsigned long Num)
allocateMemRefsArray - Allocate an array to hold MachineMemOperand pointers.
const BasicBlock * getParent() const
unsigned getFnStackAlignment() const
Return the stack alignment for the function.
int64_t getObjectSize(int ObjectIdx) const
Return the size of the specified object.
unsigned getConstantPoolIndex(const Constant *C, unsigned Alignment)
getConstantPoolIndex - Create a new entry in the constant pool or return an existing one...
This class contains meta information specific to a module.
This file describes how to lower LLVM code to machine code.
void dump() const
dump - Call to stderr.
an instruction to allocate memory on the stack
uint64_t getBaseAlignment() const
Return the minimum known alignment in bytes of the base address, without the offset.
void tidyLandingPads(DenseMap< MCSymbol *, uintptr_t > *LPMap=nullptr)
Remap landing pad labels and remove any deleted landing pads.
bool contains(unsigned Reg) const
Return true if the specified register is included in this register class.