85#define DEBUG_TYPE "asmprinter"
87STATISTIC(NumTOCEntries,
"Number of Total TOC Entries Emitted.");
88STATISTIC(NumTOCConstPool,
"Number of Constant Pool TOC Entries.");
90 "Number of Internal Linkage Global TOC Entries.");
92 "Number of External Linkage Global TOC Entries.");
93STATISTIC(NumTOCJumpTable,
"Number of Jump Table TOC Entries.");
94STATISTIC(NumTOCThreadLocal,
"Number of Thread Local TOC Entries.");
95STATISTIC(NumTOCBlockAddress,
"Number of Block Address TOC Entries.");
96STATISTIC(NumTOCEHBlock,
"Number of EH Block TOC Entries.");
109 using TOCKey = std::pair<const MCSymbol *, MCSymbolRefExpr::VariantKind>;
130 Tag_GNU_Power_ABI_FP = 4,
131 Tag_GNU_Power_ABI_Vector = 8,
132 Tag_GNU_Power_ABI_Struct_Return = 12,
135 Val_GNU_Power_ABI_NoFloat = 0b00,
136 Val_GNU_Power_ABI_HardFloat_DP = 0b01,
137 Val_GNU_Power_ABI_SoftFloat_DP = 0b10,
138 Val_GNU_Power_ABI_HardFloat_SP = 0b11,
140 Val_GNU_Power_ABI_LDBL_IBM128 = 0b0100,
141 Val_GNU_Power_ABI_LDBL_64 = 0b1000,
142 Val_GNU_Power_ABI_LDBL_IEEE128 = 0b1100,
166 std::unique_ptr<MCStreamer> Streamer)
172 TOCType_ConstantPool,
173 TOCType_GlobalExternal,
174 TOCType_GlobalInternal,
177 TOCType_BlockAddress,
183 MCSymbolRefExpr::VariantKind::VK_None);
219class PPCLinuxAsmPrinter :
public PPCAsmPrinter {
222 std::unique_ptr<MCStreamer> Streamer)
223 : PPCAsmPrinter(
TM,
std::
move(Streamer)) {}
226 return "Linux PPC Assembly Printer";
229 void emitGNUAttributes(
Module &M);
231 void emitStartOfAsmFile(
Module &M)
override;
232 void emitEndOfAsmFile(
Module &)
override;
234 void emitFunctionEntryLabel()
override;
236 void emitFunctionBodyStart()
override;
237 void emitFunctionBodyEnd()
override;
241class PPCAIXAsmPrinter :
public PPCAsmPrinter {
249 std::string FormatIndicatorAndUniqueModId;
257 void emitTracebackTable();
267 PPCAIXAsmPrinter(
TargetMachine &
TM, std::unique_ptr<MCStreamer> Streamer)
268 : PPCAsmPrinter(
TM,
std::
move(Streamer)) {
269 if (MAI->isLittleEndian())
271 "cannot create AIX PPC Assembly Printer for a little-endian target");
274 StringRef getPassName()
const override {
return "AIX PPC Assembly Printer"; }
276 bool doInitialization(
Module &M)
override;
279 bool IsCtor)
override;
285 void emitFunctionDescriptor()
override;
287 void emitFunctionEntryLabel()
override;
289 void emitFunctionBodyEnd()
override;
291 void emitPGORefs(
Module &M);
293 void emitEndOfAsmFile(
Module &)
override;
299 bool doFinalization(
Module &M)
override;
301 void emitTTypeReference(
const GlobalValue *GV,
unsigned Encoding)
override;
303 void emitModuleCommandLines(
Module &M)
override;
312 getSymbol(GV)->
print(O, MAI);
316void PPCAsmPrinter::printOperand(
const MachineInstr *
MI,
unsigned OpNo,
339 O <<
DL.getPrivateGlobalPrefix() <<
"CPI" << getFunctionNumber() <<
'_'
346 PrintSymbolOperand(MO, O);
358bool PPCAsmPrinter::PrintAsmOperand(
const MachineInstr *
MI,
unsigned OpNo,
361 if (ExtraCode && ExtraCode[0]) {
362 if (ExtraCode[1] != 0)
return true;
364 switch (ExtraCode[0]) {
370 if (!
MI->getOperand(OpNo).isReg() ||
371 OpNo+1 ==
MI->getNumOperands() ||
372 !
MI->getOperand(OpNo+1).isReg())
379 if (
MI->getOperand(OpNo).isImm())
383 if(!
MI->getOperand(OpNo).isReg())
389 Reg = PPC::VSX32 + (
Reg - PPC::V0);
391 Reg = PPC::VSX32 + (Reg - PPC::VF0);
407bool PPCAsmPrinter::PrintAsmMemoryOperand(
const MachineInstr *
MI,
unsigned OpNo,
408 const char *ExtraCode,
410 if (ExtraCode && ExtraCode[0]) {
411 if (ExtraCode[1] != 0)
return true;
413 switch (ExtraCode[0]) {
414 default:
return true;
416 O << getDataLayout().getPointerSize() <<
"(";
427 if (
MI->getOperand(OpNo).isImm())
438 assert(
MI->getOperand(OpNo).isReg());
443 assert(
MI->getOperand(OpNo).isReg());
453 case PPCAsmPrinter::TOCType_ConstantPool:
456 case PPCAsmPrinter::TOCType_GlobalInternal:
457 ++NumTOCGlobalInternal;
459 case PPCAsmPrinter::TOCType_GlobalExternal:
460 ++NumTOCGlobalExternal;
462 case PPCAsmPrinter::TOCType_JumpTable:
465 case PPCAsmPrinter::TOCType_ThreadLocal:
468 case PPCAsmPrinter::TOCType_BlockAddress:
469 ++NumTOCBlockAddress;
471 case PPCAsmPrinter::TOCType_EHBlock:
488 assert(GV &&
"expected global for MO_GlobalAddress");
510PPCAsmPrinter::lookUpOrCreateTOCEntry(
const MCSymbol *
Sym, TOCEntryType
Type,
513 if (!
TOC.contains({Sym, Kind}))
518 TOCEntry = createTempSymbol(
"C");
523 unsigned NumNOPBytes =
MI.getOperand(1).getImm();
525 auto &Ctx = OutStreamer->getContext();
526 MCSymbol *MILabel = Ctx.createTempSymbol();
527 OutStreamer->emitLabel(MILabel);
530 assert(NumNOPBytes % 4 == 0 &&
"Invalid number of NOP bytes requested!");
536 while (NumNOPBytes > 0) {
537 if (MII ==
MBB.
end() || MII->isCall() ||
538 MII->getOpcode() == PPC::DBG_VALUE ||
539 MII->getOpcode() == TargetOpcode::PATCHPOINT ||
540 MII->getOpcode() == TargetOpcode::STACKMAP)
547 for (
unsigned i = 0; i < NumNOPBytes; i += 4)
554 auto &Ctx = OutStreamer->getContext();
555 MCSymbol *MILabel = Ctx.createTempSymbol();
556 OutStreamer->emitLabel(MILabel);
561 unsigned EncodedBytes = 0;
564 if (CalleeMO.
isImm()) {
565 int64_t CallTarget = CalleeMO.
getImm();
567 assert((CallTarget & 0xFFFFFFFFFFFF) == CallTarget &&
568 "High 16 bits of call target should be zero.");
569 Register ScratchReg =
MI.getOperand(Opers.getNextScratchIdx()).getReg();
574 .addImm((CallTarget >> 32) & 0xFFFF));
579 .addImm(32).addImm(16));
584 .addImm((CallTarget >> 16) & 0xFFFF));
589 .addImm(CallTarget & 0xFFFF));
595 .addImm(TOCSaveOffset)
608 .addReg(ScratchReg));
613 .addReg(ScratchReg));
618 .addReg(ScratchReg));
626 .addImm(TOCSaveOffset)
632 MCSymbol *MOSymbol = getSymbol(GValue);
644 unsigned NumBytes = Opers.getNumPatchBytes();
645 assert(NumBytes >= EncodedBytes &&
646 "Patchpoint can't request size less than the length of a call.");
647 assert((NumBytes - EncodedBytes) % 4 == 0 &&
648 "Invalid number of NOP bytes requested!");
649 for (
unsigned i = EncodedBytes; i < NumBytes; i += 4)
660 SymName =
".__tls_get_addr";
662 case PPC::GETtlsTpointer32AIX:
663 SymName =
".__get_tpointer";
665 case PPC::GETtlsMOD32AIX:
666 case PPC::GETtlsMOD64AIX:
667 SymName =
".__tls_get_mod";
678 "Only expecting to emit calls to get the thread pointer on AIX!");
683 EmitToStreamer(*OutStreamer,
MCInstBuilder(PPC::BLA).addExpr(TlsRef));
691 unsigned Opcode = PPC::BL8_NOP_TLS;
693 assert(
MI->getNumOperands() >= 3 &&
"Expecting at least 3 operands from MI");
697 Opcode = PPC::BL8_NOTOC_TLS;
699 const Module *
M = MF->getFunction().getParent();
702 ((Subtarget->
isPPC64() &&
MI->getOperand(0).getReg() == PPC::X3) ||
703 (!Subtarget->
isPPC64() &&
MI->getOperand(0).getReg() == PPC::R3)) &&
704 "GETtls[ld]ADDR[32] must define GPR3");
706 ((Subtarget->
isPPC64() &&
MI->getOperand(1).getReg() == PPC::X3) ||
707 (!Subtarget->
isPPC64() &&
MI->getOperand(1).getReg() == PPC::R3)) &&
708 "GETtls[ld]ADDR[32] must read GPR3");
717 assert((
MI->getOpcode() == PPC::GETtlsMOD32AIX ||
718 MI->getOpcode() == PPC::GETtlsMOD64AIX ||
719 (
MI->getOperand(2).isReg() &&
720 MI->getOperand(2).getReg() == VarOffsetReg)) &&
721 "GETtls[ld]ADDR[32] must read GPR4");
722 EmitAIXTlsCallHelper(
MI);
726 MCSymbol *TlsGetAddr = OutContext.getOrCreateSymbol(
"__tls_get_addr");
741 MCSymbol *MOSymbol = getSymbol(GValue);
743 EmitToStreamer(*OutStreamer,
745 : (
unsigned)PPC::BL_TLS)
768static PPCAsmPrinter::TOCEntryType
773 return PPCAsmPrinter::TOCType_ThreadLocal;
782 return PPCAsmPrinter::TOCType_GlobalExternal;
784 return PPCAsmPrinter::TOCType_GlobalInternal;
787 return PPCAsmPrinter::TOCType_ConstantPool;
789 return PPCAsmPrinter::TOCType_JumpTable;
791 return PPCAsmPrinter::TOCType_BlockAddress;
800 PPC_MC::verifyInstructionPredicates(
MI->getOpcode(),
801 getSubtargetInfo().getFeatureBits());
804 const bool IsPPC64 = Subtarget->
isPPC64();
805 const bool IsAIX = Subtarget->
isAIXABI();
806 const bool HasAIXSmallLocalTLS = Subtarget->hasAIXSmallLocalExecTLS() ||
807 Subtarget->hasAIXSmallLocalDynamicTLS();
808 const Module *
M = MF->getFunction().getParent();
813 if (!
MI->isInlineAsm()) {
817 if (Subtarget->hasSPE()) {
818 if (PPC::F4RCRegClass.
contains(Reg) ||
827 if (PPC::SPERCRegClass.
contains(Reg))
835 auto getTOCRelocAdjustedExprForXCOFF = [
this](
const MCExpr *Expr,
844 OriginalOffset - llvm::SignExtend32<16>(OriginalOffset);
849 auto getTOCEntryLoadingExprForXCOFF =
850 [IsPPC64, getTOCRelocAdjustedExprForXCOFF,
853 MCSymbolRefExpr::VariantKind::VK_None) ->
const MCExpr * {
854 const unsigned EntryByteSize = IsPPC64 ? 8 : 4;
855 const auto TOCEntryIter =
TOC.find({MOSymbol, VK});
857 "Could not find the TOC entry for this symbol.");
858 const ptrdiff_t EntryDistanceFromTOCBase =
859 (TOCEntryIter -
TOC.begin()) * EntryByteSize;
860 constexpr int16_t PositiveTOCRange = INT16_MAX;
862 if (EntryDistanceFromTOCBase > PositiveTOCRange)
863 return getTOCRelocAdjustedExprForXCOFF(Expr, EntryDistanceFromTOCBase);
875 assert(MO.
isGlobal() &&
"Only expecting a global MachineOperand here!\n");
878 return MCSymbolRefExpr::VariantKind::VK_PPC_AIX_TLSLE;
880 return MCSymbolRefExpr::VariantKind::VK_PPC_AIX_TLSIE;
887 return MCSymbolRefExpr::VariantKind::VK_PPC_AIX_TLSGDM;
889 return MCSymbolRefExpr::VariantKind::VK_PPC_AIX_TLSGD;
894 return MCSymbolRefExpr::VariantKind::VK_PPC_AIX_TLSLD;
896 return MCSymbolRefExpr::VariantKind::VK_PPC_AIX_TLSML;
897 return MCSymbolRefExpr::VariantKind::VK_None;
901 switch (
MI->getOpcode()) {
903 case TargetOpcode::DBG_VALUE:
905 case TargetOpcode::STACKMAP:
906 return LowerSTACKMAP(SM, *
MI);
907 case TargetOpcode::PATCHPOINT:
908 return LowerPATCHPOINT(SM, *
MI);
910 case PPC::MoveGOTtoLR: {
918 OutContext.getOrCreateSymbol(
StringRef(
"_GLOBAL_OFFSET_TABLE_"));
927 EmitToStreamer(*OutStreamer,
MCInstBuilder(PPC::BL).addExpr(OffsExpr));
930 case PPC::MovePCtoLR:
931 case PPC::MovePCtoLR8: {
936 MCSymbol *PICBase = MF->getPICBaseSymbol();
939 EmitToStreamer(*OutStreamer,
946 OutStreamer->emitLabel(PICBase);
949 case PPC::UpdateGBR: {
958 if (Subtarget->isSecurePlt() && isPositionIndependent() ) {
960 MCSymbol *BaseSymbol = OutContext.getOrCreateSymbol(
972 MCInstBuilder(PPC::ADDIS).addReg(PICR).addReg(PICR).addExpr(DeltaHi));
977 MCInstBuilder(PPC::ADDI).addReg(PICR).addReg(PICR).addExpr(DeltaLo));
997 EmitToStreamer(*OutStreamer, TmpInst);
1003 EmitToStreamer(*OutStreamer, TmpInst);
1016 "Invalid operand for LWZtoc.");
1028 EmitToStreamer(*OutStreamer, TmpInst);
1048 "This pseudo should only be selected for 32-bit small code model.");
1049 Exp = getTOCEntryLoadingExprForXCOFF(MOSymbol, Exp, VK);
1054 OutStreamer->getCommentOS() << MO <<
'\n';
1055 EmitToStreamer(*OutStreamer, TmpInst);
1062 OutContext.getOrCreateSymbol(
Twine(
".LTOC")), OutContext);
1065 EmitToStreamer(*OutStreamer, TmpInst);
1069 case PPC::ADDItoc8: {
1071 "PseudoOp only valid for small code model AIX");
1077 TmpInst.
setOpcode((!IsPPC64) ? (PPC::LA) : (PPC::LA8));
1090 EmitToStreamer(*OutStreamer, TmpInst);
1105 "Invalid operand!");
1122 IsAIX ? getTOCEntryLoadingExprForXCOFF(MOSymbol, Exp, VK) : Exp);
1125 if (isVerbose() && IsAIX)
1126 OutStreamer->getCommentOS() << MO <<
'\n';
1127 EmitToStreamer(*OutStreamer, TmpInst);
1130 case PPC::ADDIStocHA: {
1134 "Invalid operand for ADDIStocHA.");
1135 assert((IsAIX && !IsPPC64 &&
1137 "This pseudo should only be selected for 32-bit large code model on"
1165 return GV->hasAttribute(
"toc-data");
1173 EmitToStreamer(*OutStreamer, TmpInst);
1176 case PPC::LWZtocL: {
1180 "Invalid operand for LWZtocL.");
1181 assert(IsAIX && !IsPPC64 &&
1183 "This pseudo should only be selected for 32-bit large code model on"
1207 EmitToStreamer(*OutStreamer, TmpInst);
1210 case PPC::ADDIStocHA8: {
1222 "Invalid operand for ADDIStocHA8!");
1228 const bool GlobalToc =
1250 EmitToStreamer(*OutStreamer, TmpInst);
1266 "Invalid operand for LDtocL!");
1270 "LDtocL used on symbol that could be accessed directly is "
1271 "invalid. Must match ADDIStocHA8."));
1285 EmitToStreamer(*OutStreamer, TmpInst);
1289 case PPC::ADDItocL8: {
1293 unsigned Op =
MI->getOpcode();
1296 TmpInst.
setOpcode(
Op == PPC::ADDItocL8 ? PPC::ADDI8 : PPC::LA);
1301 : MO.
isGlobal() &&
"Invalid operand for ADDItocL8.");
1303 "Interposable definitions must use indirect accesses.");
1315 EmitToStreamer(*OutStreamer, TmpInst);
1318 case PPC::ADDISgotTprelHA: {
1321 assert(IsPPC64 &&
"Not supported for 32-bit PowerPC");
1324 MCSymbol *MOSymbol = getSymbol(GValue);
1325 const MCExpr *SymGotTprel =
1329 .addReg(
MI->getOperand(0).getReg())
1330 .
addReg(
MI->getOperand(1).getReg())
1334 case PPC::LDgotTprelL:
1335 case PPC::LDgotTprelL32: {
1340 TmpInst.
setOpcode(IsPPC64 ? PPC::LD : PPC::LWZ);
1343 MCSymbol *MOSymbol = getSymbol(GValue);
1349 EmitToStreamer(*OutStreamer, TmpInst);
1353 case PPC::PPC32PICGOT: {
1354 MCSymbol *GOTSymbol = OutContext.getOrCreateSymbol(
StringRef(
"_GLOBAL_OFFSET_TABLE_"));
1355 MCSymbol *GOTRef = OutContext.createTempSymbol();
1356 MCSymbol *NextInstr = OutContext.createTempSymbol();
1366 OutStreamer->emitLabel(GOTRef);
1367 OutStreamer->emitValue(OffsExpr, 4);
1368 OutStreamer->emitLabel(NextInstr);
1370 .addReg(
MI->getOperand(0).getReg()));
1372 .addReg(
MI->getOperand(1).getReg())
1374 .
addReg(
MI->getOperand(0).getReg()));
1376 .addReg(
MI->getOperand(0).getReg())
1377 .
addReg(
MI->getOperand(1).getReg())
1378 .
addReg(
MI->getOperand(0).getReg()));
1381 case PPC::PPC32GOT: {
1383 OutContext.getOrCreateSymbol(
StringRef(
"_GLOBAL_OFFSET_TABLE_"));
1389 .addReg(
MI->getOperand(0).getReg())
1392 .addReg(
MI->getOperand(0).getReg())
1393 .
addReg(
MI->getOperand(0).getReg())
1397 case PPC::ADDIStlsgdHA: {
1400 assert(IsPPC64 &&
"Not supported for 32-bit PowerPC");
1403 MCSymbol *MOSymbol = getSymbol(GValue);
1404 const MCExpr *SymGotTlsGD =
1408 .addReg(
MI->getOperand(0).getReg())
1409 .
addReg(
MI->getOperand(1).getReg())
1413 case PPC::ADDItlsgdL:
1416 case PPC::ADDItlsgdL32: {
1421 MCSymbol *MOSymbol = getSymbol(GValue);
1426 EmitToStreamer(*OutStreamer,
1428 .addReg(
MI->getOperand(0).getReg())
1429 .
addReg(
MI->getOperand(1).getReg())
1433 case PPC::GETtlsMOD32AIX:
1434 case PPC::GETtlsMOD64AIX:
1438 case PPC::GETtlsADDR:
1441 case PPC::GETtlsADDRPCREL:
1442 case PPC::GETtlsADDR32AIX:
1443 case PPC::GETtlsADDR64AIX:
1447 case PPC::GETtlsADDR32: {
1453 case PPC::GETtlsTpointer32AIX: {
1456 EmitAIXTlsCallHelper(
MI);
1459 case PPC::ADDIStlsldHA: {
1462 assert(IsPPC64 &&
"Not supported for 32-bit PowerPC");
1465 MCSymbol *MOSymbol = getSymbol(GValue);
1466 const MCExpr *SymGotTlsLD =
1470 .addReg(
MI->getOperand(0).getReg())
1471 .
addReg(
MI->getOperand(1).getReg())
1475 case PPC::ADDItlsldL:
1478 case PPC::ADDItlsldL32: {
1483 MCSymbol *MOSymbol = getSymbol(GValue);
1488 EmitToStreamer(*OutStreamer,
1490 .addReg(
MI->getOperand(0).getReg())
1491 .
addReg(
MI->getOperand(1).getReg())
1495 case PPC::GETtlsldADDR:
1498 case PPC::GETtlsldADDRPCREL:
1499 case PPC::GETtlsldADDR32: {
1505 case PPC::ADDISdtprelHA:
1508 case PPC::ADDISdtprelHA32: {
1513 MCSymbol *MOSymbol = getSymbol(GValue);
1514 const MCExpr *SymDtprel =
1520 .addReg(
MI->getOperand(0).getReg())
1521 .
addReg(
MI->getOperand(1).getReg())
1525 case PPC::PADDIdtprel: {
1530 MCSymbol *MOSymbol = getSymbol(GValue);
1534 .addReg(
MI->getOperand(0).getReg())
1535 .
addReg(
MI->getOperand(1).getReg())
1540 case PPC::ADDIdtprelL:
1543 case PPC::ADDIdtprelL32: {
1548 MCSymbol *MOSymbol = getSymbol(GValue);
1549 const MCExpr *SymDtprel =
1552 EmitToStreamer(*OutStreamer,
1554 .addReg(
MI->getOperand(0).getReg())
1555 .
addReg(
MI->getOperand(1).getReg())
1561 if (!Subtarget->hasMFOCRF()) {
1564 unsigned NewOpcode =
1565 MI->getOpcode() == PPC::MFOCRF ? PPC::MFCR : PPC::MFCR8;
1569 .addReg(
MI->getOperand(0).getReg()));
1575 if (!Subtarget->hasMFOCRF()) {
1578 unsigned NewOpcode =
1579 MI->getOpcode() == PPC::MTOCRF ? PPC::MTCRF : PPC::MTCRF8;
1580 unsigned Mask = 0x80 >> OutContext.getRegisterInfo()
1581 ->getEncodingValue(
MI->getOperand(0).getReg());
1586 .addReg(
MI->getOperand(1).getReg()));
1596 unsigned OpNum = (
MI->getOpcode() == PPC::STD) ? 2 : 1;
1602 TempMO.getOperandNo() == 1)
1639 if (!HasAIXSmallLocalTLS)
1641 bool IsMIADDI8 =
MI->getOpcode() == PPC::ADDI8;
1642 unsigned OpNum = IsMIADDI8 ? 2 : 1;
1658 EmitToStreamer(*OutStreamer, TmpInst);
1664 case PPC::PseudoEIEIO: {
1667 MCInstBuilder(PPC::ORI).addReg(PPC::X2).addReg(PPC::X2).addImm(0));
1670 MCInstBuilder(PPC::ORI).addReg(PPC::X2).addReg(PPC::X2).addImm(0));
1671 EmitToStreamer(*OutStreamer,
MCInstBuilder(PPC::EnforceIEIO));
1677 EmitToStreamer(*OutStreamer, TmpInst);
1693 assert(MO.
isGlobal() &&
"Only expecting a global MachineOperand here!");
1701 "Only local-exec accesses are handled!");
1707 const auto TLSVarsMapEntryIter = TLSVarsToAddressMapping.
find(GValue);
1708 if (TLSVarsMapEntryIter == TLSVarsToAddressMapping.
end())
1709 assert(IsGlobalADeclaration &&
1710 "Only expecting to find extern TLS variables not present in the TLS "
1711 "variable-to-address map!");
1713 unsigned TLSVarAddress =
1714 IsGlobalADeclaration ? 0 : TLSVarsMapEntryIter->second;
1725 if (FinalAddress >= 32768) {
1732 ptrdiff_t Delta = ((FinalAddress + 32768) & ~0xFFFF);
1735 assert(((InstDisp < 32768) &&
1736 (InstDisp >= -32768)) &&
1737 "Expecting the instruction displacement for local-exec TLS "
1738 "variables to be between [-32768, 32768)!");
1746void PPCLinuxAsmPrinter::emitGNUAttributes(
Module &M) {
1748 Metadata *MD =
M.getModuleFlag(
"float-abi");
1749 MDString *FloatABI = dyn_cast_or_null<MDString>(MD);
1754 if (flt ==
"doubledouble")
1755 OutStreamer->emitGNUAttribute(Tag_GNU_Power_ABI_FP,
1756 Val_GNU_Power_ABI_HardFloat_DP |
1757 Val_GNU_Power_ABI_LDBL_IBM128);
1758 else if (flt ==
"ieeequad")
1759 OutStreamer->emitGNUAttribute(Tag_GNU_Power_ABI_FP,
1760 Val_GNU_Power_ABI_HardFloat_DP |
1761 Val_GNU_Power_ABI_LDBL_IEEE128);
1762 else if (flt ==
"ieeedouble")
1763 OutStreamer->emitGNUAttribute(Tag_GNU_Power_ABI_FP,
1764 Val_GNU_Power_ABI_HardFloat_DP |
1765 Val_GNU_Power_ABI_LDBL_64);
1768void PPCLinuxAsmPrinter::emitInstruction(
const MachineInstr *
MI) {
1770 return PPCAsmPrinter::emitInstruction(
MI);
1772 switch (
MI->getOpcode()) {
1774 return PPCAsmPrinter::emitInstruction(
MI);
1775 case TargetOpcode::PATCHABLE_FUNCTION_ENTER: {
1787 MCSymbol *BeginOfSled = OutContext.createTempSymbol();
1788 MCSymbol *EndOfSled = OutContext.createTempSymbol();
1789 OutStreamer->emitLabel(BeginOfSled);
1790 EmitToStreamer(*OutStreamer,
1796 MCInstBuilder(PPC::STD).addReg(PPC::X0).addImm(-8).addReg(PPC::X1));
1797 EmitToStreamer(*OutStreamer,
MCInstBuilder(PPC::MFLR8).addReg(PPC::X0));
1798 EmitToStreamer(*OutStreamer,
1801 OutContext.getOrCreateSymbol(
"__xray_FunctionEntry"),
1803 EmitToStreamer(*OutStreamer,
MCInstBuilder(PPC::MTLR8).addReg(PPC::X0));
1804 OutStreamer->emitLabel(EndOfSled);
1805 recordSled(BeginOfSled, *
MI, SledKind::FUNCTION_ENTER, 2);
1808 case TargetOpcode::PATCHABLE_RET: {
1809 unsigned RetOpcode =
MI->getOperand(0).getImm();
1819 if (RetOpcode == PPC::BCCLR) {
1820 IsConditional =
true;
1821 }
else if (RetOpcode == PPC::TCRETURNdi8 || RetOpcode == PPC::TCRETURNri8 ||
1822 RetOpcode == PPC::TCRETURNai8) {
1824 }
else if (RetOpcode == PPC::BLR8 || RetOpcode == PPC::TAILB8) {
1825 IsConditional =
false;
1827 EmitToStreamer(*OutStreamer, RetInst);
1832 if (IsConditional) {
1851 FallthroughLabel = OutContext.createTempSymbol();
1857 .
addReg(
MI->getOperand(2).getReg())
1874 OutStreamer->emitCodeAlignment(
Align(8), &getSubtargetInfo());
1875 MCSymbol *BeginOfSled = OutContext.createTempSymbol();
1876 OutStreamer->emitLabel(BeginOfSled);
1877 EmitToStreamer(*OutStreamer, RetInst);
1881 MCInstBuilder(PPC::STD).addReg(PPC::X0).addImm(-8).addReg(PPC::X1));
1882 EmitToStreamer(*OutStreamer,
MCInstBuilder(PPC::MFLR8).addReg(PPC::X0));
1883 EmitToStreamer(*OutStreamer,
1886 OutContext.getOrCreateSymbol(
"__xray_FunctionExit"),
1888 EmitToStreamer(*OutStreamer,
MCInstBuilder(PPC::MTLR8).addReg(PPC::X0));
1889 EmitToStreamer(*OutStreamer, RetInst);
1891 OutStreamer->emitLabel(FallthroughLabel);
1892 recordSled(BeginOfSled, *
MI, SledKind::FUNCTION_EXIT, 2);
1895 case TargetOpcode::PATCHABLE_FUNCTION_EXIT:
1897 case TargetOpcode::PATCHABLE_TAIL_CALL:
1901 "around this assert.");
1905void PPCLinuxAsmPrinter::emitStartOfAsmFile(
Module &M) {
1913 !isPositionIndependent())
1919 OutStreamer->switchSection(OutContext.getELFSection(
1922 MCSymbol *TOCSym = OutContext.getOrCreateSymbol(
Twine(
".LTOC"));
1923 MCSymbol *CurrentPos = OutContext.createTempSymbol();
1925 OutStreamer->emitLabel(CurrentPos);
1934 OutStreamer->emitAssignment(TOCSym, tocExpr);
1936 OutStreamer->switchSection(getObjFileLowering().getTextSection());
1939void PPCLinuxAsmPrinter::emitFunctionEntryLabel() {
1942 (!isPositionIndependent() ||
1948 if (PPCFI->
usesPICBase() && !Subtarget->isSecurePlt()) {
1950 MCSymbol *PICBase = MF->getPICBaseSymbol();
1951 OutStreamer->emitLabel(RelocSymbol);
1959 OutStreamer->emitValue(OffsExpr, 4);
1960 OutStreamer->emitLabel(CurrentFnSym);
1973 && !MF->getRegInfo().use_empty(PPC::X2)) {
1978 const MCExpr *TOCDeltaExpr =
1985 OutStreamer->emitValue(TOCDeltaExpr, 8);
1994 OutStreamer->switchSection(Section);
1995 OutStreamer->emitLabel(CurrentFnSym);
1996 OutStreamer->emitValueToAlignment(
Align(8));
1997 MCSymbol *Symbol1 = CurrentFnSymForSize;
2004 OutStreamer->emitValue(
2008 OutStreamer->emitIntValue(0, 8 );
2009 OutStreamer->switchSection(Current.first, Current.second);
2012void PPCLinuxAsmPrinter::emitEndOfAsmFile(
Module &M) {
2015 bool isPPC64 =
DL.getPointerSizeInBits() == 64;
2025 OutStreamer->emitSymbolValue(
2026 GetExternalSymbolSymbol(
"__parse_hwcap_and_convert_at_platform"),
2027 MAI->getCodePointerSize());
2028 emitGNUAttributes(M);
2031 const char *
Name = isPPC64 ?
".toc" :
".got2";
2034 OutStreamer->switchSection(Section);
2036 OutStreamer->emitValueToAlignment(
Align(4));
2038 for (
const auto &TOCMapPair : TOC) {
2039 const MCSymbol *
const TOCEntryTarget = TOCMapPair.first.first;
2040 MCSymbol *
const TOCEntryLabel = TOCMapPair.second;
2042 OutStreamer->emitLabel(TOCEntryLabel);
2044 TS->
emitTCEntry(*TOCEntryTarget, TOCMapPair.first.second);
2046 OutStreamer->emitSymbolValue(TOCEntryTarget, 4);
2050 PPCAsmPrinter::emitEndOfAsmFile(M);
2054void PPCLinuxAsmPrinter::emitFunctionBodyStart() {
2087 const bool UsesX2OrR2 = !MF->getRegInfo().use_empty(PPC::X2) ||
2088 !MF->getRegInfo().use_empty(PPC::R2);
2097 if (NonPCrelGEPRequired || PCrelGEPRequired) {
2102 OutStreamer->emitLabel(GlobalEntryLabel);
2108 const MCExpr *TOCDeltaExpr =
2110 GlobalEntryLabelExp, OutContext);
2116 .addExpr(TOCDeltaHi));
2122 .addExpr(TOCDeltaLo));
2125 const MCExpr *TOCOffsetDeltaExpr =
2127 GlobalEntryLabelExp, OutContext);
2131 .addExpr(TOCOffsetDeltaExpr)
2140 OutStreamer->emitLabel(LocalEntryLabel);
2143 const MCExpr *LocalOffsetExp =
2145 GlobalEntryLabelExp, OutContext);
2149 TS->
emitLocalEntry(cast<MCSymbolELF>(CurrentFnSym), LocalOffsetExp);
2172 if (MF->getFrameInfo().hasCalls() || MF->getFrameInfo().hasTailCall() ||
2173 MF->hasInlineAsm() || (!PPCFI->
usesTOCBasePtr() && UsesX2OrR2)) {
2185void PPCLinuxAsmPrinter::emitFunctionBodyEnd() {
2194 OutStreamer->emitIntValue(0, 4);
2195 OutStreamer->emitIntValue(0, 8);
2199void PPCAIXAsmPrinter::emitLinkage(
const GlobalValue *GV,
2202 assert(MAI->hasVisibilityOnlyWithLinkage() &&
2203 "AIX's linkage directives take a visibility setting.");
2224 "InternalLinkage should not have other visibility setting.");
2236 if (!
TM.getIgnoreXCOFFVisibility()) {
2239 "Cannot not be both dllexport and non-default visibility");
2245 VisibilityAttr = MAI->getExportedVisibilityAttr();
2248 VisibilityAttr = MAI->getHiddenVisibilityAttr();
2251 VisibilityAttr = MAI->getProtectedVisibilityAttr();
2261 OutStreamer->emitXCOFFSymbolLinkageWithVisibility(GVSym, LinkageAttr,
2268 cast<MCSectionXCOFF>(getObjFileLowering().getSectionForFunctionDescriptor(
2277uint16_t PPCAIXAsmPrinter::getNumberOfVRSaved() {
2282 if (Subtarget.
isAIXABI() && Subtarget.hasAltivec() &&
2283 TM.getAIXExtendedAltivecABI()) {
2285 for (
unsigned Reg = PPC::V20;
Reg <= PPC::V31; ++
Reg)
2286 if (
MRI.isPhysRegModified(Reg))
2288 return PPC::V31 - Reg + 1;
2293void PPCAIXAsmPrinter::emitFunctionBodyEnd() {
2295 if (!
TM.getXCOFFTracebackTable())
2298 emitTracebackTable();
2306 (getNumberOfVRSaved() > 0)) {
2308 OutStreamer->switchSection(getObjFileLowering().getCompactUnwindSection());
2311 OutStreamer->emitLabel(EHInfoLabel);
2314 OutStreamer->emitInt32(0);
2316 const DataLayout &
DL = MMI->getModule()->getDataLayout();
2319 OutStreamer->emitValueToAlignment(
Align(PointerSize));
2321 OutStreamer->emitIntValue(0, PointerSize);
2322 OutStreamer->emitIntValue(0, PointerSize);
2323 OutStreamer->switchSection(MF->
getSection());
2327void PPCAIXAsmPrinter::emitTracebackTable() {
2331 OutStreamer->emitLabel(FuncEnd);
2333 OutStreamer->AddComment(
"Traceback table begin");
2335 OutStreamer->emitIntValueInHexWithPadding(0, 4 );
2340 auto EmitComment = [&]() {
2341 OutStreamer->AddComment(CommentOS.str());
2342 CommentString.
clear();
2347 OutStreamer->emitIntValueInHexWithPadding(
Value,
Size);
2351 CommentOS <<
"Version = " <<
Version;
2352 EmitCommentAndValue(Version, 1);
2362 CommentOS <<
"Language = "
2364 EmitCommentAndValue(LanguageIdentifier, 1);
2367 uint32_t FirstHalfOfMandatoryField = 0;
2378 for (
unsigned Reg = PPC::F0;
Reg <= PPC::F31; ++
Reg) {
2379 if (
MRI.isPhysRegUsed(Reg,
true)) {
2385#define GENBOOLCOMMENT(Prefix, V, Field) \
2386 CommentOS << (Prefix) << ((V) & (TracebackTable::Field##Mask) ? "+" : "-") \
2389#define GENVALUECOMMENT(PrefixAndName, V, Field) \
2390 CommentOS << (PrefixAndName) << " = " \
2391 << static_cast<unsigned>(((V) & (TracebackTable::Field##Mask)) >> \
2392 (TracebackTable::Field##Shift))
2395 GENBOOLCOMMENT(
", ", FirstHalfOfMandatoryField, IsOutOfLineEpilogOrPrologue);
2398 GENBOOLCOMMENT(
"", FirstHalfOfMandatoryField, HasTraceBackTableOffset);
2399 GENBOOLCOMMENT(
", ", FirstHalfOfMandatoryField, IsInternalProcedure);
2402 GENBOOLCOMMENT(
"", FirstHalfOfMandatoryField, HasControlledStorage);
2406 GENBOOLCOMMENT(
"", FirstHalfOfMandatoryField, IsFloatingPointPresent);
2409 IsFloatingPointOperationLogOrAbortEnabled);
2412 OutStreamer->emitIntValueInHexWithPadding(
2413 (FirstHalfOfMandatoryField & 0x0000ff00) >> 8, 1);
2421 if (FrameReg == (Subtarget->
isPPC64() ? PPC::X31 : PPC::R31))
2425 if (!MustSaveCRs.
empty())
2431 GENBOOLCOMMENT(
"", FirstHalfOfMandatoryField, IsInterruptHandler);
2432 GENBOOLCOMMENT(
", ", FirstHalfOfMandatoryField, IsFunctionNamePresent);
2436 OnConditionDirective);
2440 OutStreamer->emitIntValueInHexWithPadding((FirstHalfOfMandatoryField & 0xff),
2444 uint32_t SecondHalfOfMandatoryField = 0;
2451 for (
unsigned Reg = PPC::F14;
Reg <= PPC::F31; ++
Reg) {
2452 if (
MRI.isPhysRegModified(Reg)) {
2453 FPRSaved = PPC::F31 -
Reg + 1;
2459 GENBOOLCOMMENT(
"", SecondHalfOfMandatoryField, IsBackChainStored);
2461 GENVALUECOMMENT(
", NumOfFPRsSaved", SecondHalfOfMandatoryField, FPRSaved);
2463 OutStreamer->emitIntValueInHexWithPadding(
2464 (SecondHalfOfMandatoryField & 0xff000000) >> 24, 1);
2470 bool HasVectorInst =
false;
2471 for (
unsigned Reg = PPC::V0;
Reg <= PPC::V31; ++
Reg)
2472 if (
MRI.isPhysRegUsed(Reg,
true)) {
2474 HasVectorInst =
true;
2481 uint16_t NumOfVRSaved = getNumberOfVRSaved();
2482 bool ShouldEmitEHBlock =
2485 if (ShouldEmitEHBlock)
2491 unsigned GPRBegin = Subtarget->
isPPC64() ? PPC::X14 : PPC::R13;
2492 unsigned GPREnd = Subtarget->
isPPC64() ? PPC::X31 : PPC::R31;
2494 for (
unsigned Reg = GPRBegin;
Reg <= GPREnd; ++
Reg) {
2495 if (
MRI.isPhysRegModified(Reg)) {
2496 GPRSaved = GPREnd -
Reg + 1;
2504 GENBOOLCOMMENT(
"", SecondHalfOfMandatoryField, HasExtensionTable);
2506 GENVALUECOMMENT(
", NumOfGPRsSaved", SecondHalfOfMandatoryField, GPRSaved);
2508 OutStreamer->emitIntValueInHexWithPadding(
2509 (SecondHalfOfMandatoryField & 0x00ff0000) >> 16, 1);
2513 SecondHalfOfMandatoryField |=
2517 NumberOfFixedParms);
2519 OutStreamer->emitIntValueInHexWithPadding(
2520 (SecondHalfOfMandatoryField & 0x0000ff00) >> 8, 1);
2528 SecondHalfOfMandatoryField |=
2533 NumberOfFloatingPointParms);
2534 GENBOOLCOMMENT(
", ", SecondHalfOfMandatoryField, HasParmsOnStack);
2536 OutStreamer->emitIntValueInHexWithPadding(SecondHalfOfMandatoryField & 0xff,
2542 if (NumberOfFixedParms || NumberOfFPParms) {
2548 ParmsTypeValue, NumberOfFixedParms, NumberOfFPParms,
2555 CommentOS <<
"Parameter type = " << ParmsType.
get();
2558 OutStreamer->emitIntValueInHexWithPadding(ParmsTypeValue,
2559 sizeof(ParmsTypeValue));
2562 OutStreamer->AddComment(
"Function size");
2564 MCSymbol *FuncSectSym = getObjFileLowering().getFunctionEntryPointSymbol(
2566 OutStreamer->emitAbsoluteSymbolDiff(FuncEnd, FuncSectSym, 4);
2578 int16_t NameLength =
Name.size();
2579 CommentOS <<
"Function name len = "
2580 <<
static_cast<unsigned int>(NameLength);
2581 EmitCommentAndValue(NameLength, 2);
2582 OutStreamer->AddComment(
"Function Name");
2583 OutStreamer->emitBytes(
Name);
2588 OutStreamer->AddComment(
"AllocaUsed");
2589 OutStreamer->emitIntValueInHex(AllocReg,
sizeof(AllocReg));
2622 OutStreamer->emitIntValueInHexWithPadding((VRData & 0xff00) >> 8, 1);
2627 OutStreamer->emitIntValueInHexWithPadding(VRData & 0x00ff, 1);
2635 CommentOS <<
"Vector Parameter type = " << VecParmsType.
get();
2638 OutStreamer->emitIntValueInHexWithPadding(VecParmTypeValue,
2639 sizeof(VecParmTypeValue));
2641 CommentOS <<
"Padding";
2642 EmitCommentAndValue(0, 2);
2645 uint8_t ExtensionTableFlag = 0;
2647 if (ShouldEmitEHBlock)
2648 ExtensionTableFlag |= ExtendedTBTableFlag::TB_EH_INFO;
2651 ExtensionTableFlag |= ExtendedTBTableFlag::TB_SSP_CANARY;
2653 CommentOS <<
"ExtensionTableFlag = "
2655 EmitCommentAndValue(ExtensionTableFlag,
sizeof(ExtensionTableFlag));
2658 if (ExtensionTableFlag & ExtendedTBTableFlag::TB_EH_INFO) {
2659 auto &Ctx = OutStreamer->getContext();
2662 MCSymbol *TOCEntry = lookUpOrCreateTOCEntry(EHInfoSym, TOCType_EHBlock);
2664 cast<MCSectionXCOFF>(getObjFileLowering().getTOCBaseSection())
2665 ->getQualNameSymbol();
2671 OutStreamer->emitValueToAlignment(
Align(4));
2672 OutStreamer->AddComment(
"EHInfo Table");
2673 OutStreamer->emitValue(Exp,
DL.getPointerSize());
2675#undef GENBOOLCOMMENT
2676#undef GENVALUECOMMENT
2685 .
Case(
"llvm.used",
true)
2687 .
Case(
"llvm.compiler.used",
true)
2693 .
Cases(
"llvm.global_ctors",
"llvm.global_dtors",
true)
2698 if (
auto *GA = dyn_cast<GlobalAlias>(
C))
2699 return getAliasOffset(GA->getAliasee());
2700 if (
auto *CE = dyn_cast<ConstantExpr>(
C)) {
2702 const MCBinaryExpr *CBE = dyn_cast<MCBinaryExpr>(LowC);
2707 auto *
RHS = dyn_cast<MCConstantExpr>(CBE->
getRHS());
2710 return RHS->getValue();
2720 "GlobalVariables with an alignment requirement stricter than TOC entry "
2721 "size not supported by the toc data transformation.");
2724 assert(GVType->
isSized() &&
"A GlobalVariable's size must be known to be "
2725 "supported by the toc data transformation.");
2729 "A GlobalVariable with size larger than a TOC entry is not currently "
2730 "supported by the toc data transformation.");
2733 "currently supported by the toc data transformation.");
2736void PPCAIXAsmPrinter::emitGlobalVariable(
const GlobalVariable *GV) {
2746 TOCDataGlobalVars.push_back(GV);
2750 emitGlobalVariableHelper(GV);
2753void PPCAIXAsmPrinter::emitGlobalVariableHelper(
const GlobalVariable *GV) {
2755 "Unhandled intrinsic global variable.");
2763 emitLinkage(GV, GVSym);
2767 SectionKind GVKind = getObjFileLowering().getKindForGlobal(GV,
TM);
2771 "not supported yet.");
2778 OutStreamer->getCommentOS() <<
'\n';
2783 getObjFileLowering().SectionForGlobal(GV, GVKind,
TM));
2786 OutStreamer->switchSection(Csect);
2799 OutStreamer->emitZeros(
Size);
2802 "BSS local toc-data already handled and TLS variables "
2803 "incompatible with XMC_TD");
2804 OutStreamer->emitXCOFFLocalCommonSymbol(
2808 OutStreamer->emitCommonSymbol(GVSym,
Size, Alignment);
2816 emitLinkage(GV, EmittedInitSym);
2818 emitLinkage(GA, getSymbol(GA));
2820 emitAlignment(getGVAlignment(GV,
DL), GV);
2824 if (!
TM.getDataSections() || GV->hasSection())
2825 OutStreamer->emitLabel(EmittedInitSym);
2828 if (!GOAliasMap[GV].
size()) {
2829 emitGlobalConstant(GV->getParent()->getDataLayout(), GV->getInitializer());
2835 AliasMapTy AliasList;
2837 AliasList[getAliasOffset(GA->getAliasee())].push_back(GA);
2840 emitGlobalConstant(GV->getParent()->getDataLayout(), GV->getInitializer(),
2844void PPCAIXAsmPrinter::emitFunctionDescriptor() {
2846 const unsigned PointerSize =
DL.getPointerSizeInBits() == 64 ? 8 : 4;
2850 OutStreamer->switchSection(
2851 cast<MCSymbolXCOFF>(CurrentFnDescSym)->getRepresentedCsect());
2855 OutStreamer->emitLabel(getSymbol(Alias));
2862 cast<MCSectionXCOFF>(getObjFileLowering().getTOCBaseSection())
2863 ->getQualNameSymbol();
2867 OutStreamer->emitIntValue(0, PointerSize);
2869 OutStreamer->switchSection(Current.first, Current.second);
2872void PPCAIXAsmPrinter::emitFunctionEntryLabel() {
2876 PPCAsmPrinter::emitFunctionEntryLabel();
2880 OutStreamer->emitLabel(
2881 getObjFileLowering().getFunctionEntryPointSymbol(Alias,
TM));
2884void PPCAIXAsmPrinter::emitPGORefs(
Module &M) {
2885 if (!OutContext.hasXCOFFSection(
2896 bool HasNonZeroLengthPrfCntsSection =
false;
2899 if (GV.hasSection() && GV.getSection().equals(
"__llvm_prf_cnts") &&
2900 DL.getTypeAllocSize(GV.getValueType()) > 0) {
2901 HasNonZeroLengthPrfCntsSection =
true;
2905 if (HasNonZeroLengthPrfCntsSection) {
2906 MCSection *CntsSection = OutContext.getXCOFFSection(
2911 OutStreamer->switchSection(CntsSection);
2912 if (OutContext.hasXCOFFSection(
2915 MCSymbol *S = OutContext.getOrCreateSymbol(
"__llvm_prf_data[RW]");
2916 OutStreamer->emitXCOFFRefDirective(S);
2918 if (OutContext.hasXCOFFSection(
2921 MCSymbol *S = OutContext.getOrCreateSymbol(
"__llvm_prf_names[RO]");
2922 OutStreamer->emitXCOFFRefDirective(S);
2924 if (OutContext.hasXCOFFSection(
2927 MCSymbol *S = OutContext.getOrCreateSymbol(
"__llvm_prf_vnds[RW]");
2928 OutStreamer->emitXCOFFRefDirective(S);
2933void PPCAIXAsmPrinter::emitEndOfAsmFile(
Module &M) {
2936 if (
M.empty() && TOCDataGlobalVars.empty())
2942 OutStreamer->switchSection(getObjFileLowering().getTOCBaseSection());
2947 for (
auto &
I : TOC) {
2952 if (
I.first.second == MCSymbolRefExpr::VariantKind::VK_PPC_AIX_TLSGDM) {
2956 Name += cast<MCSymbolXCOFF>(
I.first.first)->getSymbolTableName();
2958 TCEntry = cast<MCSectionXCOFF>(
2959 getObjFileLowering().getSectionForTOCEntry(S,
TM));
2961 TCEntry = cast<MCSectionXCOFF>(
2962 getObjFileLowering().getSectionForTOCEntry(
I.first.first,
TM));
2964 OutStreamer->switchSection(TCEntry);
2966 OutStreamer->emitLabel(
I.second);
2973 for (
const auto *GV : TOCDataGlobalVars) {
2974 if (!GV->hasCommonLinkage())
2975 emitGlobalVariableHelper(GV);
2977 for (
const auto *GV : TOCDataGlobalVars) {
2978 if (GV->hasCommonLinkage())
2979 emitGlobalVariableHelper(GV);
2983bool PPCAIXAsmPrinter::doInitialization(
Module &M) {
2984 const bool Result = PPCAsmPrinter::doInitialization(M);
2986 auto setCsectAlignment = [
this](
const GlobalObject *GO) {
2988 if (GO->isDeclarationForLinker())
2991 SectionKind GOKind = getObjFileLowering().getKindForGlobal(GO,
TM);
2993 getObjFileLowering().SectionForGlobal(GO, GOKind,
TM));
2995 Align GOAlign = getGVAlignment(GO, GO->getParent()->getDataLayout());
3003 auto DL =
M.getDataLayout();
3004 for (
const auto &
G :
M.globals()) {
3005 if (
G.isThreadLocal() && !
G.isDeclaration()) {
3006 TLSVarAddress =
alignTo(TLSVarAddress, getGVAlignment(&
G,
DL));
3007 TLSVarsToAddressMapping[&
G] = TLSVarAddress;
3008 TLSVarAddress +=
DL.getTypeAllocSize(
G.getValueType());
3015 for (
const auto &
G :
M.globals()) {
3022 if (FormatIndicatorAndUniqueModId.empty()) {
3024 if (UniqueModuleId !=
"")
3028 FormatIndicatorAndUniqueModId =
"clang_" + UniqueModuleId.substr(1);
3033 std::chrono::duration_cast<std::chrono::nanoseconds>(
3034 std::chrono::steady_clock::now().time_since_epoch())
3036 FormatIndicatorAndUniqueModId =
3039 llvm::itostr(CurTime);
3043 emitSpecialLLVMGlobal(&
G);
3047 setCsectAlignment(&
G);
3048 std::optional<CodeModel::Model> OptionalCodeModel =
G.getCodeModel();
3049 if (OptionalCodeModel)
3051 *OptionalCodeModel);
3054 for (
const auto &
F : M)
3055 setCsectAlignment(&
F);
3058 for (
const auto &Alias :
M.aliases()) {
3062 "alias without a base object is not yet supported on AIX");
3066 "\n\tAlias attribute for " +
3067 Alias.getGlobalIdentifier() +
3068 " is invalid because " + Aliasee->
getName() +
3074 dyn_cast_or_null<GlobalVariable>(Alias.getAliaseeObject());
3076 std::optional<CodeModel::Model> OptionalCodeModel = GVar->
getCodeModel();
3077 if (OptionalCodeModel)
3079 *OptionalCodeModel);
3082 GOAliasMap[Aliasee].push_back(&Alias);
3089 switch (
MI->getOpcode()) {
3096 if (
MI->getNumOperands() < 5)
3102 MCSymbol *TempSym = OutContext.createNamedTempSymbol();
3103 OutStreamer->emitLabel(TempSym);
3104 OutStreamer->emitXCOFFExceptDirective(CurrentFnSym, TempSym,
3106 Subtarget->
isPPC64() ?
MI->getMF()->getInstructionCount() * 8 :
3107 MI->getMF()->getInstructionCount() * 4,
3108 MMI->hasDebugInfo());
3111 case PPC::GETtlsMOD32AIX:
3112 case PPC::GETtlsMOD64AIX:
3113 case PPC::GETtlsTpointer32AIX:
3114 case PPC::GETtlsADDR64AIX:
3115 case PPC::GETtlsADDR32AIX: {
3120 ExtSymSDNodeSymbols.insert(TlsGetAddr);
3130 cast<MCSymbolXCOFF>(OutContext.getOrCreateSymbol(MO.
getSymbolName()));
3131 ExtSymSDNodeSymbols.insert(S);
3137 case PPC::BL8_NOP_TLS:
3144 case PPC::TAILBCTR8:
3145 if (
MI->getOperand(0).isSymbol())
3158 MCInstBuilder(PPC::ORI).addReg(PPC::R0).addReg(PPC::R0).addImm(0));
3161 return PPCAsmPrinter::emitInstruction(
MI);
3164bool PPCAIXAsmPrinter::doFinalization(
Module &M) {
3166 if (!MAI->usesDwarfFileAndLocDirectives() && MMI->hasDebugInfo())
3167 OutStreamer->doFinalizationAtSectionEnd(
3168 OutStreamer->getContext().getObjectFileInfo()->getTextSection());
3172 return PPCAsmPrinter::doFinalization(M);
3176 if (P < 0 || P > 65535)
3183 return 20 + (
P - 20) * 16;
3186 return 1004 + (
P - 81);
3189 return 2047 + (
P - 1124) * 33878;
3191 return 2147482625u + (
P - 64512);
3210 std::string PrioritySuffix;
3214 return PrioritySuffix;
3217void PPCAIXAsmPrinter::emitXXStructorList(
const DataLayout &
DL,
3218 const Constant *List,
bool IsCtor) {
3220 preprocessXXStructorList(
DL, List, Structors);
3221 if (Structors.
empty())
3225 for (Structor &S : Structors) {
3226 if (
const ConstantExpr *CE = dyn_cast<ConstantExpr>(S.Func))
3227 S.Func =
CE->getOperand(0);
3235 cast<Function>(S.Func));
3239void PPCAIXAsmPrinter::emitTTypeReference(
const GlobalValue *GV,
3240 unsigned Encoding) {
3242 TOCEntryType GlobalType = TOCType_GlobalInternal;
3247 GlobalType = TOCType_GlobalExternal;
3249 MCSymbol *TOCEntry = lookUpOrCreateTOCEntry(TypeInfoSym, GlobalType);
3251 cast<MCSectionXCOFF>(getObjFileLowering().getTOCBaseSection())
3252 ->getQualNameSymbol();
3253 auto &Ctx = OutStreamer->getContext();
3257 OutStreamer->emitValue(Exp, GetSizeOfEncodedValue(Encoding));
3259 OutStreamer->emitIntValue(0, GetSizeOfEncodedValue(Encoding));
3266 std::unique_ptr<MCStreamer> &&Streamer) {
3268 return new PPCAIXAsmPrinter(tm, std::move(Streamer));
3270 return new PPCLinuxAsmPrinter(tm, std::move(Streamer));
3273void PPCAIXAsmPrinter::emitModuleCommandLines(
Module &M) {
3274 const NamedMDNode *NMD =
M.getNamedMetadata(
"llvm.commandline");
3282 assert(
N->getNumOperands() == 1 &&
3283 "llvm.commandline metadata entry can have only one operand");
3284 const MDString *MDS = cast<MDString>(
N->getOperand(0));
3287 RSOS <<
"@(#)opt " << MDS->
getString() <<
"\n";
3290 OutStreamer->emitXCOFFCInfoSym(
".GCC.command.line", RSOS.str());
unsigned const MachineRegisterInfo * MRI
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
#define LLVM_EXTERNAL_VISIBILITY
static std::string getRegisterName(const TargetRegisterInfo *TRI, Register Reg)
This file implements a map that provides insertion order iteration.
Module.h This file contains the declarations for the Module class.
static void collectTOCStats(PPCAsmPrinter::TOCEntryType Type)
static bool isSpecialLLVMGlobalArrayForStaticInit(const GlobalVariable *GV)
static bool isSpecialLLVMGlobalArrayToSkip(const GlobalVariable *GV)
LLVM_EXTERNAL_VISIBILITY void LLVMInitializePowerPCAsmPrinter()
#define GENBOOLCOMMENT(Prefix, V, Field)
static MCSymbol * getMCSymbolForTOCPseudoMO(const MachineOperand &MO, AsmPrinter &AP)
Map a machine operand for a TOC pseudo-machine instruction to its corresponding MCSymbol.
static void setOptionalCodeModel(MCSymbolXCOFF *XSym, CodeModel::Model CM)
static AsmPrinter * createPPCAsmPrinterPass(TargetMachine &tm, std::unique_ptr< MCStreamer > &&Streamer)
static PPCAsmPrinter::TOCEntryType getTOCEntryTypeForMO(const MachineOperand &MO)
static CodeModel::Model getCodeModel(const PPCSubtarget &S, const TargetMachine &TM, const MachineOperand &MO)
static std::string convertToSinitPriority(int Priority)
static MCSymbol * createMCSymbolForTlsGetAddr(MCContext &Ctx, unsigned MIOpc)
This helper function creates the TlsGetAddr/TlsGetMod MCSymbol for AIX.
#define GENVALUECOMMENT(PrefixAndName, V, Field)
static unsigned mapToSinitPriority(int P)
static void tocDataChecks(unsigned PointerSize, const GlobalVariable *GV)
static cl::opt< bool > EnableSSPCanaryBitInTB("aix-ssp-tb-bit", cl::init(false), cl::desc("Enable Passing SSP Canary info in Trackback on AIX"), cl::Hidden)
const char LLVMTargetMachineRef TM
PassBuilder PB(Machine, PassOpts->PTO, std::nullopt, &PIC)
Provides a library for accessing information about this process and other processes on the operating ...
static SDValue lowerConstant(SDValue Op, SelectionDAG &DAG, const RISCVSubtarget &Subtarget)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static bool printOperand(raw_ostream &OS, const SelectionDAG *G, const SDValue Value)
This file defines the SmallPtrSet class.
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
This class is intended to be used as a driving class for all asm writers.
virtual void emitInstruction(const MachineInstr *)
Targets should implement this to emit instructions.
MCSymbol * getSymbol(const GlobalValue *GV) const
void emitXRayTable()
Emit a table with all XRay instrumentation points.
virtual MCSymbol * GetCPISymbol(unsigned CPID) const
Return the symbol for the specified constant pool entry.
virtual void PrintSymbolOperand(const MachineOperand &MO, raw_ostream &OS)
Print the MachineOperand as a symbol.
virtual void SetupMachineFunction(MachineFunction &MF)
This should be called when a new MachineFunction is being processed from runOnMachineFunction.
virtual void emitStartOfAsmFile(Module &)
This virtual method can be overridden by targets that want to emit something at the start of their fi...
MCSymbol * GetJTISymbol(unsigned JTID, bool isLinkerPrivate=false) const
Return the symbol for the specified jump table entry.
bool doInitialization(Module &M) override
Set up the AsmPrinter when we are working on a new module.
bool runOnMachineFunction(MachineFunction &MF) override
Emit the specified function out to the OutStreamer.
virtual bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo, const char *ExtraCode, raw_ostream &OS)
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant as...
MCSymbol * GetBlockAddressSymbol(const BlockAddress *BA) const
Return the MCSymbol used to satisfy BlockAddress uses of the specified basic block.
virtual void emitFunctionEntryLabel()
EmitFunctionEntryLabel - Emit the label that is the entrypoint for the function.
virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, const char *ExtraCode, raw_ostream &OS)
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant.
A constant value that is initialized with an expression using other constant values.
This is an important base class in LLVM.
This class represents an Operation in the Expression.
A parsed version of the target data layout string in and methods for querying it.
unsigned getPointerSize(unsigned AS=0) const
Layout pointer size in bytes, rounded up to a whole number of bytes.
TypeSize getTypeSizeInBits(Type *Ty) const
Size examples:
Tagged union holding either a T or a Error.
Error takeError()
Take ownership of the stored error.
reference get()
Returns a reference to the stored T value.
static GlobalAlias * create(Type *Ty, unsigned AddressSpace, LinkageTypes Linkage, const Twine &Name, Constant *Aliasee, Module *Parent)
If a parent module is specified, the alias is automatically inserted into the end of the specified mo...
MaybeAlign getAlign() const
Returns the alignment of the given variable or function.
bool hasSection() const
Check if this global has a custom object file section.
VisibilityTypes getVisibility() const
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
LinkageTypes getLinkage() const
bool hasDefaultVisibility() const
bool hasPrivateLinkage() const
ThreadLocalMode getThreadLocalMode() const
bool hasDLLExportStorageClass() const
bool isDeclarationForLinker() const
Module * getParent()
Get the module that this global value is contained inside of...
const GlobalObject * getAliaseeObject() const
@ DefaultVisibility
The GV is visible.
@ HiddenVisibility
The GV is hidden.
@ ProtectedVisibility
The GV is protected.
bool hasCommonLinkage() const
bool hasAppendingLinkage() const
LinkageTypes
An enumeration for the kinds of linkage for global values.
@ PrivateLinkage
Like Internal, but omit from symbol table.
@ CommonLinkage
Tentative definitions.
@ InternalLinkage
Rename collisions when linking (static functions).
@ LinkOnceAnyLinkage
Keep one copy of function when linking (inline)
@ WeakODRLinkage
Same, but only replaced by something equivalent.
@ ExternalLinkage
Externally visible function.
@ WeakAnyLinkage
Keep one copy of named function when linking (weak)
@ AppendingLinkage
Special purpose, only applies to global arrays.
@ AvailableExternallyLinkage
Available for inspection, not emission.
@ ExternalWeakLinkage
ExternalWeak linkage description.
@ LinkOnceODRLinkage
Same, but only replaced by something equivalent.
Type * getValueType() const
bool hasAttribute(Attribute::AttrKind Kind) const
Return true if the attribute exists.
bool hasInitializer() const
Definitions have initializers, declarations don't.
std::optional< CodeModel::Model > getCodeModel() const
Get the custom code model of this global if it has one.
Binary assembler expressions.
const MCExpr * getRHS() const
Get the right-hand side expression of the binary operator.
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Opcode getOpcode() const
Get the kind of this binary expression.
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Context object for machine code objects.
MCSectionXCOFF * getXCOFFSection(StringRef Section, SectionKind K, std::optional< XCOFF::CsectProperties > CsectProp=std::nullopt, bool MultiSymbolsAllowed=false, const char *BeginSymName=nullptr, std::optional< XCOFF::DwarfSectionSubtypeFlags > DwarfSubtypeFlags=std::nullopt)
Base class for the full range of assembler expressions which are needed for parsing.
MCInstBuilder & addReg(unsigned Reg)
Add a new register operand.
MCInstBuilder & addImm(int64_t Val)
Add a new integer immediate operand.
MCInstBuilder & addExpr(const MCExpr *Val)
Add a new MCExpr operand.
Instances of this class represent a single low-level machine instruction.
void addOperand(const MCOperand Op)
void setOpcode(unsigned Op)
const MCOperand & getOperand(unsigned i) const
Instances of this class represent operands of the MCInst class.
static MCOperand createExpr(const MCExpr *Val)
unsigned getReg() const
Returns the register number.
This represents a section on linux, lots of unix variants and some bare metal systems.
XCOFF::StorageMappingClass getMappingClass() const
MCSymbolXCOFF * getQualNameSymbol() const
Instances of this class represent a uniqued identifier for a section in the current translation unit.
void setAlignment(Align Value)
void ensureMinAlignment(Align MinAlignment)
Makes sure that Alignment is at least MinAlignment.
Represent a reference to a symbol from inside an expression.
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
StringRef getSymbolTableName() const
void setPerSymbolCodeModel(MCSymbolXCOFF::CodeModel Model)
void setStorageClass(XCOFF::StorageClass SC)
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
void print(raw_ostream &OS, const MCAsmInfo *MAI) const
print - Print the value to the stream OS.
StringRef getString() const
MCSymbol * getSymbol() const
Return the MCSymbol for this basic block.
uint64_t getStackSize() const
Return the number of bytes that must be allocated to hold all of the fixed size frame objects.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Function & getFunction()
Return the LLVM function that this machine code represents.
MCSection * getSection() const
Returns the Section this function belongs to.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
Representation of each machine instruction.
MachineOperand class - Representation of each machine instruction operand.
const GlobalValue * getGlobal() const
bool isReg() const
isReg - Tests if this is a MO_Register operand.
MachineBasicBlock * getMBB() const
bool isCPI() const
isCPI - Tests if this is a MO_ConstantPoolIndex operand.
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
bool isSymbol() const
isSymbol - Tests if this is a MO_ExternalSymbol operand.
bool isJTI() const
isJTI - Tests if this is a MO_JumpTableIndex operand.
const BlockAddress * getBlockAddress() const
unsigned getTargetFlags() const
bool isGlobal() const
isGlobal - Tests if this is a MO_GlobalAddress operand.
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
const char * getSymbolName() const
bool isBlockAddress() const
isBlockAddress - Tests if this is a MO_BlockAddress operand.
Register getReg() const
getReg - Returns the register number.
@ MO_Immediate
Immediate operand.
@ MO_ConstantPoolIndex
Address of indexed Constant in Constant Pool.
@ MO_GlobalAddress
Address of a global value.
@ MO_BlockAddress
Address of a basic block.
@ MO_MachineBasicBlock
MachineBasicBlock reference.
@ MO_Register
Register operand.
@ MO_JumpTableIndex
Address of indexed Jump Table for switch.
int64_t getOffset() const
Return the offset from the symbol in this operand.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
This class implements a map that also provides access to all stored values in a deterministic order.
iterator find(const KeyT &Key)
A Module instance is used to store all the information related to an LLVM module.
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
MDNode * getOperand(unsigned i) const
unsigned getNumOperands() const
uint64_t getTOCSaveOffset() const
getTOCSaveOffset - Return the previous frame offset to save the TOC register – 64-bit SVR4 ABI only.
PPCFunctionInfo - This class is derived from MachineFunction private PowerPC target-specific informat...
uint32_t getParmsType() const
MCSymbol * getPICOffsetSymbol(MachineFunction &MF) const
const SmallVectorImpl< Register > & getMustSaveCRs() const
unsigned getFloatingPointParmsNum() const
MCSymbol * getGlobalEPSymbol(MachineFunction &MF) const
MCSymbol * getLocalEPSymbol(MachineFunction &MF) const
unsigned getVectorParmsNum() const
int getVarArgsFrameIndex() const
bool usesTOCBasePtr() const
bool hasVectorParms() const
uint32_t getVecExtParmsType() const
MCSymbol * getTOCOffsetSymbol(MachineFunction &MF) const
unsigned getFixedParmsNum() const
static const char * getRegisterName(MCRegister Reg)
static bool hasTLSFlag(unsigned TF)
static const PPCMCExpr * createLo(const MCExpr *Expr, MCContext &Ctx)
static const PPCMCExpr * createHa(const MCExpr *Expr, MCContext &Ctx)
bool is32BitELFABI() const
const PPCFrameLowering * getFrameLowering() const override
bool isPPC64() const
isPPC64 - Return true if we are generating code for 64-bit pointer mode.
bool isUsingPCRelativeCalls() const
CodeModel::Model getCodeModel(const TargetMachine &TM, const GlobalValue *GV) const
Calculates the effective code model for argument GV.
const PPCRegisterInfo * getRegisterInfo() const override
bool isGVIndirectSymbol(const GlobalValue *GV) const
True if the GV will be accessed via an indirect symbol.
Common code between 32-bit and 64-bit PowerPC targets.
bool hasGlibcHWCAPAccess() const
virtual void emitAbiVersion(int AbiVersion)
virtual void emitTCEntry(const MCSymbol &S, MCSymbolRefExpr::VariantKind Kind)
virtual void emitLocalEntry(MCSymbolELF *S, const MCExpr *LocalOffset)
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
MI-level patchpoint operands.
Wrapper class representing virtual and physical registers.
SectionKind - This is a simple POD value that classifies the properties of a section.
bool isThreadBSSLocal() const
static SectionKind getText()
static SectionKind getData()
bool isThreadLocal() const
bool isGlobalWriteableData() const
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
void recordPatchPoint(const MCSymbol &L, const MachineInstr &MI)
Generate a stackmap record for a patchpoint instruction.
void recordStackMap(const MCSymbol &L, const MachineInstr &MI)
Generate a stackmap record for a stackmap instruction.
StringRef - Represent a constant reference to a string, i.e.
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
A switch()-like statement whose cases are string literals.
StringSwitch & Case(StringLiteral S, T Value)
StringSwitch & Cases(StringLiteral S0, StringLiteral S1, T Value)
static bool ShouldSetSSPCanaryBitInTB(const MachineFunction *MF)
static MCSymbol * getEHInfoTableSymbol(const MachineFunction *MF)
static XCOFF::StorageClass getStorageClassForGlobal(const GlobalValue *GV)
static bool ShouldEmitEHBlock(const MachineFunction *MF)
Primary interface to the complete machine description for the target machine.
const Triple & getTargetTriple() const
bool isOSAIX() const
Tests whether the OS is AIX.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The instances of the Type class are immutable: once they are created, they are never changed.
bool isSized(SmallPtrSetImpl< Type * > *Visited=nullptr) const
Return true if it makes sense to take the size of this type.
LLVM Value Representation.
void print(raw_ostream &O, bool IsForDebug=false) const
Implement operator<< on Value.
Align getPointerAlignment(const DataLayout &DL) const
Returns an alignment of the pointer value.
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.
StringRef getName() const
Return a constant reference to the value's name.
This class implements an extremely fast bulk output stream that can only output to a stream.
A raw_ostream that writes to an std::string.
A raw_ostream that writes to an SmallVector or SmallString.
static Pid getProcessId()
Get the process's identifier.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
@ C
The default llvm calling convention, compatible with C.
Flag
These should be considered private to the implementation of the MCInstrDesc class.
@ MO_TLSLDM_FLAG
MO_TLSLDM_FLAG - on AIX the ML relocation type is only valid for a reference to a TOC symbol from the...
@ MO_TPREL_PCREL_FLAG
MO_TPREL_PCREL_FLAG = MO_PCREL_FLAG | MO_TPREL_FLAG.
@ MO_GOT_TPREL_PCREL_FLAG
MO_GOT_TPREL_PCREL_FLAG - A combintaion of flags, if these bits are set they should produce the reloc...
@ MO_TLSGDM_FLAG
MO_TLSGDM_FLAG - If this bit is set the symbol reference is relative to the region handle of TLS Gene...
@ MO_TLSLD_FLAG
MO_TLSLD_FLAG - If this bit is set the symbol reference is relative to TLS Local Dynamic model.
@ MO_TPREL_FLAG
MO_TPREL_FLAG - If this bit is set, the symbol reference is relative to the thread pointer and the sy...
@ MO_GOT_TLSLD_PCREL_FLAG
MO_GOT_TLSLD_PCREL_FLAG - A combintaion of flags, if these bits are set they should produce the reloc...
@ MO_TLSGD_FLAG
MO_TLSGD_FLAG - If this bit is set the symbol reference is relative to TLS General Dynamic model for ...
@ MO_GOT_TLSGD_PCREL_FLAG
MO_GOT_TLSGD_PCREL_FLAG - A combintaion of flags, if these bits are set they should produce the reloc...
Predicate
Predicate - These are "(BI << 5) | BO" for various predicates.
const char * stripRegisterPrefix(const char *RegName)
stripRegisterPrefix - This method strips the character prefix from a register name so that only the n...
Predicate InvertPredicate(Predicate Opcode)
Invert the specified predicate. != -> ==, < -> >=.
static bool isVRRegister(unsigned Reg)
static bool isVFRegister(unsigned Reg)
@ CE
Windows NT (Windows on ARM)
Reg
All possible values of the reg field in the ModR/M byte.
SmallString< 32 > getExtendedTBTableFlagString(uint8_t Flag)
Expected< SmallString< 32 > > parseParmsTypeWithVecInfo(uint32_t Value, unsigned FixedParmsNum, unsigned FloatingParmsNum, unsigned VectorParmsNum)
Expected< SmallString< 32 > > parseParmsType(uint32_t Value, unsigned FixedParmsNum, unsigned FloatingParmsNum)
Expected< SmallString< 32 > > parseVectorParmsType(uint32_t Value, unsigned ParmsNum)
@ XMC_RO
Read Only Constant.
@ XMC_TD
Scalar data item in the TOC.
StringRef getNameForTracebackTableLanguageId(TracebackTable::LanguageID LangId)
constexpr uint8_t AllocRegNo
@ XTY_SD
Csect definition for initialized storage.
@ XTY_ER
External reference.
initializer< Ty > init(const Ty &Val)
static unsigned combineHashValue(unsigned a, unsigned b)
Simplistic combination of 32-bit hash values into 32-bit hash values.
std::optional< const char * > toString(const std::optional< DWARFFormValue > &V)
Take an optional DWARFFormValue and try to extract a string value from it.
constexpr uint64_t PointerSize
aarch64 pointer size.
Linkage
Describes symbol linkage. This can be used to resolve definition clashes.
This is an optimization pass for GlobalISel generic memory operations.
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
Target & getThePPC64LETarget()
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
bool LowerPPCMachineOperandToMCOperand(const MachineOperand &MO, MCOperand &OutMO, AsmPrinter &AP)
Target & getThePPC32Target()
std::string getUniqueModuleId(Module *M)
Produce a unique identifier for this module by taking the MD5 sum of the names of the module's strong...
void LowerPPCMachineInstrToMCInst(const MachineInstr *MI, MCInst &OutMI, AsmPrinter &AP)
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
FormattedNumber format_hex_no_prefix(uint64_t N, unsigned Width, bool Upper=false)
format_hex_no_prefix - Output N as a fixed width hexadecimal.
Target & getThePPC64Target()
uint64_t get_threadid()
Return the current thread id, as used in various OS system calls.
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
std::pair< MCSection *, const MCExpr * > MCSectionSubPair
Target & getThePPC32LETarget()
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
@ MCSA_Global
.type _foo, @gnu_unique_object
@ MCSA_Extern
.extern (XCOFF)
@ MCSA_LGlobal
.lglobl (XCOFF)
@ MCSA_Invalid
Not a valid directive.
Implement std::hash so that hash_code can be used in STL containers.
This struct is a compact representation of a valid (non-zero power of two) alignment.
uint64_t value() const
This is a hole in the type system and should not be abused.
static unsigned getHashValue(const TOCKey &PairVal)
static bool isEqual(const TOCKey &A, const TOCKey &B)
std::pair< const MCSymbol *, MCSymbolRefExpr::VariantKind > TOCKey
static TOCKey getTombstoneKey()
static TOCKey getEmptyKey()
An information struct used to provide DenseMap with the various necessary components for a given valu...
Align valueOrOne() const
For convenience, returns a valid alignment or 1 if undefined.
static void RegisterAsmPrinter(Target &T, Target::AsmPrinterCtorTy Fn)
RegisterAsmPrinter - Register an AsmPrinter implementation for the given target.
static constexpr uint32_t FPRSavedMask
static constexpr uint16_t NumberOfVRSavedMask
static constexpr uint8_t NumberOfFloatingPointParmsShift
static constexpr uint32_t NumberOfFixedParmsMask
static constexpr uint16_t HasVMXInstructionMask
static constexpr uint32_t IsLRSavedMask
static constexpr uint16_t HasVarArgsMask
static constexpr uint32_t IsAllocaUsedMask
static constexpr uint16_t IsVRSavedOnStackMask
static constexpr uint16_t NumberOfVectorParmsMask
static constexpr uint32_t IsFloatingPointPresentMask
static constexpr uint32_t FPRSavedShift
static constexpr uint32_t NumberOfFloatingPointParmsMask
static constexpr uint32_t HasControlledStorageMask
static constexpr uint32_t HasExtensionTableMask
static constexpr uint32_t HasTraceBackTableOffsetMask
static constexpr uint32_t IsCRSavedMask
static constexpr uint8_t NumberOfFixedParmsShift
static constexpr uint32_t GPRSavedMask
static constexpr uint8_t NumberOfVectorParmsShift
static constexpr uint32_t HasParmsOnStackMask
static constexpr uint32_t IsFunctionNamePresentMask
static constexpr uint32_t IsBackChainStoredMask
static constexpr uint32_t IsInterruptHandlerMask
static constexpr uint32_t HasVectorInfoMask
static constexpr uint8_t NumberOfVRSavedShift
static constexpr uint32_t GPRSavedShift