Skip to content

Commit

Permalink
Merge pull request #149 from fwsGonzo/bintr_jumpto
Browse files Browse the repository at this point in the history
bintr: Convert jump() to JUMP_TO() macro
  • Loading branch information
fwsGonzo committed Jun 12, 2024
2 parents 5c49b11 + f8c8284 commit 20461d3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions lib/libriscv/tr_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,8 @@ static inline int do_syscall(CPU* cpu, uint64_t counter, uint64_t max_counter, a
return (cpu->pc != old_pc || counter >= MAX_COUNTER(cpu));
}
static inline void jump(CPU* cpu, addr_t addr) {
#define JUMP_TO(cpu, addr) \
cpu->pc = addr & ~(addr_t)RISCV_ALIGN_MASK;
}
// https://stackoverflow.com/questions/28868367/getting-the-high-part-of-64-bit-integer-multiplication
// As written by catid
Expand Down
4 changes: 2 additions & 2 deletions lib/libriscv/tr_emit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -569,11 +569,11 @@ void Emitter<W>::emit()
add_code(
"{addr_t rs1 = " + from_reg(instr.Itype.rs1) + ";",
to_reg(instr.Itype.rd) + " = " + PCRELS(m_instr_length) + ";",
"jump(cpu, rs1 + " + from_imm(instr.Itype.signed_imm()) + "); }"
"JUMP_TO(cpu, rs1 + " + from_imm(instr.Itype.signed_imm()) + "); }"
);
} else {
add_code(
"jump(cpu, " + from_reg(instr.Itype.rs1) + " + " + from_imm(instr.Itype.signed_imm()) + ");"
"JUMP_TO(cpu, " + from_reg(instr.Itype.rs1) + " + " + from_imm(instr.Itype.signed_imm()) + ");"
);
}
exit_function("cpu->pc", true);
Expand Down

0 comments on commit 20461d3

Please sign in to comment.