@@ -135,16 +135,21 @@ AArch64InstructionSelector::AArch64InstructionSelector(
135
135
// for each class in the bank.
136
136
static const TargetRegisterClass *
137
137
getRegClassForTypeOnBank (LLT Ty, const RegisterBank &RB,
138
- const RegisterBankInfo &RBI) {
138
+ const RegisterBankInfo &RBI,
139
+ bool GetAllRegSet = false ) {
139
140
if (RB.getID () == AArch64::GPRRegBankID) {
140
141
if (Ty.getSizeInBits () <= 32 )
141
- return &AArch64::GPR32RegClass;
142
+ return GetAllRegSet ? &AArch64::GPR32allRegClass
143
+ : &AArch64::GPR32RegClass;
142
144
if (Ty.getSizeInBits () == 64 )
143
- return &AArch64::GPR64RegClass;
145
+ return GetAllRegSet ? &AArch64::GPR64allRegClass
146
+ : &AArch64::GPR64RegClass;
144
147
return nullptr ;
145
148
}
146
149
147
150
if (RB.getID () == AArch64::FPRRegBankID) {
151
+ if (Ty.getSizeInBits () <= 16 )
152
+ return &AArch64::FPR16RegClass;
148
153
if (Ty.getSizeInBits () == 32 )
149
154
return &AArch64::FPR32RegClass;
150
155
if (Ty.getSizeInBits () == 64 )
@@ -324,6 +329,7 @@ static bool selectCopy(MachineInstr &I, const TargetInstrInfo &TII,
324
329
325
330
const RegisterBank &RegBank = *RBI.getRegBank (DstReg, MRI, TRI);
326
331
const unsigned DstSize = MRI.getType (DstReg).getSizeInBits ();
332
+ (void )DstSize;
327
333
unsigned SrcReg = I.getOperand (1 ).getReg ();
328
334
const unsigned SrcSize = RBI.getSizeInBits (SrcReg, MRI, TRI);
329
335
(void )SrcSize;
@@ -342,26 +348,12 @@ static bool selectCopy(MachineInstr &I, const TargetInstrInfo &TII,
342
348
" Copy with different width?!" );
343
349
assert ((DstSize <= 64 || RegBank.getID () == AArch64::FPRRegBankID) &&
344
350
" GPRs cannot get more than 64-bit width values" );
345
- const TargetRegisterClass *RC = nullptr ;
346
-
347
- if (RegBank.getID () == AArch64::FPRRegBankID) {
348
- if (DstSize <= 16 )
349
- RC = &AArch64::FPR16RegClass;
350
- else if (DstSize <= 32 )
351
- RC = &AArch64::FPR32RegClass;
352
- else if (DstSize <= 64 )
353
- RC = &AArch64::FPR64RegClass;
354
- else if (DstSize <= 128 )
355
- RC = &AArch64::FPR128RegClass;
356
- else {
357
- DEBUG (dbgs () << " Unexpected bitcast size " << DstSize << ' \n ' );
358
- return false ;
359
- }
360
- } else {
361
- assert (RegBank.getID () == AArch64::GPRRegBankID &&
362
- " Bitcast for the flags?" );
363
- RC =
364
- DstSize <= 32 ? &AArch64::GPR32allRegClass : &AArch64::GPR64allRegClass;
351
+
352
+ const TargetRegisterClass *RC = getRegClassForTypeOnBank (
353
+ MRI.getType (DstReg), RegBank, RBI, /* GetAllRegSet */ true );
354
+ if (!RC) {
355
+ DEBUG (dbgs () << " Unexpected bitcast size " << DstSize << ' \n ' );
356
+ return false ;
365
357
}
366
358
367
359
// No need to constrain SrcReg. It will get constrained when
0 commit comments