101 if (
MI->memoperands_empty())
106 EE =
MI->memoperands_end(); MMOI != EE; ++MMOI)
107 if ((*MMOI)->getAlign() < Alignment)
108 Alignment = (*MMOI)->getAlign();
110 unsigned AlignmentHint = 0;
111 if (Alignment >=
Align(16))
113 else if (Alignment >=
Align(8))
115 if (AlignmentHint == 0)
129 .
addReg(
MI->getOperand(3).getReg());
167void SystemZAsmPrinter::emitCallInformation(CallType CT) {
169 MCInstBuilder(SystemZ::BCRAsm)
174uint32_t SystemZAsmPrinter::AssociatedDataAreaTable::insert(
const MCSymbol *Sym,
176 auto Key = std::make_pair(Sym, SlotKind);
177 auto It = Displacements.find(
Key);
179 if (It != Displacements.end())
193 uint32_t Displacement = NextDisplacement;
194 Displacements[std::make_pair(Sym, SlotKind)] = NextDisplacement;
195 NextDisplacement +=
Length;
201SystemZAsmPrinter::AssociatedDataAreaTable::insert(
const MachineOperand MO) {
206 assert(Sym &&
"No symbol");
210 assert(Sym &&
"No symbol");
215 return insert(Sym, ADAslotType);
219 SystemZ_MC::verifyInstructionPredicates(
MI->getOpcode(),
224 switch (
MI->getOpcode()) {
225 case SystemZ::Return:
230 case SystemZ::Return_XPLINK:
237 case SystemZ::CondReturn:
244 case SystemZ::CondReturn_XPLINK:
253 case SystemZ::CRBReturn:
262 case SystemZ::CGRBReturn:
271 case SystemZ::CIBReturn:
280 case SystemZ::CGIBReturn:
289 case SystemZ::CLRBReturn:
298 case SystemZ::CLGRBReturn:
307 case SystemZ::CLIBReturn:
316 case SystemZ::CLGIBReturn:
325 case SystemZ::CallBRASL_XPLINK64:
327 .addReg(SystemZ::R7D)
328 .addExpr(
Lower.getExpr(
MI->getOperand(0),
330 emitCallInformation(CallType::BRASL7);
333 case SystemZ::CallBASR_XPLINK64:
335 .addReg(SystemZ::R7D)
336 .addReg(
MI->getOperand(0).getReg()));
337 emitCallInformation(CallType::BASR76);
340 case SystemZ::CallBASR_STACKEXT:
342 .addReg(SystemZ::R3D)
343 .addReg(
MI->getOperand(0).getReg()));
344 emitCallInformation(CallType::BASR33);
347 case SystemZ::ADA_ENTRY_VALUE:
348 case SystemZ::ADA_ENTRY: {
351 uint32_t Disp = ADATable.insert(
MI->getOperand(1));
352 Register TargetReg =
MI->getOperand(0).getReg();
355 Disp +=
MI->getOperand(3).getImm();
356 bool LoadAddr =
MI->getOpcode() == SystemZ::ADA_ENTRY;
358 unsigned Op0 = LoadAddr ? SystemZ::LA : SystemZ::LG;
359 unsigned Op =
TII->getOpcodeForOffset(Op0, Disp);
363 if (TargetReg != ADAReg) {
364 IndexReg = TargetReg;
368 MCInstBuilder(SystemZ::LLILF).addReg(TargetReg).addImm(Disp));
385 case SystemZ::CallBRASL:
391 case SystemZ::CallBASR:
394 .
addReg(
MI->getOperand(0).getReg());
397 case SystemZ::CallJG:
402 case SystemZ::CallBRCL:
409 case SystemZ::CallBR:
411 .
addReg(
MI->getOperand(0).getReg());
414 case SystemZ::CallBCR:
418 .
addReg(
MI->getOperand(2).getReg());
421 case SystemZ::CRBCall:
430 case SystemZ::CGRBCall:
439 case SystemZ::CIBCall:
448 case SystemZ::CGIBCall:
457 case SystemZ::CLRBCall:
466 case SystemZ::CLGRBCall:
475 case SystemZ::CLIBCall:
484 case SystemZ::CLGIBCall:
493 case SystemZ::TLS_GDCALL:
501 case SystemZ::TLS_LDCALL:
515 case SystemZ::IILF64:
518 .
addImm(
MI->getOperand(2).getImm());
521 case SystemZ::IIHF64:
524 .
addImm(
MI->getOperand(2).getImm());
527 case SystemZ::RISBHH:
528 case SystemZ::RISBHL:
532 case SystemZ::RISBLH:
533 case SystemZ::RISBLL:
537 case SystemZ::VLVGP32:
600 case SystemZ::LFER_16:
608 case SystemZ::LEFR_16:
612#define LOWER_LOW(NAME) \
613 case SystemZ::NAME##64: LoweredMI = lowerRILow(MI, SystemZ::NAME); break
629#define LOWER_HIGH(NAME) \
630 case SystemZ::NAME##64: LoweredMI = lowerRIHigh(MI, SystemZ::NAME); break
646 case SystemZ::Serialize:
659 case SystemZ::Trap: {
672 case SystemZ::CondTrap: {
685 case TargetOpcode::FENTRY_CALL:
689 case TargetOpcode::STACKMAP:
693 case TargetOpcode::PATCHPOINT:
697 case TargetOpcode::PATCHABLE_FUNCTION_ENTER:
698 LowerPATCHABLE_FUNCTION_ENTER(*
MI,
Lower);
701 case TargetOpcode::PATCHABLE_RET:
702 LowerPATCHABLE_RET(*
MI,
Lower);
705 case TargetOpcode::PATCHABLE_FUNCTION_EXIT:
708 case TargetOpcode::PATCHABLE_TAIL_CALL:
712 "around this assert.");
714 case SystemZ::EXRL_Pseudo: {
715 unsigned TargetInsOpc =
MI->getOperand(0).getImm();
716 Register LenMinus1Reg =
MI->getOperand(1).getReg();
717 Register DestReg =
MI->getOperand(2).getReg();
718 int64_t DestDisp =
MI->getOperand(3).getImm();
720 int64_t SrcDisp =
MI->getOperand(5).getImm();
737 MCInstBuilder(SystemZ::EXRL).addReg(LenMinus1Reg).addExpr(Dot));
743 case SystemZ::EH_SjLj_Setup:
761 else if (NumBytes < 4) {
763 MCInstBuilder(SystemZ::BCRAsm).addImm(0).addReg(SystemZ::R0D), STI);
766 else if (NumBytes < 6) {
768 MCInstBuilder(SystemZ::BCAsm).addImm(0).addReg(0).addImm(0).addReg(0),
777 MCInstBuilder(SystemZ::BRCLAsm).addImm(0).addExpr(Dot), STI);
782void SystemZAsmPrinter::LowerFENTRY_CALL(
const MachineInstr &
MI,
783 SystemZMCInstLower &
Lower) {
784 MCContext &Ctx =
MF->getContext();
785 if (
MF->getFunction().hasFnAttribute(
"mrecord-mcount")) {
795 if (
MF->getFunction().hasFnAttribute(
"mnop-mcount")) {
801 const MCSymbolRefExpr *
Op =
804 MCInstBuilder(SystemZ::BRASL).addReg(SystemZ::R0D).addExpr(
Op),
808void SystemZAsmPrinter::LowerSTACKMAP(
const MachineInstr &
MI) {
809 auto *
TII =
MF->getSubtarget<SystemZSubtarget>().getInstrInfo();
811 unsigned NumNOPBytes =
MI.getOperand(1).getImm();
817 SM.recordStackMap(*MILabel,
MI);
818 assert(NumNOPBytes % 2 == 0 &&
"Invalid number of NOP bytes requested!");
821 unsigned ShadowBytes = 0;
822 const MachineBasicBlock &
MBB = *
MI.getParent();
825 while (ShadowBytes < NumNOPBytes) {
827 MII->getOpcode() == TargetOpcode::PATCHPOINT ||
828 MII->getOpcode() == TargetOpcode::STACKMAP)
830 ShadowBytes +=
TII->getInstSizeInBytes(*MII);
837 while (ShadowBytes < NumNOPBytes)
844void SystemZAsmPrinter::LowerPATCHPOINT(
const MachineInstr &
MI,
845 SystemZMCInstLower &
Lower) {
850 SM.recordPatchPoint(*MILabel,
MI);
851 PatchPointOpers Opers(&
MI);
853 unsigned EncodedBytes = 0;
854 const MachineOperand &CalleeMO = Opers.getCallTarget();
856 if (CalleeMO.
isImm()) {
857 uint64_t CallTarget = CalleeMO.
getImm();
859 unsigned ScratchIdx = -1;
860 unsigned ScratchReg = 0;
862 ScratchIdx = Opers.getNextScratchIdx(ScratchIdx + 1);
863 ScratchReg =
MI.getOperand(ScratchIdx).getReg();
864 }
while (ScratchReg == SystemZ::R0D);
869 .addImm(CallTarget & 0xFFFFFFFF));
871 if (CallTarget >> 32) {
874 .addImm(CallTarget >> 32));
879 .addReg(SystemZ::R14D)
880 .addReg(ScratchReg));
886 .addReg(SystemZ::R14D)
892 unsigned NumBytes = Opers.getNumPatchBytes();
893 assert(NumBytes >= EncodedBytes &&
894 "Patchpoint can't request size less than the length of a call.");
895 assert((NumBytes - EncodedBytes) % 2 == 0 &&
896 "Invalid number of NOP bytes requested!");
897 while (EncodedBytes < NumBytes)
902void SystemZAsmPrinter::LowerPATCHABLE_FUNCTION_ENTER(
903 const MachineInstr &
MI, SystemZMCInstLower &
Lower) {
909 if (
F.hasFnAttribute(
"patchable-function-entry")) {
913 if (
F.getFnAttribute(
"patchable-function-entry")
915 .getAsInteger(10, Num))
920 for (
unsigned I = 0;
I < Num; ++
I)
934 bool HasVectorFeature =
935 TM.getMCSubtargetInfo()->hasFeature(SystemZ::FeatureVector) &&
936 !
TM.getMCSubtargetInfo()->hasFeature(SystemZ::FeatureSoftFloat);
938 HasVectorFeature ?
"__xray_FunctionEntryVec" :
"__xray_FunctionEntry");
943 MCInstBuilder(SystemZ::J)
947 MCInstBuilder(SystemZ::LLILF).addReg(SystemZ::R2D).addImm(0));
949 .addReg(SystemZ::R14D)
956void SystemZAsmPrinter::LowerPATCHABLE_RET(
const MachineInstr &
MI,
957 SystemZMCInstLower &
Lower) {
958 unsigned OpCode =
MI.getOperand(0).getImm();
959 MCSymbol *FallthroughLabel =
nullptr;
960 if (OpCode == SystemZ::CondReturn) {
961 FallthroughLabel =
OutContext.createTempSymbol();
962 int64_t Cond0 =
MI.getOperand(1).getImm();
963 int64_t Cond1 =
MI.getOperand(2).getImm();
966 .addImm(Cond1 ^ Cond0)
979 bool HasVectorFeature =
980 TM.getMCSubtargetInfo()->hasFeature(SystemZ::FeatureVector) &&
981 !
TM.getMCSubtargetInfo()->hasFeature(SystemZ::FeatureSoftFloat);
983 HasVectorFeature ?
"__xray_FunctionExitVec" :
"__xray_FunctionExit");
987 MCInstBuilder(SystemZ::BR).addReg(SystemZ::R14D));
990 MCInstBuilder(SystemZ::LLILF).addReg(SystemZ::R2D).addImm(0));
994 if (FallthroughLabel)
1002void SystemZAsmPrinter::emitAttributes(
Module &M) {
1003 if (
M.getModuleFlag(
"s390x-visible-vector-ABI")) {
1004 bool HasVectorFeature =
1005 TM.getMCSubtargetInfo()->hasFeature(SystemZ::FeatureVector);
1006 OutStreamer->emitGNUAttribute(8, HasVectorFeature ? 2 : 1);
1041 if (!
TM.getTargetTriple().isOSBinFormatGOFF())
1046 if (Structors.
empty())
1054 static_cast<MCSectionGOFF *
>(Obj.getStaticXtorSection(S.Priority));
1064 uint32_t XtorPriority = Section->getPRAttributes().SortKey;
1067 assert(GV &&
"C++ xxtor pointer was not a GlobalValue!");
1072 unsigned PointerSizeInBytes =
DL.getPointerSize();
1075 const MCExpr *ADAFuncRefExpr;
1080 assert(ADASection &&
"ADA section must exist for GOFF targets!");
1082 assert(ADASym &&
"ADA symbol should already be set!");
1091 OutStreamer->emitValue(ADAFuncRefExpr, PointerSizeInBytes);
1095 OutStreamer->emitValue(ADAFuncRefExpr, PointerSizeInBytes);
1125 else if (MCOp.
isImm())
1134 const MCOperand &DispMO,
unsigned Index,
1137 if (
Base || Index) {
1151 const char *ExtraCode,
1157 if (ExtraCode[0] ==
'N' && !ExtraCode[1] && MO.
isReg() &&
1158 SystemZ::GR128BitRegClass.contains(MO.
getReg()))
1165 MCOp =
Lower.lowerOperand(MO);
1173 const char *ExtraCode,
1175 if (ExtraCode && ExtraCode[0] && !ExtraCode[1]) {
1176 switch (ExtraCode[0]) {
1183 OS <<
MI->getOperand(OpNo + 1).getImm();
1192 MI->getOperand(OpNo + 2).getReg(), OS);
1205void SystemZAsmPrinter::emitADASection() {
1211 unsigned EmittedBytes = 0;
1212 for (
auto &Entry : ADATable.getTable()) {
1215 std::tie(Sym, SlotKind) = Entry.first;
1216 unsigned Offset = Entry.second;
1217 assert(
Offset == EmittedBytes &&
"Offset not as expected");
1219#define EMIT_COMMENT(Str) \
1220 OutStreamer->AddComment(Twine("Offset ") \
1221 .concat(utostr(Offset)) \
1222 .concat(" " Str " ") \
1223 .concat(Sym->getName()));
1237 EmittedBytes += PointerSize * 2;
1245 EmittedBytes += PointerSize;
1259 EmittedBytes += PointerSize;
1271 std::string ProductID;
1272 if (
auto *MD = M.getModuleFlag(
"zos_product_id"))
1274 if (ProductID.empty())
1281 M.getModuleFlag(
"zos_product_major_version")))
1282 return VersionVal->getZExtValue();
1283 return LLVM_VERSION_MAJOR;
1288 M.getModuleFlag(
"zos_product_minor_version")))
1289 return ReleaseVal->getZExtValue();
1290 return LLVM_VERSION_MINOR;
1295 M.getModuleFlag(
"zos_product_patchlevel")))
1296 return PatchVal->getZExtValue();
1297 return LLVM_VERSION_PATCH;
1301 std::time_t Time = 0;
1303 M.getModuleFlag(
"zos_translation_time"))) {
1304 long SecondsSinceEpoch = Val->getSExtValue();
1305 Time =
static_cast<time_t
>(SecondsSinceEpoch);
1310void SystemZAsmPrinter::emitIDRLSection(
Module &M) {
1313 constexpr unsigned IDRLDataLength = 30;
1321 SmallString<IDRLDataLength + 1> TempStr;
1322 raw_svector_ostream
O(TempStr);
1323 O <<
formatv(
"{0,-10}{1,0-2:d}{2,0-2:d}{3:%Y%m%d%H%M%S}{4,0-2}",
1324 ProductID.substr(0, 10).c_str(), ProductVersion, ProductRelease,
1326 SmallString<IDRLDataLength>
Data;
1337 if (
TM.getTargetTriple().isOSzOS()) {
1349 CurrentFnPPA1Sym =
nullptr;
1350 CurrentFnEPMarkerSym =
nullptr;
1356 bool EHBlock,
bool HasArgAreaLength,
bool HasName) {
1357 enum class PPA1Flag1 :
uint8_t {
1358 DSA64Bit = (0x80 >> 0),
1359 VarArg = (0x80 >> 7),
1362 enum class PPA1Flag2 :
uint8_t {
1363 ExternalProcedure = (0x80 >> 0),
1364 STACKPROTECTOR = (0x80 >> 3),
1367 enum class PPA1Flag3 :
uint8_t {
1368 HasArgAreaLength = (0x80 >> 1),
1369 FPRMask = (0x80 >> 2),
1372 enum class PPA1Flag4 :
uint8_t {
1373 EPMOffsetPresent = (0x80 >> 0),
1374 VRMask = (0x80 >> 2),
1375 EHBlock = (0x80 >> 3),
1376 ProcedureNamePresent = (0x80 >> 7),
1381 auto Flags1 = PPA1Flag1(0);
1382 auto Flags2 = PPA1Flag2::ExternalProcedure;
1383 auto Flags3 = PPA1Flag3(0);
1384 auto Flags4 = PPA1Flag4::EPMOffsetPresent;
1386 Flags1 |= PPA1Flag1::DSA64Bit;
1389 Flags1 |= PPA1Flag1::VarArg;
1392 Flags2 |= PPA1Flag2::STACKPROTECTOR;
1394 if (HasArgAreaLength)
1395 Flags3 |= PPA1Flag3::HasArgAreaLength;
1399 Flags3 |= PPA1Flag3::FPRMask;
1402 Flags4 |= PPA1Flag4::VRMask;
1405 Flags4 |= PPA1Flag4::EHBlock;
1408 Flags4 |= PPA1Flag4::ProcedureNamePresent;
1411 if ((Flags1 & PPA1Flag1::DSA64Bit) == PPA1Flag1::DSA64Bit)
1412 OutStreamer->AddComment(
" Bit 0: 1 = 64-bit DSA");
1414 OutStreamer->AddComment(
" Bit 0: 0 = 32-bit DSA");
1415 if ((Flags1 & PPA1Flag1::VarArg) == PPA1Flag1::VarArg)
1416 OutStreamer->AddComment(
" Bit 7: 1 = Vararg function");
1420 if ((Flags2 & PPA1Flag2::ExternalProcedure) == PPA1Flag2::ExternalProcedure)
1421 OutStreamer->AddComment(
" Bit 0: 1 = External procedure");
1422 if ((Flags2 & PPA1Flag2::STACKPROTECTOR) == PPA1Flag2::STACKPROTECTOR)
1423 OutStreamer->AddComment(
" Bit 3: 1 = STACKPROTECT is enabled");
1425 OutStreamer->AddComment(
" Bit 3: 0 = STACKPROTECT is not enabled");
1429 if ((Flags3 & PPA1Flag3::HasArgAreaLength) == PPA1Flag3::HasArgAreaLength)
1431 " Bit 1: 1 = Argument Area Length is in optional area");
1432 if ((Flags3 & PPA1Flag3::FPRMask) == PPA1Flag3::FPRMask)
1433 OutStreamer->AddComment(
" Bit 2: 1 = FP Reg Mask is in optional area");
1435 static_cast<uint8_t>(Flags3));
1438 if ((Flags4 & PPA1Flag4::VRMask) == PPA1Flag4::VRMask)
1439 OutStreamer->AddComment(
" Bit 2: 1 = Vector Reg Mask is in optional area");
1440 if ((Flags4 & PPA1Flag4::EHBlock) == PPA1Flag4::EHBlock)
1441 OutStreamer->AddComment(
" Bit 3: 1 = C++ EH block");
1442 if ((Flags4 & PPA1Flag4::ProcedureNamePresent) ==
1443 PPA1Flag4::ProcedureNamePresent)
1444 OutStreamer->AddComment(
" Bit 7: 1 = Name Length and Name");
1456 OutName = OutName.
substr(0, UINT16_MAX);
1457 OutSize = UINT16_MAX;
1460 uint8_t ExtraZeros = 4 - ((2 + OutSize) % 4);
1464 OutName = OutnameConv.
str();
1473void SystemZAsmPrinter::emitPPA1(MCSymbol *FnEndSym) {
1474 assert(PPA2Sym !=
nullptr &&
"PPA2 Symbol not defined");
1476 const TargetRegisterInfo *
TRI =
MF->getRegInfo().getTargetRegisterInfo();
1477 const SystemZSubtarget &Subtarget =
MF->getSubtarget<SystemZSubtarget>();
1478 const auto TargetHasVector = Subtarget.hasVector();
1480 const SystemZMachineFunctionInfo *ZFI =
1481 MF->getInfo<SystemZMachineFunctionInfo>();
1482 const auto *ZFL =
static_cast<const SystemZXPLINKFrameLowering *
>(
1484 const MachineFrameInfo &MFFrame =
MF->getFrameInfo();
1488 uint16_t SavedGPRMask = 0;
1489 uint16_t SavedFPRMask = 0;
1490 uint8_t SavedVRMask = 0;
1491 int64_t OffsetFPR = 0;
1492 int64_t OffsetVR = 0;
1493 const int64_t TopOfStack =
1500 I &&
E &&
I <=
E; ++
I) {
1502 assert(V < 16 &&
"GPR index out of range");
1503 SavedGPRMask |= 1 << (15 -
V);
1506 for (
auto &CS : CSI) {
1507 unsigned Reg = CS.getReg();
1508 unsigned I =
TRI->getEncodingValue(
Reg);
1511 assert(
I < 16 &&
"FPR index out of range");
1512 SavedFPRMask |= 1 << (15 -
I);
1514 if (Temp < OffsetFPR)
1516 }
else if (SystemZ::VR128BitRegClass.
contains(
Reg)) {
1517 assert(
I >= 16 &&
I <= 23 &&
"VPR index out of range");
1518 unsigned BitNum =
I - 16;
1519 SavedVRMask |= 1 << (7 - BitNum);
1521 if (Temp < OffsetVR)
1527 OffsetFPR += (OffsetFPR < 0) ? TopOfStack : 0;
1528 OffsetVR += (OffsetVR < 0) ? TopOfStack : 0;
1531 uint8_t FrameReg =
TRI->getEncodingValue(
TRI->getFrameRegister(*
MF));
1532 uint8_t AllocaReg = ZFL->hasFP(*
MF) ? FrameReg : 0;
1533 assert(AllocaReg < 16 &&
"Can't have alloca register larger than 15");
1537 uint32_t FrameAndFPROffset = 0;
1539 uint64_t FPRSaveAreaOffset = OffsetFPR;
1540 assert(FPRSaveAreaOffset < 0x10000000 &&
"Offset out of range");
1542 FrameAndFPROffset = FPRSaveAreaOffset & 0x0FFFFFFF;
1543 FrameAndFPROffset |= FrameReg << 28;
1547 uint32_t FrameAndVROffset = 0;
1548 if (TargetHasVector && SavedVRMask) {
1549 uint64_t VRSaveAreaOffset = OffsetVR;
1550 assert(VRSaveAreaOffset < 0x10000000 &&
"Offset out of range");
1552 FrameAndVROffset = VRSaveAreaOffset & 0x0FFFFFFF;
1553 FrameAndVROffset |= FrameReg << 28;
1566 OutStreamer->emitAbsoluteSymbolDiff(PPA2Sym, CurrentFnPPA1Sym, 4);
1568 bool NeedEmitEHBlock = !
MF->getLandingPads().empty();
1580 bool HasArgAreaLength =
1584 MF->getFunction().hasName() &&
MF->getFunction().getName().size() > 0;
1588 TargetHasVector && SavedVRMask != 0, NeedEmitEHBlock,
1589 HasArgAreaLength, HasName);
1595 OutStreamer->emitAbsoluteSymbolDiff(FnEndSym, CurrentFnEPMarkerSym, 4);
1597 if (HasArgAreaLength) {
1609 OutStreamer->AddComment(Twine(
" Bit 0-3: Register R")
1612 OutStreamer->AddComment(Twine(
" Bit 4-31: Offset ")
1621 if (TargetHasVector && SavedVRMask) {
1627 OutStreamer->AddComment(Twine(
" Bit 0-3: Register R")
1630 OutStreamer->AddComment(Twine(
" Bit 4-31: Offset ")
1638 if (NeedEmitEHBlock) {
1640 MF->getFunction().getPersonalityFn()->stripPointerCasts());
1642 Per ?
MF->getTarget().getSymbol(Per) :
nullptr;
1643 assert(PersonalityRoutine &&
"Missing personality routine");
1653 MCSymbol *GCCEH =
MF->getContext().getOrCreateSymbol(
1654 Twine(
"GCC_except_table") + Twine(
MF->getFunctionNumber()));
1664 OutStreamer->emitAbsoluteSymbolDiff(CurrentFnEPMarkerSym, CurrentFnPPA1Sym,
1669 if (
TM.getTargetTriple().isOSzOS())
1674void SystemZAsmPrinter::emitPPA2(
Module &M) {
1680 const char *StartSymbolName =
"CELQSTRT";
1699 ProductRelease, ProductPatch);
1704 enum class PPA2MemberId :
uint8_t {
1709 enum class PPA2MemberSubId :
uint8_t {
1715 LLVMBasedLang = 0xe7,
1718 enum class PPA2Flags : uint8_t {
1719 CompileForBinaryFloatingPoint = 0x80,
1720 CompiledWithXPLink = 0x01,
1721 CompiledUnitASCII = 0x04,
1722 HasServiceInfo = 0x20,
1725 PPA2MemberSubId MemberSubId = PPA2MemberSubId::LLVMBasedLang;
1726 if (
auto *MD =
M.getModuleFlag(
"zos_cu_language")) {
1728 MemberSubId = StringSwitch<PPA2MemberSubId>(Language)
1729 .Case(
"C", PPA2MemberSubId::C)
1730 .Case(
"C++", PPA2MemberSubId::CXX)
1731 .Case(
"Swift", PPA2MemberSubId::Swift)
1732 .Case(
"Go", PPA2MemberSubId::Go)
1733 .Default(PPA2MemberSubId::LLVMBasedLang);
1738 OutStreamer->emitInt8(
static_cast<uint8_t
>(PPA2MemberId::LE_C_Runtime));
1739 OutStreamer->emitInt8(
static_cast<uint8_t
>(MemberSubId));
1742 OutStreamer->emitAbsoluteSymbolDiff(CELQSTRT, PPA2Sym, 4);
1744 OutStreamer->emitAbsoluteSymbolDiff(DateVersionSym, PPA2Sym, 4);
1747 uint8_t Flgs =
static_cast<uint8_t
>(PPA2Flags::CompileForBinaryFloatingPoint);
1748 Flgs |=
static_cast<uint8_t
>(PPA2Flags::CompiledWithXPLink);
1750 bool IsASCII =
true;
1751 if (
auto *MD =
M.getModuleFlag(
"zos_le_char_mode")) {
1753 if (CharMode ==
"ebcdic")
1755 else if (CharMode !=
"ascii")
1757 {},
"Only ascii or ebcdic are allowed for zos_le_char_mode");
1760 Flgs |=
static_cast<uint8_t
>(
1761 PPA2Flags::CompiledUnitASCII);
1783 OutStreamer->emitAbsoluteSymbolDiff(PPA2Sym, CELQSTRT, 8);
1790 if (Subtarget.getTargetTriple().isOSzOS()) {
1794 std::string
N(
MF->getFunction().hasName()
1798 CurrentFnEPMarkerSym =
1817 uint32_t DSAAndFlags = DSASize & 0xFFFFFFE0;
1818 DSAAndFlags |= Flags;
1821 OutStreamer->AddComment(
"XPLINK Routine Layout Entry");
1823 OutStreamer->AddComment(
"Eyecatcher 0x00C300C500C500");
1824 OutStreamer->emitIntValueInHex(0x00C300C500C500, 7);
1828 OutStreamer->emitAbsoluteSymbolDiff(CurrentFnPPA1Sym, CurrentFnEPMarkerSym,
1834 OutStreamer->AddComment(
" Bit 1: 1 = Leaf function");
1836 OutStreamer->AddComment(
" Bit 1: 0 = Non-leaf function");
1838 OutStreamer->AddComment(
" Bit 2: 1 = Uses alloca");
1840 OutStreamer->AddComment(
" Bit 2: 0 = Does not use alloca");
1851 "SystemZ Assembly Printer",
false,
false)
1855LLVMInitializeSystemZAsmPrinter() {
unsigned const MachineRegisterInfo * MRI
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)
static TableGen::Emitter::OptClass< SkeletonEmitter > X("gen-skeleton-class", "Generate example skeleton class")
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.
const MCAsmInfo * MAI
Target Asm Printer information.
MachineFunction * MF
The current machine function.
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)
void emitAlignment(Align Alignment, const GlobalObject *GV=nullptr, unsigned MaxBytesToEmit=0) const
Emit an alignment directive to the specified power of two boundary.
MCContext & OutContext
This is the context for the output file that we are streaming.
MCSymbol * createTempSymbol(const Twine &Name) const
virtual void emitXXStructorList(const DataLayout &DL, const Constant *List, bool IsCtor)
This method emits llvm.global_ctors or llvm.global_dtors list.
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.
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.
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.
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.
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...
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.
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.
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.
StringRef - Represent a constant reference to a string, i.e.
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
constexpr size_t size() const
size - 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.
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.
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.
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)
SystemZ::GPRRegs getSpillGPRRegs() const
unsigned getSizeOfFnParams() const
const SystemZInstrInfo * getInstrInfo() const override
const TargetFrameLowering * getFrameLowering() const override
std::pair< MCInst, const MCSubtargetInfo * > MCInstSTIPair
EXRLT2SymMap EXRLTargets2Sym
MCSymbol * getSymbol(const GlobalValue *GV) const
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
LLVM_ABI std::string str() const
Return the twine contents as a std::string.
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
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
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,...