提交 83d70c32 编写于 作者: Z Zihao Yu

engine,rv64,spill: no need to writeback s0/s1

* they are only valid during the translation of a single instruction
上级 d4f63d3d
......@@ -16,11 +16,14 @@ void spill_init() {
tmp_regs[1].rvidx = TMP_REG_2;
}
void spill_flush(int tmpidx) {
tmp_regs[tmpidx].spmidx = 0;
tmp_regs[tmpidx].dirty = 0;
}
void spill_reset() {
tmp_regs[0].spmidx = 0;
tmp_regs[0].dirty = 0;
tmp_regs[1].spmidx = 0;
tmp_regs[1].dirty = 0;
spill_flush(0);
spill_flush(1);
}
int spmidx2tmpidx(uint32_t spmidx) {
......@@ -146,3 +149,19 @@ void spill_set_dirty_rvidx(uint32_t rvidx) {
int tmpidx = rvidx2tmpidx(rvidx);
if (tmpidx != -1) spill_set_dirty(tmpidx);
}
// this will be called after every translation of an instruction
// to flush RTL tmp registers, since their life-cycle is only
// valid during the translation of a single instruction
static void spill_flush_local_internal(DecodeExecState *s, const rtlreg_t *dest) {
uint32_t varidx = rtlreg2varidx(s, dest);
for (int i = 0; i < TMP_REG_NUM; i++) {
if (tmp_regs[i].spmidx == varidx && tmp_regs[i].dirty) spill_flush(i);
}
}
void spill_flush_local() {
DecodeExecState state; // only used in rtlreg2varidx()
DecodeExecState *s = &state;
spill_flush_local_internal(s, s0);
spill_flush_local_internal(s, s1);
}
......@@ -12,7 +12,6 @@
uint32_t spmidx2rvidx(uint32_t);
uint32_t spill_out_and_remap(DecodeExecState*, uint32_t);
void spill_flush(uint32_t);
void spill_flush_all();
void cal_suffix_inst();
void spill_writeback_all();
......
......@@ -18,6 +18,7 @@ void asm_print(vaddr_t ori_pc, int instr_len, bool print_flag);
vaddr_t rv64_exec_trans_buffer(void *buf, int nr_instr, int npc_type);
void guest_getregs(CPU_state *cpu);
void spill_reset();
void spill_flush_local();
typedef struct TB {
vaddr_t pc;
......@@ -103,6 +104,8 @@ void mainloop() {
__attribute__((unused)) vaddr_t seq_pc = isa_exec_once();
guest_nr_instr ++;
spill_flush_local();
if (nemu_state.state != NEMU_RUNNING) tran_next_pc = NEXT_PC_END;
#ifdef DEBUG
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册