@@ -718,9 +718,14 @@ static int getMaxFPOffset(const ARMSubtarget &STI, const ARMFunctionInfo &AFI,
718
718
// This is a conservative estimation: Assume the frame pointer being r7 and
719
719
// pc("r15") up to r8 getting spilled before (= 8 registers).
720
720
int MaxRegBytes = 8 * 4 ;
721
- if (STI.splitFramePointerPush (MF)) {
721
+ if (STI.getPushPopSplitVariation (MF) ==
722
+ ARMSubtarget::PushPopSplitVariation::R11SplitAAPCSBranchSigning)
722
723
// Here, r11 can be stored below all of r4-r15 (3 registers more than
723
- // above), plus d8-d15.
724
+ // above).
725
+ MaxRegBytes = 11 * 4 ;
726
+ if (STI.getPushPopSplitVariation (MF) ==
727
+ ARMSubtarget::PushPopSplitVariation::R11SplitWindowsSEHUnwind) {
728
+ // Here, r11 can be stored below all of r4-r15 plus d8-d15.
724
729
MaxRegBytes = 11 * 4 + 8 * 8 ;
725
730
}
726
731
int FPCXTSaveSize =
@@ -788,7 +793,10 @@ void ARMFrameLowering::emitPrologue(MachineFunction &MF,
788
793
}
789
794
790
795
// Determine spill area sizes.
791
- if (STI.splitFramePointerPush (MF)) {
796
+ if (STI.getPushPopSplitVariation (MF) ==
797
+ ARMSubtarget::PushPopSplitVariation::R11SplitAAPCSBranchSigning ||
798
+ STI.getPushPopSplitVariation (MF) ==
799
+ ARMSubtarget::PushPopSplitVariation::R11SplitWindowsSEHUnwind) {
792
800
for (const CalleeSavedInfo &I : CSI) {
793
801
Register Reg = I.getReg ();
794
802
int FI = I.getFrameIdx ();
@@ -834,7 +842,8 @@ void ARMFrameLowering::emitPrologue(MachineFunction &MF,
834
842
case ARM::R10:
835
843
case ARM::R11:
836
844
case ARM::R12:
837
- if (STI.splitFramePushPop (MF)) {
845
+ if (STI.getPushPopSplitVariation (MF) ==
846
+ ARMSubtarget::PushPopSplitVariation::R7Split) {
838
847
GPRCS2Size += 4 ;
839
848
break ;
840
849
}
@@ -897,13 +906,15 @@ void ARMFrameLowering::emitPrologue(MachineFunction &MF,
897
906
unsigned GPRCS2Offset = GPRCS1Offset - GPRCS2Size;
898
907
Align DPRAlign = DPRCSSize ? std::min (Align (8 ), Alignment) : Align (4 );
899
908
unsigned DPRGapSize = GPRCS1Size + FPCXTSaveSize + ArgRegsSaveSize;
900
- if (!STI.splitFramePointerPush (MF)) {
909
+ if (STI.getPushPopSplitVariation (MF) !=
910
+ ARMSubtarget::PushPopSplitVariation::R11SplitWindowsSEHUnwind) {
901
911
DPRGapSize += GPRCS2Size;
902
912
}
903
913
DPRGapSize %= DPRAlign.value ();
904
914
905
915
unsigned DPRCSOffset;
906
- if (STI.splitFramePointerPush (MF)) {
916
+ if (STI.getPushPopSplitVariation (MF) ==
917
+ ARMSubtarget::PushPopSplitVariation::R11SplitWindowsSEHUnwind) {
907
918
DPRCSOffset = GPRCS1Offset - DPRGapSize - DPRCSSize;
908
919
GPRCS2Offset = DPRCSOffset - GPRCS2Size;
909
920
} else {
@@ -922,8 +933,10 @@ void ARMFrameLowering::emitPrologue(MachineFunction &MF,
922
933
AFI->setGPRCalleeSavedArea2Offset (GPRCS2Offset);
923
934
AFI->setDPRCalleeSavedAreaOffset (DPRCSOffset);
924
935
925
- // Move past area 2.
926
- if (GPRCS2Size > 0 && !STI.splitFramePointerPush (MF)) {
936
+ // Move past area 2, unless following the CSR_Win_SplitFP calling convention.
937
+ if (GPRCS2Size > 0 &&
938
+ STI.getPushPopSplitVariation (MF) !=
939
+ ARMSubtarget::PushPopSplitVariation::R11SplitWindowsSEHUnwind) {
927
940
GPRCS2Push = LastPush = MBBI++;
928
941
DefCFAOffsetCandidates.addInst (LastPush, GPRCS2Size);
929
942
}
@@ -963,13 +976,18 @@ void ARMFrameLowering::emitPrologue(MachineFunction &MF,
963
976
} else
964
977
NumBytes = DPRCSOffset;
965
978
966
- if (GPRCS2Size > 0 && STI.splitFramePointerPush (MF)) {
979
+ // Move past area 2 if following the CSR_Win_SplitFP calling convention.
980
+ if (GPRCS2Size > 0 &&
981
+ STI.getPushPopSplitVariation (MF) ==
982
+ ARMSubtarget::PushPopSplitVariation::R11SplitWindowsSEHUnwind) {
967
983
GPRCS2Push = LastPush = MBBI++;
968
984
DefCFAOffsetCandidates.addInst (LastPush, GPRCS2Size);
969
985
}
970
986
971
987
bool NeedsWinCFIStackAlloc = NeedsWinCFI;
972
- if (STI.splitFramePointerPush (MF) && HasFP)
988
+ if (STI.getPushPopSplitVariation (MF) ==
989
+ ARMSubtarget::PushPopSplitVariation::R11SplitWindowsSEHUnwind &&
990
+ HasFP)
973
991
NeedsWinCFIStackAlloc = false ;
974
992
975
993
if (STI.isTargetWindows () && WindowsRequiresStackProbe (MF, NumBytes)) {
@@ -1074,7 +1092,10 @@ void ARMFrameLowering::emitPrologue(MachineFunction &MF,
1074
1092
AfterPush = std::next (GPRCS1Push);
1075
1093
unsigned PushSize = sizeOfSPAdjustment (*GPRCS1Push);
1076
1094
int FPOffset = PushSize + FramePtrOffsetInPush;
1077
- if (STI.splitFramePointerPush (MF)) {
1095
+ if (STI.getPushPopSplitVariation (MF) ==
1096
+ ARMSubtarget::PushPopSplitVariation::R11SplitAAPCSBranchSigning ||
1097
+ STI.getPushPopSplitVariation (MF) ==
1098
+ ARMSubtarget::PushPopSplitVariation::R11SplitWindowsSEHUnwind) {
1078
1099
AfterPush = std::next (GPRCS2Push);
1079
1100
emitRegPlusImmediate (!AFI->isThumbFunction (), MBB, AfterPush, dl, TII,
1080
1101
FramePtr, ARM::SP, 0 , MachineInstr::FrameSetup);
@@ -1106,7 +1127,9 @@ void ARMFrameLowering::emitPrologue(MachineFunction &MF,
1106
1127
// instructions below don't need to be replayed to unwind the stack.
1107
1128
if (NeedsWinCFI && MBBI != MBB.begin ()) {
1108
1129
MachineBasicBlock::iterator End = MBBI;
1109
- if (HasFP && STI.splitFramePointerPush (MF))
1130
+ if (HasFP &&
1131
+ STI.getPushPopSplitVariation (MF) ==
1132
+ ARMSubtarget::PushPopSplitVariation::R11SplitWindowsSEHUnwind)
1110
1133
End = AfterPush;
1111
1134
insertSEHRange (MBB, {}, End, TII, MachineInstr::FrameSetup);
1112
1135
BuildMI (MBB, End, dl, TII.get (ARM::SEH_PrologEnd))
@@ -1118,51 +1141,103 @@ void ARMFrameLowering::emitPrologue(MachineFunction &MF,
1118
1141
// the necessary DWARF cf instructions to describe the situation. Start by
1119
1142
// recording where each register ended up:
1120
1143
if (GPRCS1Size > 0 && !NeedsWinCFI) {
1121
- MachineBasicBlock::iterator Pos = std::next (GPRCS1Push);
1122
- int CFIIndex;
1123
- for (const auto &Entry : CSI) {
1124
- Register Reg = Entry.getReg ();
1125
- int FI = Entry.getFrameIdx ();
1126
- switch (Reg) {
1127
- case ARM::R8:
1128
- case ARM::R9:
1129
- case ARM::R10:
1130
- case ARM::R11:
1131
- case ARM::R12:
1132
- if (STI.splitFramePushPop (MF))
1144
+ if (STI.getPushPopSplitVariation (MF) ==
1145
+ ARMSubtarget::PushPopSplitVariation::R11SplitAAPCSBranchSigning) {
1146
+ MachineBasicBlock::iterator Pos = std::next (GPRCS1Push);
1147
+ int CFIIndex;
1148
+ for (const auto &Entry : CSI) {
1149
+ Register Reg = Entry.getReg ();
1150
+ int FI = Entry.getFrameIdx ();
1151
+ switch (Reg) {
1152
+ case ARM::R0:
1153
+ case ARM::R1:
1154
+ case ARM::R2:
1155
+ case ARM::R3:
1156
+ case ARM::R4:
1157
+ case ARM::R5:
1158
+ case ARM::R6:
1159
+ case ARM::R7:
1160
+ case ARM::R8:
1161
+ case ARM::R9:
1162
+ case ARM::R10:
1163
+ case ARM::R12:
1164
+ CFIIndex = MF.addFrameInst (MCCFIInstruction::createOffset (
1165
+ nullptr , MRI->getDwarfRegNum (Reg, true ),
1166
+ MFI.getObjectOffset (FI)));
1167
+ BuildMI (MBB, Pos, dl, TII.get (TargetOpcode::CFI_INSTRUCTION))
1168
+ .addCFIIndex (CFIIndex)
1169
+ .setMIFlags (MachineInstr::FrameSetup);
1133
1170
break ;
1134
- [[fallthrough]];
1135
- case ARM::R0:
1136
- case ARM::R1:
1137
- case ARM::R2:
1138
- case ARM::R3:
1139
- case ARM::R4:
1140
- case ARM::R5:
1141
- case ARM::R6:
1142
- case ARM::R7:
1143
- case ARM::LR:
1144
- CFIIndex = MF.addFrameInst (MCCFIInstruction::createOffset (
1145
- nullptr , MRI->getDwarfRegNum (Reg, true ), MFI.getObjectOffset (FI)));
1146
- BuildMI (MBB, Pos, dl, TII.get (TargetOpcode::CFI_INSTRUCTION))
1147
- .addCFIIndex (CFIIndex)
1148
- .setMIFlags (MachineInstr::FrameSetup);
1149
- break ;
1171
+ }
1172
+ }
1173
+ } else {
1174
+ MachineBasicBlock::iterator Pos = std::next (GPRCS1Push);
1175
+ int CFIIndex;
1176
+ for (const auto &Entry : CSI) {
1177
+ Register Reg = Entry.getReg ();
1178
+ int FI = Entry.getFrameIdx ();
1179
+ switch (Reg) {
1180
+ case ARM::R8:
1181
+ case ARM::R9:
1182
+ case ARM::R10:
1183
+ case ARM::R11:
1184
+ case ARM::R12:
1185
+ if (STI.getPushPopSplitVariation (MF) ==
1186
+ ARMSubtarget::PushPopSplitVariation::R7Split)
1187
+ break ;
1188
+ [[fallthrough]];
1189
+ case ARM::R0:
1190
+ case ARM::R1:
1191
+ case ARM::R2:
1192
+ case ARM::R3:
1193
+ case ARM::R4:
1194
+ case ARM::R5:
1195
+ case ARM::R6:
1196
+ case ARM::R7:
1197
+ case ARM::LR:
1198
+ CFIIndex = MF.addFrameInst (MCCFIInstruction::createOffset (
1199
+ nullptr , MRI->getDwarfRegNum (Reg, true ),
1200
+ MFI.getObjectOffset (FI)));
1201
+ BuildMI (MBB, Pos, dl, TII.get (TargetOpcode::CFI_INSTRUCTION))
1202
+ .addCFIIndex (CFIIndex)
1203
+ .setMIFlags (MachineInstr::FrameSetup);
1204
+ break ;
1205
+ }
1150
1206
}
1151
1207
}
1152
1208
}
1153
1209
1154
1210
if (GPRCS2Size > 0 && !NeedsWinCFI) {
1155
1211
MachineBasicBlock::iterator Pos = std::next (GPRCS2Push);
1156
- for (const auto &Entry : CSI) {
1157
- Register Reg = Entry.getReg ();
1158
- int FI = Entry.getFrameIdx ();
1159
- switch (Reg) {
1160
- case ARM::R8:
1161
- case ARM::R9:
1162
- case ARM::R10:
1163
- case ARM::R11:
1164
- case ARM::R12:
1165
- if (STI.splitFramePushPop (MF)) {
1212
+ if (STI.getPushPopSplitVariation (MF) ==
1213
+ ARMSubtarget::PushPopSplitVariation::R11SplitAAPCSBranchSigning) {
1214
+ for (const auto &Entry : CSI) {
1215
+ Register Reg = Entry.getReg ();
1216
+ int FI = Entry.getFrameIdx ();
1217
+ switch (Reg) {
1218
+ case ARM::R11:
1219
+ case ARM::LR:
1220
+ unsigned DwarfReg = MRI->getDwarfRegNum (Reg, true );
1221
+ unsigned Offset = MFI.getObjectOffset (FI);
1222
+ unsigned CFIIndex = MF.addFrameInst (
1223
+ MCCFIInstruction::createOffset (nullptr , DwarfReg, Offset));
1224
+ BuildMI (MBB, Pos, dl, TII.get (TargetOpcode::CFI_INSTRUCTION))
1225
+ .addCFIIndex (CFIIndex)
1226
+ .setMIFlags (MachineInstr::FrameSetup);
1227
+ break ;
1228
+ }
1229
+ }
1230
+ } else {
1231
+ MachineBasicBlock::iterator Pos = std::next (GPRCS2Push);
1232
+ for (const auto &Entry : CSI) {
1233
+ Register Reg = Entry.getReg ();
1234
+ int FI = Entry.getFrameIdx ();
1235
+ switch (Reg) {
1236
+ case ARM::R8:
1237
+ case ARM::R9:
1238
+ case ARM::R10:
1239
+ case ARM::R11:
1240
+ case ARM::R12:
1166
1241
unsigned DwarfReg = MRI->getDwarfRegNum (
1167
1242
Reg == ARM::R12 ? ARM::RA_AUTH_CODE : Reg, true );
1168
1243
unsigned Offset = MFI.getObjectOffset (FI);
@@ -1171,8 +1246,8 @@ void ARMFrameLowering::emitPrologue(MachineFunction &MF,
1171
1246
BuildMI (MBB, Pos, dl, TII.get (TargetOpcode::CFI_INSTRUCTION))
1172
1247
.addCFIIndex (CFIIndex)
1173
1248
.setMIFlags (MachineInstr::FrameSetup);
1249
+ break ;
1174
1250
}
1175
- break ;
1176
1251
}
1177
1252
}
1178
1253
}
@@ -1382,7 +1457,9 @@ void ARMFrameLowering::emitEpilogue(MachineFunction &MF,
1382
1457
MachineInstr::FrameDestroy);
1383
1458
1384
1459
// Increment past our save areas.
1385
- if (AFI->getGPRCalleeSavedArea2Size () && STI.splitFramePointerPush (MF))
1460
+ if (AFI->getGPRCalleeSavedArea2Size () &&
1461
+ STI.getPushPopSplitVariation (MF) ==
1462
+ ARMSubtarget::PushPopSplitVariation::R11SplitWindowsSEHUnwind)
1386
1463
MBBI++;
1387
1464
1388
1465
if (MBBI != MBB.end () && AFI->getDPRCalleeSavedAreaSize ()) {
@@ -1399,7 +1476,9 @@ void ARMFrameLowering::emitEpilogue(MachineFunction &MF,
1399
1476
MachineInstr::FrameDestroy);
1400
1477
}
1401
1478
1402
- if (AFI->getGPRCalleeSavedArea2Size () && !STI.splitFramePointerPush (MF))
1479
+ if (AFI->getGPRCalleeSavedArea2Size () &&
1480
+ STI.getPushPopSplitVariation (MF) !=
1481
+ ARMSubtarget::PushPopSplitVariation::R11SplitWindowsSEHUnwind)
1403
1482
MBBI++;
1404
1483
if (AFI->getGPRCalleeSavedArea1Size ()) MBBI++;
1405
1484
@@ -1539,7 +1618,9 @@ void ARMFrameLowering::emitPushInst(MachineBasicBlock &MBB,
1539
1618
unsigned LastReg = 0 ;
1540
1619
for (; i != 0 ; --i) {
1541
1620
Register Reg = CSI[i-1 ].getReg ();
1542
- if (!(Func)(Reg, STI.splitFramePushPop (MF))) continue ;
1621
+ if (!(Func)(Reg, STI.getPushPopSplitVariation (MF) ==
1622
+ ARMSubtarget::PushPopSplitVariation::R7Split))
1623
+ continue ;
1543
1624
1544
1625
// D-registers in the aligned area DPRCS2 are NOT spilled here.
1545
1626
if (Reg >= ARM::D8 && Reg < ARM::D8 + NumAlignedDPRCS2Regs)
@@ -1632,15 +1713,21 @@ void ARMFrameLowering::emitPopInst(MachineBasicBlock &MBB,
1632
1713
for (; i != 0 ; --i) {
1633
1714
CalleeSavedInfo &Info = CSI[i-1 ];
1634
1715
Register Reg = Info.getReg ();
1635
- if (!(Func)(Reg, STI.splitFramePushPop (MF))) continue ;
1716
+ if (!(Func)(Reg, STI.getPushPopSplitVariation (MF) ==
1717
+ ARMSubtarget::PushPopSplitVariation::R7Split))
1718
+ continue ;
1636
1719
1637
1720
// The aligned reloads from area DPRCS2 are not inserted here.
1638
1721
if (Reg >= ARM::D8 && Reg < ARM::D8 + NumAlignedDPRCS2Regs)
1639
1722
continue ;
1640
1723
if (Reg == ARM::LR && !isTailCall && !isVarArg && !isInterrupt &&
1641
1724
!isCmseEntry && !isTrap && AFI->getArgumentStackToRestore () == 0 &&
1642
1725
STI.hasV5TOps () && MBB.succ_empty () && !hasPAC &&
1643
- !STI.splitFramePointerPush (MF)) {
1726
+ (STI.getPushPopSplitVariation (MF) !=
1727
+ ARMSubtarget::PushPopSplitVariation::
1728
+ R11SplitAAPCSBranchSigning &&
1729
+ STI.getPushPopSplitVariation (MF) !=
1730
+ ARMSubtarget::PushPopSplitVariation::R11SplitWindowsSEHUnwind)) {
1644
1731
Reg = ARM::PC;
1645
1732
// Fold the return instruction into the LDM.
1646
1733
DeleteRet = true ;
@@ -2001,7 +2088,10 @@ bool ARMFrameLowering::spillCalleeSavedRegisters(
2001
2088
.addImm (-4 )
2002
2089
.add (predOps (ARMCC::AL));
2003
2090
}
2004
- if (STI.splitFramePointerPush (MF)) {
2091
+ if (STI.getPushPopSplitVariation (MF) ==
2092
+ ARMSubtarget::PushPopSplitVariation::R11SplitAAPCSBranchSigning ||
2093
+ STI.getPushPopSplitVariation (MF) ==
2094
+ ARMSubtarget::PushPopSplitVariation::R11SplitWindowsSEHUnwind) {
2005
2095
emitPushInst (MBB, MI, CSI, PushOpc, PushOneOpc, false ,
2006
2096
&isSplitFPArea1Register, 0 , MachineInstr::FrameSetup);
2007
2097
emitPushInst (MBB, MI, CSI, FltOpc, 0 , true , &isARMArea3Register,
@@ -2046,7 +2136,10 @@ bool ARMFrameLowering::restoreCalleeSavedRegisters(
2046
2136
unsigned LdrOpc =
2047
2137
AFI->isThumbFunction () ? ARM::t2LDR_POST : ARM::LDR_POST_IMM;
2048
2138
unsigned FltOpc = ARM::VLDMDIA_UPD;
2049
- if (STI.splitFramePointerPush (MF)) {
2139
+ if (STI.getPushPopSplitVariation (MF) ==
2140
+ ARMSubtarget::PushPopSplitVariation::R11SplitAAPCSBranchSigning ||
2141
+ STI.getPushPopSplitVariation (MF) ==
2142
+ ARMSubtarget::PushPopSplitVariation::R11SplitWindowsSEHUnwind) {
2050
2143
emitPopInst (MBB, MI, CSI, PopOpc, LdrOpc, isVarArg, false ,
2051
2144
&isSplitFPArea2Register, 0 );
2052
2145
emitPopInst (MBB, MI, CSI, FltOpc, 0 , isVarArg, true , &isARMArea3Register,
@@ -2362,7 +2455,8 @@ void ARMFrameLowering::determineCalleeSaves(MachineFunction &MF,
2362
2455
if (Spilled) {
2363
2456
NumGPRSpills++;
2364
2457
2365
- if (!STI.splitFramePushPop (MF)) {
2458
+ if (STI.getPushPopSplitVariation (MF) !=
2459
+ ARMSubtarget::PushPopSplitVariation::R7Split) {
2366
2460
if (Reg == ARM::LR)
2367
2461
LRSpilled = true ;
2368
2462
CS1Spilled = true ;
@@ -2384,7 +2478,8 @@ void ARMFrameLowering::determineCalleeSaves(MachineFunction &MF,
2384
2478
break ;
2385
2479
}
2386
2480
} else {
2387
- if (!STI.splitFramePushPop (MF)) {
2481
+ if (STI.getPushPopSplitVariation (MF) !=
2482
+ ARMSubtarget::PushPopSplitVariation::R7Split) {
2388
2483
UnspilledCS1GPRs.push_back (Reg);
2389
2484
continue ;
2390
2485
}
0 commit comments