Pseudo-ize the ARM 'B' instruction.
authorJim Grosbach <grosbach@apple.com>
Fri, 11 Mar 2011 23:24:15 +0000 (23:24 +0000)
committerJim Grosbach <grosbach@apple.com>
Fri, 11 Mar 2011 23:24:15 +0000 (23:24 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127510 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/ARMAsmPrinter.cpp
lib/Target/ARM/ARMInstrInfo.td
utils/TableGen/ARMDecoderEmitter.cpp

index 478c2468381f70e314a4e05c8663a82eb2e62b77..b48fbf6740aa189522a41342bbc180d4dfe88ec7 100644 (file)
@@ -945,6 +945,17 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
   unsigned Opc = MI->getOpcode();
   switch (Opc) {
   default: break;
+  case ARM::B: {
+    // B is just a Bcc with an 'always' predicate.
+    MCInst TmpInst;
+    LowerARMMachineInstrToMCInst(MI, TmpInst, *this);
+    TmpInst.setOpcode(ARM::Bcc);
+    // Add predicate operands.
+    TmpInst.addOperand(MCOperand::CreateImm(ARMCC::AL));
+    TmpInst.addOperand(MCOperand::CreateReg(0));
+    OutStreamer.EmitInstruction(TmpInst);
+    return;
+  }
   case ARM::LDMIA_RET: {
     // LDMIA_RET is just a normal LDMIA_UPD instruction that targets PC and as
     // such has additional code-gen properties and scheduling information.
index bb40e39903b1945d9ef5b9b1219f01c18604521c..7d499749bf71b96065bd45699bce0ffe61cf8ea6 100644 (file)
@@ -1485,15 +1485,11 @@ let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in {
 }
 
 let isBranch = 1, isTerminator = 1 in {
-  // B is "predicable" since it can be xformed into a Bcc.
+  // B is "predicable" since it's just a Bcc with an 'always' condition.
   let isBarrier = 1 in {
     let isPredicable = 1 in
-    def B : ABXI<0b1010, (outs), (ins brtarget:$target), IIC_Br,
-                "b\t$target", [(br bb:$target)]> {
-      bits<24> target;
-      let Inst{31-28} = 0b1110;
-      let Inst{23-0} = target;
-    }
+    def B : ARMPseudoInst<(outs), (ins brtarget:$target), Size4Bytes, IIC_Br,
+                [(br bb:$target)]>;
 
     let isNotDuplicable = 1, isIndirectBranch = 1 in {
     def BR_JTr : ARMPseudoInst<(outs),
index 3f2c55f424d24e5bb43a35e7b54ae50d007e41a4..2ebfb2e477babac8aa9fbd04210bba634019415a 100644 (file)
@@ -1592,9 +1592,6 @@ ARMDEBackend::populateInstruction(const CodeGenInstruction &CGI,
     // better off using the generic RSCri and RSCrs instructions.
     if (Name == "RSCSri" || Name == "RSCSrs") return false;
 
-    // Bcc is in a more generic form than B.  Ignore B when decoding.
-    if (Name == "B") return false;
-
     // Ignore the non-Darwin BL instructions and the TPsoft (TLS) instruction.
     if (Name == "BL" || Name == "BL_pred" || Name == "BLX" ||
         Name == "BLX_pred" || Name == "TPsoft")