@@ -2926,26 +2926,12 @@ struct RegPairInfo {
2926
2926
int FrameIdx;
2927
2927
int Offset;
2928
2928
enum RegType { GPR, FPR64, FPR128, PPR, ZPR, VG } Type;
2929
+ const TargetRegisterClass *RC;
2929
2930
2930
2931
RegPairInfo () = default ;
2931
2932
2932
2933
bool isPaired () const { return Reg2 != AArch64::NoRegister; }
2933
2934
2934
- unsigned getScale () const {
2935
- switch (Type) {
2936
- case PPR:
2937
- return 2 ;
2938
- case GPR:
2939
- case FPR64:
2940
- case VG:
2941
- return 8 ;
2942
- case ZPR:
2943
- case FPR128:
2944
- return 16 ;
2945
- }
2946
- llvm_unreachable (" Unsupported type" );
2947
- }
2948
-
2949
2935
bool isScalable () const { return Type == PPR || Type == ZPR; }
2950
2936
};
2951
2937
@@ -3023,20 +3009,27 @@ static void computeCalleeSaveRegisterPairs(
3023
3009
RegPairInfo RPI;
3024
3010
RPI.Reg1 = CSI[i].getReg ();
3025
3011
3026
- if (AArch64::GPR64RegClass.contains (RPI.Reg1 ))
3012
+ if (AArch64::GPR64RegClass.contains (RPI.Reg1 )) {
3027
3013
RPI.Type = RegPairInfo::GPR;
3028
- else if (AArch64::FPR64RegClass.contains (RPI.Reg1 ))
3014
+ RPI.RC = &AArch64::GPR64RegClass;
3015
+ } else if (AArch64::FPR64RegClass.contains (RPI.Reg1 )) {
3029
3016
RPI.Type = RegPairInfo::FPR64;
3030
- else if (AArch64::FPR128RegClass.contains (RPI.Reg1 ))
3017
+ RPI.RC = &AArch64::FPR64RegClass;
3018
+ } else if (AArch64::FPR128RegClass.contains (RPI.Reg1 )) {
3031
3019
RPI.Type = RegPairInfo::FPR128;
3032
- else if (AArch64::ZPRRegClass.contains (RPI.Reg1 ))
3020
+ RPI.RC = &AArch64::FPR128RegClass;
3021
+ } else if (AArch64::ZPRRegClass.contains (RPI.Reg1 )) {
3033
3022
RPI.Type = RegPairInfo::ZPR;
3034
- else if (AArch64::PPRRegClass.contains (RPI.Reg1 ))
3023
+ RPI.RC = &AArch64::ZPRRegClass;
3024
+ } else if (AArch64::PPRRegClass.contains (RPI.Reg1 )) {
3035
3025
RPI.Type = RegPairInfo::PPR;
3036
- else if (RPI.Reg1 == AArch64::VG)
3026
+ RPI.RC = &AArch64::PPRRegClass;
3027
+ } else if (RPI.Reg1 == AArch64::VG) {
3037
3028
RPI.Type = RegPairInfo::VG;
3038
- else
3029
+ RPI.RC = &AArch64::FIXED_REGSRegClass;
3030
+ } else {
3039
3031
llvm_unreachable (" Unsupported register class." );
3032
+ }
3040
3033
3041
3034
// Add the stack hazard size as we transition from GPR->FPR CSRs.
3042
3035
if (AFI->hasStackHazardSlotIndex () &&
@@ -3045,7 +3038,7 @@ static void computeCalleeSaveRegisterPairs(
3045
3038
ByteOffset += StackFillDir * StackHazardSize;
3046
3039
LastReg = RPI.Reg1 ;
3047
3040
3048
- int Scale = RPI.getScale ( );
3041
+ int Scale = TRI-> getSpillSize (* RPI.RC );
3049
3042
// Add the next reg to the pair if it is in the same register class.
3050
3043
if (unsigned (i + RegInc) < Count && !AFI->hasStackHazardSlotIndex ()) {
3051
3044
Register NextReg = CSI[i + RegInc].getReg ();
@@ -3254,38 +3247,26 @@ bool AArch64FrameLowering::spillCalleeSavedRegisters(
3254
3247
// Rationale: This sequence saves uop updates compared to a sequence of
3255
3248
// pre-increment spills like stp xi,xj,[sp,#-16]!
3256
3249
// Note: Similar rationale and sequence for restores in epilog.
3257
- unsigned Size;
3258
- Align Alignment;
3250
+ unsigned Size = TRI-> getSpillSize (*RPI. RC ) ;
3251
+ Align Alignment = TRI-> getSpillAlign (*RPI. RC ) ;
3259
3252
switch (RPI.Type ) {
3260
3253
case RegPairInfo::GPR:
3261
3254
StrOpc = RPI.isPaired () ? AArch64::STPXi : AArch64::STRXui;
3262
- Size = 8 ;
3263
- Alignment = Align (8 );
3264
3255
break ;
3265
3256
case RegPairInfo::FPR64:
3266
3257
StrOpc = RPI.isPaired () ? AArch64::STPDi : AArch64::STRDui;
3267
- Size = 8 ;
3268
- Alignment = Align (8 );
3269
3258
break ;
3270
3259
case RegPairInfo::FPR128:
3271
3260
StrOpc = RPI.isPaired () ? AArch64::STPQi : AArch64::STRQui;
3272
- Size = 16 ;
3273
- Alignment = Align (16 );
3274
3261
break ;
3275
3262
case RegPairInfo::ZPR:
3276
3263
StrOpc = RPI.isPaired () ? AArch64::ST1B_2Z_IMM : AArch64::STR_ZXI;
3277
- Size = 16 ;
3278
- Alignment = Align (16 );
3279
3264
break ;
3280
3265
case RegPairInfo::PPR:
3281
3266
StrOpc = AArch64::STR_PXI;
3282
- Size = 2 ;
3283
- Alignment = Align (2 );
3284
3267
break ;
3285
3268
case RegPairInfo::VG:
3286
3269
StrOpc = AArch64::STRXui;
3287
- Size = 8 ;
3288
- Alignment = Align (8 );
3289
3270
break ;
3290
3271
}
3291
3272
@@ -3495,33 +3476,23 @@ bool AArch64FrameLowering::restoreCalleeSavedRegisters(
3495
3476
// ldp x22, x21, [sp, #0] // addImm(+0)
3496
3477
// Note: see comment in spillCalleeSavedRegisters()
3497
3478
unsigned LdrOpc;
3498
- unsigned Size;
3499
- Align Alignment;
3479
+ unsigned Size = TRI-> getSpillSize (*RPI. RC ) ;
3480
+ Align Alignment = TRI-> getSpillAlign (*RPI. RC ) ;
3500
3481
switch (RPI.Type ) {
3501
3482
case RegPairInfo::GPR:
3502
3483
LdrOpc = RPI.isPaired () ? AArch64::LDPXi : AArch64::LDRXui;
3503
- Size = 8 ;
3504
- Alignment = Align (8 );
3505
3484
break ;
3506
3485
case RegPairInfo::FPR64:
3507
3486
LdrOpc = RPI.isPaired () ? AArch64::LDPDi : AArch64::LDRDui;
3508
- Size = 8 ;
3509
- Alignment = Align (8 );
3510
3487
break ;
3511
3488
case RegPairInfo::FPR128:
3512
3489
LdrOpc = RPI.isPaired () ? AArch64::LDPQi : AArch64::LDRQui;
3513
- Size = 16 ;
3514
- Alignment = Align (16 );
3515
3490
break ;
3516
3491
case RegPairInfo::ZPR:
3517
3492
LdrOpc = RPI.isPaired () ? AArch64::LD1B_2Z_IMM : AArch64::LDR_ZXI;
3518
- Size = 16 ;
3519
- Alignment = Align (16 );
3520
3493
break ;
3521
3494
case RegPairInfo::PPR:
3522
3495
LdrOpc = AArch64::LDR_PXI;
3523
- Size = 2 ;
3524
- Alignment = Align (2 );
3525
3496
break ;
3526
3497
case RegPairInfo::VG:
3527
3498
continue ;
0 commit comments