From 00898f626454756469bdd61bdf7d6cbaa72a50e4 Mon Sep 17 00:00:00 2001 From: tracer-ysyx Date: Wed, 20 Mar 2024 20:11:10 +0800 Subject: [PATCH] =?UTF-8?q?>=20compile=20NEMU=20ysyx=5F22040000=20?= =?UTF-8?q?=E6=9D=8E=E5=BF=83=E6=9D=A8=20Linux=20calcite=206.6.19=20#1-Nix?= =?UTF-8?q?OS=20SMP=20PREEMPT=5FDYNAMIC=20Fri=20Mar=20=201=2012:35:11=20UT?= =?UTF-8?q?C=202024=20x86=5F64=20GNU/Linux=20=2020:11:10=20=20up=20=20=207?= =?UTF-8?q?:17,=20=202=20users,=20=20load=20average:=202.79,=201.85,=201.3?= =?UTF-8?q?6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nemu/src/isa/riscv32/inst.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/nemu/src/isa/riscv32/inst.c b/nemu/src/isa/riscv32/inst.c index c4d824f..41c2098 100644 --- a/nemu/src/isa/riscv32/inst.c +++ b/nemu/src/isa/riscv32/inst.c @@ -15,6 +15,7 @@ #include #include "local-include/reg.h" +#include "macro.h" #include #include #include @@ -61,7 +62,7 @@ static void do_branch(Decode *s, bool condition, word_t offset) { } } -static void ftrace(Decode *s, int rd, vaddr_t dst) { +static void ftrace_jalr(Decode *s, int rd, vaddr_t dst) { uint32_t i = s->isa.inst.val; int rs1 = BITS(i, 19, 15); if(rs1 == 1 && rd == 0) { @@ -86,8 +87,12 @@ static int decode_exec(Decode *s) { INSTPAT("??????? ????? ????? ??? ????? 01101 11", lui , U, R(rd) = imm); INSTPAT("??????? ????? ????? ??? ????? 00101 11", auipc , U, R(rd) = s->pc + imm); - INSTPAT("??????? ????? ????? ??? ????? 11011 11", jal , J, do {s->dnpc = s->pc + imm; R(rd) = s->pc + 4; ftrace_call(s->pc, s->pc + imm); } while(0)); - INSTPAT("??????? ????? ????? ??? ????? 11001 11", jalr , I, do {s->dnpc = src1 + imm; R(rd) = s->pc + 4; ftrace(s, rd, src1 + imm); } while(0)); + INSTPAT("??????? ????? ????? ??? ????? 11011 11", jal , J, do { + s->dnpc = s->pc + imm; R(rd) = s->pc + 4; + IFDEF(CONFIG_FTRACE, ftrace_call(s->pc, s->pc + imm)); } while(0)); + INSTPAT("??????? ????? ????? ??? ????? 11001 11", jalr , I, do { + s->dnpc = src1 + imm; R(rd) = s->pc + 4; + IFDEF(CONFIG_FTRACE, ftrace_jalr(s, rd, src1 + imm)); } while(0)); INSTPAT("??????? ????? ????? 000 ????? 11000 11", beq , B, do_branch(s, src1 == src2, imm)); INSTPAT("??????? ????? ????? 001 ????? 11000 11", bne , B, do_branch(s, src1 != src2, imm)); INSTPAT("??????? ????? ????? 100 ????? 11000 11", blt , B, do_branch(s, (sword_t)src1 < (sword_t)src2, imm));