forked from OSchip/llvm-project
[AArch64][GlobalISel] Select all fpexts.
Tablegen already can select these: mark them as legal, remove the c++ code, and add tests for all types. llvm-svn: 313074
This commit is contained in:
parent
a7aa2a9fb1
commit
106dd035a8
|
@ -1180,33 +1180,6 @@ bool AArch64InstructionSelector::select(MachineInstr &I) const {
|
|||
return selectCopy(I, TII, MRI, TRI, RBI);
|
||||
return false;
|
||||
|
||||
case TargetOpcode::G_FPEXT: {
|
||||
if (MRI.getType(I.getOperand(0).getReg()) != LLT::scalar(64)) {
|
||||
DEBUG(dbgs() << "G_FPEXT to type " << Ty
|
||||
<< ", expected: " << LLT::scalar(64) << '\n');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (MRI.getType(I.getOperand(1).getReg()) != LLT::scalar(32)) {
|
||||
DEBUG(dbgs() << "G_FPEXT from type " << Ty
|
||||
<< ", expected: " << LLT::scalar(32) << '\n');
|
||||
return false;
|
||||
}
|
||||
|
||||
const unsigned DefReg = I.getOperand(0).getReg();
|
||||
const RegisterBank &RB = *RBI.getRegBank(DefReg, MRI, TRI);
|
||||
|
||||
if (RB.getID() != AArch64::FPRRegBankID) {
|
||||
DEBUG(dbgs() << "G_FPEXT on bank: " << RB << ", expected: FPR\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
I.setDesc(TII.get(AArch64::FCVTDSr));
|
||||
constrainSelectedInstRegOperands(I, TII, TRI, RBI);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
case TargetOpcode::G_SELECT: {
|
||||
if (MRI.getType(I.getOperand(1).getReg()) != LLT::scalar(1)) {
|
||||
DEBUG(dbgs() << "G_SELECT cond has type: " << Ty
|
||||
|
|
|
@ -161,15 +161,16 @@ AArch64LegalizerInfo::AArch64LegalizerInfo() {
|
|||
setAction({G_ANYEXT, 1, Ty}, Legal);
|
||||
}
|
||||
|
||||
setAction({G_FPEXT, s64}, Legal);
|
||||
setAction({G_FPEXT, 1, s32}, Legal);
|
||||
|
||||
// Truncations
|
||||
for (auto Ty : { s16, s32 })
|
||||
// FP conversions
|
||||
for (auto Ty : { s16, s32 }) {
|
||||
setAction({G_FPTRUNC, Ty}, Legal);
|
||||
setAction({G_FPEXT, 1, Ty}, Legal);
|
||||
}
|
||||
|
||||
for (auto Ty : { s32, s64 })
|
||||
for (auto Ty : { s32, s64 }) {
|
||||
setAction({G_FPTRUNC, 1, Ty}, Legal);
|
||||
setAction({G_FPEXT, Ty}, Legal);
|
||||
}
|
||||
|
||||
for (auto Ty : { s1, s8, s16, s32 })
|
||||
setAction({G_TRUNC, Ty}, Legal);
|
||||
|
|
|
@ -7,7 +7,9 @@
|
|||
define void @fptrunc_s16_s64_fpr() { ret void }
|
||||
define void @fptrunc_s32_s64_fpr() { ret void }
|
||||
|
||||
define void @fpext() { ret void }
|
||||
define void @fpext_s32_s16_fpr() { ret void }
|
||||
define void @fpext_s64_s16_fpr() { ret void }
|
||||
define void @fpext_s64_s32_fpr() { ret void }
|
||||
|
||||
define void @sitofp_s32_s32_fpr() { ret void }
|
||||
define void @sitofp_s32_s64_fpr() { ret void }
|
||||
|
@ -106,8 +108,58 @@ body: |
|
|||
...
|
||||
|
||||
---
|
||||
# CHECK-LABEL: name: fpext
|
||||
name: fpext
|
||||
# CHECK-LABEL: name: fpext_s32_s16_fpr
|
||||
name: fpext_s32_s16_fpr
|
||||
legalized: true
|
||||
regBankSelected: true
|
||||
|
||||
# CHECK: registers:
|
||||
# CHECK: - { id: 0, class: fpr16, preferred-register: '' }
|
||||
# CHECK: - { id: 1, class: fpr32, preferred-register: '' }
|
||||
registers:
|
||||
- { id: 0, class: fpr }
|
||||
- { id: 1, class: fpr }
|
||||
|
||||
# CHECK: body:
|
||||
# CHECK: %0 = COPY %h0
|
||||
# CHECK: %1 = FCVTSHr %0
|
||||
body: |
|
||||
bb.0:
|
||||
liveins: %h0
|
||||
|
||||
%0(s16) = COPY %h0
|
||||
%1(s32) = G_FPEXT %0
|
||||
%s0 = COPY %1(s32)
|
||||
...
|
||||
|
||||
---
|
||||
# CHECK-LABEL: name: fpext_s64_s16_fpr
|
||||
name: fpext_s64_s16_fpr
|
||||
legalized: true
|
||||
regBankSelected: true
|
||||
|
||||
# CHECK: registers:
|
||||
# CHECK: - { id: 0, class: fpr16, preferred-register: '' }
|
||||
# CHECK: - { id: 1, class: fpr64, preferred-register: '' }
|
||||
registers:
|
||||
- { id: 0, class: fpr }
|
||||
- { id: 1, class: fpr }
|
||||
|
||||
# CHECK: body:
|
||||
# CHECK: %0 = COPY %h0
|
||||
# CHECK: %1 = FCVTDHr %0
|
||||
body: |
|
||||
bb.0:
|
||||
liveins: %h0
|
||||
|
||||
%0(s16) = COPY %h0
|
||||
%1(s64) = G_FPEXT %0
|
||||
%d0 = COPY %1(s64)
|
||||
...
|
||||
|
||||
---
|
||||
# CHECK-LABEL: name: fpext_s64_s32_fpr
|
||||
name: fpext_s64_s32_fpr
|
||||
legalized: true
|
||||
regBankSelected: true
|
||||
|
||||
|
|
Loading…
Reference in New Issue