[sim, opcodes] made sim more decoupled from opcodes
[riscv-isa-sim.git] / riscv / insn_header.h
1 #include "processor.h"
2 #include "common.h"
3 #include "config.h"
4 #include "sim.h"
5 #include "softfloat.h"
6 #include "platform.h" // softfloat isNaNF32UI, etc.
7 #include "internals.h" // ditto
8
9 #define DECLARE_INSN(name, opcode, mask) \
10 const uint32_t MATCH_ ## name = opcode; \
11 const uint32_t MASK_ ## name = mask;
12 #include "opcodes.h"
13 #undef DECLARE_INSN
14
15 reg_t processor_t::FUNC (insn_t insn, reg_t pc)
16 {
17 #define MASK (~(DISPATCH_TABLE_SIZE-1) & OPCODE_MASK)
18 #define MATCH (~(DISPATCH_TABLE_SIZE-1) & OPCODE_MATCH)
19 if(unlikely((insn.bits & MASK) != MATCH))
20 throw trap_illegal_instruction;
21
22 reg_t npc = pc + insn_length(OPCODE_MATCH);