[llvm-commits] [llvm] r127843 - in /llvm/trunk: lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h test/MC/Disassembler/ARM/thumb-tests.txt

Johnny Chen johnny.chen at apple.com
Thu Mar 17 17:38:03 PDT 2011


Author: johnny
Date: Thu Mar 17 19:38:03 2011
New Revision: 127843

URL: http://llvm.org/viewvc/llvm-project?rev=127843&view=rev
Log:
The disassembler for Thumb was wrongly adding 4 to the computed imm32 offset.
Remove the offending logic and update the test cases.

Modified:
    llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h
    llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt

Modified: llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h?rev=127843&r1=127842&r2=127843&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h (original)
+++ llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h Thu Mar 17 19:38:03 2011
@@ -962,11 +962,7 @@
 
   unsigned Imm11 = getT1Imm11(insn);
 
-  // When executing a Thumb instruction, PC reads as the address of the current
-  // instruction plus 4.  The assembler subtracts 4 from the difference between
-  // the branch instruction and the target address, disassembler has to add 4 to
-  // to compensate.
-  MI.addOperand(MCOperand::CreateImm(SignExtend32<12>(Imm11 << 1) + 4));
+  MI.addOperand(MCOperand::CreateImm(SignExtend32<12>(Imm11 << 1)));
 
   NumOpsAdded = 1;
 
@@ -1747,11 +1743,7 @@
     Offset = decodeImm32_BLX(insn);
     break;
   }
-  // When executing a Thumb instruction, PC reads as the address of the current
-  // instruction plus 4.  The assembler subtracts 4 from the difference between
-  // the branch instruction and the target address, disassembler has to add 4 to
-  // to compensate.
-  MI.addOperand(MCOperand::CreateImm(Offset + 4));
+  MI.addOperand(MCOperand::CreateImm(Offset));
 
   // This is an increment as some predicate operands may have been added first.
   NumOpsAdded += 1;

Modified: llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt?rev=127843&r1=127842&r2=127843&view=diff
==============================================================================
--- llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt (original)
+++ llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt Thu Mar 17 19:38:03 2011
@@ -6,10 +6,10 @@
 # CHECK:	adcs	r0, r0, #1
 0x50 0xf1 0x01 0x00
 
-# CHECK:	b	#34
+# CHECK:	b	#30
 0x0f 0xe0
 
-# CHECK:	b.w	#-12
+# CHECK:	b.w	#-16
 0xff 0xf7 0xf8 0xaf
 
 # CHECK:	bfi	r2, r10, #0, #1
@@ -128,5 +128,5 @@
 # CHECK: msr cpsr_fc, r0
 0x80 0xf3 0x00 0x89
 
-# CHECK: blx	#0
+# CHECK: blx	#-4
 0xff 0xf7 0xfe 0xef





More information about the llvm-commits mailing list