summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
diff options
context:
space:
mode:
authorCaroline Tice <ctice@apple.com>2011-04-19 23:30:03 +0000
committerCaroline Tice <ctice@apple.com>2011-04-19 23:30:03 +0000
commit3ac6711aec757817bed518af307ca68bc6008fc3 (patch)
tree43254ba88049f73acb6b469a266ccccaf7d5cb43 /lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
parent914bc4106cb7558b907b7b8b82df416f96c56103 (diff)
downloadbcm5719-llvm-3ac6711aec757817bed518af307ca68bc6008fc3.tar.gz
bcm5719-llvm-3ac6711aec757817bed518af307ca68bc6008fc3.zip
Add the infrastructure to test instruction emulations automatically.
The idea is that the instruction to be emulated is actually executed on the hardware to be emulated, with the before and after state of the hardware being captured and 'freeze-dried' into .dat files. The emulation testing code then loads the before & after state from the .dat file, emulates the instruction using the before state, and compares the resulting state to the 'after' state. If they match, the emulation is accurate, otherwise there is a problem. The final format of the .dat files needs a bit more work; the plan is to generalize them a bit and to convert the plain values to key-value pairs. But I wanted to get this first pass committed. This commit adds arm instruction emulation testing to the testsuite, along with many initial .dat files. It also fixes a bug in the llvm disassembler, where 32-bit thumb opcodes were getting their upper & lower 16-bits reversed. There is a new Instruction sub-class, that is intended to be loaded from a .dat file rather than read from an executable. There is also a new EmulationStateARM class, for handling the before & after states. EmulationStates for other architetures can be added later when we emulate their instructions. llvm-svn: 129832
Diffstat (limited to 'lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp')
-rw-r--r--lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp b/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
index 5ddcd727bc0..23a788b16b5 100644
--- a/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
+++ b/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
@@ -367,7 +367,19 @@ InstructionLLVM::Decode (const Disassembler &disassembler,
break;
case 4:
- m_opcode.SetOpcode32 (data.GetU32 (&offset));
+ {
+ if (GetAddressClass() == eAddressClassCodeAlternateISA)
+ {
+ // If it is a 32-bit THUMB instruction, we need to swap the upper & lower halves.
+ uint32_t orig_bytes = data.GetU32 (&offset);
+ uint16_t upper_bits = (orig_bytes >> 16) & ((1u << 16) - 1);
+ uint16_t lower_bits = orig_bytes & ((1u << 16) - 1);
+ uint32_t swapped = (lower_bits << 16) | upper_bits;
+ m_opcode.SetOpcode32 (swapped);
+ }
+ else
+ m_opcode.SetOpcode32 (data.GetU32 (&offset));
+ }
break;
default:
OpenPOWER on IntegriCloud