128 using namespace llvm;
130 #define DEBUG_TYPE "asm-printer" 142 "CodeView Line Tables";
144 STATISTIC(EmittedInsts,
"Number of machine instrs printed");
148 cl::desc(
"Print 'sched: [latency:throughput]' in .s output"));
150 char AsmPrinter::ID = 0;
164 unsigned InBits = 0) {
165 unsigned NumBits = 0;
170 if (InBits > NumBits)
188 OutContext(Streamer->getContext()), OutStreamer(
std::move(Streamer)) {
193 assert(!DD &&
Handlers.empty() &&
"Debug/EH info didn't get finalized");
195 if (GCMetadataPrinters) {
199 GCMetadataPrinters =
nullptr;
227 assert(
MF &&
"getSubtargetInfo requires a valid MachineFunction!");
249 MMI = getAnalysisIfAvailable<MachineModuleInfo>();
280 assert(MI &&
"AsmPrinter didn't require GCModuleInfo?");
283 MP->beginAssembly(M, *MI, *
this);
292 OutStreamer->AddComment(
"Start of file scope inline assembly");
296 OutStreamer->AddComment(
"End of file scope inline assembly");
304 DbgTimerName, DbgTimerDescription,
305 CodeViewLineTablesGroupName,
306 CodeViewLineTablesGroupDescription));
312 DWARFGroupName, DWARFGroupDescription));
320 isCFIMoveForDebugging =
true;
327 if (!
F.isDeclarationForLinker() &&
F.needsUnwindTableEntry()) {
328 isCFIMoveForDebugging =
false;
334 isCFIMoveForDebugging =
false;
366 DWARFGroupName, DWARFGroupDescription));
368 if (mdconst::extract_or_null<ConstantInt>(
371 CFGuardDescription, DWARFGroupName,
372 DWARFGroupDescription));
438 "No emulated TLS variables in the common section");
478 "' is already defined");
495 HI.TimerGroupName,
HI.TimerGroupDescription,
497 HI.Handler->setSymbolSize(GVSym, Size);
502 if (Size == 0) Size = 1;
503 unsigned Align = 1 << AlignLog;
521 unsigned Align = 1 << AlignLog;
522 EmitLinkage(GV, GVSym);
524 OutStreamer->EmitZerofill(TheSection, GVSym, Size, Align);
534 unsigned Align = 1 << AlignLog;
544 OutStreamer->EmitLocalCommonSymbol(GVSym, Size, Align);
575 OutStreamer->EmitTBSSSymbol(TheSection, MangSym, Size, 1 << AlignLog);
593 EmitLinkage(GV, GVSym);
614 EmitLinkage(GV, EmittedInitSym);
639 void AsmPrinter::EmitFunctionHeader() {
644 <<
"-- Begin function " 693 std::vector<MCSymbol*> DeadBlockSyms;
695 for (
unsigned i = 0, e = DeadBlockSyms.size(); i != e; ++i) {
696 OutStreamer->AddComment(
"Address taken block that was later removed");
700 if (CurrentFnBegin) {
715 HI.Handler->beginFunction(
MF);
732 "' is a protected alias");
735 "' label emitted multiple times to assembly file");
752 bool Commented =
false;
757 for (
auto A : Accesses)
759 cast<FixedStackPseudoSourceValue>(A->getPseudoValue())
761 Size += A->getSize();
772 CommentOS << MMO->
getSize() <<
"-byte Reload";
776 if (
auto Size = getSize(Accesses)) {
777 CommentOS <<
Size <<
"-byte Folded Reload";
783 CommentOS << MMO->
getSize() <<
"-byte Spill";
787 if (
auto Size = getSize(Accesses)) {
788 CommentOS <<
Size <<
"-byte Folded Spill";
796 CommentOS <<
" Reload Reuse";
818 OS <<
"implicit-def: " 831 assert(Op.
isReg() &&
"KILL instruction must have only register operands");
832 OS <<
' ' << (Op.
isDef() ?
"def " :
"killed ")
849 OS <<
"DEBUG_VALUE: ";
852 if (
auto *
SP = dyn_cast<DISubprogram>(V->
getScope())) {
866 bool NeedSep =
false;
873 for (
unsigned I = 0;
I <
Op.getNumArgs(); ++
I)
874 OS <<
' ' <<
Op.getArg(
I);
922 OS <<
'+' << Offset <<
']';
938 OS <<
"DEBUG_LABEL: ";
941 if (
auto *
SP = dyn_cast<DISubprogram>(V->
getScope())) {
981 while (
I != MBB->end() &&
I->isTransient())
983 if (
I == MBB->instr_end() &&
984 MBB->getReverseIterator() == MBB->getParent()->rbegin())
1009 if (!StackSizeSection)
1044 EmitFunctionHeader();
1053 MDT = getAnalysisIfAvailable<MachineDominatorTree>();
1055 OwnedMDT = make_unique<MachineDominatorTree>();
1056 OwnedMDT->getBase().recalculate(*
MF);
1057 MDT = OwnedMDT.get();
1061 MLI = getAnalysisIfAvailable<MachineLoopInfo>();
1063 OwnedMLI = make_unique<MachineLoopInfo>();
1065 MLI = OwnedMLI.get();
1070 bool HasAnyRealCode =
false;
1071 int NumInstsInFunction = 0;
1072 for (
auto &MBB : *
MF) {
1075 for (
auto &
MI : MBB) {
1077 if (!
MI.isPosition() && !
MI.isImplicitDef() && !
MI.isKill() &&
1078 !
MI.isDebugInstr()) {
1079 HasAnyRealCode =
true;
1080 ++NumInstsInFunction;
1087 if (ShouldPrintDebugScopes) {
1090 HI.TimerGroupName,
HI.TimerGroupDescription,
1092 HI.Handler->beginInstruction(&
MI);
1101 switch (
MI.getOpcode()) {
1102 case TargetOpcode::CFI_INSTRUCTION:
1105 case TargetOpcode::LOCAL_ESCAPE:
1109 case TargetOpcode::GC_LABEL:
1115 case TargetOpcode::DBG_VALUE:
1121 case TargetOpcode::DBG_LABEL:
1127 case TargetOpcode::IMPLICIT_DEF:
1142 if (ShouldPrintDebugScopes) {
1145 HI.TimerGroupName,
HI.TimerGroupDescription,
1147 HI.Handler->endInstruction();
1155 EmittedInsts += NumInstsInFunction;
1157 MF->getFunction().getSubprogram(),
1159 R <<
ore::NV(
"NumInstructions", NumInstsInFunction)
1160 <<
" instructions in function";
1175 MF->getSubtarget().getInstrInfo()->getNoop(Noop);
1180 OutStreamer->AddComment(
"avoids zero-length function");
1186 for (
const auto &BB : F) {
1187 if (!BB.hasAddressTaken())
1192 OutStreamer->AddComment(
"Address of block that was removed by CodeGen");
1220 HI.Handler->markFunctionEnd();
1230 HI.Handler->endFunction(MF);
1237 OutStreamer->GetCommentOS() <<
"-- End function\n";
1247 if (isa<GlobalVariable>(C))
1250 unsigned NumUses = 0;
1263 unsigned &NumGOTEquivUsers) {
1274 for (
auto *U : GV->
users())
1277 return NumGOTEquivUsers > 0;
1291 for (
const auto &
G : M.
globals()) {
1292 unsigned NumGOTEquivUsers = 0;
1311 unsigned Cnt =
I.second.second;
1315 GlobalGOTEquivs.clear();
1317 for (
auto *GV : FailedCandidates)
1321 void AsmPrinter::emitGlobalIndirectSymbol(
Module &M,
1336 if (isa<GlobalIFunc>(GIS))
1344 if (isa<GlobalAlias>(&GIS) &&
MAI->
hasAltEntry() && isa<MCBinaryExpr>(Expr))
1350 if (
auto *GA = dyn_cast<GlobalAlias>(&GIS)) {
1387 if (!
F.isDeclarationForLinker())
1394 EmitVisibility(Name, V,
false);
1406 if (!Stubs.empty()) {
1411 for (
const auto &Stub : Stubs) {
1413 OutStreamer->EmitSymbolValue(Stub.second.getPointer(),
1425 if (!Stubs.empty()) {
1428 for (
const auto &Stub : Stubs) {
1430 SectionName += Stub.first->getName();
1440 OutStreamer->EmitSymbolValue(Stub.second.getPointer(),
1450 HI.Handler->endModule();
1464 for (
const auto &GO : M.global_objects()) {
1465 if (!GO.hasExternalWeakLinkage())
1479 for (
const auto &Alias : M.aliases()) {
1482 if (!AliasVisited.
insert(Cur).second)
1487 emitGlobalIndirectSymbol(M, *AncestorAlias);
1490 for (
const auto &IFunc : M.ifuncs())
1491 emitGlobalIndirectSymbol(M, IFunc);
1494 assert(MI &&
"AsmPrinter didn't require GCModuleInfo?");
1497 MP->finishAssembly(M, *MI, *
this);
1500 EmitModuleIdents(M);
1503 EmitModuleCommandLines(M);
1535 if (!InitTrampolineIntrinsic || InitTrampolineIntrinsic->
use_empty())
1548 if (!Flags.empty()) {
1556 if (
const auto *LU = M.getNamedGlobal(
"llvm.used")) {
1557 assert(LU->hasInitializer() &&
1558 "expected llvm.used to have an initializer");
1559 assert(isa<ArrayType>(LU->getValueType()) &&
1560 "expected llvm.used to be an array type");
1561 if (
const auto *A = cast<ConstantArray>(LU->getInitializer())) {
1562 for (
const Value *
Op : A->operands()) {
1564 cast<GlobalValue>(
Op->stripPointerCastsNoFollowAliases());
1575 if (!Flags.empty()) {
1610 if (!CurExceptionSym)
1612 return CurExceptionSym;
1620 CurrentFnBegin =
nullptr;
1621 CurExceptionSym =
nullptr;
1626 if (NeedsLocalForSize)
1627 CurrentFnSymForSize = CurrentFnBegin;
1630 ORE = &getAnalysis<MachineOptimizationRemarkEmitterPass>().getORE();
1646 SectionCPs(
MCSection *s,
unsigned a) : S(s), Alignment(a) {}
1657 const std::vector<MachineConstantPoolEntry> &
CP = MCP->
getConstants();
1658 if (CP.empty())
return;
1663 for (
unsigned i = 0, e = CP.size(); i != e; ++i) {
1679 unsigned SecIdx = CPSections.
size();
1680 while (SecIdx != 0) {
1681 if (CPSections[--SecIdx].S == S) {
1687 SecIdx = CPSections.
size();
1688 CPSections.
push_back(SectionCPs(S, Align));
1691 if (Align > CPSections[SecIdx].Alignment)
1692 CPSections[SecIdx].Alignment =
Align;
1699 for (
unsigned i = 0, e = CPSections.
size(); i != e; ++i) {
1700 for (
unsigned j = 0, ee = CPSections[i].CPEs.
size(); j != ee; ++j) {
1701 unsigned CPI = CPSections[i].CPEs[j];
1706 if (CurSection != CPSections[i].S) {
1709 CurSection = CPSections[i].S;
1717 unsigned NewOffset = (Offset + AlignMask) & ~AlignMask;
1740 if (JT.empty())
return;
1749 if (JTInDiffSection) {
1759 if (!JTInDiffSection)
1762 for (
unsigned JTI = 0, e = JT.size(); JTI != e; ++JTI) {
1763 const std::vector<MachineBasicBlock*> &JTBBs = JT[JTI].MBBs;
1766 if (JTBBs.empty())
continue;
1775 for (
unsigned ii = 0, ee = JTBBs.size(); ii != ee; ++ii) {
1777 if (!EmittedSets.
insert(MBB).second)
1800 for (
unsigned ii = 0, ee = JTBBs.size(); ii != ee; ++ii)
1801 EmitJumpTableEntry(MJTI, JTBBs[ii], JTI);
1803 if (!JTInDiffSection)
1811 unsigned UID)
const {
1865 assert(Value &&
"Unknown entry kind!");
1875 if (GV->
getName() ==
"llvm.used") {
1890 if (GV->
getName() ==
"llvm.global_ctors") {
1897 if (GV->
getName() ==
"llvm.global_dtors") {
1910 void AsmPrinter::EmitLLVMUsedList(
const ConstantArray *InitList) {
1912 for (
unsigned i = 0, e = InitList->
getNumOperands(); i != e; ++i) {
1927 Structor() =
default;
1938 if (!isa<ConstantArray>(List))
return;
1942 if (!InitList)
return;
1960 if (!Priority)
continue;
1962 Structor &S = Structors.
back();
1972 std::stable_sort(Structors.
begin(), Structors.
end(),
1973 [](
const Structor &L,
1974 const Structor &R) {
return L.Priority < R.Priority; });
1975 for (Structor &S : Structors) {
1999 void AsmPrinter::EmitModuleIdents(
Module &M) {
2004 for (
unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) {
2005 const MDNode *
N = NMD->getOperand(i);
2007 "llvm.ident metadata entry can have only one operand");
2014 void AsmPrinter::EmitModuleCommandLines(
Module &M) {
2029 "llvm.commandline metadata entry can have only one operand");
2066 unsigned Size)
const {
2067 OutStreamer->emitAbsoluteSymbolDiff(Hi, Lo, Size);
2075 bool IsSectionRelative)
const {
2103 if (NumBits == 0)
return;
2106 static_cast<unsigned>(std::numeric_limits<unsigned>::digits) &&
2107 "undefined behavior");
2124 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(CV))
2127 if (
const GlobalValue *GV = dyn_cast<GlobalValue>(CV))
2130 if (
const BlockAddress *BA = dyn_cast<BlockAddress>(CV))
2151 OS <<
"Unsupported expression in static initializer: ";
2156 case Instruction::GetElementPtr: {
2159 cast<GEPOperator>(CE)->accumulateConstantOffset(
getDataLayout(), OffsetAI);
2170 case Instruction::Trunc:
2176 case Instruction::BitCast:
2179 case Instruction::IntToPtr: {
2190 case Instruction::PtrToInt: {
2213 case Instruction::Sub: {
2222 const MCExpr *RelocExpr =
2228 int64_t Addend = (LHSOffset - RHSOffset).getSExtValue();
2242 case Instruction::Mul:
2243 case Instruction::SDiv:
2244 case Instruction::SRem:
2245 case Instruction::Shl:
2246 case Instruction::And:
2247 case Instruction::Or:
2248 case Instruction::Xor: {
2280 assert(!Data.
empty() &&
"Empty aggregates should be CAZ node");
2282 for (
unsigned i = 1, e = Data.
size(); i != e; ++i)
2283 if (Data[i] != C)
return -1;
2284 return static_cast<uint8_t
>(
C);
2291 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(V)) {
2296 APInt Value = CI->getValue().zextOrSelf(Size);
2305 assert(CA->getNumOperands() != 0 &&
"Should be a CAZ");
2312 for (
unsigned i = 1, e = CA->getNumOperands(); i != e; ++i)
2313 if (CA->getOperand(i) != Op0)
2359 assert(EmittedSize <= Size &&
"Size cannot be less than EmittedSize!");
2360 if (
unsigned Padding = Size - EmittedSize)
2391 if (
unsigned Padding = Size - EmittedSize)
2401 uint64_t SizeSoFar = 0;
2412 SizeSoFar += FieldSize + PadSize;
2420 "Layout of constant struct may be incorrect!");
2435 AP.
OutStreamer->GetCommentOS() <<
"Printing <null> Type";
2436 AP.
OutStreamer->GetCommentOS() <<
' ' << StrVal <<
'\n';
2443 unsigned TrailingBytes = NumBytes %
sizeof(uint64_t);
2452 AP.
OutStreamer->EmitIntValue(p[Chunk--], TrailingBytes);
2454 for (; Chunk >= 0; --Chunk)
2455 AP.
OutStreamer->EmitIntValue(p[Chunk],
sizeof(uint64_t));
2458 for (Chunk = 0; Chunk < NumBytes /
sizeof(uint64_t); ++Chunk)
2459 AP.
OutStreamer->EmitIntValue(p[Chunk],
sizeof(uint64_t));
2462 AP.
OutStreamer->EmitIntValue(p[Chunk], TrailingBytes);
2481 uint64_t ExtraBits = 0;
2482 unsigned ExtraBitsSize = BitWidth & 63;
2484 if (ExtraBitsSize) {
2501 ExtraBits = Realigned.getRawData()[0] &
2502 (((uint64_t)-1) >> (64 - ExtraBitsSize));
2503 Realigned.lshrInPlace(ExtraBitsSize);
2505 ExtraBits = Realigned.getRawData()[BitWidth / 64];
2511 const uint64_t *RawData = Realigned.getRawData();
2512 for (
unsigned i = 0, e = BitWidth / 64; i != e; ++i) {
2513 uint64_t Val = DL.
isBigEndian() ? RawData[e - i - 1] : RawData[i];
2517 if (ExtraBitsSize) {
2522 Size -= (BitWidth / 64) * 8;
2523 assert(Size && Size * 8 >= ExtraBitsSize &&
2524 (ExtraBits & (((uint64_t)-1) >> (64 - ExtraBitsSize)))
2525 == ExtraBits &&
"Directive too small for extra bits.");
2557 if (!(*ME)->evaluateAsRelocatable(MV,
nullptr,
nullptr) || MV.
isAbsolute())
2568 const GlobalValue *BaseGV = dyn_cast_or_null<GlobalValue>(BaseCst);
2576 if (!SymB || BaseSym != &SymB->
getSymbol())
2587 if (GOTPCRelCst < 0)
2609 int NumUses = (int)Result.second;
2630 BaseCV = dyn_cast<Constant>(CV->
user_back());
2632 if (isa<ConstantAggregateZero>(CV) || isa<UndefValue>(CV))
2635 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
2643 CI->getZExtValue());
2652 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(CV))
2655 if (isa<ConstantPointerNull>(CV)) {
2669 if (
const ConstantExpr *CE = dyn_cast<ConstantExpr>(CV)) {
2672 if (CE->getOpcode() == Instruction::BitCast)
2680 if (New && New != CE)
2721 else if (Offset < 0)
2743 if (
getSubtargetInfo().getTargetTriple().isKnownWindowsMSVCEnvironment()) {
2753 if (
MCSymbol *Sym = S->getCOMDATSymbol()) {
2754 if (Sym->isUndefined())
2800 <<
"Parent Loop BB" << FunctionNumber <<
"_" 2811 OS.
indent(CL->getLoopDepth()*2)
2812 <<
"Child Loop BB" << FunctionNumber <<
"_" 2813 << CL->getHeader()->getNumber() <<
" Depth " << CL->getLoopDepth()
2828 assert(Header &&
"No header for loop");
2832 if (Header != &MBB) {
2833 AP.
OutStreamer->AddComment(
" in Loop: Header=BB" +
2859 assert(
MF !=
nullptr &&
"Machine function must be valid");
2877 HI.Handler->endFunclet();
2878 HI.Handler->beginFunclet(MBB);
2886 setupCodePaddingContext(MBB, Context);
2887 OutStreamer->EmitCodePaddingBasicBlockStart(Context);
2908 if (BB->hasName()) {
2910 false, BB->getModule());
2915 assert(
MLI !=
nullptr &&
"MachineLoopInfo should has been computed");
2934 setupCodePaddingContext(MBB, Context);
2935 OutStreamer->EmitCodePaddingBasicBlockEnd(Context);
2939 bool IsDefinition)
const {
2942 switch (Visibility) {
2985 if (!
MI.isBranch() ||
MI.isIndirectBranch())
2994 if (
OP->isMBB() &&
OP->getMBB() == MBB)
3008 if (GCPI != GCMap.
end())
3009 return GCPI->second.get();
3016 if (
Name ==
I->getName()) {
3017 std::unique_ptr<GCMetadataPrinter> GMP =
I->instantiate();
3019 auto IterBool = GCMap.
insert(std::make_pair(&S, std::move(GMP)));
3020 return IterBool.first->second.get();
3028 assert(MI &&
"AsmPrinter didn't require GCModuleInfo?");
3029 bool NeedsDefault =
false;
3032 NeedsDefault =
true;
3034 for (
auto &
I : *MI) {
3036 if (MP->emitStackMaps(SM, *
this))
3040 NeedsDefault =
true;
3059 auto Kind8 =
static_cast<uint8_t
>(Kind);
3062 StringRef(reinterpret_cast<const char *>(&AlwaysInstrument), 1));
3064 auto Padding = (4 * Bytes) - ((2 * Bytes) + 3);
3065 assert(Padding >= 0 &&
"Instrumentation map entry > 4 * Word Size");
3073 auto PrevSection =
OutStreamer->getCurrentSectionOnly();
3079 assert(Associated !=
nullptr);
3081 std::string GroupName;
3090 GroupName, UniqueID, Associated);
3093 GroupName, UniqueID, Associated);
3111 for (
const auto &Sled :
Sleds)
3121 OutStreamer->EmitCodeAlignment(2 * WordSizeBytes);
3122 OutStreamer->EmitSymbolValue(SledsStart, WordSizeBytes,
false);
3123 OutStreamer->EmitSymbolValue(SledsEnd, WordSizeBytes,
false);
3133 bool AlwaysInstrument =
3134 Attr.isStringAttribute() && Attr.getValueAsString() ==
"xray-always";
3138 AlwaysInstrument, &
F, Version});
3142 return OutStreamer->getContext().getDwarfVersion();
3146 OutStreamer->getContext().setDwarfVersion(Version);
virtual void EmitGlobalVariable(const GlobalVariable *GV)
Emit the specified global variable to the .s file.
const Function & getFunction() const
void setDwarfVersion(uint16_t Version)
bool isDeclarationForLinker() const
MachineConstantPoolValue * MachineCPVal
StringRef getSection() const
Get the custom section of this global if it has one.
const TargetLoweringObjectFile & getObjFileLowering() const
Return information about object file lowering.
Instances of this class represent a uniqued identifier for a section in the current translation unit...
IntegerType * getType() const
getType - Specialize the getType() method to always return an IntegerType, which reduces the amount o...
bool doesSetDirectiveSuppressReloc() const
void emitInt64(uint64_t Value) const
Emit a long long directive and value.
virtual void EmitStartOfAsmFile(Module &)
This virtual method can be overridden by targets that want to emit something at the start of their fi...
A parsed version of the target data layout string in and methods for querying it. ...
static void emitGlobalConstantLargeInt(const ConstantInt *CI, AsmPrinter &AP)
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
StringRef getTargetFeatureString() const
bool usesWindowsCFI() const
MCSymbolAttr getHiddenVisibilityAttr() const
The MachineConstantPool class keeps track of constants referenced by a function which must be spilled...
const std::vector< MachineJumpTableEntry > & getJumpTables() const
bool isThreadData() const
bool hasLocalLinkage() const
unsigned getOpcode() const
Return the opcode at the root of this constant expression.
Special purpose, only applies to global arrays.
uint64_t getZExtValue() const
Get zero extended value.
static void emitBasicBlockLoopComments(const MachineBasicBlock &MBB, const MachineLoopInfo *LI, const AsmPrinter &AP)
emitBasicBlockLoopComments - Pretty-print comments for basic blocks.
DiagnosticInfoOptimizationBase::Argument NV
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
bool hasDebugInfo() const
Returns true if valid debug info is present.
unsigned getFunctionNumber() const
getFunctionNumber - Return a unique ID for the current function.
MCSymbol * GetExternalSymbolSymbol(StringRef Sym) const
Return the MCSymbol for the specified ExternalSymbol.
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
static const char *const DbgTimerDescription
MDNode * getOperand(unsigned i) const
MCTargetOptions MCOptions
Machine level options.
virtual MCSection * getStaticCtorSection(unsigned Priority, const MCSymbol *KeySym) const
bool hasPrivateLinkage() const
const MachineFunction * getMF() const
Return the function that contains the basic block that this instruction belongs to.
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
const std::vector< MCCFIInstruction > & getFrameInstructions() const
Returns a reference to a list of cfi instructions in the function's prologue.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
This class represents lattice values for constants.
void EmitSymbolValue(const MCSymbol *Sym, unsigned Size, bool IsSectionRelative=false)
Special case of EmitValue that avoids the client having to pass in a MCExpr for MCSymbols.
bool isVariable() const
isVariable - Check if this is a variable symbol.
MCSection * SectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const
This method computes the appropriate section to emit the specified global variable or function defini...
.type _foo, STT_OBJECT # aka
This represents an "assembler immediate".
static bool isGOTEquivalentCandidate(const GlobalVariable *GV, unsigned &NumGOTEquivUsers)
Only consider global GOT equivalents if at least one user is a cstexpr inside an initializer of anoth...
bool hasMachoTBSSDirective() const
StringRef getPrivateGlobalPrefix() const
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
A Module instance is used to store all the information related to an LLVM module. ...
void redefineIfPossible()
Prepare this symbol to be redefined.
MCSection * getTLSBSSSection() const
unsigned getPointerPrefAlignment(unsigned AS=0) const
Return target's alignment for stack-based pointers FIXME: The defaults need to be removed once all of...
bool doesSupportDebugInformation() const
bool hasSingleParameterDotFile() const
bool doFinalization(Module &M) override
Shut down the asmprinter.
SmallVector< std::unique_ptr< GCStrategy >, 1 >::const_iterator iterator
Same, but only replaced by something equivalent.
static void emitGlobalConstantDataSequential(const DataLayout &DL, const ConstantDataSequential *CDS, AsmPrinter &AP)
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
virtual int getFrameIndexReference(const MachineFunction &MF, int FI, unsigned &FrameReg) const
getFrameIndexReference - This method should return the base register and offset used to reference a f...
MCContext & OutContext
This is the context for the output file that we are streaming.
static cl::opt< bool > PrintSchedule("print-schedule", cl::Hidden, cl::init(false), cl::desc("Print 'sched: [latency:throughput]' in .s output"))
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
bool hasLinkOnceDirective() const
unsigned getLoopDepth() const
Return the nesting level of this loop.
Available for inspection, not emission.
unsigned getNumWords() const
Get the number of words.
unsigned getNumElements() const
Random access to the elements.
const StructLayout * getStructLayout(StructType *Ty) const
Returns a StructLayout object, indicating the alignment of the struct, its size, and the offsets of i...
bool EnablePrintSchedInfo
Enable print [latency:throughput] in output.
void push_back(const T &Elt)
const MCSubtargetInfo & getSubtargetInfo() const
Return information about subtarget.
DWARF-like instruction based exceptions.
uint16_t getDwarfVersion() const
unsigned getReg() const
getReg - Returns the register number.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
CFIMoveType needsCFIMoves() const
virtual void EmitJumpTableInfo()
Print assembly representations of the jump tables used by the current function to the current output ...
static int isRepeatedByteSequence(const ConstantDataSequential *V)
isRepeatedByteSequence - Determine whether the given value is composed of a repeated sequence of iden...
Collects and handles dwarf debug information.
bool hasAvailableExternallyLinkage() const
virtual void EmitXXStructor(const DataLayout &DL, const Constant *CV)
Targets can override this to change how global constants that are part of a C++ static/global constru...
EK_Inline - Jump table entries are emitted inline at their point of use.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
virtual const TargetLowering * getTargetLowering() const
raw_ostream & indent(unsigned NumSpaces)
indent - Insert 'NumSpaces' spaces.
bool hasDotTypeDotSizeDirective() const
bool needsDwarfSectionOffsetDirective() const
float convertToFloat() const
uint64_t getElementByteSize() const
Return the size (in bytes) of each element in the array/vector.
This file contains the declaration of the Comdat class, which represents a single COMDAT in LLVM...
virtual MCSection * getSectionForCommandLines() const
If supported, return the section to use for the llvm.commandline metadata.
Like Internal, but omit from symbol table.
Externally visible function.
uint64_t getSize() const
Return the size in bytes of the memory reference.
bool IsConstantOffsetFromGlobal(Constant *C, GlobalValue *&GV, APInt &Offset, const DataLayout &DL)
If this constant is a constant offset from a global, return the global and the constant.
bool hasPrologueData() const
Check whether this function has prologue data.
bool isAbsolute() const
Is this an absolute (as opposed to relocatable) value.
static const char *const DWARFGroupName
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
A raw_ostream that writes to an SmallVector or SmallString.
virtual void EmitConstantPool()
Print to the current output stream assembly representations of the constants in the constant pool MCP...
bool hasDLLImportStorageClass() const
STATISTIC(NumFunctions, "Total number of functions")
static const MCBinaryExpr * createAnd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
unsigned getProgramPointerSize() const
MachineFunction * MF
The current machine function.
setjmp/longjmp based exceptions
SmallVector< HandlerInfo, 1 > Handlers
A vector of all debug/EH info emitters we should use.
const MDOperand & getOperand(unsigned I) const
ELFYAML::ELF_STV Visibility
APInt zextOrTrunc(unsigned width) const
Zero extend or truncate to width.
virtual void emitLinkerFlagsForUsed(raw_ostream &OS, const GlobalValue *GV) const
static const MCBinaryExpr * createMul(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
std::pair< const GlobalVariable *, unsigned > GOTEquivUsePair
Map global GOT equivalent MCSymbols to GlobalVariables and keep track of its number of uses by other ...
static void emitKill(const MachineInstr *MI, AsmPrinter &AP)
static const char *const DWARFGroupDescription
bool hasSplitStack() const
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
bool hasIdentDirective() const
bool isPPC_FP128Ty() const
Return true if this is powerpc long double.
virtual void EmitDebugValue(const MCExpr *Value, unsigned Size) const
Emit the directive and value for debug thread local expression.
DenseMap< GCStrategy *, std::unique_ptr< GCMetadataPrinter > > gcp_map_type
unsigned getBitWidth() const
getBitWidth - Return the bitwidth of this constant.
bool hasMachoZeroFillDirective() const
WinEH::EncodingType getWinEHEncodingType() const
virtual void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI, bool PrintSchedInfo=false)
Emit the given Instruction into the current section.
bool canBeOmittedFromSymbolTable() const
True if GV can be left out of the object symbol table.
unsigned getBitWidth() const
Return the number of bits in the APInt.
Constant * getPrologueData() const
Get the prologue data associated with this function.
MCSectionCOFF * getCOFFSection(StringRef Section, unsigned Characteristics, SectionKind Kind, StringRef COMDATSymName, int Selection, unsigned UniqueID=GenericSectionID, const char *BeginSymName=nullptr)
virtual MCSection * getStaticDtorSection(unsigned Priority, const MCSymbol *KeySym) const
const Triple & getTargetTriple() const
This represents a section on Windows.
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
The address of a basic block.
static const MCBinaryExpr * createXor(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
AnalysisUsage & addRequired()
int64_t getConstant() const
Used to lazily calculate structure layout information for a target machine, based on the DataLayout s...
void recordSled(MCSymbol *Sled, const MachineInstr &MI, SledKind Kind, uint8_t Version=0)
bool hasNosplitStack() const
const MCSymbolRefExpr * getSymB() const
static void emitGlobalConstantFP(const ConstantFP *CFP, AsmPrinter &AP)
bool hasPrefixData() const
Check whether this function has prefix data.
bool IsBasicBlockReachableViaBranch
A description of a memory reference used in the backend.
static Constant * getIntegerCast(Constant *C, Type *Ty, bool isSigned)
Create a ZExt, Bitcast or Trunc for integer -> integer casts.
amdgpu Simplify well known AMD library false Value Value const Twine & Name
Emits exception handling directives.
SymbolListTy GetGVStubList()
Accessor methods to return the set of stubs in sorted order.
StringRef getName() const
MCSymbol * createLinkerPrivateTempSymbol()
Create and return a new linker temporary symbol with a unique but unspecified name.
bool isMachineConstantPoolEntry() const
isMachineConstantPoolEntry - Return true if the MachineConstantPoolEntry is indeed a target specific ...
Type * getPointerElementType() const
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
virtual void EmitEndOfAsmFile(Module &)
This virtual method can be overridden by targets that want to emit something at the end of their file...
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
const HexagonInstrInfo * TII
static void emitGlobalConstantStruct(const DataLayout &DL, const ConstantStruct *CS, AsmPrinter &AP, const Constant *BaseCV, uint64_t Offset)
unsigned getPointerTypeSize(Type *Ty) const
MachineModuleInfoCOFF - This is a MachineModuleInfoImpl implementation for COFF targets.
const ConstantFP * getFPImm() const
unsigned getNumOperands() const
Retuns the total number of operands.
Printable printReg(unsigned Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubIdx=0, const MachineRegisterInfo *MRI=nullptr)
Prints virtual and physical registers with or without a TRI instance.
StringRef getRawDataValues() const
Return the raw, underlying, bytes of this data.
Class to represent struct types.
This class is basically a combination of TimeRegion and Timer.
bool isConstant() const
If the value is a global constant, its value is immutable throughout the runtime execution of the pro...
virtual void emitModuleMetadata(MCStreamer &Streamer, Module &M) const
Emit the module-level metadata that the platform cares about.
static const MCBinaryExpr * createDiv(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Base class for the full range of assembler expressions which are needed for parsing.
bool hasAtLeastLocalUnnamedAddr() const
Returns true if this value's address is not significant in this module.
iterator_range< iterator > terminators()
unsigned getAlignment() const
getAlignment - Return the alignment (log2, not bytes) of the function.
Represent a reference to a symbol from inside an expression.
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
unsigned getNumOperands() const
bool hasVarSizedObjects() const
This method may be called any time after instruction selection is complete to determine if the stack ...
void getNameWithPrefix(SmallVectorImpl< char > &Name, const GlobalValue *GV, Mangler &Mang, bool MayAlwaysUsePrivate=false) const
bool getCommDirectiveSupportsAlignment() const
MCSection * getBSSSection() const
SmallVector< XRayFunctionEntry, 4 > Sleds
An analysis pass which caches information about the entire Module.
MCSection * getDataSection() const
MCSection * getStackSizesSection(const MCSection &TextSec) const
const char * getWeakRefDirective() const
uint64_t getNumElements() const
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
unsigned getCFIIndex() const
This file implements a class to represent arbitrary precision integral constant values and operations...
bool hasCommonLinkage() const
INLINEASM - Represents an inline asm block.
Constant * getPrefixData() const
Get the prefix data associated with this function.
BlockT * getHeader() const
static const char *const CodeViewLineTablesGroupName
unsigned getPointerSize() const
Return the pointer size from the TargetMachine.
void emitXRayTable()
Emit a table with all XRay instrumentation points.
Context object for machine code objects.
auto reverse(ContainerTy &&C, typename std::enable_if< has_rbegin< ContainerTy >::value >::type *=nullptr) -> decltype(make_range(C.rbegin(), C.rend()))
bool IsBasicBlockReachableViaFallthrough
bool hasExternalLinkage() const
unsigned getEntryAlignment(const DataLayout &TD) const
getEntryAlignment - Return the alignment of each entry in the jump table.
Constant * ConstantFoldConstant(const Constant *C, const DataLayout &DL, const TargetLibraryInfo *TLI=nullptr)
ConstantFoldConstant - Attempt to fold the constant using the specified DataLayout.
static bool needFuncLabelsForEHOrDebugInfo(const MachineFunction &MF, MachineModuleInfo *MMI)
static const MCBinaryExpr * createShl(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
void getAnalysisUsage(AnalysisUsage &AU) const override
Record analysis usage.
bool isNullValue() const
Return true if this is the value that would be returned by getNullValue.
A constant value that is initialized with an expression using other constant values.
void EmitFunctionBody()
This method emits the body and trailer for a function.
int64_t getSExtValue() const
Get sign extended value.
const std::string & getName() const
Return the name of the GC strategy.
Type * getType() const
All values are typed, get the type of this value.
opStatus convert(const fltSemantics &ToSemantics, roundingMode RM, bool *losesInfo)
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
MCSymbol * getFunctionBegin() const
MCSectionMachO * getMachOSection(StringRef Segment, StringRef Section, unsigned TypeAndAttributes, unsigned Reserved2, SectionKind K, const char *BeginSymName=nullptr)
Return the MCSection for the specified mach-o section.
void toString(SmallVectorImpl< char > &Str, unsigned FormatPrecision=0, unsigned FormatMaxPadding=3, bool TruncateZero=true) const
ConstantDataSequential - A vector or array constant whose element type is a simple 1/2/4/8-byte integ...
virtual void EmitBasicBlockEnd(const MachineBasicBlock &MBB)
Targets can override this to emit stuff at the end of a basic block.
bool isPositionIndependent() const
EK_LabelDifference32 - Each entry is the address of the block minus the address of the jump table...
bool supportGOTPCRelWithOffset() const
Target GOT "PC"-relative relocation supports encoding an additional binary expression with an offset...
.type _foo, STT_GNU_IFUNC
VisibilityTypes
An enumeration for the kinds of visibility of global values.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
NamedMDNode * getNamedMetadata(const Twine &Name) const
Return the first NamedMDNode in the module with the specified name.
EK_BlockAddress - Each entry is a plain address of block, e.g.
const APInt & getValue() const
Return the constant as an APInt value reference.
BasicBlock * getBasicBlock() const
bool isFPImm() const
isFPImm - Tests if this is a MO_FPImmediate operand.
bool hasFunctionAlignment() const
bool hasPersonalityFn() const
Check whether this function has a personality function.
This class is a data container for one entry in a MachineConstantPool.
virtual const MCExpr * LowerCustomJumpTableEntry(const MachineJumpTableInfo *, const MachineBasicBlock *, unsigned, MCContext &) const
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
LinkageTypes getLinkage() const
virtual void EmitBinaryData(StringRef Data)
Functionally identical to EmitBytes.
Protected struct HandlerInfo and Handlers permit target extended AsmPrinter adds their own handlers...
virtual const TargetInstrInfo * getInstrInfo() const
static const fltSemantics & IEEEdouble() LLVM_READNONE
StringRef getTargetCPU() const
ArrayRef< MCSymbol * > getAddrLabelSymbolToEmit(const BasicBlock *BB)
Return the symbol to be used for the specified basic block when its address is taken.
unsigned getAlignment() const
void printOffset(int64_t Offset, raw_ostream &OS) const
This is just convenient handler for printing offsets.
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
bool hasLinkOnceLinkage() const
std::string getSchedInfoStr(const MachineInstr &MI) const
Returns string representation of scheduler comment.
bool isVerbose() const
Return true if assembly output should contain comments.
bool hasNoDeadStrip() const
const std::string & str() const
Type * getElementType() const
Return the element type of the array/vector.
void emitGlobalGOTEquivs()
Constant expressions using GOT equivalent globals may not be eligible for PC relative GOT entry conve...
MachineModuleInfo * MMI
This is a pointer to the current MachineModuleInfo.
Value * getOperand(unsigned i) const
Instances of this class represent a single low-level machine instruction.
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
static void handleIndirectSymViaGOTPCRel(AsmPrinter &AP, const MCExpr **ME, const Constant *BaseCst, uint64_t Offset)
Transform a not absolute MCExpr containing a reference to a GOT equivalent global, by a target specific GOT pc relative access to the final symbol.
const std::string & getSourceFileName() const
Get the module's original source file name.
static bool canBeHidden(const GlobalValue *GV, const MCAsmInfo &MAI)
static void emitGlobalConstantArray(const DataLayout &DL, const ConstantArray *CA, AsmPrinter &AP, const Constant *BaseCV, uint64_t Offset)
void EmitLabelPlusOffset(const MCSymbol *Label, uint64_t Offset, unsigned Size, bool IsSectionRelative=false) const
Emit something like ".long Label+Offset" where the size in bytes of the directive is specified by Siz...
unsigned getCodeViewFlag() const
Returns the CodeView Version by checking module flags.
StringRef getName() const
TargetInstrInfo - Interface to description of machine instruction set.
bool hasAppendingLinkage() const
iterator find(const_arg_type_t< KeyT > Val)
Windows Exception Handling.
const Constant * ConstVal
This class is intended to be used as a base class for asm properties and features specific to the tar...
virtual unsigned isStoreToStackSlotPostFE(const MachineInstr &MI, int &FrameIndex) const
Check for post-frame ptr elimination stack locations as well.
MCSection * getTLSExtraDataSection() const
bool useEmulatedTLS() const
Returns true if this target uses emulated TLS.
bool isOSWindows() const
Tests whether the OS is Windows.
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
ExternalWeak linkage description.
virtual MCSection * getNonexecutableStackSection(MCContext &Ctx) const
Targets can implement this method to specify a section to switch to if the translation unit doesn't h...
static bool emitDebugValueComment(const MachineInstr *MI, AsmPrinter &AP)
emitDebugValueComment - This method handles the target-independent form of DBG_VALUE, returning true if it was able to do so.
IntegerType * getIntPtrType(LLVMContext &C, unsigned AddressSpace=0) const
Returns an integer type with size at least as big as that of a pointer in the given address space...
unsigned getPreferredAlignmentLog(const GlobalVariable *GV) const
Returns the preferred alignment of the specified global, returned in log form.
Same, but only replaced by something equivalent.
EK_GPRel64BlockAddress - Each entry is an address of block, encoded with a relocation as gp-relative...
initializer< Ty > init(const Ty &Val)
void EmitZeros(uint64_t NumBytes)
Emit NumBytes worth of zeros.
Streaming machine code generation interface.
virtual void EmitFunctionBodyEnd()
Targets can override this to emit stuff after the last basic block in the function.
static const char *const EHTimerDescription
StringRef getName() const
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...
CodeGenOpt::Level getOptLevel() const
Returns the optimization level: None, Less, Default, or Aggressive.
.weak_def_can_be_hidden (MachO)
VisibilityTypes getVisibility() const
MCSymbol * CurrentFnSym
The symbol for the current function.
bool getAsmPrinterFlag(CommentFlag Flag) const
Return whether an AsmPrinter flag is set.
LLVM Basic Block Representation.
const FunctionListType & getFunctionList() const
Get the Module's list of functions (constant).
const MCAsmInfo * MAI
Target Asm Printer information.
The instances of the Type class are immutable: once they are created, they are never changed...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
virtual bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference, const Function &F) const
void takeDeletedSymbolsForFunction(const Function *F, std::vector< MCSymbol *> &Result)
If the specified function has had any references to address-taken blocks generated, but the block got deleted, return the symbol now so we can emit it.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
virtual void emitLinkerFlagsForGlobal(raw_ostream &OS, const GlobalValue *GV) const
bool isOSBinFormatCOFF() const
Tests whether the OS uses the COFF binary format.
AsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > Streamer)
Metadata * getModuleFlag(StringRef Key) const
Return the corresponding value if Key appears in module flags, otherwise return null.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
bool needsLocalForSize() const
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This is an important base class in LLVM.
bool hasEHFunclets() const
unsigned getPointerSize(unsigned AS=0) const
Layout pointer size FIXME: The defaults need to be removed once all of the backends/clients are updat...
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
This file contains the declarations for the subclasses of Constant, which represent the different fla...
MCSymbol * getAddrLabelSymbol(const BasicBlock *BB)
Return the symbol to be used for the specified basic block when its address is taken.
virtual MCSection * getSectionForConstant(const DataLayout &DL, SectionKind Kind, const Constant *C, unsigned &Align) const
Given a constant with the SectionKind, return a section that it should be placed in.
ConstantFP - Floating Point Values [float, double].
virtual bool isBlockOnlyReachableByFallthrough(const MachineBasicBlock *MBB) const
Return true if the basic block has exactly one predecessor and the control transfer mechanism between...
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
MCSymbol * getSymbol(const GlobalValue *GV) const
void EmitAlignment(unsigned NumBits, const GlobalObject *GV=nullptr) const
Emit an alignment directive to the specified power of two boundary.
static const MCBinaryExpr * createOr(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
unsigned getAlignment() const
Return alignment of the basic block.
unsigned EmitStackSizeSection
Emit section containing metadata on function stack sizes.
double convertToDouble() const
TargetMachine & TM
Target machine description.
This class is intended to be used as a driving class for all asm writers.
bool isCImm() const
isCImm - Test if this is a MO_CImmediate operand.
void getNameWithPrefix(SmallVectorImpl< char > &Name, const GlobalValue *GV) const
EHPersonality classifyEHPersonality(const Value *Pers)
See if the given exception handling personality function is one that we understand.
MCSymbol * getSymbolWithGlobalValueBase(const GlobalValue *GV, StringRef Suffix, const TargetMachine &TM) const
Return the MCSymbol for a private symbol with global value name as its base, with the specified suffi...
Represent the analysis usage information of a pass.
This file declares a class to represent arbitrary precision floating point values and provide a varie...
const MCSymbolRefExpr * getSymA() const
bool optForSize() const
Optimize this function for size (-Os) or minimum size (-Oz).
const DILabel * getDebugLabel() const
Return the debug label referenced by this DBG_LABEL instruction.
bool hasWeakDefCanBeHiddenDirective() const
static bool isDiscardableIfUnused(LinkageTypes Linkage)
Whether the definition of this global may be discarded if it is not used in its compilation unit...
MCSymbol * getJTISymbol(unsigned JTI, MCContext &Ctx, bool isLinkerPrivate=false) const
getJTISymbol - Return the MCSymbol for the specified non-empty jump table.
SectionKind - This is a simple POD value that classifies the properties of a section.
LCOMM::LCOMMType getLCOMMDirectiveAlignmentType() const
const Triple & getTargetTriple() const
bool useAssignmentForEHBegin() const
bool hasLinkerPrivateGlobalPrefix() const
static void PrintChildLoopComment(raw_ostream &OS, const MachineLoop *Loop, unsigned FunctionNumber)
PrintChildLoopComment - Print comments about child loops within the loop for this basic block...
self_iterator getIterator()
Ty & getObjFileInfo()
Keep track of various per-function pieces of information for backends that would like to do so...
Constant Vector Declarations.
bool usesMorestackAddr() const
MachineConstantPool * getConstantPool()
getConstantPool - Return the constant pool object for the current function.
bool hasSubsectionsViaSymbols() const
void emitFrameAlloc(const MachineInstr &MI)
bool isOSBinFormatMachO() const
Tests whether the environment is MachO.
void computeGlobalGOTEquivs(Module &M)
Unnamed constant global variables solely contaning a pointer to another globals variable act like a g...
const Target & getTarget() const
static const char *const EHTimerName
bool hasWeakDefDirective() const
bool isSplat(unsigned SplatSizeInBits) const
Check if the APInt consists of a repeated bit pattern.
void emitStackMaps(StackMaps &SM)
Emit the stack maps.
bool hasAddressTaken() const
Test whether this block is potentially the target of an indirect branch.
const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs, and aliases.
pred_iterator pred_begin()
Abstract base class for all machine specific constantpool value subclasses.
static void emitGlobalConstantVector(const DataLayout &DL, const ConstantVector *CV, AsmPrinter &AP)
auto find(R &&Range, const T &Val) -> decltype(adl_begin(Range))
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly...
virtual MCSymbol * GetCPISymbol(unsigned CPID) const
Return the symbol for the specified constant pool entry.
unsigned getDwarfVersion() const
Returns the Dwarf Version by checking module flags.
virtual void markFunctionEnd()
void printAsOperand(raw_ostream &O, bool PrintType=true, const Module *M=nullptr) const
Print the name of this Value out to the specified raw_ostream.
std::string & str()
Flushes the stream contents to the target string and returns the string's reference.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Windows x64, Windows Itanium (IA-64)
StringRef OperationEncodingString(unsigned Encoding)
static void PrintParentLoopComment(raw_ostream &OS, const MachineLoop *Loop, unsigned FunctionNumber)
PrintParentLoopComment - Print comments about parent loops of this one.
const DIExpression * getDebugExpression() const
Return the complex address expression referenced by this DBG_VALUE instruction.
Triple - Helper class for working with autoconf configuration names.
MCSection * getDrectveSection() const
EH_LABEL - Represents a label in mid basic block used to track locations needed for debug and excepti...
void serializeToStackMapSection()
If there is any stack map data, create a stack map section and serialize the map info into it...
unsigned getPointerSize(unsigned AS) const
Get the pointer size for this target.
iterator_range< expr_op_iterator > expr_ops() const
bool hasWeakLinkage() const
const std::vector< MachineConstantPoolEntry > & getConstants() const
const APFloat & getValueAPF() const
bool hasAddressTaken() const
Returns true if there are any uses of this basic block other than direct branches, switches, etc.
unsigned getFunctionNumber() const
Return a unique ID for the current function.
const std::vector< LandingPadInfo > & getLandingPads() const
Return a reference to the landing pad info for the current function.
virtual bool hasLoadFromStackSlot(const MachineInstr &MI, SmallVectorImpl< const MachineMemOperand *> &Accesses) const
If the specified machine instruction has a load from a stack slot, return true along with the FrameIn...
unsigned getNumOperands() const
void emitCFIInstruction(const MachineInstr &MI)
virtual void emitImplicitDef(const MachineInstr *MI) const
Targets can override this to customize the output of IMPLICIT_DEF instructions in verbose mode...
MCSymbol * GetBlockAddressSymbol(const BlockAddress *BA) const
Return the MCSymbol used to satisfy BlockAddress uses of the specified basic block.
ConstMIBundleOperands - Iterate over all operands in a const bundle of machine instructions.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
virtual const MCExpr * lowerRelativeReference(const GlobalValue *LHS, const GlobalValue *RHS, const TargetMachine &TM) const
uint64_t getLimitedValue(uint64_t Limit=~0ULL) const
getLimitedValue - If the value is smaller than the specified limit, return it, otherwise return the l...
unsigned Alignment
The required alignment for this entry.
This is the shared class of boolean and integer constants.
virtual TargetLoweringObjectFile * getObjFileLowering() const
SymbolListTy GetGVStubList()
Accessor methods to return the set of stubs in sorted order.
MapVector< const MCSymbol *, GOTEquivUsePair > GlobalGOTEquivs
mmo_iterator memoperands_begin() const
Access to memory operands of the instruction.
virtual const MCExpr * getIndirectSymViaGOTPCRel(const MCSymbol *Sym, const MCValue &MV, int64_t Offset, MachineModuleInfo *MMI, MCStreamer &Streamer) const
Get the target specific PC relative GOT entry relocation.
virtual bool isVirtualSection() const =0
Check whether this section is "virtual", that is has no actual object file contents.
static const char *const CodeViewLineTablesGroupDescription
MCSymbol * getSymbol(const GlobalValue *GV) const
const MCSymbol & getSymbol() const
virtual const MCExpr * lowerConstant(const Constant *CV)
Lower the specified LLVM Constant to an MCExpr.
virtual void EmitInstruction(const MachineInstr *)
Targets should implement this to emit instructions.
bool isUndefined(bool SetUsed=true) const
isUndefined - Check if this symbol undefined (i.e., implicitly defined).
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...
Keep one copy of function when linking (inline)
uint64_t getElementAsInteger(unsigned i) const
If this is a sequential container of integers (of any size), return the specified element in the low ...
StringRef getAsString() const
If this array is isString(), then this method returns the array as a StringRef.
Module.h This file contains the declarations for the Module class.
void beginModule()
Emit all Dwarf sections that should come prior to the content.
unsigned EmitAddrsig
Emit address-significance table.
Information about stack frame layout on the target.
void EmitToStreamer(MCStreamer &S, const MCInst &Inst)
bool EmitSpecialLLVMGlobal(const GlobalVariable *GV)
Check to see if the specified global is a special global used by LLVM.
static SectionKind getReadOnlyWithRel()
uint64_t getSizeInBytes() const
StringRef str()
Return a StringRef for the vector contents.
bool usesMetadata() const
If set, appropriate metadata tables must be emitted by the back-end (assembler, JIT, or otherwise).
bool hasGlobalUnnamedAddr() const
void emitInt32(int Value) const
Emit a long directive and value.
void print(raw_ostream &OS, bool isSigned) const
MachineDominatorTree * MDT
This is a pointer to the current MachineLoopInfo.
unsigned pred_size() const
bool isLayoutSuccessor(const MachineBasicBlock *MBB) const
Return true if the specified MBB will be emitted immediately after this block, such that if this bloc...
const Function & getFunction() const
Return the LLVM function that this machine code represents.
Collects and handles line tables information in a CodeView format.
bool needsUnwindTableEntry() const
True if this function needs an unwind table.
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
This file contains constants used for implementing Dwarf debug support.
bool isDefined() const
isDefined - Check if this symbol is defined (i.e., it has an address).
Target - Wrapper for Target specific information.
Class for arbitrary precision integers.
ConstantArray - Constant Array Declarations.
union llvm::MachineConstantPoolEntry::@159 Val
The constant itself.
static StringRef dropLLVMManglingEscape(StringRef Name)
If the given string begins with the GlobalValue name mangling escape character '\1', drop it.
virtual void EmitFunctionBodyStart()
Targets can override this to emit stuff before the first basic block in the function.
MCSymbol * getCurExceptionSym()
LinkageTypes
An enumeration for the kinds of linkage for global values.
unsigned getEntrySize(const DataLayout &TD) const
getEntrySize - Return the size of each entry in the jump table.
void setPreservesAll()
Set by analyses that do not transform their input at all.
iterator_range< user_iterator > users()
unsigned getNumElements() const
ArrayType * getType() const
Specialize the getType() method to always return an ArrayType, which reduces the amount of casting ne...
MCSubtargetInfo * createMCSubtargetInfo(StringRef TheTriple, StringRef CPU, StringRef Features) const
createMCSubtargetInfo - Create a MCSubtargetInfo implementation.
FunctionNumber(functionNumber)
const MachineBasicBlock * getParent() const
MachineModuleInfoELF - This is a MachineModuleInfoImpl implementation for ELF targets.
TargetSubtargetInfo - Generic base class for all target subtargets.
static bool emitDebugLabelComment(const MachineInstr *MI, AsmPrinter &AP)
This method handles the target-independent form of DBG_LABEL, returning true if it was able to do so...
Iterators for registry entries.
virtual void EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV)
const uint64_t * getRawData() const
This function returns a pointer to the internal storage of the APInt.
const Comdat * getComdat() const
uint64_t getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
LoopT * getParentLoop() const
MachineLoopInfo * MLI
This is a pointer to the current MachineLoopInfo.
Representation of each machine instruction.
static const char *const CFGuardName
static void emitGlobalConstantImpl(const DataLayout &DL, const Constant *C, AsmPrinter &AP, const Constant *BaseCV=nullptr, uint64_t Offset=0)
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
bool doInitialization(Module &M) override
Set up the AsmPrinter when we are working on a new module.
GCStrategy describes a garbage collector algorithm's code generation requirements, and provides overridable hooks for those needs which cannot be abstractly described.
void SetupMachineFunction(MachineFunction &MF)
This should be called when a new MachineFunction is being processed from runOnMachineFunction.
virtual bool hasStoreToStackSlot(const MachineInstr &MI, SmallVectorImpl< const MachineMemOperand *> &Accesses) const
If the specified machine instruction has a store to a stack slot, return true along with the FrameInd...
bool isFunctionTy() const
True if this is an instance of FunctionType.
MCSymbol * GetJTISymbol(unsigned JTID, bool isLinkerPrivate=false) const
Return the symbol for the specified jump table entry.
virtual unsigned isLoadFromStackSlotPostFE(const MachineInstr &MI, int &FrameIndex) const
Check for post-frame ptr elimination stack locations as well.
uint64_t getElementOffset(unsigned Idx) const
SequentialType * getType() const
Specialize the getType() method to always return a SequentialType, which reduces the amount of castin...
APFloat getElementAsAPFloat(unsigned i) const
If this is a sequential container of floating point type, return the specified element as an APFloat...
StringRef filename(StringRef path, Style style=Style::native)
Get filename.
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
iterator begin() const
begin/end - Iterators for used strategies.
void print(raw_ostream &O, bool IsForDebug=false, bool NoDetails=false) const
Print the current type.
bool isEHPad() const
Returns true if the block is a landing pad.
Represents a single loop in the control flow graph.
bool isPositionIndependent() const
bool isEHFuncletEntry() const
Returns true if this is the entry block of an EH funclet.
virtual void EmitBasicBlockStart(const MachineBasicBlock &MBB) const
Targets can override this to emit stuff at the start of a basic block.
VectorType * getType() const
Specialize the getType() method to always return a VectorType, which reduces the amount of casting ne...
.type _foo, STT_FUNC # aka
MCSymbol * GetJTSetSymbol(unsigned UID, unsigned MBBID) const
Return the symbol for the specified jump table .set FIXME: privatize to AsmPrinter.
StringRef getName() const
Return a constant reference to the value's name.
virtual ~AsmPrinterHandler()
Pin vtable to this file.
MCSymbol * getSymbol() const
Return the MCSymbol for this basic block.
static unsigned getNumGlobalVariableUses(const Constant *C)
Compute the number of Global Variables that uses a Constant.
bool hasInlineAsm() const
Returns true if the function contains any inline assembly.
static bool emitComments(const MachineInstr &MI, raw_ostream &CommentOS, AsmPrinter *AP)
emitComments - Pretty-print comments for instructions.
virtual const TargetFrameLowering * getFrameLowering() const
bool isFI() const
isFI - Tests if this is a MO_FrameIndex operand.
Generic base class for all target subtargets.
SectionKind getSectionKind(const DataLayout *DL) const
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
static gcp_map_type & getGCMap(void *&P)
static const MCBinaryExpr * createMod(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
void EmitLabelDifference(const MCSymbol *Hi, const MCSymbol *Lo, unsigned Size) const
Emit something like ".long Hi-Lo" where the size in bytes of the directive is specified by Size and H...
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
static const char *const CFGuardDescription
Keep one copy of named function when linking (weak)
Rename collisions when linking (static functions).
const Constant * getIndirectSymbol() const
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
static unsigned getGVAlignmentLog2(const GlobalValue *GV, const DataLayout &DL, unsigned InBits=0)
getGVAlignmentLog2 - Return the alignment to use for the specified global value in log2 form...
virtual void EmitFunctionEntryLabel()
EmitFunctionEntryLabel - Emit the label that is the entrypoint for the function.
const Module * getModule() const
bool isReg() const
isReg - Tests if this is a MO_Register operand.
std::vector< std::pair< MCSymbol *, StubValueTy > > SymbolListTy
const std::string & getModuleInlineAsm() const
Get any module-scope inline assembly blocks.
const GlobalObject * getBaseObject() const
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
StringRef getName() const
getName - Get the symbol name.
unsigned getCodePointerSize() const
Get the code pointer size in bytes.
DILocalScope * getScope() const
Get the local scope for this label.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
A raw_ostream that writes to an std::string.
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags)
virtual bool supportPrintSchedInfo() const
Support printing of [latency:throughput] comment in output .S file.
MCSymbol * getMCSymbol() const
void EmitGlobalConstant(const DataLayout &DL, const Constant *CV)
Print a general LLVM constant to the .s file.
void emitInt8(int Value) const
Emit a byte directive and value.
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
Constant * getPersonalityFn() const
Get the personality function associated with this function.
JTEntryKind getEntryKind() const
uint64_t getTypeStoreSize(Type *Ty) const
Returns the maximum number of bytes that may be overwritten by storing the specified type...
bool isThreadLocal() const
bool hasInitializer() const
Definitions have initializers, declarations don't.
MachineLoop * getLoopFor(const MachineBasicBlock *BB) const
Return the innermost loop that BB lives in.
Windows CE ARM, PowerPC, SH3, SH4.
static const char *const DbgTimerName
const DILocalVariable * getDebugVariable() const
Return the debug variable referenced by this DBG_VALUE instruction.
ExceptionHandling getExceptionHandlingType() const
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
This class implements an extremely fast bulk output stream that can only output to a stream...
Primary interface to the complete machine description for the target machine.
uint64_t getTypeAllocSizeInBits(Type *Ty) const
Returns the offset in bits between successive objects of the specified type, including alignment padd...
MCSymbol * CurrentFnSymForSize
The symbol used to represent the start of the current function for the purpose of calculating its siz...
void getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV, bool CannotUsePrivateLabel) const
Print the appropriate prefix and the specified global variable's name.
const DataLayout & getDataLayout() const
Return information about data layout.
Type * getElementType() const
bool isThreadLocal() const
If the value is "Thread Local", its value isn't shared by the threads.
virtual MCSection * getSectionForJumpTable(const Function &F, const TargetMachine &TM) const
iterator_range< global_iterator > globals()
MachineOptimizationRemarkEmitter * ORE
Optimization remark emitter.
bool hasOneUse() const
Return true if there is exactly one user of this value.
StringRef - Represent a constant reference to a string, i.e.
EK_GPRel32BlockAddress - Each entry is an address of block, encoded with a relocation as gp-relative...
APInt bitcastToAPInt() const
static SectionKind getKindForGlobal(const GlobalObject *GO, const TargetMachine &TM)
Classify the specified global variable into a set of target independent categories embodied in Sectio...
void setAsmPrinterFlag(uint8_t Flag)
Set a flag for the AsmPrinter.
unsigned getNumElements() const
Return the number of elements in the array or vector.
bool TimePassesIsEnabled
If the user specifies the -time-passes argument on an LLVM tool command line then the value of this b...
const MCSection * getCurrentSection() const
Return the current section we are emitting to.
unsigned getOpcode() const
MCSymbol * getSymbolWithGlobalValueBase(const GlobalValue *GV, StringRef Suffix) const
Return the MCSymbol for a private symbol with global value name as its base, with the specified suffi...
DILocalScope * getScope() const
Get the local scope for this variable.
VersionTuple getSDKVersion() const
Get the build SDK version metadata.
unsigned getNumOperands() const
Return number of MDNode operands.
void emit(int, MCStreamer *, const MCSymbol *) const
const MachineJumpTableInfo * getJumpTableInfo() const
getJumpTableInfo - Return the jump table info object for the current function.
const MachineOperand & getOperand(unsigned i) const
const ConstantInt * getCImm() const
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
bool isNoOpWithoutInvoke(EHPersonality Pers)
Return true if this personality may be safely removed if there are no invoke instructions remaining i...
MCSymbolAttr getHiddenDeclarationVisibilityAttr() const
DomTreeBase< MachineBasicBlock > & getBase()
static SectionKind getReadOnly()
MCSymbol * createTempSymbol(const Twine &Name) const
MCSymbolAttr getProtectedVisibilityAttr() const
StructType * getType() const
Specialization - reduce amount of casting.
uint64_t getStackSize() const
Return the number of bytes that must be allocated to hold all of the fixed size frame objects...
void emitStackSizeSection(const MachineFunction &MF)
virtual const MCExpr * getPICJumpTableRelocBaseExpr(const MachineFunction *MF, unsigned JTI, MCContext &Ctx) const
This returns the relocation base for the given PIC jumptable, the same as getPICJumpTableRelocBase, but as an MCExpr.
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx)
Type * getElementType() const
PointerType * getType() const
Global values are always pointers.
bool isSpillSlotObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a spill slot.
bool supportIndirectSymViaGOTPCRel() const
Target supports replacing a data "PC"-relative access to a symbol through another symbol...
void emitInt16(int Value) const
Emit a short directive and value.
This class contains meta information specific to a module.
This file describes how to lower LLVM code to machine code.
Type * getTypeAtIndex(const Value *V) const
Given an index value into the type, return the type of the element.
bool isString(unsigned CharSize=8) const
This method returns true if this is an array of CharSize integers.
MCSubtargetInfo & getSubtargetCopy(const MCSubtargetInfo &STI)