37 #include "debug/Decoder.hh" 136 panic(
"Went to the error state in the decoder.\n");
180 uint8_t prefix =
Prefixes[nextByte];
239 panic(
"Unrecognized prefix %#x\n", nextByte);
248 Vex2Of2 vex = nextByte;
283 nextByte >= 0xA0 && nextByte <= 0xA3);
287 Vex2Of3 vex = nextByte;
324 nextByte >= 0xA0 && nextByte <= 0xA3);
328 Vex3Of3 vex = nextByte;
363 case ThreeByte0F38Opcode:
366 case ThreeByte0F3AOpcode:
382 if (nextByte == 0x0f) {
391 nextByte >= 0xA0 && nextByte <= 0xA3);
403 if (nextByte == 0x38) {
406 }
else if (nextByte == 0x3a) {
426 DPRINTF(
Decoder,
"Found three byte 0F38 opcode %#x.\n", nextByte);
440 DPRINTF(
Decoder,
"Found three byte 0F3A opcode %#x.\n", nextByte);
486 int immType = immTable[
opcode];
493 if (modrmTable[opcode]) {
513 ModRM modRM = nextByte;
517 if ((modRM.mod == 0 && modRM.rm == 6) || modRM.mod == 2)
519 else if (modRM.mod == 1)
525 if ((modRM.mod == 0 && modRM.rm == 5) || modRM.mod == 2)
527 else if (modRM.mod == 1)
535 if (
emi.
opcode.
type == OneByteOpcode && (modRM.reg & 0x6) == 0) {
544 if (modRM.rm == 4 && modRM.mod != 3) {
595 DPRINTF(
Decoder,
"Collecting %d byte displacement, got %d bytes.\n",
614 panic(
"Undefined displacement size!\n");
684 auto iter =
instMap->find(mach_inst);
689 (*instMap)[mach_inst] =
si;
707 const int chunkSize =
sizeof(
MachInst);
715 int start = firstOffset;
719 int end = start + totalSize;
720 end = (chunkSize < end) ? chunkSize : end;
721 int size = end - start;
#define panic(...)
This implements a cprintf based panic() function.
static ByteTable UsesModRMThreeByte0F38
State doVex3Of3State(uint8_t)
struct X86ISA::ExtMachInst::@24 opcode
State doVex2Of3State(uint8_t)
State doTwoByteOpcodeState(uint8_t)
static const uint8_t SizeTypeToSize[3][10]
Value & lookup(Addr addr)
State doPrefixState(uint8_t)
StaticInstPtr decodeInst(ExtMachInst mach_inst)
State doSIBState(uint8_t)
static ByteTable ImmediateTypeThreeByte0F3A
static ByteTable UsesModRMOneByte
DecodePages * decodePages
static ByteTable UsesModRMTwoByte
static InstCacheMap instCacheMap
LegacyPrefixVector legacy
State processOpcode(ByteTable &immTable, ByteTable &modrmTable, bool addrSizedImm=false)
State doVexOpcodeState(uint8_t)
static ByteTable ImmediateTypeTwoByte
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,16,32,64}_t.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
static ByteTable ImmediateTypeOneByte
StaticInstPtr decode(ExtMachInst mach_inst, Addr addr)
Decode a machine instruction.
State doVex2Of2State(uint8_t)
State doModRMState(uint8_t)
std::vector< MachInst > masks
This is exposed globally, independent of the ISA.
DecodeCache::InstMap< ExtMachInst > * instMap
Bitfield< 24, 21 > opcode
State doDisplacementState()
State doOneByteOpcodeState(uint8_t)
State doThreeByte0F38OpcodeState(uint8_t)
const uint8_t ByteTable[256]
static ByteTable ImmediateTypeThreeByte0F38
T bits(T val, int first, int last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it...
void updateNPC(X86ISA::PCState &nextPC)
std::vector< MachInst > chunks
State doThreeByte0F3AOpcodeState(uint8_t)
std::unordered_map< CacheKey, DecodeCache::InstMap< ExtMachInst > * > InstCacheMap
static ByteTable UsesModRMThreeByte0F3A
void getImmediate(int &collected, uint64_t ¤t, int size)