ARM assembly parsing and encoding for BLX (immediate).
authorJim Grosbach <grosbach@apple.com>
Thu, 28 Jul 2011 21:57:55 +0000 (21:57 +0000)
committerJim Grosbach <grosbach@apple.com>
Thu, 28 Jul 2011 21:57:55 +0000 (21:57 +0000)
Add parsing support for BLX (immediate). Since the register operand version is
predicated and the label operand version is not, we have to use some special
handling to get the operand list right for matching.

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

lib/Target/ARM/ARMInstrInfo.td
lib/Target/ARM/AsmParser/ARMAsmParser.cpp
test/MC/ARM/basic-arm-instructions.s

index fec5f72bcfe6ecf16c1e89efd10c68e1177e8c1c..1a23651d8d39b620f095ab1ab858450220345237 100644 (file)
@@ -1639,9 +1639,9 @@ let isBranch = 1, isTerminator = 1 in {
 
 }
 
-// BLX (immediate) -- for disassembly only
+// BLX (immediate)
 def BLXi : AXI<(outs), (ins br_target:$target), BrMiscFrm, NoItinerary,
-               "blx\t$target", [/* pattern left blank */]>,
+               "blx\t$target", []>,
            Requires<[IsARM, HasV5T]> {
   let Inst{31-25} = 0b1111101;
   bits<25> target;
index a528572349bde55a06575ea5da7662ec6f3a6ce9..42e2f7f8f542d4448388653cf091eb2c78c6a72e 100644 (file)
@@ -2675,6 +2675,17 @@ bool ARMAsmParser::ParseInstruction(StringRef Name, SMLoc NameLoc,
     delete Op;
   }
 
+  // ARM mode 'blx' need special handling, as the register operand version
+  // is predicable, but the label operand version is not. So, we can't rely
+  // on the Mnemonic based checking to correctly figure out when to put
+  // a CondCode operand in the list. If we're trying to match the label
+  // version, remove the CondCode operand here.
+  if (!isThumb() && Mnemonic == "blx" && Operands.size() == 3 &&
+      static_cast<ARMOperand*>(Operands[2])->isImm()) {
+    ARMOperand *Op = static_cast<ARMOperand*>(Operands[1]);
+    Operands.erase(Operands.begin() + 1);
+    delete Op;
+  }
   return false;
 }
 
index 10ffc975b897d972a97e0f81a4002be4871ebacf..352a050f902c45a7930f6f958b404acb87619d62 100644 (file)
@@ -358,10 +358,12 @@ Lforward:
 @------------------------------------------------------------------------------
 
   bl _bar
-  @ FIXME: blx _bar
+  blx _bar
 
 @ CHECK: bl  _bar @ encoding: [A,A,A,0xeb]
 @ CHECK:   @   fixup A - offset: 0, value: _bar, kind: fixup_arm_uncondbranch
+@ CHECK: blx   _bar @ encoding: [A,A,A,0xfa]
+           @   fixup A - offset: 0, value: _bar, kind: fixup_arm_uncondbranch
 
 @------------------------------------------------------------------------------
 @ BLX (register)