102 if (
MI->memoperands_empty())
107 EE =
MI->memoperands_end(); MMOI != EE; ++MMOI)
108 if ((*MMOI)->getAlign() < Alignment)
109 Alignment = (*MMOI)->getAlign();
111 unsigned AlignmentHint = 0;
112 if (Alignment >=
Align(16))
114 else if (Alignment >=
Align(8))
116 if (AlignmentHint == 0)
130 .
addReg(
MI->getOperand(3).getReg());
170 if (
TM.getTargetTriple().isOSzOS()) {
172 for (
const auto &Alias : M.aliases()) {
176 {},
"Alias without a base object is not yet supported on z/OS.");
180 if (Alias.hasWeakLinkage() || Alias.hasLinkOnceLinkage())
182 "Weak alias/reference not supported on z/OS");
184 GOAliasMap[Aliasee].push_back(&Alias);
187 {},
"Only aliases to functions is supported in GOFF.");
198void SystemZAsmPrinter::emitCallInformation(CallType CT) {
205uint32_t SystemZAsmPrinter::AssociatedDataAreaTable::insert(
const MCSymbol *Sym,
207 auto Key = std::make_pair(Sym, SlotKind);
208 auto It = Displacements.
find(
Key);
210 if (It != Displacements.
end())
224 uint32_t Displacement = NextDisplacement;
225 Displacements[std::make_pair(Sym, SlotKind)] = NextDisplacement;
226 NextDisplacement +=
Length;
232SystemZAsmPrinter::AssociatedDataAreaTable::insert(
const MachineOperand MO) {
237 assert(Sym &&
"No symbol");
241 assert(Sym &&
"No symbol");
246 return insert(Sym, ADAslotType);
250 SystemZ_MC::verifyInstructionPredicates(
MI->getOpcode(),
255 switch (
MI->getOpcode()) {
256 case SystemZ::Return:
261 case SystemZ::Return_XPLINK:
268 case SystemZ::CondReturn:
275 case SystemZ::CondReturn_XPLINK:
284 case SystemZ::CRBReturn:
293 case SystemZ::CGRBReturn:
302 case SystemZ::CIBReturn:
311 case SystemZ::CGIBReturn:
320 case SystemZ::CLRBReturn:
329 case SystemZ::CLGRBReturn:
338 case SystemZ::CLIBReturn:
347 case SystemZ::CLGIBReturn:
356 case SystemZ::CallBRASL_XPLINK64:
358 .addReg(SystemZ::R7D)
359 .addExpr(
Lower.getExpr(
MI->getOperand(0),
361 emitCallInformation(CallType::BRASL7);
364 case SystemZ::CallBASR_XPLINK64:
366 .addReg(SystemZ::R7D)
367 .addReg(
MI->getOperand(0).getReg()));
368 emitCallInformation(CallType::BASR76);
371 case SystemZ::CallBASR_STACKEXT:
373 .addReg(SystemZ::R3D)
374 .addReg(
MI->getOperand(0).getReg()));
375 emitCallInformation(CallType::BASR33);
378 case SystemZ::ADA_ENTRY_VALUE:
379 case SystemZ::ADA_ENTRY: {
382 uint32_t Disp = ADATable.insert(
MI->getOperand(1));
383 Register TargetReg =
MI->getOperand(0).getReg();
386 Disp +=
MI->getOperand(3).getImm();
387 bool LoadAddr =
MI->getOpcode() == SystemZ::ADA_ENTRY;
389 unsigned Op0 = LoadAddr ? SystemZ::LA : SystemZ::LG;
390 unsigned Op =
TII->getOpcodeForOffset(Op0, Disp);
394 if (TargetReg != ADAReg) {
395 IndexReg = TargetReg;
399 MCInstBuilder(SystemZ::LLILF).addReg(TargetReg).addImm(Disp));
416 case SystemZ::CallBRASL:
422 case SystemZ::CallBASR:
425 .
addReg(
MI->getOperand(0).getReg());
428 case SystemZ::CallJG:
433 case SystemZ::CallBRCL:
440 case SystemZ::CallBR:
442 .
addReg(
MI->getOperand(0).getReg());
445 case SystemZ::CallBCR:
449 .
addReg(
MI->getOperand(2).getReg());
452 case SystemZ::CRBCall:
461 case SystemZ::CGRBCall:
470 case SystemZ::CIBCall:
479 case SystemZ::CGIBCall:
488 case SystemZ::CLRBCall:
497 case SystemZ::CLGRBCall:
506 case SystemZ::CLIBCall:
515 case SystemZ::CLGIBCall:
524 case SystemZ::TLS_GDCALL:
532 case SystemZ::TLS_LDCALL:
546 case SystemZ::IILF64:
549 .
addImm(
MI->getOperand(2).getImm());
552 case SystemZ::IIHF64:
555 .
addImm(
MI->getOperand(2).getImm());
558 case SystemZ::RISBHH:
559 case SystemZ::RISBHL:
563 case SystemZ::RISBLH:
564 case SystemZ::RISBLL:
568 case SystemZ::VLVGP32:
631 case SystemZ::LFER_16:
639 case SystemZ::LEFR_16:
643#define LOWER_LOW(NAME) \
644 case SystemZ::NAME##64: LoweredMI = lowerRILow(MI, SystemZ::NAME); break
660#define LOWER_HIGH(NAME) \
661 case SystemZ::NAME##64: LoweredMI = lowerRIHigh(MI, SystemZ::NAME); break
677 case SystemZ::Serialize:
690 case SystemZ::Trap: {
703 case SystemZ::CondTrap: {
716 case TargetOpcode::FENTRY_CALL:
720 case TargetOpcode::STACKMAP:
724 case TargetOpcode::PATCHPOINT:
728 case TargetOpcode::PATCHABLE_FUNCTION_ENTER:
729 LowerPATCHABLE_FUNCTION_ENTER(*
MI,
Lower);
732 case TargetOpcode::PATCHABLE_RET:
733 LowerPATCHABLE_RET(*
MI,
Lower);
736 case TargetOpcode::PATCHABLE_FUNCTION_EXIT:
739 case TargetOpcode::PATCHABLE_TAIL_CALL:
743 "around this assert.");
745 case SystemZ::EXRL_Pseudo: {
746 unsigned TargetInsOpc =
MI->getOperand(0).getImm();
747 Register LenMinus1Reg =
MI->getOperand(1).getReg();
748 Register DestReg =
MI->getOperand(2).getReg();
749 int64_t DestDisp =
MI->getOperand(3).getImm();
751 int64_t SrcDisp =
MI->getOperand(5).getImm();
768 MCInstBuilder(SystemZ::EXRL).addReg(LenMinus1Reg).addExpr(Dot));
774 case SystemZ::EH_SjLj_Setup:
777 case SystemZ::LOAD_TLS_BLOCK_ADDR:
778 lowerLOAD_TLS_BLOCK_ADDR(*
MI,
Lower);
780 case SystemZ::LOAD_GLOBAL_STACKGUARD_ADDR:
781 lowerLOAD_GLOBAL_STACKGUARD_ADDR(*
MI,
Lower);
799 else if (NumBytes < 4) {
801 MCInstBuilder(SystemZ::BCRAsm).addImm(0).addReg(SystemZ::R0D), STI);
804 else if (NumBytes < 6) {
806 MCInstBuilder(SystemZ::BCAsm).addImm(0).addReg(0).addImm(0).addReg(0),
815 MCInstBuilder(SystemZ::BRCLAsm).addImm(0).addExpr(Dot), STI);
820void SystemZAsmPrinter::LowerFENTRY_CALL(
const MachineInstr &
MI,
821 SystemZMCInstLower &
Lower) {
822 MCContext &Ctx =
MF->getContext();
823 if (
MF->getFunction().hasFnAttribute(
"mrecord-mcount")) {
833 if (
MF->getFunction().hasFnAttribute(
"mnop-mcount")) {
839 const MCSymbolRefExpr *
Op =
842 MCInstBuilder(SystemZ::BRASL).addReg(SystemZ::R0D).addExpr(
Op),
846void SystemZAsmPrinter::LowerSTACKMAP(
const MachineInstr &
MI) {
847 auto *
TII =
MF->getSubtarget<SystemZSubtarget>().getInstrInfo();
849 unsigned NumNOPBytes =
MI.getOperand(1).getImm();
855 SM.recordStackMap(*MILabel,
MI);
856 assert(NumNOPBytes % 2 == 0 &&
"Invalid number of NOP bytes requested!");
859 unsigned ShadowBytes = 0;
860 const MachineBasicBlock &
MBB = *
MI.getParent();
863 while (ShadowBytes < NumNOPBytes) {
865 MII->getOpcode() == TargetOpcode::PATCHPOINT ||
866 MII->getOpcode() == TargetOpcode::STACKMAP)
868 ShadowBytes +=
TII->getInstSizeInBytes(*MII);
875 while (ShadowBytes < NumNOPBytes)
882void SystemZAsmPrinter::LowerPATCHPOINT(
const MachineInstr &
MI,
883 SystemZMCInstLower &
Lower) {
888 SM.recordPatchPoint(*MILabel,
MI);
889 PatchPointOpers Opers(&
MI);
891 unsigned EncodedBytes = 0;
892 const MachineOperand &CalleeMO = Opers.getCallTarget();
894 if (CalleeMO.
isImm()) {
895 uint64_t CallTarget = CalleeMO.
getImm();
897 unsigned ScratchIdx = -1;
898 unsigned ScratchReg = 0;
900 ScratchIdx = Opers.getNextScratchIdx(ScratchIdx + 1);
901 ScratchReg =
MI.getOperand(ScratchIdx).getReg();
902 }
while (ScratchReg == SystemZ::R0D);
907 .addImm(CallTarget & 0xFFFFFFFF));
909 if (CallTarget >> 32) {
912 .addImm(CallTarget >> 32));
917 .addReg(SystemZ::R14D)
918 .addReg(ScratchReg));
924 .addReg(SystemZ::R14D)
930 unsigned NumBytes = Opers.getNumPatchBytes();
931 assert(NumBytes >= EncodedBytes &&
932 "Patchpoint can't request size less than the length of a call.");
933 assert((NumBytes - EncodedBytes) % 2 == 0 &&
934 "Invalid number of NOP bytes requested!");
935 while (EncodedBytes < NumBytes)
940void SystemZAsmPrinter::LowerPATCHABLE_FUNCTION_ENTER(
941 const MachineInstr &
MI, SystemZMCInstLower &
Lower) {
947 if (
F.hasFnAttribute(
"patchable-function-entry")) {
950 unsigned Num =
F.getFnAttributeAsParsedInteger(
"patchable-function-entry");
954 for (
unsigned I = 0;
I < Num; ++
I)
968 bool HasVectorFeature =
969 TM.getMCSubtargetInfo().hasFeature(SystemZ::FeatureVector) &&
970 !
TM.getMCSubtargetInfo().hasFeature(SystemZ::FeatureSoftFloat);
972 HasVectorFeature ?
"__xray_FunctionEntryVec" :
"__xray_FunctionEntry");
977 MCInstBuilder(SystemZ::J)
981 MCInstBuilder(SystemZ::LLILF).addReg(SystemZ::R2D).addImm(0));
983 .addReg(SystemZ::R14D)
990void SystemZAsmPrinter::LowerPATCHABLE_RET(
const MachineInstr &
MI,
991 SystemZMCInstLower &
Lower) {
992 unsigned OpCode =
MI.getOperand(0).getImm();
993 MCSymbol *FallthroughLabel =
nullptr;
994 if (OpCode == SystemZ::CondReturn) {
995 FallthroughLabel =
OutContext.createTempSymbol();
996 int64_t Cond0 =
MI.getOperand(1).getImm();
997 int64_t Cond1 =
MI.getOperand(2).getImm();
1000 .addImm(Cond1 ^ Cond0)
1013 bool HasVectorFeature =
1014 TM.getMCSubtargetInfo().hasFeature(SystemZ::FeatureVector) &&
1015 !
TM.getMCSubtargetInfo().hasFeature(SystemZ::FeatureSoftFloat);
1017 HasVectorFeature ?
"__xray_FunctionExitVec" :
"__xray_FunctionExit");
1021 MCInstBuilder(SystemZ::BR).addReg(SystemZ::R14D));
1024 MCInstBuilder(SystemZ::LLILF).addReg(SystemZ::R2D).addImm(0));
1028 if (FallthroughLabel)
1033void SystemZAsmPrinter::lowerLOAD_TLS_BLOCK_ADDR(
const MachineInstr &
MI,
1034 SystemZMCInstLower &
Lower) {
1035 Register AddrReg =
MI.getOperand(0).getReg();
1036 const MachineRegisterInfo &MRI =
MI.getParent()->getParent()->getRegInfo();
1045 MCInstBuilder(SystemZ::EAR).addReg(Reg32).addReg(SystemZ::A0));
1056 MCInstBuilder(SystemZ::EAR).addReg(Reg32).addReg(SystemZ::A1));
1059void SystemZAsmPrinter::lowerLOAD_GLOBAL_STACKGUARD_ADDR(
1060 const MachineInstr &
MI, SystemZMCInstLower &
Lower) {
1061 Register AddrReg =
MI.getOperand(0).getReg();
1063 const Module *
M =
MF.getFunction().getParent();
1064 const TargetLowering *TLI =
MF.getSubtarget().getTargetLowering();
1071 if (
M->hasStackProtectorGuardRecord()) {
1088 MCInstBuilder(SystemZ::LGRL)
1098void SystemZAsmPrinter::emitAttributes(
Module &M) {
1099 if (
M.getModuleFlag(
"s390x-visible-vector-ABI")) {
1100 bool HasVectorFeature =
1101 TM.getMCSubtargetInfo().hasFeature(SystemZ::FeatureVector);
1102 OutStreamer->emitGNUAttribute(8, HasVectorFeature ? 2 : 1);
1137 if (!
TM.getTargetTriple().isOSBinFormatGOFF())
1142 if (Structors.
empty())
1150 static_cast<MCSectionGOFF *
>(Obj.getStaticXtorSection(S.Priority));
1160 uint32_t XtorPriority = Section->getPRAttributes().SortKey;
1163 assert(GV &&
"C++ xxtor pointer was not a GlobalValue!");
1168 unsigned PointerSizeInBytes =
DL.getPointerSize();
1171 const MCExpr *ADAFuncRefExpr;
1176 assert(ADASection &&
"ADA section must exist for GOFF targets!");
1178 assert(ADASym &&
"ADA symbol should already be set!");
1187 OutStreamer->emitValue(ADAFuncRefExpr, PointerSizeInBytes);
1191 OutStreamer->emitValue(ADAFuncRefExpr, PointerSizeInBytes);
1221 else if (MCOp.
isImm())
1230 const MCOperand &DispMO,
unsigned Index,
1233 if (
Base || Index) {
1247 const char *ExtraCode,
1253 if (ExtraCode[0] ==
'N' && !ExtraCode[1] && MO.
isReg() &&
1254 SystemZ::GR128BitRegClass.contains(MO.
getReg()))
1261 MCOp =
Lower.lowerOperand(MO);
1269 const char *ExtraCode,
1271 if (ExtraCode && ExtraCode[0] && !ExtraCode[1]) {
1272 switch (ExtraCode[0]) {
1279 OS <<
MI->getOperand(OpNo + 1).getImm();
1288 MI->getOperand(OpNo + 2).getReg(), OS);
1296 for (
auto &Info : DeferredPPA1)
1304 for (
auto &GO : M.global_objects()) {
1308 getTargetStreamer()->emitADA(
1309 Sym,
OutContext.getObjectFileInfo()->getADASection());
1318void SystemZAsmPrinter::emitADASection() {
1324 unsigned EmittedBytes = 0;
1325 for (
auto &Entry : ADATable.getTable()) {
1328 std::tie(Sym, SlotKind) = Entry.first;
1329 unsigned Offset = Entry.second;
1330 assert(
Offset == EmittedBytes &&
"Offset not as expected");
1332#define EMIT_COMMENT(Str) \
1333 OutStreamer->AddComment(Twine("Offset ") \
1334 .concat(utostr(Offset)) \
1335 .concat(" " Str " ") \
1336 .concat(Sym->getName()));
1350 EmittedBytes += PointerSize * 2;
1358 EmittedBytes += PointerSize;
1375 EmittedBytes += PointerSize;
1387 std::string ProductID;
1388 if (
auto *MD = M.getModuleFlag(
"zos_product_id"))
1390 if (ProductID.empty())
1397 M.getModuleFlag(
"zos_product_major_version")))
1398 return VersionVal->getZExtValue();
1399 return LLVM_VERSION_MAJOR;
1404 M.getModuleFlag(
"zos_product_minor_version")))
1405 return ReleaseVal->getZExtValue();
1406 return LLVM_VERSION_MINOR;
1411 M.getModuleFlag(
"zos_product_patchlevel")))
1412 return PatchVal->getZExtValue();
1413 return LLVM_VERSION_PATCH;
1417 std::time_t Time = 0;
1419 M.getModuleFlag(
"zos_translation_time"))) {
1420 long SecondsSinceEpoch = Val->getSExtValue();
1421 Time =
static_cast<time_t
>(SecondsSinceEpoch);
1426void SystemZAsmPrinter::emitIDRLSection(
Module &M) {
1429 constexpr unsigned IDRLDataLength = 30;
1437 SmallString<IDRLDataLength + 1> TempStr;
1438 raw_svector_ostream
O(TempStr);
1439 O <<
formatv(
"{0,-10}{1,0-2:d}{2,0-2:d}{3:%Y%m%d%H%M%S}{4,0-2}",
1440 ProductID.substr(0, 10).c_str(), ProductVersion, ProductRelease,
1442 SmallString<IDRLDataLength>
Data;
1453 if (
TM.getTargetTriple().isOSzOS()) {
1456 OutStreamer->emitLabel(DeferredPPA1.back().FnEnd);
1462 bool EHBlock,
bool HasArgAreaLength,
bool HasName) {
1463 enum class PPA1Flag1 :
uint8_t {
1464 DSA64Bit = (0x80 >> 0),
1465 VarArg = (0x80 >> 7),
1468 enum class PPA1Flag2 :
uint8_t {
1469 ExternalProcedure = (0x80 >> 0),
1470 STACKPROTECTOR = (0x80 >> 3),
1473 enum class PPA1Flag3 :
uint8_t {
1474 HasArgAreaLength = (0x80 >> 1),
1475 FPRMask = (0x80 >> 2),
1478 enum class PPA1Flag4 :
uint8_t {
1479 EPMOffsetPresent = (0x80 >> 0),
1480 VRMask = (0x80 >> 2),
1481 EHBlock = (0x80 >> 3),
1482 ProcedureNamePresent = (0x80 >> 7),
1487 auto Flags1 = PPA1Flag1(0);
1488 auto Flags2 = PPA1Flag2::ExternalProcedure;
1489 auto Flags3 = PPA1Flag3(0);
1490 auto Flags4 = PPA1Flag4::EPMOffsetPresent;
1492 Flags1 |= PPA1Flag1::DSA64Bit;
1495 Flags1 |= PPA1Flag1::VarArg;
1498 Flags2 |= PPA1Flag2::STACKPROTECTOR;
1500 if (HasArgAreaLength)
1501 Flags3 |= PPA1Flag3::HasArgAreaLength;
1505 Flags3 |= PPA1Flag3::FPRMask;
1508 Flags4 |= PPA1Flag4::VRMask;
1511 Flags4 |= PPA1Flag4::EHBlock;
1514 Flags4 |= PPA1Flag4::ProcedureNamePresent;
1517 OutStreamer->AddComment(
" Bit 0: 1 = 64-bit DSA");
1518 if ((Flags1 & PPA1Flag1::VarArg) == PPA1Flag1::VarArg)
1519 OutStreamer->AddComment(
" Bit 7: 1 = Vararg function");
1523 if ((Flags2 & PPA1Flag2::ExternalProcedure) == PPA1Flag2::ExternalProcedure)
1524 OutStreamer->AddComment(
" Bit 0: 1 = External procedure");
1525 if ((Flags2 & PPA1Flag2::STACKPROTECTOR) == PPA1Flag2::STACKPROTECTOR)
1526 OutStreamer->AddComment(
" Bit 3: 1 = STACKPROTECT is enabled");
1528 OutStreamer->AddComment(
" Bit 3: 0 = STACKPROTECT is not enabled");
1532 if ((Flags3 & PPA1Flag3::HasArgAreaLength) == PPA1Flag3::HasArgAreaLength)
1534 " Bit 1: 1 = Argument Area Length is in optional area");
1535 if ((Flags3 & PPA1Flag3::FPRMask) == PPA1Flag3::FPRMask)
1536 OutStreamer->AddComment(
" Bit 2: 1 = FP Reg Mask is in optional area");
1538 static_cast<uint8_t>(Flags3));
1541 if ((Flags4 & PPA1Flag4::VRMask) == PPA1Flag4::VRMask)
1542 OutStreamer->AddComment(
" Bit 2: 1 = Vector Reg Mask is in optional area");
1543 if ((Flags4 & PPA1Flag4::EHBlock) == PPA1Flag4::EHBlock)
1544 OutStreamer->AddComment(
" Bit 3: 1 = C++ EH block");
1545 if ((Flags4 & PPA1Flag4::ProcedureNamePresent) ==
1546 PPA1Flag4::ProcedureNamePresent)
1547 OutStreamer->AddComment(
" Bit 7: 1 = Name Length and Name");
1559 OutName = OutName.
substr(0, UINT16_MAX);
1560 OutSize = UINT16_MAX;
1563 uint8_t ExtraZeros = 4 - ((2 + OutSize) % 4);
1567 OutName = OutnameConv.
str();
1576void SystemZAsmPrinter::emitPPA1(PPA1Info &Info) {
1577 assert(PPA2Sym !=
nullptr &&
"PPA2 Symbol not defined");
1589 bool HasArgAreaLength = (
Info.AllocaReg != 0) || (
Info.CallFrameSize > 128);
1604 Info.SavedFPRMask != 0,
Info.SavedVRMask != 0,
1605 Info.PersonalityRoutine !=
nullptr, HasArgAreaLength,
1606 Info.Name.size() > 0);
1610 static_cast<uint16_t
>(
Info.SizeOfFnParams / 4));
1614 if (HasArgAreaLength) {
1620 if (
Info.SavedFPRMask) {
1626 uint64_t FPRSaveAreaOffset =
Info.OffsetFPR;
1627 assert(FPRSaveAreaOffset < 0x10000000 &&
"Offset out of range");
1628 FPRSaveAreaOffset &= 0x0FFFFFFF;
1632 Twine(
" Bit 4-31: Offset ").
concat(
utostr(FPRSaveAreaOffset)).str());
1634 (
Info.FrameReg << 28));
1640 if (
Info.SavedVRMask) {
1645 uint64_t VRSaveAreaOffset =
Info.OffsetVR;
1646 assert(VRSaveAreaOffset < 0x10000000 &&
"Offset out of range");
1647 VRSaveAreaOffset &= 0x0FFFFFFF;
1652 Twine(
" Bit 4-31: Offset ").
concat(
utostr(VRSaveAreaOffset)).str());
1657 if (
Info.PersonalityRoutine) {
1671 if (
Info.Name.size())
1678void SystemZAsmPrinter::calculatePPA1() {
1679 assert(PPA2Sym !=
nullptr &&
"PPA2 Symbol not defined");
1683 const TargetRegisterInfo *
TRI =
MF->getRegInfo().getTargetRegisterInfo();
1684 const SystemZSubtarget &Subtarget =
MF->getSubtarget<SystemZSubtarget>();
1686 const SystemZMachineFunctionInfo *ZFI =
1687 MF->getInfo<SystemZMachineFunctionInfo>();
1688 const auto *ZFL =
static_cast<const SystemZXPLINKFrameLowering *
>(
1690 const MachineFrameInfo &MFFrame =
MF->getFrameInfo();
1694 uint16_t SavedGPRMask = 0;
1695 uint16_t SavedFPRMask = 0;
1696 uint8_t SavedVRMask = 0;
1697 int64_t OffsetFPR = 0;
1698 int64_t OffsetVR = 0;
1699 const int64_t TopOfStack =
1704 for (
unsigned I = ZFI->getSpillGPRRegs().LowGPR,
1705 E = ZFI->getSpillGPRRegs().HighGPR;
1706 I &&
E &&
I <=
E; ++
I) {
1708 assert(V < 16 &&
"GPR index out of range");
1709 SavedGPRMask |= 1 << (15 -
V);
1712 for (
auto &CS : CSI) {
1713 unsigned Reg = CS.getReg();
1714 unsigned I =
TRI->getEncodingValue(
Reg);
1717 assert(
I < 16 &&
"FPR index out of range");
1718 SavedFPRMask |= 1 << (15 -
I);
1720 if (Temp < OffsetFPR)
1722 }
else if (SystemZ::VR128BitRegClass.
contains(
Reg)) {
1723 assert(
I >= 16 &&
I <= 23 &&
"VPR index out of range");
1724 unsigned BitNum =
I - 16;
1725 SavedVRMask |= 1 << (7 - BitNum);
1727 if (Temp < OffsetVR)
1733 OffsetFPR += (OffsetFPR < 0) ? TopOfStack : 0;
1734 OffsetVR += (OffsetVR < 0) ? TopOfStack : 0;
1737 uint8_t FrameReg =
TRI->getEncodingValue(
TRI->getFrameRegister(*
MF));
1738 uint8_t AllocaReg = ZFL->hasFP(*
MF) ? FrameReg : 0;
1739 assert(AllocaReg < 16 &&
"Can't have alloca register larger than 15");
1741 MCSymbol *PersonalityRoutine =
nullptr;
1743 if (!
MF->getLandingPads().empty()) {
1745 MF->getFunction().getPersonalityFn()->stripPointerCasts());
1746 PersonalityRoutine = Per ?
MF->getTarget().getSymbol(Per) :
nullptr;
1747 assert(PersonalityRoutine &&
"Missing personality routine");
1749 GCCEH =
MF->getContext().getOrCreateSymbol(Twine(
"GCC_except_table") +
1750 Twine(
MF->getFunctionNumber()));
1754 std::string
N(
MF->getFunction().hasName()
1755 ? Twine(
MF->getFunction().getName()).concat(
"_").str()
1759 if (
MF->getFunction().hasName())
1760 Info.Name =
MF->getFunction().getName();
1765 Info.PersonalityRoutine = PersonalityRoutine;
1767 Info.OffsetFPR = OffsetFPR;
1768 Info.OffsetVR = OffsetVR;
1770 Info.SizeOfFnParams = ZFI->getSizeOfFnParams();
1771 Info.SavedGPRMask = SavedGPRMask;
1772 Info.SavedFPRMask = SavedFPRMask;
1773 Info.SavedVRMask = SavedVRMask;
1774 Info.FrameReg = FrameReg;
1775 Info.AllocaReg = AllocaReg;
1776 Info.IsVarArg =
MF->getFunction().isVarArg();
1779 DeferredPPA1.push_back(Info);
1783 if (
TM.getTargetTriple().isOSzOS())
1788void SystemZAsmPrinter::emitPPA2(
Module &M) {
1793 const char *StartSymbolName =
"CELQSTRT";
1812 ProductRelease, ProductPatch);
1817 enum class PPA2MemberId :
uint8_t {
1822 enum class PPA2MemberSubId :
uint8_t {
1828 LLVMBasedLang = 0xe7,
1831 enum class PPA2Flags : uint8_t {
1832 CompileForBinaryFloatingPoint = 0x80,
1833 CompiledWithXPLink = 0x01,
1834 CompiledUnitASCII = 0x04,
1835 HasServiceInfo = 0x20,
1838 PPA2MemberSubId MemberSubId = PPA2MemberSubId::LLVMBasedLang;
1839 if (
auto *MD =
M.getModuleFlag(
"zos_cu_language")) {
1841 MemberSubId = StringSwitch<PPA2MemberSubId>(Language)
1842 .Case(
"C", PPA2MemberSubId::C)
1843 .Case(
"C++", PPA2MemberSubId::CXX)
1844 .Case(
"Swift", PPA2MemberSubId::Swift)
1845 .Case(
"Go", PPA2MemberSubId::Go)
1846 .Default(PPA2MemberSubId::LLVMBasedLang);
1851 OutStreamer->emitInt8(
static_cast<uint8_t
>(PPA2MemberId::LE_C_Runtime));
1852 OutStreamer->emitInt8(
static_cast<uint8_t
>(MemberSubId));
1855 OutStreamer->emitAbsoluteSymbolDiff(CELQSTRT, PPA2Sym, 4);
1857 OutStreamer->emitAbsoluteSymbolDiff(DateVersionSym, PPA2Sym, 4);
1860 uint8_t Flgs =
static_cast<uint8_t
>(PPA2Flags::CompileForBinaryFloatingPoint);
1861 Flgs |=
static_cast<uint8_t
>(PPA2Flags::CompiledWithXPLink);
1863 bool IsASCII =
true;
1864 if (
auto *MD =
M.getModuleFlag(
"zos_le_char_mode")) {
1866 if (CharMode ==
"ebcdic")
1868 else if (CharMode !=
"ascii")
1870 {},
"Only ascii or ebcdic are allowed for zos_le_char_mode");
1873 Flgs |=
static_cast<uint8_t
>(
1874 PPA2Flags::CompiledUnitASCII);
1896 OutStreamer->emitAbsoluteSymbolDiff(PPA2Sym, CELQSTRT, 8);
1902 if (!
TM.getTargetTriple().isOSzOS())
1911 const Triple &TargetTriple =
TM.getTargetTriple();
1955 if (Subtarget.getTargetTriple().isOSzOS()) {
1972 uint32_t DSAAndFlags = DSASize & 0xFFFFFFE0;
1973 DSAAndFlags |= Flags;
1976 OutStreamer->AddComment(
"XPLINK Routine Layout Entry");
1977 OutStreamer->emitLabel(DeferredPPA1.back().EPMarker);
1978 OutStreamer->AddComment(
"Eyecatcher 0x00C300C500C500");
1979 OutStreamer->emitIntValueInHex(0x00C300C500C500, 7);
1983 OutStreamer->emitAbsoluteSymbolDiff(DeferredPPA1.back().PPA1,
1984 DeferredPPA1.back().EPMarker, 4);
1989 OutStreamer->AddComment(
" Bit 1: 1 = Leaf function");
1991 OutStreamer->AddComment(
" Bit 1: 0 = Non-leaf function");
1993 OutStreamer->AddComment(
" Bit 2: 1 = Uses alloca");
1995 OutStreamer->AddComment(
" Bit 2: 0 = Does not use alloca");
2005 if (Subtarget.getTargetTriple().isOSzOS()) {
2021 "SystemZ Assembly Printer",
false,
false)
2025LLVMInitializeSystemZAsmPrinter() {
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static const Function * getParent(const Value *V)
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_EXTERNAL_VISIBILITY
This file provides utility functions for converting between EBCDIC-1047 and UTF-8.
const HexagonInstrInfo * TII
Module.h This file contains the declarations for the Module class.
This file contains the MCSymbolGOFF class.
Machine Check Debug Module
Register const TargetRegisterInfo * TRI
Promote Memory to Register
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
static bool printOperand(raw_ostream &OS, const SelectionDAG *G, const SDValue Value)
static MCInst lowerVecEltExtraction(const MachineInstr *MI, unsigned Opcode)
static uint8_t getSpecifierFromModifier(SystemZCP::SystemZCPModifier Modifier)
static void emitPPA1Name(std::unique_ptr< MCStreamer > &OutStreamer, StringRef OutName)
static void lowerAlignmentHint(const MachineInstr *MI, MCInst &LoweredMI, unsigned Opcode)
#define EMIT_COMMENT(Str)
static const MCSymbolRefExpr * getGlobalOffsetTable(MCContext &Context)
static void printFormattedRegName(const MCAsmInfo *MAI, unsigned RegNo, raw_ostream &OS)
static MCInst lowerRILow(const MachineInstr *MI, unsigned Opcode)
static uint32_t getProductVersion(Module &M)
static std::string getProductID(Module &M)
static MCInst lowerRIHigh(const MachineInstr *MI, unsigned Opcode)
static void printAddress(const MCAsmInfo *MAI, unsigned Base, const MCOperand &DispMO, unsigned Index, raw_ostream &OS)
static time_t getTranslationTime(Module &M)
static const MCSymbolRefExpr * getTLSGetOffset(MCContext &Context)
static void emitPPA1Flags(std::unique_ptr< MCStreamer > &OutStreamer, bool VarArg, bool StackProtector, bool FPRMask, bool VRMask, bool EHBlock, bool HasArgAreaLength, bool HasName)
static MCInst lowerSubvectorStore(const MachineInstr *MI, unsigned Opcode)
static unsigned EmitNop(MCContext &OutContext, MCStreamer &OutStreamer, unsigned NumBytes, const MCSubtargetInfo &STI)
static MCInst lowerVecEltInsertion(const MachineInstr *MI, unsigned Opcode)
static uint32_t getProductRelease(Module &M)
static MCInst lowerSubvectorLoad(const MachineInstr *MI, unsigned Opcode)
static uint32_t getProductPatch(Module &M)
static MCInst lowerRIEfLow(const MachineInstr *MI, unsigned Opcode)
const TargetLoweringObjectFile & getObjFileLowering() const
Return information about object file lowering.
MCSymbol * getSymbol(const GlobalValue *GV) const
void EmitToStreamer(MCStreamer &S, const MCInst &Inst)
TargetMachine & TM
Target machine description.
virtual void emitGlobalAlias(const Module &M, const GlobalAlias &GA)
Align emitAlignment(Align Alignment, const GlobalObject *GV=nullptr, unsigned MaxBytesToEmit=0) const
Emit an alignment directive to the specified power of two boundary.
MachineFunction * MF
The current machine function.
virtual const MCExpr * lowerConstant(const Constant *CV, const Constant *BaseCV=nullptr, uint64_t Offset=0)
Lower the specified LLVM Constant to an MCExpr.
virtual void emitStartOfAsmFile(Module &)
This virtual method can be overridden by targets that want to emit something at the start of their fi...
void recordSled(MCSymbol *Sled, const MachineInstr &MI, SledKind Kind, uint8_t Version=0)
bool doInitialization(Module &M) override
Set up the AsmPrinter when we are working on a new module.
virtual void emitLinkage(const GlobalValue *GV, MCSymbol *GVSym) const
This emits linkage information about GVSym based on GV, if this is supported by the target.
MCSymbol * CurrentFnSym
The symbol for the current function.
MCContext & OutContext
This is the context for the output file that we are streaming.
virtual void emitXXStructorList(const DataLayout &DL, const Constant *List, bool IsCtor)
This method emits llvm.global_ctors or llvm.global_dtors list.
void emitVisibility(MCSymbol *Sym, unsigned Visibility, bool IsDefinition=true) const
This emits visibility information about symbol, if this is supported by the target.
void emitInt32(int Value) const
Emit a long directive and value.
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
const MCAsmInfo & MAI
Target Asm Printer information.
void preprocessXXStructorList(const DataLayout &DL, const Constant *List, SmallVector< Structor, 8 > &Structors)
This method gathers an array of Structors and then sorts them out by Priority.
unsigned getPointerSize() const
Return the pointer size from the TargetMachine.
const DataLayout & getDataLayout() const
Return information about data layout.
virtual void emitFunctionEntryLabel()
EmitFunctionEntryLabel - Emit the label that is the entrypoint for the function.
const MCSubtargetInfo & getSubtargetInfo() const
Return information about subtarget.
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.
This is an important base class in LLVM.
const Constant * stripPointerCasts() const
A parsed version of the target data layout string in and methods for querying it.
LLVM_ABI TypeSize getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
LLVM_ABI unsigned getPointerSize(unsigned AS=0) const
The pointer representation size in bytes, rounded up to a whole number of bytes.
LLVM_ABI const GlobalObject * getAliaseeObject() const
bool hasExternalLinkage() const
LLVM_ABI const GlobalObject * getAliaseeObject() const
bool hasInitializer() const
Definitions have initializers, declarations don't.
This class is intended to be used as a base class for asm properties and features specific to the tar...
unsigned getAssemblerDialect() const
void printExpr(raw_ostream &, const MCExpr &) const
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx, SMLoc Loc=SMLoc())
static LLVM_ABI const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Context object for machine code objects.
LLVM_ABI MCSymbol * createTempSymbol()
Create a temporary symbol with a unique name.
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags)
LLVM_ABI MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
Base class for the full range of assembler expressions which are needed for parsing.
MCInstBuilder & addReg(MCRegister Reg)
Add a new register operand.
MCInstBuilder & addImm(int64_t Val)
Add a new integer immediate operand.
MCInstBuilder & addExpr(const MCExpr *Val)
Add a new MCExpr operand.
Instances of this class represent a single low-level machine instruction.
void addOperand(const MCOperand Op)
void setOpcode(unsigned Op)
Instances of this class represent operands of the MCInst class.
static MCOperand createReg(MCRegister Reg)
static MCOperand createImm(int64_t Val)
MCRegister getReg() const
Returns the register number.
const MCExpr * getExpr() const
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
MCRegister getSubReg(MCRegister Reg, unsigned Idx) const
Returns the physical register number of sub-register "Index" for physical register RegNo.
MCSymbol * getBeginSymbol()
static const MCSpecifierExpr * create(const MCExpr *Expr, Spec S, MCContext &Ctx, SMLoc Loc=SMLoc())
Streaming machine code generation interface.
Generic base class for all target subtargets.
StringRef getExternalName() const
Represent a reference to a symbol from inside an expression.
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx, SMLoc Loc=SMLoc())
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
StringRef getName() const
getName - Get the symbol name.
MachineInstrBundleIterator< const MachineInstr > const_iterator
Abstract base class for all machine specific constantpool value subclasses.
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
bool hasVarSizedObjects() const
This method may be called any time after instruction selection is complete to determine if the stack ...
uint64_t getStackSize() const
Return the number of bytes that must be allocated to hold all of the fixed size frame objects.
uint64_t getMaxCallFrameSize() const
Return the maximum size of a call frame that must be allocated for an outgoing function call.
int64_t getOffsetAdjustment() const
Return the correction for frame offsets.
const std::vector< CalleeSavedInfo > & getCalleeSavedInfo() const
Returns a reference to call saved info vector for the current function.
bool hasStackProtectorIndex() const
int64_t getObjectOffset(int ObjectIdx) const
Return the assigned stack offset of the specified object from the incoming stack pointer.
MCContext & getContext() const
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
Representation of each machine instruction.
ArrayRef< MachineMemOperand * >::iterator mmo_iterator
LLVM_ABI const MachineFunction * getMF() const
Return the function that contains the basic block that this instruction belongs to.
MachineOperand class - Representation of each machine instruction operand.
const GlobalValue * getGlobal() const
bool isReg() const
isReg - Tests if this is a MO_Register operand.
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
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
Register getReg() const
getReg - Returns the register number.
@ MO_GlobalAddress
Address of a global value.
@ MO_ExternalSymbol
Name of external global symbol.
const TargetRegisterInfo * getTargetRegisterInfo() const
iterator find(const KeyT &Key)
A Module instance is used to store all the information related to an LLVM module.
Wrapper class representing virtual and physical registers.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
StringRef str() const
Explicit conversion to StringRef.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
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).
constexpr size_t size() const
Get the string size.
void emitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) override
void emitFunctionBodyEnd() override
Targets can override this to emit stuff after the last basic block in the function.
void emitStartOfAsmFile(Module &M) override
This virtual method can be overridden by targets that want to emit something at the start of their fi...
void emitInstruction(const MachineInstr *MI) override
Targets should implement this to emit instructions.
void emitGlobalAlias(const Module &M, const GlobalAlias &GA) override
bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo, const char *ExtraCode, raw_ostream &OS) override
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant as...
void emitFunctionEntryLabel() override
EmitFunctionEntryLabel - Emit the label that is the entrypoint for the function.
const MCExpr * lowerConstant(const Constant *CV, const Constant *BaseCV=nullptr, uint64_t Offset=0) override
Lower the specified LLVM Constant to an MCExpr.
bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, const char *ExtraCode, raw_ostream &OS) override
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant.
void emitXXStructorList(const DataLayout &DL, const Constant *List, bool IsCtor) override
This method emits llvm.global_ctors or llvm.global_dtors list.
bool doInitialization(Module &M) override
Set up the AsmPrinter when we are working on a new module.
void emitEndOfAsmFile(Module &M) override
This virtual method can be overridden by targets that want to emit something at the end of their file...
A SystemZ-specific constant pool value.
static const char * getRegisterName(MCRegister Reg)
static const char * getRegisterName(MCRegister Reg)
const SystemZInstrInfo * getInstrInfo() const override
const TargetFrameLowering * getFrameLowering() const override
std::pair< MCInst, const MCSubtargetInfo * > MCInstSTIPair
EXRLT2SymMap EXRLTargets2Sym
virtual void emitExternalName(MCSymbol *Sym, StringRef Name)
const LibcallLoweringInfo & getLibcallLoweringInfo() const
virtual Value * getSDagStackGuard(const Module &M, const LibcallLoweringInfo &Libcalls) const
Return the variable that's previously inserted by insertSSPDeclarations, if any, otherwise return nul...
MCSymbol * getSymbol(const GlobalValue *GV) const
Triple - Helper class for working with autoconf configuration names.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Twine concat(const Twine &Suffix) const
static Twine utohexstr(uint64_t Val)
This class implements an extremely fast bulk output stream that can only output to a stream.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Language[]
Key for Kernel::Metadata::mLanguage.
@ Swift
Calling convention for Swift.
@ C
The default llvm calling convention, compatible with C.
LLVM_ABI std::error_code convertToEBCDIC(StringRef Source, SmallVectorImpl< char > &Result)
@ MO_ADA_DATA_SYMBOL_ADDR
@ MO_ADA_DIRECT_FUNC_DESC
@ MO_ADA_INDIRECT_FUNC_DESC
unsigned getRegAsGR32(unsigned Reg)
const unsigned GR64Regs[16]
unsigned getRegAsGRH32(unsigned Reg)
unsigned getRegAsVR128(unsigned Reg)
unsigned getRegAsGR64(unsigned Reg)
constexpr size_t NameSize
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > extract_or_null(Y &&MD)
Extract a Value from Metadata, allowing null.
UtcTime< std::chrono::seconds > toUtcTime(std::time_t T)
Convert a std::time_t to a UtcTime.
This is an optimization pass for GlobalISel generic memory operations.
Target & getTheSystemZTarget()
@ LLVM_MARK_AS_BITMASK_ENUM
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
std::string utostr(uint64_t X, bool isNeg=false)
detail::concat_range< ValueT, RangeTs... > concat(RangeTs &&...Ranges)
Returns a concatenated range across two or more ranges.
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
FunctionAddr VTableAddr uintptr_t uintptr_t Version
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...
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
FunctionAddr VTableAddr uintptr_t uintptr_t Data
DWARFExpression::Operation Op
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI Printable printReg(Register Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubIdx=0, const MachineRegisterInfo *MRI=nullptr)
Prints virtual and physical registers with or without a TRI instance.
@ MCSA_OSLinkage
symbol uses OS linkage (GOFF)
@ MCSA_IndirectSymbol
.indirect_symbol (MachO)
@ MCSA_Global
.type _foo, @gnu_unique_object
@ MCSA_Extern
.extern (XCOFF)
@ MCSA_ELF_TypeObject
.type _foo, STT_OBJECT # aka @object
@ MCSA_ELF_TypeFunction
.type _foo, STT_FUNC # aka @function
This struct is a compact representation of a valid (non-zero power of two) alignment.
llvm.global_ctors and llvm.global_dtors are arrays of Structor structs.
RegisterAsmPrinter - Helper template for registering a target specific assembly printer,...