Skip to content

Commit 3838ed0

Browse files
committedFeb 2, 2018
[AArch64][GlobalISel] Use getRegClassForTypeOnBank() in selectCopy.
Differential Revision: https://reviews.llvm.org/D42832 llvm-svn: 324110
1 parent 5b8cb26 commit 3838ed0

File tree

1 file changed

+15
-23
lines changed

1 file changed

+15
-23
lines changed
 

‎llvm/lib/Target/AArch64/AArch64InstructionSelector.cpp

+15-23
Original file line numberDiff line numberDiff line change
@@ -135,16 +135,21 @@ AArch64InstructionSelector::AArch64InstructionSelector(
135135
// for each class in the bank.
136136
static const TargetRegisterClass *
137137
getRegClassForTypeOnBank(LLT Ty, const RegisterBank &RB,
138-
const RegisterBankInfo &RBI) {
138+
const RegisterBankInfo &RBI,
139+
bool GetAllRegSet = false) {
139140
if (RB.getID() == AArch64::GPRRegBankID) {
140141
if (Ty.getSizeInBits() <= 32)
141-
return &AArch64::GPR32RegClass;
142+
return GetAllRegSet ? &AArch64::GPR32allRegClass
143+
: &AArch64::GPR32RegClass;
142144
if (Ty.getSizeInBits() == 64)
143-
return &AArch64::GPR64RegClass;
145+
return GetAllRegSet ? &AArch64::GPR64allRegClass
146+
: &AArch64::GPR64RegClass;
144147
return nullptr;
145148
}
146149

147150
if (RB.getID() == AArch64::FPRRegBankID) {
151+
if (Ty.getSizeInBits() <= 16)
152+
return &AArch64::FPR16RegClass;
148153
if (Ty.getSizeInBits() == 32)
149154
return &AArch64::FPR32RegClass;
150155
if (Ty.getSizeInBits() == 64)
@@ -324,6 +329,7 @@ static bool selectCopy(MachineInstr &I, const TargetInstrInfo &TII,
324329

325330
const RegisterBank &RegBank = *RBI.getRegBank(DstReg, MRI, TRI);
326331
const unsigned DstSize = MRI.getType(DstReg).getSizeInBits();
332+
(void)DstSize;
327333
unsigned SrcReg = I.getOperand(1).getReg();
328334
const unsigned SrcSize = RBI.getSizeInBits(SrcReg, MRI, TRI);
329335
(void)SrcSize;
@@ -342,26 +348,12 @@ static bool selectCopy(MachineInstr &I, const TargetInstrInfo &TII,
342348
"Copy with different width?!");
343349
assert((DstSize <= 64 || RegBank.getID() == AArch64::FPRRegBankID) &&
344350
"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;
365357
}
366358

367359
// No need to constrain SrcReg. It will get constrained when

0 commit comments

Comments
 (0)
Please sign in to comment.