Go to the documentation of this file.
72 using namespace dwarf;
77 M.getModuleFlagsMetadata(ModuleFlags);
79 for (
const auto &MFE: ModuleFlags) {
85 if (
Key ==
"Objective-C Image Info Version") {
86 Version = mdconst::extract<ConstantInt>(MFE.Val)->getZExtValue();
87 }
else if (
Key ==
"Objective-C Garbage Collection" ||
88 Key ==
"Objective-C GC Only" ||
89 Key ==
"Objective-C Is Simulated" ||
90 Key ==
"Objective-C Class Properties" ||
91 Key ==
"Objective-C Image Swift Version") {
92 Flags |= mdconst::extract<ConstantInt>(MFE.Val)->getZExtValue();
93 }
else if (
Key ==
"Objective-C Image Info Section") {
94 Section = cast<MDString>(MFE.Val)->getString();
98 else if (
Key ==
"Swift ABI Version") {
99 Flags |= (mdconst::extract<ConstantInt>(MFE.Val)->getZExtValue()) << 8;
100 }
else if (
Key ==
"Swift Major Version") {
101 Flags |= (mdconst::extract<ConstantInt>(MFE.Val)->getZExtValue()) << 24;
102 }
else if (
Key ==
"Swift Minor Version") {
103 Flags |= (mdconst::extract<ConstantInt>(MFE.Val)->getZExtValue()) << 16;
113 SupportDSOLocalEquivalentLowering =
true;
135 PersonalityEncoding = isPositionIndependent()
140 LSDAEncoding = isPositionIndependent()
143 TTypeEncoding = isPositionIndependent()
149 if (isPositionIndependent()) {
160 PersonalityEncoding =
173 if (isPositionIndependent()) {
185 if (isPositionIndependent()) {
244 if (isPositionIndependent()) {
268 if (isPositionIndependent()) {
281 if (isPositionIndependent()) {
310 if (
auto *GO = dyn_cast<GlobalObject>(GV))
316 auto &
C = getContext();
318 if (
NamedMDNode *LinkerOptions =
M.getNamedMetadata(
"llvm.linker.options")) {
324 for (
const auto *Operand : LinkerOptions->operands()) {
325 if (cast<MDNode>(Operand)->getNumOperands() != 2)
327 for (
const auto &
Option : cast<MDNode>(Operand)->operands()) {
334 if (
NamedMDNode *DependentLibraries =
M.getNamedMetadata(
"llvm.dependent-libraries")) {
340 for (
const auto *Operand : DependentLibraries->operands()) {
342 cast<MDString>(cast<MDNode>(Operand)->getOperand(0))->getString());
354 for (
const auto *Operand : FuncInfo->operands()) {
355 const auto *MD = cast<MDNode>(Operand);
356 auto *GUID = mdconst::dyn_extract<ConstantInt>(MD->getOperand(0));
357 auto *Hash = mdconst::dyn_extract<ConstantInt>(MD->getOperand(1));
358 auto *Name = cast<MDString>(MD->getOperand(2));
359 auto *
S =
C.getObjectFileInfo()->getPseudoProbeDescSection(
360 TM->getFunctionSections() ? Name->getString() :
StringRef());
363 Streamer.
emitInt64(GUID->getZExtValue());
364 Streamer.
emitInt64(Hash->getZExtValue());
370 if (
NamedMDNode *LLVMStats =
M.getNamedMetadata(
"llvm.stats")) {
373 auto *
S =
C.getObjectFileInfo()->getLLVMStatsSection();
375 for (
const auto *Operand : LLVMStats->operands()) {
376 const auto *MD = cast<MDNode>(Operand);
377 assert(MD->getNumOperands() % 2 == 0 &&
378 (
"Operand num should be even for a list of key/value pair"));
379 for (
size_t I = 0;
I < MD->getNumOperands();
I += 2) {
381 auto *
Key = cast<MDString>(MD->getOperand(
I));
386 Twine(mdconst::dyn_extract<ConstantInt>(MD->getOperand(
I + 1))
400 if (!Section.empty()) {
409 emitCGProfileMetadata(Streamer,
M);
415 unsigned Encoding = getPersonalityEncoding();
417 return getContext().getOrCreateSymbol(
StringRef(
"DW.ref.") +
418 TM.getSymbol(GV)->getName());
420 return TM.getSymbol(GV);
429 cast<MCSymbolELF>(getContext().getOrCreateSymbol(NameData));
433 MCSection *Sec = getContext().getELFNamedSection(
".data", Label->getName(),
435 unsigned Size =
DL.getPointerSize();
452 MCSymbol *SSym = getSymbolWithGlobalValueBase(GV,
".DW.stub",
TM);
483 Name ==
".llvmbc" || Name ==
".llvmcmd")
486 if (Name.empty() || Name[0] !=
'.')
return K;
489 if (Name ==
".bss" ||
490 Name.startswith(
".bss.") ||
491 Name.startswith(
".gnu.linkonce.b.") ||
492 Name.startswith(
".llvm.linkonce.b.") ||
494 Name.startswith(
".sbss.") ||
495 Name.startswith(
".gnu.linkonce.sb.") ||
496 Name.startswith(
".llvm.linkonce.sb."))
499 if (Name ==
".tdata" ||
500 Name.startswith(
".tdata.") ||
501 Name.startswith(
".gnu.linkonce.td.") ||
502 Name.startswith(
".llvm.linkonce.td."))
505 if (Name ==
".tbss" ||
506 Name.startswith(
".tbss.") ||
507 Name.startswith(
".gnu.linkonce.tb.") ||
508 Name.startswith(
".llvm.linkonce.tb."))
523 if (Name.startswith(
".note"))
582 "SelectionKind::NoDeduplicate, '" +
583 C->getName() +
"' cannot be lowered.");
595 auto *OtherGV = dyn_cast<GlobalValue>(VM->getValue());
596 return OtherGV ? dyn_cast<MCSymbolELF>(
TM.getSymbol(OtherGV)) :
nullptr;
600 if (Kind.isMergeable1ByteCString())
602 else if (Kind.isMergeable2ByteCString())
604 else if (Kind.isMergeable4ByteCString())
606 else if (Kind.isMergeableConst4())
608 else if (Kind.isMergeableConst8())
610 else if (Kind.isMergeableConst16())
612 else if (Kind.isMergeableConst32())
617 assert(!Kind.isMergeableCString() &&
"unknown string width");
618 assert(!Kind.isMergeableConst() &&
"unknown data width");
628 if (Kind.isReadOnly())
632 if (Kind.isThreadData())
634 if (Kind.isThreadBSS())
638 if (Kind.isReadOnlyWithRel())
639 return ".data.rel.ro";
646 unsigned EntrySize,
bool UniqueSectionName) {
648 if (Kind.isMergeableCString()) {
653 cast<GlobalVariable>(GO));
655 std::string SizeSpec =
".rodata.str" + utostr(EntrySize) +
".";
656 Name = SizeSpec + utostr(Alignment.
value());
657 }
else if (Kind.isMergeableConst()) {
658 Name =
".rodata.cst";
659 Name += utostr(EntrySize);
664 bool HasPrefix =
false;
665 if (
const auto *
F = dyn_cast<Function>(GO)) {
666 if (std::optional<StringRef>
Prefix =
F->getSectionPrefix()) {
672 if (UniqueSectionName) {
674 TM.getNameWithPrefix(Name, GO, Mang,
true);
675 }
else if (HasPrefix)
687 LoweringDiagnosticInfo(
const Twine &DiagMsg,
700 unsigned &EntrySize,
unsigned &NextUniqueID,
701 const bool Retain,
const bool ForceUnique) {
706 return NextUniqueID++;
710 const bool Associated = GO->
getMetadata(LLVMContext::MD_associated);
713 return NextUniqueID++;
717 if (
TM.getTargetTriple().isOSSolaris())
722 return NextUniqueID++;
733 if (!SupportsUnique) {
740 const bool SeenSectionNameBefore =
744 if (!SymbolMergeable && !SeenSectionNameBefore)
750 const auto PreviousID =
761 if (SymbolMergeable &&
768 return NextUniqueID++;
774 bool Retain,
bool ForceUnique) {
783 if (
Attrs.hasAttribute(
"bss-section") && Kind.isBSS()) {
785 }
else if (
Attrs.hasAttribute(
"rodata-section") && Kind.isReadOnly()) {
787 }
else if (
Attrs.hasAttribute(
"relro-section") && Kind.isReadOnlyWithRel()) {
789 }
else if (
Attrs.hasAttribute(
"data-section") && Kind.isData()) {
793 const Function *
F = dyn_cast<Function>(GO);
794 if (
F &&
F->hasFnAttribute(
"implicit-section-name")) {
795 SectionName =
F->getFnAttribute(
"implicit-section-name").getValueAsString();
802 bool IsComdat =
false;
805 Group =
C->getName();
812 GO,
SectionName, Kind,
TM, Ctx, Mang, Flags, EntrySize, NextUniqueID,
813 Retain, ForceUnique);
818 Group, IsComdat, UniqueID, LinkedToSym);
821 assert(Section->getLinkedToSymbol() == LinkedToSym &&
822 "Associated symbol mismatch between sections");
832 "Symbol '" + GO->
getName() +
"' from module '" +
834 "' required a section with entry-size=" +
837 ": Explicit assignment by pragma or attribute of an incompatible "
838 "symbol to this section?"));
847 NextUniqueID, Used.count(GO),
854 unsigned *NextUniqueID,
const MCSymbolELF *AssociatedSymbol) {
857 bool IsComdat =
false;
860 Group =
C->getName();
867 bool UniqueSectionName =
false;
869 if (EmitUniqueSection) {
870 if (
TM.getUniqueSectionNames()) {
871 UniqueSectionName =
true;
873 UniqueID = *NextUniqueID;
878 GO, Kind, Mang,
TM, EntrySize, UniqueSectionName);
881 if (Kind.isExecuteOnly())
884 EntrySize, Group, IsComdat, UniqueID,
891 unsigned Flags,
unsigned *NextUniqueID) {
894 EmitUniqueSection =
true;
898 if (
TM.getTargetTriple().isOSSolaris()) {
899 EmitUniqueSection =
true;
903 EmitUniqueSection =
true;
909 Ctx, GO, Kind, Mang,
TM, EmitUniqueSection, Flags,
910 NextUniqueID, LinkedToSym);
911 assert(Section->getLinkedToSymbol() == LinkedToSym);
921 bool EmitUniqueSection =
false;
924 EmitUniqueSection =
TM.getFunctionSections();
926 EmitUniqueSection =
TM.getDataSections();
930 Used.count(GO), EmitUniqueSection, Flags,
940 if (
F.hasSection() ||
F.hasFnAttribute(
"implicit-section-name"))
942 &
F, Kind,
TM, getContext(), getMangler(), NextUniqueID,
943 Used.count(&
F),
true);
946 getContext(), &
F, Kind, getMangler(),
TM, Used.count(&
F),
947 true, Flags, &NextUniqueID);
955 bool EmitUniqueSection =
TM.getFunctionSections() ||
C;
956 if (!EmitUniqueSection)
957 return ReadOnlySection;
960 getMangler(),
TM, EmitUniqueSection,
969 if (!LSDASection || (!
F.hasComdat() && !
TM.getFunctionSections()))
972 const auto *LSDA = cast<MCSectionELF>(LSDASection);
973 unsigned Flags = LSDA->getFlags();
976 bool IsComdat =
false;
979 Group =
C->getName();
984 if (
TM.getFunctionSections() &&
985 (getContext().getAsmInfo()->useIntegratedAssembler() &&
986 getContext().getAsmInfo()->binutilsIsAtLeast(2, 36))) {
988 LinkedToSym = cast<MCSymbolELF>(&FnSym);
993 return getContext().getELFSection(
994 (
TM.getUniqueSectionNames() ? LSDA->getName() +
"." +
F.getName()
1001 bool UsesLabelDifference,
const Function &
F)
const {
1011 Align &Alignment)
const {
1012 if (Kind.isMergeableConst4() && MergeableConst4Section)
1013 return MergeableConst4Section;
1014 if (Kind.isMergeableConst8() && MergeableConst8Section)
1015 return MergeableConst8Section;
1016 if (Kind.isMergeableConst16() && MergeableConst16Section)
1017 return MergeableConst16Section;
1018 if (Kind.isMergeableConst32() && MergeableConst32Section)
1019 return MergeableConst32Section;
1020 if (Kind.isReadOnly())
1021 return ReadOnlySection;
1023 assert(Kind.isReadOnlyWithRel() &&
"Unknown section kind");
1024 return DataRelROSection;
1044 Name +=
".text.eh.";
1048 if (
TM.getUniqueBasicBlockSectionNames()) {
1049 if (!Name.endswith(
"."))
1053 UniqueID = NextUniqueID++;
1058 std::string GroupName;
1059 if (
F.hasComdat()) {
1061 GroupName =
F.getComdat()->getName().str();
1065 F.hasComdat(), UniqueID,
nullptr);
1069 bool IsCtor,
unsigned Priority,
1082 Name =
".init_array";
1085 Name =
".fini_array";
1087 if (Priority != 65535) {
1089 Name += utostr(Priority);
1098 if (Priority != 65535)
1107 unsigned Priority,
const MCSymbol *KeySym)
const {
1113 unsigned Priority,
const MCSymbol *KeySym)
const {
1123 if (!
LHS->hasGlobalUnnamedAddr() || !
LHS->getValueType()->isFunctionTy())
1129 RHS->isThreadLocal())
1140 assert(supportDSOLocalEquivalentLowering());
1145 if (GV->isDSOLocal() || GV->isImplicitDSOLocal())
1162 UseInitArray = UseInitArray_;
1164 if (!UseInitArray) {
1184 SupportIndirectSymViaGOTPCRel =
true;
1204 PersonalityEncoding =
1212 unsigned Priority,
const MCSymbol *KeySym)
const {
1215 if (
TM->Options.LowerGlobalDtorsViaCxaAtExit)
1217 return StaticDtorSection;
1223 if (
auto *LinkerOptions =
M.getNamedMetadata(
"llvm.linker.options")) {
1224 for (
const auto *
Option : LinkerOptions->operands()) {
1226 for (
const auto &Piece : cast<MDNode>(
Option)->operands())
1227 StrOptions.push_back(std::string(cast<MDString>(Piece)->getString()));
1232 unsigned VersionVal = 0;
1233 unsigned ImageInfoFlags = 0;
1237 emitCGProfileMetadata(Streamer,
M);
1240 if (SectionVal.
empty())
1244 unsigned TAA = 0, StubSize = 0;
1247 SectionVal, Segment, Section, TAA, TAAParsed, StubSize)) {
1258 getOrCreateSymbol(
StringRef(
"L_OBJC_IMAGE_INFO")));
1270 "' cannot be lowered.");
1278 const Function *
F = dyn_cast<Function>(GO);
1279 if (
F &&
F->hasFnAttribute(
"implicit-section-name")) {
1280 SectionName =
F->getFnAttribute(
"implicit-section-name").getValueAsString();
1285 unsigned TAA = 0, StubSize = 0;
1291 SectionName, Segment, Section, TAA, TAAParsed, StubSize)) {
1294 "' has an invalid section specifier '" +
1300 getContext().getMachOSection(Segment, Section, TAA, StubSize, Kind);
1305 TAA =
S->getTypeAndAttributes();
1310 if (
S->getTypeAndAttributes() != TAA ||
S->getStubSize() != StubSize) {
1313 "' section type or attributes does not match previous"
1314 " section specifier");
1325 if (Kind.isThreadBSS())
return TLSBSSSection;
1326 if (Kind.isThreadData())
return TLSDataSection;
1334 if (Kind.isReadOnly())
1335 return ConstTextCoalSection;
1336 if (Kind.isReadOnlyWithRel())
1337 return ConstDataCoalSection;
1338 return DataCoalSection;
1342 if (Kind.isMergeable1ByteCString() &&
1344 cast<GlobalVariable>(GO)) <
Align(32))
1345 return CStringSection;
1352 cast<GlobalVariable>(GO)) <
Align(32))
1353 return UStringSection;
1358 if (Kind.isMergeableConst4())
1359 return FourByteConstantSection;
1360 if (Kind.isMergeableConst8())
1361 return EightByteConstantSection;
1362 if (Kind.isMergeableConst16())
1363 return SixteenByteConstantSection;
1368 if (Kind.isReadOnly())
1369 return ReadOnlySection;
1373 if (Kind.isReadOnlyWithRel())
1374 return ConstDataSection;
1378 if (Kind.isBSSExtern())
1379 return DataCommonSection;
1383 if (Kind.isBSSLocal())
1384 return DataBSSSection;
1392 Align &Alignment)
const {
1395 if (Kind.isData() || Kind.isReadOnlyWithRel())
1396 return ConstDataSection;
1398 if (Kind.isMergeableConst4())
1399 return FourByteConstantSection;
1400 if (Kind.isMergeableConst8())
1401 return EightByteConstantSection;
1402 if (Kind.isMergeableConst16())
1403 return SixteenByteConstantSection;
1404 return ReadOnlySection;
1416 MCSymbol *SSym = getSymbolWithGlobalValueBase(GV,
"$non_lazy_ptr",
TM);
1442 MCSymbol *SSym = getSymbolWithGlobalValueBase(GV,
"$non_lazy_ptr",
TM);
1511 MCSymbol *Stub = Ctx.getOrCreateSymbol(Name);
1547 bool CannotUsePrivateLabel =
true;
1550 const MCSection *TheSection = SectionForGlobal(GO, GOKind,
TM);
1551 CannotUsePrivateLabel =
1554 getMangler().getNameWithPrefix(OutName, GV, CannotUsePrivateLabel);
1603 assert(
C &&
"expected GV to have a Comdat!");
1609 "' does not exist.");
1613 "' is not a key for its COMDAT.");
1621 if (
const auto *GA = dyn_cast<GlobalAlias>(ComdatKey))
1623 if (ComdatKey == GV) {
1624 switch (
C->getSelectionKind()) {
1659 COMDATSymName = Sym->
getName();
1666 return getContext().getCOFFSection(Name,
Characteristics, Kind, COMDATSymName,
1675 if (Kind.isThreadLocal())
1677 if (Kind.isReadOnly() || Kind.isReadOnlyWithRel())
1686 bool EmitUniquedSection;
1688 EmitUniquedSection =
TM.getFunctionSections();
1690 EmitUniquedSection =
TM.getDataSections();
1692 if ((EmitUniquedSection && !Kind.isCommon()) || GO->
hasComdat()) {
1708 if (EmitUniquedSection)
1709 UniqueID = NextUniqueID++;
1715 if (
const auto *
F = dyn_cast<Function>(GO))
1716 if (std::optional<StringRef>
Prefix =
F->getSectionPrefix())
1722 if (getContext().getTargetTriple().isWindowsGNUEnvironment())
1729 getMangler().getNameWithPrefix(TmpData, GO,
true);
1730 return getContext().getCOFFSection(Name,
Characteristics, Kind, TmpData,
1738 if (Kind.isThreadLocal())
1739 return TLSDataSection;
1741 if (Kind.isReadOnly() || Kind.isReadOnlyWithRel())
1742 return ReadOnlySection;
1747 if (Kind.isBSS() || Kind.isCommon())
1756 bool CannotUsePrivateLabel =
false;
1758 ((isa<Function>(GV) &&
TM.getFunctionSections()) ||
1759 (isa<GlobalVariable>(GV) &&
TM.getDataSections())))
1760 CannotUsePrivateLabel =
true;
1762 getMangler().getNameWithPrefix(OutName, GV, CannotUsePrivateLabel);
1770 bool EmitUniqueSection =
TM.getFunctionSections() ||
C;
1771 if (!EmitUniqueSection)
1772 return ReadOnlySection;
1775 if (
F.hasPrivateLinkage())
1776 return ReadOnlySection;
1785 unsigned UniqueID = NextUniqueID++;
1787 return getContext().getCOFFSection(
1794 emitLinkerDirectives(Streamer,
M);
1801 if (!Section.empty()) {
1802 auto &
C = getContext();
1803 auto *
S =
C.getCOFFSection(Section,
1814 emitCGProfileMetadata(Streamer,
M);
1817 void TargetLoweringObjectFileCOFF::emitLinkerDirectives(
1819 if (
NamedMDNode *LinkerOptions =
M.getNamedMetadata(
"llvm.linker.options")) {
1825 for (
const auto *
Option : LinkerOptions->operands()) {
1826 for (
const auto &Piece : cast<MDNode>(
Option)->operands()) {
1829 Directive.append(std::string(cast<MDString>(Piece)->getString()));
1842 if (!
Flags.empty()) {
1850 if (
const auto *LU =
M.getNamedGlobal(
"llvm.used")) {
1851 assert(LU->hasInitializer() &&
"expected llvm.used to have an initializer");
1852 assert(isa<ArrayType>(LU->getValueType()) &&
1853 "expected llvm.used to be an array type");
1854 if (
const auto *A = cast<ConstantArray>(LU->getInitializer())) {
1855 for (
const Value *
Op :
A->operands()) {
1856 const auto *GV = cast<GlobalValue>(
Op->stripPointerCasts());
1860 if (GV->hasLocalLinkage())
1868 if (!
Flags.empty()) {
1883 if (
T.isWindowsMSVCEnvironment() ||
T.isWindowsItaniumEnvironment()) {
1909 if (
T.isWindowsMSVCEnvironment() ||
T.isWindowsItaniumEnvironment()) {
1911 if (Priority == 65535)
1925 char LastLetter =
'T';
1926 bool AddPrioritySuffix = Priority != 200 && Priority != 400;
1929 else if (Priority < 400)
1931 else if (Priority == 400)
1934 OS <<
".CRT$X" << (IsCtor ?
"C" :
"T") << LastLetter;
1935 if (AddPrioritySuffix)
1936 OS <<
format(
"%05u", Priority);
1943 std::string Name = IsCtor ?
".ctors" :
".dtors";
1944 if (Priority != 65535)
1956 unsigned Priority,
const MCSymbol *KeySym)
const {
1958 getContext(), getContext().getTargetTriple(),
true, Priority, KeySym,
1959 cast<MCSectionCOFF>(StaticCtorSection));
1963 unsigned Priority,
const MCSymbol *KeySym)
const {
1965 getContext(), getContext().getTargetTriple(),
false, Priority, KeySym,
1966 cast<MCSectionCOFF>(StaticDtorSection));
1973 if (
T.isOSCygMing())
1989 if (!isa<GlobalObject>(
LHS) || !isa<GlobalVariable>(
RHS) ||
1990 LHS->isThreadLocal() ||
RHS->isThreadLocal() ||
1991 RHS->
getName() !=
"__ImageBase" || !
RHS->hasExternalLinkage() ||
1992 cast<GlobalVariable>(
RHS)->hasInitializer() ||
RHS->hasSection())
2002 std::string HexString =
toString(AI, 16,
false);
2004 unsigned Size = HexString.size();
2005 assert(
Width >= Size &&
"hex string is too large!");
2006 HexString.insert(HexString.begin(),
Width - Size,
'0');
2012 Type *Ty =
C->getType();
2013 if (isa<UndefValue>(
C)) {
2015 }
else if (
const auto *CFP = dyn_cast<ConstantFP>(
C)) {
2017 }
else if (
const auto *CI = dyn_cast<ConstantInt>(
C)) {
2020 unsigned NumElements;
2021 if (
auto *VTy = dyn_cast<VectorType>(Ty))
2022 NumElements = cast<FixedVectorType>(VTy)->getNumElements();
2025 std::string HexString;
2026 for (
int I = NumElements - 1,
E = -1;
I !=
E; --
I)
2034 Align &Alignment)
const {
2035 if (Kind.isMergeableConst() &&
C &&
2036 getContext().getAsmInfo()->hasCOFFComdatConstants()) {
2044 std::string COMDATSymName;
2045 if (Kind.isMergeableConst4()) {
2046 if (Alignment <= 4) {
2048 Alignment =
Align(4);
2050 }
else if (Kind.isMergeableConst8()) {
2051 if (Alignment <= 8) {
2053 Alignment =
Align(8);
2055 }
else if (Kind.isMergeableConst16()) {
2057 if (Alignment <= 16) {
2059 Alignment =
Align(16);
2061 }
else if (Kind.isMergeableConst32()) {
2062 if (Alignment <= 32) {
2064 Alignment =
Align(32);
2068 if (!COMDATSymName.empty())
2089 "SelectionKind::Any, '" +
C->getName() +
"' cannot be "
2113 if (isa<Function>(GO)) {
2114 return SelectSectionForGlobal(GO, Kind,
TM);
2124 if (Name ==
".llvmcmd" || Name ==
".llvmbc")
2129 Group =
C->getName();
2141 const TargetMachine &
TM,
bool EmitUniqueSection,
unsigned *NextUniqueID) {
2144 Group =
C->getName();
2147 bool UniqueSectionNames =
TM.getUniqueSectionNames();
2150 if (
const auto *
F = dyn_cast<Function>(GO)) {
2151 const auto &OptionalPrefix =
F->getSectionPrefix();
2156 if (EmitUniqueSection && UniqueSectionNames) {
2157 Name.push_back(
'.');
2158 TM.getNameWithPrefix(Name, GO, Mang,
true);
2161 if (EmitUniqueSection && !UniqueSectionNames) {
2162 UniqueID = *NextUniqueID;
2173 if (Kind.isCommon())
2178 bool EmitUniqueSection =
false;
2180 EmitUniqueSection =
TM.getFunctionSections();
2182 EmitUniqueSection =
TM.getDataSections();
2186 EmitUniqueSection, &NextUniqueID);
2190 bool UsesLabelDifference,
const Function &
F)
const {
2201 if (!
LHS->hasGlobalUnnamedAddr() || !
LHS->getValueType()->isFunctionTy())
2207 RHS->isThreadLocal())
2226 unsigned Priority,
const MCSymbol *KeySym)
const {
2227 return Priority == UINT16_MAX ?
2229 getContext().getWasmSection(
".init_array." + utostr(Priority),
2234 unsigned Priority,
const MCSymbol *KeySym)
const {
2247 if (!
F.hasPersonalityFn() || !
F.needsUnwindTableEntry())
2251 dyn_cast<GlobalValue>(
F.getPersonalityFn()->stripPointerCasts());
2252 assert(Per &&
"Personality routine is not a GlobalValue type.");
2262 if (!
F.hasStackProtectorFnAttr())
2287 if (
const GlobalObject *GO = dyn_cast<GlobalObject>(GV)) {
2288 if (GO->isDeclarationForLinker())
2289 return cast<MCSectionXCOFF>(getSectionForExternalReference(GO,
TM))
2290 ->getQualNameSymbol();
2293 if (GVar->hasAttribute(
"toc-data"))
2294 return cast<MCSectionXCOFF>(
2296 ->getQualNameSymbol();
2300 return cast<MCSectionXCOFF>(
2301 getSectionForFunctionDescriptor(cast<Function>(GO),
TM))
2302 ->getQualNameSymbol();
2303 if ((
TM.getDataSections() && !GO->hasSection()) || GO->hasCommonLinkage() ||
2305 return cast<MCSectionXCOFF>(SectionForGlobal(GO, GOKind,
TM))
2306 ->getQualNameSymbol();
2322 if (GVar->hasAttribute(
"toc-data"))
2323 return getContext().getXCOFFSection(
2331 else if (Kind.isData() || Kind.isReadOnlyWithRel() || Kind.isBSS())
2333 else if (Kind.isReadOnly())
2338 return getContext().getXCOFFSection(
2346 "Tried to get ER section for a defined global.");
2349 getNameWithPrefix(Name, GO,
TM);
2357 if (GVar->hasAttribute(
"toc-data"))
2361 return getContext().getXCOFFSection(
2370 if (GVar->hasAttribute(
"toc-data")) {
2372 getNameWithPrefix(Name, GO,
TM);
2373 return getContext().getXCOFFSection(
2382 if (Kind.isBSSLocal() || GO->
hasCommonLinkage() || Kind.isThreadBSSLocal()) {
2384 getNameWithPrefix(Name, GO,
TM);
2388 return getContext().getXCOFFSection(
2392 if (Kind.isMergeableCString()) {
2394 cast<GlobalVariable>(GO));
2397 std::string SizeSpec =
".rodata.str" + utostr(EntrySize) +
".";
2399 Name = SizeSpec + utostr(Alignment.
value());
2401 if (
TM.getDataSections())
2402 getNameWithPrefix(Name, GO,
TM);
2404 return getContext().getXCOFFSection(
2406 !
TM.getDataSections());
2409 if (Kind.isText()) {
2410 if (
TM.getFunctionSections()) {
2411 return cast<MCSymbolXCOFF>(getFunctionEntryPointSymbol(GO,
TM))
2412 ->getRepresentedCsect();
2424 if (Kind.isData() || Kind.isReadOnlyWithRel() || Kind.isBSS()) {
2425 if (
TM.getDataSections()) {
2427 getNameWithPrefix(Name, GO,
TM);
2428 return getContext().getXCOFFSection(
2435 if (Kind.isReadOnly()) {
2436 if (
TM.getDataSections()) {
2438 getNameWithPrefix(Name, GO,
TM);
2439 return getContext().getXCOFFSection(
2443 return ReadOnlySection;
2450 if (Kind.isThreadLocal()) {
2451 if (
TM.getDataSections()) {
2453 getNameWithPrefix(Name, GO,
TM);
2454 return getContext().getXCOFFSection(
2457 return TLSDataSection;
2465 assert (!
F.getComdat() &&
"Comdat not supported on XCOFF.");
2467 if (!
TM.getFunctionSections())
2468 return ReadOnlySection;
2473 getNameWithPrefix(NameStr, &
F,
TM);
2474 return getContext().getXCOFFSection(
2480 bool UsesLabelDifference,
const Function &
F)
const {
2488 Align &Alignment)
const {
2490 if (Alignment >
Align(16))
2493 if (Alignment ==
Align(8)) {
2494 assert(ReadOnly8Section &&
"Section should always be initialized.");
2495 return ReadOnly8Section;
2498 if (Alignment ==
Align(16)) {
2499 assert(ReadOnly16Section &&
"Section should always be initialized.");
2500 return ReadOnly16Section;
2503 return ReadOnlySection;
2513 PersonalityEncoding = 0;
2522 SupportDebugThreadLocalLocation =
false;
2526 unsigned Priority,
const MCSymbol *KeySym)
const {
2531 unsigned Priority,
const MCSymbol *KeySym)
const {
2544 assert(!isa<GlobalIFunc>(GV) &&
"GlobalIFunc is not supported on AIX.");
2562 "There is no mapping that implements AppendingLinkage for XCOFF.");
2569 assert((isa<Function>(Func) ||
2570 (isa<GlobalAlias>(Func) &&
2571 isa_and_nonnull<Function>(
2572 cast<GlobalAlias>(Func)->getAliaseeObject()))) &&
2573 "Func must be a function or an alias which has a function as base "
2577 NameStr.push_back(
'.');
2578 getNameWithPrefix(NameStr, Func,
TM);
2584 if (((
TM.getFunctionSections() && !Func->hasSection()) ||
2585 Func->isDeclaration()) &&
2586 isa<Function>(Func)) {
2593 ->getQualNameSymbol();
2596 return getContext().getOrCreateSymbol(NameStr);
2602 getNameWithPrefix(NameStr,
F,
TM);
2603 return getContext().getXCOFFSection(
2612 return getContext().getXCOFFSection(
2621 auto *LSDA = cast<MCSectionXCOFF>(LSDASection);
2622 if (
TM.getFunctionSections()) {
2628 LSDA = getContext().getXCOFFSection(NameStr, LSDA->getKind(),
2629 LSDA->getCsectProp());
2640 return SelectSectionForGlobal(GO, Kind,
TM);
2645 auto *Symbol =
TM.getSymbol(GO);
2650 return getContext().getObjectFileInfo()->getTextSection();
@ IMAGE_COMDAT_SELECT_EXACT_MATCH
MCSection * getSectionForLSDA(const Function &F, const MCSymbol &FnSym, const TargetMachine &TM) const override
@ XTY_ER
External reference.
bool isThreadLocal() const
This is an optimization pass for GlobalISel generic memory operations.
static MCSectionCOFF * getCOFFStaticStructorSection(MCContext &Ctx, const Triple &T, bool IsCtor, unsigned Priority, const MCSymbol *KeySym, MCSectionCOFF *Default)
static unsigned calcUniqueIDUpdateFlagsAndSize(const GlobalObject *GO, StringRef SectionName, SectionKind Kind, const TargetMachine &TM, MCContext &Ctx, Mangler &Mang, unsigned &Flags, unsigned &EntrySize, unsigned &NextUniqueID, const bool Retain, const bool ForceUnique)
Calculate an appropriate unique ID for a section, and update Flags, EntrySize and NextUniqueID where ...
@ IMAGE_SCN_CNT_UNINITIALIZED_DATA
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
static MCSectionELF * selectELFSectionForGlobal(MCContext &Ctx, const GlobalObject *GO, SectionKind Kind, Mangler &Mang, const TargetMachine &TM, bool EmitUniqueSection, unsigned Flags, unsigned *NextUniqueID, const MCSymbolELF *AssociatedSymbol)
static SectionKind getMetadata()
bool hasCommonLinkage() const
A parsed version of the target data layout string in and methods for querying it.
TargetLoweringObjectFileELF()
MCSection * SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
@ LinkOnceAnyLinkage
Keep one copy of function when linking (inline)
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.
Align getPreferredAlign(const GlobalVariable *GV) const
Returns the preferred alignment of the specified global.
@ ExactMatch
The data referenced by the COMDAT must be the same.
@ SHT_LLVM_DEPENDENT_LIBRARIES
const MCContext & getContext() const
bool hasExternalLinkage() const
cl::opt< std::string > BBSectionsColdTextPrefix
bool useIntegratedAssembler() const
Return true if assembly (inline or otherwise) should be parsed.
MCSection * getSectionForTOCEntry(const MCSymbol *Sym, const TargetMachine &TM) const override
On targets that support TOC entries, return a section for the entry given the symbol it refers to.
static unsigned getELFSectionType(StringRef Name, SectionKind K)
LinkageTypes getLinkage() const
@ IMAGE_COMDAT_SELECT_NODUPLICATES
@ XMC_TD
Scalar data item in the TOC.
Context object for machine code objects.
static SmallString< 128 > getELFSectionNameForGlobal(const GlobalObject *GO, SectionKind Kind, Mangler &Mang, const TargetMachine &TM, unsigned EntrySize, bool UniqueSectionName)
MCSection * getStaticCtorSection(unsigned Priority, const MCSymbol *KeySym) const override
virtual void emitELFSize(MCSymbol *Symbol, const MCExpr *Value)
Emit an ELF .size directive.
void emitModuleMetadata(MCStreamer &Streamer, Module &M) const override
Emit Obj-C garbage collection and linker options.
@ MCSA_ELF_TypeObject
.type _foo, STT_OBJECT # aka @object
void emitInt64(uint64_t Value)
@ XMC_TE
Symbol mapped at the end of TOC.
A raw_ostream that writes to an std::string.
StringRef getSection() const
Get the custom section of this global if it has one.
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
This class is intended to be used as a base class for asm properties and features specific to the tar...
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...
@ NoDeduplicate
No deduplication is performed.
void emitInt8(uint64_t Value)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
@ IMAGE_SCN_MEM_DISCARDABLE
MCSection * SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
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...
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
static bool hasPrefix(StringRef SectionName, StringRef Prefix)
MDNode * getMetadata(unsigned KindID) const
Get the current metadata attachments for the given kind, if any.
TargetLoweringObjectFileMachO()
unsigned getFunctionNumber() const
getFunctionNumber - Return a unique ID for the current function.
static void checkMachOComdat(const GlobalValue *GV)
Triple - Helper class for working with autoconf configuration names.
void InitializeELF(bool UseInitArray_)
PointerIntPair< MCSymbol *, 1, bool > StubValueTy
@ XMC_UA
Unclassified - Treated as Read Write.
MCSection * getSectionForJumpTable(const Function &F, const TargetMachine &TM) const override
static MCSymbol * getEHInfoTableSymbol(const MachineFunction *MF)
The instances of the Type class are immutable: once they are created, they are never changed.
unsigned getBitWidth() const
Return the number of bits in the APInt.
void emitInt32(uint64_t Value)
@ XMC_TC
General TOC item.
bool isMergeableConst() const
@ IMAGE_COMDAT_SELECT_ASSOCIATIVE
@ Largest
The linker will choose the largest COMDAT.
virtual void emitLinkerOptions(ArrayRef< std::string > Kind)
Emit the given list Options of strings as linker options into the output.
StubValueTy & getGVStubEntry(MCSymbol *Sym)
MCSection * getSectionForExternalReference(const GlobalObject *GO, const TargetMachine &TM) const override
For external functions, this will always return a function descriptor csect.
This represents a section on linux, lots of unix variants and some bare metal systems.
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.
static bool ShouldEmitEHBlock(const MachineFunction *MF)
static SectionKind getELFKindForNamedSection(StringRef Name, SectionKind K)
static APInt getZero(unsigned numBits)
Get the '0' value for the specified bit-width.
MCSection * getSectionForJumpTable(const Function &F, const TargetMachine &TM) const override
std::string encodeBase64(InputBytes const &Bytes)
@ S_MOD_TERM_FUNC_POINTERS
S_MOD_TERM_FUNC_POINTERS - Section with only function pointers for termination.
bool isELFImplicitMergeableSectionNamePrefix(StringRef Name)
GlobalVariable * collectUsedGlobalVariables(const Module &M, SmallVectorImpl< GlobalValue * > &Vec, bool CompilerUsed)
Given "llvm.used" or "llvm.compiler.used" as a global name, collect the initializer elements of that ...
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.
bool isBeginSection() const
Returns true if this block begins any section.
void getNameWithPrefix(SmallVectorImpl< char > &OutName, const GlobalValue *GV, const TargetMachine &TM) const override
EHPersonality classifyEHPersonality(const Value *Pers)
See if the given exception handling personality function is one that we understand.
void Initialize(MCContext &Ctx, const TargetMachine &TM) override
This method must be called before any actual lowering is done.
static SectionKind getReadOnly()
MCSymbol * getSymbol() const
Return the MCSymbol for this basic block.
MCSection * getStaticCtorSection(unsigned Priority, const MCSymbol *KeySym) const override
static unsigned getELFSectionFlags(SectionKind K)
Streaming machine code generation interface.
MCSection * getSectionForConstant(const DataLayout &DL, SectionKind Kind, const Constant *C, Align &Alignment) const override
Given a constant with the SectionKind, return a section that it should be placed in.
@ IMAGE_SCN_CNT_INITIALIZED_DATA
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference, const Function &F) const override
static SectionKind getThreadBSS()
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...
@ XMC_RO
Read Only Constant.
bool isELFGenericMergeableSection(StringRef Name)
@ IMAGE_COMDAT_SELECT_SAME_SIZE
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This represents a section on wasm.
MCSection * getStaticCtorSection(unsigned Priority, const MCSymbol *KeySym) const override
@ GenericSectionID
Pass this value as the UniqueID during section creation to get the generic section with the given nam...
unsigned UseInitArray
UseInitArray - Use .init_array instead of .ctors for static constructors.
(vector float) vec_cmpeq(*A, *B) C
const MCExpr * lowerRelativeReference(const GlobalValue *LHS, const GlobalValue *RHS, const TargetMachine &TM) const override
static std::string scalarConstantToHexString(const Constant *C)
static Error ParseSectionSpecifier(StringRef Spec, StringRef &Segment, StringRef &Section, unsigned &TAA, bool &TAAParsed, unsigned &StubSize)
Parse the section specifier indicated by "Spec".
virtual void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())
Emit a label for Symbol into the current section.
virtual void switchSection(MCSection *Section, const MCExpr *Subsection=nullptr)
Set the current section where code is being emitted to Section.
MCSection * getStaticDtorSection(unsigned Priority, const MCSymbol *KeySym) const override
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 hasPrivateLinkage() const
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags)
constexpr const char * PseudoProbeDescMetadataName
static SectionKind getBSS()
@ Any
The linker may choose any COMDAT.
void getModuleMetadata(Module &M) override
Get the module-level metadata that the platform cares about.
static void GetObjCImageInfo(Module &M, unsigned &Version, unsigned &Flags, StringRef &Section)
std::optional< unsigned > getELFUniqueIDForEntsize(StringRef SectionName, unsigned Flags, unsigned EntrySize)
Return the unique ID of the section with the given name, flags and entry size, if it exists.
This class contains meta information specific to a module.
DiagnosticSeverity
Defines the different supported severity of a diagnostic.
void getNameWithPrefix(SmallVectorImpl< char > &OutName, const GlobalValue *GV, const TargetMachine &TM) const override
std::optional< const char * > toString(const std::optional< DWARFFormValue > &V)
Take an optional DWARFFormValue and try to extract a string value from it.
bool isNoOpWithoutInvoke(EHPersonality Pers)
Return true if this personality may be safely removed if there are no invoke instructions remaining i...
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
@ SHT_LLVM_LINKER_OPTIONS
MCSection * SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
const MCSymbol & getSymbol() const
int64_t getConstant() const
virtual void Initialize(MCContext &ctx, const TargetMachine &TM)
This method must be called before any actual lowering is done.
@ SameSize
The data referenced by the COMDAT must be the same size.
@ MCSA_Hidden
.hidden (ELF)
StringRef getName() const
getName - Get the symbol name.
static bool isThumb(const MCSubtargetInfo &STI)
This is the base abstract class for diagnostic reporting in the backend.
static SectionKind getText()
@ XTY_SD
Csect definition for initialized storage.
Interface for custom diagnostic printing.
@ InternalLinkage
Rename collisions when linking (static functions).
This struct is a compact representation of a valid (non-zero power of two) alignment.
MCSection * getSectionForConstant(const DataLayout &DL, SectionKind Kind, const Constant *C, Align &Alignment) const override
Given a constant with the SectionKind, return a section that it should be placed in.
ArchType getArch() const
Get the parsed architecture type of this triple.
virtual void addBlankLine()
Emit a blank line to a .s file to pretty it up.
MCSection * getSectionForFunctionDescriptor(const Function *F, const TargetMachine &TM) const override
On targets that use separate function descriptor symbols, return a section for the descriptor given i...
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.
static const MCSymbolELF * getLinkedToSymbol(const GlobalObject *GO, const TargetMachine &TM)
MCSectionWasm * getWasmSection(const Twine &Section, SectionKind K, unsigned Flags=0)
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 StringRef getCOFFSectionNameForUniqueGlobal(SectionKind Kind)
void emitPersonalityValue(MCStreamer &Streamer, const DataLayout &DL, const MCSymbol *Sym) const override
StorageMappingClass
Storage Mapping Class definitions.
std::string str() const
Return the twine contents as a std::string.
void emitModuleMetadata(MCStreamer &Streamer, Module &M) const override
Emit Obj-C garbage collection and linker options.
static unsigned getCOFFSectionFlags(SectionKind K, const TargetMachine &TM)
const MDOperand & getOperand(unsigned I) const
constexpr bool empty() const
empty - Check if the string is empty.
PointerTy getPointer() const
MachineModuleInfo & getMMI() const
bool isThreadBSSLocal() const
MCSection * getStaticDtorSection(unsigned Priority, const MCSymbol *KeySym) const override
bool hasSection() const
Check if this global has a custom object file section.
virtual bool isSectionAtomizableBySymbols(const MCSection &Section) const
True if the section is atomized using the symbols in it.
This is an important base class in LLVM.
unsigned emitULEB128IntValue(uint64_t Value, unsigned PadTo=0)
Special case of EmitULEB128Value that avoids the client having to pass in a MCExpr for constant integ...
static bool isWeakForLinker(LinkageTypes Linkage)
Whether the definition of this global may be replaced at link time.
@ S_MOD_INIT_FUNC_POINTERS
S_MOD_INIT_FUNC_POINTERS - Section with only function pointers for initialization.
static unsigned getEntrySizeForKind(SectionKind Kind)
const MCAsmInfo * getAsmInfo() const
Module * getParent()
Get the module that this global value is contained inside of...
@ XTY_CM
Common csect definition. For uninitialized storage.
bool hasImplicitSection() const
Check if section name is present.
bool isArch32Bit() const
Test whether the architecture is 32-bit.
@ XMC_TL
Initialized thread-local variable.
@ WeakAnyLinkage
Keep one copy of named function when linking (weak)
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
GlobalValue * getGlobalValue() const
bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference, const Function &F) const override
void Initialize(MCContext &Ctx, const TargetMachine &TM) override
This method must be called before any actual lowering is done.
bool isMergeableCString() const
MCSymbol * getTargetSymbol(const GlobalValue *GV, const TargetMachine &TM) const override
For functions, this will always return a function descriptor symbol.
static constexpr unsigned NonUniqueID
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
const static MBBSectionID ExceptionSectionID
const MCExpr * getTTypeReference(const MCSymbolRefExpr *Sym, unsigned Encoding, MCStreamer &Streamer) const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Primary interface to the complete machine description for the target machine.
This represents a section on Windows.
uint64_t getArrayNumElements() 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...
MCSection * getStaticDtorSection(unsigned Priority, const MCSymbol *KeySym) const override
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
bool hasLocalLinkage() const
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
bool isThreadLocal() const
If the value is "Thread Local", its value isn't shared by the threads.
const std::vector< LandingPadInfo > & getLandingPads() const
Return a reference to the landing pad info for the current function.
static std::string APIntToHexString(const APInt &AI)
void emitModuleMetadata(MCStreamer &Streamer, Module &M) const override
Emit the module flags that specify the garbage collection information.
static SectionKind getThreadData()
A Module instance is used to store all the information related to an LLVM module.
MCSection * getSectionForConstant(const DataLayout &DL, SectionKind Kind, const Constant *C, Align &Alignment) const override
Given a constant with the SectionKind, return a section that it should be placed in.
const MCExpr * lowerDSOLocalEquivalent(const DSOLocalEquivalent *Equiv, const TargetMachine &TM) const override
@ IMAGE_COMDAT_SELECT_LARGEST
MCSection * SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
Class for arbitrary precision integers.
void Initialize(MCContext &Ctx, const TargetMachine &TM) override
This method must be called before any actual lowering is done.
MCSymbol * getFunctionEntryPointSymbol(const GlobalValue *Func, const TargetMachine &TM) const override
If supported, return the function entry point symbol.
Printable print(const GCNRegPressure &RP, const GCNSubtarget *ST=nullptr)
@ AppendingLinkage
Special purpose, only applies to global arrays.
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
StubValueTy & getGVStubEntry(MCSymbol *Sym)
MCSection * getStaticDtorSection(unsigned Priority, const MCSymbol *KeySym) const override
StringRef - Represent a constant reference to a string, i.e.
So we should use XX3Form_Rcr to implement intrinsic Convert DP outs ins xscvdpsp No builtin are required Round &Convert QP DP(dword[1] is set to zero) No builtin are required Round to Quad Precision because you need to assign rounding mode in instruction Provide builtin(set f128:$vT,(int_ppc_vsx_xsrqpi f128:$vB))(set f128 yields< n x< ty > >< result > yields< ty >< result > No builtin are required Load Store load store see def memrix16 in PPCInstrInfo td Load Store Vector load store outs ins lxsdx set load store with conversion from to DP
MCSymbol * getCFIPersonalitySymbol(const GlobalValue *GV, const TargetMachine &TM, MachineModuleInfo *MMI) const override
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Type * getType() const
All values are typed, get the type of this value.
OutputIt transform(R &&Range, OutputIt d_first, UnaryFunction F)
Wrapper function around std::transform to apply a function to a range and store the result elsewhere.
@ WeakODRLinkage
Same, but only replaced by something equivalent.
static int getSelectionForCOFF(const GlobalValue *GV)
static bool canUsePrivateLabel(const MCAsmInfo &AsmInfo, const MCSection &Section)
LLVMContext & getContext() const
All values hold a context through their type.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Instances of this class represent a uniqued identifier for a section in the current translation unit.
virtual void emitValueToAlignment(Align Alignment, int64_t Value=0, unsigned ValueSize=1, unsigned MaxBytesToEmit=0)
Emit some number of copies of Value until the byte alignment ByteAlignment is reached.
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
void emitLinkerFlagsForUsedCOFF(raw_ostream &OS, const GlobalValue *GV, const Triple &T, Mangler &M)
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
@ AvailableExternallyLinkage
Available for inspection, not emission.
MCSectionCOFF * getCOFFSection(StringRef Section, unsigned Characteristics, SectionKind Kind, StringRef COMDATSymName, int Selection, unsigned UniqueID=GenericSectionID, const char *BeginSymName=nullptr)
const GlobalObject * getAliaseeObject() const
static StringRef getSectionPrefixForGlobal(SectionKind Kind)
Return the section prefix name used by options FunctionsSections and DataSections.
static const Comdat * getWasmComdat(const GlobalValue *GV)
StringRef getName() const
Return a constant reference to the value's name.
MCSection * getUniqueSectionForFunction(const Function &F, const TargetMachine &TM) const override
const std::string & getSourceFileName() const
Get the module's original source file name.
@ CommonLinkage
Tentative definitions.
MBBSectionID getSectionID() const
Returns the section ID of this basic block.
const CustomOperand< const MCSubtargetInfo & > Msg[]
StringRef getName() const
MCSection * getSection() const
Returns the Section this function belongs to.
static SectionKind getData()
static MCSection * selectExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM, MCContext &Ctx, Mangler &Mang, unsigned &NextUniqueID, bool Retain, bool ForceUnique)
MCSymbol * getCFIPersonalitySymbol(const GlobalValue *GV, const TargetMachine &TM, MachineModuleInfo *MMI) const override
void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
SectionKind - This is a simple POD value that classifies the properties of a section.
Function & getFunction()
Return the LLVM function that this machine code represents.
TargetLoweringObjectFileGOFF()
virtual bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute)=0
Add the given Attribute to Symbol.
const static MBBSectionID ColdSectionID
uint64_t value() const
This is a hole in the type system and should not be abused.
StringRef getPrivateGlobalPrefix() const
Lightweight error class with error context and mandatory checking.
This represents a section on a Mach-O system (used by Mac OS X).
const Comdat * getComdat() const
static bool ShouldSetSSPCanaryBitInTB(const MachineFunction *MF)
MCSection * getSectionForCommandLines() const override
If supported, return the section to use for the llvm.commandline metadata.
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...
void Initialize(MCContext &Ctx, const TargetMachine &TM) override
This method must be called before any actual lowering is done.
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
AttributeSet getAttributes() const
Return the attribute set for this global.
@ Require
Adds a requirement that another module flag be present and have a specified value after linking is pe...
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 MCSection * getSectionForConstant(const DataLayout &DL, SectionKind Kind, const Constant *C, Align &Alignment) const
Given a constant with the SectionKind, return a section that it should be placed in.
@ XMC_DS
Descriptor csect.
amdgpu AMDGPU DAG DAG Pattern Instruction Selection
bool binutilsIsAtLeast(int Major, int Minor) const
std::string getInstrProfSectionName(InstrProfSectKind IPSK, Triple::ObjectFormatType OF, bool AddSegmentInfo=true)
Return the name of the profile section corresponding to IPSK.
@ ExternalLinkage
Externally visible function.
ExceptionHandling getExceptionHandlingType() const
static XCOFF::StorageClass getStorageClassForGlobal(const GlobalValue *GV)
@ PrivateLinkage
Like Internal, but omit from symbol table.
PointerIntPair - This class implements a pair of a pointer and small integer.
void emitLinkerFlagsForGlobalCOFF(raw_ostream &OS, const GlobalValue *GV, const Triple &TT, Mangler &Mangler)
MCSection * SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
const MCExpr * lowerRelativeReference(const GlobalValue *LHS, const GlobalValue *RHS, const TargetMachine &TM) const override
COFFYAML::WeakExternalCharacteristics Characteristics
bool isReadOnlyWithRel() const
const Triple & getTargetTriple() const
MachineModuleInfoELF - This is a MachineModuleInfoImpl implementation for ELF targets.
MCSection * getSectionForMachineBasicBlock(const Function &F, const MachineBasicBlock &MBB, const TargetMachine &TM) const override
Returns a unique section for the given machine basic block.
static MCSectionWasm * selectWasmSectionForGlobal(MCContext &Ctx, const GlobalObject *GO, SectionKind Kind, Mangler &Mang, const TargetMachine &TM, bool EmitUniqueSection, unsigned *NextUniqueID)
bool isDeclarationForLinker() const
A raw_ostream that writes to an SmallVector or SmallString.
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...
virtual void emitBytes(StringRef Data)
Emit the bytes in Data into the output.
EnvironmentType getEnvironment() const
Get the parsed environment type of this triple.
const MCExpr * lowerRelativeReference(const GlobalValue *LHS, const GlobalValue *RHS, const TargetMachine &TM) const override
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
const char LLVMTargetMachineRef TM
static MCSectionELF * getStaticStructorSection(MCContext &Ctx, bool UseInitArray, bool IsCtor, unsigned Priority, const MCSymbol *KeySym)
This represents an "assembler immediate".
CodeModel::Model getCodeModel() const
Returns the code model.
MCSection * getSectionForConstant(const DataLayout &DL, SectionKind Kind, const Constant *C, Align &Alignment) const override
Given a mergeable constant with the specified size and relocation information, return a section that ...
MCSection * SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
MCSection * getSectionForLSDA(const Function &F, const MCSymbol &FnSym, const TargetMachine &TM) const override
For functions, this will return the LSDA section.
MCSection * getSectionForJumpTable(const Function &F, const TargetMachine &TM) const override
@ ExternalWeakLinkage
ExternalWeak linkage description.
@ XMC_UL
Uninitialized thread-local variable.
MCSection * getStaticCtorSection(unsigned Priority, const MCSymbol *KeySym) const override
static const Comdat * getELFComdat(const GlobalValue *GV)
@ LinkOnceODRLinkage
Same, but only replaced by something equivalent.
MCSection * getStaticDtorSection(unsigned Priority, const MCSymbol *KeySym) const override
static const GlobalValue * getComdatGVForCOFF(const GlobalValue *GV)
const Module * getModule() const
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...
LLVM Value Representation.
Wrapper for a function that represents a value that functionally represents the original function.
Base class for the full range of assembler expressions which are needed for parsing.
bool isExecuteOnly() const
bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference, const Function &F) const override
Ty & getObjFileInfo()
Keep track of various per-module pieces of information for backends that would like to do so.
static unsigned getWasmSectionFlags(SectionKind K)
@ IMAGE_COMDAT_SELECT_ANY
@ XMC_BS
BSS class (uninitialized static internal)
GlobalValue * getNamedValue(StringRef Name) const
Return the global value in the module with the specified name, of arbitrary type.
const MCSymbolRefExpr * getSymB() const
MachineModuleInfoMachO - This is a MachineModuleInfoImpl implementation for MachO targets.
const MCExpr * lowerRelativeReference(const GlobalValue *LHS, const GlobalValue *RHS, const TargetMachine &TM) const override
TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.