[llvm] r178275 - Fix issue with disassembler decoding CBZ/CBNZ immediates as negatives when the upper bit is set.
Gordon Keiser
gkeiser at arxan.com
Thu Mar 28 12:22:28 PDT 2013
Author: gkeiser
Date: Thu Mar 28 14:22:28 2013
New Revision: 178275
URL: http://llvm.org/viewvc/llvm-project?rev=178275&view=rev
Log:
Fix issue with disassembler decoding CBZ/CBNZ immediates as negatives when the upper bit is set.
They should always be zero-extended, not sign extended. Added test case.
Modified:
llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp
llvm/trunk/test/MC/Disassembler/ARM/thumb2.txt
Modified: llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp?rev=178275&r1=178274&r2=178275&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp (original)
+++ llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp Thu Mar 28 14:22:28 2013
@@ -3049,9 +3049,9 @@ static DecodeStatus DecodeT2BROperand(MC
static DecodeStatus DecodeThumbCmpBROperand(MCInst &Inst, unsigned Val,
uint64_t Address, const void *Decoder) {
- if (!tryAddingSymbolicOperand(Address, Address + SignExtend32<7>(Val<<1) + 4,
+ if (!tryAddingSymbolicOperand(Address, Address + (Val<<1) + 4,
true, 2, Inst, Decoder))
- Inst.addOperand(MCOperand::CreateImm(SignExtend32<7>(Val << 1)));
+ Inst.addOperand(MCOperand::CreateImm(Val << 1));
return MCDisassembler::Success;
}
Modified: llvm/trunk/test/MC/Disassembler/ARM/thumb2.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/ARM/thumb2.txt?rev=178275&r1=178274&r2=178275&view=diff
==============================================================================
--- llvm/trunk/test/MC/Disassembler/ARM/thumb2.txt (original)
+++ llvm/trunk/test/MC/Disassembler/ARM/thumb2.txt Thu Mar 28 14:22:28 2013
@@ -254,9 +254,12 @@
#------------------------------------------------------------------------------
# CHECK: cbnz r7, #6
# CHECK: cbnz r7, #12
+# CHECK: cbz r4, #64
0x1f 0xb9
0x37 0xb9
+0x04 0xb3
+
#------------------------------------------------------------------------------
# CDP/CDP2
More information about the llvm-commits
mailing list