mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 19:52:54 +01:00
[ARM] GlobalISel: Select shifts
Unfortunately TableGen doesn't handle this yet: Unable to deduce gMIR opcode to handle Src (which is a leaf). Just add some temporary hand-written code to generate the proper MOVsr. llvm-svn: 315071
This commit is contained in:
parent
8e11cf0c12
commit
a66dd16961
@ -59,6 +59,7 @@ private:
|
||||
|
||||
bool selectGlobal(MachineInstrBuilder &MIB, MachineRegisterInfo &MRI) const;
|
||||
bool selectSelect(MachineInstrBuilder &MIB, MachineRegisterInfo &MRI) const;
|
||||
bool selectShift(unsigned ShiftOpc, MachineInstrBuilder &MIB) const;
|
||||
|
||||
// Check if the types match and both operands have the expected size and
|
||||
// register bank.
|
||||
@ -640,6 +641,14 @@ bool ARMInstructionSelector::selectSelect(MachineInstrBuilder &MIB,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ARMInstructionSelector::selectShift(unsigned ShiftOpc,
|
||||
MachineInstrBuilder &MIB) const {
|
||||
MIB->setDesc(TII.get(ARM::MOVsr));
|
||||
MIB.addImm(ShiftOpc);
|
||||
MIB.add(predOps(ARMCC::AL)).add(condCodeOp());
|
||||
return constrainSelectedInstRegOperands(*MIB, TII, TRI, RBI);
|
||||
}
|
||||
|
||||
bool ARMInstructionSelector::select(MachineInstr &I) const {
|
||||
assert(I.getParent() && "Instruction should be in a basic block!");
|
||||
assert(I.getParent()->getParent() && "Instruction should be in a function!");
|
||||
@ -766,6 +775,13 @@ bool ARMInstructionSelector::select(MachineInstr &I) const {
|
||||
ARM::FPRRegBankID, Size);
|
||||
return selectCmp(Helper, MIB, MRI);
|
||||
}
|
||||
case G_LSHR:
|
||||
return selectShift(ARM_AM::ShiftOpc::lsr, MIB);
|
||||
case G_ASHR:
|
||||
return selectShift(ARM_AM::ShiftOpc::asr, MIB);
|
||||
case G_SHL: {
|
||||
return selectShift(ARM_AM::ShiftOpc::lsl, MIB);
|
||||
}
|
||||
case G_GEP:
|
||||
I.setDesc(TII.get(ARM::ADDrr));
|
||||
MIB.add(predOps(ARMCC::AL)).add(condCodeOp());
|
||||
|
@ -32,6 +32,10 @@
|
||||
define void @test_or_s32() { ret void }
|
||||
define void @test_xor_s32() { ret void }
|
||||
|
||||
define void @test_lshr_s32() { ret void }
|
||||
define void @test_ashr_s32() { ret void }
|
||||
define void @test_shl_s32() { ret void }
|
||||
|
||||
define void @test_load_from_stack() { ret void }
|
||||
define void @test_load_f32() #0 { ret void }
|
||||
define void @test_load_f64() #0 { ret void }
|
||||
@ -891,6 +895,105 @@ body: |
|
||||
; CHECK: BX_RET 14, _, implicit %r0
|
||||
...
|
||||
---
|
||||
name: test_lshr_s32
|
||||
# CHECK-LABEL: name: test_lshr_s32
|
||||
legalized: true
|
||||
regBankSelected: true
|
||||
selected: false
|
||||
# CHECK: selected: true
|
||||
registers:
|
||||
- { id: 0, class: gprb }
|
||||
- { id: 1, class: gprb }
|
||||
- { id: 2, class: gprb }
|
||||
# CHECK: id: 0, class: gpr
|
||||
# CHECK: id: 1, class: gpr
|
||||
# CHECK: id: 2, class: gpr
|
||||
body: |
|
||||
bb.0:
|
||||
liveins: %r0, %r1
|
||||
|
||||
%0(s32) = COPY %r0
|
||||
; CHECK: [[VREGX:%[0-9]+]] = COPY %r0
|
||||
|
||||
%1(s32) = COPY %r1
|
||||
; CHECK: [[VREGY:%[0-9]+]] = COPY %r1
|
||||
|
||||
%2(s32) = G_LSHR %0, %1
|
||||
; CHECK: [[VREGRES:%[0-9]+]] = MOVsr [[VREGX]], [[VREGY]], 3, 14, _, _
|
||||
|
||||
%r0 = COPY %2(s32)
|
||||
; CHECK: %r0 = COPY [[VREGRES]]
|
||||
|
||||
BX_RET 14, _, implicit %r0
|
||||
; CHECK: BX_RET 14, _, implicit %r0
|
||||
...
|
||||
---
|
||||
name: test_ashr_s32
|
||||
# CHECK-LABEL: name: test_ashr_s32
|
||||
legalized: true
|
||||
regBankSelected: true
|
||||
selected: false
|
||||
# CHECK: selected: true
|
||||
registers:
|
||||
- { id: 0, class: gprb }
|
||||
- { id: 1, class: gprb }
|
||||
- { id: 2, class: gprb }
|
||||
# CHECK: id: 0, class: gpr
|
||||
# CHECK: id: 1, class: gpr
|
||||
# CHECK: id: 2, class: gpr
|
||||
body: |
|
||||
bb.0:
|
||||
liveins: %r0, %r1
|
||||
|
||||
%0(s32) = COPY %r0
|
||||
; CHECK: [[VREGX:%[0-9]+]] = COPY %r0
|
||||
|
||||
%1(s32) = COPY %r1
|
||||
; CHECK: [[VREGY:%[0-9]+]] = COPY %r1
|
||||
|
||||
%2(s32) = G_ASHR %0, %1
|
||||
; CHECK: [[VREGRES:%[0-9]+]] = MOVsr [[VREGX]], [[VREGY]], 1, 14, _, _
|
||||
|
||||
%r0 = COPY %2(s32)
|
||||
; CHECK: %r0 = COPY [[VREGRES]]
|
||||
|
||||
BX_RET 14, _, implicit %r0
|
||||
; CHECK: BX_RET 14, _, implicit %r0
|
||||
...
|
||||
---
|
||||
name: test_shl_s32
|
||||
# CHECK-LABEL: name: test_shl_s32
|
||||
legalized: true
|
||||
regBankSelected: true
|
||||
selected: false
|
||||
# CHECK: selected: true
|
||||
registers:
|
||||
- { id: 0, class: gprb }
|
||||
- { id: 1, class: gprb }
|
||||
- { id: 2, class: gprb }
|
||||
# CHECK: id: 0, class: gpr
|
||||
# CHECK: id: 1, class: gpr
|
||||
# CHECK: id: 2, class: gpr
|
||||
body: |
|
||||
bb.0:
|
||||
liveins: %r0, %r1
|
||||
|
||||
%0(s32) = COPY %r0
|
||||
; CHECK: [[VREGX:%[0-9]+]] = COPY %r0
|
||||
|
||||
%1(s32) = COPY %r1
|
||||
; CHECK: [[VREGY:%[0-9]+]] = COPY %r1
|
||||
|
||||
%2(s32) = G_SHL %0, %1
|
||||
; CHECK: [[VREGRES:%[0-9]+]] = MOVsr [[VREGX]], [[VREGY]], 2, 14, _, _
|
||||
|
||||
%r0 = COPY %2(s32)
|
||||
; CHECK: %r0 = COPY [[VREGRES]]
|
||||
|
||||
BX_RET 14, _, implicit %r0
|
||||
; CHECK: BX_RET 14, _, implicit %r0
|
||||
...
|
||||
---
|
||||
name: test_load_from_stack
|
||||
# CHECK-LABEL: name: test_load_from_stack
|
||||
legalized: true
|
||||
|
Loading…
Reference in New Issue
Block a user