Thumb disassembler did not handle tBRIND (indirect branch) properly.
authorJohnny Chen <johnny.chen@apple.com>
Wed, 13 Apr 2011 21:59:01 +0000 (21:59 +0000)
committerJohnny Chen <johnny.chen@apple.com>
Wed, 13 Apr 2011 21:59:01 +0000 (21:59 +0000)
rdar://problem/9280370

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

lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h
test/MC/Disassembler/ARM/thumb-tests.txt

index ec8005627e10c07ed9293706b19341039877ea21..aded43b4b7f8b9439fb3c94c0a5ce0059accee7d 100644 (file)
@@ -479,6 +479,7 @@ static bool DisassembleThumb1DP(MCInst &MI, unsigned Opcode, uint32_t insn,
 // tBX_RET: 0 operand
 // tBX_RET_vararg: Rm
 // tBLXr_r9: Rm
+// tBRIND: Rm
 static bool DisassembleThumb1Special(MCInst &MI, unsigned Opcode, uint32_t insn,
     unsigned short NumOps, unsigned &NumOpsAdded, BO B) {
 
@@ -486,14 +487,17 @@ static bool DisassembleThumb1Special(MCInst &MI, unsigned Opcode, uint32_t insn,
   if (NumOps == 0)
     return true;
 
-  // BX/BLX has 1 reg operand: Rm.
-  if (Opcode == ARM::tBLXr_r9 || Opcode == ARM::tBX_Rm) {
-    // Handling the two predicate operands before the reg operand.
-    if (!B->DoPredicateOperands(MI, Opcode, insn, NumOps))
-      return false;
+  // BX/BLX/tBRIND (indirect branch, i.e, mov pc, Rm) has 1 reg operand: Rm.
+  if (Opcode==ARM::tBLXr_r9 || Opcode==ARM::tBX_Rm || Opcode==ARM::tBRIND) {
+    if (Opcode != ARM::tBRIND) {
+      // Handling the two predicate operands before the reg operand.
+      if (!B->DoPredicateOperands(MI, Opcode, insn, NumOps))
+        return false;
+      NumOpsAdded += 2;
+    }
     MI.addOperand(MCOperand::CreateReg(getRegisterEnum(B, ARM::GPRRegClassID,
                                                        getT1Rm(insn))));
-    NumOpsAdded = 3;
+    NumOpsAdded += 1;
     return true;
   }
 
index 04bde41af6210d93d29abd9674786c3e50ec7f63..a30422626fc653c9c2763333870290e8f2d019c4 100644 (file)
 
 # CHECK:       mov.w   r3, #4294967295
 0x4f 0xf0 0xff 0x33
+
+# CHECK:       mov     pc, sp
+0xef 0x46