Skip to content

Commit

Permalink
Minor cleanup, reduce 32-bit dispatcher size
Browse files Browse the repository at this point in the history
  • Loading branch information
fwsGonzo committed Nov 23, 2023
1 parent 4035d90 commit 88662d2
Showing 1 changed file with 34 additions and 14 deletions.
48 changes: 34 additions & 14 deletions lib/libriscv/bytecode_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,11 +435,6 @@ INSTRUCTION(RV32I_BC_OP_SRA, rv32i_op_sra) {
dst = saddr_t(src1) >> (src2 & (XLEN-1));
NEXT_INSTR();
}
INSTRUCTION(RV32I_BC_OP_ADD_UW, rv32i_op_add_uw) {
VIEW_INSTR();
REG(instr.Rtype.rd) = REG(instr.Rtype.rs2) + uint32_t(REG(instr.Rtype.rs1));
NEXT_INSTR();
}
INSTRUCTION(RV32I_BC_OP_ZEXT_H, rv32i_op_zext_h) {
OP_INSTR();
dst = uint16_t(src1);
Expand All @@ -448,9 +443,24 @@ INSTRUCTION(RV32I_BC_OP_ZEXT_H, rv32i_op_zext_h) {
}

INSTRUCTION(RV64I_BC_OP_ADDW, rv64i_op_addw) {
OP_INSTR();
dst = int32_t(uint32_t(src1) + uint32_t(src2));
NEXT_INSTR();
if constexpr (W >= 8) {
OP_INSTR();
dst = int32_t(uint32_t(src1) + uint32_t(src2));
NEXT_INSTR();
}
#ifdef DISPATCH_MODE_TAILCALL
else UNUSED_FUNCTION();
#endif
}
INSTRUCTION(RV32I_BC_OP_ADD_UW, rv32i_op_add_uw) {
if constexpr (W >= 8) {
VIEW_INSTR();
REG(instr.Rtype.rd) = REG(instr.Rtype.rs2) + uint32_t(REG(instr.Rtype.rs1));
NEXT_INSTR();
}
#ifdef DISPATCH_MODE_TAILCALL
else UNUSED_FUNCTION();
#endif
}

INSTRUCTION(RV32I_BC_SEXT_B, rv32i_sext_b) {
Expand Down Expand Up @@ -571,14 +581,24 @@ INSTRUCTION(RV64I_BC_SRAIW, rv64i_sraiw) {
#endif
}
INSTRUCTION(RV64I_BC_OP_SH1ADD_UW, rv64i_op_sh1add_uw) {
OP_INSTR();
dst = src2 + (addr_t(uint32_t(src1)) << 1);
NEXT_INSTR();
if constexpr (W >= 8) {
OP_INSTR();
dst = src2 + (addr_t(uint32_t(src1)) << 1);
NEXT_INSTR();
}
#ifdef DISPATCH_MODE_TAILCALL
else UNUSED_FUNCTION();
#endif
}
INSTRUCTION(RV64I_BC_OP_SH2ADD_UW, rv64i_op_sh2add_uw) {
OP_INSTR();
dst = src2 + (addr_t(uint32_t(src1)) << 2);
NEXT_INSTR();
if constexpr (W >= 8) {
OP_INSTR();
dst = src2 + (addr_t(uint32_t(src1)) << 2);
NEXT_INSTR();
}
#ifdef DISPATCH_MODE_TAILCALL
else UNUSED_FUNCTION();
#endif
}

INSTRUCTION(RV32I_BC_OP_DIV, rv32i_op_div) {
Expand Down

0 comments on commit 88662d2

Please sign in to comment.