Go to the documentation of this file.
41 #include "llvm/Config/llvm-config.h"
73 #include <type_traits>
81 #define DEBUG_TYPE "codegen"
84 "align-all-functions",
85 cl::desc(
"Force the alignment of all functions in log2 format (e.g. 4 "
86 "means align on 16B boundaries)."),
94 case P::FailedISel:
return "FailedISel";
95 case P::IsSSA:
return "IsSSA";
96 case P::Legalized:
return "Legalized";
97 case P::NoPHIs:
return "NoPHIs";
98 case P::NoVRegs:
return "NoVRegs";
99 case P::RegBankSelected:
return "RegBankSelected";
100 case P::Selected:
return "Selected";
101 case P::TracksLiveness:
return "TracksLiveness";
102 case P::TiedOpsRewritten:
return "TiedOpsRewritten";
103 case P::FailsVerification:
return "FailsVerification";
104 case P::TracksDebugUserValues:
return "TracksDebugUserValues";
111 if (!
F.hasFnAttribute(Attribute::SafeStack))
115 dyn_cast_or_null<MDTuple>(
F.getMetadata(LLVMContext::MD_annotation));
117 if (!Existing || Existing->getNumOperands() != 2)
120 auto *MetadataName =
"unsafe-stack-size";
121 if (
auto &
N = Existing->getOperand(0)) {
122 if (cast<MDString>(
N.get())->getString() == MetadataName) {
123 if (
auto &
Op = Existing->getOperand(1)) {
124 auto Val = mdconst::extract<ConstantInt>(
Op)->getZExtValue();
132 void MachineFunction::Delegate::anchor() {}
135 const char *Separator =
"";
139 OS << Separator << getPropertyName(static_cast<Property>(
I));
157 if (
auto MA =
F.getFnStackAlign())
166 FunctionNumber = FunctionNum;
180 void MachineFunction::init() {
217 JumpTableInfo =
nullptr;
230 "Can't create a MachineFunction using a Module with a "
231 "Target-incompatible DataLayout attached\n");
233 PSVManager = std::make_unique<PseudoSourceValueManager>(
getTarget());
238 assert(!MFInfo &&
"MachineFunctionInfo already set");
239 MFInfo =
Target.createMachineFunctionInfo(Allocator, F, &STI);
246 void MachineFunction::clear() {
253 I->Insts.clearAndLeakNodesUnsafely();
254 MBBNumbering.clear();
256 InstructionRecycler.clear(Allocator);
257 OperandRecycler.
clear(Allocator);
258 BasicBlockRecycler.clear(Allocator);
259 CodeViewAnnotations.clear();
262 RegInfo->~MachineRegisterInfo();
270 FrameInfo->~MachineFrameInfo();
277 JumpTableInfo->~MachineJumpTableInfo();
282 WinEHInfo->~WinEHFuncInfo();
287 WasmEHInfo->~WasmEHFuncInfo();
300 if (JumpTableInfo)
return JumpTableInfo;
302 JumpTableInfo =
new (Allocator)
304 return JumpTableInfo;
316 [[nodiscard]]
unsigned
318 FrameInstructions.push_back(Inst);
319 return FrameInstructions.size() - 1;
327 if (
empty()) { MBBNumbering.clear();
return; }
335 unsigned BlockNo = 0;
337 BlockNo = std::prev(
MBBI)->getNumber() + 1;
344 "MBB number mismatch!");
349 if (MBBNumbering[BlockNo])
350 MBBNumbering[BlockNo]->setNumber(-1);
352 MBBNumbering[BlockNo] = &*
MBBI;
359 assert(BlockNo <= MBBNumbering.size() &&
"Mismatch!");
360 MBBNumbering.resize(BlockNo);
373 std::prev(
MBBI)->setIsEndSection();
383 return new (InstructionRecycler.Allocate<
MachineInstr>(Allocator))
391 return new (InstructionRecycler.Allocate<
MachineInstr>(Allocator))
403 if (FirstClone ==
nullptr) {
409 if (!
I->isBundledWithSucc())
430 assert((!
MI->isCandidateForCallSiteEntry() ||
431 CallSitesInfo.
find(
MI) == CallSitesInfo.
end()) &&
432 "Call site info was not updated!");
440 InstructionRecycler.Deallocate(Allocator,
MI);
465 MBB->~MachineBasicBlock();
466 BasicBlockRecycler.Deallocate(Allocator,
MBB);
474 return new (Allocator)
476 SSID, Ordering, FailureOrdering);
484 return new (Allocator)
486 Ordering, FailureOrdering);
491 return new (Allocator)
499 return new (Allocator)
550 return MachineInstr::ExtraInfo::create(Allocator, MMOs, PreInstrSymbol,
551 PostInstrSymbol, HeapAllocMarker,
552 PCSections, CFIType);
556 char *Dest = Allocator.
Allocate<
char>(Name.size() + 1);
558 Dest[Name.size()] = 0;
566 memset(
Mask, 0, Size *
sizeof(
Mask[0]));
573 return {AllocMask,
Mask.size()};
576 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
587 OS <<
"# Machine code for function " <<
getName() <<
": ";
592 FrameInfo->
print(*
this, OS);
596 JumpTableInfo->
print(OS);
604 OS <<
"Function Live Ins: ";
610 if (std::next(
I) !=
E)
618 for (
const auto &
BB : *
this) {
621 BB.print(OS, MST, Indexes,
true);
624 OS <<
"\n# End machine code for function " <<
getName() <<
".\n\n";
641 return (
"CFG for '" +
F->getName() +
"' function").str();
653 OSS <<
": " <<
BB->getName();
658 if (OutStr[0] ==
'\n') OutStr.erase(OutStr.begin());
661 for (
unsigned i = 0;
i != OutStr.length(); ++
i)
662 if (OutStr[
i] ==
'\n') {
664 OutStr.insert(OutStr.begin()+
i+1,
'l');
677 errs() <<
"MachineFunction::viewCFG is only available in debug builds on "
678 <<
"systems with Graphviz or gv!\n";
687 errs() <<
"MachineFunction::viewCFGOnly is only available in debug builds on "
688 <<
"systems with Graphviz or gv!\n";
708 "Register class mismatch!");
720 bool isLinkerPrivate)
const {
722 assert(JumpTableInfo &&
"No jump tables");
723 assert(JTI < JumpTableInfo->getJumpTables().
size() &&
"Invalid JTI!");
726 :
DL.getPrivateGlobalPrefix();
745 unsigned N = LandingPads.size();
746 for (
unsigned i = 0;
i <
N; ++
i) {
753 return LandingPads[
N];
769 if (
const auto *LPI = dyn_cast<LandingPadInst>(FirstI)) {
772 if (LPI->isCleanup() && LPI->getNumClauses() != 0)
778 for (
unsigned I = LPI->getNumClauses();
I != 0; --
I) {
779 Value *Val = LPI->getClause(
I - 1);
780 if (LPI->isCatch(
I - 1)) {
785 auto *CVal = cast<Constant>(Val);
787 for (
const Use &U : CVal->operands())
788 FilterList.push_back(
789 getTypeIDFor(cast<GlobalValue>(U->stripPointerCasts())));
795 }
else if (
const auto *CPI = dyn_cast<CatchPadInst>(FirstI)) {
796 for (
unsigned I = CPI->arg_size();
I != 0; --
I) {
798 dyn_cast<GlobalValue>(CPI->getArgOperand(
I - 1)->stripPointerCasts());
803 assert(isa<CleanupPadInst>(FirstI) &&
"Invalid landingpad!");
806 return LandingPadLabel;
811 LPadToCallSiteMap[Sym].append(Sites.
begin(), Sites.
end());
815 for (
unsigned i = 0,
N = TypeInfos.size();
i !=
N; ++
i)
816 if (TypeInfos[
i] == TI)
return i + 1;
818 TypeInfos.push_back(TI);
819 return TypeInfos.size();
826 for (
unsigned i : FilterEnds) {
827 unsigned j = TyIds.
size();
830 if (FilterIds[--
i] != TyIds[--
j])
841 int FilterID = -(1 + FilterIds.size());
842 FilterIds.reserve(FilterIds.size() + TyIds.
size() + 1);
844 FilterEnds.push_back(FilterIds.size());
845 FilterIds.push_back(0);
851 assert(
MI->isCandidateForCallSiteEntry() &&
852 "Call site info refers only to call (MI) candidates");
854 if (!
Target.Options.EmitCallSiteInfo)
855 return CallSitesInfo.
end();
856 return CallSitesInfo.
find(
MI);
866 if (BMI.isCandidateForCallSiteEntry())
873 assert(
MI->shouldUpdateCallSiteInfo() &&
874 "Call site info refers only to call (MI) candidates or "
875 "candidates inside bundles");
879 if (CSIt == CallSitesInfo.
end())
881 CallSitesInfo.
erase(CSIt);
887 "Call site info refers only to call (MI) candidates or "
888 "candidates inside bundles");
890 if (!New->isCandidateForCallSiteEntry())
895 if (CSIt == CallSitesInfo.
end())
899 CallSitesInfo[New] = CSInfo;
905 "Call site info refers only to call (MI) candidates or "
906 "candidates inside bundles");
908 if (!New->isCandidateForCallSiteEntry())
913 if (CSIt == CallSitesInfo.
end())
917 CallSitesInfo.
erase(CSIt);
918 CallSitesInfo[New] = CSInfo;
938 unsigned MaxOperand) {
950 for (
unsigned int I = 0;
I < MaxOperand; ++
I) {
952 auto &NewMO = New.getOperand(
I);
955 if (!OldMO.isReg() || !OldMO.isDef())
959 unsigned NewInstrNum = New.getDebugInstrNum();
961 std::make_pair(NewInstrNum,
I));
973 if (
auto CopyDstSrc =
TII.isCopyInstr(
MI)) {
974 Dest = CopyDstSrc->Destination->getReg();
977 Dest =
MI.getOperand(0).getReg();
980 auto CacheIt = DbgPHICache.find(Dest);
981 if (CacheIt != DbgPHICache.end())
982 return CacheIt->second;
985 auto OperandPair = salvageCopySSAImpl(
MI);
986 DbgPHICache.insert({Dest, OperandPair});
1012 auto GetRegAndSubreg =
1013 [&](
const MachineInstr &Cpy) -> std::pair<Register, unsigned> {
1017 OldReg = Cpy.getOperand(0).getReg();
1018 NewReg = Cpy.getOperand(1).getReg();
1019 SubReg = Cpy.getOperand(1).getSubReg();
1020 }
else if (Cpy.isSubregToReg()) {
1021 OldReg = Cpy.getOperand(0).getReg();
1022 NewReg = Cpy.getOperand(2).getReg();
1023 SubReg = Cpy.getOperand(3).getImm();
1025 auto CopyDetails = *
TII.isCopyInstr(Cpy);
1029 NewReg = Src.getReg();
1030 SubReg = Src.getSubReg();
1040 auto State = GetRegAndSubreg(
MI);
1041 auto CurInst =
MI.getIterator();
1045 if (!State.first.isVirtual())
1050 SubregsSeen.push_back(State.second);
1059 State = GetRegAndSubreg(Inst);
1066 auto ApplySubregisters =
1068 for (
unsigned Subreg :
reverse(SubregsSeen)) {
1070 unsigned NewInstrNumber = getNewDebugInstrNum();
1073 makeDebugValueSubstitution({NewInstrNumber, 0},
P, Subreg);
1076 P = {NewInstrNumber, 0};
1083 if (State.first.isVirtual()) {
1086 for (
auto &MO : Inst->
operands()) {
1087 if (!MO.isReg() || !MO.isDef() || MO.getReg() != State.first)
1089 return ApplySubregisters(
1098 assert(CurInst->isCopyLike() ||
TII.isCopyInstr(*CurInst));
1099 State = GetRegAndSubreg(*CurInst);
1102 auto RMII = CurInst->getReverseIterator();
1103 auto PrevInstrs =
make_range(RMII, CurInst->getParent()->instr_rend());
1104 for (
auto &ToExamine : PrevInstrs) {
1105 for (
auto &MO : ToExamine.operands()) {
1107 if (!MO.isReg() || !MO.isDef() ||
1111 return ApplySubregisters(
1112 {ToExamine.getDebugInstrNum(), ToExamine.getOperandNo(&MO)});
1129 TII.get(TargetOpcode::DBG_PHI));
1131 unsigned NewNum = getNewDebugInstrNum();
1133 return ApplySubregisters({NewNum, 0u});
1140 const MCInstrDesc &RefII =
TII->get(TargetOpcode::DBG_VALUE_LIST);
1142 MI.setDebugValueUndef();
1146 for (
auto &
MBB : *
this) {
1147 for (
auto &
MI :
MBB) {
1148 if (!
MI.isDebugRef())
1151 bool IsValidRef =
true;
1175 MO.ChangeToDbgInstrRef(Result.first, Result.second);
1178 unsigned OperandIdx = 0;
1179 for (
const auto &DefMO :
DefMI.operands()) {
1180 if (DefMO.isReg() && DefMO.isDef() && DefMO.getReg() ==
Reg)
1187 unsigned ID =
DefMI.getDebugInstrNum();
1188 MO.ChangeToDbgInstrRef(
ID, OperandIdx);
1193 MakeUndefDbgValue(
MI);
1207 if (
F.hasFnAttribute(Attribute::OptimizeNone))
1274 const std::vector<MachineBasicBlock*> &DestBBs) {
1275 assert(!DestBBs.empty() &&
"Cannot create an empty jump table!");
1277 return JumpTables.size()-1;
1284 assert(Old != New &&
"Not making a change?");
1285 bool MadeChange =
false;
1286 for (
size_t i = 0,
e = JumpTables.size();
i !=
e; ++
i)
1293 bool MadeChange =
false;
1295 auto removeBeginItr =
std::remove(JTE.MBBs.begin(), JTE.MBBs.end(),
MBB);
1296 MadeChange |= (removeBeginItr != JTE.MBBs.end());
1297 JTE.MBBs.erase(removeBeginItr, JTE.MBBs.end());
1307 assert(Old != New &&
"Not making a change?");
1308 bool MadeChange =
false;
1319 if (JumpTables.empty())
return;
1321 OS <<
"Jump Tables:\n";
1323 for (
unsigned i = 0,
e = JumpTables.size();
i !=
e; ++
i) {
1334 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1346 void MachineConstantPoolValue::anchor() {}
1349 return DL.getTypeAllocSize(Ty);
1354 return Val.MachineCPVal->getSizeInBytes(
DL);
1355 return DL.getTypeAllocSize(
Val.ConstVal->getType());
1361 return Val.ConstVal->needsDynamicRelocation();
1387 if (
C.isMachineConstantPoolEntry()) {
1388 Deleted.insert(
C.Val.MachineCPVal);
1389 delete C.Val.MachineCPVal;
1402 if (
A ==
B)
return true;
1406 if (
A->getType() ==
B->getType())
return false;
1409 if (isa<StructType>(
A->getType()) || isa<ArrayType>(
A->getType()) ||
1410 isa<StructType>(
B->getType()) || isa<ArrayType>(
B->getType()))
1414 uint64_t StoreSize =
DL.getTypeStoreSize(
A->getType());
1415 if (StoreSize !=
DL.getTypeStoreSize(
B->getType()) || StoreSize > 128)
1424 if (isa<PointerType>(
A->getType()))
1427 else if (
A->getType() != IntTy)
1430 if (isa<PointerType>(
B->getType()))
1433 else if (
B->getType() != IntTy)
1444 if (Alignment > PoolAlignment) PoolAlignment = Alignment;
1450 if (!
Constants[
i].isMachineConstantPoolEntry() &&
1463 if (Alignment > PoolAlignment) PoolAlignment = Alignment;
1470 MachineCPVsSharingEntries.insert(V);
1471 return (
unsigned)Idx;
1481 OS <<
"Constant Pool:\n";
1483 OS <<
" cp#" <<
i <<
": ";
1484 if (
Constants[
i].isMachineConstantPoolEntry())
1487 Constants[
i].Val.ConstVal->printAsOperand(OS,
false);
1488 OS <<
", align=" <<
Constants[
i].getAlign().value();
1493 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void addLiveIn(MCRegister Reg, Register vreg=Register())
addLiveIn - Add the specified register as a live-in.
void setBBID(unsigned V)
Sets the fixed BBID of this basic block.
std::string getNodeLabel(const MachineBasicBlock *Node, const MachineFunction *Graph)
unsigned getDebugInstrNum()
Fetch the instruction number of this MachineInstr.
static SectionKind getReadOnlyWithRel()
unsigned getOperandNo(const_mop_iterator I) const
Returns the number of the operand iterator I points to.
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
bool isNull() const
Test if the pointer held in the union is null, regardless of which type it is.
def_iterator def_begin(Register RegNo) const
unsigned getConstantPoolIndex(const Constant *C, Align Alignment)
getConstantPoolIndex - Create a new entry in the constant pool or return an existing one.
This is an optimization pass for GlobalISel generic memory operations.
bool RemoveMBBFromJumpTables(MachineBasicBlock *MBB)
RemoveMBBFromJumpTables - If MBB is present in any jump tables, remove it.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
unsigned createJumpTableIndex(const std::vector< MachineBasicBlock * > &DestBBs)
createJumpTableIndex - Create a new jump table.
A parsed version of the target data layout string in and methods for querying it.
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
std::pair< unsigned, unsigned > DebugInstrOperandPair
Pair of instruction number and operand number.
uint32_t * allocateRegMask()
Allocate and initialize a register mask with NumRegister bits.
void print(raw_ostream &OS) const
Print the MachineFunctionProperties in human-readable form.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Context object for machine code objects.
MCContext & getContext() const
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
virtual const TargetInstrInfo * getInstrInfo() const
union llvm::MachineConstantPoolEntry::@191 Val
The constant itself.
void assignBeginEndSections()
Assign IsBeginSection IsEndSection fields for basic blocks in this function.
A raw_ostream that writes to an std::string.
Target - Wrapper for Target specific information.
def_instr_iterator def_instr_begin(Register RegNo) const
MaybeAlign getFnStackAlign() const
Return the stack alignment for the function.
bool useDebugInstrRef() const
Returns true if the function's variable locations are tracked with instruction referencing.
static cl::opt< unsigned > AlignAllFunctions("align-all-functions", cl::desc("Force the alignment of all functions in log2 format (e.g. 4 " "means align on 16B boundaries)."), cl::init(0), cl::Hidden)
Align getPrefFunctionAlignment() const
Return the preferred function alignment.
MCSymbol * LandingPadLabel
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags f, uint64_t s, Align base_alignment, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr, SyncScope::ID SSID=SyncScope::System, AtomicOrdering Ordering=AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering=AtomicOrdering::NotAtomic)
getMachineMemOperand - Allocate a new MachineMemOperand.
int64_t getOffset() const
For normal values, this is a byte offset added to the base address.
Printable printMBBReference(const MachineBasicBlock &MBB)
Prints a machine basic block reference.
bool livein_empty() const
void copyCallSiteInfo(const MachineInstr *Old, const MachineInstr *New)
Copy the call site info from Old to \ New.
unsigned getNumRegs() const
Return the number of registers this target has (useful for sizing arrays holding per register informa...
Reg
All possible values of the reg field in the ModR/M byte.
const TargetRegisterInfo * getTargetRegisterInfo() const
MachineJumpTableInfo * getOrCreateJumpTableInfo(unsigned JTEntryKind)
getOrCreateJumpTableInfo - Get the JumpTableInfo for this function, if it does already exist,...
unsigned getFunctionNumber() const
getFunctionNumber - Return a unique ID for the current function.
int getFilterIDFor(ArrayRef< unsigned > TyIds)
Return the id of the filter encoded by TyIds. This is function wide.
void bundleWithPred()
Bundle this instruction with its predecessor.
const MachineBasicBlock & back() const
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
bool erase(const KeyT &Val)
bool hasDebugInfo() const
Returns true if valid debug info is present.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
void moveCallSiteInfo(const MachineInstr *Old, const MachineInstr *New)
Move the call site info from Old to \New call site info.
Abstract base class for all machine specific constantpool value subclasses.
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
MachineInstr * CreateMachineInstr(const MCInstrDesc &MCID, DebugLoc DL, bool NoImplicit=false)
CreateMachineInstr - Allocate a new MachineInstr.
virtual void MF_HandleRemoval(MachineInstr &MI)=0
Callback before a removal. This should not modify the MI directly.
The instances of the Type class are immutable: once they are created, they are never changed.
static SectionKind getMergeableConst16()
A description of a memory reference used in the backend.
Register getLiveInVirtReg(MCRegister PReg) const
getLiveInVirtReg - If PReg is a live-in physical register, return the corresponding live-in virtual r...
OutputIt copy(R &&Range, OutputIt Out)
void setCallSiteLandingPad(MCSymbol *Sym, ArrayRef< unsigned > Sites)
Map the landing pad's EH symbol to the call site indexes.
@ EK_BlockAddress
EK_BlockAddress - Each entry is a plain address of block, e.g.
unsigned peekDebugInstrNum() const
Examine the instruction number of this MachineInstr.
Expected< ExpressionValue > max(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
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.
void incorporateFunction(const Function &F)
Incorporate the given function.
MCSymbol * getJTISymbol(unsigned JTI, MCContext &Ctx, bool isLinkerPrivate=false) const
getJTISymbol - Return the MCSymbol for the specified non-empty jump table.
MachineInstr & cloneMachineInstrBundle(MachineBasicBlock &MBB, MachineBasicBlock::iterator InsertBefore, const MachineInstr &Orig)
Clones instruction or the whole instruction bundle Orig and insert into MBB before InsertBefore.
AAMDNodes getAAInfo() const
Return the AA tags for the memory reference.
@ EK_Custom32
EK_Custom32 - Each entry is a 32-bit value that is custom lowered by the TargetLowering::LowerCustomJ...
Manage lifetime of a slot tracker for printing IR.
unsigned const TargetRegisterInfo * TRI
Align commonAlignment(Align A, uint64_t Offset)
Returns the alignment that satisfies both alignments.
static const char * getPropertyName(MachineFunctionProperties::Property Prop)
BasicBlockListType::iterator iterator
iterator erase(iterator where)
LLVM Basic Block Representation.
unsigned getEntrySize(const DataLayout &TD) const
getEntrySize - Return the size of each entry in the jump table.
MachineBasicBlock::instr_iterator getBundleEnd(MachineBasicBlock::instr_iterator I)
Returns an iterator pointing beyond the bundle containing I.
bool ReplaceMBBInJumpTables(MachineBasicBlock *Old, MachineBasicBlock *New)
ReplaceMBBInJumpTables - If Old is the target of any jump tables, update the jump tables to branch to...
JTEntryKind getEntryKind() const
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void dump() const
dump - Call to stderr.
EHPersonality classifyEHPersonality(const Value *Pers)
See if the given exception handling personality function is one that we understand.
static SectionKind getReadOnly()
const MachinePointerInfo & getPointerInfo() const
constexpr std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
void substituteDebugValuesForInst(const MachineInstr &Old, MachineInstr &New, unsigned MaxOperand=UINT_MAX)
Create substitutions for any tracked values in Old, to point at New.
bool contains(Register Reg) const
Return true if the specified register is included in this register class.
< i1 > br i1 label label bb bb
MachineInstr::ExtraInfo * createMIExtraInfo(ArrayRef< MachineMemOperand * > MMOs, MCSymbol *PreInstrSymbol=nullptr, MCSymbol *PostInstrSymbol=nullptr, MDNode *HeapAllocMarker=nullptr, MDNode *PCSections=nullptr, uint32_t CFIType=0)
Allocate and construct an extra info structure for a MachineInstr.
const MachineBasicBlock & front() const
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
TargetInstrInfo - Interface to description of machine instruction set.
Align getBaseAlign() const
Return the minimum known alignment in bytes of the base address, without the offset.
SmallVector< MCSymbol *, 1 > EndLabels
Itanium Name Demangler i e convert the string _Z1fv into f()". You can also use the CRTP base ManglingParser to perform some simple analysis on the mangled name
void ensureMaxAlignment(Align Alignment)
Make sure the function is at least Align bytes aligned.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static unsigned getRegMaskSize(unsigned NumRegs)
Returns number of elements needed for a regmask array.
Constant * ConstantFoldCastOperand(unsigned Opcode, Constant *C, Type *DestTy, const DataLayout &DL)
Attempt to constant fold a cast with the specified operand.
const Value * getValue() const
Return the base address of the memory access.
Align getStackAlign() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
(vector float) vec_cmpeq(*A, *B) C
const MachineOperand & getOperand(unsigned i) const
DenormalMode getDenormalMode(const fltSemantics &FPType) const
Returns the denormal handling type for the default rounding mode of the function.
unsigned ForceDwarfFrameSection
Emit DWARF debug frame section.
bool UseDebugInstrRef
Flag for whether this function contains DBG_VALUEs (false) or DBG_INSTR_REF (true).
Align getMinFunctionAlignment() const
Return the minimum function alignment.
Align getABIIntegerTypeAlignment(unsigned BitWidth) const
Returns the minimum ABI-required alignment for an integer type of the specified bitwidth.
std::vector< MachineBasicBlock * > MBBs
MBBs - The vector of basic blocks from which to create the jump table.
void print(const MachineFunction &MF, raw_ostream &OS) const
Used by the MachineFunction printer to print information about stack objects.
virtual ~MachineFunctionInfo()
void deleteMachineInstr(MachineInstr *MI)
DeleteMachineInstr - Delete the given MachineInstr.
const MachineFunctionProperties & getProperties() const
Get the function properties.
std::vector< int > TypeIds
const HexagonInstrInfo * TII
void setDebugInstrNumberingCount(unsigned Num)
Set value of DebugInstrNumberingCount field.
SectionKind getSectionKind(const DataLayout *DL) const
void deleteMachineBasicBlock(MachineBasicBlock *MBB)
DeleteMachineBasicBlock - Delete the given MachineBasicBlock.
unsigned getTypeIDFor(const GlobalValue *TI)
Return the type id for the specified typeinfo. This is function wide.
Describe properties that are true of each instruction in the target description file.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
MachineOperand class - Representation of each machine instruction operand.
MachineFunctionProperties & set(Property P)
This class contains meta information specific to a module.
bool shouldUpdateCallSiteInfo() const
Return true if copying, moving, or erasing this instruction requires updating Call Site Info (see cop...
bool isStackRealignable() const
isStackRealignable - This method returns whether the stack can be realigned.
void viewCFG() const
viewCFG - This function is meant for use from the debugger.
This class implements an extremely fast bulk output stream that can only output to a stream.
bool hasPersonalityFn() const
Check whether this function has a personality function.
bool shouldSplitStack() const
Should we be emitting segmented stack stuff for the function.
Printable printJumpTableEntryReference(unsigned Idx)
Prints a jump table entry reference.
livein_iterator livein_begin() const
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.
const Instruction * getFirstNonPHI() const
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
This struct is a compact representation of a valid (non-zero power of two) alignment.
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID for this memory operation.
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...
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
static const MachineInstr * getCallInstr(const MachineInstr *MI)
Return the call machine instruction or find a call within bundle.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
void viewCFGOnly() const
viewCFGOnly - This function is meant for use from the debugger.
@ EK_LabelDifference32
EK_LabelDifference32 - Each entry is the address of the block minus the address of the jump table.
DOTGraphTraits - Template class that can be specialized to customize how graphs are converted to 'dot...
const TargetRegisterClass * getRegClass(Register Reg) const
Return the register class of the specified virtual register.
static std::string getGraphName(const MachineFunction *F)
MachineModuleInfo & getMMI() const
void deallocateOperandArray(OperandCapacity Cap, MachineOperand *Array)
Dellocate an array of MachineOperands and recycle the memory.
Implements a dense probed hash-table based set.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
AtomicOrdering
Atomic ordering for LLVM's memory model.
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
@ EK_GPRel64BlockAddress
EK_GPRel64BlockAddress - Each entry is an address of block, encoded with a relocation as gp-relative,...
This is an important base class in LLVM.
bool regsOverlap(Register RegA, Register RegB) const
Returns true if the two registers are equal or alias each other.
virtual unsigned getSizeInBytes(const DataLayout &DL) const
SmallVector< MCSymbol *, 1 > BeginLabels
Representation of each machine instruction.
Module * getParent()
Get the module that this global value is contained inside of...
MachineInstr * CloneMachineInstr(const MachineInstr *Orig)
Create a new MachineInstr which is a copy of Orig, identical in all ways except the instruction has n...
multiplies can be turned into SHL s
bool debuginfoShouldUseDebugInstrRef(const Triple &T)
This class contains a discriminated union of information about pointers in memory operands,...
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
The MachineConstantPool class keeps track of constants referenced by a function which must be spilled...
void dump() const
dump - Print the current MachineFunction to cerr, useful for debugger use.
bool isScopedEHPersonality(EHPersonality Pers)
Returns true if this personality uses scope-style EH IR instructions: catchswitch,...
Represent subnormal handling kind for floating point instruction inputs and outputs.
initializer< Ty > init(const Ty &Val)
iterator getFirstNonPHI()
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
JTEntryKind
JTEntryKind - This enum indicates how each entry of the jump table is represented and emitted.
MachineBasicBlock * CreateMachineBasicBlock(const BasicBlock *bb=nullptr)
CreateMachineBasicBlock - Allocate a new MachineBasicBlock.
void finalizeDebugInstrRefs()
Finalise any partially emitted debug instructions.
void setUseDebugInstrRef(bool UseInstrRef)
Set whether this function will use instruction referencing or not.
void setIsEndSection(bool V=true)
iterator find(const_arg_type_t< KeyT > Val)
Flags
Flags values. These may be or'd together.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool isMachineConstantPoolEntry() const
isMachineConstantPoolEntry - Return true if the MachineConstantPoolEntry is indeed a target specific ...
MachineBasicBlock * LandingPadBlock
Align getPointerABIAlignment(unsigned AS) const
Layout pointer alignment.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
AtomicOrdering getSuccessOrdering() const
Return the atomic ordering requirements for this memory operation.
void makeDebugValueSubstitution(DebugInstrOperandPair, DebugInstrOperandPair, unsigned SubReg=0)
Create a substitution between one <instr,operand> value to a different, new value.
Register getReg() const
getReg - Returns the register number.
bool hasOneDef(Register RegNo) const
Return true if there is exactly one operand defining the specified register.
MachinePointerInfo getWithOffset(int64_t O) const
void clear(AllocatorType &Allocator)
Release all the tracked allocations to the allocator.
bool needsRelocation() const
This method classifies the entry according to whether or not it may generate a relocation entry.
Register addLiveIn(MCRegister PReg, const TargetRegisterClass *RC)
addLiveIn - Add the specified physical register as a live-in value and create a corresponding virtual...
std::error_code remove(const Twine &path, bool IgnoreNonExisting=true)
Remove path.
void initTargetMachineFunctionInfo(const TargetSubtargetInfo &STI)
Initialize the target specific MachineFunctionInfo.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
PointerUnion< const Value *, const PseudoSourceValue * > V
This is the IR pointer value for the access, or it is null if unknown.
Expected< ExpressionValue > min(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
ArrayRef< int > allocateShuffleMask(ArrayRef< int > Mask)
StringRef - Represent a constant reference to a string, i.e.
MachineBasicBlock MachineBasicBlock::iterator MBBI
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static const Function * getParent(const Value *V)
MachineBasicBlock::instr_iterator getBundleStart(MachineBasicBlock::instr_iterator I)
Returns an iterator to the first instruction in the bundle containing I.
void append_range(Container &C, Range &&R)
Wrapper function to append a range to a container.
self_iterator getIterator()
void print(raw_ostream &OS) const
print - Used by the MachineFunction printer to print information about jump tables.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
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...
MachineFunctionProperties & reset(Property P)
void setUnsafeStackSize(const Function &F, MachineFrameInfo &FrameInfo)
StringRef getName() const
Return a constant reference to the value's name.
MCSymbol * createTempSymbol()
Create a temporary symbol with a unique name.
TargetSubtargetInfo - Generic base class for all target subtargets.
MBBSectionID getSectionID() const
Returns the section ID of this basic block.
unsigned DebugInstrNumberingCount
A count of how many instructions in the function have had numbers assigned to them.
DenormalMode getDenormalMode(const fltSemantics &FPType) const
Returns the denormal handling type for the default rounding mode of the function.
unsigned const MachineRegisterInfo * MRI
const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
Wrapper class representing virtual and physical registers.
unsigned addFrameInst(const MCCFIInstruction &Inst)
static Align getFnStackAlignment(const TargetSubtargetInfo *STI, const Function &F)
static SectionKind getMergeableConst8()
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
SectionKind - This is a simple POD value that classifies the properties of a section.
This class is a data container for one entry in a MachineConstantPool.
Function & getFunction()
Return the LLVM function that this machine code represents.
virtual const TargetFrameLowering * getFrameLowering() const
bool needsFrameMoves() const
True if this function needs frame moves for debug or exceptions.
bool isCopyLike() const
Return true if the instruction behaves like a copy.
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
Iterator for intrusive lists based on ilist_node.
uint64_t value() const
This is a hole in the type system and should not be abused.
uint64_t getSize() const
Return the size in bytes of the memory reference.
@ EK_Inline
EK_Inline - Jump table entries are emitted inline at their point of use.
LLVM_ATTRIBUTE_RETURNS_NONNULL void * Allocate(size_t Size, Align Alignment)
Allocate space at the specified alignment.
void setIsBeginSection(bool V=true)
std::vector< std::pair< MCRegister, Register > >::const_iterator livein_iterator
void print(raw_ostream &OS, const SlotIndexes *=nullptr) const
print - Print out the MachineFunction in a format suitable for debugging to the specified stream.
MachineJumpTableEntry - One jump table in the jump table info.
bool needsUnwindTableEntry() const
True if this function needs an unwind table.
This class describes a target machine that is implemented with the LLVM target-independent code gener...
MachineFunction(Function &F, const LLVMTargetMachine &Target, const TargetSubtargetInfo &STI, unsigned FunctionNum, MachineModuleInfo &MMI)
static bool isSimple(Instruction *I)
Constant * getPersonalityFn() const
Get the personality function associated with this function.
void print(raw_ostream &OS) const
print - Used by the MachineFunction printer to print information about constant pool objects.
bool getAlign(const Function &F, unsigned index, unsigned &align)
MCSymbol * getPICBaseSymbol() const
getPICBaseSymbol - Return a function-local symbol to represent the PIC base.
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
virtual const TargetLowering * getTargetLowering() const
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
static void deleteNode(NodeTy *V)
virtual int getExistingMachineCPValue(MachineConstantPool *CP, Align Alignment)=0
Simple wrapper around std::function<void(raw_ostream&)>.
void setUnsafeStackSize(uint64_t Size)
static SectionKind getMergeableConst4()
MachineInstrBuilder MachineInstrBuilder & DefMI
SmallVector< DebugSubstitution, 8 > DebugValueSubstitutions
Debug value substitutions: a collection of DebugSubstitution objects, recording changes in where a va...
unsigned getNumOperands() const
Retuns the total number of operands.
size_t size() const
size - Get the array size.
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
A raw_ostream that writes to an SmallVector or SmallString.
@ EK_GPRel32BlockAddress
EK_GPRel32BlockAddress - Each entry is an address of block, encoded with a relocation as gp-relative,...
DefaultDOTGraphTraits - This class provides the default implementations of all of the DOTGraphTraits ...
auto reverse(ContainerTy &&C)
AtomicOrdering getFailureOrdering() const
For cmpxchg atomic operations, return the atomic ordering requirements when store does not occur.
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
This structure is used to retain landing pad info for the current function.
bool shouldUseDebugInstrRef() const
Determine whether, in the current machine configuration, we should use instruction referencing or not...
static IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
bool hasSubClassEq(const TargetRegisterClass *RC) const
Returns true if RC is a sub-class of or equal to this class.
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
const char * createExternalSymbolName(StringRef Name)
Allocate a string and populate it with the given external symbol name.
unsigned getEntryAlignment(const DataLayout &TD) const
getEntryAlignment - Return the alignment of each entry in the jump table.
const static unsigned int DebugOperandMemNumber
A reserved operand number representing the instructions memory operand, for instructions that have a ...
DebugInstrOperandPair salvageCopySSA(MachineInstr &MI, DenseMap< Register, DebugInstrOperandPair > &DbgPHICache)
Find the underlying defining instruction / operand for a COPY instruction while in SSA form.
MCSymbol * addLandingPad(MachineBasicBlock *LandingPad)
Add a new panding pad, and extract the exception handling information from the landingpad instruction...
static SectionKind getMergeableConst32()
const MDNode * getRanges() const
Return the range tag for the memory reference.
void dump() const
dump - Call print(cerr) to be called from the debugger.
Printable printReg(Register Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubIdx=0, const MachineRegisterInfo *MRI=nullptr)
Prints virtual and physical registers with or without a TRI instance.
void eraseCallSiteInfo(const MachineInstr *MI)
Following functions update call site info.
VariableDbgInfoMapTy VariableDbgInfos
livein_iterator livein_end() const
DOTGraphTraits(bool isSimple=false)
iterator_range< mop_iterator > operands()
LLVM Value Representation.
Flags getFlags() const
Return the raw flags of the source value,.
void Deallocate(const void *Ptr, size_t Size, size_t)
void RenumberBlocks(MachineBasicBlock *MBBFrom=nullptr)
RenumberBlocks - This discards all of the MachineBasicBlock numbers and recomputes them.
LandingPadInfo & getOrCreateLandingPadInfo(MachineBasicBlock *LandingPad)
Find or create an LandingPadInfo for the specified MachineBasicBlock.
DebugInstrOperandPair salvageCopySSAImpl(MachineInstr &MI)
bool isFuncletEHPersonality(EHPersonality Pers)
Returns true if this is a personality function that invokes handler funclets (which must return to it...
unsigned getPointerSize(unsigned AS=0) const
Layout pointer size in bytes, rounded up to a whole number of bytes.
unsigned getSizeInBytes(const DataLayout &DL) const
A Use represents the edge between a Value definition and its users.
Wrapper class representing physical registers. Should be passed by value.
const PseudoSourceValue * getPseudoValue() const
virtual void MF_HandleInsertion(MachineInstr &MI)=0
Callback after an insertion. This should not modify the MI directly.