converted sh4 translation macros to functions to avoid duplicate value expansion

avoid calling sr_updated when only the T bit changes, reduces calls from 30m/s to 300k/s
This commit is contained in:
Anthony Pesch 2016-11-26 10:37:21 -08:00
parent c92cba792f
commit cd0f94c205
9 changed files with 744 additions and 703 deletions

View File

@ -113,5 +113,4 @@ void prof_flip() {
/* flip time-based stats every frame */
MicroProfileFlip();
}
}

View File

@ -18,14 +18,14 @@ typedef uint64_t prof_token_t;
#define PROF_LEAVE() prof_leave(prof_tok, prof_tick)
#define PROF_STAT(name) \
static int STAT_##name; \
#define PROF_STAT(name) \
static int STAT_##name; \
static struct prof_stat STAT_T_##name = {#name, &STAT_##name, 0, {0}}; \
CONSTRUCTOR(STAT_REGISTER_##name) { \
prof_stat_register(&STAT_T_##name); \
} \
DESTRUCTOR(STAT_UNREGISTER_##name) { \
prof_stat_unregister(&STAT_T_##name); \
CONSTRUCTOR(STAT_REGISTER_##name) { \
prof_stat_register(&STAT_T_##name); \
} \
DESTRUCTOR(STAT_UNREGISTER_##name) { \
prof_stat_unregister(&STAT_T_##name); \
}
#define PROF_COUNT(name, count) \

View File

@ -18,6 +18,8 @@
#include "sys/time.h"
#include "ui/nuklear.h"
PROF_STAT(sr_updated);
static bool sh4_init(struct device *dev);
static int sh4_block_offset(uint32_t addr);
static void sh4_compile_pc();
@ -286,6 +288,8 @@ static void sh4_swap_fpr_bank(struct sh4 *sh4) {
void sh4_sr_updated(struct sh4_ctx *ctx, uint64_t old_sr) {
struct sh4 *sh4 = ctx->sh4;
STAT_sr_updated++;
if ((ctx->sr & RB) != (old_sr & RB)) {
sh4_swap_gpr_bank(sh4);
}

View File

@ -16,7 +16,6 @@ struct sh4_opdef {
};
static struct sh4_opdef s_opdefs[NUM_SH4_OPS] = {
{SH4_OP_INVALID, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
#define SH4_INSTR(name, desc, sig, cycles, flags) \
{SH4_OP_##name, desc, #sig, cycles, flags, 0, 0, 0, 0, 0, 0, 0, 0, 0},
#include "jit/frontend/sh4/sh4_instr.inc"

View File

@ -16,7 +16,6 @@ enum {
};
enum sh4_op {
SH4_OP_INVALID,
#define SH4_INSTR(name, desc, instr_code, cycles, flags) SH4_OP_##name,
#include "jit/frontend/sh4/sh4_instr.inc"
#undef SH4_INSTR

View File

@ -2,6 +2,8 @@
// NAME DESC INSTR_CODE CYCLES FLAGS
//
SH4_INSTR(INVALID, "invalid", 0000000000000000, 1, 0)
// fixed-point transfer instructions
SH4_INSTR(MOVI, "mov #imm8, rn", 1110nnnniiiiiiii, 1, 0)
SH4_INSTR(MOVWLPC, "mov.w @(disp:8,pc), rn", 1001nnnndddddddd, 1, SH4_FLAG_LOAD)

File diff suppressed because it is too large Load Diff

View File

@ -723,7 +723,8 @@ void ir_branch(struct ir *ir, struct ir_value *dst) {
ir_set_arg0(ir, instr, dst);
}
void ir_branch_false(struct ir *ir, struct ir_value *cond, struct ir_value *dst) {
void ir_branch_false(struct ir *ir, struct ir_value *cond,
struct ir_value *dst) {
CHECK(dst->type == VALUE_I64);
struct ir_instr *instr = ir_append_instr(ir, OP_BRANCH_FALSE, VALUE_V);
@ -731,7 +732,8 @@ void ir_branch_false(struct ir *ir, struct ir_value *cond, struct ir_value *dst)
ir_set_arg1(ir, instr, dst);
}
void ir_branch_true(struct ir *ir, struct ir_value *cond, struct ir_value *dst) {
void ir_branch_true(struct ir *ir, struct ir_value *cond,
struct ir_value *dst) {
CHECK(dst->type == VALUE_I64);
struct ir_instr *instr = ir_append_instr(ir, OP_BRANCH_TRUE, VALUE_V);

View File

@ -319,7 +319,8 @@ struct ir_value *ir_lshd(struct ir *ir, struct ir_value *a, struct ir_value *n);
// branches
void ir_branch(struct ir *ir, struct ir_value *dst);
void ir_branch_false(struct ir *ir, struct ir_value *cond, struct ir_value *dst);
void ir_branch_false(struct ir *ir, struct ir_value *cond,
struct ir_value *dst);
void ir_branch_true(struct ir *ir, struct ir_value *cond, struct ir_value *dst);
// calls