63 using namespace dwarf;
70 for (
const auto &MFE: ModuleFlags) {
76 if (Key ==
"Objective-C Image Info Version") {
77 Version = mdconst::extract<ConstantInt>(MFE.Val)->getZExtValue();
78 }
else if (Key ==
"Objective-C Garbage Collection" ||
79 Key ==
"Objective-C GC Only" ||
80 Key ==
"Objective-C Is Simulated" ||
81 Key ==
"Objective-C Class Properties" ||
82 Key ==
"Objective-C Image Swift Version") {
83 Flags |= mdconst::extract<ConstantInt>(MFE.Val)->getZExtValue();
84 }
else if (Key ==
"Objective-C Image Info Section") {
85 Section = cast<MDString>(MFE.Val)->getString();
112 PersonalityEncoding = isPositionIndependent()
117 LSDAEncoding = isPositionIndependent()
120 TTypeEncoding = isPositionIndependent()
126 if (isPositionIndependent()) {
137 PersonalityEncoding =
150 if (isPositionIndependent()) {
162 if (isPositionIndependent()) {
212 if (isPositionIndependent()) {
236 if (isPositionIndependent()) {
249 if (isPositionIndependent()) {
268 auto &
C = getContext();
276 for (
const auto *Operand : LinkerOptions->operands()) {
277 if (cast<MDNode>(Operand)->getNumOperands() != 2)
279 for (
const auto &Option : cast<MDNode>(Operand)->operands()) {
280 Streamer.
EmitBytes(cast<MDString>(Option)->getString());
292 for (
const auto *Operand : DependentLibraries->operands()) {
294 cast<MDString>(cast<MDNode>(Operand)->getOperand(0))->getString());
304 if (!Section.
empty()) {
316 MDNode *CFGProfile =
nullptr;
318 for (
const auto &MFE : ModuleFlags) {
320 if (Key ==
"CG Profile") {
321 CFGProfile = cast<MDNode>(MFE.Val);
332 auto V = cast<ValueAsMetadata>(MDO);
333 const Function *
F = cast<Function>(V->getValue());
334 return TM->getSymbol(F);
337 for (
const auto &Edge : CFGProfile->
operands()) {
338 MDNode *
E = cast<MDNode>(Edge);
345 uint64_t Count = cast<ConstantAsMetadata>(E->
getOperand(2))
358 unsigned Encoding = getPersonalityEncoding();
360 return getContext().getOrCreateSymbol(
StringRef(
"DW.ref.") +
372 cast<MCSymbolELF>(getContext().getOrCreateSymbol(NameData));
395 MCSymbol *SSym = getSymbolWithGlobalValueBase(GV,
".DW.stub", TM);
407 Encoding & ~DW_EH_PE_indirect, Streamer);
426 if (Name.
empty() || Name[0] !=
'.')
return K;
429 if (Name ==
".bss" ||
439 if (Name ==
".tdata" ||
445 if (Name ==
".tbss" ||
461 if (Name ==
".init_array")
464 if (Name ==
".fini_array")
467 if (Name ==
".preinit_array")
510 C->
getName() +
"' cannot be lowered.");
567 if (
Attrs.hasAttribute(
"bss-section") && Kind.
isBSS()) {
568 SectionName =
Attrs.getAttribute(
"bss-section").getValueAsString();
569 }
else if (
Attrs.hasAttribute(
"rodata-section") && Kind.
isReadOnly()) {
570 SectionName =
Attrs.getAttribute(
"rodata-section").getValueAsString();
572 SectionName =
Attrs.getAttribute(
"relro-section").getValueAsString();
573 }
else if (
Attrs.hasAttribute(
"data-section") && Kind.
isData()) {
574 SectionName =
Attrs.getAttribute(
"data-section").getValueAsString();
596 if (AssociatedSymbol) {
597 UniqueID = NextUniqueID++;
607 "Associated symbol mismatch between sections");
627 return ".data.rel.ro";
633 unsigned *NextUniqueID,
const MCSymbolELF *AssociatedSymbol) {
650 cast<GlobalVariable>(GO));
652 std::string SizeSpec =
".rodata.str" +
utostr(EntrySize) +
".";
653 Name = SizeSpec +
utostr(Align);
655 Name =
".rodata.cst";
656 Name +=
utostr(EntrySize);
661 if (
const auto *
F = dyn_cast<Function>(GO)) {
662 const auto &OptionalPrefix =
F->getSectionPrefix();
664 Name += *OptionalPrefix;
668 if (EmitUniqueSection) {
673 UniqueID = *NextUniqueID;
681 EntrySize, Group, UniqueID, AssociatedSymbol);
690 bool EmitUniqueSection =
false;
700 if (AssociatedSymbol) {
701 EmitUniqueSection =
true;
706 getContext(), GO, Kind, getMangler(), TM, EmitUniqueSection, Flags,
707 &NextUniqueID, AssociatedSymbol);
718 if (!EmitUniqueSection)
719 return ReadOnlySection;
722 getMangler(), TM, EmitUniqueSection,
728 bool UsesLabelDifference,
const Function &
F)
const {
738 unsigned &
Align)
const {
740 return MergeableConst4Section;
742 return MergeableConst8Section;
744 return MergeableConst16Section;
746 return MergeableConst32Section;
748 return ReadOnlySection;
751 return DataRelROSection;
755 bool IsCtor,
unsigned Priority,
768 Name =
".init_array";
771 Name =
".fini_array";
773 if (Priority != 65535) {
784 if (Priority != 65535)
793 unsigned Priority,
const MCSymbol *KeySym)
const {
799 unsigned Priority,
const MCSymbol *KeySym)
const {
834 UseInitArray = UseInitArray_;
888 for (
const auto *Option : LinkerOptions->operands()) {
890 for (
const auto &Piece : cast<MDNode>(Option)->operands())
891 StrOptions.
push_back(cast<MDString>(Piece)->getString());
896 unsigned VersionVal = 0;
897 unsigned ImageInfoFlags = 0;
903 if (SectionVal.
empty())
907 unsigned TAA = 0, StubSize = 0;
909 std::string ErrorCode =
911 TAA, TAAParsed, StubSize);
912 if (!ErrorCode.empty())
922 getOrCreateSymbol(
StringRef(
"L_OBJC_IMAGE_INFO")));
934 "' cannot be lowered.");
941 unsigned TAA = 0, StubSize = 0;
946 std::string ErrorCode =
948 TAA, TAAParsed, StubSize);
949 if (!ErrorCode.empty()) {
952 "' has an invalid section specifier '" +
968 if (S->getTypeAndAttributes() != TAA || S->getStubSize() != StubSize) {
971 "' section type or attributes does not match previous" 972 " section specifier");
1002 cast<GlobalVariable>(GO)) < 32)
1010 cast<GlobalVariable>(GO)) < 32)
1050 unsigned &
Align)
const {
1086 Encoding & ~DW_EH_PE_indirect, Streamer);
1169 MCSymbol *Stub = Ctx.getOrCreateSymbol(Name);
1206 bool CannotUsePrivateLabel =
true;
1210 CannotUsePrivateLabel =
1259 assert(C &&
"expected GV to have a Comdat!");
1265 "' does not exist.");
1269 "' is not a key for its COMDAT.");
1277 if (
const auto *GA = dyn_cast<GlobalAlias>(ComdatKey))
1279 if (ComdatKey == GV) {
1280 switch (
C->getSelectionKind()) {
1315 COMDATSymName = Sym->
getName();
1342 bool EmitUniquedSection;
1364 if (EmitUniquedSection)
1365 UniqueID = NextUniqueID++;
1378 COMDATSymName, Selection, UniqueID);
1383 Selection, UniqueID);
1408 bool CannotUsePrivateLabel =
false;
1412 CannotUsePrivateLabel =
true;
1423 if (!EmitUniqueSection)
1437 unsigned UniqueID = NextUniqueID++;
1440 SecName, Characteristics, Kind, COMDATSymName,
1452 for (
const auto *Option : LinkerOptions->operands()) {
1453 for (
const auto &Piece : cast<MDNode>(Option)->operands()) {
1456 Directive.append(cast<MDString>(Piece)->getString());
1467 if (Section.
empty())
1471 auto *S =
C.getCOFFSection(
1513 if (Priority == 65535)
1524 OS <<
".CRT$X" << (IsCtor ?
"C" :
"T") <<
1525 (Priority < 200 ?
'A' :
'T') <<
format(
"%05u", Priority);
1532 std::string
Name = IsCtor ?
".ctors" :
".dtors";
1533 if (Priority != 65535)
1545 unsigned Priority,
const MCSymbol *KeySym)
const {
1552 unsigned Priority,
const MCSymbol *KeySym)
const {
1588 if (!isa<GlobalObject>(LHS) || !isa<GlobalVariable>(RHS) ||
1591 cast<GlobalVariable>(RHS)->hasInitializer() || RHS->
hasSection())
1601 std::string HexString = AI.
toString(16,
false);
1602 transform(HexString.begin(), HexString.end(), HexString.begin(), tolower);
1603 unsigned Size = HexString.size();
1604 assert(Width >= Size &&
"hex string is too large!");
1605 HexString.insert(HexString.begin(), Width -
Size,
'0');
1612 if (isa<UndefValue>(C)) {
1614 }
else if (
const auto *CFP = dyn_cast<ConstantFP>(C)) {
1616 }
else if (
const auto *CI = dyn_cast<ConstantInt>(C)) {
1619 unsigned NumElements;
1620 if (isa<VectorType>(Ty))
1624 std::string HexString;
1625 for (
int I = NumElements - 1,
E = -1;
I !=
E; --
I)
1633 unsigned &
Align)
const {
1643 std::string COMDATSymName;
1667 if (!COMDATSymName.empty())
1688 "SelectionKind::Any, '" + C->
getName() +
"' cannot be " 1708 if (isa<Function>(GO)) {
1730 const TargetMachine &
TM,
bool EmitUniqueSection,
unsigned *NextUniqueID) {
1739 if (
const auto *
F = dyn_cast<Function>(GO)) {
1740 const auto &OptionalPrefix =
F->getSectionPrefix();
1742 Name += *OptionalPrefix;
1745 if (EmitUniqueSection && UniqueSectionNames) {
1750 if (EmitUniqueSection && !UniqueSectionNames) {
1751 UniqueID = *NextUniqueID;
1766 bool EmitUniqueSection =
false;
1774 EmitUniqueSection, &NextUniqueID);
1778 bool UsesLabelDifference,
const Function &
F)
const {
1814 unsigned Priority,
const MCSymbol *KeySym)
const {
1815 return Priority == UINT16_MAX ?
1822 unsigned Priority,
const MCSymbol *KeySym)
const {
1838 "XCOFF unique sections not yet implemented.");
1857 cast<GlobalVariable>(GO));
1860 std::string SizeSpec =
".rodata.str" +
utostr(EntrySize) +
".";
1862 Name = SizeSpec +
utostr(Align);
1901 bool UsesLabelDifference,
const Function &
F)
const {
1909 unsigned &
Align)
const {
1923 unsigned Priority,
const MCSymbol *KeySym)
const {
1928 unsigned Priority,
const MCSymbol *KeySym)
const {
1951 "Unhandled linkage when mapping linkage to StorageClass.");
const MCExpr * lowerRelativeReference(const GlobalValue *LHS, const GlobalValue *RHS, const TargetMachine &TM) const override
const MCAsmInfo * getAsmInfo() const
AttributeSet getAttributes() const
Return the attribute set for this global.
void getNameWithPrefix(SmallVectorImpl< char > &OutName, const GlobalValue *GV, const TargetMachine &TM) const override
StringRef getSection() const
Get the custom section of this global if it has one.
Instances of this class represent a uniqued identifier for a section in the current translation unit...
void emitModuleMetadata(MCStreamer &Streamer, Module &M) const override
Emit Obj-C garbage collection and linker options.
A parsed version of the target data layout string in and methods for querying it. ...
Tracking metadata reference owned by Metadata.
static SectionKind getData()
static MCSectionCOFF * getCOFFStaticStructorSection(MCContext &Ctx, const Triple &T, bool IsCtor, unsigned Priority, const MCSymbol *KeySym, MCSectionCOFF *Default)
static MCSectionELF * selectELFSectionForGlobal(MCContext &Ctx, const GlobalObject *GO, SectionKind Kind, Mangler &Mang, const TargetMachine &TM, bool EmitUniqueSection, unsigned Flags, unsigned *NextUniqueID, const MCSymbolELF *AssociatedSymbol)
bool isThreadData() const
bool hasLocalLinkage() const
MCSection * getExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
Targets should implement this method to assign a section to globals with an explicit section specfied...
bool hasAttribute(unsigned Value) const
This represents a section on a Mach-O system (used by Mac OS X).
MCSection * getSectionForJumpTable(const Function &F, const TargetMachine &TM) const override
bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference, const Function &F) const override
MCSection * getStaticCtorSection(unsigned Priority, const MCSymbol *KeySym) const override
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
bool hasPrivateLinkage() const
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
This class represents lattice values for constants.
PointerTy getPointer() const
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.
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".
void emitPersonalityValue(MCStreamer &Streamer, const DataLayout &DL, const MCSymbol *Sym) const override
StringRef getPrivateGlobalPrefix() const
static std::string scalarConstantToHexString(const Constant *C)
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 emitLinkerFlagsForGlobal(raw_ostream &OS, const GlobalValue *GV) const override
virtual void AddBlankLine()
AddBlankLine - Emit a blank line to a .s file to pretty it up.
MCSection * getStaticDtorSection(unsigned Priority, const MCSymbol *KeySym) const override
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
MCSection * ConstDataSection
MCSymbol * getCFIPersonalitySymbol(const GlobalValue *GV, const TargetMachine &TM, MachineModuleInfo *MMI) const override
void Initialize(MCContext &Ctx, const TargetMachine &TM) override
This method must be called before any actual lowering is done.
MCSection * SixteenByteConstantSection
LLVM_NODISCARD bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
void push_back(const T &Elt)
MCSection * TextSection
Section directive for standard text.
void emitModuleMetadata(MCStreamer &Streamer, Module &M) const override
Emit Obj-C garbage collection and linker options.
MCSection * StaticCtorSection
This section contains the static constructor pointer list.
MCSection * ConstTextCoalSection
virtual void EmitBytes(StringRef Data)
Emit the bytes in Data into the output.
void emitModuleMetadata(MCStreamer &Streamer, Module &M) const override
Emit the module flags that specify the garbage collection information.
MCSection * DataCoalSection
static void checkMachOComdat(const GlobalValue *GV)
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
MCSymbol * getCFIPersonalitySymbol(const GlobalValue *GV, const TargetMachine &TM, MachineModuleInfo *MMI) const override
MCSectionWasm * getWasmSection(const Twine &Section, SectionKind K)
This file contains the declaration of the Comdat class, which represents a single COMDAT in LLVM...
Like Internal, but omit from symbol table.
void Initialize(MCContext &Ctx, const TargetMachine &TM) override
This method must be called before any actual lowering is done.
Externally visible function.
bool isMergeableConst8() const
PointerIntPair< MCSymbol *, 1, bool > StubValueTy
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
The data referenced by the COMDAT must be the same size.
A raw_ostream that writes to an SmallVector or SmallString.
MCSection * getExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
Targets should implement this method to assign a section to globals with an explicit section specfied...
bool isMergeableCString() const
const MCExpr * getTTypeReference(const MCSymbolRefExpr *Sym, unsigned Encoding, MCStreamer &Streamer) const
MCSection * SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
std::string getInstrProfSectionName(InstrProfSectKind IPSK, Triple::ObjectFormatType OF, bool AddSegmentInfo=true)
Return the name of the profile section corresponding to IPSK.
MCSection * getSectionForConstant(const DataLayout &DL, SectionKind Kind, const Constant *C, unsigned &Align) const override
Given a constant with the SectionKind, return a section that it should be placed in.
const MDOperand & getOperand(unsigned I) const
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
MCSection * getSectionForJumpTable(const Function &F, const TargetMachine &TM) const override
MCSection * getStaticCtorSection(unsigned Priority, const MCSymbol *KeySym) const override
static bool isThumb(const MCSubtargetInfo &STI)
unsigned getTypeAndAttributes() const
unsigned getBitWidth() const
Return the number of bits in the APInt.
MCSectionCOFF * getCOFFSection(StringRef Section, unsigned Characteristics, SectionKind Kind, StringRef COMDATSymName, int Selection, unsigned UniqueID=GenericSectionID, const char *BeginSymName=nullptr)
bool isMergeable2ByteCString() const
MCSection * getSectionForJumpTable(const Function &F, const TargetMachine &TM) const override
MCSectionCOFF * getAssociativeCOFFSection(MCSectionCOFF *Sec, const MCSymbol *KeySym, unsigned UniqueID=GenericSectionID)
Gets or creates a section equivalent to Sec that is associated with the section containing KeySym...
Adds a requirement that another module flag be present and have a specified value after linking is pe...
unsigned PersonalityEncoding
PersonalityEncoding, LSDAEncoding, TTypeEncoding - Some encoding values for EH.
This represents a section on Windows.
MCSection * SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
static MCSectionWasm * selectWasmSectionForGlobal(MCContext &Ctx, const GlobalObject *GO, SectionKind Kind, Mangler &Mang, const TargetMachine &TM, bool EmitUniqueSection, unsigned *NextUniqueID)
int64_t getConstant() const
const MCSymbolRefExpr * getSymB() const
static SectionKind getBSS()
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
uint64_t getArrayNumElements() const
virtual void Initialize(MCContext &ctx, const TargetMachine &TM)
This method must be called before any actual lowering is done.
Base class for the full range of assembler expressions which are needed for parsing.
MDNode * getMetadata(unsigned KindID) const
Get the current metadata attachments for the given kind, if any.
The linker may choose any COMDAT.
bool hasCOFFComdatConstants() const
void getNameWithPrefix(SmallVectorImpl< char > &Name, const GlobalValue *GV, Mangler &Mang, bool MayAlwaysUsePrivate=false) const
const MCExpr * lowerRelativeReference(const GlobalValue *LHS, const GlobalValue *RHS, const TargetMachine &TM) const override
MCSection * EightByteConstantSection
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
S_MOD_TERM_FUNC_POINTERS - Section with only function pointers for termination.
MCSection * TLSDataSection
Section directive for Thread Local data. ELF, MachO, COFF, and Wasm.
static const GlobalValue * getComdatGVForCOFF(const GlobalValue *GV)
MCSection * SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
Context object for machine code objects.
bool hasExternalLinkage() const
MCSection * DataCommonSection
MCSectionXCOFF * getXCOFFSection(StringRef Section, XCOFF::StorageMappingClass MappingClass, XCOFF::SymbolType CSectType, XCOFF::StorageClass StorageClass, SectionKind K, const char *BeginSymName=nullptr)
Type * getType() const
All values are typed, get the type of this value.
const MCExpr * getIndirectSymViaGOTPCRel(const GlobalValue *GV, const MCSymbol *Sym, const MCValue &MV, int64_t Offset, MachineModuleInfo *MMI, MCStreamer &Streamer) const override
Get MachO PC relative GOT entry relocation.
MCSection * getExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
Targets should implement this method to assign a section to globals with an explicit section specfied...
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
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.
op_range operands() const
ArchType getArch() const
getArch - Get the parsed architecture type of this triple.
static std::string APIntToHexString(const APInt &AI)
Directive
IDs for all OpenMP directives.
MCSection * StaticDtorSection
This section contains the static destructor pointer list.
MCSection * getStaticDtorSection(unsigned Priority, const MCSymbol *KeySym) const override
static void GetObjCImageInfo(Module &M, unsigned &Version, unsigned &Flags, StringRef &Section)
NamedMDNode * getNamedMetadata(const Twine &Name) const
Return the first NamedMDNode in the module with the specified name.
MCSection * ConstDataCoalSection
GlobalValue * getNamedValue(StringRef Name) const
Return the global value in the module with the specified name, of arbitrary type. ...
void Initialize(MCContext &Ctx, const TargetMachine &TM) override
This method must be called before any actual lowering is done.
bool isMergeableConst32() const
bool hasImplicitSection() const
Check if section name is present.
Reloc::Model getRelocationModel() const
Returns the code generation relocation model.
LinkageTypes getLinkage() const
MCSection * SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
static SectionKind getThreadData()
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
bool isWindowsItaniumEnvironment() const
uint64_t value() const
This is a hole in the type system and should not be abused.
constexpr char Attrs[]
Key for Kernel::Metadata::mAttrs.
virtual void EmitIntValue(uint64_t Value, unsigned Size)
Special case of EmitValue that avoids the client having to pass in a MCExpr for constant integers...
static StringRef getCOFFSectionNameForUniqueGlobal(SectionKind Kind)
MCSection * DataSection
Section directive for standard data.
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false)
bool getDataSections() const
Return true if data objects should be emitted into their own section, corresponds to -fdata-sections...
bool isReadOnlyWithRel() const
void getNameWithPrefix(SmallVectorImpl< char > &OutName, const GlobalValue *GV, const TargetMachine &TM) const override
Common csect definition. For uninitialized storage.
Constant * getAggregateElement(unsigned Elt) const
For aggregates (struct/array/vector) return the constant that corresponds to the specified element if...
static bool isWeakForLinker(LinkageTypes Linkage)
Whether the definition of this global may be replaced at link time.
This class is intended to be used as a base class for asm properties and features specific to the tar...
bool getFunctionSections() const
Return true if functions should be emitted into their own section, corresponding to -ffunction-sectio...
ExternalWeak linkage description.
MCSection * getSectionForConstant(const DataLayout &DL, SectionKind Kind, const Constant *C, unsigned &Align) const override
Given a constant with the SectionKind, return a section that it should be placed in.
void getModuleFlagsMetadata(SmallVectorImpl< ModuleFlagEntry > &Flags) const
Returns the module flags in the provided vector.
static const Comdat * getWasmComdat(const GlobalValue *GV)
No other Module may specify this COMDAT.
Streaming machine code generation interface.
StringRef getName() const
static std::string ParseSectionSpecifier(StringRef Spec, StringRef &Segment, StringRef &Section, unsigned &TAA, bool &TAAParsed, unsigned &StubSize)
Parse the section specifier indicated by "Spec".
MCSection * getSectionForCommandLines() const override
If supported, return the section to use for the llvm.commandline metadata.
TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
PointerIntPair - This class implements a pair of a pointer and small integer.
The instances of the Type class are immutable: once they are created, they are never changed...
MCSection * getSectionForConstant(const DataLayout &DL, SectionKind Kind, const Constant *C, unsigned &Align) const override
Given a mergeable constant with the specified size and relocation information, return a section that ...
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This is an important base class in LLVM.
unsigned getPointerSize(unsigned AS=0) const
Layout pointer size FIXME: The defaults need to be removed once all of the backends/clients are updat...
virtual void SwitchSection(MCSection *Section, const MCExpr *Subsection=nullptr)
Set the current section where code is being emitted to Section.
This represents a section on wasm.
const MCExpr * getTTypeGlobalReference(const GlobalValue *GV, unsigned Encoding, const TargetMachine &TM, MachineModuleInfo *MMI, MCStreamer &Streamer) const override
Return an MCExpr to use for a reference to the specified type info global variable from exception han...
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static SectionKind getELFKindForNamedSection(StringRef Name, SectionKind K)
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.
const MCAsmInfo * getMCAsmInfo() const
Return target specific asm information.
MCSymbol * getSymbol(const GlobalValue *GV) const
void InitializeELF(bool UseInitArray_)
MCSection * getStaticDtorSection(unsigned Priority, const MCSymbol *KeySym) const override
virtual bool isSectionAtomizableBySymbols(const MCSection &Section) const
True if the section is atomized using the symbols in it.
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 void EmitValueToAlignment(unsigned ByteAlignment, int64_t Value=0, unsigned ValueSize=1, unsigned MaxBytesToEmit=0)
Emit some number of copies of Value until the byte alignment ByteAlignment is reached.
virtual bool EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute)=0
Add the given Attribute to Symbol.
void emitLinkerFlagsForGlobalCOFF(raw_ostream &OS, const GlobalValue *GV, const Triple &TT, Mangler &Mangler)
SectionKind - This is a simple POD value that classifies the properties of a section.
MCContext & getContext() const
MCSection * UStringSection
const Triple & getTargetTriple() const
void emitLinkerFlagsForUsed(raw_ostream &OS, const GlobalValue *GV) const override
virtual const MCExpr * getTTypeGlobalReference(const GlobalValue *GV, unsigned Encoding, const TargetMachine &TM, MachineModuleInfo *MMI, MCStreamer &Streamer) const
Return an MCExpr to use for a reference to the specified global variable from exception handling info...
bool isMergeableConst16() const
MCSection * getSectionForConstant(const DataLayout &DL, SectionKind Kind, const Constant *C, unsigned &Align) const override
Given a constant with the SectionKind, return a section that it should be placed in.
Ty & getObjFileInfo()
Keep track of various per-function pieces of information for backends that would like to do so...
The data referenced by the COMDAT must be the same.
StubValueTy & getGVStubEntry(MCSymbol *Sym)
StubValueTy & getGVStubEntry(MCSymbol *Sym)
MCSection * getStaticDtorSection(unsigned Priority, const MCSymbol *KeySym) const override
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
S_ATTR_NO_DEAD_STRIP - No dead stripping.
const MCExpr * lowerRelativeReference(const GlobalValue *LHS, const GlobalValue *RHS, const TargetMachine &TM) const override
This struct is a compact representation of a valid (non-zero power of two) alignment.
Triple - Helper class for working with autoconf configuration names.
MCSection * getDrectveSection() const
const MCExpr * getTTypeGlobalReference(const GlobalValue *GV, unsigned Encoding, const TargetMachine &TM, MachineModuleInfo *MMI, MCStreamer &Streamer) const override
The mach-o version of this method defaults to returning a stub reference.
bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference, const Function &F) const override
bool isMergeableConst4() const
Align getPointerABIAlignment(unsigned AS) const
Layout pointer alignment.
static const MCSymbolELF * getAssociatedSymbol(const GlobalObject *GO, const TargetMachine &TM)
BSS class (uninitialized static internal)
static SectionKind getThreadBSS()
BlockVerifier::State From
static bool canUsePrivateLabel(const MCAsmInfo &AsmInfo, const MCSection &Section)
const MCSymbol & getSymbol() const
bool isMergeable4ByteCString() const
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Module.h This file contains the declarations for the Module class.
static SectionKind getMetadata()
CHAIN = SC CHAIN, Imm128 - System call.
const Triple & getTargetTriple() const
MCSection * DataBSSSection
static const Comdat * getELFComdat(const GlobalValue *GV)
The linker will choose the largest COMDAT.
bool hasGlobalUnnamedAddr() const
std::string utostr(uint64_t X, bool isNeg=false)
unsigned getVectorNumElements() const
unsigned getPreferredAlignment(const GlobalVariable *GV) const
Returns the preferred alignment of the specified global.
This file contains constants used for implementing Dwarf debug support.
const Comdat * getComdat() const
Class for arbitrary precision integers.
CodeModel::Model getCodeModel() const
Returns the code model.
static SectionKind getWasmKindForNamedSection(StringRef Name, SectionKind K)
bool isOSCygMing() const
Tests for either Cygwin or MinGW OS.
amdgpu AMDGPU DAG DAG Pattern Instruction Selection
TargetLoweringObjectFileMachO()
static StringRef getSectionPrefixForGlobal(SectionKind Kind)
Return the section prefix name used by options FunctionsSections and DataSections.
MCSection * FourByteConstantSection
Csect definition for initialized storage.
MachineModuleInfoELF - This is a MachineModuleInfoImpl implementation for ELF targets.
const Comdat * getComdat() const
bool isMergeableConst() const
const MCExpr * lowerRelativeReference(const GlobalValue *LHS, const GlobalValue *RHS, const TargetMachine &TM) const override
bool isFunctionTy() const
True if this is an instance of FunctionType.
MCSection * getStaticCtorSection(unsigned Priority, const MCSymbol *KeySym) const override
virtual void EmitLinkerOptions(ArrayRef< std::string > Kind)
Emit the given list Options of strings as linker options into the output.
bool getUniqueSectionNames() const
StringRef getValueAsString() const
Return the attribute's value as a string.
MCSection * getStaticCtorSection(unsigned Priority, const MCSymbol *KeySym) const override
MCSection * SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
StringRef getName() const
Return a constant reference to the value's name.
static int getSelectionForCOFF(const GlobalValue *GV)
COFFYAML::WeakExternalCharacteristics Characteristics
virtual void emitELFSize(MCSymbol *Symbol, const MCExpr *Value)
Emit an ELF .size directive.
static unsigned getCOFFSectionFlags(SectionKind K, const TargetMachine &TM)
This represents a section on linux, lots of unix variants and some bare metal systems.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Type * getValueType() const
void emitLinkerFlagsForUsedCOFF(raw_ostream &OS, const GlobalValue *GV, const Triple &T, Mangler &M)
Rename collisions when linking (static functions).
const Module * getModule() const
MachineModuleInfoMachO - This is a MachineModuleInfoImpl implementation for MachO targets...
OutputIt transform(R &&Range, OutputIt d_first, UnaryPredicate P)
Wrapper function around std::transform to apply a function to a range and store the result elsewhere...
const GlobalObject * getBaseObject() const
StringRef getName() const
getName - Get the symbol name.
Pass this value as the UniqueID during section creation to get the generic section with the given nam...
static unsigned getEntrySizeForKind(SectionKind Kind)
MCSection * TLSBSSSection
Section directive for Thread Local uninitialized data.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
MCSection * TextCoalSection
A raw_ostream that writes to an std::string.
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags)
static MCSectionELF * getStaticStructorSection(MCContext &Ctx, bool UseInitArray, bool IsCtor, unsigned Priority, const MCSymbol *KeySym)
Module * getParent()
Get the module that this global value is contained inside of...
MCSection * CStringSection
bool isThreadLocal() const
bool isMergeable1ByteCString() const
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
MCSection * getExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
Targets should implement this method to assign a section to globals with an explicit section specfied...
virtual void EmitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())
Emit a label for Symbol into the current section.
ExceptionHandling getExceptionHandlingType() const
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
bool isExecuteOnly() const
This class implements an extremely fast bulk output stream that can only output to a stream...
bool SupportIndirectSymViaGOTPCRel
Mangler & getMangler() const
virtual void emitCGProfileEntry(const MCSymbolRefExpr *From, const MCSymbolRefExpr *To, uint64_t Count)
Primary interface to the complete machine description for the target machine.
void getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV, bool CannotUsePrivateLabel) const
Print the appropriate prefix and the specified global variable's name.
MCSection * BSSSection
Section that is default initialized to zero.
bool isThreadLocal() const
If the value is "Thread Local", its value isn't shared by the threads.
const MCSymbol * getAssociatedSymbol() const
StringRef - Represent a constant reference to a string, i.e.
MCSection * ReadOnlySection
Section that is readonly and can contain arbitrary initialized data.
static unsigned getELFSectionFlags(SectionKind K)
static SectionKind getKindForGlobal(const GlobalObject *GO, const TargetMachine &TM)
Classify the specified global variable into a set of target independent categories embodied in Sectio...
static APInt getNullValue(unsigned numBits)
Get the '0' value.
S_MOD_INIT_FUNC_POINTERS - Section with only function pointers for initialization.
bool isWindowsMSVCEnvironment() const
Checks if the environment could be MSVC.
void Initialize(MCContext &Ctx, const TargetMachine &TM) override
This method must be called before any actual lowering is done.
static SectionKind getReadOnly()
void toString(SmallVectorImpl< char > &Str, unsigned Radix, bool Signed, bool formatAsCLiteral=false) const
Converts an APInt to a string and append it to Str.
static unsigned getELFSectionType(StringRef Name, SectionKind K)
static XCOFF::StorageClass getStorageClassForGlobal(const GlobalObject *GO)
PointerType * getType() const
Global values are always pointers.
This class contains meta information specific to a module.
MCSection * getExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
Targets should implement this method to assign a section to globals with an explicit section specfied...
SelectionKind getSelectionKind() const
static SectionKind getText()
bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference, const Function &F) const override