gem5
|
#include <decoder.hh>
Classes | |
struct | InstBytes |
Public Member Functions | |
Decoder (ISA *isa=nullptr) | |
void | setM5Reg (HandyM5Reg m5Reg) |
void | takeOverFrom (Decoder *old) |
void | reset () |
void | process () |
void | moreBytes (const PCState &pc, Addr fetchPC, MachInst data) |
bool | needMoreBytes () |
bool | instReady () |
void | updateNPC (X86ISA::PCState &nextPC) |
StaticInstPtr | decodeInst (ExtMachInst mach_inst) |
StaticInstPtr | decode (ExtMachInst mach_inst, Addr addr) |
Decode a machine instruction. More... | |
StaticInstPtr | decode (X86ISA::PCState &nextPC) |
Protected Types | |
enum | State { ResetState, FromCacheState, PrefixState, Vex2Of2State, Vex2Of3State, Vex3Of3State, VexOpcodeState, OneByteOpcodeState, TwoByteOpcodeState, ThreeByte0F38OpcodeState, ThreeByte0F3AOpcodeState, ModRMState, SIBState, DisplacementState, ImmediateState, ErrorState } |
typedef MiscReg | CacheKey |
Caching for decoded instruction objects. More... | |
typedef DecodeCache::AddrMap < Decoder::InstBytes > | DecodePages |
typedef std::unordered_map < CacheKey, DecodePages * > | AddrCacheMap |
typedef std::unordered_map < CacheKey, DecodeCache::InstMap * > | InstCacheMap |
Protected Member Functions | |
uint8_t | getNextByte () |
void | getImmediate (int &collected, uint64_t ¤t, int size) |
void | updateOffsetState () |
void | consumeByte () |
void | consumeBytes (int numBytes) |
State | doResetState () |
State | doFromCacheState () |
State | doPrefixState (uint8_t) |
State | doVex2Of2State (uint8_t) |
State | doVex2Of3State (uint8_t) |
State | doVex3Of3State (uint8_t) |
State | doVexOpcodeState (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 () |
State | processOpcode (ByteTable &immTable, ByteTable &modrmTable, bool addrSizedImm=false) |
State | processExtendedOpcode (ByteTable &immTable) |
Protected Attributes | |
MachInst | fetchChunk |
InstBytes * | instBytes |
int | chunkIdx |
Addr | basePC |
Addr | origPC |
int | offset |
ExtMachInst | emi |
X86Mode | mode |
X86SubMode | submode |
uint8_t | altOp |
uint8_t | defOp |
uint8_t | altAddr |
uint8_t | defAddr |
uint8_t | stack |
bool | outOfBytes |
bool | instDone |
int | displacementSize |
int | immediateSize |
int | immediateCollected |
State | state |
DecodePages * | decodePages |
AddrCacheMap | addrCacheMap |
DecodeCache::InstMap * | instMap |
Static Protected Attributes | |
static InstBytes | dummy |
static InstCacheMap | instCacheMap |
Private Types | |
typedef const uint8_t | ByteTable [256] |
Static Private Attributes | |
static const uint8_t | SizeTypeToSize [3][10] |
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 |
static ByteTable | ImmediateTypeVex [10] |
Definition at line 52 of file decoder.hh.
|
protected |
Definition at line 229 of file decoder.hh.
|
private |
Definition at line 57 of file decoder.hh.
|
protected |
Caching for decoded instruction objects.
Definition at line 225 of file decoder.hh.
|
protected |
Definition at line 227 of file decoder.hh.
|
protected |
Definition at line 233 of file decoder.hh.
|
protected |
Definition at line 177 of file decoder.hh.
|
inline |
Definition at line 237 of file decoder.hh.
References altAddr, altOp, decodePages, defAddr, defOp, dummy, emi, instBytes, instMap, mode, X86ISA::ExtMachInst::mode, X86ISA::SixtyFourBitMode, stack, and submode.
|
inlineprotected |
Definition at line 151 of file decoder.hh.
References offset, and updateOffsetState().
Referenced by doModRMState(), doOneByteOpcodeState(), doPrefixState(), doSIBState(), doThreeByte0F38OpcodeState(), doThreeByte0F3AOpcodeState(), doTwoByteOpcodeState(), doVex2Of2State(), doVex2Of3State(), and doVex3Of3State().
|
inlineprotected |
Definition at line 157 of file decoder.hh.
References offset, and updateOffsetState().
Referenced by getImmediate().
StaticInstPtr X86ISA::Decoder::decode | ( | ExtMachInst | mach_inst, |
Addr | addr | ||
) |
Decode a machine instruction.
mach_inst | The binary instruction to decode. |
A | pointer to the corresponding StaticInst object. |
Definition at line 681 of file decoder.cc.
References decodeInst(), instMap, and X86ISA::si.
Referenced by decode().
StaticInstPtr X86ISA::Decoder::decode | ( | X86ISA::PCState & | nextPC | ) |
Definition at line 693 of file decoder.cc.
References basePC, X86ISA::Decoder::InstBytes::chunks, decode(), emi, instBytes, instDone, X86ISA::Decoder::InstBytes::lastOffset, X86ISA::mask, X86ISA::Decoder::InstBytes::masks, offset, origPC, X86ISA::Decoder::InstBytes::si, X86ISA::si, X86ISA::size(), and updateNPC().
StaticInstPtr X86ISA::Decoder::decodeInst | ( | ExtMachInst | mach_inst | ) |
Referenced by decode().
|
protected |
Definition at line 586 of file decoder.cc.
References X86ISA::ExtMachInst::displacement, displacementSize, DisplacementState, X86ISA::ExtMachInst::dispSize, DPRINTF, emi, ErrorState, getImmediate(), immediateCollected, immediateSize, ImmediateState, instDone, panic, and ResetState.
Referenced by process().
|
protected |
Definition at line 144 of file decoder.cc.
References basePC, chunkIdx, X86ISA::Decoder::InstBytes::chunks, DPRINTF, fetchChunk, FromCacheState, instBytes, instDone, X86ISA::Decoder::InstBytes::lastOffset, X86ISA::Decoder::InstBytes::masks, offset, origPC, outOfBytes, PrefixState, ResetState, and X86ISA::Decoder::InstBytes::si.
Referenced by process().
|
protected |
Definition at line 634 of file decoder.cc.
References DPRINTF, emi, ErrorState, getImmediate(), X86ISA::ExtMachInst::immediate, immediateCollected, immediateSize, ImmediateState, instDone, and ResetState.
Referenced by process().
|
protected |
Definition at line 509 of file decoder.cc.
References consumeByte(), defOp, displacementSize, DisplacementState, DPRINTF, emi, ErrorState, immediateSize, ImmediateState, instDone, X86ISA::ExtMachInst::modRM, X86ISA::ExtMachInst::op, X86ISA::ExtMachInst::opcode, X86ISA::ExtMachInst::opSize, ResetState, SIBState, and X86ISA::ExtMachInst::type.
Referenced by process().
|
protected |
Definition at line 376 of file decoder.cc.
References consumeByte(), DPRINTF, emi, ErrorState, ImmediateTypeOneByte, X86ISA::ExtMachInst::op, X86ISA::ExtMachInst::opcode, processOpcode(), TwoByteOpcodeState, X86ISA::ExtMachInst::type, and UsesModRMOneByte.
Referenced by process().
|
protected |
Definition at line 178 of file decoder.cc.
References X86ISA::AddressSizeOverride, consumeByte(), X86ISA::CSOverride, DPRINTF, X86ISA::DSOverride, emi, X86ISA::ESOverride, X86ISA::FSOverride, X86ISA::GSOverride, X86ISA::ExtMachInst::legacy, X86ISA::Lock, X86ISA::ExtMachInst::mode, OneByteOpcodeState, X86ISA::OperandSizeOverride, panic, PrefixState, X86ISA::Rep, X86ISA::Repne, X86ISA::ExtMachInst::rex, X86ISA::RexPrefix, X86ISA::SixtyFourBitMode, X86ISA::SSOverride, X86ISA::ExtMachInst::vex, Vex2Of2State, Vex2Of3State, X86ISA::Vex2Prefix, and X86ISA::Vex3Prefix.
Referenced by process().
|
protected |
Definition at line 43 of file decoder.cc.
References basePC, chunkIdx, X86ISA::Decoder::InstBytes::chunks, decodePages, X86ISA::ExtMachInst::displacement, X86ISA::ExtMachInst::dispSize, DPRINTF, emi, FromCacheState, X86ISA::ExtMachInst::immediate, immediateCollected, instBytes, X86ISA::ExtMachInst::legacy, DecodeCache::AddrMap< Value >::lookup(), X86ISA::ExtMachInst::modRM, offset, X86ISA::ExtMachInst::op, X86ISA::ExtMachInst::opcode, origPC, PrefixState, X86ISA::ExtMachInst::rex, X86ISA::Decoder::InstBytes::si, X86ISA::ExtMachInst::sib, X86ISA::ExtMachInst::type, and X86ISA::ExtMachInst::vex.
Referenced by process().
|
protected |
Definition at line 564 of file decoder.cc.
References consumeByte(), displacementSize, DisplacementState, DPRINTF, emi, ErrorState, immediateSize, ImmediateState, instDone, X86ISA::ExtMachInst::modRM, ResetState, and X86ISA::ExtMachInst::sib.
Referenced by process().
|
protected |
Definition at line 421 of file decoder.cc.
References consumeByte(), DPRINTF, emi, ImmediateTypeThreeByte0F38, X86ISA::ExtMachInst::op, X86ISA::ExtMachInst::opcode, processOpcode(), X86ISA::ExtMachInst::type, and UsesModRMThreeByte0F38.
Referenced by process().
|
protected |
Definition at line 435 of file decoder.cc.
References consumeByte(), DPRINTF, emi, ImmediateTypeThreeByte0F3A, X86ISA::ExtMachInst::op, X86ISA::ExtMachInst::opcode, processOpcode(), X86ISA::ExtMachInst::type, and UsesModRMThreeByte0F3A.
Referenced by process().
|
protected |
Definition at line 398 of file decoder.cc.
References consumeByte(), DPRINTF, emi, ErrorState, ImmediateTypeTwoByte, X86ISA::ExtMachInst::op, X86ISA::ExtMachInst::opcode, processOpcode(), ThreeByte0F38OpcodeState, ThreeByte0F3AOpcodeState, X86ISA::ExtMachInst::type, and UsesModRMTwoByte.
Referenced by process().
|
protected |
Definition at line 245 of file decoder.cc.
References consumeByte(), emi, X86ISA::ExtMachInst::legacy, X86ISA::ExtMachInst::opcode, X86ISA::ExtMachInst::rex, X86ISA::ExtMachInst::type, X86ISA::ExtMachInst::vex, and VexOpcodeState.
Referenced by process().
|
protected |
Definition at line 275 of file decoder.cc.
References bits(), consumeByte(), emi, ImmediateTypeOneByte, instDone, X86ISA::ExtMachInst::mode, X86ISA::ExtMachInst::op, X86ISA::ExtMachInst::opcode, processOpcode(), ResetState, X86ISA::ExtMachInst::rex, X86ISA::SixtyFourBitMode, X86ISA::ExtMachInst::type, UsesModRMOneByte, X86ISA::ExtMachInst::vex, and Vex3Of3State.
Referenced by process().
|
protected |
Definition at line 316 of file decoder.cc.
References bits(), consumeByte(), emi, ImmediateTypeOneByte, X86ISA::ExtMachInst::legacy, X86ISA::ExtMachInst::mode, X86ISA::ExtMachInst::op, X86ISA::ExtMachInst::opcode, processOpcode(), X86ISA::ExtMachInst::rex, X86ISA::SixtyFourBitMode, X86ISA::ExtMachInst::type, UsesModRMOneByte, X86ISA::ExtMachInst::vex, and VexOpcodeState.
Referenced by process().
|
protected |
Definition at line 353 of file decoder.cc.
References DPRINTF, emi, ImmediateTypeThreeByte0F38, ImmediateTypeThreeByte0F3A, ImmediateTypeTwoByte, X86ISA::ExtMachInst::op, X86ISA::ExtMachInst::opcode, panic, processOpcode(), X86ISA::ExtMachInst::type, UsesModRMThreeByte0F38, UsesModRMThreeByte0F3A, and UsesModRMTwoByte.
Referenced by process().
|
inlineprotected |
Definition at line 111 of file decoder.hh.
References consumeBytes(), fetchChunk, immediateCollected, X86ISA::mask, and offset.
Referenced by doDisplacementState(), and doImmediateState().
|
inlineprotected |
Definition at line 106 of file decoder.hh.
References fetchChunk, and offset.
Referenced by process().
|
inline |
Definition at line 322 of file decoder.hh.
References instDone.
Definition at line 307 of file decoder.hh.
References basePC, data, DPRINTF, fetchChunk, GenericISA::PCStateBase::instAddr(), offset, outOfBytes, and process().
|
inline |
Definition at line 317 of file decoder.hh.
References outOfBytes.
void X86ISA::Decoder::process | ( | ) |
Definition at line 74 of file decoder.cc.
References X86ISA::Decoder::InstBytes::chunks, DisplacementState, doDisplacementState(), doFromCacheState(), doImmediateState(), doModRMState(), doOneByteOpcodeState(), doPrefixState(), doResetState(), doSIBState(), doThreeByte0F38OpcodeState(), doThreeByte0F3AOpcodeState(), doTwoByteOpcodeState(), doVex2Of2State(), doVex2Of3State(), doVex3Of3State(), doVexOpcodeState(), ErrorState, fetchChunk, FromCacheState, getNextByte(), ImmediateState, instBytes, instDone, ModRMState, OneByteOpcodeState, outOfBytes, panic, PrefixState, ResetState, SIBState, state, ThreeByte0F38OpcodeState, ThreeByte0F3AOpcodeState, TwoByteOpcodeState, Vex2Of2State, Vex2Of3State, Vex3Of3State, and VexOpcodeState.
Referenced by moreBytes().
|
protected |
Definition at line 449 of file decoder.cc.
References X86ISA::ExtMachInst::addrSize, altAddr, altOp, defAddr, defOp, emi, ErrorState, immediateSize, ImmediateState, instDone, X86ISA::ExtMachInst::legacy, ModRMState, X86ISA::ExtMachInst::op, ArmISA::opcode, X86ISA::ExtMachInst::opcode, X86ISA::ExtMachInst::opSize, ResetState, X86ISA::ExtMachInst::rex, SizeTypeToSize, stack, and X86ISA::ExtMachInst::stackSize.
Referenced by doOneByteOpcodeState(), doThreeByte0F38OpcodeState(), doThreeByte0F3AOpcodeState(), doTwoByteOpcodeState(), doVex2Of3State(), doVex3Of3State(), and doVexOpcodeState().
|
inline |
Definition at line 298 of file decoder.hh.
References ResetState, and state.
|
inline |
Definition at line 256 of file decoder.hh.
References addrCacheMap, altAddr, altOp, decodePages, defAddr, defOp, emi, instCacheMap, instMap, mode, X86ISA::ExtMachInst::mode, stack, and submode.
|
inline |
|
inline |
Definition at line 328 of file decoder.hh.
References basePC, DPRINTF, GenericISA::SimplePCState< MachInst >::npc(), offset, origPC, GenericISA::SimplePCState< MachInst >::pc(), X86ISA::size(), and X86ISA::PCState::size().
Referenced by decode().
|
inlineprotected |
Definition at line 134 of file decoder.hh.
References basePC, chunkIdx, X86ISA::Decoder::InstBytes::chunks, DPRINTF, fetchChunk, instBytes, offset, and outOfBytes.
Referenced by consumeByte(), and consumeBytes().
|
protected |
Definition at line 230 of file decoder.hh.
Referenced by setM5Reg().
|
protected |
Definition at line 102 of file decoder.hh.
Referenced by Decoder(), processOpcode(), setM5Reg(), and takeOverFrom().
|
protected |
Definition at line 100 of file decoder.hh.
Referenced by Decoder(), processOpcode(), setM5Reg(), and takeOverFrom().
|
protected |
Definition at line 90 of file decoder.hh.
Referenced by decode(), doFromCacheState(), doResetState(), moreBytes(), updateNPC(), and updateOffsetState().
|
protected |
Definition at line 88 of file decoder.hh.
Referenced by doFromCacheState(), doResetState(), and updateOffsetState().
|
protected |
Definition at line 228 of file decoder.hh.
Referenced by Decoder(), doResetState(), and setM5Reg().
|
protected |
Definition at line 103 of file decoder.hh.
Referenced by Decoder(), processOpcode(), setM5Reg(), and takeOverFrom().
|
protected |
Definition at line 101 of file decoder.hh.
Referenced by Decoder(), doModRMState(), processOpcode(), setM5Reg(), and takeOverFrom().
|
protected |
Definition at line 170 of file decoder.hh.
Referenced by doDisplacementState(), doModRMState(), and doSIBState().
|
staticprotected |
Definition at line 83 of file decoder.hh.
Referenced by Decoder().
|
protected |
Definition at line 96 of file decoder.hh.
Referenced by decode(), Decoder(), doDisplacementState(), doImmediateState(), doModRMState(), doOneByteOpcodeState(), doPrefixState(), doResetState(), doSIBState(), doThreeByte0F38OpcodeState(), doThreeByte0F3AOpcodeState(), doTwoByteOpcodeState(), doVex2Of2State(), doVex2Of3State(), doVex3Of3State(), doVexOpcodeState(), processOpcode(), setM5Reg(), and takeOverFrom().
|
protected |
Definition at line 86 of file decoder.hh.
Referenced by doFromCacheState(), getImmediate(), getNextByte(), moreBytes(), process(), and updateOffsetState().
|
protected |
Definition at line 175 of file decoder.hh.
Referenced by doDisplacementState(), doImmediateState(), doResetState(), and getImmediate().
|
protected |
Definition at line 172 of file decoder.hh.
Referenced by doDisplacementState(), doImmediateState(), doModRMState(), doSIBState(), and processOpcode().
|
staticprivate |
Definition at line 65 of file decoder.hh.
Referenced by doOneByteOpcodeState(), doVex2Of3State(), and doVex3Of3State().
|
staticprivate |
Definition at line 67 of file decoder.hh.
Referenced by doThreeByte0F38OpcodeState(), and doVexOpcodeState().
|
staticprivate |
Definition at line 68 of file decoder.hh.
Referenced by doThreeByte0F3AOpcodeState(), and doVexOpcodeState().
|
staticprivate |
Definition at line 66 of file decoder.hh.
Referenced by doTwoByteOpcodeState(), and doVexOpcodeState().
|
staticprivate |
Definition at line 69 of file decoder.hh.
|
protected |
Definition at line 87 of file decoder.hh.
Referenced by decode(), Decoder(), doFromCacheState(), doResetState(), process(), and updateOffsetState().
|
staticprotected |
Definition at line 234 of file decoder.hh.
Referenced by setM5Reg().
|
protected |
Definition at line 168 of file decoder.hh.
Referenced by decode(), doDisplacementState(), doFromCacheState(), doImmediateState(), doModRMState(), doSIBState(), doVex2Of3State(), instReady(), process(), and processOpcode().
|
protected |
Definition at line 232 of file decoder.hh.
Referenced by decode(), Decoder(), and setM5Reg().
|
protected |
Definition at line 98 of file decoder.hh.
Referenced by Decoder(), setM5Reg(), and takeOverFrom().
|
protected |
Definition at line 94 of file decoder.hh.
Referenced by consumeByte(), consumeBytes(), decode(), doFromCacheState(), doResetState(), getImmediate(), getNextByte(), moreBytes(), updateNPC(), and updateOffsetState().
|
protected |
Definition at line 92 of file decoder.hh.
Referenced by decode(), doFromCacheState(), doResetState(), and updateNPC().
|
protected |
Definition at line 166 of file decoder.hh.
Referenced by doFromCacheState(), moreBytes(), needMoreBytes(), process(), and updateOffsetState().
|
staticprivate |
Definition at line 58 of file decoder.hh.
|
staticprivate |
Definition at line 56 of file decoder.hh.
Referenced by processOpcode().
|
protected |
Definition at line 104 of file decoder.hh.
Referenced by Decoder(), processOpcode(), setM5Reg(), and takeOverFrom().
|
protected |
Definition at line 197 of file decoder.hh.
|
protected |
Definition at line 99 of file decoder.hh.
Referenced by Decoder(), setM5Reg(), and takeOverFrom().
|
staticprivate |
Definition at line 60 of file decoder.hh.
Referenced by doOneByteOpcodeState(), doVex2Of3State(), and doVex3Of3State().
|
staticprivate |
Definition at line 62 of file decoder.hh.
Referenced by doThreeByte0F38OpcodeState(), and doVexOpcodeState().
|
staticprivate |
Definition at line 63 of file decoder.hh.
Referenced by doThreeByte0F3AOpcodeState(), and doVexOpcodeState().
|
staticprivate |
Definition at line 61 of file decoder.hh.
Referenced by doTwoByteOpcodeState(), and doVexOpcodeState().