Add a Thumb BRIND pattern. Change the ARM BRIND assembly to separate the
authorBob Wilson <bob.wilson@apple.com>
Wed, 28 Oct 2009 18:26:41 +0000 (18:26 +0000)
committerBob Wilson <bob.wilson@apple.com>
Wed, 28 Oct 2009 18:26:41 +0000 (18:26 +0000)
opcode and operand with a tab.  Check for these instructions in the usual
places.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85411 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/ARMBaseInstrInfo.cpp
lib/Target/ARM/ARMBaseInstrInfo.h
lib/Target/ARM/ARMInstrInfo.cpp
lib/Target/ARM/ARMInstrInfo.td
lib/Target/ARM/ARMInstrThumb.td
lib/Target/ARM/Thumb1InstrInfo.cpp
lib/Target/ARM/Thumb2InstrInfo.cpp

index a4218413a0c6c310131f2f26e5f100381bc8ea6a..6b031da1438429acab2edfdd766f79f00fdd9273 100644 (file)
@@ -249,7 +249,8 @@ ARMBaseInstrInfo::AnalyzeBranch(MachineBasicBlock &MBB,MachineBasicBlock *&TBB,
   // ...likewise if it ends with a branch table followed by an unconditional
   // branch. The branch folder can create these, and we must get rid of them for
   // correctness of Thumb constant islands.
-  if (isJumpTableBranchOpcode(SecondLastOpc) &&
+  if ((isJumpTableBranchOpcode(SecondLastOpc) ||
+       isIndirectBranchOpcode(SecondLastOpc)) &&
       isUncondBranchOpcode(LastOpc)) {
     I = LastInst;
     if (AllowModify)
index a13155b9fd0d1b525fef1bf00df48fd02fb9b687..acb7fdd9f1d0d84cc5892807c2b97b156dfa0f10 100644 (file)
@@ -293,6 +293,11 @@ bool isJumpTableBranchOpcode(int Opc) {
     Opc == ARM::tBR_JTr || Opc == ARM::t2BR_JT;
 }
 
+static inline
+bool isIndirectBranchOpcode(int Opc) {
+  return Opc == ARM::BRIND || Opc == ARM::tBRIND;
+}
+
 /// getInstrPredicate - If instruction is predicated, returns its predicate
 /// condition, otherwise returns AL. It also returns the condition code
 /// register by reference.
index dd4123bfa0a3ea2ebc7da318c296e55be1c45eaf..c24c690f253b7d66bf9718619d24206f9a7f76e8 100644 (file)
@@ -67,6 +67,7 @@ bool ARMInstrInfo::BlockHasNoFallThrough(const MachineBasicBlock &MBB) const {
   case ARM::BX_RET:   // Return.
   case ARM::LDM_RET:
   case ARM::B:
+  case ARM::BRIND:
   case ARM::BR_JTr:   // Jumptable branch.
   case ARM::BR_JTm:   // Jumptable branch through mem.
   case ARM::BR_JTadd: // Jumptable branch add to pc.
index c044f717f3987c0451c2e319a04c85cc12fc8d53..b4a9c4f951c2cd9b425f9e18971e1dbe0a71db16 100644 (file)
@@ -659,7 +659,7 @@ let isReturn = 1, isTerminator = 1, isBarrier = 1 in
 
 // Indirect branches
 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
-  def BRIND : AXI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br, "bx $dst",
+  def BRIND : AXI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br, "bx\t$dst",
                   [(brind GPR:$dst)]> {
     let Inst{7-4}   = 0b0001;
     let Inst{19-8}  = 0b111111111111;
index 1c57b7f171b99185b9920763efd1f918080488d9..b9be32671e3b10da873c8887e86f1c11c85574e6 100644 (file)
@@ -180,6 +180,12 @@ let isReturn = 1, isTerminator = 1, isBarrier = 1 in {
   def tBX_RET_vararg : TI<(outs), (ins tGPR:$target), IIC_Br, "bx\t$target", []>;
 }
 
+// Indirect branches
+let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
+  def tBRIND : TI<(outs), (ins GPR:$dst), IIC_Br, "bx\t$dst",
+                  [(brind GPR:$dst)]>;
+}
+
 // FIXME: remove when we have a way to marking a MI with these properties.
 let isReturn = 1, isTerminator = 1, isBarrier = 1, mayLoad = 1,
     hasExtraDefRegAllocReq = 1 in
index 7eed30edf25c33e739798ca0b74eae10b668ab97..51119dac4dee74997b1b21f3767964a55776cabc 100644 (file)
@@ -38,6 +38,7 @@ Thumb1InstrInfo::BlockHasNoFallThrough(const MachineBasicBlock &MBB) const {
   case ARM::tBX_RET_vararg:
   case ARM::tPOP_RET:
   case ARM::tB:
+  case ARM::tBRIND:
   case ARM::tBR_JTr:
     return true;
   default:
index 264601bf4143e676f81970f71529c1b280de8bc2..634911ab00615898a182f50674e30ee9329b23ef 100644 (file)
@@ -46,6 +46,7 @@ Thumb2InstrInfo::BlockHasNoFallThrough(const MachineBasicBlock &MBB) const {
   case ARM::tBX_RET_vararg:
   case ARM::tPOP_RET:
   case ARM::tB:
+  case ARM::tBRIND:
     return true;
   default:
     break;