@@ -713,16 +713,17 @@ static void emitAligningInstructions(MachineFunction &MF, ARMFunctionInfo *AFI,
713
713
// / this to produce a conservative estimate that we check in an assert() later.
714
714
static int getMaxFPOffset (const ARMSubtarget &STI, const ARMFunctionInfo &AFI,
715
715
const MachineFunction &MF) {
716
+ ARMSubtarget::PushPopSplitVariation PushPopSplit =
717
+ STI.getPushPopSplitVariation (MF);
716
718
// For Thumb1, push.w isn't available, so the first push will always push
717
719
// r7 and lr onto the stack first.
718
720
if (AFI.isThumb1OnlyFunction ())
719
721
return -AFI.getArgRegsSaveSize () - (2 * 4 );
720
722
// This is a conservative estimation: Assume the frame pointer being r7 and
721
723
// pc("r15") up to r8 getting spilled before (= 8 registers).
722
724
int MaxRegBytes = 8 * 4 ;
723
- if (STI.splitFramePointerPush (MF)) {
724
- // Here, r11 can be stored below all of r4-r15 (3 registers more than
725
- // above), plus d8-d15.
725
+ if (PushPopSplit == ARMSubtarget::SplitR11WindowsSEH) {
726
+ // Here, r11 can be stored below all of r4-r15 plus d8-d15.
726
727
MaxRegBytes = 11 * 4 + 8 * 8 ;
727
728
}
728
729
int FPCXTSaveSize =
@@ -749,6 +750,8 @@ void ARMFrameLowering::emitPrologue(MachineFunction &MF,
749
750
const std::vector<CalleeSavedInfo> &CSI = MFI.getCalleeSavedInfo ();
750
751
int FPCXTSaveSize = 0 ;
751
752
bool NeedsWinCFI = needsWinCFI (MF);
753
+ ARMSubtarget::PushPopSplitVariation PushPopSplit =
754
+ STI.getPushPopSplitVariation (MF);
752
755
753
756
// Debug location must be unknown since the first debug location is used
754
757
// to determine the end of the prologue.
@@ -789,7 +792,7 @@ void ARMFrameLowering::emitPrologue(MachineFunction &MF,
789
792
}
790
793
791
794
// Determine spill area sizes.
792
- if (STI. splitFramePointerPush (MF) ) {
795
+ if (PushPopSplit == ARMSubtarget::SplitR11WindowsSEH ) {
793
796
for (const CalleeSavedInfo &I : CSI) {
794
797
Register Reg = I.getReg ();
795
798
int FI = I.getFrameIdx ();
@@ -835,7 +838,7 @@ void ARMFrameLowering::emitPrologue(MachineFunction &MF,
835
838
case ARM::R10:
836
839
case ARM::R11:
837
840
case ARM::R12:
838
- if (STI. splitFramePushPop (MF) ) {
841
+ if (PushPopSplit == ARMSubtarget::SplitR7 ) {
839
842
GPRCS2Size += 4 ;
840
843
break ;
841
844
}
@@ -898,13 +901,13 @@ void ARMFrameLowering::emitPrologue(MachineFunction &MF,
898
901
unsigned GPRCS2Offset = GPRCS1Offset - GPRCS2Size;
899
902
Align DPRAlign = DPRCSSize ? std::min (Align (8 ), Alignment) : Align (4 );
900
903
unsigned DPRGapSize = GPRCS1Size + FPCXTSaveSize + ArgRegsSaveSize;
901
- if (!STI. splitFramePointerPush (MF) ) {
904
+ if (PushPopSplit != ARMSubtarget::SplitR11WindowsSEH ) {
902
905
DPRGapSize += GPRCS2Size;
903
906
}
904
907
DPRGapSize %= DPRAlign.value ();
905
908
906
909
unsigned DPRCSOffset;
907
- if (STI. splitFramePointerPush (MF) ) {
910
+ if (PushPopSplit == ARMSubtarget::SplitR11WindowsSEH ) {
908
911
DPRCSOffset = GPRCS1Offset - DPRGapSize - DPRCSSize;
909
912
GPRCS2Offset = DPRCSOffset - GPRCS2Size;
910
913
} else {
@@ -923,8 +926,9 @@ void ARMFrameLowering::emitPrologue(MachineFunction &MF,
923
926
AFI->setGPRCalleeSavedArea2Offset (GPRCS2Offset);
924
927
AFI->setDPRCalleeSavedAreaOffset (DPRCSOffset);
925
928
926
- // Move past area 2.
927
- if (GPRCS2Size > 0 && !STI.splitFramePointerPush (MF)) {
929
+ // Move GPRCS2, unless using SplitR11WindowsSEH, in which case it will be
930
+ // after DPRCS1.
931
+ if (GPRCS2Size > 0 && PushPopSplit != ARMSubtarget::SplitR11WindowsSEH) {
928
932
GPRCS2Push = LastPush = MBBI++;
929
933
DefCFAOffsetCandidates.addInst (LastPush, GPRCS2Size);
930
934
}
@@ -943,7 +947,7 @@ void ARMFrameLowering::emitPrologue(MachineFunction &MF,
943
947
}
944
948
}
945
949
946
- // Move past area 3 .
950
+ // Move past DPRCS1 .
947
951
if (DPRCSSize > 0 ) {
948
952
// Since vpush register list cannot have gaps, there may be multiple vpush
949
953
// instructions in the prologue.
@@ -964,13 +968,14 @@ void ARMFrameLowering::emitPrologue(MachineFunction &MF,
964
968
} else
965
969
NumBytes = DPRCSOffset;
966
970
967
- if (GPRCS2Size > 0 && STI.splitFramePointerPush (MF)) {
971
+ // Move GPRCS2, if using using SplitR11WindowsSEH.
972
+ if (GPRCS2Size > 0 && PushPopSplit == ARMSubtarget::SplitR11WindowsSEH) {
968
973
GPRCS2Push = LastPush = MBBI++;
969
974
DefCFAOffsetCandidates.addInst (LastPush, GPRCS2Size);
970
975
}
971
976
972
977
bool NeedsWinCFIStackAlloc = NeedsWinCFI;
973
- if (STI. splitFramePointerPush (MF) && HasFP)
978
+ if (PushPopSplit == ARMSubtarget::SplitR11WindowsSEH && HasFP)
974
979
NeedsWinCFIStackAlloc = false ;
975
980
976
981
if (STI.isTargetWindows () && WindowsRequiresStackProbe (MF, NumBytes)) {
@@ -1075,7 +1080,7 @@ void ARMFrameLowering::emitPrologue(MachineFunction &MF,
1075
1080
AfterPush = std::next (GPRCS1Push);
1076
1081
unsigned PushSize = sizeOfSPAdjustment (*GPRCS1Push);
1077
1082
int FPOffset = PushSize + FramePtrOffsetInPush;
1078
- if (STI. splitFramePointerPush (MF) ) {
1083
+ if (PushPopSplit == ARMSubtarget::SplitR11WindowsSEH ) {
1079
1084
AfterPush = std::next (GPRCS2Push);
1080
1085
emitRegPlusImmediate (!AFI->isThumbFunction (), MBB, AfterPush, dl, TII,
1081
1086
FramePtr, ARM::SP, 0 , MachineInstr::FrameSetup);
@@ -1107,7 +1112,7 @@ void ARMFrameLowering::emitPrologue(MachineFunction &MF,
1107
1112
// instructions below don't need to be replayed to unwind the stack.
1108
1113
if (NeedsWinCFI && MBBI != MBB.begin ()) {
1109
1114
MachineBasicBlock::iterator End = MBBI;
1110
- if (HasFP && STI. splitFramePointerPush (MF) )
1115
+ if (HasFP && PushPopSplit == ARMSubtarget::SplitR11WindowsSEH )
1111
1116
End = AfterPush;
1112
1117
insertSEHRange (MBB, {}, End, TII, MachineInstr::FrameSetup);
1113
1118
BuildMI (MBB, End, dl, TII.get (ARM::SEH_PrologEnd))
@@ -1130,7 +1135,7 @@ void ARMFrameLowering::emitPrologue(MachineFunction &MF,
1130
1135
case ARM::R10:
1131
1136
case ARM::R11:
1132
1137
case ARM::R12:
1133
- if (STI. splitFramePushPop (MF) )
1138
+ if (PushPopSplit == ARMSubtarget::SplitR7 )
1134
1139
break ;
1135
1140
[[fallthrough]];
1136
1141
case ARM::R0:
@@ -1163,7 +1168,7 @@ void ARMFrameLowering::emitPrologue(MachineFunction &MF,
1163
1168
case ARM::R10:
1164
1169
case ARM::R11:
1165
1170
case ARM::R12:
1166
- if (STI. splitFramePushPop (MF) ) {
1171
+ if (PushPopSplit == ARMSubtarget::SplitR7 ) {
1167
1172
unsigned DwarfReg = MRI->getDwarfRegNum (
1168
1173
Reg == ARM::R12 ? ARM::RA_AUTH_CODE : Reg, true );
1169
1174
int64_t Offset = MFI.getObjectOffset (FI);
@@ -1280,6 +1285,8 @@ void ARMFrameLowering::emitEpilogue(MachineFunction &MF,
1280
1285
assert (!AFI->isThumb1OnlyFunction () &&
1281
1286
" This emitEpilogue does not support Thumb1!" );
1282
1287
bool isARM = !AFI->isThumbFunction ();
1288
+ ARMSubtarget::PushPopSplitVariation PushPopSplit =
1289
+ STI.getPushPopSplitVariation (MF);
1283
1290
1284
1291
// Amount of stack space we reserved next to incoming args for either
1285
1292
// varargs registers or stack arguments in tail calls made by this function.
@@ -1383,7 +1390,8 @@ void ARMFrameLowering::emitEpilogue(MachineFunction &MF,
1383
1390
MachineInstr::FrameDestroy);
1384
1391
1385
1392
// Increment past our save areas.
1386
- if (AFI->getGPRCalleeSavedArea2Size () && STI.splitFramePointerPush (MF))
1393
+ if (AFI->getGPRCalleeSavedArea2Size () &&
1394
+ PushPopSplit == ARMSubtarget::SplitR11WindowsSEH)
1387
1395
MBBI++;
1388
1396
1389
1397
if (MBBI != MBB.end () && AFI->getDPRCalleeSavedAreaSize ()) {
@@ -1400,7 +1408,8 @@ void ARMFrameLowering::emitEpilogue(MachineFunction &MF,
1400
1408
MachineInstr::FrameDestroy);
1401
1409
}
1402
1410
1403
- if (AFI->getGPRCalleeSavedArea2Size () && !STI.splitFramePointerPush (MF))
1411
+ if (AFI->getGPRCalleeSavedArea2Size () &&
1412
+ PushPopSplit != ARMSubtarget::SplitR11WindowsSEH)
1404
1413
MBBI++;
1405
1414
if (AFI->getGPRCalleeSavedArea1Size ()) MBBI++;
1406
1415
@@ -1529,6 +1538,8 @@ void ARMFrameLowering::emitPushInst(MachineBasicBlock &MBB,
1529
1538
MachineFunction &MF = *MBB.getParent ();
1530
1539
const TargetInstrInfo &TII = *MF.getSubtarget ().getInstrInfo ();
1531
1540
const TargetRegisterInfo &TRI = *STI.getRegisterInfo ();
1541
+ ARMSubtarget::PushPopSplitVariation PushPopSplit =
1542
+ STI.getPushPopSplitVariation (MF);
1532
1543
1533
1544
DebugLoc DL;
1534
1545
@@ -1540,7 +1551,8 @@ void ARMFrameLowering::emitPushInst(MachineBasicBlock &MBB,
1540
1551
unsigned LastReg = 0 ;
1541
1552
for (; i != 0 ; --i) {
1542
1553
Register Reg = CSI[i-1 ].getReg ();
1543
- if (!(Func)(Reg, STI.splitFramePushPop (MF))) continue ;
1554
+ if (!(Func)(Reg, PushPopSplit == ARMSubtarget::SplitR7))
1555
+ continue ;
1544
1556
1545
1557
// D-registers in the aligned area DPRCS2 are NOT spilled here.
1546
1558
if (Reg >= ARM::D8 && Reg < ARM::D8 + NumAlignedDPRCS2Regs)
@@ -1613,6 +1625,8 @@ void ARMFrameLowering::emitPopInst(MachineBasicBlock &MBB,
1613
1625
bool isInterrupt = false ;
1614
1626
bool isTrap = false ;
1615
1627
bool isCmseEntry = false ;
1628
+ ARMSubtarget::PushPopSplitVariation PushPopSplit =
1629
+ STI.getPushPopSplitVariation (MF);
1616
1630
if (MBB.end () != MI) {
1617
1631
DL = MI->getDebugLoc ();
1618
1632
unsigned RetOpcode = MI->getOpcode ();
@@ -1635,15 +1649,16 @@ void ARMFrameLowering::emitPopInst(MachineBasicBlock &MBB,
1635
1649
for (; i != 0 ; --i) {
1636
1650
CalleeSavedInfo &Info = CSI[i-1 ];
1637
1651
Register Reg = Info.getReg ();
1638
- if (!(Func)(Reg, STI.splitFramePushPop (MF))) continue ;
1652
+ if (!(Func)(Reg, PushPopSplit == ARMSubtarget::SplitR7))
1653
+ continue ;
1639
1654
1640
1655
// The aligned reloads from area DPRCS2 are not inserted here.
1641
1656
if (Reg >= ARM::D8 && Reg < ARM::D8 + NumAlignedDPRCS2Regs)
1642
1657
continue ;
1643
1658
if (Reg == ARM::LR && !isTailCall && !isVarArg && !isInterrupt &&
1644
1659
!isCmseEntry && !isTrap && AFI->getArgumentStackToRestore () == 0 &&
1645
1660
STI.hasV5TOps () && MBB.succ_empty () && !hasPAC &&
1646
- !STI. splitFramePointerPush (MF) ) {
1661
+ PushPopSplit != ARMSubtarget::SplitR11WindowsSEH ) {
1647
1662
Reg = ARM::PC;
1648
1663
// Fold the return instruction into the LDM.
1649
1664
DeleteRet = true ;
@@ -1983,6 +1998,8 @@ bool ARMFrameLowering::spillCalleeSavedRegisters(
1983
1998
1984
1999
MachineFunction &MF = *MBB.getParent ();
1985
2000
ARMFunctionInfo *AFI = MF.getInfo <ARMFunctionInfo>();
2001
+ ARMSubtarget::PushPopSplitVariation PushPopSplit =
2002
+ STI.getPushPopSplitVariation (MF);
1986
2003
1987
2004
unsigned PushOpc = AFI->isThumbFunction () ? ARM::t2STMDB_UPD : ARM::STMDB_UPD;
1988
2005
unsigned PushOneOpc = AFI->isThumbFunction () ?
@@ -2004,7 +2021,7 @@ bool ARMFrameLowering::spillCalleeSavedRegisters(
2004
2021
.addImm (-4 )
2005
2022
.add (predOps (ARMCC::AL));
2006
2023
}
2007
- if (STI. splitFramePointerPush (MF) ) {
2024
+ if (PushPopSplit == ARMSubtarget::SplitR11WindowsSEH ) {
2008
2025
emitPushInst (MBB, MI, CSI, PushOpc, PushOneOpc, false ,
2009
2026
&isSplitFPArea1Register, 0 , MachineInstr::FrameSetup);
2010
2027
emitPushInst (MBB, MI, CSI, FltOpc, 0 , true , &isARMArea3Register,
@@ -2039,6 +2056,8 @@ bool ARMFrameLowering::restoreCalleeSavedRegisters(
2039
2056
ARMFunctionInfo *AFI = MF.getInfo <ARMFunctionInfo>();
2040
2057
bool isVarArg = AFI->getArgRegsSaveSize () > 0 ;
2041
2058
unsigned NumAlignedDPRCS2Regs = AFI->getNumAlignedDPRCS2Regs ();
2059
+ ARMSubtarget::PushPopSplitVariation PushPopSplit =
2060
+ STI.getPushPopSplitVariation (MF);
2042
2061
2043
2062
// The emitPopInst calls below do not insert reloads for the aligned DPRCS2
2044
2063
// registers. Do that here instead.
@@ -2049,7 +2068,7 @@ bool ARMFrameLowering::restoreCalleeSavedRegisters(
2049
2068
unsigned LdrOpc =
2050
2069
AFI->isThumbFunction () ? ARM::t2LDR_POST : ARM::LDR_POST_IMM;
2051
2070
unsigned FltOpc = ARM::VLDMDIA_UPD;
2052
- if (STI. splitFramePointerPush (MF) ) {
2071
+ if (PushPopSplit == ARMSubtarget::SplitR11WindowsSEH ) {
2053
2072
emitPopInst (MBB, MI, CSI, PopOpc, LdrOpc, isVarArg, false ,
2054
2073
&isSplitFPArea2Register, 0 );
2055
2074
emitPopInst (MBB, MI, CSI, FltOpc, 0 , isVarArg, true , &isARMArea3Register,
@@ -2287,6 +2306,8 @@ void ARMFrameLowering::determineCalleeSaves(MachineFunction &MF,
2287
2306
const TargetRegisterInfo *TRI = MF.getSubtarget ().getRegisterInfo ();
2288
2307
(void )TRI; // Silence unused warning in non-assert builds.
2289
2308
Register FramePtr = RegInfo->getFrameRegister (MF);
2309
+ ARMSubtarget::PushPopSplitVariation PushPopSplit =
2310
+ STI.getPushPopSplitVariation (MF);
2290
2311
2291
2312
// Spill R4 if Thumb2 function requires stack realignment - it will be used as
2292
2313
// scratch register. Also spill R4 if Thumb2 function has varsized objects,
@@ -2365,7 +2386,7 @@ void ARMFrameLowering::determineCalleeSaves(MachineFunction &MF,
2365
2386
if (Spilled) {
2366
2387
NumGPRSpills++;
2367
2388
2368
- if (!STI. splitFramePushPop (MF) ) {
2389
+ if (PushPopSplit != ARMSubtarget::SplitR7 ) {
2369
2390
if (Reg == ARM::LR)
2370
2391
LRSpilled = true ;
2371
2392
CS1Spilled = true ;
@@ -2387,7 +2408,7 @@ void ARMFrameLowering::determineCalleeSaves(MachineFunction &MF,
2387
2408
break ;
2388
2409
}
2389
2410
} else {
2390
- if (!STI. splitFramePushPop (MF) ) {
2411
+ if (PushPopSplit != ARMSubtarget::SplitR7 ) {
2391
2412
UnspilledCS1GPRs.push_back (Reg);
2392
2413
continue ;
2393
2414
}
0 commit comments