diff options
| author | Diana Picus <diana.picus@linaro.org> | 2019-02-07 11:05:33 +0000 |
|---|---|---|
| committer | Diana Picus <diana.picus@linaro.org> | 2019-02-07 11:05:33 +0000 |
| commit | 75a04e2a77e14de2f42e2b7ddd002cc0a4ac57e5 (patch) | |
| tree | fb39b62b482cbbd9d17a962147d0bbfb0962c09e /llvm/lib/Target | |
| parent | baf2f35ec4c5adeaab2a51b2e6c5eb6156f82575 (diff) | |
| download | bcm5719-llvm-75a04e2a77e14de2f42e2b7ddd002cc0a4ac57e5.tar.gz bcm5719-llvm-75a04e2a77e14de2f42e2b7ddd002cc0a4ac57e5.zip | |
[ARM GlobalISel] Support G_ICMP for Thumb2
Mark as legal and use the t2* equivalents of the arm mode instructions,
e.g. t2CMPrr instead of plain CMPrr.
llvm-svn: 353392
Diffstat (limited to 'llvm/lib/Target')
| -rw-r--r-- | llvm/lib/Target/ARM/ARMInstructionSelector.cpp | 29 | ||||
| -rw-r--r-- | llvm/lib/Target/ARM/ARMLegalizerInfo.cpp | 8 |
2 files changed, 25 insertions, 12 deletions
diff --git a/llvm/lib/Target/ARM/ARMInstructionSelector.cpp b/llvm/lib/Target/ARM/ARMInstructionSelector.cpp index 2d80a193b03..960953235de 100644 --- a/llvm/lib/Target/ARM/ARMInstructionSelector.cpp +++ b/llvm/lib/Target/ARM/ARMInstructionSelector.cpp @@ -97,6 +97,10 @@ private: unsigned STORE8; unsigned LOAD8; + unsigned CMPrr; + unsigned MOVi; + unsigned MOVCCi; + OpcodeCache(const ARMSubtarget &STI); } const Opcodes; @@ -284,6 +288,10 @@ ARMInstructionSelector::OpcodeCache::OpcodeCache(const ARMSubtarget &STI) { STORE_OPCODE(STORE8, STRBi12); STORE_OPCODE(LOAD8, LDRBi12); + + STORE_OPCODE(CMPrr, CMPrr); + STORE_OPCODE(MOVi, MOVi); + STORE_OPCODE(MOVCCi, MOVCCi); #undef MAP_OPCODE } @@ -407,10 +415,11 @@ getComparePreds(CmpInst::Predicate Pred) { } struct ARMInstructionSelector::CmpConstants { - CmpConstants(unsigned CmpOpcode, unsigned FlagsOpcode, unsigned OpRegBank, - unsigned OpSize) + CmpConstants(unsigned CmpOpcode, unsigned FlagsOpcode, unsigned SelectOpcode, + unsigned OpRegBank, unsigned OpSize) : ComparisonOpcode(CmpOpcode), ReadFlagsOpcode(FlagsOpcode), - OperandRegBankID(OpRegBank), OperandSize(OpSize) {} + SelectResultOpcode(SelectOpcode), OperandRegBankID(OpRegBank), + OperandSize(OpSize) {} // The opcode used for performing the comparison. const unsigned ComparisonOpcode; @@ -419,6 +428,9 @@ struct ARMInstructionSelector::CmpConstants { // ARM::INSTRUCTION_LIST_END if we don't need to read the flags. const unsigned ReadFlagsOpcode; + // The opcode used for materializing the result of the comparison. + const unsigned SelectResultOpcode; + // The assumed register bank ID for the operands. const unsigned OperandRegBankID; @@ -438,7 +450,7 @@ struct ARMInstructionSelector::InsertInfo { void ARMInstructionSelector::putConstant(InsertInfo I, unsigned DestReg, unsigned Constant) const { - (void)BuildMI(I.MBB, I.InsertBefore, I.DbgLoc, TII.get(ARM::MOVi)) + (void)BuildMI(I.MBB, I.InsertBefore, I.DbgLoc, TII.get(Opcodes.MOVi)) .addDef(DestReg) .addImm(Constant) .add(predOps(ARMCC::AL)) @@ -541,7 +553,8 @@ bool ARMInstructionSelector::insertComparison(CmpConstants Helper, InsertInfo I, } // Select either 1 or the previous result based on the value of the flags. - auto Mov1I = BuildMI(I.MBB, I.InsertBefore, I.DbgLoc, TII.get(ARM::MOVCCi)) + auto Mov1I = BuildMI(I.MBB, I.InsertBefore, I.DbgLoc, + TII.get(Helper.SelectResultOpcode)) .addDef(ResReg) .addUse(PrevRes) .addImm(1) @@ -899,8 +912,8 @@ bool ARMInstructionSelector::select(MachineInstr &I, case G_SELECT: return selectSelect(MIB, MRI); case G_ICMP: { - CmpConstants Helper(ARM::CMPrr, ARM::INSTRUCTION_LIST_END, - ARM::GPRRegBankID, 32); + CmpConstants Helper(Opcodes.CMPrr, ARM::INSTRUCTION_LIST_END, + Opcodes.MOVCCi, ARM::GPRRegBankID, 32); return selectCmp(Helper, MIB, MRI); } case G_FCMP: { @@ -919,7 +932,7 @@ bool ARMInstructionSelector::select(MachineInstr &I, } CmpConstants Helper(Size == 32 ? ARM::VCMPS : ARM::VCMPD, ARM::FMSTAT, - ARM::FPRRegBankID, Size); + Opcodes.MOVCCi, ARM::FPRRegBankID, Size); return selectCmp(Helper, MIB, MRI); } case G_LSHR: diff --git a/llvm/lib/Target/ARM/ARMLegalizerInfo.cpp b/llvm/lib/Target/ARM/ARMLegalizerInfo.cpp index fb7053c8c00..0a8beaa5d82 100644 --- a/llvm/lib/Target/ARM/ARMLegalizerInfo.cpp +++ b/llvm/lib/Target/ARM/ARMLegalizerInfo.cpp @@ -120,6 +120,10 @@ ARMLegalizerInfo::ARMLegalizerInfo(const ARMSubtarget &ST) { .legalFor({s32, p0}) .clampScalar(0, s32, s32); + getActionDefinitionsBuilder(G_ICMP) + .legalForCartesianProduct({s1}, {s32, p0}) + .minScalar(1, s32); + // We're keeping these builders around because we'll want to add support for // floating point to them. auto &LoadStoreBuilder = @@ -168,10 +172,6 @@ ARMLegalizerInfo::ARMLegalizerInfo(const ARMSubtarget &ST) { getActionDefinitionsBuilder(G_BRCOND).legalFor({s1}); - getActionDefinitionsBuilder(G_ICMP) - .legalForCartesianProduct({s1}, {s32, p0}) - .minScalar(1, s32); - // We're keeping these builders around because we'll want to add support for // floating point to them. auto &PhiBuilder = |

