58 #define DEBUG_TYPE "asm-printer"
68 "CodeView Line Tables";
70 STATISTIC(EmittedInsts,
"Number of machine instrs printed");
72 char AsmPrinter::ID = 0;
86 unsigned InBits = 0) {
110 OutContext(Streamer->getContext()), OutStreamer(std::move(Streamer)),
111 isCFIMoveForDebugging(
false), LastMI(nullptr), LastFn(0),
Counter(~0U) {
117 CurrentFnBegin =
nullptr;
118 CurrentFnEnd =
nullptr;
119 GCMetadataPrinters =
nullptr;
124 assert(!DD && Handlers.
empty() &&
"Debug/EH info didn't get finalized");
126 if (GCMetadataPrinters) {
130 GCMetadataPrinters =
nullptr;
157 assert(
MF &&
"getSubtargetInfo requires a valid MachineFunction!");
180 MMI = getAnalysisIfAvailable<MachineModuleInfo>();
199 unsigned Major, Minor, Update;
216 OutStreamer->EmitVersionMin(VersionType, Major, Minor, Update);
230 assert(MI &&
"AsmPrinter didn't require GCModuleInfo?");
233 MP->beginAssembly(M, *MI, *
this);
242 OutStreamer->AddComment(
"Start of file scope inline assembly");
246 OutStreamer->AddComment(
"End of file scope inline assembly");
271 isCFIMoveForDebugging =
true;
278 if (!
F.isDeclarationForLinker() &&
F.needsUnwindTableEntry()) {
279 isCFIMoveForDebugging =
false;
285 isCFIMoveForDebugging =
false;
379 "No emulated TLS variables in the common section");
419 "' is already defined");
434 for (
const HandlerInfo &
HI : Handlers) {
436 HI.TimerGroupName,
HI.TimerGroupDescription,
438 HI.Handler->setSymbolSize(GVSym, Size);
443 if (Size == 0) Size = 1;
444 unsigned Align = 1 << AlignLog;
462 unsigned Align = 1 << AlignLog;
463 EmitLinkage(GV, GVSym);
465 OutStreamer->EmitZerofill(TheSection, GVSym, Size, Align);
475 unsigned Align = 1 << AlignLog;
485 OutStreamer->EmitLocalCommonSymbol(GVSym, Size, Align);
516 OutStreamer->EmitTBSSSymbol(TheSection, MangSym, Size, 1 << AlignLog);
534 EmitLinkage(GV, GVSym);
555 EmitLinkage(GV, EmittedInitSym);
575 unsigned Size)
const {
581 void AsmPrinter::EmitFunctionHeader() {
615 std::vector<MCSymbol*> DeadBlockSyms;
617 for (
unsigned i = 0, e = DeadBlockSyms.size();
i != e; ++
i) {
618 OutStreamer->AddComment(
"Address taken block that was later removed");
622 if (CurrentFnBegin) {
634 for (
const HandlerInfo &
HI : Handlers) {
637 HI.Handler->beginFunction(
MF);
654 "' is a protected alias");
657 "' label emitted multiple times to assembly file");
678 CommentOS << MMO->
getSize() <<
"-byte Reload\n";
682 CommentOS << MMO->
getSize() <<
"-byte Folded Reload\n";
686 CommentOS << MMO->
getSize() <<
"-byte Spill\n";
690 CommentOS << MMO->
getSize() <<
"-byte Folded Spill\n";
695 CommentOS <<
" Reload Reuse\n";
705 OS <<
"implicit-def: "
718 assert(Op.
isReg() &&
"KILL instruction must have only register operands");
722 << (Op.
isDef() ?
"<def>" :
"<kill>");
738 OS <<
"DEBUG_VALUE: ";
741 if (
auto *SP = dyn_cast<DISubprogram>(V->
getScope())) {
751 OS <<
" [fragment offset=" << Fragment->OffsetInBits
752 <<
" size=" << Fragment->SizeInBits <<
"]";
767 OS <<
" [complex expression]";
770 }
else if (Op == dwarf::DW_OP_deref) {
776 if (Op == dwarf::DW_OP_plus)
777 Offset += ExtraOffset;
779 assert(Op == dwarf::DW_OP_minus);
780 Offset -= ExtraOffset;
827 OS <<
'+' << Offset <<
']';
877 EmitFunctionHeader();
885 bool HasAnyRealCode =
false;
886 for (
auto &
MBB : *
MF) {
889 for (
auto &
MI :
MBB) {
892 if (!
MI.isPosition() && !
MI.isImplicitDef() && !
MI.isKill() &&
893 !
MI.isDebugValue()) {
894 HasAnyRealCode =
true;
898 if (ShouldPrintDebugScopes) {
899 for (
const HandlerInfo &
HI : Handlers) {
901 HI.TimerGroupName,
HI.TimerGroupDescription,
903 HI.Handler->beginInstruction(&
MI);
910 switch (
MI.getOpcode()) {
911 case TargetOpcode::CFI_INSTRUCTION:
915 case TargetOpcode::LOCAL_ESCAPE:
920 case TargetOpcode::GC_LABEL:
926 case TargetOpcode::DBG_VALUE:
932 case TargetOpcode::IMPLICIT_DEF:
943 if (ShouldPrintDebugScopes) {
944 for (
const HandlerInfo &
HI : Handlers) {
946 HI.TimerGroupName,
HI.TimerGroupDescription,
948 HI.Handler->endInstruction();
961 MF->getSubtarget().getInstrInfo()->getNoopForMachoTarget(Noop);
962 OutStreamer->AddComment(
"avoids zero-length function");
970 const Function *F = MF->getFunction();
971 for (
const auto &BB : *F) {
972 if (!BB.hasAddressTaken())
977 OutStreamer->AddComment(
"Address of block that was removed by CodeGen");
1002 for (
const HandlerInfo &
HI : Handlers) {
1005 HI.Handler->markFunctionEnd();
1012 for (
const HandlerInfo &
HI : Handlers) {
1015 HI.Handler->endFunction(MF);
1026 if (isa<GlobalVariable>(C))
1029 unsigned NumUses = 0;
1030 for (
auto *CU : C->
users())
1042 unsigned &NumGOTEquivUsers) {
1053 for (
auto *U : GV->
users())
1056 return NumGOTEquivUsers > 0;
1070 for (
const auto &
G : M.
globals()) {
1071 unsigned NumGOTEquivUsers = 0;
1090 unsigned Cnt =
I.second.second;
1094 GlobalGOTEquivs.clear();
1096 for (
auto *GV : FailedCandidates)
1100 void AsmPrinter::emitGlobalIndirectSymbol(
Module &M,
1115 if (isa<GlobalIFunc>(GIS))
1123 if (isa<GlobalAlias>(&GIS) &&
MAI->
hasAltEntry() && isa<MCBinaryExpr>(Expr))
1129 if (
auto *GA = dyn_cast<GlobalAlias>(&GIS)) {
1173 EmitVisibility(Name, V,
false);
1180 M.getModuleFlagsMetadata(ModuleFlags);
1181 if (!ModuleFlags.
empty())
1189 if (!Stubs.empty()) {
1193 for (
const auto &Stub : Stubs) {
1195 OutStreamer->EmitSymbolValue(Stub.second.getPointer(),
1202 for (
const HandlerInfo &
HI : Handlers) {
1205 HI.Handler->endModule();
1219 for (
const auto &GO : M.global_objects()) {
1220 if (!GO.hasExternalWeakLinkage())
1234 for (
const auto &Alias : M.aliases()) {
1237 if (!AliasVisited.
insert(Cur).second)
1242 emitGlobalIndirectSymbol(M, *AncestorAlias);
1245 for (
const auto &IFunc : M.ifuncs())
1246 emitGlobalIndirectSymbol(M, IFunc);
1249 assert(MI &&
"AsmPrinter didn't require GCModuleInfo?");
1252 MP->finishAssembly(M, *MI, *
this);
1255 EmitModuleIdents(M);
1269 unsigned PtrSize = M.getDataLayout().getPointerSize(0);
1276 Function *InitTrampolineIntrinsic = M.getFunction(
"llvm.init.trampoline");
1277 if (!InitTrampolineIntrinsic || InitTrampolineIntrinsic->
use_empty())
1294 if (!CurExceptionSym)
1296 return CurExceptionSym;
1304 CurrentFnBegin =
nullptr;
1305 CurExceptionSym =
nullptr;
1310 if (NeedsLocalForSize)
1311 CurrentFnSymForSize = CurrentFnBegin;
1315 LI = &getAnalysis<MachineLoopInfo>();
1324 SectionCPs(
MCSection *s,
unsigned a) : S(s), Alignment(a) {}
1335 const std::vector<MachineConstantPoolEntry> &
CP = MCP->
getConstants();
1336 if (CP.empty())
return;
1341 for (
unsigned i = 0, e = CP.size();
i != e; ++
i) {
1357 unsigned SecIdx = CPSections.
size();
1358 while (SecIdx != 0) {
1359 if (CPSections[--SecIdx].S == S) {
1365 SecIdx = CPSections.
size();
1366 CPSections.
push_back(SectionCPs(S, Align));
1369 if (Align > CPSections[SecIdx].Alignment)
1370 CPSections[SecIdx].Alignment = Align;
1377 for (
unsigned i = 0, e = CPSections.
size();
i != e; ++
i) {
1378 for (
unsigned j = 0, ee = CPSections[
i].CPEs.
size(); j != ee; ++j) {
1379 unsigned CPI = CPSections[
i].CPEs[j];
1384 if (CurSection != CPSections[
i].S) {
1387 CurSection = CPSections[
i].S;
1395 unsigned NewOffset = (Offset + AlignMask) & ~AlignMask;
1419 if (JT.empty())
return;
1428 if (JTInDiffSection) {
1438 if (!JTInDiffSection)
1441 for (
unsigned JTI = 0, e = JT.size(); JTI != e; ++JTI) {
1442 const std::vector<MachineBasicBlock*> &JTBBs = JT[JTI].MBBs;
1445 if (JTBBs.empty())
continue;
1454 for (
unsigned ii = 0, ee = JTBBs.size(); ii != ee; ++ii) {
1456 if (!EmittedSets.
insert(MBB).second)
1479 for (
unsigned ii = 0, ee = JTBBs.size(); ii != ee; ++ii)
1480 EmitJumpTableEntry(MJTI, JTBBs[ii], JTI);
1482 if (!JTInDiffSection)
1490 unsigned UID)
const {
1544 assert(Value &&
"Unknown entry kind!");
1555 if (GV->
getName() ==
"llvm.used") {
1570 if (GV->
getName() ==
"llvm.global_ctors") {
1577 if (GV->
getName() ==
"llvm.global_dtors") {
1590 void AsmPrinter::EmitLLVMUsedList(
const ConstantArray *InitList) {
1602 Structor() : Priority(0),
Func(nullptr), ComdatKey(nullptr) {}
1615 if (!isa<ConstantArray>(List))
return;
1619 if (!InitList)
return;
1631 for (Value *O : InitList->
operands()) {
1637 if (!Priority)
continue;
1639 Structor &S = Structors.
back();
1649 std::stable_sort(Structors.
begin(), Structors.
end(),
1650 [](
const Structor &
L,
1651 const Structor &R) {
return L.Priority < R.Priority; });
1652 for (Structor &S : Structors) {
1673 void AsmPrinter::EmitModuleIdents(
Module &M) {
1678 for (
unsigned i = 0, e = NMD->getNumOperands();
i != e; ++
i) {
1679 const MDNode *
N = NMD->getOperand(
i);
1681 "llvm.ident metadata entry can have only one operand");
1714 unsigned Size)
const {
1715 OutStreamer->emitAbsoluteSymbolDiff(Hi, Lo, Size);
1723 bool IsSectionRelative)
const {
1752 if (NumBits == 0)
return;
1755 static_cast<unsigned>(std::numeric_limits<unsigned>::digits) &&
1756 "undefined behavior");
1773 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(CV))
1776 if (
const GlobalValue *GV = dyn_cast<GlobalValue>(CV))
1779 if (
const BlockAddress *BA = dyn_cast<BlockAddress>(CV))
1800 OS <<
"Unsupported expression in static initializer: ";
1805 case Instruction::GetElementPtr: {
1808 cast<GEPOperator>(CE)->accumulateConstantOffset(
getDataLayout(), OffsetAI);
1819 case Instruction::Trunc:
1825 case Instruction::BitCast:
1828 case Instruction::IntToPtr: {
1839 case Instruction::PtrToInt: {
1862 case Instruction::Sub: {
1871 const MCExpr *RelocExpr =
1877 int64_t Addend = (LHSOffset - RHSOffset).getSExtValue();
1890 case Instruction::Mul:
1891 case Instruction::SDiv:
1892 case Instruction::SRem:
1893 case Instruction::Shl:
1927 assert(!Data.
empty() &&
"Empty aggregates should be CAZ node");
1929 for (
unsigned i = 1, e = Data.
size();
i != e; ++
i)
1930 if (Data[
i] != C)
return -1;
1931 return static_cast<uint8_t
>(
C);
1939 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(V)) {
1953 assert(CA->getNumOperands() != 0 &&
"Should be a CAZ");
1960 for (
unsigned i = 1, e = CA->getNumOperands();
i != e; ++
i)
1961 if (CA->getOperand(
i) != Op0)
2007 if (
unsigned Padding = Size - EmittedSize)
2039 if (
unsigned Padding = Size - EmittedSize)
2049 uint64_t SizeSoFar = 0;
2060 SizeSoFar += FieldSize + PadSize;
2068 "Layout of constant struct may be incorrect!");
2083 AP.
OutStreamer->GetCommentOS() <<
"Printing <null> Type";
2084 AP.
OutStreamer->GetCommentOS() <<
' ' << StrVal <<
'\n';
2091 unsigned TrailingBytes = NumBytes %
sizeof(uint64_t);
2100 AP.
OutStreamer->EmitIntValue(p[Chunk--], TrailingBytes);
2102 for (; Chunk >= 0; --Chunk)
2103 AP.
OutStreamer->EmitIntValue(p[Chunk],
sizeof(uint64_t));
2106 for (Chunk = 0; Chunk < NumBytes /
sizeof(uint64_t); ++Chunk)
2107 AP.
OutStreamer->EmitIntValue(p[Chunk],
sizeof(uint64_t));
2110 AP.
OutStreamer->EmitIntValue(p[Chunk], TrailingBytes);
2126 uint64_t ExtraBits = 0;
2127 unsigned ExtraBitsSize = BitWidth & 63;
2129 if (ExtraBitsSize) {
2146 ExtraBits = Realigned.getRawData()[0] &
2147 (((uint64_t)-1) >> (64 - ExtraBitsSize));
2148 Realigned = Realigned.lshr(ExtraBitsSize);
2150 ExtraBits = Realigned.getRawData()[BitWidth / 64];
2156 const uint64_t *RawData = Realigned.getRawData();
2157 for (
unsigned i = 0, e = BitWidth / 64;
i != e; ++
i) {
2158 uint64_t Val = DL.
isBigEndian() ? RawData[e -
i - 1] : RawData[
i];
2162 if (ExtraBitsSize) {
2167 Size -= (BitWidth / 64) * 8;
2168 assert(Size && Size * 8 >= ExtraBitsSize &&
2169 (ExtraBits & (((uint64_t)-1) >> (64 - ExtraBitsSize)))
2170 == ExtraBits &&
"Directive too small for extra bits.");
2203 if (!(*ME)->evaluateAsRelocatable(MV,
nullptr,
nullptr) || MV.
isAbsolute())
2214 const GlobalValue *BaseGV = dyn_cast_or_null<GlobalValue>(BaseCst);
2222 if (!SymB || BaseSym != &SymB->
getSymbol())
2234 if (GOTPCRelCst < 0)
2257 int NumUses = (int)Result.second;
2278 BaseCV = dyn_cast<Constant>(CV->
user_back());
2280 if (isa<ConstantAggregateZero>(CV) || isa<UndefValue>(CV))
2283 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
2291 CI->getZExtValue());
2292 AP.
OutStreamer->EmitIntValue(CI->getZExtValue(), Size);
2300 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(CV))
2303 if (isa<ConstantPointerNull>(CV)) {
2317 if (
const ConstantExpr *CE = dyn_cast<ConstantExpr>(CV)) {
2320 if (CE->getOpcode() == Instruction::BitCast)
2328 if (New && New != CE)
2369 else if (Offset < 0)
2431 <<
"Parent Loop BB" << FunctionNumber <<
"_"
2443 OS.
indent(CL->getLoopDepth()*2)
2444 <<
"Child Loop BB" << FunctionNumber <<
"_"
2445 << CL->getHeader()->getNumber() <<
" Depth " << CL->getLoopDepth()
2460 assert(Header &&
"No header for loop");
2464 if (Header != &MBB) {
2465 AP.
OutStreamer->AddComment(
" in Loop: Header=BB" +
2496 for (
const HandlerInfo &
HI : Handlers) {
2497 HI.Handler->endFunclet();
2498 HI.Handler->beginFunclet(MBB);
2525 if (BB->hasName()) {
2527 false, BB->getModule());
2547 bool IsDefinition)
const {
2550 switch (Visibility) {
2593 if (!
MI.isBranch() ||
MI.isIndirectBranch())
2602 if (
OP->isMBB() &&
OP->getMBB() ==
MBB)
2617 " stackmap formats, please see the documentation for a description of"
2618 " the default format. If you really need a custom serialized format,"
2619 " please file a bug");
2623 if (GCPI != GCMap.end())
2624 return GCPI->second.get();
2631 if (Name ==
I->getName()) {
2632 std::unique_ptr<GCMetadataPrinter> GMP =
I->instantiate();
2634 auto IterBool = GCMap.insert(std::make_pair(&S, std::move(GMP)));
2635 return IterBool.first->second.get();
2650 const MCSymbol *CurrentFnSym)
const {
2653 auto Kind8 =
static_cast<uint8_t
>(
Kind);
2664 auto PrevSection =
OutStreamer->getCurrentSectionOnly();
2668 if (Fn->hasComdat()) {
2671 Fn->getComdat()->getName());
2691 OutStreamer->EmitSymbolValue(Tmp, WordSizeBytes,
false);
2694 for (
const auto &Sled :
Sleds)
2705 bool AlwaysInstrument =
2712 return OutStreamer->getContext().getDwarfVersion();
2716 OutStreamer->getContext().setDwarfVersion(Version);
std::vector< XRayFunctionEntry > Sleds
virtual void EmitGlobalVariable(const GlobalVariable *GV)
Emit the specified global variable to the .s file.
void setDwarfVersion(uint16_t Version)
MachineConstantPoolValue * MachineCPVal
Instances of this class represent a uniqued identifier for a section in the current translation unit...
bool usesMetadata() const
If set, appropriate metadata tables must be emitted by the back-end (assembler, JIT, or otherwise).
void push_back(const T &Elt)
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
virtual void EmitStartOfAsmFile(Module &)
This virtual method can be overridden by targets that want to emit something at the start of their fi...
bool isEHPad() const
Returns true if the block is a landing pad.
bool doesSupportDebugInformation() const
A parsed version of the target data layout string in and methods for querying it. ...
bool useAssignmentForEHBegin() const
static void emitGlobalConstantLargeInt(const ConstantInt *CI, AsmPrinter &AP)
LinkageTypes getLinkage() const
IntegerType * getType() const
getType - Specialize the getType() method to always return an IntegerType, which reduces the amount o...
The MachineConstantPool class keeps track of constants referenced by a function which must be spilled...
unsigned getAlignment() const
getAlignment - Return the alignment (log2, not bytes) of the function.
SectionKind getSectionKind(const DataLayout *DL) const
StringRef getPrivateGlobalPrefix() const
StringRef getTargetCPU() const
Special purpose, only applies to global arrays.
VisibilityTypes getVisibility() const
unsigned getOSMajorVersion() const
getOSMajorVersion - Return just the major version number, this is specialized because it is a common ...
bool isOSBinFormatMachO() const
Tests whether the environment is MachO.
Constant * getPrologueData() const
Get the prologue data associated with this function.
static void emitBasicBlockLoopComments(const MachineBasicBlock &MBB, const MachineLoopInfo *LI, const AsmPrinter &AP)
emitBasicBlockLoopComments - Pretty-print comments for basic blocks.
uint64_t getZExtValue() const
Get zero extended value.
bool hasIdentDirective() const
bool needsLocalForSize() const
const MCSymbol & getSymbol() const
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
void getNameWithPrefix(SmallVectorImpl< char > &Name, const GlobalValue *GV, Mangler &Mang, bool MayAlwaysUsePrivate=false) const
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
MCSymbol * getSymbol(const GlobalValue *GV) const
static const char *const DbgTimerDescription
MCTargetOptions MCOptions
Machine level options.
STATISTIC(NumFunctions,"Total number of functions")
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
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.
.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...
WinEH::EncodingType getWinEHEncodingType() const
const ConstantFP * getFPImm() const
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
A Module instance is used to store all the information related to an LLVM module. ...
void redefineIfPossible()
Prepare this symbol to be redefined.
float convertToFloat() const
const DataLayout & getDataLayout() const
Return information about data layout.
bool doFinalization(Module &M) override
Shut down the asmprinter.
void EmitInt8(int Value) const
Emit a byte directive and value.
Same, but only replaced by something equivalent.
static void emitGlobalConstantDataSequential(const DataLayout &DL, const ConstantDataSequential *CDS, AsmPrinter &AP)
MCContext & OutContext
This is the context for the output file that we are streaming.
MCSymbol * getSymbol(const GlobalValue *GV) const
bool canBeOmittedFromSymbolTable(const GlobalValue *GV)
void print(raw_ostream &OS, bool isSigned) const
uint64_t getElement(unsigned I) const
DILocalScope * getScope() const
Get the local scope for this variable.
unsigned getBitWidth() const
getBitWidth - Return the bitwidth of this constant.
void getWatchOSVersion(unsigned &Major, unsigned &Minor, unsigned &Micro) const
getWatchOSVersion - Parse the version number as with getOSVersion.
unsigned getNumOperands() const
Available for inspection, not emission.
unsigned getNumOperands() const
Return number of MDNode operands.
DWARF-like instruction based exceptions.
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...
virtual void EmitBytes(StringRef Data)
Emit the bytes in Data into the output.
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...
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...
Constant * getElementAsConstant(unsigned i) const
Return a Constant for a specified index's element.
Collects and handles dwarf debug information.
bool hasAppendingLinkage() 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.
unsigned getPointerPrefAlignment(unsigned AS=0) const
Return target's alignment for stack-based pointers FIXME: The defaults need to be removed once all of...
const MachineFunction * MF
The current machine function.
raw_ostream & indent(unsigned NumSpaces)
indent - Insert 'NumSpaces' spaces.
const std::vector< LandingPadInfo > & getLandingPads() const
Return a reference to the landing pad info for the current function.
Like Internal, but omit from symbol table.
virtual void EmitDebugValue(const MCExpr *Value, unsigned Size) const
Emit the directive and value for debug thread local expression.
Externally visible function.
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
bool hasAvailableExternallyLinkage() const
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.
static const char *const DWARFGroupName
A raw_ostream that writes to an SmallVector or SmallString.
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...
virtual void EmitConstantPool()
Print to the current output stream assembly representations of the constants in the constant pool MCP...
MCSection * getDataSection() const
LoopT * getParentLoop() const
unsigned getFunctionNumber() const
Return a unique ID for the current function.
const std::string & str() const
bool hasPrologueData() const
Check whether this function has prologue data.
static const MCBinaryExpr * createAnd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
void EmitInt32(int Value) const
Emit a long directive and value.
const Function * getFunction() const
getFunction - Return the LLVM function that this machine code represents
setjmp/longjmp based exceptions
const char * getWeakRefDirective() const
ELFYAML::ELF_STV Visibility
LCOMM::LCOMMType getLCOMMDirectiveAlignmentType() const
bool supportGOTPCRelWithOffset() const
Target GOT "PC"-relative relocation supports encoding an additional binary expression with an offset...
const MCSubtargetInfo & getSubtargetInfo() const
Return information about subtarget.
static const MCBinaryExpr * createMul(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Type * getElementType() const
unsigned getFunctionNumber() const
getFunctionNumber - Return a unique ID for the current function.
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
static void emitKill(const MachineInstr *MI, AsmPrinter &AP)
static const char *const DWARFGroupDescription
bool hasLinkOnceDirective() const
std::vector< std::pair< MCSymbol *, StubValueTy > > SymbolListTy
APInt zextOrTrunc(unsigned width) const
Zero extend or truncate to width.
unsigned getOpcode() const
Return the opcode at the root of this constant expression.
virtual void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI)
Emit the given Instruction into the current section.
BlockT * getHeader() const
void getNameWithPrefix(SmallVectorImpl< char > &Name, const GlobalValue *GV) const
Type * getPointerElementType() const
uint64_t getTypeAllocSizeInBits(Type *Ty) const
Returns the offset in bits between successive objects of the specified type, including alignment padd...
StringRef getName() const
Return a constant reference to the value's name.
bool hasMachoTBSSDirective() const
const Triple & getTargetTriple() const
unsigned getPointerTypeSize(Type *Ty) const
MCSymbolAttr getHiddenVisibilityAttr() const
bool isMacOSX() const
isMacOSX - Is this a Mac OS X triple.
MCSubtargetInfo * createMCSubtargetInfo(StringRef TheTriple, StringRef CPU, StringRef Features) const
createMCSubtargetInfo - Create a MCSubtargetInfo implementation.
const std::vector< MachineJumpTableEntry > & getJumpTables() const
The address of a basic block.
static const MCBinaryExpr * createXor(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
AnalysisUsage & addRequired()
Used to lazily calculate structure layout information for a target machine, based on the DataLayout s...
static void emitGlobalConstantFP(const ConstantFP *CFP, AsmPrinter &AP)
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.
bool getAsmPrinterFlag(CommentFlag Flag) const
Return whether an AsmPrinter flag is set.
Emits exception handling directives.
bool hasCommonLinkage() const
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
bool hasWeakDefDirective() const
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
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.
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
const StructLayout * getStructLayout(StructType *Ty) const
Returns a StructLayout object, indicating the alignment of the struct, its size, and the offsets of i...
unsigned getCFIIndex() const
static void emitGlobalConstantStruct(const DataLayout &DL, const ConstantStruct *CS, AsmPrinter &AP, const Constant *BaseCV, uint64_t Offset)
const APInt & getValue() const
Return the constant as an APInt value reference.
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...
Class to represent struct types.
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
This class is basically a combination of TimeRegion and Timer.
void toString(SmallVectorImpl< char > &Str, unsigned FormatPrecision=0, unsigned FormatMaxPadding=3) const
static const MCBinaryExpr * createDiv(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
bool isReg() const
isReg - Tests if this is a MO_Register operand.
Base class for the full range of assembler expressions which are needed for parsing.
virtual TargetLoweringObjectFile * getObjFileLowering() const
bool hasAddressTaken() const
Returns true if there are any uses of this basic block other than direct branches, switches, etc.
const Module * getModule() const
Reg
All possible values of the reg field in the ModR/M byte.
iterator_range< iterator > terminators()
APInt bitcastToAPInt() const
MCSymbol * GetJTISymbol(unsigned JTID, bool isLinkerPrivate=false) const
Return the symbol for the specified jump table entry.
Represent a reference to a symbol from inside an expression.
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
bool hasMachoZeroFillDirective() const
Only used in LLVM metadata.
uint16_t getDwarfVersion() const
An analysis pass which caches information about the entire Module.
bool hasDebugInfo() const
Returns true if valid debug info is present.
StringRef getName() const
const std::string & getModuleIdentifier() const
Get the module identifier which is, essentially, the name of the module.
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
bool hasPrivateLinkage() const
INLINEASM - Represents an inline asm block.
bool isSplat(unsigned SplatSizeInBits) const
Check if the APInt consists of a repeated bit pattern.
LLVM_NODISCARD bool empty() const
unsigned getNumOperands() const
Access to explicit operands of the instruction.
static const char *const CodeViewLineTablesGroupName
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()))
Constant * ConstantFoldConstant(const Constant *C, const DataLayout &DL, const TargetLibraryInfo *TLI=nullptr)
ConstantFoldConstant - Attempt to fold the constant using the specified DataLayout.
static const MCBinaryExpr * createShl(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
void getAnalysisUsage(AnalysisUsage &AU) const override
Record analysis usage.
unsigned getCodeViewFlag() const
Returns the CodeView Version by checking module flags.
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.
virtual unsigned isLoadFromStackSlotPostFE(const MachineInstr &MI, int &FrameIndex) const
Check for post-frame ptr elimination stack locations as well.
static void emitComments(const MachineInstr &MI, raw_ostream &CommentOS)
emitComments - Pretty-print comments for instructions.
MCSection * getBSSSection() const
APInt zextOrSelf(unsigned width) const
Zero extend or truncate to width.
opStatus convert(const fltSemantics &ToSemantics, roundingMode RM, bool *losesInfo)
bool useStatepoints() const
Returns true if this strategy is expecting the use of gc.statepoints, and false otherwise.
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
bool isFI() const
isFI - Tests if this is a MO_FrameIndex operand.
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.
ConstantDataSequential - A vector or array constant whose element type is a simple 1/2/4/8-byte integ...
EK_LabelDifference32 - Each entry is the address of the block minus the address of the jump table...
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.
.type _foo, STT_GNU_IFUNC
VisibilityTypes
An enumeration for the kinds of visibility of global values.
const std::string & getName() const
Return the name of the GC strategy.
bool isAbsolute() const
Is this an absolute (as opposed to relocatable) value.
const MCSection * getCurrentSection() const
Return the current section we are emitting to.
uint64_t getLimitedValue(uint64_t Limit=~0ULL) const
getLimitedValue - If the value is smaller than the specified limit, return it, otherwise return the l...
Function Alias Analysis false
void EmitInt16(int Value) const
Emit a short directive and value.
StringRef getSection() const
Get the custom section of this global if it has one.
const MachineJumpTableInfo * getJumpTableInfo() const
getJumpTableInfo - Return the jump table info object for the current function.
EK_BlockAddress - Each entry is a plain address of block, e.g.
static Optional< FragmentInfo > getFragmentInfo(expr_op_iterator Start, expr_op_iterator End)
Retrieve the details of this fragment expression.
SequentialType * getType() const
Specialize the getType() method to always return a SequentialType, which reduces the amount of castin...
This class is a data container for one entry in a MachineConstantPool.
ArrayRef< MCSymbol * > getAddrLabelSymbolToEmit(const BasicBlock *BB)
Return the symbol to be used for the specified basic block when its address is taken.
virtual void emitImplicitDef(const MachineInstr *MI) const
Targets can override this to customize the output of IMPLICIT_DEF instructions in verbose mode...
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
bool isTvOS() const
Is this an Apple tvOS triple.
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
Printable PrintReg(unsigned Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubRegIdx=0)
Prints virtual and physical registers with or without a TRI instance.
bool isPPC_FP128Ty() const
Return true if this is powerpc long double.
Type * getElementType() const
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...
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.
virtual bool hasLoadFromStackSlot(const MachineInstr &MI, const MachineMemOperand *&MMO, int &FrameIndex) const
If the specified machine instruction has a load from a stack slot, return true along with the FrameIn...
Instances of this class represent a single low-level machine instruction.
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 BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
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)
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
bool isMachineConstantPoolEntry() const
isMachineConstantPoolEntry - Return true if the MachineConstantPoolEntry is indeed a target specific ...
virtual bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference, const Function &F) const
bool isSpillSlotObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a spill slot.
bool getCommDirectiveSupportsAlignment() const
const MachineBasicBlock * getParent() const
format_object< Ts...> format(const char *Fmt, const Ts &...Vals)
These are helper functions used to produce formatted output.
TargetInstrInfo - Interface to description of machine instruction set.
uint64_t getElementOffset(unsigned Idx) const
const Constant * ConstVal
This class is intended to be used as a base class for asm properties and features specific to the tar...
ExternalWeak linkage description.
unsigned getEntrySize(const DataLayout &TD) const
getEntrySize - Return the size of each entry in the jump table.
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.
MachineLoop * getLoopFor(const MachineBasicBlock *BB) const
Return the innermost loop that BB lives in.
bool needsDwarfSectionOffsetDirective() const
unsigned getEntryAlignment(const DataLayout &TD) const
getEntryAlignment - Return the alignment of each entry in the jump table.
Same, but only replaced by something equivalent.
EK_GPRel64BlockAddress - Each entry is an address of block, encoded with a relocation as gp-relative...
std::pair< const GlobalVariable *, unsigned > GOTEquivUsePair
Map global GOT equivalent MCSymbols to GlobalVariables and keep track of its number of uses by other ...
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
virtual MCSection * getStaticDtorSection(unsigned Priority, const MCSymbol *KeySym) const
MCSymbol * createTempSymbol(bool CanBeUnnamed=true)
Create and return a new assembler temporary symbol with a unique but unspecified name.
unsigned getNumElements() const
EK_Custom32 - Each entry is a 32-bit value that is custom lowered by the TargetLowering::LowerCustomJ...
MCSymbolAttr getHiddenDeclarationVisibilityAttr() const
.weak_def_can_be_hidden (MachO)
MCSymbol * CurrentFnSym
The symbol for the current function.
MCSymbolAttr getProtectedVisibilityAttr() const
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.
LLVM Basic Block Representation.
const MCAsmInfo * MAI
Target Asm Printer information.
The instances of the Type class are immutable: once they are created, they are never changed...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
AsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > Streamer)
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
This is an important base class in LLVM.
uint64_t getElementByteSize() const
Return the size (in bytes) of each element in the array/vector.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
int64_t getSExtValue() const
Get sign extended value.
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.
StringRef getAsString() const
If this array is isString(), then this method returns the array as a StringRef.
bool isThreadData() const
const MachineOperand & getOperand(unsigned i) const
void recordSled(MCSymbol *Sled, const MachineInstr &MI, SledKind Kind)
StringRef getRawDataValues() const
Return the raw, underlying, bytes of this data.
MCSymbol * getAddrLabelSymbol(const BasicBlock *BB)
Return the symbol to be used for the specified basic block when its address is taken.
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
MCSymbol * GetJTSetSymbol(unsigned UID, unsigned MBBID) const
Return the symbol for the specified jump table .set FIXME: privatize to AsmPrinter.
APInt Or(const APInt &LHS, const APInt &RHS)
Bitwise OR function for APInt.
ConstantFP - Floating Point Values [float, double].
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
APInt Xor(const APInt &LHS, const APInt &RHS)
Bitwise XOR function for APInt.
static const MCBinaryExpr * createOr(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
TargetMachine & TM
Target machine description.
bool isCImm() const
isCImm - Test if this is a MO_CImmediate operand.
bool hasFunctionAlignment() const
This class is intended to be used as a driving class for all asm writers.
Represent the analysis usage information of a pass.
virtual MCSection * getStaticCtorSection(unsigned Priority, const MCSymbol *KeySym) const
bool isWatchOS() const
Is this an Apple watchOS triple.
void print(raw_ostream &O, bool IsForDebug=false, bool NoDetails=false) const
Print the current type.
bool isEHFuncletEntry() const
Returns true if this is the entry block of an EH funclet.
bool isPositionIndependent() const
unsigned getBitWidth() const
Return the number of bits in the APInt.
void printOffset(int64_t Offset, raw_ostream &OS) const
This is just convenient handler for printing offsets.
static bool isDiscardableIfUnused(LinkageTypes Linkage)
Whether the definition of this global may be discarded if it is not used in its compilation unit...
const std::vector< MCCFIInstruction > & getFrameInstructions() const
Returns a reference to a list of cfi instructions in the function's prologue.
uint64_t getNumElements() const
SectionKind - This is a simple POD value that classifies the properties of a section.
ExceptionHandling getExceptionHandlingType() const
Value * getOperand(unsigned i) 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...
DenseMap< GCStrategy *, std::unique_ptr< GCMetadataPrinter > > gcp_map_type
virtual bool isBlockOnlyReachableByFallthrough(const MachineBasicBlock *MBB) const
Return true if the basic block has exactly one predecessor and the control transfer mechanism between...
Ty & getObjFileInfo()
Keep track of various per-function pieces of information for backends that would like to do so...
Constant Vector Declarations.
void getiOSVersion(unsigned &Major, unsigned &Minor, unsigned &Micro) const
getiOSVersion - Parse the version number as with getOSVersion.
MachineConstantPool * getConstantPool()
getConstantPool - Return the constant pool object for the current function.
void emitFrameAlloc(const MachineInstr &MI)
const DIExpression * getDebugExpression() const
Return the complex address expression referenced by this DBG_VALUE instruction.
void computeGlobalGOTEquivs(Module &M)
Unnamed constant global variables solely contaning a pointer to another globals variable act like a g...
bool isThreadLocal() const
If the value is "Thread Local", its value isn't shared by the threads.
static const char *const EHTimerName
bool supportIndirectSymViaGOTPCRel() const
Target supports replacing a data "PC"-relative access to a symbol through another symbol...
uint64_t getElementAsInteger(unsigned i) const
If this is a sequential container of integers (of any size), return the specified element in the low ...
const MCSymbolRefExpr * getSymB() const
bool hasWeakLinkage() const
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)
unsigned getDwarfVersion() const
Returns the Dwarf Version by checking module flags.
MCSymbol * getSymbol() const
Return the MCSymbol for this basic block.
virtual void markFunctionEnd()
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.
bool isThreadLocal() const
Windows x64, Windows Itanium (IA-64)
static void PrintParentLoopComment(raw_ostream &OS, const MachineLoop *Loop, unsigned FunctionNumber)
PrintParentLoopComment - Print comments about parent loops of this one.
Triple - Helper class for working with autoconf configuration names.
EH_LABEL - Represents a label in mid basic block used to track locations needed for debug and excepti...
void EmitAlignment(unsigned NumBits, const GlobalObject *GO=nullptr) const
Emit an alignment directive to the specified power of two boundary.
unsigned getPreferredAlignmentLog(const GlobalVariable *GV) const
Returns the preferred alignment of the specified global, returned in log form.
const std::string & getModuleInlineAsm() const
Get any module-scope inline assembly blocks.
virtual unsigned isStoreToStackSlotPostFE(const MachineInstr &MI, int &FrameIndex) const
Check for post-frame ptr elimination stack locations as well.
bool isOSDarwin() const
isOSDarwin - Is this a "Darwin" OS (OS X, iOS, or watchOS).
const FunctionListType & getFunctionList() const
Get the Module's list of functions (constant).
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...
virtual const TargetFrameLowering * getFrameLowering() const
bool hasExternalLinkage() const
const MDOperand & getOperand(unsigned I) const
bool hasGlobalUnnamedAddr() const
void emitCFIInstruction(const MachineInstr &MI)
ArrayType * getType() const
Specialize the getType() method to always return an ArrayType, which reduces the amount of casting ne...
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...
bool doesSetDirectiveSuppressReloc() const
This is the shared class of boolean and integer constants.
virtual MCSection * getSectionForJumpTable(const Function &F, const TargetMachine &TM) const
bool isFunctionTy() const
True if this is an instance of FunctionType.
SymbolListTy GetGVStubList()
Accessor methods to return the set of stubs in sorted order.
StringRef getTargetFeatureString() const
MapVector< const MCSymbol *, GOTEquivUsePair > GlobalGOTEquivs
const MCSymbolRefExpr * getSymA() const
uint64_t getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
virtual bool isVirtualSection() const =0
Check whether this section is "virtual", that is has no actual object file contents.
static const char *const CodeViewLineTablesGroupDescription
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.
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)
Module.h This file contains the declarations for the Module class.
Type * getType() const
All values are typed, get the type of this value.
void beginModule()
Emit all Dwarf sections that should come prior to the content.
virtual const TargetLowering * getTargetLowering() const
bool usesMorestackAddr() const
MCSection * getTLSExtraDataSection() const
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
bool needsUnwindTableEntry() const
True if this function needs an unwind table.
BasicBlock * getBasicBlock() const
Value * stripPointerCasts()
Strip off pointer casts, all-zero GEPs, and aliases.
StringRef str()
Return a StringRef for the vector contents.
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.
MCSymbol * createTempSymbol(const Twine &Name) const
bool isDefined(bool SetUsed=true) const
isDefined - Check if this symbol is defined (i.e., it has an address).
bool isNullValue() const
Return true if this is the value that would be returned by getNullValue.
bool isPositionIndependent() const
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
Collects and handles line tables information in a CodeView format.
unsigned Log2_32(uint32_t Value)
Log2_32 - This function returns the floor log base 2 of the specified value, -1 if the value is zero...
bool isFPImm() const
isFPImm - Tests if this is a MO_FPImmediate operand.
const ConstantInt * getCImm() const
MCSymbol * getJTISymbol(unsigned JTI, MCContext &Ctx, bool isLinkerPrivate=false) const
getJTISymbol - Return the MCSymbol for the specified non-empty jump table.
unsigned getOpcode() const
void emit(int, MCStreamer *, const MCSymbol *) const
virtual void EmitBasicBlockStart(const MachineBasicBlock &MBB) const
Targets can override this to emit stuff at the start of a basic block.
Class for arbitrary precision integers.
ConstantArray - Constant Array Declarations.
bool hasInitializer() const
Definitions have initializers, declarations don't.
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.
bool hasSingleParameterDotFile() const
bool hasEHFunclets() const
bool isConstant() const
If the value is a global constant, its value is immutable throughout the runtime execution of the pro...
virtual const MCExpr * lowerRelativeReference(const GlobalValue *LHS, const GlobalValue *RHS, const TargetMachine &TM) const
unsigned EmulatedTLS
EmulatedTLS - This flag enables emulated TLS model, using emutls function in the runtime library...
void setPreservesAll()
Set by analyses that do not transform their input at all.
StructType * getType() const
Specialization - reduce amount of casting.
iterator_range< user_iterator > users()
const GlobalObject * getBaseObject() const
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
virtual void emitModuleFlags(MCStreamer &Streamer, ArrayRef< Module::ModuleFlagEntry > Flags, const TargetMachine &TM) const
Emit the module flags that the platform cares about.
FunctionNumber(functionNumber)
double convertToDouble() const
static const fltSemantics & IEEEdouble()
APInt And(const APInt &LHS, const APInt &RHS)
Bitwise AND function for APInt.
MachineModuleInfoELF - This is a MachineModuleInfoImpl implementation for ELF targets.
Iterators for registry entries.
virtual void EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV)
bool hasLinkOnceLinkage() const
Representation of each machine instruction.
iterator begin() const
begin/end - Iterators for used strategies.
static void emitGlobalConstantImpl(const DataLayout &DL, const Constant *C, AsmPrinter &AP, const Constant *BaseCV=nullptr, uint64_t Offset=0)
bool hasAddressTaken() const
Test whether this block is potentially the target of an indirect branch.
PointerType * getType() const
Global values are always pointers.
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
NamedMDNode * getNamedMetadata(const Twine &Name) const
Return the first NamedMDNode in the module with the specified name.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
bool hasNoDeadStrip() const
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.
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
StringRef getName() const
getName - Get the symbol name.
const uint64_t * getRawData() const
This function returns a pointer to the internal storage of the APInt.
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
bool hasLinkerPrivateGlobalPrefix() const
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
void getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV, bool CannotUsePrivateLabel) const
Print the appropriate prefix and the specified global variable's name.
Represents a single loop in the control flow graph.
.type _foo, STT_FUNC # aka
virtual ~AsmPrinterHandler()
Pin vtable to this file.
static unsigned getNumGlobalVariableUses(const Constant *C)
Compute the number of Global Variables that uses a Constant.
MCSymbol * GetBlockAddressSymbol(const BlockAddress *BA) const
Return the MCSymbol used to satisfy BlockAddress uses of the specified basic block.
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
bool hasOneUse() const
Return true if there is exactly one user of this value.
virtual void EmitBasicBlockEnd(const MachineBasicBlock &MBB)
Targets can override this to emit stuff at the end of a basic block.
unsigned getNumElements() const
Return the number of elements in the array or vector.
MCSymbol * getMCSymbol() const
MCSubtargetInfo - Generic base class for all target subtargets.
unsigned getPointerSize() const
Return the pointer size from the TargetMachine.
static gcp_map_type & getGCMap(void *&P)
static const MCBinaryExpr * createMod(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
bool getMacOSXVersion(unsigned &Major, unsigned &Minor, unsigned &Micro) const
getMacOSXVersion - Parse the version number as with getOSVersion and then translate generic "darwin" ...
bool isString() const
This method returns true if this is an array of i8.
bool hasPrefixData() const
Check whether this function has prefix data.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Keep one copy of named function when linking (weak)
bool isStringAttribute() const
Return true if the attribute is a string (target-dependent) attribute.
virtual const MCExpr * LowerCustomJumpTableEntry(const MachineJumpTableInfo *, const MachineBasicBlock *, unsigned, MCContext &) const
Rename collisions when linking (static functions).
const Triple & getTargetTriple() const
getTargetTriple - Return the target triple string.
uint64_t getTypeStoreSize(Type *Ty) const
Returns the maximum number of bytes that may be overwritten by storing the specified type...
Constant * getPrefixData() const
Get the prefix data associated with this function.
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.
JTEntryKind getEntryKind() const
const Constant * getIndirectSymbol() const
bool hasLocalLinkage() const
const DILocalVariable * getDebugVariable() const
Return the debug variable referenced by this DBG_VALUE instruction.
bool isVariable() const
isVariable - Check if this is a variable symbol.
virtual MCSymbol * GetCPISymbol(unsigned CPID) const
Return the symbol for the specified constant pool entry.
const APFloat & getValueAPF() const
CFIMoveType needsCFIMoves()
VectorType * getType() const
Specialize the getType() method to always return a VectorType, which reduces the amount of casting ne...
Type * getElementType() const
Return the element type of the array/vector.
unsigned getPointerSize() const
Get the pointer size for this target.
unsigned getReg() const
getReg - Returns the register number.
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...
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...
const TargetLoweringObjectFile & getObjFileLowering() const
Return information about object file lowering.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
unsigned getAlignment() const
int64_t getConstant() const
A raw_ostream that writes to an std::string.
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags)
virtual const TargetInstrInfo * getInstrInfo() const
void EmitGlobalConstant(const DataLayout &DL, const Constant *CV)
Print a general LLVM constant to the .s file.
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
bool isKnownWindowsMSVCEnvironment() const
Checks if the environment is MSVC.
virtual bool hasStoreToStackSlot(const MachineInstr &MI, const MachineMemOperand *&MMO, int &FrameIndex) const
If the specified machine instruction has a store to a stack slot, return true along with the FrameInd...
bool hasSubsectionsViaSymbols() const
Windows CE ARM, PowerPC, SH3, SH4.
static const char *const DbgTimerName
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
bool isWindowsItaniumEnvironment() const
bool hasWeakDefCanBeHiddenDirective() const
uint64_t getSize() const
Return the size in bytes of the memory reference.
This class implements an extremely fast bulk output stream that can only output to a stream...
const Target & getTarget() const
Primary interface to the complete machine description for the target machine.
MCSymbol * CurrentFnSymForSize
The symbol used to represent the start of the current function for the purpose of calculating its siz...
const std::vector< MachineConstantPoolEntry > & getConstants() const
iterator_range< global_iterator > globals()
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
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...
static SectionKind getKindForGlobal(const GlobalObject *GO, const TargetMachine &TM)
Classify the specified global variable into a set of target independent categories embodied in Sectio...
union llvm::MachineConstantPoolEntry::@35 Val
The constant itself.
bool TimePassesIsEnabled
If the user specifies the -time-passes argument on an LLVM tool command line then the value of this b...
unsigned getPointerSize(unsigned AS=0) const
Layout pointer size FIXME: The defaults need to be removed once all of the backends/clients are updat...
MCSection * getTLSBSSSection() const
unsigned getNumElements() const
Random access to the elements.
bool isLayoutSuccessor(const MachineBasicBlock *MBB) const
Return true if the specified MBB will be emitted immediately after this block, such that if this bloc...
bool hasDotTypeDotSizeDirective() const
bool isVerbose() const
Return true if assembly output should contain comments.
unsigned getLoopDepth() const
Return the nesting level of this loop.
static SectionKind getReadOnly()
MCSymbol * GetExternalSymbolSymbol(StringRef Sym) const
Return the MCSymbol for the specified ExternalSymbol.
bool isDeclarationForLinker() const
unsigned pred_size() const
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx)
Type * getTypeAtIndex(const Value *V) const
Given an index value into the type, return the type of the element.
This class contains meta information specific to a module.
This file describes how to lower LLVM code to machine code.
unsigned getAlignment() const
Return alignment of the basic block.
bool isUndefined(bool SetUsed=true) const
isUndefined - Check if this symbol undefined (i.e., implicitly defined).
mmo_iterator memoperands_begin() const
Access to memory operands of the instruction.
unsigned getNumWords() const
Get the number of words.
bool usesWindowsCFI() const
MCSubtargetInfo & getSubtargetCopy(const MCSubtargetInfo &STI)