mirror of https://github.com/inolen/redream.git
update inlined sh4_implode_sr / sh4_explode_sr to match actual functions
This commit is contained in:
parent
1ce904f5a9
commit
3ebfbe47cc
|
@ -256,6 +256,7 @@ void sh4_reset(struct sh4 *sh4, uint32_t pc) {
|
|||
sh4->ctx.pr = 0x0;
|
||||
sh4->ctx.sr = 0x700000f0;
|
||||
sh4->ctx.fpscr = 0x00040001;
|
||||
sh4_explode_sr(&sh4->ctx);
|
||||
|
||||
/* initialize registers */
|
||||
#define SH4_REG(addr, name, default, type) \
|
||||
|
|
|
@ -146,18 +146,16 @@ static inline void sh4_swap_fpr_bank(struct sh4_context *ctx) {
|
|||
|
||||
static inline void sh4_implode_sr(struct sh4_context *ctx) {
|
||||
uint32_t sr_q = (ctx->sr_qm >> 31) == ctx->sr_m;
|
||||
|
||||
ctx->sr &= ~(M_MASK | Q_MASK | S_MASK | T_MASK);
|
||||
ctx->sr |= (ctx->sr_m << M_BIT) | (sr_q << Q_BIT) | (ctx->sr_s << S_BIT) |
|
||||
(ctx->sr_t << T_BIT);
|
||||
}
|
||||
|
||||
static inline void sh4_explode_sr(struct sh4_context *ctx) {
|
||||
uint32_t sr_q = (ctx->sr & Q_MASK) >> Q_BIT;
|
||||
ctx->sr_t = (ctx->sr & T_MASK) >> T_BIT;
|
||||
ctx->sr_s = (ctx->sr & S_MASK) >> S_BIT;
|
||||
ctx->sr_m = (ctx->sr & M_MASK) >> M_BIT;
|
||||
|
||||
uint32_t sr_q = (ctx->sr & Q_MASK) >> Q_BIT;
|
||||
ctx->sr_qm = (sr_q == ctx->sr_m) << 31;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,14 +10,26 @@ static struct ir_value *load_sr(struct ir *ir) {
|
|||
ir_load_context(ir, offsetof(struct sh4_context, sr), VALUE_I32);
|
||||
|
||||
/* inlined version of sh4_implode_sr */
|
||||
sr = ir_and(ir, sr, ir_alloc_i32(ir, ~(M_MASK | Q_MASK | S_MASK | T_MASK)));
|
||||
|
||||
struct ir_value *sr_t =
|
||||
ir_load_context(ir, offsetof(struct sh4_context, sr_t), VALUE_I32);
|
||||
sr = ir_or(ir, sr, sr_t);
|
||||
|
||||
struct ir_value *sr_s =
|
||||
ir_load_context(ir, offsetof(struct sh4_context, sr_s), VALUE_I32);
|
||||
sr = ir_and(ir, sr, ir_alloc_i32(ir, ~(S_MASK | T_MASK)));
|
||||
sr = ir_or(ir, sr, sr_t);
|
||||
sr = ir_or(ir, sr, ir_shli(ir, sr_s, S_BIT));
|
||||
|
||||
struct ir_value *sr_m =
|
||||
ir_load_context(ir, offsetof(struct sh4_context, sr_m), VALUE_I32);
|
||||
sr = ir_or(ir, sr, ir_shli(ir, sr_m, M_BIT));
|
||||
|
||||
struct ir_value *sr_qm =
|
||||
ir_load_context(ir, offsetof(struct sh4_context, sr_qm), VALUE_I32);
|
||||
struct ir_value *sr_q =
|
||||
ir_zext(ir, ir_cmp_eq(ir, ir_lshri(ir, sr_qm, 31), sr_m), VALUE_I32);
|
||||
sr = ir_or(ir, sr, ir_shli(ir, sr_q, Q_BIT));
|
||||
|
||||
return sr;
|
||||
}
|
||||
|
||||
|
@ -34,11 +46,22 @@ static void store_sr(struct sh4_guest *guest, struct ir *ir,
|
|||
|
||||
/* inline version of sh4_explode_sr */
|
||||
struct ir_value *sr_t = ir_and(ir, v, ir_alloc_i32(ir, T_MASK));
|
||||
ir_store_context(ir, offsetof(struct sh4_context, sr_t), sr_t);
|
||||
|
||||
struct ir_value *sr_s =
|
||||
ir_lshri(ir, ir_and(ir, v, ir_alloc_i32(ir, S_MASK)), S_BIT);
|
||||
ir_store_context(ir, offsetof(struct sh4_context, sr_t), sr_t);
|
||||
ir_store_context(ir, offsetof(struct sh4_context, sr_s), sr_s);
|
||||
|
||||
struct ir_value *sr_m =
|
||||
ir_lshri(ir, ir_and(ir, v, ir_alloc_i32(ir, M_MASK)), M_BIT);
|
||||
ir_store_context(ir, offsetof(struct sh4_context, sr_m), sr_m);
|
||||
|
||||
struct ir_value *sr_q =
|
||||
ir_lshri(ir, ir_and(ir, v, ir_alloc_i32(ir, Q_MASK)), Q_BIT);
|
||||
struct ir_value *sr_qm =
|
||||
ir_shli(ir, ir_zext(ir, ir_cmp_eq(ir, sr_q, sr_m), VALUE_I32), 31);
|
||||
ir_store_context(ir, offsetof(struct sh4_context, sr_qm), sr_qm);
|
||||
|
||||
ir_call_2(ir, sr_updated, data, old_sr);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue