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.");
102 "ppc-aix-ssp-tb-bit",
cl::init(
false),
106 "ppc-ifunc-local-if-proven",
cl::init(
false),
107 cl::desc(
"During ifunc lowering, the compiler assumes the resolver returns "
108 "dso-local functions and bails out if non-local functions are "
109 "detected; this flag flips the assumption: resolver returns "
110 "preemptible functions unless the compiler can prove all paths "
111 "return local functions."),
125 using TOCKey = std::pair<const MCSymbol *, PPCMCExpr::Specifier>;
140 Tag_GNU_Power_ABI_FP = 4,
141 Tag_GNU_Power_ABI_Vector = 8,
142 Tag_GNU_Power_ABI_Struct_Return = 12,
145 Val_GNU_Power_ABI_NoFloat = 0b00,
146 Val_GNU_Power_ABI_HardFloat_DP = 0b01,
147 Val_GNU_Power_ABI_SoftFloat_DP = 0b10,
148 Val_GNU_Power_ABI_HardFloat_SP = 0b11,
150 Val_GNU_Power_ABI_LDBL_IBM128 = 0b0100,
151 Val_GNU_Power_ABI_LDBL_64 = 0b1000,
152 Val_GNU_Power_ABI_LDBL_IEEE128 = 0b1100,
164 MapVector<std::pair<const MCSymbol *, PPCMCExpr::Specifier>,
MCSymbol *> TOC;
165 const PPCSubtarget *Subtarget =
nullptr;
170 MapVector<const GlobalValue *, uint64_t> TLSVarsToAddressMapping;
173 explicit PPCAsmPrinter(TargetMachine &TM,
174 std::unique_ptr<MCStreamer>
Streamer,
char &ID)
177 StringRef getPassName()
const override {
return "PowerPC Assembly Printer"; }
180 TOCType_ConstantPool,
181 TOCType_GlobalExternal,
182 TOCType_GlobalInternal,
185 TOCType_BlockAddress,
189 MCSymbol *lookUpOrCreateTOCEntry(
const MCSymbol *Sym, TOCEntryType
Type,
192 bool doInitialization(
Module &M)
override {
198 const MCExpr *symbolWithSpecifier(
const MCSymbol *S,
205 void printOperand(
const MachineInstr *
MI,
unsigned OpNo, raw_ostream &O);
207 void PrintSymbolOperand(
const MachineOperand &MO, raw_ostream &O)
override;
208 bool PrintAsmOperand(
const MachineInstr *
MI,
unsigned OpNo,
209 const char *ExtraCode, raw_ostream &O)
override;
210 bool PrintAsmMemoryOperand(
const MachineInstr *
MI,
unsigned OpNo,
211 const char *ExtraCode, raw_ostream &O)
override;
213 void LowerSTACKMAP(StackMaps &SM,
const MachineInstr &
MI);
214 void LowerPATCHPOINT(StackMaps &SM,
const MachineInstr &
MI);
216 void EmitAIXTlsCallHelper(
const MachineInstr *
MI);
217 const MCExpr *getAdjustedFasterLocalExpr(
const MachineOperand &MO,
228class PPCLinuxAsmPrinter :
public PPCAsmPrinter {
232 explicit PPCLinuxAsmPrinter(TargetMachine &TM,
233 std::unique_ptr<MCStreamer>
Streamer)
236 StringRef getPassName()
const override {
237 return "Linux PPC Assembly Printer";
240 void emitGNUAttributes(
Module &M);
242 void emitStartOfAsmFile(
Module &M)
override;
243 void emitEndOfAsmFile(
Module &)
override;
245 void emitFunctionEntryLabel()
override;
247 void emitFunctionBodyStart()
override;
248 void emitFunctionBodyEnd()
override;
252class PPCAIXAsmPrinter :
public PPCAsmPrinter {
256 SmallSetVector<MCSymbol *, 8> ExtSymSDNodeSymbols;
260 std::string FormatIndicatorAndUniqueModId;
264 DenseMap<const GlobalObject *, SmallVector<const GlobalAlias *, 1>>
267 uint16_t getNumberOfVRSaved();
268 void emitTracebackTable();
272 void emitGlobalVariableHelper(
const GlobalVariable *);
275 uint64_t getAliasOffset(
const Constant *
C);
280 PPCAIXAsmPrinter(TargetMachine &TM, std::unique_ptr<MCStreamer>
Streamer)
282 if (MAI.isLittleEndian())
284 "cannot create AIX PPC Assembly Printer for a little-endian target");
287 StringRef getPassName()
const override {
return "AIX PPC Assembly Printer"; }
289 bool doInitialization(
Module &M)
override;
291 void emitXXStructorList(
const DataLayout &
DL,
const Constant *
List,
292 bool IsCtor)
override;
296 void emitGlobalVariable(
const GlobalVariable *GV)
override;
298 void emitFunctionDescriptor()
override;
300 void emitFunctionEntryLabel()
override;
302 void emitFunctionBodyEnd()
override;
304 void emitPGORefs(
Module &M);
308 void emitEndOfAsmFile(
Module &)
override;
310 void emitLinkage(
const GlobalValue *GV, MCSymbol *GVSym)
const override;
314 bool doFinalization(
Module &M)
override;
316 void emitTTypeReference(
const GlobalValue *GV,
unsigned Encoding)
override;
318 void emitModuleCommandLines(
Module &M)
override;
320 void emitRefMetadata(
const GlobalObject *);
322 void emitGlobalIFunc(
Module &M,
const GlobalIFunc &GI)
override;
331 getSymbol(GV)->
print(O, MAI);
335void PPCAsmPrinter::printOperand(
const MachineInstr *
MI,
unsigned OpNo,
337 const DataLayout &
DL = getDataLayout();
338 const MachineOperand &MO =
MI->getOperand(OpNo);
358 O <<
DL.getInternalSymbolPrefix() <<
"CPI" << getFunctionNumber() <<
'_'
365 PrintSymbolOperand(MO, O);
370 O <<
"<unknown operand type: " << (unsigned)MO.
getType() <<
">";
377bool PPCAsmPrinter::PrintAsmOperand(
const MachineInstr *
MI,
unsigned OpNo,
378 const char *ExtraCode, raw_ostream &O) {
380 if (ExtraCode && ExtraCode[0]) {
381 if (ExtraCode[1] != 0)
return true;
383 switch (ExtraCode[0]) {
389 if (!
MI->getOperand(OpNo).isReg() ||
390 OpNo+1 ==
MI->getNumOperands() ||
391 !
MI->getOperand(OpNo+1).isReg())
398 if (
MI->getOperand(OpNo).isImm())
402 if(!
MI->getOperand(OpNo).isReg())
408 Reg = PPC::VSX32 + (
Reg - PPC::V0);
410 Reg = PPC::VSX32 + (
Reg - PPC::VF0);
426bool PPCAsmPrinter::PrintAsmMemoryOperand(
const MachineInstr *
MI,
unsigned OpNo,
427 const char *ExtraCode,
429 if (ExtraCode && ExtraCode[0]) {
430 if (ExtraCode[1] != 0)
return true;
432 switch (ExtraCode[0]) {
433 default:
return true;
435 O << getDataLayout().getPointerSize() <<
"(";
446 if (
MI->getOperand(OpNo).isImm())
457 assert(
MI->getOperand(OpNo).isReg());
462 assert(
MI->getOperand(OpNo).isReg());
472 case PPCAsmPrinter::TOCType_ConstantPool:
475 case PPCAsmPrinter::TOCType_GlobalInternal:
476 ++NumTOCGlobalInternal;
478 case PPCAsmPrinter::TOCType_GlobalExternal:
479 ++NumTOCGlobalExternal;
481 case PPCAsmPrinter::TOCType_JumpTable:
484 case PPCAsmPrinter::TOCType_ThreadLocal:
487 case PPCAsmPrinter::TOCType_BlockAddress:
488 ++NumTOCBlockAddress;
490 case PPCAsmPrinter::TOCType_EHBlock:
507 assert(GV &&
"expected global for MO_GlobalAddress");
528MCSymbol *PPCAsmPrinter::lookUpOrCreateTOCEntry(
const MCSymbol *Sym,
532 auto [It,
Inserted] =
TOC.try_emplace({Sym, Spec});
538 TOCEntry = createTempSymbol(
"C");
542void PPCAsmPrinter::LowerSTACKMAP(StackMaps &SM,
const MachineInstr &
MI) {
543 unsigned NumNOPBytes =
MI.getOperand(1).getImm();
545 auto &Ctx = OutStreamer->getContext();
546 MCSymbol *MILabel = Ctx.createTempSymbol();
547 OutStreamer->emitLabel(MILabel);
550 assert(NumNOPBytes % 4 == 0 &&
"Invalid number of NOP bytes requested!");
556 while (NumNOPBytes > 0) {
557 if (MII !=
MBB.
end() && MII->isDebugInstr()) {
561 if (MII ==
MBB.
end() || MII->isCall() ||
562 MII->getOpcode() == TargetOpcode::PATCHPOINT ||
563 MII->getOpcode() == TargetOpcode::STACKMAP)
570 for (
unsigned i = 0; i < NumNOPBytes; i += 4)
571 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::NOP));
576void PPCAsmPrinter::LowerPATCHPOINT(StackMaps &SM,
const MachineInstr &
MI) {
577 auto &Ctx = OutStreamer->getContext();
578 MCSymbol *MILabel = Ctx.createTempSymbol();
579 OutStreamer->emitLabel(MILabel);
582 PatchPointOpers Opers(&
MI);
584 unsigned EncodedBytes = 0;
585 const MachineOperand &CalleeMO = Opers.getCallTarget();
587 if (CalleeMO.
isImm()) {
588 int64_t CallTarget = CalleeMO.
getImm();
590 assert((CallTarget & 0xFFFFFFFFFFFF) == CallTarget &&
591 "High 16 bits of call target should be zero.");
592 Register ScratchReg =
MI.getOperand(Opers.getNextScratchIdx()).getReg();
595 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::LI8)
597 .addImm((CallTarget >> 32) & 0xFFFF));
600 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::RLDIC)
603 .addImm(32).addImm(16));
606 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::ORIS8)
609 .addImm((CallTarget >> 16) & 0xFFFF));
612 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::ORI8)
615 .addImm(CallTarget & 0xFFFF));
620 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::STD)
622 .addImm(TOCSaveOffset)
632 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::LD)
635 .addReg(ScratchReg));
638 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::LD)
641 .addReg(ScratchReg));
645 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::MTCTR8)
646 .addReg(ScratchReg));
649 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::BCTRL8));
653 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::LD)
655 .addImm(TOCSaveOffset)
660 const GlobalValue *GValue = CalleeMO.
getGlobal();
661 MCSymbol *MOSymbol = getSymbol(GValue);
664 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::BL8_NOP)
673 unsigned NumBytes = Opers.getNumPatchBytes();
674 if (NumBytes < EncodedBytes)
676 "Patchpoint can't request size less than the length of a call.");
678 assert((NumBytes - EncodedBytes) % 4 == 0 &&
679 "Invalid number of NOP bytes requested!");
680 for (
unsigned i = EncodedBytes; i < NumBytes; i += 4)
681 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::NOP));
691 SymName =
".__tls_get_addr";
693 case PPC::GETtlsTpointer32AIX:
694 SymName =
".__get_tpointer";
696 case PPC::GETtlsMOD32AIX:
697 case PPC::GETtlsMOD64AIX:
698 SymName =
".__tls_get_mod";
704 ->getQualNameSymbol();
707void PPCAsmPrinter::EmitAIXTlsCallHelper(
const MachineInstr *
MI) {
709 "Only expecting to emit calls to get the thread pointer on AIX!");
713 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::BLA).addExpr(TlsRef));
718void PPCAsmPrinter::emitTlsCall(
const MachineInstr *
MI,
721 unsigned Opcode = PPC::BL8_NOP_TLS;
723 assert(
MI->getNumOperands() >= 3 &&
"Expecting at least 3 operands from MI");
727 Opcode = PPC::BL8_NOTOC_TLS;
729 const Module *
M = MF->getFunction().getParent();
732 ((Subtarget->isPPC64() &&
MI->getOperand(0).getReg() == PPC::X3) ||
733 (!Subtarget->isPPC64() &&
MI->getOperand(0).getReg() == PPC::R3)) &&
734 "GETtls[ld]ADDR[32] must define GPR3");
736 ((Subtarget->isPPC64() &&
MI->getOperand(1).getReg() == PPC::X3) ||
737 (!Subtarget->isPPC64() &&
MI->getOperand(1).getReg() == PPC::R3)) &&
738 "GETtls[ld]ADDR[32] must read GPR3");
745 Register VarOffsetReg = Subtarget->isPPC64() ? PPC::X4 : PPC::R4;
747 assert((
MI->getOpcode() == PPC::GETtlsMOD32AIX ||
748 MI->getOpcode() == PPC::GETtlsMOD64AIX ||
749 (
MI->getOperand(2).isReg() &&
750 MI->getOperand(2).getReg() == VarOffsetReg)) &&
751 "GETtls[ld]ADDR[32] must read GPR4");
752 EmitAIXTlsCallHelper(
MI);
756 MCSymbol *TlsGetAddr = OutContext.getOrCreateSymbol(
"__tls_get_addr");
764 if (Kind ==
PPC::S_PLT && Subtarget->isSecurePlt() &&
768 const MachineOperand &MO =
MI->getOperand(2);
769 const GlobalValue *GValue = MO.
getGlobal();
770 MCSymbol *MOSymbol = getSymbol(GValue);
772 EmitToStreamer(*OutStreamer,
773 MCInstBuilder(Subtarget->isPPC64() ? Opcode
774 : (
unsigned)PPC::BL_TLS)
797static PPCAsmPrinter::TOCEntryType
802 return PPCAsmPrinter::TOCType_GlobalExternal;
804 return PPCAsmPrinter::TOCType_GlobalInternal;
807static PPCAsmPrinter::TOCEntryType
812 return PPCAsmPrinter::TOCType_ThreadLocal;
820 return PPCAsmPrinter::TOCType_ConstantPool;
822 return PPCAsmPrinter::TOCType_JumpTable;
824 return PPCAsmPrinter::TOCType_BlockAddress;
830const MCExpr *PPCAsmPrinter::symbolWithSpecifier(
const MCSymbol *S,
838void PPCAsmPrinter::emitInstruction(
const MachineInstr *
MI) {
839 PPC_MC::verifyInstructionPredicates(
MI->getOpcode(),
840 getSubtargetInfo().getFeatureBits());
843 const bool IsPPC64 = Subtarget->isPPC64();
844 const bool IsAIX = Subtarget->
isAIXABI();
845 const bool HasAIXSmallLocalTLS = Subtarget->hasAIXSmallLocalExecTLS() ||
846 Subtarget->hasAIXSmallLocalDynamicTLS();
847 const Module *
M = MF->getFunction().getParent();
852 if (!
MI->isInlineAsm()) {
853 for (
const MachineOperand &MO:
MI->operands()) {
856 if (Subtarget->hasSPE()) {
874 auto getTOCRelocAdjustedExprForXCOFF = [
this](
const MCExpr *Expr,
875 ptrdiff_t OriginalOffset) {
882 ptrdiff_t Adjustment =
888 auto getTOCEntryLoadingExprForXCOFF =
889 [IsPPC64, getTOCRelocAdjustedExprForXCOFF,
890 this](
const MCSymbol *MOSymbol,
const MCExpr *Expr,
892 const unsigned EntryByteSize = IsPPC64 ? 8 : 4;
893 const auto TOCEntryIter =
TOC.find({MOSymbol, VK});
895 "Could not find the TOC entry for this symbol.");
896 const ptrdiff_t EntryDistanceFromTOCBase =
897 (TOCEntryIter -
TOC.begin()) * EntryByteSize;
898 constexpr int16_t PositiveTOCRange = INT16_MAX;
900 if (EntryDistanceFromTOCBase > PositiveTOCRange)
901 return getTOCRelocAdjustedExprForXCOFF(Expr, EntryDistanceFromTOCBase);
913 assert(MO.
isGlobal() &&
"Only expecting a global MachineOperand here!\n");
921 PPCFunctionInfo *FuncInfo = MF->getInfo<PPCFunctionInfo>();
925 dbgs() <<
"Current function uses IE access for default LD vars.\n");
948 switch (
MI->getOpcode()) {
950 case TargetOpcode::PATCHABLE_FUNCTION_ENTER: {
952 "AIX does not support patchable function entry!");
954 unsigned Num =
F.getFnAttributeAsParsedInteger(
"patchable-function-entry");
960 case TargetOpcode::DBG_VALUE:
962 case TargetOpcode::STACKMAP:
963 return LowerSTACKMAP(SM, *
MI);
964 case TargetOpcode::PATCHPOINT:
965 return LowerPATCHPOINT(SM, *
MI);
967 case PPC::MoveGOTtoLR: {
975 OutContext.getOrCreateSymbol(StringRef(
"_GLOBAL_OFFSET_TABLE_"));
981 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::BL).addExpr(OffsExpr));
984 case PPC::MovePCtoLR:
985 case PPC::MovePCtoLR8: {
990 MCSymbol *PICBase = MF->getPICBaseSymbol();
993 EmitToStreamer(*OutStreamer,
994 MCInstBuilder(PPC::BCLalways)
1000 OutStreamer->emitLabel(PICBase);
1003 case PPC::UpdateGBR: {
1012 if (Subtarget->isSecurePlt() && isPositionIndependent() ) {
1014 MCSymbol *BaseSymbol = OutContext.getOrCreateSymbol(
1023 const MCExpr *DeltaHi =
1027 MCInstBuilder(PPC::ADDIS).addReg(PICR).addReg(PICR).addExpr(DeltaHi));
1029 const MCExpr *DeltaLo =
1033 MCInstBuilder(PPC::ADDI).addReg(PICR).addReg(PICR).addExpr(DeltaLo));
1037 MF->getInfo<PPCFunctionInfo>()->getPICOffsetSymbol(*MF);
1044 const MCOperand PICR = TmpInst.
getOperand(0);
1051 EmitToStreamer(*OutStreamer, TmpInst);
1057 EmitToStreamer(*OutStreamer, TmpInst);
1068 const MachineOperand &MO =
MI->getOperand(1);
1070 "Invalid operand for LWZtoc.");
1078 const MCExpr *
Exp = symbolWithSpecifier(MOSymbol,
PPC::S_GOT);
1080 EmitToStreamer(*OutStreamer, TmpInst);
1099 "This pseudo should only be selected for 32-bit small code model.");
1100 Exp = getTOCEntryLoadingExprForXCOFF(MOSymbol, Exp, VK);
1105 OutStreamer->getCommentOS() << MO <<
'\n';
1106 EmitToStreamer(*OutStreamer, TmpInst);
1113 OutContext.getOrCreateSymbol(Twine(
".LTOC")), OutContext);
1116 EmitToStreamer(*OutStreamer, TmpInst);
1120 case PPC::ADDItoc8: {
1122 "PseudoOp only valid for small code model AIX");
1128 TmpInst.
setOpcode((!IsPPC64) ? (PPC::LA) : (PPC::LA8));
1130 const MachineOperand &MO =
MI->getOperand(2);
1139 EmitToStreamer(*OutStreamer, TmpInst);
1152 const MachineOperand &MO =
MI->getOperand(1);
1154 "Invalid operand!");
1168 const MCExpr *
Exp = symbolWithSpecifier(TOCEntry, VKExpr);
1170 IsAIX ? getTOCEntryLoadingExprForXCOFF(MOSymbol, Exp, VK) : Exp);
1173 if (isVerbose() && IsAIX)
1174 OutStreamer->getCommentOS() << MO <<
'\n';
1175 EmitToStreamer(*OutStreamer, TmpInst);
1178 case PPC::ADDIStocHA: {
1179 const MachineOperand &MO =
MI->getOperand(2);
1182 "Invalid operand for ADDIStocHA.");
1183 assert((IsAIX && !IsPPC64 &&
1185 "This pseudo should only be selected for 32-bit large code model on"
1205 if ( {
1217 const MCExpr *
Exp = symbolWithSpecifier(MOSymbol,
PPC::S_U);
1219 EmitToStreamer(*OutStreamer, TmpInst);
1222 case PPC::LWZtocL: {
1223 const MachineOperand &MO =
MI->getOperand(1);
1226 "Invalid operand for LWZtocL.");
1227 assert(IsAIX && !IsPPC64 &&
1229 "This pseudo should only be selected for 32-bit large code model on"
1249 const MCExpr *
Exp = symbolWithSpecifier(TOCEntry,
PPC::S_L);
1251 EmitToStreamer(*OutStreamer, TmpInst);
1254 case PPC::ADDIStocHA8: {
1264 const MachineOperand &MO =
MI->getOperand(2);
1266 "Invalid operand for ADDIStocHA8!");
1272 const bool GlobalToc =
1284 const MCExpr *
Exp = symbolWithSpecifier(MOSymbol, VK);
1293 EmitToStreamer(*OutStreamer, TmpInst);
1306 const MachineOperand &MO =
MI->getOperand(1);
1309 "Invalid operand for LDtocL!");
1313 "LDtocL used on symbol that could be accessed directly is "
1314 "invalid. Must match ADDIStocHA8."));
1325 const MCExpr *
Exp = symbolWithSpecifier(MOSymbol, VK);
1327 EmitToStreamer(*OutStreamer, TmpInst);
1331 case PPC::ADDItocL8: {
1335 unsigned Op =
MI->getOpcode();
1339 TmpInst.
setOpcode(
Op == PPC::ADDItocL8 ? (IsAIX ? PPC::LA8 : PPC::ADDI8)
1342 const MachineOperand &MO =
MI->getOperand(2);
1345 : MO.
isGlobal() &&
"Invalid operand for ADDItocL8.");
1347 "Interposable definitions must use indirect accesses.");
1356 EmitToStreamer(*OutStreamer, TmpInst);
1359 case PPC::ADDISgotTprelHA: {
1362 assert(IsPPC64 &&
"Not supported for 32-bit PowerPC");
1363 const MachineOperand &MO =
MI->getOperand(2);
1364 const GlobalValue *GValue = MO.
getGlobal();
1365 MCSymbol *MOSymbol = getSymbol(GValue);
1366 const MCExpr *SymGotTprel =
1368 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::ADDIS8)
1369 .addReg(
MI->getOperand(0).getReg())
1370 .addReg(
MI->getOperand(1).getReg())
1371 .addExpr(SymGotTprel));
1374 case PPC::LDgotTprelL:
1375 case PPC::LDgotTprelL32: {
1380 TmpInst.
setOpcode(IsPPC64 ? PPC::LD : PPC::LWZ);
1381 const MachineOperand &MO =
MI->getOperand(1);
1382 const GlobalValue *GValue = MO.
getGlobal();
1383 MCSymbol *MOSymbol = getSymbol(GValue);
1384 const MCExpr *
Exp = symbolWithSpecifier(
1387 EmitToStreamer(*OutStreamer, TmpInst);
1391 case PPC::PPC32PICGOT: {
1392 MCSymbol *GOTSymbol = OutContext.getOrCreateSymbol(StringRef(
"_GLOBAL_OFFSET_TABLE_"));
1393 MCSymbol *GOTRef = OutContext.createTempSymbol();
1394 MCSymbol *NextInstr = OutContext.createTempSymbol();
1396 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::BL)
1400 const MCExpr *OffsExpr =
1404 OutStreamer->emitLabel(GOTRef);
1405 OutStreamer->emitValue(OffsExpr, 4);
1406 OutStreamer->emitLabel(NextInstr);
1407 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::MFLR)
1408 .addReg(
MI->getOperand(0).getReg()));
1409 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::LWZ)
1410 .addReg(
MI->getOperand(1).getReg())
1412 .addReg(
MI->getOperand(0).getReg()));
1413 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::ADD4)
1414 .addReg(
MI->getOperand(0).getReg())
1415 .addReg(
MI->getOperand(1).getReg())
1416 .addReg(
MI->getOperand(0).getReg()));
1419 case PPC::PPC32GOT: {
1421 OutContext.getOrCreateSymbol(StringRef(
"_GLOBAL_OFFSET_TABLE_"));
1422 const MCExpr *SymGotTlsL =
1424 const MCExpr *SymGotTlsHA =
1426 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::LI)
1427 .addReg(
MI->getOperand(0).getReg())
1428 .addExpr(SymGotTlsL));
1429 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::ADDIS)
1430 .addReg(
MI->getOperand(0).getReg())
1431 .addReg(
MI->getOperand(0).getReg())
1432 .addExpr(SymGotTlsHA));
1435 case PPC::ADDIStlsgdHA: {
1438 assert(IsPPC64 &&
"Not supported for 32-bit PowerPC");
1439 const MachineOperand &MO =
MI->getOperand(2);
1440 const GlobalValue *GValue = MO.
getGlobal();
1441 MCSymbol *MOSymbol = getSymbol(GValue);
1442 const MCExpr *SymGotTlsGD =
1444 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::ADDIS8)
1445 .addReg(
MI->getOperand(0).getReg())
1446 .addReg(
MI->getOperand(1).getReg())
1447 .addExpr(SymGotTlsGD));
1450 case PPC::ADDItlsgdL:
1453 case PPC::ADDItlsgdL32: {
1456 const MachineOperand &MO =
MI->getOperand(2);
1457 const GlobalValue *GValue = MO.
getGlobal();
1458 MCSymbol *MOSymbol = getSymbol(GValue);
1459 const MCExpr *SymGotTlsGD = symbolWithSpecifier(
1461 EmitToStreamer(*OutStreamer,
1462 MCInstBuilder(IsPPC64 ? PPC::ADDI8 : PPC::ADDI)
1463 .addReg(
MI->getOperand(0).getReg())
1464 .addReg(
MI->getOperand(1).getReg())
1465 .addExpr(SymGotTlsGD));
1468 case PPC::GETtlsMOD32AIX:
1469 case PPC::GETtlsMOD64AIX:
1473 case PPC::GETtlsADDR:
1476 case PPC::GETtlsADDRPCREL:
1477 case PPC::GETtlsADDR32AIX:
1478 case PPC::GETtlsADDR64AIX:
1482 case PPC::GETtlsADDR32: {
1488 case PPC::GETtlsTpointer32AIX: {
1491 EmitAIXTlsCallHelper(
MI);
1494 case PPC::ADDIStlsldHA: {
1497 assert(IsPPC64 &&
"Not supported for 32-bit PowerPC");
1498 const MachineOperand &MO =
MI->getOperand(2);
1499 const GlobalValue *GValue = MO.
getGlobal();
1500 MCSymbol *MOSymbol = getSymbol(GValue);
1501 const MCExpr *SymGotTlsLD =
1503 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::ADDIS8)
1504 .addReg(
MI->getOperand(0).getReg())
1505 .addReg(
MI->getOperand(1).getReg())
1506 .addExpr(SymGotTlsLD));
1509 case PPC::ADDItlsldL:
1512 case PPC::ADDItlsldL32: {
1515 const MachineOperand &MO =
MI->getOperand(2);
1516 const GlobalValue *GValue = MO.
getGlobal();
1517 MCSymbol *MOSymbol = getSymbol(GValue);
1518 const MCExpr *SymGotTlsLD = symbolWithSpecifier(
1520 EmitToStreamer(*OutStreamer,
1521 MCInstBuilder(IsPPC64 ? PPC::ADDI8 : PPC::ADDI)
1522 .addReg(
MI->getOperand(0).getReg())
1523 .addReg(
MI->getOperand(1).getReg())
1524 .addExpr(SymGotTlsLD));
1527 case PPC::GETtlsldADDR:
1530 case PPC::GETtlsldADDRPCREL:
1531 case PPC::GETtlsldADDR32: {
1537 case PPC::ADDISdtprelHA:
1540 case PPC::ADDISdtprelHA32: {
1543 const MachineOperand &MO =
MI->getOperand(2);
1544 const GlobalValue *GValue = MO.
getGlobal();
1545 MCSymbol *MOSymbol = getSymbol(GValue);
1549 MCInstBuilder(IsPPC64 ? PPC::ADDIS8 : PPC::ADDIS)
1550 .addReg(
MI->getOperand(0).getReg())
1551 .addReg(
MI->getOperand(1).getReg())
1552 .addExpr(SymDtprel));
1555 case PPC::PADDIdtprel: {
1558 const MachineOperand &MO =
MI->getOperand(2);
1559 const GlobalValue *GValue = MO.
getGlobal();
1560 MCSymbol *MOSymbol = getSymbol(GValue);
1561 const MCExpr *SymDtprel = symbolWithSpecifier(MOSymbol,
PPC::S_DTPREL);
1562 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::PADDI8)
1563 .addReg(
MI->getOperand(0).getReg())
1564 .addReg(
MI->getOperand(1).getReg())
1565 .addExpr(SymDtprel));
1569 case PPC::ADDIdtprelL:
1572 case PPC::ADDIdtprelL32: {
1575 const MachineOperand &MO =
MI->getOperand(2);
1576 const GlobalValue *GValue = MO.
getGlobal();
1577 MCSymbol *MOSymbol = getSymbol(GValue);
1579 EmitToStreamer(*OutStreamer,
1580 MCInstBuilder(IsPPC64 ? PPC::ADDI8 : PPC::ADDI)
1581 .addReg(
MI->getOperand(0).getReg())
1582 .addReg(
MI->getOperand(1).getReg())
1583 .addExpr(SymDtprel));
1588 if (!Subtarget->hasMFOCRF()) {
1591 unsigned NewOpcode =
1592 MI->getOpcode() == PPC::MFOCRF ? PPC::MFCR : PPC::MFCR8;
1593 OutStreamer->AddComment(PPCInstPrinter::
1595 EmitToStreamer(*OutStreamer, MCInstBuilder(NewOpcode)
1596 .addReg(
MI->getOperand(0).getReg()));
1602 if (!Subtarget->hasMFOCRF()) {
1605 unsigned NewOpcode =
1606 MI->getOpcode() == PPC::MTOCRF ? PPC::MTCRF : PPC::MTCRF8;
1607 unsigned Mask = 0x80 >> OutContext.getRegisterInfo()
1608 ->getEncodingValue(
MI->getOperand(0).getReg());
1609 OutStreamer->AddComment(PPCInstPrinter::
1611 EmitToStreamer(*OutStreamer, MCInstBuilder(NewOpcode)
1613 .addReg(
MI->getOperand(1).getReg()));
1623 unsigned OpNum = (
MI->getOpcode() == PPC::STD) ? 2 : 1;
1627 for (
const MachineOperand &TempMO :
MI->operands()) {
1630 TempMO.getOperandNo() == 1)
1633 const MachineOperand &MO =
MI->getOperand(OpNum);
1667 if (!HasAIXSmallLocalTLS)
1669 bool IsMIADDI8 =
MI->getOpcode() == PPC::ADDI8;
1670 unsigned OpNum = IsMIADDI8 ? 2 : 1;
1671 const MachineOperand &MO =
MI->getOperand(OpNum);
1678 const MCExpr *Expr = getAdjustedFasterLocalExpr(MO, MO.
getOffset());
1686 EmitToStreamer(*OutStreamer, TmpInst);
1692 case PPC::PseudoEIEIO: {
1695 MCInstBuilder(PPC::ORI).addReg(PPC::X2).addReg(PPC::X2).addImm(0));
1698 MCInstBuilder(PPC::ORI).addReg(PPC::X2).addReg(PPC::X2).addImm(0));
1699 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::EnforceIEIO));
1705 EmitToStreamer(*OutStreamer, TmpInst);
1715PPCAsmPrinter::getAdjustedFasterLocalExpr(
const MachineOperand &MO,
1722 assert(MO.
isGlobal() &&
"Only expecting a global MachineOperand here!");
1723 const GlobalValue *GValue = MO.
getGlobal();
1726 "Only local-[exec|dynamic] accesses are handled!");
1732 const auto TLSVarsMapEntryIter = TLSVarsToAddressMapping.
find(GValue);
1733 if (TLSVarsMapEntryIter == TLSVarsToAddressMapping.
end())
1734 assert(IsGlobalADeclaration &&
1735 "Only expecting to find extern TLS variables not present in the TLS "
1736 "variable-to-address map!");
1738 unsigned TLSVarAddress =
1739 IsGlobalADeclaration ? 0 : TLSVarsMapEntryIter->second;
1740 ptrdiff_t FinalAddress = (TLSVarAddress +
Offset);
1752 if (FinalAddress >= 32768) {
1759 ptrdiff_t Delta = ((FinalAddress + 32768) & ~0xFFFF);
1761 [[maybe_unused]] ptrdiff_t InstDisp = TLSVarAddress +
Offset - Delta;
1763 ((InstDisp < 32768) && (InstDisp >= -32768)) &&
1764 "Expecting the instruction displacement for local-[exec|dynamic] TLS "
1765 "variables to be between [-32768, 32768)!");
1773void PPCLinuxAsmPrinter::emitGNUAttributes(
Module &M) {
1775 MDString *LongDoubleType =
1777 if (!LongDoubleType)
1782 case LongDoubleFormat::PPCDoubleDouble:
1783 OutStreamer->emitGNUAttribute(Tag_GNU_Power_ABI_FP,
1784 Val_GNU_Power_ABI_HardFloat_DP |
1785 Val_GNU_Power_ABI_LDBL_IBM128);
1787 case LongDoubleFormat::IEEEquad:
1788 OutStreamer->emitGNUAttribute(Tag_GNU_Power_ABI_FP,
1789 Val_GNU_Power_ABI_HardFloat_DP |
1790 Val_GNU_Power_ABI_LDBL_IEEE128);
1792 case LongDoubleFormat::IEEEdouble:
1793 OutStreamer->emitGNUAttribute(Tag_GNU_Power_ABI_FP,
1794 Val_GNU_Power_ABI_HardFloat_DP |
1795 Val_GNU_Power_ABI_LDBL_64);
1802void PPCLinuxAsmPrinter::emitInstruction(
const MachineInstr *
MI) {
1803 if (!Subtarget->isPPC64())
1804 return PPCAsmPrinter::emitInstruction(
MI);
1806 switch (
MI->getOpcode()) {
1809 case TargetOpcode::PATCHABLE_FUNCTION_ENTER: {
1823 unsigned Num =
F.getFnAttributeAsParsedInteger(
"patchable-function-entry");
1825 if (!MAI.isLittleEndian() || Num)
1827 MCSymbol *BeginOfSled = OutContext.createTempSymbol();
1828 MCSymbol *EndOfSled = OutContext.createTempSymbol();
1829 OutStreamer->emitLabel(BeginOfSled);
1830 EmitToStreamer(*OutStreamer,
1831 MCInstBuilder(PPC::B).addExpr(
1833 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::NOP));
1836 MCInstBuilder(PPC::STD).addReg(PPC::X0).addImm(-8).addReg(PPC::X1));
1837 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::MFLR8).addReg(PPC::X0));
1838 EmitToStreamer(*OutStreamer,
1839 MCInstBuilder(PPC::BL8_NOP)
1841 OutContext.getOrCreateSymbol(
"__xray_FunctionEntry"),
1843 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::MTLR8).addReg(PPC::X0));
1844 OutStreamer->emitLabel(EndOfSled);
1845 recordSled(BeginOfSled, *
MI, SledKind::FUNCTION_ENTER, 2);
1848 case TargetOpcode::PATCHABLE_RET: {
1849 unsigned RetOpcode =
MI->getOperand(0).getImm();
1859 if (RetOpcode == PPC::BCCLR) {
1860 IsConditional =
true;
1861 }
else if (RetOpcode == PPC::TCRETURNdi8 || RetOpcode == PPC::TCRETURNri8 ||
1862 RetOpcode == PPC::TCRETURNai8) {
1864 }
else if (RetOpcode == PPC::BLR8 || RetOpcode == PPC::TAILB8) {
1865 IsConditional =
false;
1867 EmitToStreamer(*OutStreamer, RetInst);
1872 if (IsConditional) {
1891 FallthroughLabel = OutContext.createTempSymbol();
1894 MCInstBuilder(PPC::BCC)
1897 .addReg(
MI->getOperand(2).getReg())
1914 OutStreamer->emitCodeAlignment(
Align(8), getSubtargetInfo());
1915 MCSymbol *BeginOfSled = OutContext.createTempSymbol();
1916 OutStreamer->emitLabel(BeginOfSled);
1917 EmitToStreamer(*OutStreamer, RetInst);
1918 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::NOP));
1921 MCInstBuilder(PPC::STD).addReg(PPC::X0).addImm(-8).addReg(PPC::X1));
1922 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::MFLR8).addReg(PPC::X0));
1923 EmitToStreamer(*OutStreamer,
1924 MCInstBuilder(PPC::BL8_NOP)
1926 OutContext.getOrCreateSymbol(
"__xray_FunctionExit"),
1928 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::MTLR8).addReg(PPC::X0));
1929 EmitToStreamer(*OutStreamer, RetInst);
1931 OutStreamer->emitLabel(FallthroughLabel);
1932 recordSled(BeginOfSled, *
MI, SledKind::FUNCTION_EXIT, 2);
1935 case TargetOpcode::PATCHABLE_FUNCTION_EXIT:
1937 case TargetOpcode::PATCHABLE_TAIL_CALL:
1941 "around this assert.");
1943 return PPCAsmPrinter::emitInstruction(
MI);
1946void PPCLinuxAsmPrinter::emitStartOfAsmFile(
Module &M) {
1949 PPCTargetStreamer *TS =
1950 static_cast<PPCTargetStreamer *
>(OutStreamer->getTargetStreamer());
1954 if (
static_cast<const PPCTargetMachine &
>(TM).isPPC64() ||
1955 !isPositionIndependent())
1961 OutStreamer->switchSection(OutContext.getELFSection(
1964 MCSymbol *TOCSym = OutContext.getOrCreateSymbol(Twine(
".LTOC"));
1965 MCSymbol *CurrentPos = OutContext.createTempSymbol();
1967 OutStreamer->emitLabel(CurrentPos);
1971 const MCExpr *tocExpr =
1976 OutStreamer->emitAssignment(TOCSym, tocExpr);
1978 OutStreamer->switchSection(getObjFileLowering().getTextSection());
1981void PPCLinuxAsmPrinter::emitFunctionEntryLabel() {
1983 if (!Subtarget->isPPC64() &&
1984 (!isPositionIndependent() ||
1988 if (!Subtarget->isPPC64()) {
1989 const PPCFunctionInfo *PPCFI = MF->getInfo<PPCFunctionInfo>();
1990 if (PPCFI->
usesPICBase() && !Subtarget->isSecurePlt()) {
1992 MCSymbol *PICBase = MF->getPICBaseSymbol();
1993 OutStreamer->emitLabel(RelocSymbol);
1995 const MCExpr *OffsExpr =
2001 OutStreamer->emitValue(OffsExpr, 4);
2002 OutStreamer->emitLabel(CurrentFnSym);
2015 && !MF->getRegInfo().use_empty(PPC::X2)) {
2016 const PPCFunctionInfo *PPCFI = MF->getInfo<PPCFunctionInfo>();
2018 MCSymbol *TOCSymbol = OutContext.getOrCreateSymbol(StringRef(
".TOC."));
2020 const MCExpr *TOCDeltaExpr =
2027 OutStreamer->emitValue(TOCDeltaExpr, 8);
2034 MCSectionELF *
Section = OutStreamer->getContext().getELFSection(
2036 OutStreamer->switchSection(Section);
2037 OutStreamer->emitLabel(CurrentFnSym);
2038 OutStreamer->emitValueToAlignment(
Align(8));
2039 MCSymbol *Symbol1 = CurrentFnSymForSize;
2044 MCSymbol *Symbol2 = OutContext.getOrCreateSymbol(StringRef(
".TOC."));
2046 OutStreamer->emitValue(
2049 OutStreamer->emitIntValue(0, 8 );
2050 OutStreamer->switchSection(Current.first, Current.second);
2053void PPCLinuxAsmPrinter::emitEndOfAsmFile(
Module &M) {
2054 const DataLayout &
DL = getDataLayout();
2056 bool isPPC64 =
DL.getPointerSizeInBits() == 64;
2058 PPCTargetStreamer *TS =
2059 static_cast<PPCTargetStreamer *
>(OutStreamer->getTargetStreamer());
2065 if (
static_cast<const PPCTargetMachine &
>(TM).hasGlibcHWCAPAccess())
2066 OutStreamer->emitSymbolValue(
2067 GetExternalSymbolSymbol(
"__parse_hwcap_and_convert_at_platform"),
2068 MAI.getCodePointerSize());
2069 emitGNUAttributes(M);
2072 const char *
Name = isPPC64 ?
".toc" :
".got2";
2073 MCSectionELF *
Section = OutContext.getELFSection(
2075 OutStreamer->switchSection(Section);
2077 OutStreamer->emitValueToAlignment(
Align(4));
2079 for (
const auto &TOCMapPair : TOC) {
2080 const MCSymbol *
const TOCEntryTarget = TOCMapPair.first.first;
2081 MCSymbol *
const TOCEntryLabel = TOCMapPair.second;
2083 OutStreamer->emitLabel(TOCEntryLabel);
2085 TS->
emitTCEntry(*TOCEntryTarget, TOCMapPair.first.second);
2087 OutStreamer->emitSymbolValue(TOCEntryTarget, 4);
2091 PPCAsmPrinter::emitEndOfAsmFile(M);
2095void PPCLinuxAsmPrinter::emitFunctionBodyStart() {
2127 const PPCFunctionInfo *PPCFI = MF->getInfo<PPCFunctionInfo>();
2128 const bool UsesX2OrR2 = !MF->getRegInfo().use_empty(PPC::X2) ||
2129 !MF->getRegInfo().use_empty(PPC::R2);
2138 if (NonPCrelGEPRequired || PCrelGEPRequired) {
2143 OutStreamer->emitLabel(GlobalEntryLabel);
2144 const MCSymbolRefExpr *GlobalEntryLabelExp =
2148 MCSymbol *TOCSymbol = OutContext.getOrCreateSymbol(StringRef(
".TOC."));
2149 const MCExpr *TOCDeltaExpr =
2151 GlobalEntryLabelExp, OutContext);
2153 const MCExpr *TOCDeltaHi =
2155 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::ADDIS)
2158 .addExpr(TOCDeltaHi));
2160 const MCExpr *TOCDeltaLo =
2162 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::ADDI)
2165 .addExpr(TOCDeltaLo));
2168 const MCExpr *TOCOffsetDeltaExpr =
2170 GlobalEntryLabelExp, OutContext);
2172 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::LD)
2174 .addExpr(TOCOffsetDeltaExpr)
2176 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::ADD8)
2183 OutStreamer->emitLabel(LocalEntryLabel);
2184 const MCSymbolRefExpr *LocalEntryLabelExp =
2186 const MCExpr *LocalOffsetExp =
2188 GlobalEntryLabelExp, OutContext);
2190 PPCTargetStreamer *TS =
2191 static_cast<PPCTargetStreamer *
>(OutStreamer->getTargetStreamer());
2216 if (MF->getFrameInfo().hasCalls() || MF->getFrameInfo().hasTailCall() ||
2217 MF->hasInlineAsm() || (!PPCFI->
usesTOCBasePtr() && UsesX2OrR2)) {
2218 PPCTargetStreamer *TS =
2219 static_cast<PPCTargetStreamer *
>(OutStreamer->getTargetStreamer());
2229void PPCLinuxAsmPrinter::emitFunctionBodyEnd() {
2237 if (Subtarget->isPPC64()) {
2238 OutStreamer->emitIntValue(0, 4);
2239 OutStreamer->emitIntValue(0, 8);
2243char PPCLinuxAsmPrinter::ID = 0;
2246 "Linux PPC Assembly Printer",
false,
false)
2251 switch (GV->getLinkage()) {
2252 case GlobalValue::ExternalLinkage:
2253 LinkageAttr = GV->isDeclaration() ? MCSA_Extern : MCSA_Global;
2255 case GlobalValue::LinkOnceAnyLinkage:
2256 case GlobalValue::LinkOnceODRLinkage:
2257 case GlobalValue::WeakAnyLinkage:
2258 case GlobalValue::WeakODRLinkage:
2259 case GlobalValue::ExternalWeakLinkage:
2260 LinkageAttr = MCSA_Weak;
2262 case GlobalValue::AvailableExternallyLinkage:
2263 LinkageAttr = MCSA_Extern;
2265 case GlobalValue::PrivateLinkage:
2267 case GlobalValue::InternalLinkage:
2268 assert(GV->getVisibility() == GlobalValue::DefaultVisibility &&
2269 "InternalLinkage should not have other visibility setting.");
2270 LinkageAttr = MCSA_LGlobal;
2272 case GlobalValue::AppendingLinkage:
2273 llvm_unreachable(
"Should never emit this");
2274 case GlobalValue::CommonLinkage:
2275 llvm_unreachable(
"CommonLinkage of XCOFF should not come to this path");
2281 if (!TM.getIgnoreXCOFFVisibility()) {
2282 if (GV->hasDLLExportStorageClass() && !GV->hasDefaultVisibility())
2284 "Cannot not be both dllexport and non-default visibility");
2285 switch (GV->getVisibility()) {
2288 case GlobalValue::DefaultVisibility:
2289 if (GV->hasDLLExportStorageClass())
2290 VisibilityAttr = MAI.getExportedVisibilityAttr();
2292 case GlobalValue::HiddenVisibility:
2293 VisibilityAttr = MAI.getHiddenVisibilityAttr();
2295 case GlobalValue::ProtectedVisibility:
2296 VisibilityAttr = MAI.getProtectedVisibilityAttr();
2306 OutStreamer->emitXCOFFSymbolLinkageWithVisibility(GVSym, LinkageAttr,
2312 auto *FnDescSec =
static_cast<MCSectionXCOFF *
>(
2313 getObjFileLowering().getSectionForFunctionDescriptor(&MF.
getFunction(),
2315 FnDescSec->setAlignment(
Align(Subtarget->isPPC64() ? 8 : 4));
2317 CurrentFnDescSym = FnDescSec->getQualNameSymbol();
2322uint16_t PPCAIXAsmPrinter::getNumberOfVRSaved() {
2326 const PPCSubtarget &Subtarget = MF->
getSubtarget<PPCSubtarget>();
2327 if (Subtarget.
isAIXABI() && Subtarget.hasAltivec() &&
2330 for (
unsigned Reg = PPC::V20;
Reg <= PPC::V31; ++
Reg)
2333 return PPC::V31 -
Reg + 1;
2338void PPCAIXAsmPrinter::emitFunctionBodyEnd() {
2340 if (!TM.getXCOFFTracebackTable())
2343 emitTracebackTable();
2351 (getNumberOfVRSaved() > 0)) {
2353 OutStreamer->switchSection(getObjFileLowering().getCompactUnwindSection());
2356 OutStreamer->emitLabel(EHInfoLabel);
2359 OutStreamer->emitInt32(0);
2361 const DataLayout &
DL = MMI->getModule()->getDataLayout();
2364 OutStreamer->emitValueToAlignment(
Align(PointerSize));
2366 OutStreamer->emitIntValue(0, PointerSize);
2367 OutStreamer->emitIntValue(0, PointerSize);
2368 OutStreamer->switchSection(MF->
getSection());
2372void PPCAIXAsmPrinter::emitTracebackTable() {
2376 OutStreamer->emitLabel(FuncEnd);
2378 OutStreamer->AddComment(
"Traceback table begin");
2380 OutStreamer->emitIntValueInHexWithPadding(0, 4 );
2382 SmallString<128> CommentString;
2383 raw_svector_ostream CommentOS(CommentString);
2385 auto EmitComment = [&]() {
2386 OutStreamer->AddComment(CommentOS.str());
2387 CommentString.
clear();
2392 OutStreamer->emitIntValueInHexWithPadding(
Value,
Size);
2396 CommentOS <<
"Version = " <<
Version;
2397 EmitCommentAndValue(
Version, 1);
2407 CommentOS <<
"Language = "
2409 EmitCommentAndValue(LanguageIdentifier, 1);
2412 uint32_t FirstHalfOfMandatoryField = 0;
2419 const PPCFunctionInfo *FI = MF->
getInfo<PPCFunctionInfo>();
2423 for (
unsigned Reg = PPC::F0;
Reg <= PPC::F31; ++
Reg) {
2430#define GENBOOLCOMMENT(Prefix, V, Field) \
2431 CommentOS << (Prefix) << ((V) & (TracebackTable::Field##Mask) ? "+" : "-") \
2434#define GENVALUECOMMENT(PrefixAndName, V, Field) \
2435 CommentOS << (PrefixAndName) << " = " \
2436 << static_cast<unsigned>(((V) & (TracebackTable::Field##Mask)) >> \
2437 (TracebackTable::Field##Shift))
2440 GENBOOLCOMMENT(
", ", FirstHalfOfMandatoryField, IsOutOfLineEpilogOrPrologue);
2443 GENBOOLCOMMENT(
"", FirstHalfOfMandatoryField, HasTraceBackTableOffset);
2444 GENBOOLCOMMENT(
", ", FirstHalfOfMandatoryField, IsInternalProcedure);
2447 GENBOOLCOMMENT(
"", FirstHalfOfMandatoryField, HasControlledStorage);
2451 GENBOOLCOMMENT(
"", FirstHalfOfMandatoryField, IsFloatingPointPresent);
2454 IsFloatingPointOperationLogOrAbortEnabled);
2457 OutStreamer->emitIntValueInHexWithPadding(
2458 (FirstHalfOfMandatoryField & 0x0000ff00) >> 8, 1);
2465 if (FrameReg == (Subtarget->isPPC64() ? PPC::X31 : PPC::R31))
2468 const SmallVectorImpl<Register> &MustSaveCRs = FI->
getMustSaveCRs();
2469 if (!MustSaveCRs.
empty())
2475 GENBOOLCOMMENT(
"", FirstHalfOfMandatoryField, IsInterruptHandler);
2476 GENBOOLCOMMENT(
", ", FirstHalfOfMandatoryField, IsFunctionNamePresent);
2480 OnConditionDirective);
2484 OutStreamer->emitIntValueInHexWithPadding((FirstHalfOfMandatoryField & 0xff),
2488 uint32_t SecondHalfOfMandatoryField = 0;
2494 uint32_t FPRSaved = 0;
2495 for (
unsigned Reg = PPC::F14;
Reg <= PPC::F31; ++
Reg) {
2497 FPRSaved = PPC::F31 -
Reg + 1;
2503 GENBOOLCOMMENT(
"", SecondHalfOfMandatoryField, IsBackChainStored);
2505 GENVALUECOMMENT(
", NumOfFPRsSaved", SecondHalfOfMandatoryField, FPRSaved);
2507 OutStreamer->emitIntValueInHexWithPadding(
2508 (SecondHalfOfMandatoryField & 0xff000000) >> 24, 1);
2514 bool HasVectorInst =
false;
2515 for (
unsigned Reg = PPC::V0;
Reg <= PPC::V31; ++
Reg)
2518 HasVectorInst =
true;
2525 uint16_t NumOfVRSaved = getNumberOfVRSaved();
2526 bool ShouldEmitEHBlock =
2529 if (ShouldEmitEHBlock)
2532 uint32_t GPRSaved = 0;
2535 unsigned GPRBegin = Subtarget->isPPC64() ? PPC::X14 : PPC::R13;
2536 unsigned GPREnd = Subtarget->isPPC64() ? PPC::X31 : PPC::R31;
2538 for (
unsigned Reg = GPRBegin;
Reg <= GPREnd; ++
Reg) {
2540 GPRSaved = GPREnd -
Reg + 1;
2548 GENBOOLCOMMENT(
"", SecondHalfOfMandatoryField, HasExtensionTable);
2550 GENVALUECOMMENT(
", NumOfGPRsSaved", SecondHalfOfMandatoryField, GPRSaved);
2552 OutStreamer->emitIntValueInHexWithPadding(
2553 (SecondHalfOfMandatoryField & 0x00ff0000) >> 16, 1);
2557 SecondHalfOfMandatoryField |=
2561 NumberOfFixedParms);
2563 OutStreamer->emitIntValueInHexWithPadding(
2564 (SecondHalfOfMandatoryField & 0x0000ff00) >> 8, 1);
2572 SecondHalfOfMandatoryField |=
2577 NumberOfFloatingPointParms);
2578 GENBOOLCOMMENT(
", ", SecondHalfOfMandatoryField, HasParmsOnStack);
2580 OutStreamer->emitIntValueInHexWithPadding(SecondHalfOfMandatoryField & 0xff,
2586 if (NumberOfFixedParms || NumberOfFPParms) {
2589 Expected<SmallString<32>> ParmsType =
2592 ParmsTypeValue, NumberOfFixedParms, NumberOfFPParms,
2599 CommentOS <<
"Parameter type = " << ParmsType.
get();
2602 OutStreamer->emitIntValueInHexWithPadding(ParmsTypeValue,
2603 sizeof(ParmsTypeValue));
2606 OutStreamer->AddComment(
"Function size");
2608 MCSymbol *FuncSectSym = getObjFileLowering().getFunctionEntryPointSymbol(
2610 OutStreamer->emitAbsoluteSymbolDiff(FuncEnd, FuncSectSym, 4);
2622 int16_t NameLength =
Name.size();
2623 CommentOS <<
"Function name len = "
2624 <<
static_cast<unsigned int>(NameLength);
2625 EmitCommentAndValue(NameLength, 2);
2626 OutStreamer->AddComment(
"Function Name");
2627 OutStreamer->emitBytes(Name);
2632 OutStreamer->AddComment(
"AllocaUsed");
2633 OutStreamer->emitIntValueInHex(AllocReg,
sizeof(AllocReg));
2637 uint16_t VRData = 0;
2666 OutStreamer->emitIntValueInHexWithPadding((VRData & 0xff00) >> 8, 1);
2671 OutStreamer->emitIntValueInHexWithPadding(VRData & 0x00ff, 1);
2675 Expected<SmallString<32>> VecParmsType =
2679 CommentOS <<
"Vector Parameter type = " << VecParmsType.
get();
2682 OutStreamer->emitIntValueInHexWithPadding(VecParmTypeValue,
2683 sizeof(VecParmTypeValue));
2685 CommentOS <<
"Padding";
2686 EmitCommentAndValue(0, 2);
2689 uint8_t ExtensionTableFlag = 0;
2691 if (ShouldEmitEHBlock)
2692 ExtensionTableFlag |= ExtendedTBTableFlag::TB_EH_INFO;
2695 ExtensionTableFlag |= ExtendedTBTableFlag::TB_SSP_CANARY;
2697 CommentOS <<
"ExtensionTableFlag = "
2699 EmitCommentAndValue(ExtensionTableFlag,
sizeof(ExtensionTableFlag));
2702 if (ExtensionTableFlag & ExtendedTBTableFlag::TB_EH_INFO) {
2703 auto &Ctx = OutStreamer->getContext();
2706 MCSymbol *TOCEntry = lookUpOrCreateTOCEntry(EHInfoSym, TOCType_EHBlock);
2707 const MCSymbol *TOCBaseSym =
static_cast<const MCSectionXCOFF *
>(
2708 getObjFileLowering().getTOCBaseSection())
2709 ->getQualNameSymbol();
2714 const DataLayout &
DL = getDataLayout();
2715 OutStreamer->emitValueToAlignment(
Align(4));
2716 OutStreamer->AddComment(
"EHInfo Table");
2717 OutStreamer->emitValue(Exp,
DL.getPointerSize());
2719#undef GENBOOLCOMMENT
2720#undef GENVALUECOMMENT
2729 .
Case(
"llvm.used",
true)
2731 .
Case(
"llvm.compiler.used",
true)
2737 .
Cases({
"llvm.global_ctors",
"llvm.global_dtors"},
true)
2741uint64_t PPCAIXAsmPrinter::getAliasOffset(
const Constant *
C) {
2743 return getAliasOffset(GA->getAliasee());
2754 return RHS->getValue();
2764 "GlobalVariables with an alignment requirement stricter than TOC entry "
2765 "size not supported by the toc data transformation.");
2768 assert(GVType->
isSized() &&
"A GlobalVariable's size must be known to be "
2769 "supported by the toc data transformation.");
2773 "A GlobalVariable with size larger than a TOC entry is not currently "
2774 "supported by the toc data transformation.");
2777 "currently supported by the toc data transformation.");
2780void PPCAIXAsmPrinter::emitGlobalVariable(
const GlobalVariable *GV) {
2798 emitGlobalVariableHelper(GV);
2801void PPCAIXAsmPrinter::emitGlobalVariableHelper(
const GlobalVariable *GV) {
2803 "Unhandled intrinsic global variable.");
2808 auto *GVSym =
static_cast<MCSymbolXCOFF *
>(getSymbol(GV));
2811 emitLinkage(GV, GVSym);
2815 SectionKind GVKind = getObjFileLowering().getKindForGlobal(GV, TM);
2819 "not supported yet.");
2826 OutStreamer->getCommentOS() <<
'\n';
2830 auto *Csect =
static_cast<MCSectionXCOFF *
>(
2831 getObjFileLowering().SectionForGlobal(GV, GVKind, TM));
2834 OutStreamer->switchSection(Csect);
2836 if (GV->
hasMetadata(LLVMContext::MD_implicit_ref)) {
2837 emitRefMetadata(GV);
2847 GVSym->setStorageClass(
2851 OutStreamer->emitZeros(
Size);
2854 "BSS local toc-data already handled and TLS variables "
2855 "incompatible with XMC_TD");
2856 OutStreamer->emitXCOFFLocalCommonSymbol(
2857 OutContext.getOrCreateSymbol(GVSym->getSymbolTableName()),
Size,
2860 OutStreamer->emitCommonSymbol(GVSym,
Size, Alignment);
2868 emitLinkage(GV, EmittedInitSym);
2869 for (
const GlobalAlias *GA : GOAliasMap[GV])
2870 emitLinkage(GA, getSymbol(GA));
2872 emitAlignment(getGVAlignment(GV,
DL), GV);
2876 if (!TM.getDataSections() || GV->hasSection()) {
2878 OutStreamer->emitLabel(EmittedInitSym);
2882 if (!GOAliasMap[GV].
size()) {
2883 emitGlobalConstant(GV->getDataLayout(), GV->getInitializer());
2889 AliasMapTy AliasList;
2890 for (
const GlobalAlias *GA : GOAliasMap[GV])
2891 AliasList[getAliasOffset(GA->getAliasee())].push_back(GA);
2894 emitGlobalConstant(GV->getDataLayout(), GV->getInitializer(),
2898void PPCAIXAsmPrinter::emitFunctionDescriptor() {
2899 const DataLayout &
DL = getDataLayout();
2900 const unsigned PointerSize =
DL.getPointerSizeInBits() == 64 ? 8 : 4;
2904 OutStreamer->switchSection(
2905 static_cast<MCSymbolXCOFF *
>(CurrentFnDescSym)->getRepresentedCsect());
2910 for (
const GlobalAlias *Alias : GOAliasMap[&MF->
getFunction()])
2911 OutStreamer->emitLabel(getSymbol(Alias));
2917 const MCSymbol *TOCBaseSym =
static_cast<const MCSectionXCOFF *
>(
2918 getObjFileLowering().getTOCBaseSection())
2919 ->getQualNameSymbol();
2923 OutStreamer->emitIntValue(0, PointerSize);
2925 OutStreamer->switchSection(Current.first, Current.second);
2928void PPCAIXAsmPrinter::emitFunctionEntryLabel() {
2932 PPCAsmPrinter::emitFunctionEntryLabel();
2940 for (
const GlobalAlias *Alias : GOAliasMap[
F])
2941 OutStreamer->emitLabel(
2942 getObjFileLowering().getFunctionEntryPointSymbol(Alias, TM));
2944 if (
F->hasMetadata(LLVMContext::MD_implicit_ref)) {
2949void PPCAIXAsmPrinter::emitPGORefs(
Module &M) {
2950 if (!OutContext.hasXCOFFSection(
2961 bool HasNonZeroLengthPrfCntsSection =
false;
2962 const DataLayout &
DL =
M.getDataLayout();
2963 for (GlobalVariable &GV :
M.globals())
2964 if (GV.hasSection() && GV.getSection() ==
"__llvm_prf_cnts" &&
2965 GV.getGlobalSize(
DL) > 0) {
2966 HasNonZeroLengthPrfCntsSection =
true;
2970 if (HasNonZeroLengthPrfCntsSection) {
2971 MCSection *CntsSection = OutContext.getXCOFFSection(
2976 OutStreamer->switchSection(CntsSection);
2977 if (OutContext.hasXCOFFSection(
2980 MCSymbol *S = OutContext.getOrCreateSymbol(
"__llvm_prf_data[RW]");
2981 OutStreamer->emitXCOFFRefDirective(S);
2983 if (OutContext.hasXCOFFSection(
2986 MCSymbol *S = OutContext.getOrCreateSymbol(
"__llvm_prf_names[RO]");
2987 OutStreamer->emitXCOFFRefDirective(S);
2989 if (OutContext.hasXCOFFSection(
2992 MCSymbol *S = OutContext.getOrCreateSymbol(
"__llvm_prf_vnds[RW]");
2993 OutStreamer->emitXCOFFRefDirective(S);
2998void PPCAIXAsmPrinter::emitGCOVRefs() {
2999 if (!OutContext.hasXCOFFSection(
3000 "__llvm_gcov_ctr_section",
3004 MCSection *CtrSection = OutContext.getXCOFFSection(
3009 OutStreamer->switchSection(CtrSection);
3012 if (OutContext.hasXCOFFSection(
3015 const char *SymbolStr = TM.Options.XCOFFReadOnlyPointers
3016 ?
"__llvm_covinit[RO]"
3017 :
"__llvm_covinit[RW]";
3018 MCSymbol *S = OutContext.getOrCreateSymbol(SymbolStr);
3019 OutStreamer->emitXCOFFRefDirective(S);
3023void PPCAIXAsmPrinter::emitEndOfAsmFile(
Module &M) {
3026 if (
M.empty() && TOCDataGlobalVars.
empty())
3033 OutStreamer->switchSection(getObjFileLowering().getTOCBaseSection());
3035 PPCTargetStreamer *TS =
3036 static_cast<PPCTargetStreamer *
>(OutStreamer->getTargetStreamer());
3038 for (
auto &
I : TOC) {
3039 MCSectionXCOFF *TCEntry;
3046 (Subtarget->hasAIXShLibTLSModelOpt() &&
3048 SmallString<128>
Name;
3051 Name +=
static_cast<const MCSymbolXCOFF *
>(
I.first.first)
3052 ->getSymbolTableName();
3053 MCSymbol *S = OutContext.getOrCreateSymbol(Name);
3054 TCEntry =
static_cast<MCSectionXCOFF *
>(
3055 getObjFileLowering().getSectionForTOCEntry(S, TM));
3057 TCEntry =
static_cast<MCSectionXCOFF *
>(
3058 getObjFileLowering().getSectionForTOCEntry(
I.first.first, TM));
3060 OutStreamer->switchSection(TCEntry);
3062 OutStreamer->emitLabel(
I.second);
3069 for (
const auto *GV : TOCDataGlobalVars) {
3070 if (!GV->hasCommonLinkage())
3071 emitGlobalVariableHelper(GV);
3073 for (
const auto *GV : TOCDataGlobalVars) {
3074 if (GV->hasCommonLinkage())
3075 emitGlobalVariableHelper(GV);
3079bool PPCAIXAsmPrinter::doInitialization(
Module &M) {
3080 const bool Result = PPCAsmPrinter::doInitialization(M);
3083 const Triple &
Target =
M.getTargetTriple();
3090 if (FunCpuId > TargetCpuId)
3091 TargetCpuId = FunCpuId;
3097 StringRef TargetCPU = TM.getTargetCPU();
3102 PPCTargetStreamer *TS =
3103 static_cast<PPCTargetStreamer *
>(OutStreamer->getTargetStreamer());
3106 auto setCsectAlignment = [
this](
const GlobalObject *GO) {
3108 if (GO->isDeclarationForLinker())
3111 SectionKind GOKind = getObjFileLowering().getKindForGlobal(GO, TM);
3112 auto *Csect =
static_cast<MCSectionXCOFF *
>(
3113 getObjFileLowering().SectionForGlobal(GO, GOKind, TM));
3115 Align GOAlign = getGVAlignment(GO, GO->getDataLayout());
3116 Csect->ensureMinAlignment(GOAlign);
3123 auto DL =
M.getDataLayout();
3124 for (
const auto &
G :
M.globals()) {
3125 if (
G.isThreadLocal() && !
G.isDeclaration()) {
3126 TLSVarAddress =
alignTo(TLSVarAddress, getGVAlignment(&
G,
DL));
3127 TLSVarsToAddressMapping[&
G] = TLSVarAddress;
3128 TLSVarAddress +=
G.getGlobalSize(
DL);
3135 for (
const auto &
G :
M.globals()) {
3142 if (FormatIndicatorAndUniqueModId.empty()) {
3144 if (UniqueModuleId !=
"")
3148 FormatIndicatorAndUniqueModId =
"clang_" + UniqueModuleId.substr(1);
3153 std::chrono::duration_cast<std::chrono::nanoseconds>(
3154 std::chrono::steady_clock::now().time_since_epoch())
3156 FormatIndicatorAndUniqueModId =
3163 emitSpecialLLVMGlobal(&
G);
3167 setCsectAlignment(&
G);
3168 std::optional<CodeModel::Model> OptionalCodeModel =
G.getCodeModel();
3169 if (OptionalCodeModel)
3171 *OptionalCodeModel);
3174 for (
const auto &
F : M)
3175 setCsectAlignment(&
F);
3178 for (
const auto &Alias :
M.aliases()) {
3179 const GlobalObject *Aliasee = Alias.getAliaseeObject();
3182 "alias without a base object is not yet supported on AIX");
3186 "\n\tAlias attribute for " +
3187 Alias.getName() +
" is invalid because " +
3188 Aliasee->
getName() +
" is common.",
3192 const GlobalVariable *GVar =
3195 std::optional<CodeModel::Model> OptionalCodeModel = GVar->
getCodeModel();
3196 if (OptionalCodeModel)
3198 *OptionalCodeModel);
3201 GOAliasMap[Aliasee].push_back(&Alias);
3207void PPCAIXAsmPrinter::emitInstruction(
const MachineInstr *
MI) {
3208 switch (
MI->getOpcode()) {
3215 if (
MI->getNumOperands() < 5)
3217 const MachineOperand &LangMO =
MI->getOperand(3);
3218 const MachineOperand &ReasonMO =
MI->getOperand(4);
3221 MCSymbol *TempSym = OutContext.createNamedTempSymbol();
3222 OutStreamer->emitLabel(TempSym);
3223 OutStreamer->emitXCOFFExceptDirective(
3224 CurrentFnSym, TempSym, LangMO.
getImm(), ReasonMO.
getImm(),
3225 Subtarget->isPPC64() ?
MI->getMF()->getInstructionCount() * 8
3226 :
MI->getMF()->getInstructionCount() * 4,
3230 case PPC::GETtlsMOD32AIX:
3231 case PPC::GETtlsMOD64AIX:
3232 case PPC::GETtlsTpointer32AIX:
3233 case PPC::GETtlsADDR64AIX:
3234 case PPC::GETtlsADDR32AIX: {
3239 ExtSymSDNodeSymbols.
insert(TlsGetAddr);
3246 case PPC::BL_LWZinto_toc:
3247 case PPC::BL_LWZinto_toc_RM:
3248 case PPC::BL8_LDinto_toc:
3249 case PPC::BL8_LDinto_toc_RM: {
3250 const MachineOperand &MO =
MI->getOperand(0);
3252 auto *S =
static_cast<MCSymbolXCOFF *
>(
3254 ExtSymSDNodeSymbols.
insert(S);
3260 case PPC::BL8_NOP_TLS:
3267 case PPC::TAILBCTR8:
3268 if (
MI->getOperand(0).isSymbol())
3281 MCInstBuilder(PPC::ORI).addReg(PPC::R0).addReg(PPC::R0).addImm(0));
3284 return PPCAsmPrinter::emitInstruction(
MI);
3287bool PPCAIXAsmPrinter::doFinalization(
Module &M) {
3288 for (MCSymbol *Sym : ExtSymSDNodeSymbols)
3289 OutStreamer->emitSymbolAttribute(Sym,
MCSA_Extern);
3290 return PPCAsmPrinter::doFinalization(M);
3301 return 20 + (
P - 20) * 16;
3304 return 1004 + (
P - 81);
3307 return 2047 + (
P - 1124) * 33878;
3309 return 2147482625u + (
P - 64512);
3328 std::string PrioritySuffix;
3331 return PrioritySuffix;
3334void PPCAIXAsmPrinter::emitXXStructorList(
const DataLayout &
DL,
3335 const Constant *
List,
bool IsCtor) {
3337 preprocessXXStructorList(
DL,
List, Structors);
3338 if (Structors.
empty())
3342 for (Structor &S : Structors) {
3344 S.Func =
CE->getOperand(0);
3348 (IsCtor ? llvm::Twine(
"__sinit") : llvm::Twine(
"__sterm")) +
3350 llvm::Twine(
"_", FormatIndicatorAndUniqueModId) +
3356void PPCAIXAsmPrinter::emitTTypeReference(
const GlobalValue *GV,
3357 unsigned Encoding) {
3359 TOCEntryType GlobalType = TOCType_GlobalInternal;
3364 GlobalType = TOCType_GlobalExternal;
3365 MCSymbol *TypeInfoSym = TM.getSymbol(GV);
3366 MCSymbol *TOCEntry = lookUpOrCreateTOCEntry(TypeInfoSym, GlobalType);
3367 const MCSymbol *TOCBaseSym =
static_cast<const MCSectionXCOFF *
>(
3368 getObjFileLowering().getTOCBaseSection())
3369 ->getQualNameSymbol();
3370 auto &Ctx = OutStreamer->getContext();
3374 OutStreamer->emitValue(Exp, GetSizeOfEncodedValue(Encoding));
3376 OutStreamer->emitIntValue(0, GetSizeOfEncodedValue(Encoding));
3379void PPCAIXAsmPrinter::emitRefMetadata(
const GlobalObject *GO) {
3381 GO->
getMetadata(LLVMContext::MD_implicit_ref, MDs);
3382 assert(MDs.
size() &&
"Expected !implicit.ref metadata nodes");
3384 for (
const MDNode *MD : MDs) {
3389 ? getObjFileLowering().getFunctionEntryPointSymbol(GV, TM)
3391 OutStreamer->emitXCOFFRefDirective(Referenced);
3399 std::unique_ptr<MCStreamer> &&
Streamer) {
3401 return new PPCAIXAsmPrinter(tm, std::move(
Streamer));
3403 return new PPCLinuxAsmPrinter(tm, std::move(
Streamer));
3406void PPCAIXAsmPrinter::emitModuleCommandLines(
Module &M) {
3407 const NamedMDNode *NMD =
M.getNamedMetadata(
"llvm.commandline");
3412 raw_string_ostream RSOS(S);
3415 assert(
N->getNumOperands() == 1 &&
3416 "llvm.commandline metadata entry can have only one operand");
3420 RSOS <<
"@(#)opt " << MDS->
getString() <<
"\n";
3423 OutStreamer->emitXCOFFCInfoSym(
".GCC.command.line", RSOS.str());
3427 enum class IsLocal {
3439 if (
LHS == IsLocal::False ||
RHS == IsLocal::False)
3440 return IsLocal::False;
3441 if (
LHS == IsLocal::True &&
RHS == IsLocal::True)
3442 return IsLocal::True;
3443 return IsLocal::Unknown;
3447 auto IsLocalFunc = [](
const Function *
F) -> IsLocal {
3448 bool Result =
F->isDSOLocal();
3450 << (Result ?
"dso_local\n" :
"not dso_local\n"));
3451 return Result ? IsLocal::True : IsLocal::False;
3460 std::function<IsLocal(
const Value *)> ValueIsALocalFunc =
3461 [&IsLocalFunc, &
Combine, &ValueIsALocalFunc](
const Value *V) -> IsLocal {
3463 return IsLocalFunc(
F);
3465 return IsLocal::Unknown;
3470 return Combine(ValueIsALocalFunc(
SI->getTrueValue()),
3471 ValueIsALocalFunc(
SI->getFalseValue()));
3473 IsLocal Res = IsLocal::True;
3474 for (
unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) {
3475 Res =
Combine(Res, ValueIsALocalFunc(PN->getIncomingValue(i)));
3476 if (Res == IsLocal::False)
3491 return IsLocal::Unknown;
3494 return IsLocal::Unknown;
3496 IsLocal Res = IsLocal::True;
3497 for (
unsigned Idx = 0,
End =
Init->getNumOperands(); Idx !=
End; ++Idx) {
3498 Res =
Combine(Res, ValueIsALocalFunc(
Init->getOperand(Idx)));
3499 if (Res == IsLocal::False)
3504 return IsLocal::Unknown;
3514 IsLocal Res = IsLocal::True;
3519 Value *RV = Ret->getReturnValue();
3521 Res =
Combine(Res, ValueIsALocalFunc(RV));
3522 if (Res == IsLocal::False)
3551void PPCAIXAsmPrinter::emitGlobalIFunc(
Module &M,
const GlobalIFunc &GI) {
3553 const TargetSubtargetInfo *STI =
3555 bool IsPPC64 =
static_cast<const PPCSubtarget *
>(STI)->isPPC64();
3560 MCSectionXCOFF *FnDescSec =
static_cast<MCSectionXCOFF *
>(
3561 getObjFileLowering().getSectionForFunctionDescriptor(&GI, TM));
3566 CurrentFnSym = getObjFileLowering().getFunctionEntryPointSymbol(&GI, TM);
3569 if (TM.getFunctionSections())
3570 OutStreamer->switchSection(
3571 static_cast<MCSymbolXCOFF *
>(CurrentFnSym)->getRepresentedCsect());
3573 OutStreamer->switchSection(getObjFileLowering().getTextSection());
3576 emitRefMetadata(&GI);
3579 emitLinkage(&GI, CurrentFnDescSym);
3580 emitLinkage(&GI, CurrentFnSym);
3584 emitAlignment(Alignment,
nullptr);
3587 emitFunctionDescriptor();
3589 emitFunctionEntryLabel();
3593 SmallString<128>
Msg;
3594 Msg.append(
"unimplemented: TOC register save/restore needed for ifunc \"");
3595 getNameWithPrefix(
Msg, &GI);
3596 Msg.append(
"\", because couldn't prove all candidates are static or "
3597 "hidden/protected visibility definitions");
3605 auto *FnDescTOCEntrySym =
3606 lookUpOrCreateTOCEntry(CurrentFnDescSym, FnDescTOCEntryType);
3611 auto *Exp_U = symbolWithSpecifier(FnDescTOCEntrySym,
PPC::S_U);
3612 OutStreamer->emitInstruction(MCInstBuilder(PPC::ADDIS)
3617 auto *Exp_L = symbolWithSpecifier(FnDescTOCEntrySym,
PPC::S_L);
3618 OutStreamer->emitInstruction(MCInstBuilder(IsPPC64 ? PPC::LD : PPC::LWZ)
3628 OutStreamer->emitInstruction(MCInstBuilder(IsPPC64 ? PPC::LD : PPC::LWZ)
3635 OutStreamer->emitInstruction(MCInstBuilder(IsPPC64 ? PPC::LD : PPC::LWZ)
3637 .addImm(IsPPC64 ? 16 : 8)
3641 OutStreamer->emitInstruction(MCInstBuilder(IsPPC64 ? PPC::LD : PPC::LWZ)
3647 OutStreamer->emitInstruction(
3648 MCInstBuilder(IsPPC64 ? PPC::MTCTR8 : PPC::MTCTR).addReg(PPC::X12),
3651 OutStreamer->emitInstruction(MCInstBuilder(IsPPC64 ? PPC::BCTR8 : PPC::BCTR),
3655char PPCAIXAsmPrinter::ID = 0;
3658 "AIX PPC Assembly Printer",
false,
false)
3662LLVMInitializePowerPCAsmPrinter() {
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 isSpecialLLVMGlobalArrayToSkip(const GlobalVariable *GV)
static cl::opt< bool > IFuncLocalIfProven("ppc-ifunc-local-if-proven", cl::init(false), cl::desc("During ifunc lowering, the compiler assumes the resolver returns " "dso-local functions and bails out if non-local functions are " "detected; this flag flips the assumption: resolver returns " "preemptible functions unless the compiler can prove all paths " "return local functions."), cl::Hidden)
#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 bool TOCRestoreNeededForCallToImplementation(const GlobalIFunc &GI)
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 cl::opt< bool > IFuncWarnInsteadOfError("ppc-test-ifunc-warn-noerror", cl::init(false), cl::ReallyHidden)
static cl::opt< bool > EnableSSPCanaryBitInTB("ppc-aix-ssp-tb-bit", cl::init(false), cl::desc("Enable Passing SSP Canary info in Trackback on AIX"), cl::Hidden)
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
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
uint64_t getTOCSaveOffset() const
getTOCSaveOffset - Return the previous frame offset to save the TOC register – 64-bit SVR4 ABI only.
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
bool is32BitELFABI() const
const PPCFrameLowering * getFrameLowering() const override
bool isUsingPCRelativeCalls() const
bool isAIXExtendedAltivecABI() const
Returns true when the AIX extended Altivec ABI ("vec-extabi") is in effect, allowing use of the nonvo...
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.
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.
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.
initializer< Ty > init(const Ty &Val)
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