125 using namespace llvm;
127 #define DEBUG_TYPE "asm-printer" 139 "CodeView Line Tables";
141 STATISTIC(EmittedInsts,
"Number of machine instrs printed");
145 cl::desc(
"Print 'sched: [latency:throughput]' in .s output"));
147 char AsmPrinter::ID = 0;
161 unsigned InBits = 0) {
162 unsigned NumBits = 0;
167 if (InBits > NumBits)
185 OutContext(Streamer->getContext()), OutStreamer(
std::move(Streamer)) {
190 assert(!DD && Handlers.
empty() &&
"Debug/EH info didn't get finalized");
192 if (GCMetadataPrinters) {
196 GCMetadataPrinters =
nullptr;
224 assert(
MF &&
"getSubtargetInfo requires a valid MachineFunction!");
246 MMI = getAnalysisIfAvailable<MachineModuleInfo>();
277 assert(MI &&
"AsmPrinter didn't require GCModuleInfo?");
280 MP->beginAssembly(M, *MI, *
this);
289 OutStreamer->AddComment(
"Start of file scope inline assembly");
293 OutStreamer->AddComment(
"End of file scope inline assembly");
301 DbgTimerName, DbgTimerDescription,
302 CodeViewLineTablesGroupName,
303 CodeViewLineTablesGroupDescription));
308 Handlers.
push_back(HandlerInfo(DD, DbgTimerName, DbgTimerDescription,
309 DWARFGroupName, DWARFGroupDescription));
317 isCFIMoveForDebugging =
true;
324 if (!
F.isDeclarationForLinker() &&
F.needsUnwindTableEntry()) {
325 isCFIMoveForDebugging =
false;
331 isCFIMoveForDebugging =
false;
362 Handlers.
push_back(HandlerInfo(ES, EHTimerName, EHTimerDescription,
363 DWARFGroupName, DWARFGroupDescription));
365 if (mdconst::extract_or_null<ConstantInt>(
368 CFGuardDescription, DWARFGroupName,
369 DWARFGroupDescription));
435 "No emulated TLS variables in the common section");
475 "' is already defined");
490 for (
const HandlerInfo &
HI : Handlers) {
492 HI.TimerGroupName,
HI.TimerGroupDescription,
494 HI.Handler->setSymbolSize(GVSym, Size);
499 if (Size == 0) Size = 1;
500 unsigned Align = 1 << AlignLog;
518 unsigned Align = 1 << AlignLog;
519 EmitLinkage(GV, GVSym);
521 OutStreamer->EmitZerofill(TheSection, GVSym, Size, Align);
531 unsigned Align = 1 << AlignLog;
541 OutStreamer->EmitLocalCommonSymbol(GVSym, Size, Align);
572 OutStreamer->EmitTBSSSymbol(TheSection, MangSym, Size, 1 << AlignLog);
590 EmitLinkage(GV, GVSym);
611 EmitLinkage(GV, EmittedInitSym);
631 unsigned Size)
const {
637 void AsmPrinter::EmitFunctionHeader() {
642 <<
"-- Begin function " 691 std::vector<MCSymbol*> DeadBlockSyms;
693 for (
unsigned i = 0, e = DeadBlockSyms.size(); i != e; ++i) {
694 OutStreamer->AddComment(
"Address taken block that was later removed");
698 if (CurrentFnBegin) {
710 for (
const HandlerInfo &
HI : Handlers) {
713 HI.Handler->beginFunction(
MF);
730 "' is a protected alias");
733 "' label emitted multiple times to assembly file");
750 bool Commented =
false;
758 CommentOS << MMO->
getSize() <<
"-byte Reload";
763 CommentOS << MMO->
getSize() <<
"-byte Folded Reload";
769 CommentOS << MMO->
getSize() <<
"-byte Spill";
774 CommentOS << MMO->
getSize() <<
"-byte Folded Spill";
782 CommentOS <<
" Reload Reuse";
804 OS <<
"implicit-def: " 817 assert(Op.
isReg() &&
"KILL instruction must have only register operands");
818 OS <<
' ' << (Op.
isDef() ?
"def " :
"killed ")
835 OS <<
"DEBUG_VALUE: ";
838 if (
auto *
SP = dyn_cast<DISubprogram>(V->
getScope())) {
852 bool NeedSep =
false;
859 for (
unsigned I = 0;
I <
Op.getNumArgs(); ++
I)
860 OS <<
' ' <<
Op.getArg(
I);
908 OS <<
'+' << Offset <<
']';
924 OS <<
"DEBUG_LABEL: ";
927 if (
auto *
SP = dyn_cast<DISubprogram>(V->
getScope())) {
967 while (
I != MBB->end() &&
I->isTransient())
969 if (
I == MBB->instr_end() &&
970 MBB->getReverseIterator() == MBB->getParent()->rbegin())
995 if (!StackSizeSection)
1030 EmitFunctionHeader();
1039 MDT = getAnalysisIfAvailable<MachineDominatorTree>();
1041 OwnedMDT = make_unique<MachineDominatorTree>();
1042 OwnedMDT->getBase().recalculate(*
MF);
1043 MDT = OwnedMDT.get();
1047 MLI = getAnalysisIfAvailable<MachineLoopInfo>();
1049 OwnedMLI = make_unique<MachineLoopInfo>();
1051 MLI = OwnedMLI.get();
1056 bool HasAnyRealCode =
false;
1057 int NumInstsInFunction = 0;
1058 for (
auto &MBB : *
MF) {
1061 for (
auto &
MI : MBB) {
1063 if (!
MI.isPosition() && !
MI.isImplicitDef() && !
MI.isKill() &&
1064 !
MI.isDebugInstr()) {
1065 HasAnyRealCode =
true;
1066 ++NumInstsInFunction;
1069 if (ShouldPrintDebugScopes) {
1070 for (
const HandlerInfo &
HI : Handlers) {
1072 HI.TimerGroupName,
HI.TimerGroupDescription,
1074 HI.Handler->beginInstruction(&
MI);
1083 switch (
MI.getOpcode()) {
1084 case TargetOpcode::CFI_INSTRUCTION:
1087 case TargetOpcode::LOCAL_ESCAPE:
1091 case TargetOpcode::GC_LABEL:
1097 case TargetOpcode::DBG_VALUE:
1103 case TargetOpcode::DBG_LABEL:
1109 case TargetOpcode::IMPLICIT_DEF:
1120 if (ShouldPrintDebugScopes) {
1121 for (
const HandlerInfo &
HI : Handlers) {
1123 HI.TimerGroupName,
HI.TimerGroupDescription,
1125 HI.Handler->endInstruction();
1133 EmittedInsts += NumInstsInFunction;
1135 MF->getFunction().getSubprogram(),
1137 R <<
ore::NV(
"NumInstructions", NumInstsInFunction)
1138 <<
" instructions in function";
1153 MF->getSubtarget().getInstrInfo()->getNoop(Noop);
1158 OutStreamer->AddComment(
"avoids zero-length function");
1164 for (
const auto &BB : F) {
1165 if (!BB.hasAddressTaken())
1170 OutStreamer->AddComment(
"Address of block that was removed by CodeGen");
1195 for (
const HandlerInfo &
HI : Handlers) {
1198 HI.Handler->markFunctionEnd();
1205 for (
const HandlerInfo &
HI : Handlers) {
1208 HI.Handler->endFunction(MF);
1215 OutStreamer->GetCommentOS() <<
"-- End function\n";
1225 if (isa<GlobalVariable>(C))
1228 unsigned NumUses = 0;
1241 unsigned &NumGOTEquivUsers) {
1252 for (
auto *U : GV->
users())
1255 return NumGOTEquivUsers > 0;
1269 for (
const auto &
G : M.
globals()) {
1270 unsigned NumGOTEquivUsers = 0;
1289 unsigned Cnt =
I.second.second;
1293 GlobalGOTEquivs.clear();
1295 for (
auto *GV : FailedCandidates)
1299 void AsmPrinter::emitGlobalIndirectSymbol(
Module &M,
1314 if (isa<GlobalIFunc>(GIS))
1322 if (isa<GlobalAlias>(&GIS) &&
MAI->
hasAltEntry() && isa<MCBinaryExpr>(Expr))
1328 if (
auto *GA = dyn_cast<GlobalAlias>(&GIS)) {
1365 if (!
F.isDeclarationForLinker())
1372 EmitVisibility(Name, V,
false);
1384 if (!Stubs.empty()) {
1389 for (
const auto &Stub : Stubs) {
1391 OutStreamer->EmitSymbolValue(Stub.second.getPointer(),
1398 for (
const HandlerInfo &
HI : Handlers) {
1401 HI.Handler->endModule();
1415 for (
const auto &GO : M.global_objects()) {
1416 if (!GO.hasExternalWeakLinkage())
1430 for (
const auto &Alias : M.aliases()) {
1433 if (!AliasVisited.
insert(Cur).second)
1438 emitGlobalIndirectSymbol(M, *AncestorAlias);
1441 for (
const auto &IFunc : M.ifuncs())
1442 emitGlobalIndirectSymbol(M, IFunc);
1445 assert(MI &&
"AsmPrinter didn't require GCModuleInfo?");
1448 MP->finishAssembly(M, *MI, *
this);
1451 EmitModuleIdents(M);
1483 if (!InitTrampolineIntrinsic || InitTrampolineIntrinsic->
use_empty())
1496 if (!Flags.empty()) {
1504 if (
const auto *LU = M.getNamedGlobal(
"llvm.used")) {
1505 assert(LU->hasInitializer() &&
1506 "expected llvm.used to have an initializer");
1507 assert(isa<ArrayType>(LU->getValueType()) &&
1508 "expected llvm.used to be an array type");
1509 if (
const auto *A = cast<ConstantArray>(LU->getInitializer())) {
1510 for (
const Value *
Op : A->operands()) {
1512 cast<GlobalValue>(
Op->stripPointerCastsNoFollowAliases());
1523 if (!Flags.empty()) {
1557 if (!CurExceptionSym)
1559 return CurExceptionSym;
1567 CurrentFnBegin =
nullptr;
1568 CurExceptionSym =
nullptr;
1573 if (NeedsLocalForSize)
1574 CurrentFnSymForSize = CurrentFnBegin;
1577 ORE = &getAnalysis<MachineOptimizationRemarkEmitterPass>().getORE();
1593 SectionCPs(
MCSection *s,
unsigned a) : S(s), Alignment(a) {}
1604 const std::vector<MachineConstantPoolEntry> &
CP = MCP->
getConstants();
1605 if (CP.empty())
return;
1610 for (
unsigned i = 0, e = CP.size(); i != e; ++i) {
1626 unsigned SecIdx = CPSections.
size();
1627 while (SecIdx != 0) {
1628 if (CPSections[--SecIdx].S == S) {
1634 SecIdx = CPSections.
size();
1635 CPSections.
push_back(SectionCPs(S, Align));
1638 if (Align > CPSections[SecIdx].Alignment)
1639 CPSections[SecIdx].Alignment =
Align;
1646 for (
unsigned i = 0, e = CPSections.
size(); i != e; ++i) {
1647 for (
unsigned j = 0, ee = CPSections[i].CPEs.
size(); j != ee; ++j) {
1648 unsigned CPI = CPSections[i].CPEs[j];
1653 if (CurSection != CPSections[i].S) {
1656 CurSection = CPSections[i].S;
1664 unsigned NewOffset = (Offset + AlignMask) & ~AlignMask;
1687 if (JT.empty())
return;
1696 if (JTInDiffSection) {
1706 if (!JTInDiffSection)
1709 for (
unsigned JTI = 0, e = JT.size(); JTI != e; ++JTI) {
1710 const std::vector<MachineBasicBlock*> &JTBBs = JT[JTI].MBBs;
1713 if (JTBBs.empty())
continue;
1722 for (
unsigned ii = 0, ee = JTBBs.size(); ii != ee; ++ii) {
1724 if (!EmittedSets.
insert(MBB).second)
1747 for (
unsigned ii = 0, ee = JTBBs.size(); ii != ee; ++ii)
1748 EmitJumpTableEntry(MJTI, JTBBs[ii], JTI);
1750 if (!JTInDiffSection)
1758 unsigned UID)
const {
1812 assert(Value &&
"Unknown entry kind!");
1822 if (GV->
getName() ==
"llvm.used") {
1837 if (GV->
getName() ==
"llvm.global_ctors") {
1844 if (GV->
getName() ==
"llvm.global_dtors") {
1857 void AsmPrinter::EmitLLVMUsedList(
const ConstantArray *InitList) {
1859 for (
unsigned i = 0, e = InitList->
getNumOperands(); i != e; ++i) {
1874 Structor() =
default;
1885 if (!isa<ConstantArray>(List))
return;
1889 if (!InitList)
return;
1907 if (!Priority)
continue;
1909 Structor &S = Structors.
back();
1919 std::stable_sort(Structors.
begin(), Structors.
end(),
1920 [](
const Structor &L,
1921 const Structor &R) {
return L.Priority < R.Priority; });
1922 for (Structor &S : Structors) {
1946 void AsmPrinter::EmitModuleIdents(
Module &M) {
1951 for (
unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) {
1952 const MDNode *
N = NMD->getOperand(i);
1954 "llvm.ident metadata entry can have only one operand");
1990 unsigned Size)
const {
1991 OutStreamer->emitAbsoluteSymbolDiff(Hi, Lo, Size);
1999 bool IsSectionRelative)
const {
2027 if (NumBits == 0)
return;
2030 static_cast<unsigned>(std::numeric_limits<unsigned>::digits) &&
2031 "undefined behavior");
2048 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(CV))
2051 if (
const GlobalValue *GV = dyn_cast<GlobalValue>(CV))
2054 if (
const BlockAddress *BA = dyn_cast<BlockAddress>(CV))
2075 OS <<
"Unsupported expression in static initializer: ";
2080 case Instruction::GetElementPtr: {
2083 cast<GEPOperator>(CE)->accumulateConstantOffset(
getDataLayout(), OffsetAI);
2094 case Instruction::Trunc:
2100 case Instruction::BitCast:
2103 case Instruction::IntToPtr: {
2114 case Instruction::PtrToInt: {
2137 case Instruction::Sub: {
2146 const MCExpr *RelocExpr =
2152 int64_t Addend = (LHSOffset - RHSOffset).getSExtValue();
2166 case Instruction::Mul:
2167 case Instruction::SDiv:
2168 case Instruction::SRem:
2169 case Instruction::Shl:
2170 case Instruction::And:
2171 case Instruction::Or:
2172 case Instruction::Xor: {
2204 assert(!Data.
empty() &&
"Empty aggregates should be CAZ node");
2206 for (
unsigned i = 1, e = Data.
size(); i != e; ++i)
2207 if (Data[i] != C)
return -1;
2208 return static_cast<uint8_t
>(
C);
2215 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(V)) {
2220 APInt Value = CI->getValue().zextOrSelf(Size);
2229 assert(CA->getNumOperands() != 0 &&
"Should be a CAZ");
2236 for (
unsigned i = 1, e = CA->getNumOperands(); i != e; ++i)
2237 if (CA->getOperand(i) != Op0)
2283 assert(EmittedSize <= Size &&
"Size cannot be less than EmittedSize!");
2284 if (
unsigned Padding = Size - EmittedSize)
2315 if (
unsigned Padding = Size - EmittedSize)
2325 uint64_t SizeSoFar = 0;
2336 SizeSoFar += FieldSize + PadSize;
2344 "Layout of constant struct may be incorrect!");
2359 AP.
OutStreamer->GetCommentOS() <<
"Printing <null> Type";
2360 AP.
OutStreamer->GetCommentOS() <<
' ' << StrVal <<
'\n';
2367 unsigned TrailingBytes = NumBytes %
sizeof(uint64_t);
2376 AP.
OutStreamer->EmitIntValue(p[Chunk--], TrailingBytes);
2378 for (; Chunk >= 0; --Chunk)
2379 AP.
OutStreamer->EmitIntValue(p[Chunk],
sizeof(uint64_t));
2382 for (Chunk = 0; Chunk < NumBytes /
sizeof(uint64_t); ++Chunk)
2383 AP.
OutStreamer->EmitIntValue(p[Chunk],
sizeof(uint64_t));
2386 AP.
OutStreamer->EmitIntValue(p[Chunk], TrailingBytes);
2405 uint64_t ExtraBits = 0;
2406 unsigned ExtraBitsSize = BitWidth & 63;
2408 if (ExtraBitsSize) {
2425 ExtraBits = Realigned.getRawData()[0] &
2426 (((uint64_t)-1) >> (64 - ExtraBitsSize));
2427 Realigned.lshrInPlace(ExtraBitsSize);
2429 ExtraBits = Realigned.getRawData()[BitWidth / 64];
2435 const uint64_t *RawData = Realigned.getRawData();
2436 for (
unsigned i = 0, e = BitWidth / 64; i != e; ++i) {
2437 uint64_t Val = DL.
isBigEndian() ? RawData[e - i - 1] : RawData[i];
2441 if (ExtraBitsSize) {
2446 Size -= (BitWidth / 64) * 8;
2447 assert(Size && Size * 8 >= ExtraBitsSize &&
2448 (ExtraBits & (((uint64_t)-1) >> (64 - ExtraBitsSize)))
2449 == ExtraBits &&
"Directive too small for extra bits.");
2481 if (!(*ME)->evaluateAsRelocatable(MV,
nullptr,
nullptr) || MV.
isAbsolute())
2492 const GlobalValue *BaseGV = dyn_cast_or_null<GlobalValue>(BaseCst);
2500 if (!SymB || BaseSym != &SymB->
getSymbol())
2511 if (GOTPCRelCst < 0)
2533 int NumUses = (int)Result.second;
2554 BaseCV = dyn_cast<Constant>(CV->
user_back());
2556 if (isa<ConstantAggregateZero>(CV) || isa<UndefValue>(CV))
2559 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
2567 CI->getZExtValue());
2576 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(CV))
2579 if (isa<ConstantPointerNull>(CV)) {
2593 if (
const ConstantExpr *CE = dyn_cast<ConstantExpr>(CV)) {
2596 if (CE->getOpcode() == Instruction::BitCast)
2604 if (New && New != CE)
2645 else if (Offset < 0)
2667 if (
getSubtargetInfo().getTargetTriple().isKnownWindowsMSVCEnvironment()) {
2677 if (
MCSymbol *Sym = S->getCOMDATSymbol()) {
2678 if (Sym->isUndefined())
2724 <<
"Parent Loop BB" << FunctionNumber <<
"_" 2735 OS.
indent(CL->getLoopDepth()*2)
2736 <<
"Child Loop BB" << FunctionNumber <<
"_" 2737 << CL->getHeader()->getNumber() <<
" Depth " << CL->getLoopDepth()
2752 assert(Header &&
"No header for loop");
2756 if (Header != &MBB) {
2757 AP.
OutStreamer->AddComment(
" in Loop: Header=BB" +
2783 assert(
MF !=
nullptr &&
"Machine function must be valid");
2800 for (
const HandlerInfo &
HI : Handlers) {
2801 HI.Handler->endFunclet();
2802 HI.Handler->beginFunclet(MBB);
2810 setupCodePaddingContext(MBB, Context);
2811 OutStreamer->EmitCodePaddingBasicBlockStart(Context);
2832 if (BB->hasName()) {
2834 false, BB->getModule());
2839 assert(
MLI !=
nullptr &&
"MachineLoopInfo should has been computed");
2858 setupCodePaddingContext(MBB, Context);
2859 OutStreamer->EmitCodePaddingBasicBlockEnd(Context);
2863 bool IsDefinition)
const {
2866 switch (Visibility) {
2909 if (!
MI.isBranch() ||
MI.isIndirectBranch())
2918 if (
OP->isMBB() &&
OP->getMBB() == MBB)
2931 " stackmap formats, please see the documentation for a description of" 2932 " the default format. If you really need a custom serialized format," 2933 " please file a bug");
2937 if (GCPI != GCMap.end())
2938 return GCPI->second.get();
2945 if (
Name ==
I->getName()) {
2946 std::unique_ptr<GCMetadataPrinter> GMP =
I->instantiate();
2948 auto IterBool = GCMap.insert(std::make_pair(&S, std::move(GMP)));
2949 return IterBool.first->second.get();
2967 auto Kind8 =
static_cast<uint8_t
>(Kind);
2970 StringRef(reinterpret_cast<const char *>(&AlwaysInstrument), 1));
2972 auto Padding = (4 * Bytes) - ((2 * Bytes) + 3);
2973 assert(Padding >= 0 &&
"Instrumentation map entry > 4 * Word Size");
2981 auto PrevSection =
OutStreamer->getCurrentSectionOnly();
2987 assert(Associated !=
nullptr);
2989 std::string GroupName;
2998 GroupName, UniqueID, Associated);
3001 GroupName, UniqueID, Associated);
3019 for (
const auto &Sled :
Sleds)
3029 OutStreamer->EmitCodeAlignment(2 * WordSizeBytes);
3030 OutStreamer->EmitSymbolValue(SledsStart, WordSizeBytes,
false);
3031 OutStreamer->EmitSymbolValue(SledsEnd, WordSizeBytes,
false);
3041 bool AlwaysInstrument =
3042 Attr.isStringAttribute() && Attr.getValueAsString() ==
"xray-always";
3046 AlwaysInstrument, &
F, Version});
3050 return OutStreamer->getContext().getDwarfVersion();
3054 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...
void push_back(const T &Elt)
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
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.
Compute iterated dominance frontiers using a linear time algorithm.
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.
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...
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...
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
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.
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.
virtual MCSection * getStaticDtorSection(unsigned Priority, const MCSymbol *KeySym) const
const Triple & getTargetTriple() const
This represents a section on Windows.
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
virtual void EmitDebugThreadLocal(const MCExpr *Value, unsigned Size) const
Emit the directive and value for debug thread local expression.
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.
Emits exception handling directives.
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
const ConstantFP * getFPImm() const
unsigned getNumOperands() const
Access to explicit operands of the instruction.
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.
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
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...
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.
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
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 useStatepoints() const
Returns true if this strategy is expecting the use of gc.statepoints, and false otherwise.
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.
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...
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.
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 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...
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.
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()
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...
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.
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.
union llvm::MachineConstantPoolEntry::@146 Val
The constant itself.
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.
LLVM_NODISCARD bool empty() const
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
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.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
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.
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
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.
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)