35#include "debug/Decode.hh"
36#include "debug/Decoder.hh"
140 panic(
"Went to the error state in the decoder.\n");
187 const uint8_t prefix =
Prefixes[table_idx][nextByte];
242 panic(
"Unrecognized prefix %#x\n", nextByte);
251 Vex2Of2 vex = nextByte;
286 nextByte >= 0xA0 && nextByte <= 0xA3);
290 Vex2Of3 vex = nextByte;
327 nextByte >= 0xA0 && nextByte <= 0xA3);
331 Vex3Of3 vex = nextByte;
366 case ThreeByte0F38Opcode:
369 case ThreeByte0F3AOpcode:
385 if (nextByte == 0x0f) {
394 nextByte >= 0xA0 && nextByte <= 0xA3);
406 if (nextByte == 0x38) {
409 }
else if (nextByte == 0x3a) {
429 DPRINTF(
Decoder,
"Found three byte 0F38 opcode %#x.\n", nextByte);
443 DPRINTF(
Decoder,
"Found three byte 0F3A opcode %#x.\n", nextByte);
489 int immType = immTable[
opcode];
516 ModRM modRM = nextByte;
520 if ((modRM.mod == 0 && modRM.rm == 6) || modRM.mod == 2)
522 else if (modRM.mod == 1)
528 if ((modRM.mod == 0 && modRM.rm == 5) || modRM.mod == 2)
530 else if (modRM.mod == 1)
538 if (
emi.
opcode.
type == OneByteOpcode && (modRM.reg & 0x6) == 0) {
547 if (modRM.rm == 4 && modRM.mod != 3 &&
emi.
addrSize != 2) {
596 DPRINTF(
Decoder,
"Collecting %d byte displacement, got %d bytes.\n",
615 panic(
"Undefined displacement size!\n");
682 auto iter =
instMap->find(mach_inst);
687 (*instMap)[mach_inst] =
si;
692 DPRINTF(Decode,
"Decode: Decoded %s instruction: %#x\n",
693 si->getName(), mach_inst);
711 const int chunkSize =
sizeof(
MachInst);
719 int start = firstOffset;
723 int end = start + totalSize;
724 end = (chunkSize < end) ? chunkSize : end;
725 int size = end - start;
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
StaticInstPtr fetchMicroop(MicroPC microPC, StaticInstPtr curMacroop)
State doPrefixState(uint8_t)
std::unordered_map< CacheKey, decode_cache::InstMap< ExtMachInst > * > InstCacheMap
StaticInstPtr decode(ExtMachInst mach_inst, Addr addr)
Decode a machine instruction.
static ByteTable ImmediateTypeTwoByte
@ ThreeByte0F3AOpcodeState
@ ThreeByte0F38OpcodeState
DecodePages * decodePages
StaticInstPtr fetchRomMicroop(MicroPC micropc, StaticInstPtr curMacroop) override
State doThreeByte0F3AOpcodeState(uint8_t)
static ByteTable UsesModRMTwoByte
void updateNPC(X86ISA::PCState &nextPC)
State doVex3Of3State(uint8_t)
decode_cache::InstMap< ExtMachInst > * instMap
static ByteTable UsesModRMThreeByte0F3A
State doVexOpcodeState(uint8_t)
State doDisplacementState()
State doVex2Of2State(uint8_t)
static ByteTable ImmediateTypeThreeByte0F38
State doVex2Of3State(uint8_t)
void getImmediate(int &collected, uint64_t ¤t, int size)
State processOpcode(ByteTable &immTable, ByteTable &modrmTable, bool addrSizedImm=false)
static ByteTable UsesModRMThreeByte0F38
StaticInstPtr decodeInst(ExtMachInst mach_inst)
static InstCacheMap instCacheMap
State doOneByteOpcodeState(uint8_t)
static const uint8_t SizeTypeToSize[3][10]
State doTwoByteOpcodeState(uint8_t)
static X86ISAInst::MicrocodeRom microcodeRom
static ByteTable ImmediateTypeThreeByte0F3A
State doThreeByte0F38OpcodeState(uint8_t)
static ByteTable ImmediateTypeOneByte
State doSIBState(uint8_t)
State doModRMState(uint8_t)
static ByteTable UsesModRMOneByte
Value & lookup(Addr addr)
constexpr T bits(T val, unsigned first, unsigned last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
constexpr uint64_t sext(uint64_t val)
Sign-extend an N-bit value to 64 bits.
#define panic(...)
This implements a cprintf based panic() function.
Bitfield< 24, 21 > opcode
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
std::vector< MachInst > chunks
std::vector< MachInst > masks
struct gem5::X86ISA::ExtMachInst::@42 opcode
LegacyPrefixVector legacy