summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2018-02-20 15:34:56 +0000
committerHans Wennborg <hans@hanshq.net>2018-02-20 15:34:56 +0000
commit3a4f297d2967b8f86330fb9116229955d6bd6ca1 (patch)
tree2e0f8c82be73ec2f780c6449458f1339e07a3f7e
parent71667f50373a9a452c81d6a83204679a8eebbf0c (diff)
Merging r324110:
------------------------------------------------------------------------ r324110 | aemerson | 2018-02-02 19:03:30 +0100 (Fri, 02 Feb 2018) | 3 lines [AArch64][GlobalISel] Use getRegClassForTypeOnBank() in selectCopy. Differential Revision: https://reviews.llvm.org/D42832 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_60@325584 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Target/AArch64/AArch64InstructionSelector.cpp38
1 files changed, 15 insertions, 23 deletions
diff --git a/lib/Target/AArch64/AArch64InstructionSelector.cpp b/lib/Target/AArch64/AArch64InstructionSelector.cpp
index 2bb9e381073..d60a156666e 100644
--- a/lib/Target/AArch64/AArch64InstructionSelector.cpp
+++ b/lib/Target/AArch64/AArch64InstructionSelector.cpp
@@ -133,16 +133,21 @@ AArch64InstructionSelector::AArch64InstructionSelector(
// for each class in the bank.
static const TargetRegisterClass *
getRegClassForTypeOnBank(LLT Ty, const RegisterBank &RB,
- const RegisterBankInfo &RBI) {
+ const RegisterBankInfo &RBI,
+ bool GetAllRegSet = false) {
if (RB.getID() == AArch64::GPRRegBankID) {
if (Ty.getSizeInBits() <= 32)
- return &AArch64::GPR32RegClass;
+ return GetAllRegSet ? &AArch64::GPR32allRegClass
+ : &AArch64::GPR32RegClass;
if (Ty.getSizeInBits() == 64)
- return &AArch64::GPR64RegClass;
+ return GetAllRegSet ? &AArch64::GPR64allRegClass
+ : &AArch64::GPR64RegClass;
return nullptr;
}
if (RB.getID() == AArch64::FPRRegBankID) {
+ if (Ty.getSizeInBits() <= 16)
+ return &AArch64::FPR16RegClass;
if (Ty.getSizeInBits() == 32)
return &AArch64::FPR32RegClass;
if (Ty.getSizeInBits() == 64)
@@ -322,6 +327,7 @@ static bool selectCopy(MachineInstr &I, const TargetInstrInfo &TII,
const RegisterBank &RegBank = *RBI.getRegBank(DstReg, MRI, TRI);
const unsigned DstSize = MRI.getType(DstReg).getSizeInBits();
+ (void)DstSize;
unsigned SrcReg = I.getOperand(1).getReg();
const unsigned SrcSize = RBI.getSizeInBits(SrcReg, MRI, TRI);
(void)SrcSize;
@@ -340,26 +346,12 @@ static bool selectCopy(MachineInstr &I, const TargetInstrInfo &TII,
"Copy with different width?!");
assert((DstSize <= 64 || RegBank.getID() == AArch64::FPRRegBankID) &&
"GPRs cannot get more than 64-bit width values");
- const TargetRegisterClass *RC = nullptr;
-
- if (RegBank.getID() == AArch64::FPRRegBankID) {
- if (DstSize <= 16)
- RC = &AArch64::FPR16RegClass;
- else if (DstSize <= 32)
- RC = &AArch64::FPR32RegClass;
- else if (DstSize <= 64)
- RC = &AArch64::FPR64RegClass;
- else if (DstSize <= 128)
- RC = &AArch64::FPR128RegClass;
- else {
- DEBUG(dbgs() << "Unexpected bitcast size " << DstSize << '\n');
- return false;
- }
- } else {
- assert(RegBank.getID() == AArch64::GPRRegBankID &&
- "Bitcast for the flags?");
- RC =
- DstSize <= 32 ? &AArch64::GPR32allRegClass : &AArch64::GPR64allRegClass;
+
+ const TargetRegisterClass *RC = getRegClassForTypeOnBank(
+ MRI.getType(DstReg), RegBank, RBI, /* GetAllRegSet */ true);
+ if (!RC) {
+ DEBUG(dbgs() << "Unexpected bitcast size " << DstSize << '\n');
+ return false;
}
// No need to constrain SrcReg. It will get constrained when