88#define DEBUG_TYPE "asmprinter"
90STATISTIC(NumTOCEntries,
"Number of Total TOC Entries Emitted.");
91STATISTIC(NumTOCConstPool,
"Number of Constant Pool TOC Entries.");
93 "Number of Internal Linkage Global TOC Entries.");
95 "Number of External Linkage Global TOC Entries.");
96STATISTIC(NumTOCJumpTable,
"Number of Jump Table TOC Entries.");
97STATISTIC(NumTOCThreadLocal,
"Number of Thread Local TOC Entries.");
98STATISTIC(NumTOCBlockAddress,
"Number of Block Address TOC Entries.");
99STATISTIC(NumTOCEHBlock,
"Number of EH Block TOC Entries.");
108 using TOCKey = std::pair<const MCSymbol *, PPCMCExpr::Specifier>;
123 Tag_GNU_Power_ABI_FP = 4,
124 Tag_GNU_Power_ABI_Vector = 8,
125 Tag_GNU_Power_ABI_Struct_Return = 12,
128 Val_GNU_Power_ABI_NoFloat = 0b00,
129 Val_GNU_Power_ABI_HardFloat_DP = 0b01,
130 Val_GNU_Power_ABI_SoftFloat_DP = 0b10,
131 Val_GNU_Power_ABI_HardFloat_SP = 0b11,
133 Val_GNU_Power_ABI_LDBL_IBM128 = 0b0100,
134 Val_GNU_Power_ABI_LDBL_64 = 0b1000,
135 Val_GNU_Power_ABI_LDBL_IEEE128 = 0b1100,
147 MapVector<std::pair<const MCSymbol *, PPCMCExpr::Specifier>,
MCSymbol *> TOC;
148 const PPCSubtarget *Subtarget =
nullptr;
153 MapVector<const GlobalValue *, uint64_t> TLSVarsToAddressMapping;
156 explicit PPCAsmPrinter(TargetMachine &TM,
157 std::unique_ptr<MCStreamer>
Streamer,
char &ID)
160 StringRef getPassName()
const override {
return "PowerPC Assembly Printer"; }
163 TOCType_ConstantPool,
164 TOCType_GlobalExternal,
165 TOCType_GlobalInternal,
168 TOCType_BlockAddress,
172 MCSymbol *lookUpOrCreateTOCEntry(
const MCSymbol *Sym, TOCEntryType
Type,
175 bool doInitialization(
Module &M)
override {
181 const MCExpr *symbolWithSpecifier(
const MCSymbol *S,
188 void printOperand(
const MachineInstr *
MI,
unsigned OpNo, raw_ostream &O);
190 void PrintSymbolOperand(
const MachineOperand &MO, raw_ostream &O)
override;
191 bool PrintAsmOperand(
const MachineInstr *
MI,
unsigned OpNo,
192 const char *ExtraCode, raw_ostream &O)
override;
193 bool PrintAsmMemoryOperand(
const MachineInstr *
MI,
unsigned OpNo,
194 const char *ExtraCode, raw_ostream &O)
override;
196 void LowerSTACKMAP(StackMaps &SM,
const MachineInstr &
MI);
197 void LowerPATCHPOINT(StackMaps &SM,
const MachineInstr &
MI);
199 void EmitAIXTlsCallHelper(
const MachineInstr *
MI);
200 const MCExpr *getAdjustedFasterLocalExpr(
const MachineOperand &MO,
211class PPCLinuxAsmPrinter :
public PPCAsmPrinter {
215 explicit PPCLinuxAsmPrinter(TargetMachine &TM,
216 std::unique_ptr<MCStreamer>
Streamer)
219 StringRef getPassName()
const override {
220 return "Linux PPC Assembly Printer";
223 void emitGNUAttributes(
Module &M);
225 void emitStartOfAsmFile(
Module &M)
override;
226 void emitEndOfAsmFile(
Module &)
override;
228 void emitFunctionEntryLabel()
override;
230 void emitFunctionBodyStart()
override;
231 void emitFunctionBodyEnd()
override;
235class PPCAIXAsmPrinter :
public PPCAsmPrinter {
239 SmallSetVector<MCSymbol *, 8> ExtSymSDNodeSymbols;
243 std::string FormatIndicatorAndUniqueModId;
247 DenseMap<const GlobalObject *, SmallVector<const GlobalAlias *, 1>>
250 uint16_t getNumberOfVRSaved();
251 void emitTracebackTable();
255 void emitGlobalVariableHelper(
const GlobalVariable *);
258 uint64_t getAliasOffset(
const Constant *
C);
263 PPCAIXAsmPrinter(TargetMachine &TM, std::unique_ptr<MCStreamer>
Streamer)
265 if (MAI.isLittleEndian())
267 "cannot create AIX PPC Assembly Printer for a little-endian target");
270 StringRef getPassName()
const override {
return "AIX PPC Assembly Printer"; }
272 bool doInitialization(
Module &M)
override;
274 void emitXXStructorList(
const DataLayout &
DL,
const Constant *
List,
275 bool IsCtor)
override;
279 void emitGlobalVariable(
const GlobalVariable *GV)
override;
281 void emitFunctionDescriptor()
override;
283 void emitFunctionEntryLabel()
override;
285 void emitFunctionBodyEnd()
override;
287 void emitPGORefs(
Module &M);
291 void emitEndOfAsmFile(
Module &)
override;
293 void emitLinkage(
const GlobalValue *GV, MCSymbol *GVSym)
const override;
297 bool doFinalization(
Module &M)
override;
299 void emitTTypeReference(
const GlobalValue *GV,
unsigned Encoding)
override;
301 void emitModuleCommandLines(
Module &M)
override;
303 void emitRefMetadata(
const GlobalObject *);
305 void emitGlobalIFunc(
Module &M,
const GlobalIFunc &GI)
override;
314 getSymbol(GV)->
print(O, MAI);
318void PPCAsmPrinter::printOperand(
const MachineInstr *
MI,
unsigned OpNo,
320 const DataLayout &
DL = getDataLayout();
321 const MachineOperand &MO =
MI->getOperand(OpNo);
341 O <<
DL.getInternalSymbolPrefix() <<
"CPI" << getFunctionNumber() <<
'_'
348 PrintSymbolOperand(MO, O);
353 O <<
"<unknown operand type: " << (unsigned)MO.
getType() <<
">";
360bool PPCAsmPrinter::PrintAsmOperand(
const MachineInstr *
MI,
unsigned OpNo,
361 const char *ExtraCode, raw_ostream &O) {
363 if (ExtraCode && ExtraCode[0]) {
364 if (ExtraCode[1] != 0)
return true;
366 switch (ExtraCode[0]) {
372 if (!
MI->getOperand(OpNo).isReg() ||
373 OpNo+1 ==
MI->getNumOperands() ||
374 !
MI->getOperand(OpNo+1).isReg())
381 if (
MI->getOperand(OpNo).isImm())
385 if(!
MI->getOperand(OpNo).isReg())
391 Reg = PPC::VSX32 + (
Reg - PPC::V0);
393 Reg = PPC::VSX32 + (
Reg - PPC::VF0);
409bool PPCAsmPrinter::PrintAsmMemoryOperand(
const MachineInstr *
MI,
unsigned OpNo,
410 const char *ExtraCode,
412 if (ExtraCode && ExtraCode[0]) {
413 if (ExtraCode[1] != 0)
return true;
415 switch (ExtraCode[0]) {
416 default:
return true;
418 O << getDataLayout().getPointerSize() <<
"(";
429 if (
MI->getOperand(OpNo).isImm())
440 assert(
MI->getOperand(OpNo).isReg());
445 assert(
MI->getOperand(OpNo).isReg());
455 case PPCAsmPrinter::TOCType_ConstantPool:
458 case PPCAsmPrinter::TOCType_GlobalInternal:
459 ++NumTOCGlobalInternal;
461 case PPCAsmPrinter::TOCType_GlobalExternal:
462 ++NumTOCGlobalExternal;
464 case PPCAsmPrinter::TOCType_JumpTable:
467 case PPCAsmPrinter::TOCType_ThreadLocal:
470 case PPCAsmPrinter::TOCType_BlockAddress:
471 ++NumTOCBlockAddress;
473 case PPCAsmPrinter::TOCType_EHBlock:
490 assert(GV &&
"expected global for MO_GlobalAddress");
511MCSymbol *PPCAsmPrinter::lookUpOrCreateTOCEntry(
const MCSymbol *Sym,
515 auto [It,
Inserted] =
TOC.try_emplace({Sym, Spec});
521 TOCEntry = createTempSymbol(
"C");
525void PPCAsmPrinter::LowerSTACKMAP(StackMaps &SM,
const MachineInstr &
MI) {
526 unsigned NumNOPBytes =
MI.getOperand(1).getImm();
528 auto &Ctx = OutStreamer->getContext();
529 MCSymbol *MILabel = Ctx.createTempSymbol();
530 OutStreamer->emitLabel(MILabel);
533 assert(NumNOPBytes % 4 == 0 &&
"Invalid number of NOP bytes requested!");
539 while (NumNOPBytes > 0) {
540 if (MII !=
MBB.
end() && MII->isDebugInstr()) {
544 if (MII ==
MBB.
end() || MII->isCall() ||
545 MII->getOpcode() == TargetOpcode::PATCHPOINT ||
546 MII->getOpcode() == TargetOpcode::STACKMAP)
553 for (
unsigned i = 0; i < NumNOPBytes; i += 4)
554 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::NOP));
559void PPCAsmPrinter::LowerPATCHPOINT(StackMaps &SM,
const MachineInstr &
MI) {
560 auto &Ctx = OutStreamer->getContext();
561 MCSymbol *MILabel = Ctx.createTempSymbol();
562 OutStreamer->emitLabel(MILabel);
565 PatchPointOpers Opers(&
MI);
567 unsigned EncodedBytes = 0;
568 const MachineOperand &CalleeMO = Opers.getCallTarget();
570 if (CalleeMO.
isImm()) {
571 int64_t CallTarget = CalleeMO.
getImm();
573 assert((CallTarget & 0xFFFFFFFFFFFF) == CallTarget &&
574 "High 16 bits of call target should be zero.");
575 Register ScratchReg =
MI.getOperand(Opers.getNextScratchIdx()).getReg();
578 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::LI8)
580 .addImm((CallTarget >> 32) & 0xFFFF));
583 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::RLDIC)
586 .addImm(32).addImm(16));
589 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::ORIS8)
592 .addImm((CallTarget >> 16) & 0xFFFF));
595 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::ORI8)
598 .addImm(CallTarget & 0xFFFF));
603 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::STD)
605 .addImm(TOCSaveOffset)
615 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::LD)
618 .addReg(ScratchReg));
621 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::LD)
624 .addReg(ScratchReg));
628 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::MTCTR8)
629 .addReg(ScratchReg));
632 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::BCTRL8));
636 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::LD)
638 .addImm(TOCSaveOffset)
643 const GlobalValue *GValue = CalleeMO.
getGlobal();
644 MCSymbol *MOSymbol = getSymbol(GValue);
647 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::BL8_NOP)
656 unsigned NumBytes = Opers.getNumPatchBytes();
657 if (NumBytes < EncodedBytes)
659 "Patchpoint can't request size less than the length of a call.");
661 assert((NumBytes - EncodedBytes) % 4 == 0 &&
662 "Invalid number of NOP bytes requested!");
663 for (
unsigned i = EncodedBytes; i < NumBytes; i += 4)
664 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::NOP));
674 SymName =
".__tls_get_addr";
676 case PPC::GETtlsTpointer32AIX:
677 SymName =
".__get_tpointer";
679 case PPC::GETtlsMOD32AIX:
680 case PPC::GETtlsMOD64AIX:
681 SymName =
".__tls_get_mod";
687 ->getQualNameSymbol();
690void PPCAsmPrinter::EmitAIXTlsCallHelper(
const MachineInstr *
MI) {
692 "Only expecting to emit calls to get the thread pointer on AIX!");
696 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::BLA).addExpr(TlsRef));
701void PPCAsmPrinter::emitTlsCall(
const MachineInstr *
MI,
704 unsigned Opcode = PPC::BL8_NOP_TLS;
706 assert(
MI->getNumOperands() >= 3 &&
"Expecting at least 3 operands from MI");
710 Opcode = PPC::BL8_NOTOC_TLS;
712 const Module *
M = MF->getFunction().getParent();
715 ((
Subtarget->isPPC64() &&
MI->getOperand(0).getReg() == PPC::X3) ||
716 (!
Subtarget->isPPC64() &&
MI->getOperand(0).getReg() == PPC::R3)) &&
717 "GETtls[ld]ADDR[32] must define GPR3");
719 ((
Subtarget->isPPC64() &&
MI->getOperand(1).getReg() == PPC::X3) ||
720 (!
Subtarget->isPPC64() &&
MI->getOperand(1).getReg() == PPC::R3)) &&
721 "GETtls[ld]ADDR[32] must read GPR3");
730 assert((
MI->getOpcode() == PPC::GETtlsMOD32AIX ||
731 MI->getOpcode() == PPC::GETtlsMOD64AIX ||
732 (
MI->getOperand(2).isReg() &&
733 MI->getOperand(2).getReg() == VarOffsetReg)) &&
734 "GETtls[ld]ADDR[32] must read GPR4");
735 EmitAIXTlsCallHelper(
MI);
739 MCSymbol *TlsGetAddr = OutContext.getOrCreateSymbol(
"__tls_get_addr");
741 if (
Subtarget->is32BitELFABI() && isPositionIndependent())
751 const MachineOperand &MO =
MI->getOperand(2);
752 const GlobalValue *GValue = MO.
getGlobal();
753 MCSymbol *MOSymbol = getSymbol(GValue);
755 EmitToStreamer(*OutStreamer,
756 MCInstBuilder(
Subtarget->isPPC64() ? Opcode
757 : (
unsigned)PPC::BL_TLS)
780static PPCAsmPrinter::TOCEntryType
785 return PPCAsmPrinter::TOCType_GlobalExternal;
787 return PPCAsmPrinter::TOCType_GlobalInternal;
790static PPCAsmPrinter::TOCEntryType
795 return PPCAsmPrinter::TOCType_ThreadLocal;
803 return PPCAsmPrinter::TOCType_ConstantPool;
805 return PPCAsmPrinter::TOCType_JumpTable;
807 return PPCAsmPrinter::TOCType_BlockAddress;
813const MCExpr *PPCAsmPrinter::symbolWithSpecifier(
const MCSymbol *S,
821void PPCAsmPrinter::emitInstruction(
const MachineInstr *
MI) {
822 PPC_MC::verifyInstructionPredicates(
MI->getOpcode(),
823 getSubtargetInfo().getFeatureBits());
826 const bool IsPPC64 =
Subtarget->isPPC64();
827 const bool IsAIX =
Subtarget->isAIXABI();
828 const bool HasAIXSmallLocalTLS =
Subtarget->hasAIXSmallLocalExecTLS() ||
830 const Module *
M = MF->getFunction().getParent();
835 if (!
MI->isInlineAsm()) {
836 for (
const MachineOperand &MO:
MI->operands()) {
857 auto getTOCRelocAdjustedExprForXCOFF = [
this](
const MCExpr *Expr,
858 ptrdiff_t OriginalOffset) {
865 ptrdiff_t Adjustment =
871 auto getTOCEntryLoadingExprForXCOFF =
872 [IsPPC64, getTOCRelocAdjustedExprForXCOFF,
873 this](
const MCSymbol *MOSymbol,
const MCExpr *Expr,
875 const unsigned EntryByteSize = IsPPC64 ? 8 : 4;
876 const auto TOCEntryIter =
TOC.find({MOSymbol, VK});
878 "Could not find the TOC entry for this symbol.");
879 const ptrdiff_t EntryDistanceFromTOCBase =
880 (TOCEntryIter -
TOC.begin()) * EntryByteSize;
881 constexpr int16_t PositiveTOCRange = INT16_MAX;
883 if (EntryDistanceFromTOCBase > PositiveTOCRange)
884 return getTOCRelocAdjustedExprForXCOFF(Expr, EntryDistanceFromTOCBase);
896 assert(MO.
isGlobal() &&
"Only expecting a global MachineOperand here!\n");
904 PPCFunctionInfo *FuncInfo = MF->getInfo<PPCFunctionInfo>();
908 dbgs() <<
"Current function uses IE access for default LD vars.\n");
931 switch (
MI->getOpcode()) {
933 case TargetOpcode::PATCHABLE_FUNCTION_ENTER: {
935 "AIX does not support patchable function entry!");
937 unsigned Num =
F.getFnAttributeAsParsedInteger(
"patchable-function-entry");
943 case TargetOpcode::DBG_VALUE:
945 case TargetOpcode::STACKMAP:
946 return LowerSTACKMAP(SM, *
MI);
947 case TargetOpcode::PATCHPOINT:
948 return LowerPATCHPOINT(SM, *
MI);
950 case PPC::MoveGOTtoLR: {
958 OutContext.getOrCreateSymbol(StringRef(
"_GLOBAL_OFFSET_TABLE_"));
964 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::BL).addExpr(OffsExpr));
967 case PPC::MovePCtoLR:
968 case PPC::MovePCtoLR8: {
973 MCSymbol *PICBase = MF->getPICBaseSymbol();
976 EmitToStreamer(*OutStreamer,
977 MCInstBuilder(PPC::BCLalways)
983 OutStreamer->emitLabel(PICBase);
986 case PPC::UpdateGBR: {
995 if (
Subtarget->isSecurePlt() && isPositionIndependent() ) {
997 MCSymbol *BaseSymbol = OutContext.getOrCreateSymbol(
1006 const MCExpr *DeltaHi =
1010 MCInstBuilder(PPC::ADDIS).addReg(PICR).addReg(PICR).addExpr(DeltaHi));
1012 const MCExpr *DeltaLo =
1016 MCInstBuilder(PPC::ADDI).addReg(PICR).addReg(PICR).addExpr(DeltaLo));
1020 MF->getInfo<PPCFunctionInfo>()->getPICOffsetSymbol(*MF);
1027 const MCOperand PICR = TmpInst.
getOperand(0);
1034 EmitToStreamer(*OutStreamer, TmpInst);
1040 EmitToStreamer(*OutStreamer, TmpInst);
1051 const MachineOperand &MO =
MI->getOperand(1);
1053 "Invalid operand for LWZtoc.");
1061 const MCExpr *
Exp = symbolWithSpecifier(MOSymbol,
PPC::S_GOT);
1063 EmitToStreamer(*OutStreamer, TmpInst);
1082 "This pseudo should only be selected for 32-bit small code model.");
1083 Exp = getTOCEntryLoadingExprForXCOFF(MOSymbol, Exp, VK);
1088 OutStreamer->getCommentOS() << MO <<
'\n';
1089 EmitToStreamer(*OutStreamer, TmpInst);
1096 OutContext.getOrCreateSymbol(Twine(
".LTOC")), OutContext);
1099 EmitToStreamer(*OutStreamer, TmpInst);
1103 case PPC::ADDItoc8: {
1105 "PseudoOp only valid for small code model AIX");
1111 TmpInst.
setOpcode((!IsPPC64) ? (PPC::LA) : (PPC::LA8));
1113 const MachineOperand &MO =
MI->getOperand(2);
1122 EmitToStreamer(*OutStreamer, TmpInst);
1135 const MachineOperand &MO =
MI->getOperand(1);
1137 "Invalid operand!");
1151 const MCExpr *
Exp = symbolWithSpecifier(TOCEntry, VKExpr);
1153 IsAIX ? getTOCEntryLoadingExprForXCOFF(MOSymbol, Exp, VK) : Exp);
1156 if (isVerbose() && IsAIX)
1157 OutStreamer->getCommentOS() << MO <<
'\n';
1158 EmitToStreamer(*OutStreamer, TmpInst);
1161 case PPC::ADDIStocHA: {
1162 const MachineOperand &MO =
MI->getOperand(2);
1165 "Invalid operand for ADDIStocHA.");
1166 assert((IsAIX && !IsPPC64 &&
1168 "This pseudo should only be selected for 32-bit large code model on"
1188 if ( {
1200 const MCExpr *
Exp = symbolWithSpecifier(MOSymbol,
PPC::S_U);
1202 EmitToStreamer(*OutStreamer, TmpInst);
1205 case PPC::LWZtocL: {
1206 const MachineOperand &MO =
MI->getOperand(1);
1209 "Invalid operand for LWZtocL.");
1210 assert(IsAIX && !IsPPC64 &&
1212 "This pseudo should only be selected for 32-bit large code model on"
1232 const MCExpr *
Exp = symbolWithSpecifier(TOCEntry,
PPC::S_L);
1234 EmitToStreamer(*OutStreamer, TmpInst);
1237 case PPC::ADDIStocHA8: {
1247 const MachineOperand &MO =
MI->getOperand(2);
1249 "Invalid operand for ADDIStocHA8!");
1255 const bool GlobalToc =
1267 const MCExpr *
Exp = symbolWithSpecifier(MOSymbol, VK);
1276 EmitToStreamer(*OutStreamer, TmpInst);
1289 const MachineOperand &MO =
MI->getOperand(1);
1292 "Invalid operand for LDtocL!");
1296 "LDtocL used on symbol that could be accessed directly is "
1297 "invalid. Must match ADDIStocHA8."));
1308 const MCExpr *
Exp = symbolWithSpecifier(MOSymbol, VK);
1310 EmitToStreamer(*OutStreamer, TmpInst);
1314 case PPC::ADDItocL8: {
1318 unsigned Op =
MI->getOpcode();
1322 TmpInst.
setOpcode(
Op == PPC::ADDItocL8 ? (IsAIX ? PPC::LA8 : PPC::ADDI8)
1325 const MachineOperand &MO =
MI->getOperand(2);
1328 : MO.
isGlobal() &&
"Invalid operand for ADDItocL8.");
1330 "Interposable definitions must use indirect accesses.");
1339 EmitToStreamer(*OutStreamer, TmpInst);
1342 case PPC::ADDISgotTprelHA: {
1345 assert(IsPPC64 &&
"Not supported for 32-bit PowerPC");
1346 const MachineOperand &MO =
MI->getOperand(2);
1347 const GlobalValue *GValue = MO.
getGlobal();
1348 MCSymbol *MOSymbol = getSymbol(GValue);
1349 const MCExpr *SymGotTprel =
1351 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::ADDIS8)
1352 .addReg(
MI->getOperand(0).getReg())
1353 .addReg(
MI->getOperand(1).getReg())
1354 .addExpr(SymGotTprel));
1357 case PPC::LDgotTprelL:
1358 case PPC::LDgotTprelL32: {
1363 TmpInst.
setOpcode(IsPPC64 ? PPC::LD : PPC::LWZ);
1364 const MachineOperand &MO =
MI->getOperand(1);
1365 const GlobalValue *GValue = MO.
getGlobal();
1366 MCSymbol *MOSymbol = getSymbol(GValue);
1367 const MCExpr *
Exp = symbolWithSpecifier(
1370 EmitToStreamer(*OutStreamer, TmpInst);
1374 case PPC::PPC32PICGOT: {
1375 MCSymbol *GOTSymbol = OutContext.getOrCreateSymbol(StringRef(
"_GLOBAL_OFFSET_TABLE_"));
1376 MCSymbol *GOTRef = OutContext.createTempSymbol();
1377 MCSymbol *NextInstr = OutContext.createTempSymbol();
1379 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::BL)
1383 const MCExpr *OffsExpr =
1387 OutStreamer->emitLabel(GOTRef);
1388 OutStreamer->emitValue(OffsExpr, 4);
1389 OutStreamer->emitLabel(NextInstr);
1390 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::MFLR)
1391 .addReg(
MI->getOperand(0).getReg()));
1392 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::LWZ)
1393 .addReg(
MI->getOperand(1).getReg())
1395 .addReg(
MI->getOperand(0).getReg()));
1396 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::ADD4)
1397 .addReg(
MI->getOperand(0).getReg())
1398 .addReg(
MI->getOperand(1).getReg())
1399 .addReg(
MI->getOperand(0).getReg()));
1402 case PPC::PPC32GOT: {
1404 OutContext.getOrCreateSymbol(StringRef(
"_GLOBAL_OFFSET_TABLE_"));
1405 const MCExpr *SymGotTlsL =
1407 const MCExpr *SymGotTlsHA =
1409 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::LI)
1410 .addReg(
MI->getOperand(0).getReg())
1411 .addExpr(SymGotTlsL));
1412 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::ADDIS)
1413 .addReg(
MI->getOperand(0).getReg())
1414 .addReg(
MI->getOperand(0).getReg())
1415 .addExpr(SymGotTlsHA));
1418 case PPC::ADDIStlsgdHA: {
1421 assert(IsPPC64 &&
"Not supported for 32-bit PowerPC");
1422 const MachineOperand &MO =
MI->getOperand(2);
1423 const GlobalValue *GValue = MO.
getGlobal();
1424 MCSymbol *MOSymbol = getSymbol(GValue);
1425 const MCExpr *SymGotTlsGD =
1427 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::ADDIS8)
1428 .addReg(
MI->getOperand(0).getReg())
1429 .addReg(
MI->getOperand(1).getReg())
1430 .addExpr(SymGotTlsGD));
1433 case PPC::ADDItlsgdL:
1436 case PPC::ADDItlsgdL32: {
1439 const MachineOperand &MO =
MI->getOperand(2);
1440 const GlobalValue *GValue = MO.
getGlobal();
1441 MCSymbol *MOSymbol = getSymbol(GValue);
1442 const MCExpr *SymGotTlsGD = symbolWithSpecifier(
1444 EmitToStreamer(*OutStreamer,
1445 MCInstBuilder(IsPPC64 ? PPC::ADDI8 : PPC::ADDI)
1446 .addReg(
MI->getOperand(0).getReg())
1447 .addReg(
MI->getOperand(1).getReg())
1448 .addExpr(SymGotTlsGD));
1451 case PPC::GETtlsMOD32AIX:
1452 case PPC::GETtlsMOD64AIX:
1456 case PPC::GETtlsADDR:
1459 case PPC::GETtlsADDRPCREL:
1460 case PPC::GETtlsADDR32AIX:
1461 case PPC::GETtlsADDR64AIX:
1465 case PPC::GETtlsADDR32: {
1471 case PPC::GETtlsTpointer32AIX: {
1474 EmitAIXTlsCallHelper(
MI);
1477 case PPC::ADDIStlsldHA: {
1480 assert(IsPPC64 &&
"Not supported for 32-bit PowerPC");
1481 const MachineOperand &MO =
MI->getOperand(2);
1482 const GlobalValue *GValue = MO.
getGlobal();
1483 MCSymbol *MOSymbol = getSymbol(GValue);
1484 const MCExpr *SymGotTlsLD =
1486 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::ADDIS8)
1487 .addReg(
MI->getOperand(0).getReg())
1488 .addReg(
MI->getOperand(1).getReg())
1489 .addExpr(SymGotTlsLD));
1492 case PPC::ADDItlsldL:
1495 case PPC::ADDItlsldL32: {
1498 const MachineOperand &MO =
MI->getOperand(2);
1499 const GlobalValue *GValue = MO.
getGlobal();
1500 MCSymbol *MOSymbol = getSymbol(GValue);
1501 const MCExpr *SymGotTlsLD = symbolWithSpecifier(
1503 EmitToStreamer(*OutStreamer,
1504 MCInstBuilder(IsPPC64 ? PPC::ADDI8 : PPC::ADDI)
1505 .addReg(
MI->getOperand(0).getReg())
1506 .addReg(
MI->getOperand(1).getReg())
1507 .addExpr(SymGotTlsLD));
1510 case PPC::GETtlsldADDR:
1513 case PPC::GETtlsldADDRPCREL:
1514 case PPC::GETtlsldADDR32: {
1520 case PPC::ADDISdtprelHA:
1523 case PPC::ADDISdtprelHA32: {
1526 const MachineOperand &MO =
MI->getOperand(2);
1527 const GlobalValue *GValue = MO.
getGlobal();
1528 MCSymbol *MOSymbol = getSymbol(GValue);
1532 MCInstBuilder(IsPPC64 ? PPC::ADDIS8 : PPC::ADDIS)
1533 .addReg(
MI->getOperand(0).getReg())
1534 .addReg(
MI->getOperand(1).getReg())
1535 .addExpr(SymDtprel));
1538 case PPC::PADDIdtprel: {
1541 const MachineOperand &MO =
MI->getOperand(2);
1542 const GlobalValue *GValue = MO.
getGlobal();
1543 MCSymbol *MOSymbol = getSymbol(GValue);
1544 const MCExpr *SymDtprel = symbolWithSpecifier(MOSymbol,
PPC::S_DTPREL);
1545 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::PADDI8)
1546 .addReg(
MI->getOperand(0).getReg())
1547 .addReg(
MI->getOperand(1).getReg())
1548 .addExpr(SymDtprel));
1552 case PPC::ADDIdtprelL:
1555 case PPC::ADDIdtprelL32: {
1558 const MachineOperand &MO =
MI->getOperand(2);
1559 const GlobalValue *GValue = MO.
getGlobal();
1560 MCSymbol *MOSymbol = getSymbol(GValue);
1562 EmitToStreamer(*OutStreamer,
1563 MCInstBuilder(IsPPC64 ? PPC::ADDI8 : PPC::ADDI)
1564 .addReg(
MI->getOperand(0).getReg())
1565 .addReg(
MI->getOperand(1).getReg())
1566 .addExpr(SymDtprel));
1574 unsigned NewOpcode =
1575 MI->getOpcode() == PPC::MFOCRF ? PPC::MFCR : PPC::MFCR8;
1576 OutStreamer->AddComment(PPCInstPrinter::
1578 EmitToStreamer(*OutStreamer, MCInstBuilder(NewOpcode)
1579 .addReg(
MI->getOperand(0).getReg()));
1588 unsigned NewOpcode =
1589 MI->getOpcode() == PPC::MTOCRF ? PPC::MTCRF : PPC::MTCRF8;
1590 unsigned Mask = 0x80 >> OutContext.getRegisterInfo()
1591 ->getEncodingValue(
MI->getOperand(0).getReg());
1592 OutStreamer->AddComment(PPCInstPrinter::
1594 EmitToStreamer(*OutStreamer, MCInstBuilder(NewOpcode)
1596 .addReg(
MI->getOperand(1).getReg()));
1606 unsigned OpNum = (
MI->getOpcode() == PPC::STD) ? 2 : 1;
1610 for (
const MachineOperand &TempMO :
MI->operands()) {
1613 TempMO.getOperandNo() == 1)
1616 const MachineOperand &MO =
MI->getOperand(OpNum);
1650 if (!HasAIXSmallLocalTLS)
1652 bool IsMIADDI8 =
MI->getOpcode() == PPC::ADDI8;
1653 unsigned OpNum = IsMIADDI8 ? 2 : 1;
1654 const MachineOperand &MO =
MI->getOperand(OpNum);
1661 const MCExpr *Expr = getAdjustedFasterLocalExpr(MO, MO.
getOffset());
1669 EmitToStreamer(*OutStreamer, TmpInst);
1675 case PPC::PseudoEIEIO: {
1678 MCInstBuilder(PPC::ORI).addReg(PPC::X2).addReg(PPC::X2).addImm(0));
1681 MCInstBuilder(PPC::ORI).addReg(PPC::X2).addReg(PPC::X2).addImm(0));
1682 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::EnforceIEIO));
1688 EmitToStreamer(*OutStreamer, TmpInst);
1698PPCAsmPrinter::getAdjustedFasterLocalExpr(
const MachineOperand &MO,
1705 assert(MO.
isGlobal() &&
"Only expecting a global MachineOperand here!");
1706 const GlobalValue *GValue = MO.
getGlobal();
1709 "Only local-[exec|dynamic] accesses are handled!");
1715 const auto TLSVarsMapEntryIter = TLSVarsToAddressMapping.
find(GValue);
1716 if (TLSVarsMapEntryIter == TLSVarsToAddressMapping.
end())
1717 assert(IsGlobalADeclaration &&
1718 "Only expecting to find extern TLS variables not present in the TLS "
1719 "variable-to-address map!");
1721 unsigned TLSVarAddress =
1722 IsGlobalADeclaration ? 0 : TLSVarsMapEntryIter->second;
1723 ptrdiff_t FinalAddress = (TLSVarAddress +
Offset);
1735 if (FinalAddress >= 32768) {
1742 ptrdiff_t Delta = ((FinalAddress + 32768) & ~0xFFFF);
1744 [[maybe_unused]] ptrdiff_t InstDisp = TLSVarAddress +
Offset - Delta;
1746 ((InstDisp < 32768) && (InstDisp >= -32768)) &&
1747 "Expecting the instruction displacement for local-[exec|dynamic] TLS "
1748 "variables to be between [-32768, 32768)!");
1756void PPCLinuxAsmPrinter::emitGNUAttributes(
Module &M) {
1758 MDString *LongDoubleType =
1760 if (!LongDoubleType)
1765 case LongDoubleFormat::PPCDoubleDouble:
1766 OutStreamer->emitGNUAttribute(Tag_GNU_Power_ABI_FP,
1767 Val_GNU_Power_ABI_HardFloat_DP |
1768 Val_GNU_Power_ABI_LDBL_IBM128);
1770 case LongDoubleFormat::IEEEquad:
1771 OutStreamer->emitGNUAttribute(Tag_GNU_Power_ABI_FP,
1772 Val_GNU_Power_ABI_HardFloat_DP |
1773 Val_GNU_Power_ABI_LDBL_IEEE128);
1775 case LongDoubleFormat::IEEEdouble:
1776 OutStreamer->emitGNUAttribute(Tag_GNU_Power_ABI_FP,
1777 Val_GNU_Power_ABI_HardFloat_DP |
1778 Val_GNU_Power_ABI_LDBL_64);
1785void PPCLinuxAsmPrinter::emitInstruction(
const MachineInstr *
MI) {
1787 return PPCAsmPrinter::emitInstruction(
MI);
1789 switch (
MI->getOpcode()) {
1792 case TargetOpcode::PATCHABLE_FUNCTION_ENTER: {
1806 unsigned Num =
F.getFnAttributeAsParsedInteger(
"patchable-function-entry");
1808 if (!MAI.isLittleEndian() || Num)
1810 MCSymbol *BeginOfSled = OutContext.createTempSymbol();
1811 MCSymbol *EndOfSled = OutContext.createTempSymbol();
1812 OutStreamer->emitLabel(BeginOfSled);
1813 EmitToStreamer(*OutStreamer,
1814 MCInstBuilder(PPC::B).addExpr(
1816 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::NOP));
1819 MCInstBuilder(PPC::STD).addReg(PPC::X0).addImm(-8).addReg(PPC::X1));
1820 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::MFLR8).addReg(PPC::X0));
1821 EmitToStreamer(*OutStreamer,
1822 MCInstBuilder(PPC::BL8_NOP)
1824 OutContext.getOrCreateSymbol(
"__xray_FunctionEntry"),
1826 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::MTLR8).addReg(PPC::X0));
1827 OutStreamer->emitLabel(EndOfSled);
1828 recordSled(BeginOfSled, *
MI, SledKind::FUNCTION_ENTER, 2);
1831 case TargetOpcode::PATCHABLE_RET: {
1832 unsigned RetOpcode =
MI->getOperand(0).getImm();
1842 if (RetOpcode == PPC::BCCLR) {
1843 IsConditional =
true;
1844 }
else if (RetOpcode == PPC::TCRETURNdi8 || RetOpcode == PPC::TCRETURNri8 ||
1845 RetOpcode == PPC::TCRETURNai8) {
1847 }
else if (RetOpcode == PPC::BLR8 || RetOpcode == PPC::TAILB8) {
1848 IsConditional =
false;
1850 EmitToStreamer(*OutStreamer, RetInst);
1855 if (IsConditional) {
1874 FallthroughLabel = OutContext.createTempSymbol();
1877 MCInstBuilder(PPC::BCC)
1880 .addReg(
MI->getOperand(2).getReg())
1897 OutStreamer->emitCodeAlignment(
Align(8), getSubtargetInfo());
1898 MCSymbol *BeginOfSled = OutContext.createTempSymbol();
1899 OutStreamer->emitLabel(BeginOfSled);
1900 EmitToStreamer(*OutStreamer, RetInst);
1901 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::NOP));
1904 MCInstBuilder(PPC::STD).addReg(PPC::X0).addImm(-8).addReg(PPC::X1));
1905 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::MFLR8).addReg(PPC::X0));
1906 EmitToStreamer(*OutStreamer,
1907 MCInstBuilder(PPC::BL8_NOP)
1909 OutContext.getOrCreateSymbol(
"__xray_FunctionExit"),
1911 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::MTLR8).addReg(PPC::X0));
1912 EmitToStreamer(*OutStreamer, RetInst);
1914 OutStreamer->emitLabel(FallthroughLabel);
1915 recordSled(BeginOfSled, *
MI, SledKind::FUNCTION_EXIT, 2);
1918 case TargetOpcode::PATCHABLE_FUNCTION_EXIT:
1920 case TargetOpcode::PATCHABLE_TAIL_CALL:
1924 "around this assert.");
1926 return PPCAsmPrinter::emitInstruction(
MI);
1929void PPCLinuxAsmPrinter::emitStartOfAsmFile(
Module &M) {
1932 PPCTargetStreamer *TS =
1933 static_cast<PPCTargetStreamer *
>(OutStreamer->getTargetStreamer());
1937 if (
static_cast<const PPCTargetMachine &
>(TM).isPPC64() ||
1938 !isPositionIndependent())
1944 OutStreamer->switchSection(OutContext.getELFSection(
1947 MCSymbol *TOCSym = OutContext.getOrCreateSymbol(Twine(
".LTOC"));
1948 MCSymbol *CurrentPos = OutContext.createTempSymbol();
1950 OutStreamer->emitLabel(CurrentPos);
1954 const MCExpr *tocExpr =
1959 OutStreamer->emitAssignment(TOCSym, tocExpr);
1961 OutStreamer->switchSection(getObjFileLowering().getTextSection());
1964void PPCLinuxAsmPrinter::emitFunctionEntryLabel() {
1967 (!isPositionIndependent() ||
1972 const PPCFunctionInfo *PPCFI = MF->getInfo<PPCFunctionInfo>();
1975 MCSymbol *PICBase = MF->getPICBaseSymbol();
1976 OutStreamer->emitLabel(RelocSymbol);
1978 const MCExpr *OffsExpr =
1984 OutStreamer->emitValue(OffsExpr, 4);
1985 OutStreamer->emitLabel(CurrentFnSym);
1998 && !MF->getRegInfo().use_empty(PPC::X2)) {
1999 const PPCFunctionInfo *PPCFI = MF->getInfo<PPCFunctionInfo>();
2001 MCSymbol *TOCSymbol = OutContext.getOrCreateSymbol(StringRef(
".TOC."));
2003 const MCExpr *TOCDeltaExpr =
2010 OutStreamer->emitValue(TOCDeltaExpr, 8);
2017 MCSectionELF *
Section = OutStreamer->getContext().getELFSection(
2019 OutStreamer->switchSection(Section);
2020 OutStreamer->emitLabel(CurrentFnSym);
2021 OutStreamer->emitValueToAlignment(
Align(8));
2022 MCSymbol *Symbol1 = CurrentFnSymForSize;
2027 MCSymbol *Symbol2 = OutContext.getOrCreateSymbol(StringRef(
".TOC."));
2029 OutStreamer->emitValue(
2032 OutStreamer->emitIntValue(0, 8 );
2033 OutStreamer->switchSection(Current.first, Current.second);
2036void PPCLinuxAsmPrinter::emitEndOfAsmFile(
Module &M) {
2037 const DataLayout &
DL = getDataLayout();
2039 bool isPPC64 =
DL.getPointerSizeInBits() == 64;
2041 PPCTargetStreamer *TS =
2042 static_cast<PPCTargetStreamer *
>(OutStreamer->getTargetStreamer());
2048 if (
static_cast<const PPCTargetMachine &
>(TM).hasGlibcHWCAPAccess())
2049 OutStreamer->emitSymbolValue(
2050 GetExternalSymbolSymbol(
"__parse_hwcap_and_convert_at_platform"),
2051 MAI.getCodePointerSize());
2052 emitGNUAttributes(M);
2055 const char *
Name = isPPC64 ?
".toc" :
".got2";
2056 MCSectionELF *
Section = OutContext.getELFSection(
2058 OutStreamer->switchSection(Section);
2060 OutStreamer->emitValueToAlignment(
Align(4));
2062 for (
const auto &TOCMapPair : TOC) {
2063 const MCSymbol *
const TOCEntryTarget = TOCMapPair.first.first;
2064 MCSymbol *
const TOCEntryLabel = TOCMapPair.second;
2066 OutStreamer->emitLabel(TOCEntryLabel);
2068 TS->
emitTCEntry(*TOCEntryTarget, TOCMapPair.first.second);
2070 OutStreamer->emitSymbolValue(TOCEntryTarget, 4);
2074 PPCAsmPrinter::emitEndOfAsmFile(M);
2078void PPCLinuxAsmPrinter::emitFunctionBodyStart() {
2110 const PPCFunctionInfo *PPCFI = MF->getInfo<PPCFunctionInfo>();
2111 const bool UsesX2OrR2 = !MF->getRegInfo().use_empty(PPC::X2) ||
2112 !MF->getRegInfo().use_empty(PPC::R2);
2113 const bool PCrelGEPRequired =
Subtarget->isUsingPCRelativeCalls() &&
2115 const bool NonPCrelGEPRequired = !
Subtarget->isUsingPCRelativeCalls() &&
2121 if (NonPCrelGEPRequired || PCrelGEPRequired) {
2126 OutStreamer->emitLabel(GlobalEntryLabel);
2127 const MCSymbolRefExpr *GlobalEntryLabelExp =
2131 MCSymbol *TOCSymbol = OutContext.getOrCreateSymbol(StringRef(
".TOC."));
2132 const MCExpr *TOCDeltaExpr =
2134 GlobalEntryLabelExp, OutContext);
2136 const MCExpr *TOCDeltaHi =
2138 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::ADDIS)
2141 .addExpr(TOCDeltaHi));
2143 const MCExpr *TOCDeltaLo =
2145 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::ADDI)
2148 .addExpr(TOCDeltaLo));
2151 const MCExpr *TOCOffsetDeltaExpr =
2153 GlobalEntryLabelExp, OutContext);
2155 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::LD)
2157 .addExpr(TOCOffsetDeltaExpr)
2159 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::ADD8)
2166 OutStreamer->emitLabel(LocalEntryLabel);
2167 const MCSymbolRefExpr *LocalEntryLabelExp =
2169 const MCExpr *LocalOffsetExp =
2171 GlobalEntryLabelExp, OutContext);
2173 PPCTargetStreamer *TS =
2174 static_cast<PPCTargetStreamer *
>(OutStreamer->getTargetStreamer());
2177 }
else if (
Subtarget->isUsingPCRelativeCalls()) {
2199 if (MF->getFrameInfo().hasCalls() || MF->getFrameInfo().hasTailCall() ||
2200 MF->hasInlineAsm() || (!PPCFI->
usesTOCBasePtr() && UsesX2OrR2)) {
2201 PPCTargetStreamer *TS =
2202 static_cast<PPCTargetStreamer *
>(OutStreamer->getTargetStreamer());
2212void PPCLinuxAsmPrinter::emitFunctionBodyEnd() {
2221 OutStreamer->emitIntValue(0, 4);
2222 OutStreamer->emitIntValue(0, 8);
2226char PPCLinuxAsmPrinter::ID = 0;
2229 "Linux PPC Assembly Printer",
false,
false)
2234 switch (GV->getLinkage()) {
2235 case GlobalValue::ExternalLinkage:
2236 LinkageAttr = GV->isDeclaration() ? MCSA_Extern : MCSA_Global;
2238 case GlobalValue::LinkOnceAnyLinkage:
2239 case GlobalValue::LinkOnceODRLinkage:
2240 case GlobalValue::WeakAnyLinkage:
2241 case GlobalValue::WeakODRLinkage:
2242 case GlobalValue::ExternalWeakLinkage:
2243 LinkageAttr = MCSA_Weak;
2245 case GlobalValue::AvailableExternallyLinkage:
2246 LinkageAttr = MCSA_Extern;
2248 case GlobalValue::PrivateLinkage:
2250 case GlobalValue::InternalLinkage:
2251 assert(GV->getVisibility() == GlobalValue::DefaultVisibility &&
2252 "InternalLinkage should not have other visibility setting.");
2253 LinkageAttr = MCSA_LGlobal;
2255 case GlobalValue::AppendingLinkage:
2256 llvm_unreachable(
"Should never emit this");
2257 case GlobalValue::CommonLinkage:
2258 llvm_unreachable(
"CommonLinkage of XCOFF should not come to this path");
2264 if (!TM.getIgnoreXCOFFVisibility()) {
2265 if (GV->hasDLLExportStorageClass() && !GV->hasDefaultVisibility())
2267 "Cannot not be both dllexport and non-default visibility");
2268 switch (GV->getVisibility()) {
2271 case GlobalValue::DefaultVisibility:
2272 if (GV->hasDLLExportStorageClass())
2273 VisibilityAttr = MAI.getExportedVisibilityAttr();
2275 case GlobalValue::HiddenVisibility:
2276 VisibilityAttr = MAI.getHiddenVisibilityAttr();
2278 case GlobalValue::ProtectedVisibility:
2279 VisibilityAttr = MAI.getProtectedVisibilityAttr();
2289 OutStreamer->emitXCOFFSymbolLinkageWithVisibility(GVSym, LinkageAttr,
2295 auto *FnDescSec =
static_cast<MCSectionXCOFF *
>(
2296 getObjFileLowering().getSectionForFunctionDescriptor(&MF.
getFunction(),
2300 CurrentFnDescSym = FnDescSec->getQualNameSymbol();
2305uint16_t PPCAIXAsmPrinter::getNumberOfVRSaved() {
2313 for (
unsigned Reg = PPC::V20;
Reg <= PPC::V31; ++
Reg)
2316 return PPC::V31 -
Reg + 1;
2321void PPCAIXAsmPrinter::emitFunctionBodyEnd() {
2323 if (!TM.getXCOFFTracebackTable())
2326 emitTracebackTable();
2334 (getNumberOfVRSaved() > 0)) {
2336 OutStreamer->switchSection(getObjFileLowering().getCompactUnwindSection());
2339 OutStreamer->emitLabel(EHInfoLabel);
2342 OutStreamer->emitInt32(0);
2344 const DataLayout &
DL = MMI->getModule()->getDataLayout();
2347 OutStreamer->emitValueToAlignment(
Align(PointerSize));
2349 OutStreamer->emitIntValue(0, PointerSize);
2350 OutStreamer->emitIntValue(0, PointerSize);
2351 OutStreamer->switchSection(MF->
getSection());
2355void PPCAIXAsmPrinter::emitTracebackTable() {
2359 OutStreamer->emitLabel(FuncEnd);
2361 OutStreamer->AddComment(
"Traceback table begin");
2363 OutStreamer->emitIntValueInHexWithPadding(0, 4 );
2365 SmallString<128> CommentString;
2366 raw_svector_ostream CommentOS(CommentString);
2368 auto EmitComment = [&]() {
2369 OutStreamer->AddComment(CommentOS.str());
2370 CommentString.
clear();
2375 OutStreamer->emitIntValueInHexWithPadding(
Value,
Size);
2379 CommentOS <<
"Version = " <<
Version;
2380 EmitCommentAndValue(
Version, 1);
2390 CommentOS <<
"Language = "
2392 EmitCommentAndValue(LanguageIdentifier, 1);
2395 uint32_t FirstHalfOfMandatoryField = 0;
2402 const PPCFunctionInfo *FI = MF->
getInfo<PPCFunctionInfo>();
2406 for (
unsigned Reg = PPC::F0;
Reg <= PPC::F31; ++
Reg) {
2413#define GENBOOLCOMMENT(Prefix, V, Field) \
2414 CommentOS << (Prefix) << ((V) & (TracebackTable::Field##Mask) ? "+" : "-") \
2417#define GENVALUECOMMENT(PrefixAndName, V, Field) \
2418 CommentOS << (PrefixAndName) << " = " \
2419 << static_cast<unsigned>(((V) & (TracebackTable::Field##Mask)) >> \
2420 (TracebackTable::Field##Shift))
2423 GENBOOLCOMMENT(
", ", FirstHalfOfMandatoryField, IsOutOfLineEpilogOrPrologue);
2426 GENBOOLCOMMENT(
"", FirstHalfOfMandatoryField, HasTraceBackTableOffset);
2427 GENBOOLCOMMENT(
", ", FirstHalfOfMandatoryField, IsInternalProcedure);
2430 GENBOOLCOMMENT(
"", FirstHalfOfMandatoryField, HasControlledStorage);
2434 GENBOOLCOMMENT(
"", FirstHalfOfMandatoryField, IsFloatingPointPresent);
2437 IsFloatingPointOperationLogOrAbortEnabled);
2440 OutStreamer->emitIntValueInHexWithPadding(
2441 (FirstHalfOfMandatoryField & 0x0000ff00) >> 8, 1);
2448 if (FrameReg == (
Subtarget->isPPC64() ? PPC::X31 : PPC::R31))
2451 const SmallVectorImpl<Register> &MustSaveCRs = FI->
getMustSaveCRs();
2452 if (!MustSaveCRs.
empty())
2458 GENBOOLCOMMENT(
"", FirstHalfOfMandatoryField, IsInterruptHandler);
2459 GENBOOLCOMMENT(
", ", FirstHalfOfMandatoryField, IsFunctionNamePresent);
2463 OnConditionDirective);
2467 OutStreamer->emitIntValueInHexWithPadding((FirstHalfOfMandatoryField & 0xff),
2471 uint32_t SecondHalfOfMandatoryField = 0;
2477 uint32_t FPRSaved = 0;
2478 for (
unsigned Reg = PPC::F14;
Reg <= PPC::F31; ++
Reg) {
2480 FPRSaved = PPC::F31 -
Reg + 1;
2486 GENBOOLCOMMENT(
"", SecondHalfOfMandatoryField, IsBackChainStored);
2488 GENVALUECOMMENT(
", NumOfFPRsSaved", SecondHalfOfMandatoryField, FPRSaved);
2490 OutStreamer->emitIntValueInHexWithPadding(
2491 (SecondHalfOfMandatoryField & 0xff000000) >> 24, 1);
2497 bool HasVectorInst =
false;
2498 for (
unsigned Reg = PPC::V0;
Reg <= PPC::V31; ++
Reg)
2501 HasVectorInst =
true;
2508 uint16_t NumOfVRSaved = getNumberOfVRSaved();
2509 bool ShouldEmitEHBlock =
2512 if (ShouldEmitEHBlock)
2515 uint32_t GPRSaved = 0;
2518 unsigned GPRBegin =
Subtarget->isPPC64() ? PPC::X14 : PPC::R13;
2519 unsigned GPREnd =
Subtarget->isPPC64() ? PPC::X31 : PPC::R31;
2521 for (
unsigned Reg = GPRBegin;
Reg <= GPREnd; ++
Reg) {
2523 GPRSaved = GPREnd -
Reg + 1;
2531 GENBOOLCOMMENT(
"", SecondHalfOfMandatoryField, HasExtensionTable);
2533 GENVALUECOMMENT(
", NumOfGPRsSaved", SecondHalfOfMandatoryField, GPRSaved);
2535 OutStreamer->emitIntValueInHexWithPadding(
2536 (SecondHalfOfMandatoryField & 0x00ff0000) >> 16, 1);
2540 SecondHalfOfMandatoryField |=
2544 NumberOfFixedParms);
2546 OutStreamer->emitIntValueInHexWithPadding(
2547 (SecondHalfOfMandatoryField & 0x0000ff00) >> 8, 1);
2555 SecondHalfOfMandatoryField |=
2560 NumberOfFloatingPointParms);
2561 GENBOOLCOMMENT(
", ", SecondHalfOfMandatoryField, HasParmsOnStack);
2563 OutStreamer->emitIntValueInHexWithPadding(SecondHalfOfMandatoryField & 0xff,
2569 if (NumberOfFixedParms || NumberOfFPParms) {
2572 Expected<SmallString<32>> ParmsType =
2575 ParmsTypeValue, NumberOfFixedParms, NumberOfFPParms,
2582 CommentOS <<
"Parameter type = " << ParmsType.
get();
2585 OutStreamer->emitIntValueInHexWithPadding(ParmsTypeValue,
2586 sizeof(ParmsTypeValue));
2589 OutStreamer->AddComment(
"Function size");
2591 MCSymbol *FuncSectSym = getObjFileLowering().getFunctionEntryPointSymbol(
2593 OutStreamer->emitAbsoluteSymbolDiff(FuncEnd, FuncSectSym, 4);
2605 int16_t NameLength =
Name.size();
2606 CommentOS <<
"Function name len = "
2607 <<
static_cast<unsigned int>(NameLength);
2608 EmitCommentAndValue(NameLength, 2);
2609 OutStreamer->AddComment(
"Function Name");
2610 OutStreamer->emitBytes(Name);
2615 OutStreamer->AddComment(
"AllocaUsed");
2616 OutStreamer->emitIntValueInHex(AllocReg,
sizeof(AllocReg));
2620 uint16_t VRData = 0;
2649 OutStreamer->emitIntValueInHexWithPadding((VRData & 0xff00) >> 8, 1);
2654 OutStreamer->emitIntValueInHexWithPadding(VRData & 0x00ff, 1);
2658 Expected<SmallString<32>> VecParmsType =
2662 CommentOS <<
"Vector Parameter type = " << VecParmsType.
get();
2665 OutStreamer->emitIntValueInHexWithPadding(VecParmTypeValue,
2666 sizeof(VecParmTypeValue));
2668 CommentOS <<
"Padding";
2669 EmitCommentAndValue(0, 2);
2672 uint8_t ExtensionTableFlag = 0;
2674 if (ShouldEmitEHBlock)
2675 ExtensionTableFlag |= ExtendedTBTableFlag::TB_EH_INFO;
2678 ExtensionTableFlag |= ExtendedTBTableFlag::TB_SSP_CANARY;
2680 CommentOS <<
"ExtensionTableFlag = "
2682 EmitCommentAndValue(ExtensionTableFlag,
sizeof(ExtensionTableFlag));
2685 if (ExtensionTableFlag & ExtendedTBTableFlag::TB_EH_INFO) {
2686 auto &Ctx = OutStreamer->getContext();
2689 MCSymbol *TOCEntry = lookUpOrCreateTOCEntry(EHInfoSym, TOCType_EHBlock);
2690 const MCSymbol *TOCBaseSym =
static_cast<const MCSectionXCOFF *
>(
2691 getObjFileLowering().getTOCBaseSection())
2692 ->getQualNameSymbol();
2697 const DataLayout &
DL = getDataLayout();
2698 OutStreamer->emitValueToAlignment(
Align(4));
2699 OutStreamer->AddComment(
"EHInfo Table");
2700 OutStreamer->emitValue(Exp,
DL.getPointerSize());
2702#undef GENBOOLCOMMENT
2703#undef GENVALUECOMMENT
2712 .
Case(
"llvm.used",
true)
2714 .
Case(
"llvm.compiler.used",
true)
2720 .
Cases({
"llvm.global_ctors",
"llvm.global_dtors"},
true)
2724uint64_t PPCAIXAsmPrinter::getAliasOffset(
const Constant *
C) {
2726 return getAliasOffset(GA->getAliasee());
2737 return RHS->getValue();
2747 "GlobalVariables with an alignment requirement stricter than TOC entry "
2748 "size not supported by the toc data transformation.");
2751 assert(GVType->
isSized() &&
"A GlobalVariable's size must be known to be "
2752 "supported by the toc data transformation.");
2756 "A GlobalVariable with size larger than a TOC entry is not currently "
2757 "supported by the toc data transformation.");
2760 "currently supported by the toc data transformation.");
2763void PPCAIXAsmPrinter::emitGlobalVariable(
const GlobalVariable *GV) {
2781 emitGlobalVariableHelper(GV);
2784void PPCAIXAsmPrinter::emitGlobalVariableHelper(
const GlobalVariable *GV) {
2786 "Unhandled intrinsic global variable.");
2791 auto *GVSym =
static_cast<MCSymbolXCOFF *
>(getSymbol(GV));
2794 emitLinkage(GV, GVSym);
2798 SectionKind GVKind = getObjFileLowering().getKindForGlobal(GV, TM);
2802 "not supported yet.");
2809 OutStreamer->getCommentOS() <<
'\n';
2813 auto *Csect =
static_cast<MCSectionXCOFF *
>(
2814 getObjFileLowering().SectionForGlobal(GV, GVKind, TM));
2817 OutStreamer->switchSection(Csect);
2819 if (GV->
hasMetadata(LLVMContext::MD_implicit_ref)) {
2820 emitRefMetadata(GV);
2830 GVSym->setStorageClass(
2834 OutStreamer->emitZeros(
Size);
2837 "BSS local toc-data already handled and TLS variables "
2838 "incompatible with XMC_TD");
2839 OutStreamer->emitXCOFFLocalCommonSymbol(
2840 OutContext.getOrCreateSymbol(GVSym->getSymbolTableName()),
Size,
2843 OutStreamer->emitCommonSymbol(GVSym,
Size, Alignment);
2851 emitLinkage(GV, EmittedInitSym);
2852 for (
const GlobalAlias *GA : GOAliasMap[GV])
2853 emitLinkage(GA, getSymbol(GA));
2855 emitAlignment(getGVAlignment(GV,
DL), GV);
2859 if (!TM.getDataSections() || GV->hasSection()) {
2861 OutStreamer->emitLabel(EmittedInitSym);
2865 if (!GOAliasMap[GV].
size()) {
2866 emitGlobalConstant(GV->getDataLayout(), GV->getInitializer());
2872 AliasMapTy AliasList;
2873 for (
const GlobalAlias *GA : GOAliasMap[GV])
2874 AliasList[getAliasOffset(GA->getAliasee())].push_back(GA);
2877 emitGlobalConstant(GV->getDataLayout(), GV->getInitializer(),
2881void PPCAIXAsmPrinter::emitFunctionDescriptor() {
2882 const DataLayout &
DL = getDataLayout();
2883 const unsigned PointerSize =
DL.getPointerSizeInBits() == 64 ? 8 : 4;
2887 OutStreamer->switchSection(
2888 static_cast<MCSymbolXCOFF *
>(CurrentFnDescSym)->getRepresentedCsect());
2893 for (
const GlobalAlias *Alias : GOAliasMap[&MF->
getFunction()])
2894 OutStreamer->emitLabel(getSymbol(Alias));
2900 const MCSymbol *TOCBaseSym =
static_cast<const MCSectionXCOFF *
>(
2901 getObjFileLowering().getTOCBaseSection())
2902 ->getQualNameSymbol();
2906 OutStreamer->emitIntValue(0, PointerSize);
2908 OutStreamer->switchSection(Current.first, Current.second);
2911void PPCAIXAsmPrinter::emitFunctionEntryLabel() {
2915 PPCAsmPrinter::emitFunctionEntryLabel();
2923 for (
const GlobalAlias *Alias : GOAliasMap[
F])
2924 OutStreamer->emitLabel(
2925 getObjFileLowering().getFunctionEntryPointSymbol(Alias, TM));
2927 if (
F->hasMetadata(LLVMContext::MD_implicit_ref)) {
2932void PPCAIXAsmPrinter::emitPGORefs(
Module &M) {
2933 if (!OutContext.hasXCOFFSection(
2944 bool HasNonZeroLengthPrfCntsSection =
false;
2945 const DataLayout &
DL =
M.getDataLayout();
2946 for (GlobalVariable &GV :
M.globals())
2947 if (GV.hasSection() && GV.getSection() ==
"__llvm_prf_cnts" &&
2948 GV.getGlobalSize(
DL) > 0) {
2949 HasNonZeroLengthPrfCntsSection =
true;
2953 if (HasNonZeroLengthPrfCntsSection) {
2954 MCSection *CntsSection = OutContext.getXCOFFSection(
2959 OutStreamer->switchSection(CntsSection);
2960 if (OutContext.hasXCOFFSection(
2963 MCSymbol *S = OutContext.getOrCreateSymbol(
"__llvm_prf_data[RW]");
2964 OutStreamer->emitXCOFFRefDirective(S);
2966 if (OutContext.hasXCOFFSection(
2969 MCSymbol *S = OutContext.getOrCreateSymbol(
"__llvm_prf_names[RO]");
2970 OutStreamer->emitXCOFFRefDirective(S);
2972 if (OutContext.hasXCOFFSection(
2975 MCSymbol *S = OutContext.getOrCreateSymbol(
"__llvm_prf_vnds[RW]");
2976 OutStreamer->emitXCOFFRefDirective(S);
2981void PPCAIXAsmPrinter::emitGCOVRefs() {
2982 if (!OutContext.hasXCOFFSection(
2983 "__llvm_gcov_ctr_section",
2987 MCSection *CtrSection = OutContext.getXCOFFSection(
2992 OutStreamer->switchSection(CtrSection);
2995 if (OutContext.hasXCOFFSection(
2998 const char *SymbolStr = TM.Options.XCOFFReadOnlyPointers
2999 ?
"__llvm_covinit[RO]"
3000 :
"__llvm_covinit[RW]";
3001 MCSymbol *S = OutContext.getOrCreateSymbol(SymbolStr);
3002 OutStreamer->emitXCOFFRefDirective(S);
3006void PPCAIXAsmPrinter::emitEndOfAsmFile(
Module &M) {
3009 if (
M.empty() && TOCDataGlobalVars.
empty())
3016 OutStreamer->switchSection(getObjFileLowering().getTOCBaseSection());
3018 PPCTargetStreamer *TS =
3019 static_cast<PPCTargetStreamer *
>(OutStreamer->getTargetStreamer());
3021 for (
auto &
I : TOC) {
3022 MCSectionXCOFF *TCEntry;
3031 SmallString<128>
Name;
3034 Name +=
static_cast<const MCSymbolXCOFF *
>(
I.first.first)
3035 ->getSymbolTableName();
3036 MCSymbol *S = OutContext.getOrCreateSymbol(Name);
3037 TCEntry =
static_cast<MCSectionXCOFF *
>(
3038 getObjFileLowering().getSectionForTOCEntry(S, TM));
3040 TCEntry =
static_cast<MCSectionXCOFF *
>(
3041 getObjFileLowering().getSectionForTOCEntry(
I.first.first, TM));
3043 OutStreamer->switchSection(TCEntry);
3045 OutStreamer->emitLabel(
I.second);
3052 for (
const auto *GV : TOCDataGlobalVars) {
3053 if (!GV->hasCommonLinkage())
3054 emitGlobalVariableHelper(GV);
3056 for (
const auto *GV : TOCDataGlobalVars) {
3057 if (GV->hasCommonLinkage())
3058 emitGlobalVariableHelper(GV);
3062bool PPCAIXAsmPrinter::doInitialization(
Module &M) {
3063 const bool Result = PPCAsmPrinter::doInitialization(M);
3066 const Triple &
Target =
M.getTargetTriple();
3073 if (FunCpuId > TargetCpuId)
3074 TargetCpuId = FunCpuId;
3080 StringRef TargetCPU = TM.getTargetCPU();
3085 PPCTargetStreamer *TS =
3086 static_cast<PPCTargetStreamer *
>(OutStreamer->getTargetStreamer());
3089 auto setCsectAlignment = [
this](
const GlobalObject *GO) {
3091 if (GO->isDeclarationForLinker())
3094 SectionKind GOKind = getObjFileLowering().getKindForGlobal(GO, TM);
3095 auto *Csect =
static_cast<MCSectionXCOFF *
>(
3096 getObjFileLowering().SectionForGlobal(GO, GOKind, TM));
3098 Align GOAlign = getGVAlignment(GO, GO->getDataLayout());
3099 Csect->ensureMinAlignment(GOAlign);
3106 auto DL =
M.getDataLayout();
3107 for (
const auto &
G :
M.globals()) {
3108 if (
G.isThreadLocal() && !
G.isDeclaration()) {
3109 TLSVarAddress =
alignTo(TLSVarAddress, getGVAlignment(&
G,
DL));
3110 TLSVarsToAddressMapping[&
G] = TLSVarAddress;
3111 TLSVarAddress +=
G.getGlobalSize(
DL);
3118 for (
const auto &
G :
M.globals()) {
3125 if (FormatIndicatorAndUniqueModId.empty()) {
3127 if (UniqueModuleId !=
"")
3131 FormatIndicatorAndUniqueModId =
"clang_" + UniqueModuleId;
3136 std::chrono::duration_cast<std::chrono::nanoseconds>(
3137 std::chrono::steady_clock::now().time_since_epoch())
3139 FormatIndicatorAndUniqueModId =
3146 emitSpecialLLVMGlobal(&
G);
3150 setCsectAlignment(&
G);
3151 std::optional<CodeModel::Model> OptionalCodeModel =
G.getCodeModel();
3152 if (OptionalCodeModel)
3154 *OptionalCodeModel);
3157 for (
const auto &
F : M)
3158 setCsectAlignment(&
F);
3161 for (
const auto &Alias :
M.aliases()) {
3162 const GlobalObject *Aliasee = Alias.getAliaseeObject();
3165 "alias without a base object is not yet supported on AIX");
3169 "\n\tAlias attribute for " +
3170 Alias.getName() +
" is invalid because " +
3171 Aliasee->
getName() +
" is common.",
3175 const GlobalVariable *GVar =
3178 std::optional<CodeModel::Model> OptionalCodeModel = GVar->
getCodeModel();
3179 if (OptionalCodeModel)
3181 *OptionalCodeModel);
3184 GOAliasMap[Aliasee].push_back(&Alias);
3190void PPCAIXAsmPrinter::emitInstruction(
const MachineInstr *
MI) {
3191 switch (
MI->getOpcode()) {
3198 if (
MI->getNumOperands() < 5)
3200 const MachineOperand &LangMO =
MI->getOperand(3);
3201 const MachineOperand &ReasonMO =
MI->getOperand(4);
3204 MCSymbol *TempSym = OutContext.createNamedTempSymbol();
3205 OutStreamer->emitLabel(TempSym);
3206 OutStreamer->emitXCOFFExceptDirective(
3207 CurrentFnSym, TempSym, LangMO.
getImm(), ReasonMO.
getImm(),
3208 Subtarget->isPPC64() ?
MI->getMF()->getInstructionCount() * 8
3209 :
MI->getMF()->getInstructionCount() * 4,
3213 case PPC::GETtlsMOD32AIX:
3214 case PPC::GETtlsMOD64AIX:
3215 case PPC::GETtlsTpointer32AIX:
3216 case PPC::GETtlsADDR64AIX:
3217 case PPC::GETtlsADDR32AIX: {
3222 ExtSymSDNodeSymbols.
insert(TlsGetAddr);
3229 case PPC::BL_LWZinto_toc:
3230 case PPC::BL_LWZinto_toc_RM:
3231 case PPC::BL8_LDinto_toc:
3232 case PPC::BL8_LDinto_toc_RM: {
3233 const MachineOperand &MO =
MI->getOperand(0);
3235 auto *S =
static_cast<MCSymbolXCOFF *
>(
3237 ExtSymSDNodeSymbols.
insert(S);
3243 case PPC::BL8_NOP_TLS:
3250 case PPC::TAILBCTR8:
3251 if (
MI->getOperand(0).isSymbol())
3264 MCInstBuilder(PPC::ORI).addReg(PPC::R0).addReg(PPC::R0).addImm(0));
3267 return PPCAsmPrinter::emitInstruction(
MI);
3270bool PPCAIXAsmPrinter::doFinalization(
Module &M) {
3271 for (MCSymbol *Sym : ExtSymSDNodeSymbols)
3272 OutStreamer->emitSymbolAttribute(Sym,
MCSA_Extern);
3273 return PPCAsmPrinter::doFinalization(M);
3284 return 20 + (
P - 20) * 16;
3287 return 1004 + (
P - 81);
3290 return 2047 + (
P - 1124) * 33878;
3292 return 2147482625u + (
P - 64512);
3311 std::string PrioritySuffix;
3314 return PrioritySuffix;
3317void PPCAIXAsmPrinter::emitXXStructorList(
const DataLayout &
DL,
3318 const Constant *
List,
bool IsCtor) {
3320 preprocessXXStructorList(
DL,
List, Structors);
3321 if (Structors.
empty())
3325 for (Structor &S : Structors) {
3327 S.Func =
CE->getOperand(0);
3331 (IsCtor ? llvm::Twine(
"__sinit") : llvm::Twine(
"__sterm")) +
3333 llvm::Twine(
"_", FormatIndicatorAndUniqueModId) +
3339void PPCAIXAsmPrinter::emitTTypeReference(
const GlobalValue *GV,
3340 unsigned Encoding) {
3342 TOCEntryType GlobalType = TOCType_GlobalInternal;
3347 GlobalType = TOCType_GlobalExternal;
3348 MCSymbol *TypeInfoSym = TM.getSymbol(GV);
3349 MCSymbol *TOCEntry = lookUpOrCreateTOCEntry(TypeInfoSym, GlobalType);
3350 const MCSymbol *TOCBaseSym =
static_cast<const MCSectionXCOFF *
>(
3351 getObjFileLowering().getTOCBaseSection())
3352 ->getQualNameSymbol();
3353 auto &Ctx = OutStreamer->getContext();
3357 OutStreamer->emitValue(Exp, GetSizeOfEncodedValue(Encoding));
3359 OutStreamer->emitIntValue(0, GetSizeOfEncodedValue(Encoding));
3362void PPCAIXAsmPrinter::emitRefMetadata(
const GlobalObject *GO) {
3364 GO->
getMetadata(LLVMContext::MD_implicit_ref, MDs);
3365 assert(MDs.
size() &&
"Expected !implicit.ref metadata nodes");
3367 for (
const MDNode *MD : MDs) {
3372 ? getObjFileLowering().getFunctionEntryPointSymbol(GV, TM)
3374 OutStreamer->emitXCOFFRefDirective(Referenced);
3382 std::unique_ptr<MCStreamer> &&
Streamer) {
3384 return new PPCAIXAsmPrinter(tm, std::move(
Streamer));
3386 return new PPCLinuxAsmPrinter(tm, std::move(
Streamer));
3389void PPCAIXAsmPrinter::emitModuleCommandLines(
Module &M) {
3390 const NamedMDNode *NMD =
M.getNamedMetadata(
"llvm.commandline");
3395 raw_string_ostream RSOS(S);
3398 assert(
N->getNumOperands() == 1 &&
3399 "llvm.commandline metadata entry can have only one operand");
3403 RSOS <<
"@(#)opt " << MDS->
getString() <<
"\n";
3406 OutStreamer->emitXCOFFCInfoSym(
".GCC.command.line", RSOS.str());
3410 bool LocalIfProven) {
3411 enum class IsLocal {
3423 if (
LHS == IsLocal::False ||
RHS == IsLocal::False)
3424 return IsLocal::False;
3425 if (
LHS == IsLocal::True &&
RHS == IsLocal::True)
3426 return IsLocal::True;
3427 return IsLocal::Unknown;
3431 auto IsLocalFunc = [](
const Function *
F) -> IsLocal {
3432 bool Result =
F->isDSOLocal();
3434 << (Result ?
"dso_local\n" :
"not dso_local\n"));
3435 return Result ? IsLocal::True : IsLocal::False;
3444 std::function<IsLocal(
const Value *)> ValueIsALocalFunc =
3445 [&IsLocalFunc, &
Combine, &ValueIsALocalFunc](
const Value *
V) -> IsLocal {
3447 return IsLocalFunc(
F);
3449 return IsLocal::Unknown;
3454 return Combine(ValueIsALocalFunc(
SI->getTrueValue()),
3455 ValueIsALocalFunc(
SI->getFalseValue()));
3457 IsLocal Res = IsLocal::True;
3458 for (
unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) {
3459 Res =
Combine(Res, ValueIsALocalFunc(PN->getIncomingValue(i)));
3460 if (Res == IsLocal::False)
3475 return IsLocal::Unknown;
3478 return IsLocal::Unknown;
3480 IsLocal Res = IsLocal::True;
3481 for (
unsigned Idx = 0,
End =
Init->getNumOperands(); Idx !=
End; ++Idx) {
3482 Res =
Combine(Res, ValueIsALocalFunc(
Init->getOperand(Idx)));
3483 if (Res == IsLocal::False)
3488 return IsLocal::Unknown;
3493 if (IsLocalFunc(
Resolver) == IsLocal::False && LocalIfProven)
3498 IsLocal Res = IsLocal::True;
3503 Value *RV = Ret->getReturnValue();
3505 Res =
Combine(Res, ValueIsALocalFunc(RV));
3506 if (Res == IsLocal::False)
3511 if (Res == IsLocal::True || (Res == IsLocal::Unknown && !LocalIfProven))
3535void PPCAIXAsmPrinter::emitGlobalIFunc(
Module &M,
const GlobalIFunc &GI) {
3537 const TargetSubtargetInfo *STI =
3539 bool IsPPC64 =
static_cast<const PPCSubtarget *
>(STI)->isPPC64();
3540 const PPCOptions &CLOpts =
3541 static_cast<const PPCTargetMachine &
>(TM).
getCLOpts();
3546 MCSectionXCOFF *FnDescSec =
static_cast<MCSectionXCOFF *
>(
3547 getObjFileLowering().getSectionForFunctionDescriptor(&GI, TM));
3552 CurrentFnSym = getObjFileLowering().getFunctionEntryPointSymbol(&GI, TM);
3555 if (TM.getFunctionSections())
3556 OutStreamer->switchSection(
3557 static_cast<MCSymbolXCOFF *
>(CurrentFnSym)->getRepresentedCsect());
3559 OutStreamer->switchSection(getObjFileLowering().getTextSection());
3562 emitRefMetadata(&GI);
3565 emitLinkage(&GI, CurrentFnDescSym);
3566 emitLinkage(&GI, CurrentFnSym);
3570 emitAlignment(Alignment,
nullptr);
3573 emitFunctionDescriptor();
3575 emitFunctionEntryLabel();
3579 CLOpts.ifunc_local_if_proven)) {
3580 SmallString<128>
Msg;
3581 Msg.append(
"unimplemented: TOC register save/restore needed for ifunc \"");
3582 getNameWithPrefix(
Msg, &GI);
3583 Msg.append(
"\", because couldn't prove all candidates are static or "
3584 "hidden/protected visibility definitions");
3585 if (!CLOpts.test_ifunc_warn_noerror)
3592 auto *FnDescTOCEntrySym =
3593 lookUpOrCreateTOCEntry(CurrentFnDescSym, FnDescTOCEntryType);
3598 auto *Exp_U = symbolWithSpecifier(FnDescTOCEntrySym,
PPC::S_U);
3599 OutStreamer->emitInstruction(MCInstBuilder(PPC::ADDIS)
3604 auto *Exp_L = symbolWithSpecifier(FnDescTOCEntrySym,
PPC::S_L);
3605 OutStreamer->emitInstruction(MCInstBuilder(IsPPC64 ? PPC::LD : PPC::LWZ)
3615 OutStreamer->emitInstruction(MCInstBuilder(IsPPC64 ? PPC::LD : PPC::LWZ)
3622 OutStreamer->emitInstruction(MCInstBuilder(IsPPC64 ? PPC::LD : PPC::LWZ)
3624 .addImm(IsPPC64 ? 16 : 8)
3628 OutStreamer->emitInstruction(MCInstBuilder(IsPPC64 ? PPC::LD : PPC::LWZ)
3634 OutStreamer->emitInstruction(
3635 MCInstBuilder(IsPPC64 ? PPC::MTCTR8 : PPC::MTCTR).addReg(PPC::X12),
3638 OutStreamer->emitInstruction(MCInstBuilder(IsPPC64 ? PPC::BCTR8 : PPC::BCTR),
3642char PPCAIXAsmPrinter::ID = 0;
3645 "AIX PPC Assembly Printer",
false,
false)
3649LLVMInitializePowerPCAsmPrinter() {
const AArch64Subtarget & Subtarget
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static AMDGPUMCExpr::Specifier getSpecifier(unsigned MOFlags)
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_EXTERNAL_VISIBILITY
static bool hasDebugInfo(const MachineFunction *MF)
Module.h This file contains the declarations for the Module class.
static std::string getRegisterName(const TargetRegisterInfo *TRI, Register Reg)
Machine Check Debug Module
This file implements a map that provides insertion order iteration.
Promote Memory to Register
static void collectTOCStats(PPCAsmPrinter::TOCEntryType Type)
static bool isSpecialLLVMGlobalArrayForStaticInit(const GlobalVariable *GV)
static bool TOCRestoreNeededForCallToImplementation(const GlobalIFunc &GI, bool LocalIfProven)
static bool isSpecialLLVMGlobalArrayToSkip(const GlobalVariable *GV)
#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 PPCAsmPrinter::TOCEntryType getTOCEntryTypeForLinkage(GlobalValue::LinkageTypes Linkage)
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)
PassBuilder PB(Mod->getContext(), Machine, PassOpts->PTO, std::nullopt, &PIC)
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
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)
MachineRegisterInfo & MRI
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
static bool printOperand(raw_ostream &OS, const SelectionDAG *G, const SDValue Value)
This file implements a set that has insertion order iteration characteristics.
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
std::unique_ptr< MCStreamer > && Streamer
const AArch64RegisterInfo * getRegisterInfo() const override
const AArch64Options & getCLOpts() const
const AArch64FrameLowering * getFrameLowering() const override
This class is intended to be used as a driving class for all asm writers.
MCSymbol * getSymbol(const GlobalValue *GV) const
virtual MCSymbol * GetCPISymbol(unsigned CPID) const
Return the symbol for the specified constant pool entry.
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.
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.
LLVM_ABI unsigned getPointerSize(unsigned AS=0) const
The pointer representation size in bytes, rounded up to a whole number of bytes.
TypeSize getTypeSizeInBits(Type *Ty) const
Size examples:
Error takeError()
Take ownership of the stored error.
reference get()
Returns a reference to the stored T value.
static LLVM_ABI 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...
LLVM_ABI const Function * getResolverFunction() const
StringRef getSection() const
Get the custom section of this global if it has one.
bool hasMetadata() const
Return true if this GlobalObject has any metadata attached to it.
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this GlobalObject.
bool hasSection() const
Check if this global has a custom object file section.
LinkageTypes getLinkage() const
bool hasPrivateLinkage() const
ThreadLocalMode getThreadLocalMode() const
bool isDeclarationForLinker() const
Module * getParent()
Get the module that this global value is contained inside of...
LLVM_ABI const DataLayout & getDataLayout() const
Get the data layout of the module this global belongs to.
bool hasCommonLinkage() const
bool hasAppendingLinkage() const
LinkageTypes
An enumeration for the kinds of linkage for global values.
@ ExternalLinkage
Externally visible function.
@ AvailableExternallyLinkage
Available for inspection, not emission.
@ ExternalWeakLinkage
ExternalWeak linkage description.
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.
MaybeAlign getAlign() const
Returns the alignment of the given variable.
LLVM_ABI uint64_t getGlobalSize(const DataLayout &DL) const
Get the size of this global variable in bytes.
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx, SMLoc Loc=SMLoc())
const MCExpr * getRHS() const
Get the right-hand side expression of the binary operator.
Opcode getOpcode() const
Get the kind of this binary expression.
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
static LLVM_ABI const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Context object for machine code objects.
void addOperand(const MCOperand Op)
void setOpcode(unsigned Op)
const MCOperand & getOperand(unsigned i) const
static MCOperand createExpr(const MCExpr *Val)
MCRegister getReg() const
Returns the register number.
MCSymbolXCOFF * getQualNameSymbol() const
void setAlignment(Align Value)
static const MCSpecifierExpr * create(const MCExpr *Expr, Spec S, MCContext &Ctx, SMLoc Loc=SMLoc())
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx, SMLoc Loc=SMLoc())
void setPerSymbolCodeModel(MCSymbolXCOFF::CodeModel Model)
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
LLVM_ABI void print(raw_ostream &OS, const MCAsmInfo *MAI) const
print - Print the value to the stream OS.
LLVM_ABI StringRef getString() const
MachineInstrBundleIterator< const MachineInstr > const_iterator
LLVM_ABI MCSymbol * getSymbol() const
Return the MCSymbol for this basic block.
const MachineFunction * getParent() const
Return the MachineFunction containing 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...
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.
LLVM_ABI bool isPhysRegModified(MCRegister PhysReg, bool SkipNoReturnDef=false) const
Return true if the specified register is modified in this function.
LLVM_ABI bool isPhysRegUsed(MCRegister PhysReg, bool SkipRegMaskTest=false) const
Return true if the specified register is modified or read in this function.
iterator find(const KeyT &Key)
LLVM_ABI MDNode * getOperand(unsigned i) const
LLVM_ABI unsigned getNumOperands() const
uint32_t getParmsType() const
MCSymbol * getPICOffsetSymbol(MachineFunction &MF) const
const SmallVectorImpl< Register > & getMustSaveCRs() const
unsigned getFloatingPointParmsNum() const
bool isAIXFuncUseTLSIEForLD() 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)
Register getFrameRegister(const MachineFunction &MF) const override
CodeModel::Model getCodeModel(const TargetMachine &TM, const GlobalValue *GV) const
Calculates the effective code model for argument GV.
static PPCABI computeABI(const Triple &TT, StringRef ABIName)
Compute the ABI variant for TT and ABIName (the "target-abi" module flag), falling back to the triple...
virtual void emitAbiVersion(int AbiVersion)
virtual void emitLocalEntry(MCSymbolELF *S, const MCExpr *LocalOffset)
virtual void emitTCEntry(const MCSymbol &S, PPCMCExpr::Specifier Kind)
virtual void emitMachine(StringRef CPU)
Interface for looking up the initializer for a variable name, used by Init::resolveReferences.
bool isThreadBSSLocal() const
static SectionKind getText()
static SectionKind getData()
bool isThreadLocal() const
bool isGlobalWriteableData() const
bool insert(const value_type &X)
Insert a new element into the SetVector.
void push_back(const T &Elt)
LLVM_ABI void recordPatchPoint(const MCSymbol &L, const MachineInstr &MI)
Generate a stackmap record for a patchpoint instruction.
LLVM_ABI void recordStackMap(const MCSymbol &L, const MachineInstr &MI)
Generate a stackmap record for a stackmap instruction.
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.
constexpr bool empty() const
Check if the string is empty.
A switch()-like statement whose cases are string literals.
StringSwitch & Case(StringLiteral S, T Value)
StringSwitch & Cases(std::initializer_list< StringLiteral > CaseStrings, T Value)
Align getMinFunctionAlignment() const
Return the minimum function alignment.
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
CodeModel::Model getCodeModel() const
Returns the code model.
virtual const TargetLowering * getTargetLowering() const
bool isOSAIX() const
Tests whether the OS is AIX.
The instances of the Type class are immutable: once they are created, they are never changed.
bool isSized() const
Return true if it makes sense to take the size of this type.
LLVM Value Representation.
LLVM_ABI void print(raw_ostream &O, bool IsForDebug=false) const
Implement operator<< on Value.
LLVM_ABI Align getPointerAlignment(const DataLayout &DL) const
Returns an alignment of the pointer value.
LLVM_ABI 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.
LLVM_ABI 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.
static LLVM_ABI Pid getProcessId()
Get the process's identifier.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
const AArch64MCOptions & getCLOpts(const MCTargetOptions &Options)
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
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.
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...
LLVM_ABI StringRef getNormalizedPPCTargetCPU(const Triple &T, StringRef CPUName="")
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(MCRegister Reg)
static bool isVFRegister(MCRegister Reg)
@ CE
Windows NT (Windows on ARM)
void emitInstruction(MCObjectStreamer &, const MCInst &Inst, const MCSubtargetInfo &STI)
LLVM_ABI SmallString< 32 > getExtendedTBTableFlagString(uint8_t Flag)
LLVM_ABI XCOFF::CFileCpuId getCpuID(StringRef CPU)
LLVM_ABI Expected< SmallString< 32 > > parseParmsTypeWithVecInfo(uint32_t Value, unsigned FixedParmsNum, unsigned FloatingParmsNum, unsigned VectorParmsNum)
LLVM_ABI Expected< SmallString< 32 > > parseParmsType(uint32_t Value, unsigned FixedParmsNum, unsigned FloatingParmsNum)
LLVM_ABI Expected< SmallString< 32 > > parseVectorParmsType(uint32_t Value, unsigned ParmsNum)
@ TCPU_INVALID
Invalid id - assumes POWER for old objects.
StorageMappingClass
Storage Mapping Class definitions.
@ XMC_RO
Read Only Constant.
@ XMC_TD
Scalar data item in the TOC.
LLVM_ABI StringRef getTCPUString(XCOFF::CFileCpuId TCPU)
LLVM_ABI StringRef getNameForTracebackTableLanguageId(TracebackTable::LanguageID LangId)
constexpr uint8_t AllocRegNo
@ XTY_SD
Csect definition for initialized storage.
@ XTY_ER
External reference.
unsigned combineHashValue(unsigned a, unsigned b)
Simplistic combination of 32-bit hash values into 32-bit hash values.
constexpr uint64_t PointerSize
aarch64 pointer size.
This is an optimization pass for GlobalISel generic memory operations.
std::optional< LongDoubleFormat > parseLongDoubleFormat(StringRef Name)
Parses an IR floating-point type name into a LongDoubleFormat, returning std::nullopt if it does not ...
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.
@ Unknown
Not known to have no common set bits.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
auto cast_or_null(const Y &Val)
Target & getThePPC32Target()
std::string utostr(uint64_t X, bool isNeg=false)
const Value * getPointerOperand(const Value *V)
A helper function that returns the pointer operand of a load, store or GEP instruction.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
auto dyn_cast_or_null(const Y &Val)
LLVM_ABI 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)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
constexpr uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
bool LowerPPCMachineOperandToMCOperand(unsigned MIOpcode, const MachineOperand &MO, MCOperand &OutMO, AsmPrinter &AP)
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
FormattedNumber format_hex_no_prefix(uint64_t N, unsigned Width, bool Upper=false)
format_hex_no_prefix - Output N as a fixed width hexadecimal.
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
Target & getThePPC64Target()
LLVM_ABI uint64_t get_threadid()
Return the current thread id, as used in various OS system calls.
DWARFExpression::Operation Op
std::string toString(const APInt &I, unsigned Radix, bool Signed, bool formatAsCLiteral=false, bool UpperCase=true, bool InsertSeparators=false)
constexpr int32_t SignExtend32(uint32_t X)
Sign-extend the number in the bottom B bits of X to a 32-bit integer.
Target & getThePPC32LETarget()
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
std::pair< MCSection *, uint32_t > MCSectionSubPair
@ End
Run the machine verifier once, at the end of the pipeline.
std::string itostr(int64_t X)
@ MCSA_Extern
.extern (XCOFF)
@ MCSA_Invalid
Not a valid directive.
LLVM_ABI void reportFatalUsageError(Error Err)
Report a fatal error that does not indicate a bug in LLVM.
Implement std::hash so that hash_code can be used in STL containers.
constexpr uint64_t value() const
This is a hole in the type system and should not be abused.
static bool isEqual(const TOCKey &A, const TOCKey &B)
std::pair< const MCSymbol *, PPCMCExpr::Specifier > TOCKey
static unsigned getHashValue(const TOCKey &PairVal)
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