summaryrefslogtreecommitdiff
path: root/src/arch/x86/decoder.hh
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2014-12-04 15:53:54 -0800
committerGabe Black <gabeblack@google.com>2014-12-04 15:53:54 -0800
commit22aaa5867f2449e2a73b7891fc34072c12c199b3 (patch)
tree6083ecfd34307076c8d9c55a450e6cc118025b95 /src/arch/x86/decoder.hh
parent3069c28a021d3f8c29221e537d48ee382c30646f (diff)
downloadgem5-22aaa5867f2449e2a73b7891fc34072c12c199b3.tar.xz
x86: Rework opcode parsing to support 3 byte opcodes properly.
Instead of counting the number of opcode bytes in an instruction and recording each byte before the actual opcode, we can represent the path we took to get to the actual opcode byte by using a type code. That has a couple of advantages. First, we can disambiguate the properties of opcodes of the same length which have different properties. Second, it reduces the amount of data stored in an ExtMachInst, making them slightly easier/faster to create and process. This also adds some flexibility as far as how different types of opcodes are handled, which might come in handy if we decide to support VEX or XOP instructions. This change also adds tables to support properly decoding 3 byte opcodes. Before we would fall off the end of some arrays, on top of the ambiguity described above. This change doesn't measureably affect performance on the twolf benchmark. --HG-- rename : src/arch/x86/isa/decoder/three_byte_opcodes.isa => src/arch/x86/isa/decoder/three_byte_0f38_opcodes.isa rename : src/arch/x86/isa/decoder/three_byte_opcodes.isa => src/arch/x86/isa/decoder/three_byte_0f3a_opcodes.isa
Diffstat (limited to 'src/arch/x86/decoder.hh')
-rw-r--r--src/arch/x86/decoder.hh29
1 files changed, 24 insertions, 5 deletions
diff --git a/src/arch/x86/decoder.hh b/src/arch/x86/decoder.hh
index ca7ef96fe..a37fccfb1 100644
--- a/src/arch/x86/decoder.hh
+++ b/src/arch/x86/decoder.hh
@@ -51,10 +51,19 @@ class Decoder
{
private:
//These are defined and documented in decoder_tables.cc
- static const uint8_t Prefixes[256];
- static const uint8_t UsesModRM[2][256];
- static const uint8_t ImmediateType[2][256];
static const uint8_t SizeTypeToSize[3][10];
+ typedef const uint8_t ByteTable[256];
+ static ByteTable Prefixes;
+
+ static ByteTable UsesModRMOneByte;
+ static ByteTable UsesModRMTwoByte;
+ static ByteTable UsesModRMThreeByte0F38;
+ static ByteTable UsesModRMThreeByte0F3A;
+
+ static ByteTable ImmediateTypeOneByte;
+ static ByteTable ImmediateTypeTwoByte;
+ static ByteTable ImmediateTypeThreeByte0F38;
+ static ByteTable ImmediateTypeThreeByte0F3A;
protected:
struct InstBytes
@@ -166,7 +175,10 @@ class Decoder
ResetState,
FromCacheState,
PrefixState,
- OpcodeState,
+ OneByteOpcodeState,
+ TwoByteOpcodeState,
+ ThreeByte0F38OpcodeState,
+ ThreeByte0F3AOpcodeState,
ModRMState,
SIBState,
DisplacementState,
@@ -181,12 +193,19 @@ class Decoder
State doResetState();
State doFromCacheState();
State doPrefixState(uint8_t);
- State doOpcodeState(uint8_t);
+ State doOneByteOpcodeState(uint8_t);
+ State doTwoByteOpcodeState(uint8_t);
+ State doThreeByte0F38OpcodeState(uint8_t);
+ State doThreeByte0F3AOpcodeState(uint8_t);
State doModRMState(uint8_t);
State doSIBState(uint8_t);
State doDisplacementState();
State doImmediateState();
+ //Process the actual opcode found earlier, using the supplied tables.
+ State processOpcode(ByteTable &immTable, ByteTable &modrmTable,
+ bool addrSizedImm = false);
+
protected:
/// Caching for decoded instruction objects.