> compile NEMU

ysyx_22040000 李心杨
Linux calcite 6.6.19 #1-NixOS SMP PREEMPT_DYNAMIC Fri Mar  1 12:35:11 UTC 2024 x86_64 GNU/Linux
 20:11:10  up   7:17,  2 users,  load average: 2.79, 1.85, 1.36
This commit is contained in:
tracer-ysyx 2024-03-20 20:11:10 +08:00 committed by xinyangli
parent 94f7a9282a
commit 00898f6264

View file

@ -15,6 +15,7 @@
#include <common.h> #include <common.h>
#include "local-include/reg.h" #include "local-include/reg.h"
#include "macro.h"
#include <cpu/cpu.h> #include <cpu/cpu.h>
#include <cpu/ifetch.h> #include <cpu/ifetch.h>
#include <cpu/decode.h> #include <cpu/decode.h>
@ -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; uint32_t i = s->isa.inst.val;
int rs1 = BITS(i, 19, 15); int rs1 = BITS(i, 19, 15);
if(rs1 == 1 && rd == 0) { if(rs1 == 1 && rd == 0) {
@ -86,8 +87,12 @@ static int decode_exec(Decode *s) {
INSTPAT("??????? ????? ????? ??? ????? 01101 11", lui , U, R(rd) = imm); INSTPAT("??????? ????? ????? ??? ????? 01101 11", lui , U, R(rd) = imm);
INSTPAT("??????? ????? ????? ??? ????? 00101 11", auipc , U, R(rd) = s->pc + 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("??????? ????? ????? ??? ????? 11011 11", jal , J, do {
INSTPAT("??????? ????? ????? ??? ????? 11001 11", jalr , I, do {s->dnpc = src1 + imm; R(rd) = s->pc + 4; ftrace(s, rd, src1 + imm); } while(0)); 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("??????? ????? ????? 000 ????? 11000 11", beq , B, do_branch(s, src1 == src2, imm));
INSTPAT("??????? ????? ????? 001 ????? 11000 11", bne , 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)); INSTPAT("??????? ????? ????? 100 ????? 11000 11", blt , B, do_branch(s, (sword_t)src1 < (sword_t)src2, imm));