control.h 911 字节
Newer Older
Z
Zihao Yu 已提交
1 2 3
#include <monitor/difftest.h>

static inline make_EHelper(jal) {
4
  rtl_li(s, ddest, s->seq_pc);
Z
Zihao Yu 已提交
5 6 7 8 9 10
  rtl_j(s, s->jmp_pc);

  print_asm_template2(jal);
}

static inline make_EHelper(jalr) {
Z
Zihao Yu 已提交
11
  rtl_addi(s, s0, dsrc1, id_src2->imm);
12
#ifdef __ENGINE_interpreter__
Z
Zihao Yu 已提交
13
  rtl_andi(s, s0, s0, ~0x1u);
14
#endif
Z
Zihao Yu 已提交
15 16
  rtl_jr(s, s0);

17 18
  rtl_li(s, ddest, s->seq_pc);

Z
Zihao Yu 已提交
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
  difftest_skip_dut(1, 2);

  print_asm_template3(jalr);
}

static const struct {
  int relop;
  char *name;
} branch_map [] = {
  [0] = { RELOP_EQ, "eq"},
  [1] = { RELOP_NE, "ne"},
  [4] = { RELOP_LT, "lt"},
  [5] = { RELOP_GE, "ge"},
  [6] = { RELOP_LTU, "ltu"},
  [7] = { RELOP_GEU, "geu"},
};

static inline make_EHelper(branch) {
  int type = s->isa.instr.b.funct3;
  assert(type != 2 && type != 3);
  rtl_jrelop(s, branch_map[type].relop, dsrc1, dsrc2, s->jmp_pc);

Z
Zihao Yu 已提交
41
  print_asm("b%s %s,%s,0x%x", branch_map[type].name, id_src1->str, id_src2->str, s->jmp_pc);
Z
Zihao Yu 已提交
42
}