@@ -818,7 +818,7 @@ bool SystemZELFFrameLowering::usePackedStack(MachineFunction &MF) const {
818818}
819819
820820SystemZXPLINKFrameLowering::SystemZXPLINKFrameLowering ()
821- : SystemZFrameLowering(TargetFrameLowering::StackGrowsDown , Align(32 ), 0 ,
821+ : SystemZFrameLowering(TargetFrameLowering::StackGrowsUp , Align(32 ), 128 ,
822822 Align(32 ), /* StackRealignable */ false),
823823 RegSpillOffsets(-1 ) {
824824
@@ -990,183 +990,12 @@ bool SystemZXPLINKFrameLowering::spillCalleeSavedRegisters(
990990 return true ;
991991}
992992
993- bool SystemZXPLINKFrameLowering::restoreCalleeSavedRegisters (
994- MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI,
995- MutableArrayRef<CalleeSavedInfo> CSI, const TargetRegisterInfo *TRI) const {
996-
997- if (CSI.empty ())
998- return false ;
999-
1000- MachineFunction &MF = *MBB.getParent ();
1001- SystemZMachineFunctionInfo *ZFI = MF.getInfo <SystemZMachineFunctionInfo>();
1002- const SystemZSubtarget &Subtarget = MF.getSubtarget <SystemZSubtarget>();
1003- const TargetInstrInfo *TII = Subtarget.getInstrInfo ();
1004- auto &Regs = Subtarget.getSpecialRegisters <SystemZXPLINK64Registers>();
1005-
1006- DebugLoc DL = MBBI != MBB.end () ? MBBI->getDebugLoc () : DebugLoc ();
1007-
1008- // Restore FPRs in the normal TargetInstrInfo way.
1009- for (unsigned I = 0 , E = CSI.size (); I != E; ++I) {
1010- unsigned Reg = CSI[I].getReg ();
1011- if (SystemZ::FP64BitRegClass.contains (Reg))
1012- TII->loadRegFromStackSlot (MBB, MBBI, Reg, CSI[I].getFrameIdx (),
1013- &SystemZ::FP64BitRegClass, TRI);
1014- if (SystemZ::VR128BitRegClass.contains (Reg))
1015- TII->loadRegFromStackSlot (MBB, MBBI, Reg, CSI[I].getFrameIdx (),
1016- &SystemZ::VR128BitRegClass, TRI);
1017- }
1018-
1019- // Restore call-saved GPRs (but not call-clobbered varargs, which at
1020- // this point might hold return values).
1021- SystemZ::GPRRegs RestoreGPRs = ZFI->getRestoreGPRRegs ();
1022- if (RestoreGPRs.LowGPR ) {
1023- assert (isInt<20 >(Regs.getStackPointerBias () + RestoreGPRs.GPROffset ));
1024- if (RestoreGPRs.LowGPR == RestoreGPRs.HighGPR )
1025- // Build an LG/L instruction.
1026- BuildMI (MBB, MBBI, DL, TII->get (SystemZ::LG), RestoreGPRs.LowGPR )
1027- .addReg (Regs.getStackPointerRegister ())
1028- .addImm (Regs.getStackPointerBias () + RestoreGPRs.GPROffset )
1029- .addReg (0 );
1030- else {
1031- // Build an LMG/LM instruction.
1032- MachineInstrBuilder MIB = BuildMI (MBB, MBBI, DL, TII->get (SystemZ::LMG));
1033-
1034- // Add the explicit register operands.
1035- MIB.addReg (RestoreGPRs.LowGPR , RegState::Define);
1036- MIB.addReg (RestoreGPRs.HighGPR , RegState::Define);
1037-
1038- // Add the address.
1039- MIB.addReg (Regs.getStackPointerRegister ());
1040- MIB.addImm (Regs.getStackPointerBias () + RestoreGPRs.GPROffset );
1041-
1042- // Do a second scan adding regs as being defined by instruction
1043- for (unsigned I = 0 , E = CSI.size (); I != E; ++I) {
1044- unsigned Reg = CSI[I].getReg ();
1045- if (Reg > RestoreGPRs.LowGPR && Reg < RestoreGPRs.HighGPR )
1046- MIB.addReg (Reg, RegState::ImplicitDefine);
1047- }
1048- }
1049- }
1050-
1051- return true ;
1052- }
1053-
1054993void SystemZXPLINKFrameLowering::emitPrologue (MachineFunction &MF,
1055- MachineBasicBlock &MBB) const {
1056- assert (&MF.front () == &MBB && " Shrink-wrapping not yet supported" );
1057- const SystemZSubtarget &Subtarget = MF.getSubtarget <SystemZSubtarget>();
1058- SystemZMachineFunctionInfo *ZFI = MF.getInfo <SystemZMachineFunctionInfo>();
1059- MachineBasicBlock::iterator MBBI = MBB.begin ();
1060- auto *ZII = static_cast <const SystemZInstrInfo *>(Subtarget.getInstrInfo ());
1061- auto &Regs = Subtarget.getSpecialRegisters <SystemZXPLINK64Registers>();
1062- MachineFrameInfo &MFFrame = MF.getFrameInfo ();
1063- MachineInstr *StoreInstr = nullptr ;
1064- bool HasFP = hasFP (MF);
1065- // Debug location must be unknown since the first debug location is used
1066- // to determine the end of the prologue.
1067- DebugLoc DL;
1068- uint64_t Offset = 0 ;
1069-
1070- // TODO: Support leaf functions; only add size of save+reserved area when
1071- // function is non-leaf.
1072- MFFrame.setStackSize (MFFrame.getStackSize () + Regs.getCallFrameSize ());
1073- uint64_t StackSize = MFFrame.getStackSize ();
1074-
1075- // FIXME: Implement support for large stack sizes, when the stack extension
1076- // routine needs to be called.
1077- if (StackSize > 1024 * 1024 ) {
1078- llvm_unreachable (" Huge Stack Frame not yet supported on z/OS" );
1079- }
1080-
1081- if (ZFI->getSpillGPRRegs ().LowGPR ) {
1082- // Skip over the GPR saves.
1083- if ((MBBI != MBB.end ()) && ((MBBI->getOpcode () == SystemZ::STMG))) {
1084- const int Operand = 3 ;
1085- // Now we can set the offset for the operation, since now the Stack
1086- // has been finalized.
1087- Offset = Regs.getStackPointerBias () + MBBI->getOperand (Operand).getImm ();
1088- // Maximum displacement for STMG instruction.
1089- if (isInt<20 >(Offset - StackSize))
1090- Offset -= StackSize;
1091- else
1092- StoreInstr = &*MBBI;
1093- MBBI->getOperand (Operand).setImm (Offset);
1094- ++MBBI;
1095- } else
1096- llvm_unreachable (" Couldn't skip over GPR saves" );
1097- }
1098-
1099- if (StackSize) {
1100- MachineBasicBlock::iterator InsertPt = StoreInstr ? StoreInstr : MBBI;
1101- // Allocate StackSize bytes.
1102- int64_t Delta = -int64_t (StackSize);
1103-
1104- // In case the STM(G) instruction also stores SP (R4), but the displacement
1105- // is too large, the SP register is manipulated first before storing,
1106- // resulting in the wrong value stored and retrieved later. In this case, we
1107- // need to temporarily save the value of SP, and store it later to memory.
1108- if (StoreInstr && HasFP) {
1109- // Insert LR r0,r4 before STMG instruction.
1110- BuildMI (MBB, InsertPt, DL, ZII->get (SystemZ::LGR))
1111- .addReg (SystemZ::R0D, RegState::Define)
1112- .addReg (SystemZ::R4D);
1113- // Insert ST r0,xxx(,r4) after STMG instruction.
1114- BuildMI (MBB, MBBI, DL, ZII->get (SystemZ::STG), SystemZ::R0D)
1115- .addReg (SystemZ::R4D)
1116- .addImm (Offset)
1117- .addReg (0 );
1118- }
1119-
1120- emitIncrement (MBB, InsertPt, DL, Regs.getStackPointerRegister (), Delta,
1121- ZII);
1122- }
1123-
1124- if (HasFP) {
1125- // Copy the base of the frame to Frame Pointer Register.
1126- BuildMI (MBB, MBBI, DL, ZII->get (SystemZ::LGR),
1127- Regs.getFramePointerRegister ())
1128- .addReg (Regs.getStackPointerRegister ());
1129-
1130- // Mark the FramePtr as live at the beginning of every block except
1131- // the entry block. (We'll have marked R8 as live on entry when
1132- // saving the GPRs.)
1133- for (auto I = std::next (MF.begin ()), E = MF.end (); I != E; ++I)
1134- I->addLiveIn (Regs.getFramePointerRegister ());
1135- }
1136- }
994+ MachineBasicBlock &MBB) const {}
1137995
1138996void SystemZXPLINKFrameLowering::emitEpilogue (MachineFunction &MF,
1139- MachineBasicBlock &MBB) const {
1140- const SystemZSubtarget &Subtarget = MF.getSubtarget <SystemZSubtarget>();
1141- MachineBasicBlock::iterator MBBI = MBB.getLastNonDebugInstr ();
1142- SystemZMachineFunctionInfo *ZFI = MF.getInfo <SystemZMachineFunctionInfo>();
1143- MachineFrameInfo &MFFrame = MF.getFrameInfo ();
1144- auto *ZII = static_cast <const SystemZInstrInfo *>(Subtarget.getInstrInfo ());
1145- auto &Regs = Subtarget.getSpecialRegisters <SystemZXPLINK64Registers>();
1146-
1147- // Skip the return instruction.
1148- assert (MBBI->isReturn () && " Can only insert epilogue into returning blocks" );
1149-
1150- uint64_t StackSize = MFFrame.getStackSize ();
1151- if (StackSize) {
1152- unsigned SPReg = Regs.getStackPointerRegister ();
1153- if (ZFI->getRestoreGPRRegs ().LowGPR != SPReg) {
1154- DebugLoc DL = MBBI->getDebugLoc ();
1155- emitIncrement (MBB, MBBI, DL, SPReg, StackSize, ZII);
1156- }
1157- }
1158- }
997+ MachineBasicBlock &MBB) const {}
1159998
1160999bool SystemZXPLINKFrameLowering::hasFP (const MachineFunction &MF) const {
1161- return (MF.getFrameInfo ().hasVarSizedObjects ());
1162- }
1163-
1164- void SystemZXPLINKFrameLowering::processFunctionBeforeFrameFinalized (
1165- MachineFunction &MF, RegScavenger *RS) const {
1166- MachineFrameInfo &MFFrame = MF.getFrameInfo ();
1167- const SystemZSubtarget &Subtarget = MF.getSubtarget <SystemZSubtarget>();
1168- auto &Regs = Subtarget.getSpecialRegisters <SystemZXPLINK64Registers>();
1169-
1170- // Setup stack frame offset
1171- MFFrame.setOffsetAdjustment (Regs.getStackPointerBias ());
1000+ return false ;
11721001}
0 commit comments