mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-02-02 07:51:08 +00:00
target-i386: emulate LOCK'ed INC using atomic helper
Backports commit 60e573462fcdb83aa1a41e66a9f31dc8a4364399 from qemu
This commit is contained in:
parent
7c7b0fe746
commit
05c94546d5
|
@ -1562,21 +1562,23 @@ static void gen_inc(DisasContext *s, TCGMemOp ot, int d, int c)
|
|||
TCGv cpu_cc_src = tcg_ctx->cpu_cc_src;
|
||||
TCGv cpu_T0 = tcg_ctx->cpu_T0;
|
||||
|
||||
if (d != OR_TMP0) {
|
||||
gen_op_mov_v_reg(tcg_ctx, ot, cpu_T0, d);
|
||||
if (s->prefix & PREFIX_LOCK) {
|
||||
tcg_gen_movi_tl(tcg_ctx, cpu_T0, c > 0 ? 1 : -1);
|
||||
tcg_gen_atomic_add_fetch_tl(tcg_ctx, cpu_T0, cpu_A0, cpu_T0,
|
||||
s->mem_index, ot | MO_LE);
|
||||
} else {
|
||||
gen_op_ld_v(s, ot, cpu_T0, cpu_A0);
|
||||
if (d != OR_TMP0) {
|
||||
gen_op_mov_v_reg(tcg_ctx, ot, cpu_T0, d);
|
||||
} else {
|
||||
gen_op_ld_v(s, ot, cpu_T0, cpu_A0);
|
||||
}
|
||||
tcg_gen_addi_tl(tcg_ctx, cpu_T0, cpu_T0, (c > 0 ? 1 : -1));
|
||||
gen_op_st_rm_T0_A0(s, ot, d);
|
||||
}
|
||||
|
||||
gen_compute_eflags_c(s, cpu_cc_src);
|
||||
if (c > 0) {
|
||||
tcg_gen_addi_tl(tcg_ctx, cpu_T0, cpu_T0, 1);
|
||||
set_cc_op(s, CC_OP_INCB + ot);
|
||||
} else {
|
||||
tcg_gen_addi_tl(tcg_ctx, cpu_T0, cpu_T0, -1);
|
||||
set_cc_op(s, CC_OP_DECB + ot);
|
||||
}
|
||||
gen_op_st_rm_T0_A0(s, ot, d);
|
||||
tcg_gen_mov_tl(tcg_ctx, cpu_cc_dst, cpu_T0);
|
||||
set_cc_op(s, (c > 0 ? CC_OP_INCB : CC_OP_DECB) + ot);
|
||||
}
|
||||
|
||||
static void gen_shift_flags(DisasContext *s, TCGMemOp ot, TCGv result,
|
||||
|
|
Loading…
Reference in a new issue