diff --git a/llvm/lib/Target/SystemZ/SystemZAsmPrinter.h b/llvm/lib/Target/SystemZ/SystemZAsmPrinter.h --- a/llvm/lib/Target/SystemZ/SystemZAsmPrinter.h +++ b/llvm/lib/Target/SystemZ/SystemZAsmPrinter.h @@ -52,6 +52,7 @@ SM.reset(); return AsmPrinter::doInitialization(M); } + void emitFunctionEntryLabel() override; private: void LowerFENTRY_CALL(const MachineInstr &MI, SystemZMCInstLower &MCIL); diff --git a/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp b/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp --- a/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp +++ b/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp @@ -786,6 +786,51 @@ emitStackMaps(SM); } +void SystemZAsmPrinter::emitFunctionEntryLabel() { + const SystemZSubtarget &Subtarget = + static_cast(MF->getSubtarget()); + + if (Subtarget.getTargetTriple().isOSzOS()) { + MCContext &OutContext = OutStreamer->getContext(); + MCSymbol *EPMarkerSym = OutContext.createTempSymbol("CM_", true); + + // EntryPoint Marker + const MachineFrameInfo &MFFrame = MF->getFrameInfo(); + bool IsUsingAlloca = MFFrame.hasVarSizedObjects(); + + // Set Flags + uint8_t Flags = 0; + if (IsUsingAlloca) + Flags |= 0x04; + + // FIXME: Remove the addition of 128 when update to getStackSize is merged. + uint32_t DSASize = MFFrame.getStackSize() + 128; + + // Combine into top 27 bits of DSASize and bottom 5 bits of Flags. + uint32_t DSAAndFlags = DSASize & 0xFFFFFFE0; // (x/32) << 5 + DSAAndFlags |= Flags; + + // Emit entry point marker section. + OutStreamer->AddComment("XPLINK Routine Layout Entry"); + OutStreamer->emitLabel(EPMarkerSym); + OutStreamer->AddComment("Eyecatcher 0x00C300C500C500"); + OutStreamer->emitIntValueInHex(0x00C300C500C500, 7); // Eyecatcher. + OutStreamer->AddComment("Mark Type C'1'"); + OutStreamer->emitInt8(0xF1); // Mark Type. + if (OutStreamer->isVerboseAsm()) { + OutStreamer->AddComment("DSA Size 0x" + Twine::utohexstr(DSASize)); + OutStreamer->AddComment("Entry Flags"); + if (Flags & 0x04) + OutStreamer->AddComment(" Bit 2: 1 = Uses alloca"); + else + OutStreamer->AddComment(" Bit 2: 0 = Does not use alloca"); + } + OutStreamer->emitInt32(DSAAndFlags); + } + + AsmPrinter::emitFunctionEntryLabel(); +} + // Force static initialization. extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeSystemZAsmPrinter() { RegisterAsmPrinter X(getTheSystemZTarget()); diff --git a/llvm/test/MC/GOFF/ppa1.ll b/llvm/test/MC/GOFF/ppa1.ll new file mode 100644 --- /dev/null +++ b/llvm/test/MC/GOFF/ppa1.ll @@ -0,0 +1,15 @@ +; RUN: llc -mtriple s390x-ibm-zos < %s | FileCheck %s + +; CHECK: @@CM_0: * @void_test +; CHECK: * XPLINK Routine Layout Entry +; CHECK: .long 12779717 * Eyecatcher 0x00C300C500C500 +; CHECK: .short 197 +; CHECK: .byte 0 +; CHECK: .byte 241 * Mark Type C'1' +; CHECK: .long 128 * DSA Size 0x80 +; CHECK: * Entry Flags +; CHECK: * Bit 2: 0 = Does not use alloca +define void @void_test() { +entry: + ret void +}