From a00425ff0d04ac862a7990e3826f5aa00dad5d56 Mon Sep 17 00:00:00 2001 From: Diana Picus Date: Fri, 15 Feb 2019 10:24:03 +0000 Subject: [ARM GlobalISel] Support branches for Thumb2 Just like arm mode, but with different opcodes. llvm-svn: 354113 --- llvm/lib/Target/ARM/ARMInstructionSelector.cpp | 22 +++++++++++++++------- llvm/lib/Target/ARM/ARMLegalizerInfo.cpp | 4 ++-- 2 files changed, 17 insertions(+), 9 deletions(-) (limited to 'llvm/lib/Target') diff --git a/llvm/lib/Target/ARM/ARMInstructionSelector.cpp b/llvm/lib/Target/ARM/ARMInstructionSelector.cpp index 262300ebb62..3030e219474 100644 --- a/llvm/lib/Target/ARM/ARMInstructionSelector.cpp +++ b/llvm/lib/Target/ARM/ARMInstructionSelector.cpp @@ -106,6 +106,9 @@ private: unsigned CMPri; unsigned MOVCCr; + unsigned TSTri; + unsigned Bcc; + OpcodeCache(const ARMSubtarget &STI); } const Opcodes; @@ -300,6 +303,9 @@ ARMInstructionSelector::OpcodeCache::OpcodeCache(const ARMSubtarget &STI) { STORE_OPCODE(CMPri, CMPri); STORE_OPCODE(MOVCCr, MOVCCr); + + STORE_OPCODE(TSTri, TSTri); + STORE_OPCODE(Bcc, Bcc); #undef MAP_OPCODE } @@ -1008,17 +1014,19 @@ bool ARMInstructionSelector::select(MachineInstr &I, } // Set the flags. - auto Test = BuildMI(*I.getParent(), I, I.getDebugLoc(), TII.get(ARM::TSTri)) - .addReg(I.getOperand(0).getReg()) - .addImm(1) - .add(predOps(ARMCC::AL)); + auto Test = + BuildMI(*I.getParent(), I, I.getDebugLoc(), TII.get(Opcodes.TSTri)) + .addReg(I.getOperand(0).getReg()) + .addImm(1) + .add(predOps(ARMCC::AL)); if (!constrainSelectedInstRegOperands(*Test, TII, TRI, RBI)) return false; // Branch conditionally. - auto Branch = BuildMI(*I.getParent(), I, I.getDebugLoc(), TII.get(ARM::Bcc)) - .add(I.getOperand(1)) - .add(predOps(ARMCC::NE, ARM::CPSR)); + auto Branch = + BuildMI(*I.getParent(), I, I.getDebugLoc(), TII.get(Opcodes.Bcc)) + .add(I.getOperand(1)) + .add(predOps(ARMCC::NE, ARM::CPSR)); if (!constrainSelectedInstRegOperands(*Branch, TII, TRI, RBI)) return false; I.eraseFromParent(); diff --git a/llvm/lib/Target/ARM/ARMLegalizerInfo.cpp b/llvm/lib/Target/ARM/ARMLegalizerInfo.cpp index 2b217ce660e..0794e1711fd 100644 --- a/llvm/lib/Target/ARM/ARMLegalizerInfo.cpp +++ b/llvm/lib/Target/ARM/ARMLegalizerInfo.cpp @@ -140,6 +140,8 @@ ARMLegalizerInfo::ARMLegalizerInfo(const ARMSubtarget &ST) { getActionDefinitionsBuilder(G_GEP).legalFor({{p0, s32}}); + getActionDefinitionsBuilder(G_BRCOND).legalFor({s1}); + if (ST.isThumb()) { // FIXME: merge with the code for non-Thumb. computeTables(); @@ -170,8 +172,6 @@ ARMLegalizerInfo::ARMLegalizerInfo(const ARMSubtarget &ST) { .clampScalar(0, s32, s32); } - getActionDefinitionsBuilder(G_BRCOND).legalFor({s1}); - // We're keeping these builders around because we'll want to add support for // floating point to them. auto &PhiBuilder = -- cgit v1.2.3