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.");
106 "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>;
141 Tag_GNU_Power_ABI_FP = 4,
142 Tag_GNU_Power_ABI_Vector = 8,
143 Tag_GNU_Power_ABI_Struct_Return = 12,
146 Val_GNU_Power_ABI_NoFloat = 0b00,
147 Val_GNU_Power_ABI_HardFloat_DP = 0b01,
148 Val_GNU_Power_ABI_SoftFloat_DP = 0b10,
149 Val_GNU_Power_ABI_HardFloat_SP = 0b11,
151 Val_GNU_Power_ABI_LDBL_IBM128 = 0b0100,
152 Val_GNU_Power_ABI_LDBL_64 = 0b1000,
153 Val_GNU_Power_ABI_LDBL_IEEE128 = 0b1100,
165 MapVector<std::pair<const MCSymbol *, PPCMCExpr::Specifier>,
MCSymbol *> TOC;
166 const PPCSubtarget *Subtarget =
nullptr;
171 MapVector<const GlobalValue *, uint64_t> TLSVarsToAddressMapping;
174 explicit PPCAsmPrinter(TargetMachine &TM,
175 std::unique_ptr<MCStreamer> Streamer,
char &
ID)
176 : AsmPrinter(TM, std::
move(Streamer),
ID) {}
178 StringRef getPassName()
const override {
return "PowerPC Assembly Printer"; }
181 TOCType_ConstantPool,
182 TOCType_GlobalExternal,
183 TOCType_GlobalInternal,
186 TOCType_BlockAddress,
190 MCSymbol *lookUpOrCreateTOCEntry(
const MCSymbol *Sym, TOCEntryType
Type,
193 bool doInitialization(
Module &M)
override {
199 const MCExpr *symbolWithSpecifier(
const MCSymbol *S,
206 void printOperand(
const MachineInstr *
MI,
unsigned OpNo, raw_ostream &O);
208 void PrintSymbolOperand(
const MachineOperand &MO, raw_ostream &O)
override;
209 bool PrintAsmOperand(
const MachineInstr *
MI,
unsigned OpNo,
210 const char *ExtraCode, raw_ostream &O)
override;
211 bool PrintAsmMemoryOperand(
const MachineInstr *
MI,
unsigned OpNo,
212 const char *ExtraCode, raw_ostream &O)
override;
214 void LowerSTACKMAP(StackMaps &
SM,
const MachineInstr &
MI);
215 void LowerPATCHPOINT(StackMaps &
SM,
const MachineInstr &
MI);
217 void EmitAIXTlsCallHelper(
const MachineInstr *
MI);
218 const MCExpr *getAdjustedFasterLocalExpr(
const MachineOperand &MO,
220 bool runOnMachineFunction(MachineFunction &MF)
override {
229class PPCLinuxAsmPrinter :
public PPCAsmPrinter {
233 explicit PPCLinuxAsmPrinter(TargetMachine &TM,
234 std::unique_ptr<MCStreamer> Streamer)
235 : PPCAsmPrinter(TM, std::
move(Streamer), ID) {}
237 StringRef getPassName()
const override {
238 return "Linux PPC Assembly Printer";
241 void emitGNUAttributes(
Module &M);
243 void emitStartOfAsmFile(
Module &M)
override;
244 void emitEndOfAsmFile(
Module &)
override;
246 void emitFunctionEntryLabel()
override;
248 void emitFunctionBodyStart()
override;
249 void emitFunctionBodyEnd()
override;
253class PPCAIXAsmPrinter :
public PPCAsmPrinter {
257 SmallSetVector<MCSymbol *, 8> ExtSymSDNodeSymbols;
261 std::string FormatIndicatorAndUniqueModId;
265 DenseMap<const GlobalObject *, SmallVector<const GlobalAlias *, 1>>
268 uint16_t getNumberOfVRSaved();
269 void emitTracebackTable();
273 void emitGlobalVariableHelper(
const GlobalVariable *);
276 uint64_t getAliasOffset(
const Constant *
C);
281 PPCAIXAsmPrinter(TargetMachine &TM, std::unique_ptr<MCStreamer> Streamer)
282 : PPCAsmPrinter(TM, std::
move(Streamer), ID) {
283 if (MAI.isLittleEndian())
285 "cannot create AIX PPC Assembly Printer for a little-endian target");
288 StringRef getPassName()
const override {
return "AIX PPC Assembly Printer"; }
290 bool doInitialization(
Module &M)
override;
292 void emitXXStructorList(
const DataLayout &
DL,
const Constant *
List,
293 bool IsCtor)
override;
295 void SetupMachineFunction(MachineFunction &MF)
override;
297 void emitGlobalVariable(
const GlobalVariable *GV)
override;
299 void emitFunctionDescriptor()
override;
301 void emitFunctionEntryLabel()
override;
303 void emitFunctionBodyEnd()
override;
305 void emitPGORefs(
Module &M);
309 void emitEndOfAsmFile(
Module &)
override;
311 void emitLinkage(
const GlobalValue *GV, MCSymbol *GVSym)
const override;
315 bool doFinalization(
Module &M)
override;
317 void emitTTypeReference(
const GlobalValue *GV,
unsigned Encoding)
override;
319 void emitModuleCommandLines(
Module &M)
override;
321 void emitRefMetadata(
const GlobalObject *);
323 void emitGlobalIFunc(
Module &M,
const GlobalIFunc &GI)
override;
332 getSymbol(GV)->
print(O, MAI);
336void PPCAsmPrinter::printOperand(
const MachineInstr *
MI,
unsigned OpNo,
338 const DataLayout &
DL = getDataLayout();
339 const MachineOperand &MO =
MI->getOperand(OpNo);
359 O <<
DL.getInternalSymbolPrefix() <<
"CPI" << getFunctionNumber() <<
'_'
366 PrintSymbolOperand(MO, O);
371 O <<
"<unknown operand type: " << (unsigned)MO.
getType() <<
">";
378bool PPCAsmPrinter::PrintAsmOperand(
const MachineInstr *
MI,
unsigned OpNo,
379 const char *ExtraCode, raw_ostream &O) {
381 if (ExtraCode && ExtraCode[0]) {
382 if (ExtraCode[1] != 0)
return true;
384 switch (ExtraCode[0]) {
390 if (!
MI->getOperand(OpNo).isReg() ||
391 OpNo+1 ==
MI->getNumOperands() ||
392 !
MI->getOperand(OpNo+1).isReg())
399 if (
MI->getOperand(OpNo).isImm())
403 if(!
MI->getOperand(OpNo).isReg())
409 Reg = PPC::VSX32 + (
Reg - PPC::V0);
411 Reg = PPC::VSX32 + (
Reg - PPC::VF0);
427bool PPCAsmPrinter::PrintAsmMemoryOperand(
const MachineInstr *
MI,
unsigned OpNo,
428 const char *ExtraCode,
430 if (ExtraCode && ExtraCode[0]) {
431 if (ExtraCode[1] != 0)
return true;
433 switch (ExtraCode[0]) {
434 default:
return true;
436 O << getDataLayout().getPointerSize() <<
"(";
447 if (
MI->getOperand(OpNo).isImm())
458 assert(
MI->getOperand(OpNo).isReg());
463 assert(
MI->getOperand(OpNo).isReg());
473 case PPCAsmPrinter::TOCType_ConstantPool:
476 case PPCAsmPrinter::TOCType_GlobalInternal:
477 ++NumTOCGlobalInternal;
479 case PPCAsmPrinter::TOCType_GlobalExternal:
480 ++NumTOCGlobalExternal;
482 case PPCAsmPrinter::TOCType_JumpTable:
485 case PPCAsmPrinter::TOCType_ThreadLocal:
488 case PPCAsmPrinter::TOCType_BlockAddress:
489 ++NumTOCBlockAddress;
491 case PPCAsmPrinter::TOCType_EHBlock:
508 assert(GV &&
"expected global for MO_GlobalAddress");
529MCSymbol *PPCAsmPrinter::lookUpOrCreateTOCEntry(
const MCSymbol *Sym,
533 auto [It,
Inserted] =
TOC.try_emplace({Sym, Spec});
539 TOCEntry = createTempSymbol(
"C");
543void PPCAsmPrinter::LowerSTACKMAP(StackMaps &
SM,
const MachineInstr &
MI) {
544 unsigned NumNOPBytes =
MI.getOperand(1).getImm();
546 auto &Ctx = OutStreamer->getContext();
547 MCSymbol *MILabel = Ctx.createTempSymbol();
548 OutStreamer->emitLabel(MILabel);
550 SM.recordStackMap(*MILabel,
MI);
551 assert(NumNOPBytes % 4 == 0 &&
"Invalid number of NOP bytes requested!");
554 const MachineBasicBlock &
MBB = *
MI.getParent();
557 while (NumNOPBytes > 0) {
558 if (MII ==
MBB.
end() || MII->isCall() ||
559 MII->getOpcode() == PPC::DBG_VALUE ||
560 MII->getOpcode() == TargetOpcode::PATCHPOINT ||
561 MII->getOpcode() == TargetOpcode::STACKMAP)
568 for (
unsigned i = 0; i < NumNOPBytes; i += 4)
569 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::NOP));
574void PPCAsmPrinter::LowerPATCHPOINT(StackMaps &
SM,
const MachineInstr &
MI) {
575 auto &Ctx = OutStreamer->getContext();
576 MCSymbol *MILabel = Ctx.createTempSymbol();
577 OutStreamer->emitLabel(MILabel);
579 SM.recordPatchPoint(*MILabel,
MI);
580 PatchPointOpers Opers(&
MI);
582 unsigned EncodedBytes = 0;
583 const MachineOperand &CalleeMO = Opers.getCallTarget();
585 if (CalleeMO.
isImm()) {
586 int64_t CallTarget = CalleeMO.
getImm();
588 assert((CallTarget & 0xFFFFFFFFFFFF) == CallTarget &&
589 "High 16 bits of call target should be zero.");
590 Register ScratchReg =
MI.getOperand(Opers.getNextScratchIdx()).getReg();
593 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::LI8)
595 .addImm((CallTarget >> 32) & 0xFFFF));
598 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::RLDIC)
601 .addImm(32).addImm(16));
604 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::ORIS8)
607 .addImm((CallTarget >> 16) & 0xFFFF));
610 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::ORI8)
613 .addImm(CallTarget & 0xFFFF));
618 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::STD)
620 .addImm(TOCSaveOffset)
630 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::LD)
633 .addReg(ScratchReg));
636 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::LD)
639 .addReg(ScratchReg));
643 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::MTCTR8)
644 .addReg(ScratchReg));
647 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::BCTRL8));
651 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::LD)
653 .addImm(TOCSaveOffset)
658 const GlobalValue *GValue = CalleeMO.
getGlobal();
659 MCSymbol *MOSymbol = getSymbol(GValue);
662 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::BL8_NOP)
671 unsigned NumBytes = Opers.getNumPatchBytes();
672 if (NumBytes < EncodedBytes)
674 "Patchpoint can't request size less than the length of a call.");
676 assert((NumBytes - EncodedBytes) % 4 == 0 &&
677 "Invalid number of NOP bytes requested!");
678 for (
unsigned i = EncodedBytes; i < NumBytes; i += 4)
679 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::NOP));
689 SymName =
".__tls_get_addr";
691 case PPC::GETtlsTpointer32AIX:
692 SymName =
".__get_tpointer";
694 case PPC::GETtlsMOD32AIX:
695 case PPC::GETtlsMOD64AIX:
696 SymName =
".__tls_get_mod";
702 ->getQualNameSymbol();
705void PPCAsmPrinter::EmitAIXTlsCallHelper(
const MachineInstr *
MI) {
707 "Only expecting to emit calls to get the thread pointer on AIX!");
711 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::BLA).addExpr(TlsRef));
716void PPCAsmPrinter::emitTlsCall(
const MachineInstr *
MI,
719 unsigned Opcode = PPC::BL8_NOP_TLS;
721 assert(
MI->getNumOperands() >= 3 &&
"Expecting at least 3 operands from MI");
725 Opcode = PPC::BL8_NOTOC_TLS;
727 const Module *
M = MF->getFunction().getParent();
730 ((Subtarget->isPPC64() &&
MI->getOperand(0).getReg() == PPC::X3) ||
731 (!Subtarget->isPPC64() &&
MI->getOperand(0).getReg() == PPC::R3)) &&
732 "GETtls[ld]ADDR[32] must define GPR3");
734 ((Subtarget->isPPC64() &&
MI->getOperand(1).getReg() == PPC::X3) ||
735 (!Subtarget->isPPC64() &&
MI->getOperand(1).getReg() == PPC::R3)) &&
736 "GETtls[ld]ADDR[32] must read GPR3");
743 Register VarOffsetReg = Subtarget->isPPC64() ? PPC::X4 : PPC::R4;
745 assert((
MI->getOpcode() == PPC::GETtlsMOD32AIX ||
746 MI->getOpcode() == PPC::GETtlsMOD64AIX ||
747 (
MI->getOperand(2).isReg() &&
748 MI->getOperand(2).getReg() == VarOffsetReg)) &&
749 "GETtls[ld]ADDR[32] must read GPR4");
750 EmitAIXTlsCallHelper(
MI);
754 MCSymbol *TlsGetAddr = OutContext.getOrCreateSymbol(
"__tls_get_addr");
762 if (Kind ==
PPC::S_PLT && Subtarget->isSecurePlt() &&
766 const MachineOperand &MO =
MI->getOperand(2);
767 const GlobalValue *GValue = MO.
getGlobal();
768 MCSymbol *MOSymbol = getSymbol(GValue);
770 EmitToStreamer(*OutStreamer,
771 MCInstBuilder(Subtarget->isPPC64() ? Opcode
772 : (
unsigned)PPC::BL_TLS)
795static PPCAsmPrinter::TOCEntryType
800 return PPCAsmPrinter::TOCType_GlobalExternal;
802 return PPCAsmPrinter::TOCType_GlobalInternal;
805static PPCAsmPrinter::TOCEntryType
810 return PPCAsmPrinter::TOCType_ThreadLocal;
818 return PPCAsmPrinter::TOCType_ConstantPool;
820 return PPCAsmPrinter::TOCType_JumpTable;
822 return PPCAsmPrinter::TOCType_BlockAddress;
828const MCExpr *PPCAsmPrinter::symbolWithSpecifier(
const MCSymbol *S,
836void PPCAsmPrinter::emitInstruction(
const MachineInstr *
MI) {
837 PPC_MC::verifyInstructionPredicates(
MI->getOpcode(),
838 getSubtargetInfo().getFeatureBits());
841 const bool IsPPC64 = Subtarget->isPPC64();
842 const bool IsAIX = Subtarget->
isAIXABI();
843 const bool HasAIXSmallLocalTLS = Subtarget->hasAIXSmallLocalExecTLS() ||
844 Subtarget->hasAIXSmallLocalDynamicTLS();
845 const Module *
M = MF->getFunction().getParent();
850 if (!
MI->isInlineAsm()) {
851 for (
const MachineOperand &MO:
MI->operands()) {
854 if (Subtarget->hasSPE()) {
872 auto getTOCRelocAdjustedExprForXCOFF = [
this](
const MCExpr *Expr,
873 ptrdiff_t OriginalOffset) {
880 ptrdiff_t Adjustment =
886 auto getTOCEntryLoadingExprForXCOFF =
887 [IsPPC64, getTOCRelocAdjustedExprForXCOFF,
888 this](
const MCSymbol *MOSymbol,
const MCExpr *Expr,
890 const unsigned EntryByteSize = IsPPC64 ? 8 : 4;
891 const auto TOCEntryIter =
TOC.find({MOSymbol, VK});
893 "Could not find the TOC entry for this symbol.");
894 const ptrdiff_t EntryDistanceFromTOCBase =
895 (TOCEntryIter -
TOC.begin()) * EntryByteSize;
896 constexpr int16_t PositiveTOCRange = INT16_MAX;
898 if (EntryDistanceFromTOCBase > PositiveTOCRange)
899 return getTOCRelocAdjustedExprForXCOFF(Expr, EntryDistanceFromTOCBase);
911 assert(MO.
isGlobal() &&
"Only expecting a global MachineOperand here!\n");
919 PPCFunctionInfo *FuncInfo = MF->getInfo<PPCFunctionInfo>();
923 dbgs() <<
"Current function uses IE access for default LD vars.\n");
946 switch (
MI->getOpcode()) {
948 case TargetOpcode::PATCHABLE_FUNCTION_ENTER: {
950 "AIX does not support patchable function entry!");
952 unsigned Num =
F.getFnAttributeAsParsedInteger(
"patchable-function-entry");
958 case TargetOpcode::DBG_VALUE:
960 case TargetOpcode::STACKMAP:
961 return LowerSTACKMAP(
SM, *
MI);
962 case TargetOpcode::PATCHPOINT:
963 return LowerPATCHPOINT(
SM, *
MI);
965 case PPC::MoveGOTtoLR: {
973 OutContext.getOrCreateSymbol(StringRef(
"_GLOBAL_OFFSET_TABLE_"));
979 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::BL).addExpr(OffsExpr));
982 case PPC::MovePCtoLR:
983 case PPC::MovePCtoLR8: {
988 MCSymbol *PICBase = MF->getPICBaseSymbol();
991 EmitToStreamer(*OutStreamer,
992 MCInstBuilder(PPC::BCLalways)
998 OutStreamer->emitLabel(PICBase);
1001 case PPC::UpdateGBR: {
1010 if (Subtarget->isSecurePlt() && isPositionIndependent() ) {
1012 MCSymbol *BaseSymbol = OutContext.getOrCreateSymbol(
1021 const MCExpr *DeltaHi =
1025 MCInstBuilder(PPC::ADDIS).addReg(PICR).addReg(PICR).addExpr(DeltaHi));
1027 const MCExpr *DeltaLo =
1031 MCInstBuilder(PPC::ADDI).addReg(PICR).addReg(PICR).addExpr(DeltaLo));
1035 MF->getInfo<PPCFunctionInfo>()->getPICOffsetSymbol(*MF);
1042 const MCOperand PICR = TmpInst.
getOperand(0);
1049 EmitToStreamer(*OutStreamer, TmpInst);
1055 EmitToStreamer(*OutStreamer, TmpInst);
1066 const MachineOperand &MO =
MI->getOperand(1);
1068 "Invalid operand for LWZtoc.");
1076 const MCExpr *
Exp = symbolWithSpecifier(MOSymbol,
PPC::S_GOT);
1078 EmitToStreamer(*OutStreamer, TmpInst);
1097 "This pseudo should only be selected for 32-bit small code model.");
1098 Exp = getTOCEntryLoadingExprForXCOFF(MOSymbol, Exp, VK);
1103 OutStreamer->getCommentOS() << MO <<
'\n';
1104 EmitToStreamer(*OutStreamer, TmpInst);
1111 OutContext.getOrCreateSymbol(Twine(
".LTOC")), OutContext);
1114 EmitToStreamer(*OutStreamer, TmpInst);
1118 case PPC::ADDItoc8: {
1120 "PseudoOp only valid for small code model AIX");
1126 TmpInst.
setOpcode((!IsPPC64) ? (PPC::LA) : (PPC::LA8));
1128 const MachineOperand &MO =
MI->getOperand(2);
1137 EmitToStreamer(*OutStreamer, TmpInst);
1150 const MachineOperand &MO =
MI->getOperand(1);
1152 "Invalid operand!");
1166 const MCExpr *
Exp = symbolWithSpecifier(TOCEntry, VKExpr);
1168 IsAIX ? getTOCEntryLoadingExprForXCOFF(MOSymbol, Exp, VK) : Exp);
1171 if (isVerbose() && IsAIX)
1172 OutStreamer->getCommentOS() << MO <<
'\n';
1173 EmitToStreamer(*OutStreamer, TmpInst);
1176 case PPC::ADDIStocHA: {
1177 const MachineOperand &MO =
MI->getOperand(2);
1180 "Invalid operand for ADDIStocHA.");
1181 assert((IsAIX && !IsPPC64 &&
1183 "This pseudo should only be selected for 32-bit large code model on"
1203 if ( {
1215 const MCExpr *
Exp = symbolWithSpecifier(MOSymbol,
PPC::S_U);
1217 EmitToStreamer(*OutStreamer, TmpInst);
1220 case PPC::LWZtocL: {
1221 const MachineOperand &MO =
MI->getOperand(1);
1224 "Invalid operand for LWZtocL.");
1225 assert(IsAIX && !IsPPC64 &&
1227 "This pseudo should only be selected for 32-bit large code model on"
1247 const MCExpr *
Exp = symbolWithSpecifier(TOCEntry,
PPC::S_L);
1249 EmitToStreamer(*OutStreamer, TmpInst);
1252 case PPC::ADDIStocHA8: {
1262 const MachineOperand &MO =
MI->getOperand(2);
1264 "Invalid operand for ADDIStocHA8!");
1270 const bool GlobalToc =
1282 const MCExpr *
Exp = symbolWithSpecifier(MOSymbol, VK);
1291 EmitToStreamer(*OutStreamer, TmpInst);
1304 const MachineOperand &MO =
MI->getOperand(1);
1307 "Invalid operand for LDtocL!");
1311 "LDtocL used on symbol that could be accessed directly is "
1312 "invalid. Must match ADDIStocHA8."));
1323 const MCExpr *
Exp = symbolWithSpecifier(MOSymbol, VK);
1325 EmitToStreamer(*OutStreamer, TmpInst);
1329 case PPC::ADDItocL8: {
1333 unsigned Op =
MI->getOpcode();
1337 TmpInst.
setOpcode(
Op == PPC::ADDItocL8 ? (IsAIX ? PPC::LA8 : PPC::ADDI8)
1340 const MachineOperand &MO =
MI->getOperand(2);
1343 : MO.
isGlobal() &&
"Invalid operand for ADDItocL8.");
1345 "Interposable definitions must use indirect accesses.");
1354 EmitToStreamer(*OutStreamer, TmpInst);
1357 case PPC::ADDISgotTprelHA: {
1360 assert(IsPPC64 &&
"Not supported for 32-bit PowerPC");
1361 const MachineOperand &MO =
MI->getOperand(2);
1362 const GlobalValue *GValue = MO.
getGlobal();
1363 MCSymbol *MOSymbol = getSymbol(GValue);
1364 const MCExpr *SymGotTprel =
1366 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::ADDIS8)
1367 .addReg(
MI->getOperand(0).getReg())
1368 .addReg(
MI->getOperand(1).getReg())
1369 .addExpr(SymGotTprel));
1372 case PPC::LDgotTprelL:
1373 case PPC::LDgotTprelL32: {
1378 TmpInst.
setOpcode(IsPPC64 ? PPC::LD : PPC::LWZ);
1379 const MachineOperand &MO =
MI->getOperand(1);
1380 const GlobalValue *GValue = MO.
getGlobal();
1381 MCSymbol *MOSymbol = getSymbol(GValue);
1382 const MCExpr *
Exp = symbolWithSpecifier(
1385 EmitToStreamer(*OutStreamer, TmpInst);
1389 case PPC::PPC32PICGOT: {
1390 MCSymbol *GOTSymbol = OutContext.getOrCreateSymbol(StringRef(
"_GLOBAL_OFFSET_TABLE_"));
1391 MCSymbol *GOTRef = OutContext.createTempSymbol();
1392 MCSymbol *NextInstr = OutContext.createTempSymbol();
1394 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::BL)
1398 const MCExpr *OffsExpr =
1402 OutStreamer->emitLabel(GOTRef);
1403 OutStreamer->emitValue(OffsExpr, 4);
1404 OutStreamer->emitLabel(NextInstr);
1405 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::MFLR)
1406 .addReg(
MI->getOperand(0).getReg()));
1407 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::LWZ)
1408 .addReg(
MI->getOperand(1).getReg())
1410 .addReg(
MI->getOperand(0).getReg()));
1411 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::ADD4)
1412 .addReg(
MI->getOperand(0).getReg())
1413 .addReg(
MI->getOperand(1).getReg())
1414 .addReg(
MI->getOperand(0).getReg()));
1417 case PPC::PPC32GOT: {
1419 OutContext.getOrCreateSymbol(StringRef(
"_GLOBAL_OFFSET_TABLE_"));
1420 const MCExpr *SymGotTlsL =
1422 const MCExpr *SymGotTlsHA =
1424 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::LI)
1425 .addReg(
MI->getOperand(0).getReg())
1426 .addExpr(SymGotTlsL));
1427 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::ADDIS)
1428 .addReg(
MI->getOperand(0).getReg())
1429 .addReg(
MI->getOperand(0).getReg())
1430 .addExpr(SymGotTlsHA));
1433 case PPC::ADDIStlsgdHA: {
1436 assert(IsPPC64 &&
"Not supported for 32-bit PowerPC");
1437 const MachineOperand &MO =
MI->getOperand(2);
1438 const GlobalValue *GValue = MO.
getGlobal();
1439 MCSymbol *MOSymbol = getSymbol(GValue);
1440 const MCExpr *SymGotTlsGD =
1442 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::ADDIS8)
1443 .addReg(
MI->getOperand(0).getReg())
1444 .addReg(
MI->getOperand(1).getReg())
1445 .addExpr(SymGotTlsGD));
1448 case PPC::ADDItlsgdL:
1451 case PPC::ADDItlsgdL32: {
1454 const MachineOperand &MO =
MI->getOperand(2);
1455 const GlobalValue *GValue = MO.
getGlobal();
1456 MCSymbol *MOSymbol = getSymbol(GValue);
1457 const MCExpr *SymGotTlsGD = symbolWithSpecifier(
1459 EmitToStreamer(*OutStreamer,
1460 MCInstBuilder(IsPPC64 ? PPC::ADDI8 : PPC::ADDI)
1461 .addReg(
MI->getOperand(0).getReg())
1462 .addReg(
MI->getOperand(1).getReg())
1463 .addExpr(SymGotTlsGD));
1466 case PPC::GETtlsMOD32AIX:
1467 case PPC::GETtlsMOD64AIX:
1471 case PPC::GETtlsADDR:
1474 case PPC::GETtlsADDRPCREL:
1475 case PPC::GETtlsADDR32AIX:
1476 case PPC::GETtlsADDR64AIX:
1480 case PPC::GETtlsADDR32: {
1486 case PPC::GETtlsTpointer32AIX: {
1489 EmitAIXTlsCallHelper(
MI);
1492 case PPC::ADDIStlsldHA: {
1495 assert(IsPPC64 &&
"Not supported for 32-bit PowerPC");
1496 const MachineOperand &MO =
MI->getOperand(2);
1497 const GlobalValue *GValue = MO.
getGlobal();
1498 MCSymbol *MOSymbol = getSymbol(GValue);
1499 const MCExpr *SymGotTlsLD =
1501 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::ADDIS8)
1502 .addReg(
MI->getOperand(0).getReg())
1503 .addReg(
MI->getOperand(1).getReg())
1504 .addExpr(SymGotTlsLD));
1507 case PPC::ADDItlsldL:
1510 case PPC::ADDItlsldL32: {
1513 const MachineOperand &MO =
MI->getOperand(2);
1514 const GlobalValue *GValue = MO.
getGlobal();
1515 MCSymbol *MOSymbol = getSymbol(GValue);
1516 const MCExpr *SymGotTlsLD = symbolWithSpecifier(
1518 EmitToStreamer(*OutStreamer,
1519 MCInstBuilder(IsPPC64 ? PPC::ADDI8 : PPC::ADDI)
1520 .addReg(
MI->getOperand(0).getReg())
1521 .addReg(
MI->getOperand(1).getReg())
1522 .addExpr(SymGotTlsLD));
1525 case PPC::GETtlsldADDR:
1528 case PPC::GETtlsldADDRPCREL:
1529 case PPC::GETtlsldADDR32: {
1535 case PPC::ADDISdtprelHA:
1538 case PPC::ADDISdtprelHA32: {
1541 const MachineOperand &MO =
MI->getOperand(2);
1542 const GlobalValue *GValue = MO.
getGlobal();
1543 MCSymbol *MOSymbol = getSymbol(GValue);
1547 MCInstBuilder(IsPPC64 ? PPC::ADDIS8 : PPC::ADDIS)
1548 .addReg(
MI->getOperand(0).getReg())
1549 .addReg(
MI->getOperand(1).getReg())
1550 .addExpr(SymDtprel));
1553 case PPC::PADDIdtprel: {
1556 const MachineOperand &MO =
MI->getOperand(2);
1557 const GlobalValue *GValue = MO.
getGlobal();
1558 MCSymbol *MOSymbol = getSymbol(GValue);
1559 const MCExpr *SymDtprel = symbolWithSpecifier(MOSymbol,
PPC::S_DTPREL);
1560 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::PADDI8)
1561 .addReg(
MI->getOperand(0).getReg())
1562 .addReg(
MI->getOperand(1).getReg())
1563 .addExpr(SymDtprel));
1567 case PPC::ADDIdtprelL:
1570 case PPC::ADDIdtprelL32: {
1573 const MachineOperand &MO =
MI->getOperand(2);
1574 const GlobalValue *GValue = MO.
getGlobal();
1575 MCSymbol *MOSymbol = getSymbol(GValue);
1577 EmitToStreamer(*OutStreamer,
1578 MCInstBuilder(IsPPC64 ? PPC::ADDI8 : PPC::ADDI)
1579 .addReg(
MI->getOperand(0).getReg())
1580 .addReg(
MI->getOperand(1).getReg())
1581 .addExpr(SymDtprel));
1586 if (!Subtarget->hasMFOCRF()) {
1589 unsigned NewOpcode =
1590 MI->getOpcode() == PPC::MFOCRF ? PPC::MFCR : PPC::MFCR8;
1591 OutStreamer->AddComment(PPCInstPrinter::
1593 EmitToStreamer(*OutStreamer, MCInstBuilder(NewOpcode)
1594 .addReg(
MI->getOperand(0).getReg()));
1600 if (!Subtarget->hasMFOCRF()) {
1603 unsigned NewOpcode =
1604 MI->getOpcode() == PPC::MTOCRF ? PPC::MTCRF : PPC::MTCRF8;
1605 unsigned Mask = 0x80 >> OutContext.getRegisterInfo()
1606 ->getEncodingValue(
MI->getOperand(0).getReg());
1607 OutStreamer->AddComment(PPCInstPrinter::
1609 EmitToStreamer(*OutStreamer, MCInstBuilder(NewOpcode)
1611 .addReg(
MI->getOperand(1).getReg()));
1621 unsigned OpNum = (
MI->getOpcode() == PPC::STD) ? 2 : 1;
1625 for (
const MachineOperand &TempMO :
MI->operands()) {
1628 TempMO.getOperandNo() == 1)
1631 const MachineOperand &MO =
MI->getOperand(OpNum);
1665 if (!HasAIXSmallLocalTLS)
1667 bool IsMIADDI8 =
MI->getOpcode() == PPC::ADDI8;
1668 unsigned OpNum = IsMIADDI8 ? 2 : 1;
1669 const MachineOperand &MO =
MI->getOperand(OpNum);
1676 const MCExpr *Expr = getAdjustedFasterLocalExpr(MO, MO.
getOffset());
1684 EmitToStreamer(*OutStreamer, TmpInst);
1690 case PPC::PseudoEIEIO: {
1693 MCInstBuilder(PPC::ORI).addReg(PPC::X2).addReg(PPC::X2).addImm(0));
1696 MCInstBuilder(PPC::ORI).addReg(PPC::X2).addReg(PPC::X2).addImm(0));
1697 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::EnforceIEIO));
1703 EmitToStreamer(*OutStreamer, TmpInst);
1713PPCAsmPrinter::getAdjustedFasterLocalExpr(
const MachineOperand &MO,
1720 assert(MO.
isGlobal() &&
"Only expecting a global MachineOperand here!");
1721 const GlobalValue *GValue = MO.
getGlobal();
1724 "Only local-[exec|dynamic] accesses are handled!");
1730 const auto TLSVarsMapEntryIter = TLSVarsToAddressMapping.
find(GValue);
1731 if (TLSVarsMapEntryIter == TLSVarsToAddressMapping.
end())
1732 assert(IsGlobalADeclaration &&
1733 "Only expecting to find extern TLS variables not present in the TLS "
1734 "variable-to-address map!");
1736 unsigned TLSVarAddress =
1737 IsGlobalADeclaration ? 0 : TLSVarsMapEntryIter->second;
1738 ptrdiff_t FinalAddress = (TLSVarAddress +
Offset);
1750 if (FinalAddress >= 32768) {
1757 ptrdiff_t Delta = ((FinalAddress + 32768) & ~0xFFFF);
1759 [[maybe_unused]] ptrdiff_t InstDisp = TLSVarAddress +
Offset - Delta;
1761 ((InstDisp < 32768) && (InstDisp >= -32768)) &&
1762 "Expecting the instruction displacement for local-[exec|dynamic] TLS "
1763 "variables to be between [-32768, 32768)!");
1771void PPCLinuxAsmPrinter::emitGNUAttributes(
Module &M) {
1773 Metadata *MD =
M.getModuleFlag(
"float-abi");
1779 if (flt ==
"doubledouble")
1780 OutStreamer->emitGNUAttribute(Tag_GNU_Power_ABI_FP,
1781 Val_GNU_Power_ABI_HardFloat_DP |
1782 Val_GNU_Power_ABI_LDBL_IBM128);
1783 else if (flt ==
"ieeequad")
1784 OutStreamer->emitGNUAttribute(Tag_GNU_Power_ABI_FP,
1785 Val_GNU_Power_ABI_HardFloat_DP |
1786 Val_GNU_Power_ABI_LDBL_IEEE128);
1787 else if (flt ==
"ieeedouble")
1788 OutStreamer->emitGNUAttribute(Tag_GNU_Power_ABI_FP,
1789 Val_GNU_Power_ABI_HardFloat_DP |
1790 Val_GNU_Power_ABI_LDBL_64);
1793void PPCLinuxAsmPrinter::emitInstruction(
const MachineInstr *
MI) {
1794 if (!Subtarget->isPPC64())
1795 return PPCAsmPrinter::emitInstruction(
MI);
1797 switch (
MI->getOpcode()) {
1800 case TargetOpcode::PATCHABLE_FUNCTION_ENTER: {
1814 unsigned Num =
F.getFnAttributeAsParsedInteger(
"patchable-function-entry");
1816 if (!MAI.isLittleEndian() || Num)
1818 MCSymbol *BeginOfSled = OutContext.createTempSymbol();
1819 MCSymbol *EndOfSled = OutContext.createTempSymbol();
1820 OutStreamer->emitLabel(BeginOfSled);
1821 EmitToStreamer(*OutStreamer,
1822 MCInstBuilder(PPC::B).addExpr(
1824 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::NOP));
1827 MCInstBuilder(PPC::STD).addReg(PPC::X0).addImm(-8).addReg(PPC::X1));
1828 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::MFLR8).addReg(PPC::X0));
1829 EmitToStreamer(*OutStreamer,
1830 MCInstBuilder(PPC::BL8_NOP)
1832 OutContext.getOrCreateSymbol(
"__xray_FunctionEntry"),
1834 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::MTLR8).addReg(PPC::X0));
1835 OutStreamer->emitLabel(EndOfSled);
1836 recordSled(BeginOfSled, *
MI, SledKind::FUNCTION_ENTER, 2);
1839 case TargetOpcode::PATCHABLE_RET: {
1840 unsigned RetOpcode =
MI->getOperand(0).getImm();
1850 if (RetOpcode == PPC::BCCLR) {
1851 IsConditional =
true;
1852 }
else if (RetOpcode == PPC::TCRETURNdi8 || RetOpcode == PPC::TCRETURNri8 ||
1853 RetOpcode == PPC::TCRETURNai8) {
1855 }
else if (RetOpcode == PPC::BLR8 || RetOpcode == PPC::TAILB8) {
1856 IsConditional =
false;
1858 EmitToStreamer(*OutStreamer, RetInst);
1863 if (IsConditional) {
1882 FallthroughLabel = OutContext.createTempSymbol();
1885 MCInstBuilder(PPC::BCC)
1888 .addReg(
MI->getOperand(2).getReg())
1905 OutStreamer->emitCodeAlignment(
Align(8), &getSubtargetInfo());
1906 MCSymbol *BeginOfSled = OutContext.createTempSymbol();
1907 OutStreamer->emitLabel(BeginOfSled);
1908 EmitToStreamer(*OutStreamer, RetInst);
1909 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::NOP));
1912 MCInstBuilder(PPC::STD).addReg(PPC::X0).addImm(-8).addReg(PPC::X1));
1913 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::MFLR8).addReg(PPC::X0));
1914 EmitToStreamer(*OutStreamer,
1915 MCInstBuilder(PPC::BL8_NOP)
1917 OutContext.getOrCreateSymbol(
"__xray_FunctionExit"),
1919 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::MTLR8).addReg(PPC::X0));
1920 EmitToStreamer(*OutStreamer, RetInst);
1922 OutStreamer->emitLabel(FallthroughLabel);
1923 recordSled(BeginOfSled, *
MI, SledKind::FUNCTION_EXIT, 2);
1926 case TargetOpcode::PATCHABLE_FUNCTION_EXIT:
1928 case TargetOpcode::PATCHABLE_TAIL_CALL:
1932 "around this assert.");
1934 return PPCAsmPrinter::emitInstruction(
MI);
1937void PPCLinuxAsmPrinter::emitStartOfAsmFile(
Module &M) {
1938 if (
static_cast<const PPCTargetMachine &
>(TM).isELFv2ABI()) {
1939 PPCTargetStreamer *TS =
1940 static_cast<PPCTargetStreamer *
>(OutStreamer->getTargetStreamer());
1944 if (
static_cast<const PPCTargetMachine &
>(TM).isPPC64() ||
1945 !isPositionIndependent())
1951 OutStreamer->switchSection(OutContext.getELFSection(
1954 MCSymbol *TOCSym = OutContext.getOrCreateSymbol(Twine(
".LTOC"));
1955 MCSymbol *CurrentPos = OutContext.createTempSymbol();
1957 OutStreamer->emitLabel(CurrentPos);
1961 const MCExpr *tocExpr =
1966 OutStreamer->emitAssignment(TOCSym, tocExpr);
1968 OutStreamer->switchSection(getObjFileLowering().getTextSection());
1971void PPCLinuxAsmPrinter::emitFunctionEntryLabel() {
1973 if (!Subtarget->isPPC64() &&
1974 (!isPositionIndependent() ||
1978 if (!Subtarget->isPPC64()) {
1979 const PPCFunctionInfo *PPCFI = MF->getInfo<PPCFunctionInfo>();
1980 if (PPCFI->
usesPICBase() && !Subtarget->isSecurePlt()) {
1982 MCSymbol *PICBase = MF->getPICBaseSymbol();
1983 OutStreamer->emitLabel(RelocSymbol);
1985 const MCExpr *OffsExpr =
1991 OutStreamer->emitValue(OffsExpr, 4);
1992 OutStreamer->emitLabel(CurrentFnSym);
2005 && !MF->getRegInfo().use_empty(PPC::X2)) {
2006 const PPCFunctionInfo *PPCFI = MF->getInfo<PPCFunctionInfo>();
2008 MCSymbol *TOCSymbol = OutContext.getOrCreateSymbol(StringRef(
".TOC."));
2010 const MCExpr *TOCDeltaExpr =
2017 OutStreamer->emitValue(TOCDeltaExpr, 8);
2024 MCSectionELF *
Section = OutStreamer->getContext().getELFSection(
2026 OutStreamer->switchSection(Section);
2027 OutStreamer->emitLabel(CurrentFnSym);
2028 OutStreamer->emitValueToAlignment(
Align(8));
2029 MCSymbol *Symbol1 = CurrentFnSymForSize;
2034 MCSymbol *Symbol2 = OutContext.getOrCreateSymbol(StringRef(
".TOC."));
2036 OutStreamer->emitValue(
2039 OutStreamer->emitIntValue(0, 8 );
2040 OutStreamer->switchSection(Current.first, Current.second);
2043void PPCLinuxAsmPrinter::emitEndOfAsmFile(
Module &M) {
2044 const DataLayout &
DL = getDataLayout();
2046 bool isPPC64 =
DL.getPointerSizeInBits() == 64;
2048 PPCTargetStreamer *TS =
2049 static_cast<PPCTargetStreamer *
>(OutStreamer->getTargetStreamer());
2055 if (
static_cast<const PPCTargetMachine &
>(TM).hasGlibcHWCAPAccess())
2056 OutStreamer->emitSymbolValue(
2057 GetExternalSymbolSymbol(
"__parse_hwcap_and_convert_at_platform"),
2058 MAI.getCodePointerSize());
2059 emitGNUAttributes(M);
2062 const char *
Name = isPPC64 ?
".toc" :
".got2";
2063 MCSectionELF *
Section = OutContext.getELFSection(
2065 OutStreamer->switchSection(Section);
2067 OutStreamer->emitValueToAlignment(
Align(4));
2069 for (
const auto &TOCMapPair : TOC) {
2070 const MCSymbol *
const TOCEntryTarget = TOCMapPair.first.first;
2071 MCSymbol *
const TOCEntryLabel = TOCMapPair.second;
2073 OutStreamer->emitLabel(TOCEntryLabel);
2075 TS->
emitTCEntry(*TOCEntryTarget, TOCMapPair.first.second);
2077 OutStreamer->emitSymbolValue(TOCEntryTarget, 4);
2081 PPCAsmPrinter::emitEndOfAsmFile(M);
2085void PPCLinuxAsmPrinter::emitFunctionBodyStart() {
2117 const PPCFunctionInfo *PPCFI = MF->getInfo<PPCFunctionInfo>();
2118 const bool UsesX2OrR2 = !MF->getRegInfo().use_empty(PPC::X2) ||
2119 !MF->getRegInfo().use_empty(PPC::R2);
2128 if (NonPCrelGEPRequired || PCrelGEPRequired) {
2133 OutStreamer->emitLabel(GlobalEntryLabel);
2134 const MCSymbolRefExpr *GlobalEntryLabelExp =
2138 MCSymbol *TOCSymbol = OutContext.getOrCreateSymbol(StringRef(
".TOC."));
2139 const MCExpr *TOCDeltaExpr =
2141 GlobalEntryLabelExp, OutContext);
2143 const MCExpr *TOCDeltaHi =
2145 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::ADDIS)
2148 .addExpr(TOCDeltaHi));
2150 const MCExpr *TOCDeltaLo =
2152 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::ADDI)
2155 .addExpr(TOCDeltaLo));
2158 const MCExpr *TOCOffsetDeltaExpr =
2160 GlobalEntryLabelExp, OutContext);
2162 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::LD)
2164 .addExpr(TOCOffsetDeltaExpr)
2166 EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::ADD8)
2173 OutStreamer->emitLabel(LocalEntryLabel);
2174 const MCSymbolRefExpr *LocalEntryLabelExp =
2176 const MCExpr *LocalOffsetExp =
2178 GlobalEntryLabelExp, OutContext);
2180 PPCTargetStreamer *TS =
2181 static_cast<PPCTargetStreamer *
>(OutStreamer->getTargetStreamer());
2206 if (MF->getFrameInfo().hasCalls() || MF->getFrameInfo().hasTailCall() ||
2207 MF->hasInlineAsm() || (!PPCFI->
usesTOCBasePtr() && UsesX2OrR2)) {
2208 PPCTargetStreamer *TS =
2209 static_cast<PPCTargetStreamer *
>(OutStreamer->getTargetStreamer());
2219void PPCLinuxAsmPrinter::emitFunctionBodyEnd() {
2227 if (Subtarget->isPPC64()) {
2228 OutStreamer->emitIntValue(0, 4);
2229 OutStreamer->emitIntValue(0, 8);
2233char PPCLinuxAsmPrinter::ID = 0;
2236 "Linux PPC Assembly Printer",
false,
false)
2241 switch (GV->getLinkage()) {
2242 case GlobalValue::ExternalLinkage:
2243 LinkageAttr = GV->isDeclaration() ? MCSA_Extern : MCSA_Global;
2245 case GlobalValue::LinkOnceAnyLinkage:
2246 case GlobalValue::LinkOnceODRLinkage:
2247 case GlobalValue::WeakAnyLinkage:
2248 case GlobalValue::WeakODRLinkage:
2249 case GlobalValue::ExternalWeakLinkage:
2250 LinkageAttr = MCSA_Weak;
2252 case GlobalValue::AvailableExternallyLinkage:
2253 LinkageAttr = MCSA_Extern;
2255 case GlobalValue::PrivateLinkage:
2257 case GlobalValue::InternalLinkage:
2258 assert(GV->getVisibility() == GlobalValue::DefaultVisibility &&
2259 "InternalLinkage should not have other visibility setting.");
2260 LinkageAttr = MCSA_LGlobal;
2262 case GlobalValue::AppendingLinkage:
2263 llvm_unreachable(
"Should never emit this");
2264 case GlobalValue::CommonLinkage:
2265 llvm_unreachable(
"CommonLinkage of XCOFF should not come to this path");
2271 if (!TM.getIgnoreXCOFFVisibility()) {
2272 if (GV->hasDLLExportStorageClass() && !GV->hasDefaultVisibility())
2274 "Cannot not be both dllexport and non-default visibility");
2275 switch (GV->getVisibility()) {
2278 case GlobalValue::DefaultVisibility:
2279 if (GV->hasDLLExportStorageClass())
2280 VisibilityAttr = MAI.getExportedVisibilityAttr();
2282 case GlobalValue::HiddenVisibility:
2283 VisibilityAttr = MAI.getHiddenVisibilityAttr();
2285 case GlobalValue::ProtectedVisibility:
2286 VisibilityAttr = MAI.getProtectedVisibilityAttr();
2296 OutStreamer->emitXCOFFSymbolLinkageWithVisibility(GVSym, LinkageAttr,
2300void PPCAIXAsmPrinter::SetupMachineFunction(MachineFunction &MF) {
2302 auto *FnDescSec =
static_cast<MCSectionXCOFF *
>(
2303 getObjFileLowering().getSectionForFunctionDescriptor(&MF.
getFunction(),
2305 FnDescSec->setAlignment(
Align(Subtarget->isPPC64() ? 8 : 4));
2307 CurrentFnDescSym = FnDescSec->getQualNameSymbol();
2312uint16_t PPCAIXAsmPrinter::getNumberOfVRSaved() {
2316 const PPCSubtarget &Subtarget = MF->
getSubtarget<PPCSubtarget>();
2317 if (Subtarget.
isAIXABI() && Subtarget.hasAltivec() &&
2318 TM.getAIXExtendedAltivecABI()) {
2319 const MachineRegisterInfo &MRI = MF->
getRegInfo();
2320 for (
unsigned Reg = PPC::V20;
Reg <= PPC::V31; ++
Reg)
2323 return PPC::V31 -
Reg + 1;
2328void PPCAIXAsmPrinter::emitFunctionBodyEnd() {
2330 if (!TM.getXCOFFTracebackTable())
2333 emitTracebackTable();
2341 (getNumberOfVRSaved() > 0)) {
2343 OutStreamer->switchSection(getObjFileLowering().getCompactUnwindSection());
2346 OutStreamer->emitLabel(EHInfoLabel);
2349 OutStreamer->emitInt32(0);
2351 const DataLayout &
DL = MMI->getModule()->getDataLayout();
2354 OutStreamer->emitValueToAlignment(
Align(PointerSize));
2356 OutStreamer->emitIntValue(0, PointerSize);
2357 OutStreamer->emitIntValue(0, PointerSize);
2358 OutStreamer->switchSection(MF->
getSection());
2362void PPCAIXAsmPrinter::emitTracebackTable() {
2366 OutStreamer->emitLabel(FuncEnd);
2368 OutStreamer->AddComment(
"Traceback table begin");
2370 OutStreamer->emitIntValueInHexWithPadding(0, 4 );
2372 SmallString<128> CommentString;
2373 raw_svector_ostream CommentOS(CommentString);
2375 auto EmitComment = [&]() {
2376 OutStreamer->AddComment(CommentOS.str());
2377 CommentString.
clear();
2380 auto EmitCommentAndValue = [&](uint64_t
Value,
int Size) {
2382 OutStreamer->emitIntValueInHexWithPadding(
Value,
Size);
2386 CommentOS <<
"Version = " <<
Version;
2387 EmitCommentAndValue(
Version, 1);
2397 CommentOS <<
"Language = "
2399 EmitCommentAndValue(LanguageIdentifier, 1);
2402 uint32_t FirstHalfOfMandatoryField = 0;
2409 const PPCFunctionInfo *FI = MF->
getInfo<PPCFunctionInfo>();
2410 const MachineRegisterInfo &MRI = MF->
getRegInfo();
2413 for (
unsigned Reg = PPC::F0;
Reg <= PPC::F31; ++
Reg) {
2414 if (MRI.isPhysRegUsed(
Reg,
true)) {
2420#define GENBOOLCOMMENT(Prefix, V, Field) \
2421 CommentOS << (Prefix) << ((V) & (TracebackTable::Field##Mask) ? "+" : "-") \
2424#define GENVALUECOMMENT(PrefixAndName, V, Field) \
2425 CommentOS << (PrefixAndName) << " = " \
2426 << static_cast<unsigned>(((V) & (TracebackTable::Field##Mask)) >> \
2427 (TracebackTable::Field##Shift))
2430 GENBOOLCOMMENT(
", ", FirstHalfOfMandatoryField, IsOutOfLineEpilogOrPrologue);
2433 GENBOOLCOMMENT(
"", FirstHalfOfMandatoryField, HasTraceBackTableOffset);
2434 GENBOOLCOMMENT(
", ", FirstHalfOfMandatoryField, IsInternalProcedure);
2437 GENBOOLCOMMENT(
"", FirstHalfOfMandatoryField, HasControlledStorage);
2441 GENBOOLCOMMENT(
"", FirstHalfOfMandatoryField, IsFloatingPointPresent);
2444 IsFloatingPointOperationLogOrAbortEnabled);
2447 OutStreamer->emitIntValueInHexWithPadding(
2448 (FirstHalfOfMandatoryField & 0x0000ff00) >> 8, 1);
2455 if (FrameReg == (Subtarget->isPPC64() ? PPC::X31 : PPC::R31))
2458 const SmallVectorImpl<Register> &MustSaveCRs = FI->
getMustSaveCRs();
2459 if (!MustSaveCRs.
empty())
2465 GENBOOLCOMMENT(
"", FirstHalfOfMandatoryField, IsInterruptHandler);
2466 GENBOOLCOMMENT(
", ", FirstHalfOfMandatoryField, IsFunctionNamePresent);
2470 OnConditionDirective);
2474 OutStreamer->emitIntValueInHexWithPadding((FirstHalfOfMandatoryField & 0xff),
2478 uint32_t SecondHalfOfMandatoryField = 0;
2484 uint32_t FPRSaved = 0;
2485 for (
unsigned Reg = PPC::F14;
Reg <= PPC::F31; ++
Reg) {
2486 if (MRI.isPhysRegModified(
Reg)) {
2487 FPRSaved = PPC::F31 -
Reg + 1;
2493 GENBOOLCOMMENT(
"", SecondHalfOfMandatoryField, IsBackChainStored);
2495 GENVALUECOMMENT(
", NumOfFPRsSaved", SecondHalfOfMandatoryField, FPRSaved);
2497 OutStreamer->emitIntValueInHexWithPadding(
2498 (SecondHalfOfMandatoryField & 0xff000000) >> 24, 1);
2504 bool HasVectorInst =
false;
2505 for (
unsigned Reg = PPC::V0;
Reg <= PPC::V31; ++
Reg)
2506 if (MRI.isPhysRegUsed(
Reg,
true)) {
2508 HasVectorInst =
true;
2515 uint16_t NumOfVRSaved = getNumberOfVRSaved();
2516 bool ShouldEmitEHBlock =
2519 if (ShouldEmitEHBlock)
2522 uint32_t GPRSaved = 0;
2525 unsigned GPRBegin = Subtarget->isPPC64() ? PPC::X14 : PPC::R13;
2526 unsigned GPREnd = Subtarget->isPPC64() ? PPC::X31 : PPC::R31;
2528 for (
unsigned Reg = GPRBegin;
Reg <= GPREnd; ++
Reg) {
2529 if (MRI.isPhysRegModified(
Reg)) {
2530 GPRSaved = GPREnd -
Reg + 1;
2538 GENBOOLCOMMENT(
"", SecondHalfOfMandatoryField, HasExtensionTable);
2540 GENVALUECOMMENT(
", NumOfGPRsSaved", SecondHalfOfMandatoryField, GPRSaved);
2542 OutStreamer->emitIntValueInHexWithPadding(
2543 (SecondHalfOfMandatoryField & 0x00ff0000) >> 16, 1);
2547 SecondHalfOfMandatoryField |=
2551 NumberOfFixedParms);
2553 OutStreamer->emitIntValueInHexWithPadding(
2554 (SecondHalfOfMandatoryField & 0x0000ff00) >> 8, 1);
2562 SecondHalfOfMandatoryField |=
2567 NumberOfFloatingPointParms);
2568 GENBOOLCOMMENT(
", ", SecondHalfOfMandatoryField, HasParmsOnStack);
2570 OutStreamer->emitIntValueInHexWithPadding(SecondHalfOfMandatoryField & 0xff,
2576 if (NumberOfFixedParms || NumberOfFPParms) {
2579 Expected<SmallString<32>> ParmsType =
2582 ParmsTypeValue, NumberOfFixedParms, NumberOfFPParms,
2589 CommentOS <<
"Parameter type = " << ParmsType.
get();
2592 OutStreamer->emitIntValueInHexWithPadding(ParmsTypeValue,
2593 sizeof(ParmsTypeValue));
2596 OutStreamer->AddComment(
"Function size");
2598 MCSymbol *FuncSectSym = getObjFileLowering().getFunctionEntryPointSymbol(
2600 OutStreamer->emitAbsoluteSymbolDiff(FuncEnd, FuncSectSym, 4);
2612 int16_t NameLength =
Name.size();
2613 CommentOS <<
"Function name len = "
2614 <<
static_cast<unsigned int>(NameLength);
2615 EmitCommentAndValue(NameLength, 2);
2616 OutStreamer->AddComment(
"Function Name");
2617 OutStreamer->emitBytes(Name);
2622 OutStreamer->AddComment(
"AllocaUsed");
2623 OutStreamer->emitIntValueInHex(AllocReg,
sizeof(AllocReg));
2627 uint16_t VRData = 0;
2656 OutStreamer->emitIntValueInHexWithPadding((VRData & 0xff00) >> 8, 1);
2661 OutStreamer->emitIntValueInHexWithPadding(VRData & 0x00ff, 1);
2665 Expected<SmallString<32>> VecParmsType =
2669 CommentOS <<
"Vector Parameter type = " << VecParmsType.
get();
2672 OutStreamer->emitIntValueInHexWithPadding(VecParmTypeValue,
2673 sizeof(VecParmTypeValue));
2675 CommentOS <<
"Padding";
2676 EmitCommentAndValue(0, 2);
2679 uint8_t ExtensionTableFlag = 0;
2681 if (ShouldEmitEHBlock)
2682 ExtensionTableFlag |= ExtendedTBTableFlag::TB_EH_INFO;
2685 ExtensionTableFlag |= ExtendedTBTableFlag::TB_SSP_CANARY;
2687 CommentOS <<
"ExtensionTableFlag = "
2689 EmitCommentAndValue(ExtensionTableFlag,
sizeof(ExtensionTableFlag));
2692 if (ExtensionTableFlag & ExtendedTBTableFlag::TB_EH_INFO) {
2693 auto &Ctx = OutStreamer->getContext();
2696 MCSymbol *TOCEntry = lookUpOrCreateTOCEntry(EHInfoSym, TOCType_EHBlock);
2697 const MCSymbol *TOCBaseSym =
static_cast<const MCSectionXCOFF *
>(
2698 getObjFileLowering().getTOCBaseSection())
2699 ->getQualNameSymbol();
2704 const DataLayout &
DL = getDataLayout();
2705 OutStreamer->emitValueToAlignment(
Align(4));
2706 OutStreamer->AddComment(
"EHInfo Table");
2707 OutStreamer->emitValue(Exp,
DL.getPointerSize());
2709#undef GENBOOLCOMMENT
2710#undef GENVALUECOMMENT
2719 .
Case(
"llvm.used",
true)
2721 .
Case(
"llvm.compiler.used",
true)
2727 .
Cases({
"llvm.global_ctors",
"llvm.global_dtors"},
true)
2731uint64_t PPCAIXAsmPrinter::getAliasOffset(
const Constant *
C) {
2733 return getAliasOffset(GA->getAliasee());
2744 return RHS->getValue();
2754 "GlobalVariables with an alignment requirement stricter than TOC entry "
2755 "size not supported by the toc data transformation.");
2758 assert(GVType->
isSized() &&
"A GlobalVariable's size must be known to be "
2759 "supported by the toc data transformation.");
2763 "A GlobalVariable with size larger than a TOC entry is not currently "
2764 "supported by the toc data transformation.");
2767 "currently supported by the toc data transformation.");
2770void PPCAIXAsmPrinter::emitGlobalVariable(
const GlobalVariable *GV) {
2788 emitGlobalVariableHelper(GV);
2791void PPCAIXAsmPrinter::emitGlobalVariableHelper(
const GlobalVariable *GV) {
2793 "Unhandled intrinsic global variable.");
2798 auto *GVSym =
static_cast<MCSymbolXCOFF *
>(getSymbol(GV));
2801 emitLinkage(GV, GVSym);
2805 SectionKind GVKind = getObjFileLowering().getKindForGlobal(GV, TM);
2809 "not supported yet.");
2816 OutStreamer->getCommentOS() <<
'\n';
2820 auto *Csect =
static_cast<MCSectionXCOFF *
>(
2821 getObjFileLowering().SectionForGlobal(GV, GVKind, TM));
2824 OutStreamer->switchSection(Csect);
2826 if (GV->
hasMetadata(LLVMContext::MD_implicit_ref)) {
2827 emitRefMetadata(GV);
2837 GVSym->setStorageClass(
2841 OutStreamer->emitZeros(
Size);
2844 "BSS local toc-data already handled and TLS variables "
2845 "incompatible with XMC_TD");
2846 OutStreamer->emitXCOFFLocalCommonSymbol(
2847 OutContext.getOrCreateSymbol(GVSym->getSymbolTableName()),
Size,
2850 OutStreamer->emitCommonSymbol(GVSym,
Size, Alignment);
2858 emitLinkage(GV, EmittedInitSym);
2859 for (
const GlobalAlias *GA : GOAliasMap[GV])
2860 emitLinkage(GA, getSymbol(GA));
2862 emitAlignment(getGVAlignment(GV,
DL), GV);
2866 if (!TM.getDataSections() || GV->hasSection()) {
2868 OutStreamer->emitLabel(EmittedInitSym);
2872 if (!GOAliasMap[GV].
size()) {
2873 emitGlobalConstant(GV->getDataLayout(), GV->getInitializer());
2879 AliasMapTy AliasList;
2880 for (
const GlobalAlias *GA : GOAliasMap[GV])
2881 AliasList[getAliasOffset(GA->getAliasee())].push_back(GA);
2884 emitGlobalConstant(GV->getDataLayout(), GV->getInitializer(),
2888void PPCAIXAsmPrinter::emitFunctionDescriptor() {
2889 const DataLayout &
DL = getDataLayout();
2890 const unsigned PointerSize =
DL.getPointerSizeInBits() == 64 ? 8 : 4;
2894 OutStreamer->switchSection(
2895 static_cast<MCSymbolXCOFF *
>(CurrentFnDescSym)->getRepresentedCsect());
2900 for (
const GlobalAlias *Alias : GOAliasMap[&MF->
getFunction()])
2901 OutStreamer->emitLabel(getSymbol(Alias));
2907 const MCSymbol *TOCBaseSym =
static_cast<const MCSectionXCOFF *
>(
2908 getObjFileLowering().getTOCBaseSection())
2909 ->getQualNameSymbol();
2913 OutStreamer->emitIntValue(0, PointerSize);
2915 OutStreamer->switchSection(Current.first, Current.second);
2918void PPCAIXAsmPrinter::emitFunctionEntryLabel() {
2922 PPCAsmPrinter::emitFunctionEntryLabel();
2930 for (
const GlobalAlias *Alias : GOAliasMap[
F])
2931 OutStreamer->emitLabel(
2932 getObjFileLowering().getFunctionEntryPointSymbol(Alias, TM));
2934 if (
F->hasMetadata(LLVMContext::MD_implicit_ref)) {
2939void PPCAIXAsmPrinter::emitPGORefs(
Module &M) {
2940 if (!OutContext.hasXCOFFSection(
2951 bool HasNonZeroLengthPrfCntsSection =
false;
2952 const DataLayout &
DL =
M.getDataLayout();
2953 for (GlobalVariable &GV :
M.globals())
2954 if (GV.hasSection() && GV.getSection() ==
"__llvm_prf_cnts" &&
2955 GV.getGlobalSize(
DL) > 0) {
2956 HasNonZeroLengthPrfCntsSection =
true;
2960 if (HasNonZeroLengthPrfCntsSection) {
2961 MCSection *CntsSection = OutContext.getXCOFFSection(
2966 OutStreamer->switchSection(CntsSection);
2967 if (OutContext.hasXCOFFSection(
2970 MCSymbol *S = OutContext.getOrCreateSymbol(
"__llvm_prf_data[RW]");
2971 OutStreamer->emitXCOFFRefDirective(S);
2973 if (OutContext.hasXCOFFSection(
2976 MCSymbol *S = OutContext.getOrCreateSymbol(
"__llvm_prf_names[RO]");
2977 OutStreamer->emitXCOFFRefDirective(S);
2979 if (OutContext.hasXCOFFSection(
2982 MCSymbol *S = OutContext.getOrCreateSymbol(
"__llvm_prf_vnds[RW]");
2983 OutStreamer->emitXCOFFRefDirective(S);
2988void PPCAIXAsmPrinter::emitGCOVRefs() {
2989 if (!OutContext.hasXCOFFSection(
2990 "__llvm_gcov_ctr_section",
2994 MCSection *CtrSection = OutContext.getXCOFFSection(
2999 OutStreamer->switchSection(CtrSection);
3002 if (OutContext.hasXCOFFSection(
3005 const char *SymbolStr = TM.Options.XCOFFReadOnlyPointers
3006 ?
"__llvm_covinit[RO]"
3007 :
"__llvm_covinit[RW]";
3008 MCSymbol *S = OutContext.getOrCreateSymbol(SymbolStr);
3009 OutStreamer->emitXCOFFRefDirective(S);
3013void PPCAIXAsmPrinter::emitEndOfAsmFile(
Module &M) {
3016 if (
M.empty() && TOCDataGlobalVars.
empty())
3023 OutStreamer->switchSection(getObjFileLowering().getTOCBaseSection());
3025 PPCTargetStreamer *TS =
3026 static_cast<PPCTargetStreamer *
>(OutStreamer->getTargetStreamer());
3028 for (
auto &
I : TOC) {
3029 MCSectionXCOFF *TCEntry;
3036 (Subtarget->hasAIXShLibTLSModelOpt() &&
3038 SmallString<128>
Name;
3041 Name +=
static_cast<const MCSymbolXCOFF *
>(
I.first.first)
3042 ->getSymbolTableName();
3043 MCSymbol *S = OutContext.getOrCreateSymbol(Name);
3044 TCEntry =
static_cast<MCSectionXCOFF *
>(
3045 getObjFileLowering().getSectionForTOCEntry(S, TM));
3047 TCEntry =
static_cast<MCSectionXCOFF *
>(
3048 getObjFileLowering().getSectionForTOCEntry(
I.first.first, TM));
3050 OutStreamer->switchSection(TCEntry);
3052 OutStreamer->emitLabel(
I.second);
3059 for (
const auto *GV : TOCDataGlobalVars) {
3060 if (!GV->hasCommonLinkage())
3061 emitGlobalVariableHelper(GV);
3063 for (
const auto *GV : TOCDataGlobalVars) {
3064 if (GV->hasCommonLinkage())
3065 emitGlobalVariableHelper(GV);
3069bool PPCAIXAsmPrinter::doInitialization(
Module &M) {
3070 const bool Result = PPCAsmPrinter::doInitialization(M);
3073 const Triple &
Target = TM.getTargetTriple();
3080 if (FunCpuId > TargetCpuId)
3081 TargetCpuId = FunCpuId;
3087 StringRef TargetCPU = TM.getTargetCPU();
3092 PPCTargetStreamer *TS =
3093 static_cast<PPCTargetStreamer *
>(OutStreamer->getTargetStreamer());
3096 auto setCsectAlignment = [
this](
const GlobalObject *GO) {
3098 if (GO->isDeclarationForLinker())
3101 SectionKind GOKind = getObjFileLowering().getKindForGlobal(GO, TM);
3102 auto *Csect =
static_cast<MCSectionXCOFF *
>(
3103 getObjFileLowering().SectionForGlobal(GO, GOKind, TM));
3105 Align GOAlign = getGVAlignment(GO, GO->getDataLayout());
3106 Csect->ensureMinAlignment(GOAlign);
3112 uint64_t TLSVarAddress = 0;
3113 auto DL =
M.getDataLayout();
3114 for (
const auto &
G :
M.globals()) {
3115 if (
G.isThreadLocal() && !
G.isDeclaration()) {
3116 TLSVarAddress =
alignTo(TLSVarAddress, getGVAlignment(&
G,
DL));
3117 TLSVarsToAddressMapping[&
G] = TLSVarAddress;
3118 TLSVarAddress +=
G.getGlobalSize(
DL);
3125 for (
const auto &
G :
M.globals()) {
3132 if (FormatIndicatorAndUniqueModId.empty()) {
3134 if (UniqueModuleId !=
"")
3138 FormatIndicatorAndUniqueModId =
"clang_" + UniqueModuleId.substr(1);
3143 std::chrono::duration_cast<std::chrono::nanoseconds>(
3144 std::chrono::steady_clock::now().time_since_epoch())
3146 FormatIndicatorAndUniqueModId =
3153 emitSpecialLLVMGlobal(&
G);
3157 setCsectAlignment(&
G);
3158 std::optional<CodeModel::Model> OptionalCodeModel =
G.getCodeModel();
3159 if (OptionalCodeModel)
3161 *OptionalCodeModel);
3164 for (
const auto &
F : M)
3165 setCsectAlignment(&
F);
3168 for (
const auto &Alias :
M.aliases()) {
3169 const GlobalObject *Aliasee = Alias.getAliaseeObject();
3172 "alias without a base object is not yet supported on AIX");
3176 "\n\tAlias attribute for " +
3177 Alias.getName() +
" is invalid because " +
3178 Aliasee->
getName() +
" is common.",
3182 const GlobalVariable *GVar =
3185 std::optional<CodeModel::Model> OptionalCodeModel = GVar->
getCodeModel();
3186 if (OptionalCodeModel)
3188 *OptionalCodeModel);
3191 GOAliasMap[Aliasee].push_back(&Alias);
3197void PPCAIXAsmPrinter::emitInstruction(
const MachineInstr *
MI) {
3198 switch (
MI->getOpcode()) {
3205 if (
MI->getNumOperands() < 5)
3207 const MachineOperand &LangMO =
MI->getOperand(3);
3208 const MachineOperand &ReasonMO =
MI->getOperand(4);
3211 MCSymbol *TempSym = OutContext.createNamedTempSymbol();
3212 OutStreamer->emitLabel(TempSym);
3213 OutStreamer->emitXCOFFExceptDirective(
3214 CurrentFnSym, TempSym, LangMO.
getImm(), ReasonMO.
getImm(),
3215 Subtarget->isPPC64() ?
MI->getMF()->getInstructionCount() * 8
3216 :
MI->getMF()->getInstructionCount() * 4,
3220 case PPC::GETtlsMOD32AIX:
3221 case PPC::GETtlsMOD64AIX:
3222 case PPC::GETtlsTpointer32AIX:
3223 case PPC::GETtlsADDR64AIX:
3224 case PPC::GETtlsADDR32AIX: {
3229 ExtSymSDNodeSymbols.
insert(TlsGetAddr);
3236 case PPC::BL_LWZinto_toc:
3237 case PPC::BL_LWZinto_toc_RM:
3238 case PPC::BL8_LDinto_toc:
3239 case PPC::BL8_LDinto_toc_RM: {
3240 const MachineOperand &MO =
MI->getOperand(0);
3242 auto *S =
static_cast<MCSymbolXCOFF *
>(
3244 ExtSymSDNodeSymbols.
insert(S);
3250 case PPC::BL8_NOP_TLS:
3257 case PPC::TAILBCTR8:
3258 if (
MI->getOperand(0).isSymbol())
3271 MCInstBuilder(PPC::ORI).addReg(PPC::R0).addReg(PPC::R0).addImm(0));
3274 return PPCAsmPrinter::emitInstruction(
MI);
3277bool PPCAIXAsmPrinter::doFinalization(
Module &M) {
3278 for (MCSymbol *Sym : ExtSymSDNodeSymbols)
3279 OutStreamer->emitSymbolAttribute(Sym,
MCSA_Extern);
3280 return PPCAsmPrinter::doFinalization(M);
3291 return 20 + (
P - 20) * 16;
3294 return 1004 + (
P - 81);
3297 return 2047 + (
P - 1124) * 33878;
3299 return 2147482625u + (
P - 64512);
3318 std::string PrioritySuffix;
3321 return PrioritySuffix;
3324void PPCAIXAsmPrinter::emitXXStructorList(
const DataLayout &
DL,
3325 const Constant *
List,
bool IsCtor) {
3327 preprocessXXStructorList(
DL,
List, Structors);
3328 if (Structors.
empty())
3332 for (Structor &S : Structors) {
3334 S.Func =
CE->getOperand(0);
3338 (IsCtor ? llvm::Twine(
"__sinit") : llvm::Twine(
"__sterm")) +
3340 llvm::Twine(
"_", FormatIndicatorAndUniqueModId) +
3346void PPCAIXAsmPrinter::emitTTypeReference(
const GlobalValue *GV,
3347 unsigned Encoding) {
3349 TOCEntryType GlobalType = TOCType_GlobalInternal;
3354 GlobalType = TOCType_GlobalExternal;
3355 MCSymbol *TypeInfoSym = TM.getSymbol(GV);
3356 MCSymbol *TOCEntry = lookUpOrCreateTOCEntry(TypeInfoSym, GlobalType);
3357 const MCSymbol *TOCBaseSym =
static_cast<const MCSectionXCOFF *
>(
3358 getObjFileLowering().getTOCBaseSection())
3359 ->getQualNameSymbol();
3360 auto &Ctx = OutStreamer->getContext();
3364 OutStreamer->emitValue(Exp, GetSizeOfEncodedValue(Encoding));
3366 OutStreamer->emitIntValue(0, GetSizeOfEncodedValue(Encoding));
3369void PPCAIXAsmPrinter::emitRefMetadata(
const GlobalObject *GO) {
3371 GO->
getMetadata(LLVMContext::MD_implicit_ref, MDs);
3372 assert(MDs.
size() &&
"Expected !implicit.ref metadata nodes");
3374 for (
const MDNode *MD : MDs) {
3379 ? getObjFileLowering().getFunctionEntryPointSymbol(GV, TM)
3381 OutStreamer->emitXCOFFRefDirective(Referenced);
3389 std::unique_ptr<MCStreamer> &&Streamer) {
3391 return new PPCAIXAsmPrinter(tm, std::move(Streamer));
3393 return new PPCLinuxAsmPrinter(tm, std::move(Streamer));
3396void PPCAIXAsmPrinter::emitModuleCommandLines(
Module &M) {
3397 const NamedMDNode *NMD =
M.getNamedMetadata(
"llvm.commandline");
3402 raw_string_ostream RSOS(S);
3405 assert(
N->getNumOperands() == 1 &&
3406 "llvm.commandline metadata entry can have only one operand");
3410 RSOS <<
"@(#)opt " << MDS->
getString() <<
"\n";
3413 OutStreamer->emitXCOFFCInfoSym(
".GCC.command.line", RSOS.str());
3417 enum class IsLocal {
3429 if (
LHS == IsLocal::False ||
RHS == IsLocal::False)
3430 return IsLocal::False;
3431 if (
LHS == IsLocal::True &&
RHS == IsLocal::True)
3432 return IsLocal::True;
3433 return IsLocal::Unknown;
3437 auto IsLocalFunc = [](
const Function *
F) -> IsLocal {
3438 bool Result =
F->isDSOLocal();
3440 << (Result ?
"dso_local\n" :
"not dso_local\n"));
3441 return Result ? IsLocal::True : IsLocal::False;
3450 std::function<IsLocal(
const Value *)> ValueIsALocalFunc =
3451 [&IsLocalFunc, &
Combine, &ValueIsALocalFunc](
const Value *V) -> IsLocal {
3453 return IsLocalFunc(
F);
3455 return IsLocal::Unknown;
3460 return Combine(ValueIsALocalFunc(
SI->getTrueValue()),
3461 ValueIsALocalFunc(
SI->getFalseValue()));
3463 IsLocal Res = IsLocal::True;
3464 for (
unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) {
3465 Res =
Combine(Res, ValueIsALocalFunc(PN->getIncomingValue(i)));
3466 if (Res == IsLocal::False)
3481 return IsLocal::Unknown;
3484 return IsLocal::Unknown;
3486 IsLocal Res = IsLocal::True;
3487 for (
unsigned Idx = 0, End =
Init->getNumOperands(); Idx != End; ++Idx) {
3488 Res =
Combine(Res, ValueIsALocalFunc(
Init->getOperand(Idx)));
3489 if (Res == IsLocal::False)
3494 return IsLocal::Unknown;
3504 IsLocal Res = IsLocal::True;
3509 Value *RV = Ret->getReturnValue();
3511 Res =
Combine(Res, ValueIsALocalFunc(RV));
3512 if (Res == IsLocal::False)
3541void PPCAIXAsmPrinter::emitGlobalIFunc(
Module &M,
const GlobalIFunc &GI) {
3543 const TargetSubtargetInfo *STI =
3545 bool IsPPC64 =
static_cast<const PPCSubtarget *
>(STI)->isPPC64();
3550 MCSectionXCOFF *FnDescSec =
static_cast<MCSectionXCOFF *
>(
3551 getObjFileLowering().getSectionForFunctionDescriptor(&GI, TM));
3556 CurrentFnSym = getObjFileLowering().getFunctionEntryPointSymbol(&GI, TM);
3559 if (TM.getFunctionSections())
3560 OutStreamer->switchSection(
3561 static_cast<MCSymbolXCOFF *
>(CurrentFnSym)->getRepresentedCsect());
3563 OutStreamer->switchSection(getObjFileLowering().getTextSection());
3566 emitRefMetadata(&GI);
3569 emitLinkage(&GI, CurrentFnDescSym);
3570 emitLinkage(&GI, CurrentFnSym);
3574 emitAlignment(Alignment,
nullptr);
3577 emitFunctionDescriptor();
3579 emitFunctionEntryLabel();
3583 SmallString<128> Msg;
3584 Msg.
append(
"unimplemented: TOC register save/restore needed for ifunc \"");
3585 getNameWithPrefix(Msg, &GI);
3586 Msg.
append(
"\", because couldn't prove all candidates are static or "
3587 "hidden/protected visibility definitions");
3591 dbgs() << Msg <<
"\n";
3595 auto *FnDescTOCEntrySym =
3596 lookUpOrCreateTOCEntry(CurrentFnDescSym, FnDescTOCEntryType);
3601 auto *Exp_U = symbolWithSpecifier(FnDescTOCEntrySym,
PPC::S_U);
3602 OutStreamer->emitInstruction(MCInstBuilder(PPC::ADDIS)
3607 auto *Exp_L = symbolWithSpecifier(FnDescTOCEntrySym,
PPC::S_L);
3608 OutStreamer->emitInstruction(MCInstBuilder(IsPPC64 ? PPC::LD : PPC::LWZ)
3618 OutStreamer->emitInstruction(MCInstBuilder(IsPPC64 ? PPC::LD : PPC::LWZ)
3625 OutStreamer->emitInstruction(MCInstBuilder(IsPPC64 ? PPC::LD : PPC::LWZ)
3627 .addImm(IsPPC64 ? 16 : 8)
3631 OutStreamer->emitInstruction(MCInstBuilder(IsPPC64 ? PPC::LD : PPC::LWZ)
3637 OutStreamer->emitInstruction(
3638 MCInstBuilder(IsPPC64 ? PPC::MTCTR8 : PPC::MTCTR).addReg(PPC::X12),
3641 OutStreamer->emitInstruction(MCInstBuilder(IsPPC64 ? PPC::BCTR8 : PPC::BCTR),
3645char PPCAIXAsmPrinter::ID = 0;
3648 "AIX PPC Assembly Printer",
false,
false)
3652LLVMInitializePowerPCAsmPrinter() {
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static AMDGPUMCExpr::Specifier getSpecifier(unsigned MOFlags)
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
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 constexpr unsigned SM(unsigned Version)
static void collectTOCStats(PPCAsmPrinter::TOCEntryType Type)
static bool isSpecialLLVMGlobalArrayForStaticInit(const GlobalVariable *GV)
static bool isSpecialLLVMGlobalArrayToSkip(const GlobalVariable *GV)
static cl::opt< bool > IFuncLocalIfProven("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 cl::opt< bool > IFuncWarnInsteadOfError("test-ifunc-warn-noerror", cl::init(false), cl::ReallyHidden)
static MCSymbol * createMCSymbolForTlsGetAddr(MCContext &Ctx, unsigned MIOpc)
This helper function creates the TlsGetAddr/TlsGetMod MCSymbol for AIX.
#define GENVALUECOMMENT(PrefixAndName, V, Field)
static unsigned mapToSinitPriority(int P)
static void tocDataChecks(unsigned PointerSize, const GlobalVariable *GV)
static cl::opt< bool > EnableSSPCanaryBitInTB("aix-ssp-tb-bit", cl::init(false), cl::desc("Enable Passing SSP Canary info in Trackback on AIX"), cl::Hidden)
PassBuilder PB(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)
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)
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.
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.
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
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.
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 append(StringRef RHS)
Append from a StringRef.
StringRef str() const
Explicit conversion to StringRef.
void push_back(const T &Elt)
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(SmallPtrSetImpl< Type * > *Visited=nullptr) 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.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ C
The default llvm calling convention, compatible with C.
Flag
These should be considered private to the implementation of the MCInstrDesc class.
@ MO_TLSLDM_FLAG
MO_TLSLDM_FLAG - on AIX the ML relocation type is only valid for a reference to a TOC symbol from the...
@ MO_TPREL_PCREL_FLAG
MO_TPREL_PCREL_FLAG = MO_PCREL_FLAG | MO_TPREL_FLAG.
@ MO_GOT_TPREL_PCREL_FLAG
MO_GOT_TPREL_PCREL_FLAG - A combintaion of flags, if these bits are set they should produce the reloc...
@ MO_TLSGDM_FLAG
MO_TLSGDM_FLAG - If this bit is set the symbol reference is relative to the region handle of TLS Gene...
@ MO_TLSLD_FLAG
MO_TLSLD_FLAG - If this bit is set the symbol reference is relative to TLS Local Dynamic model.
@ MO_TPREL_FLAG
MO_TPREL_FLAG - If this bit is set, the symbol reference is relative to the thread pointer and the sy...
@ MO_GOT_TLSLD_PCREL_FLAG
MO_GOT_TLSLD_PCREL_FLAG - A combintaion of flags, if these bits are set they should produce the reloc...
@ MO_TLSGD_FLAG
MO_TLSGD_FLAG - If this bit is set the symbol reference is relative to TLS General Dynamic model for ...
@ MO_GOT_TLSGD_PCREL_FLAG
MO_GOT_TLSGD_PCREL_FLAG - A combintaion of flags, if these bits are set they should produce the reloc...
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.
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
FunctionAddr VTableAddr Value
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.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
bool LowerPPCMachineOperandToMCOperand(const MachineOperand &MO, MCOperand &OutMO, AsmPrinter &AP)
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.
auto dyn_cast_or_null(const Y &Val)
FunctionAddr VTableAddr uintptr_t uintptr_t Version
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.
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
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)
static TOCKey getEmptyKey()
An information struct used to provide DenseMap with the various necessary components for a given valu...
Align valueOrOne() const
For convenience, returns a valid alignment or 1 if undefined.
static void RegisterAsmPrinter(Target &T, Target::AsmPrinterCtorTy Fn)
RegisterAsmPrinter - Register an AsmPrinter implementation for the given target.
static constexpr uint32_t FPRSavedMask
static constexpr uint16_t NumberOfVRSavedMask
static constexpr uint8_t NumberOfFloatingPointParmsShift
static constexpr uint32_t NumberOfFixedParmsMask
static constexpr uint16_t HasVMXInstructionMask
static constexpr uint32_t IsLRSavedMask
static constexpr uint16_t HasVarArgsMask
static constexpr uint32_t IsAllocaUsedMask
static constexpr uint16_t IsVRSavedOnStackMask
static constexpr uint16_t NumberOfVectorParmsMask
static constexpr uint32_t IsFloatingPointPresentMask
static constexpr uint32_t FPRSavedShift
static constexpr uint32_t NumberOfFloatingPointParmsMask
static constexpr uint32_t HasControlledStorageMask
static constexpr uint32_t HasExtensionTableMask
static constexpr uint32_t HasTraceBackTableOffsetMask
static constexpr uint32_t IsCRSavedMask
static constexpr uint8_t NumberOfFixedParmsShift
static constexpr uint32_t GPRSavedMask
static constexpr uint8_t NumberOfVectorParmsShift
static constexpr uint32_t HasParmsOnStackMask
static constexpr uint32_t IsFunctionNamePresentMask
static constexpr uint32_t IsBackChainStoredMask
static constexpr uint32_t IsInterruptHandlerMask
static constexpr uint32_t HasVectorInfoMask
static constexpr uint8_t NumberOfVRSavedShift
static constexpr uint32_t GPRSavedShift