Skip to content

Commit

Permalink
Tweak constopt_info_t code manipulation
Browse files Browse the repository at this point in the history
This patch simplifies the naming scheme for constant optimization
routines. In addition, an unused parameter warning is eliminated.
  • Loading branch information
jserv committed Oct 6, 2023
1 parent 3a113f7 commit 1c2be0a
Show file tree
Hide file tree
Showing 2 changed files with 255 additions and 295 deletions.
20 changes: 9 additions & 11 deletions src/emulate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1045,11 +1045,11 @@ typedef struct {
uint32_t const_val[N_RV_REGS];
} constopt_info_t;

#define CONSTOPT(inst, code) \
static void constopt_##inst(UNUSED rv_insn_t *ir, \
UNUSED constopt_info_t *constopt_info) \
{ \
code; \
#define CONSTOPT(inst, code) \
static void constopt_##inst(rv_insn_t *ir UNUSED, \
constopt_info_t *info UNUSED) \
{ \
code; \
}

#include "rv32_constopt.c"
Expand All @@ -1064,17 +1064,15 @@ static const void *constopt_table[] = {

/* clang-format on */
typedef void (*constopt_func_t)(rv_insn_t *, constopt_info_t *);
static void optimize_constant(riscv_t *rv, block_t *block)
static void optimize_constant(riscv_t *rv UNUSED, block_t *block)
{
constopt_info_t constopt_info = {0};
constopt_info.is_constant[0] = true;
constopt_info_t info = {.is_constant[0] = true};
assert(rv->X[0] == 0);

uint32_t i;
rv_insn_t *ir;
for (i = 0, ir = block->ir_head; i < block->n_insn; i++, ir = ir->next) {
((constopt_func_t) constopt_table[ir->opcode])(ir, &constopt_info);
}
for (i = 0, ir = block->ir_head; i < block->n_insn; i++, ir = ir->next)
((constopt_func_t) constopt_table[ir->opcode])(ir, &info);
}

static block_t *prev = NULL;
Expand Down
Loading

1 comment on commit 1c2be0a

@jserv
Copy link
Contributor Author

@jserv jserv commented on 1c2be0a Oct 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmarks

Benchmark suite Current: 1c2be0a Previous: 2672969 Ratio
Dhrystone 1279.5 Average DMIPS over 10 runs 1271.85 Average DMIPS over 10 runs 0.99
Coremark 1021.535 Average iterations/sec over 10 runs 1017.142 Average iterations/sec over 10 runs 1.00

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.