#define zext_xlen(x) (((reg_t)(x) << (64-xlen)) >> (64-xlen))
#define set_pc(x) \
- do { if (unlikely(((x) & 2)) && !p->supports_extension('C')) \
- throw trap_instruction_address_misaligned(x); \
+ do { p->check_pc_alignment(x); \
npc = sext_xlen(x); \
} while(0)
#define set_pc_and_serialize(x) \
do { reg_t __npc = (x); \
- set_pc(__npc); /* check alignment */ \
npc = PC_SERIALIZE_AFTER; \
STATE.pc = __npc; \
} while(0)
+#define serialize() set_pc_and_serialize(npc)
+
/* Sentinel PC values to serialize simulator pipeline */
#define PC_SERIALIZE_BEFORE 3
#define PC_SERIALIZE_AFTER 5
default: abort(); \
} \
pc = state.pc; \
+ check_pc_alignment(pc); \
break; \
} else { \
state.pc = pc; \
p->set_csr(csr, old & ~RS1);
}
WRITE_RD(sext_xlen(old));
+serialize();
p->set_csr(csr, old & ~(reg_t)insn.rs1());
}
WRITE_RD(sext_xlen(old));
+serialize();
p->set_csr(csr, old | RS1);
}
WRITE_RD(sext_xlen(old));
+serialize();
p->set_csr(csr, old | insn.rs1());
}
WRITE_RD(sext_xlen(old));
+serialize();
reg_t old = p->get_csr(csr);
p->set_csr(csr, RS1);
WRITE_RD(sext_xlen(old));
+serialize();
reg_t old = p->get_csr(csr);
p->set_csr(csr, insn.rs1());
WRITE_RD(sext_xlen(old));
+serialize();
#include "decode.h"
#include "config.h"
#include "devices.h"
+#include "trap.h"
#include <string>
#include <vector>
#include <map>
if (ext >= 'a' && ext <= 'z') ext += 'A' - 'a';
return ext >= 'A' && ext <= 'Z' && ((isa >> (ext - 'A')) & 1);
}
+ void check_pc_alignment(reg_t pc) {
+ if (unlikely(pc & 2) && !supports_extension('C'))
+ throw trap_instruction_address_misaligned(pc);
+ }
reg_t legalize_privilege(reg_t);
void set_privilege(reg_t);
void yield_load_reservation() { state.load_reservation = (reg_t)-1; }