From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58831) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHboB-0006gK-EV for qemu-devel@nongnu.org; Mon, 27 Jun 2016 15:03:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bHbo6-0008Hc-UY for qemu-devel@nongnu.org; Mon, 27 Jun 2016 15:02:58 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:58077) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHbo5-0008Ca-K8 for qemu-devel@nongnu.org; Mon, 27 Jun 2016 15:02:54 -0400 From: "Emilio G. Cota" Date: Mon, 27 Jun 2016 15:01:59 -0400 Message-Id: <1467054136-10430-14-git-send-email-cota@braap.org> In-Reply-To: <1467054136-10430-1-git-send-email-cota@braap.org> References: <1467054136-10430-1-git-send-email-cota@braap.org> Subject: [Qemu-devel] [RFC 13/30] target-i386: emulate LOCK'ed INC using atomic helper List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: QEMU Developers , MTTCG Devel Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Paolo Bonzini , Richard Henderson , Sergey Fedorov , Alvise Rigo , Peter Maydell Signed-off-by: Emilio G. Cota --- target-i386/translate.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/target-i386/translate.c b/target-i386/translate.c index 1dc7014..a9fa25a 100644 --- a/target-i386/translate.c +++ b/target-i386/translate.c @@ -1433,9 +1433,30 @@ static void gen_op(DisasContext *s1, int op, TCGMemOp ot, int d) } } +static void gen_inc_locked(DisasContext *s1, TCGMemOp ot, int c) +{ + TCGv t0; + + t0 = tcg_temp_new(); + tcg_gen_movi_tl(t0, 1); + gen_compute_eflags_c(s1, cpu_cc_src); + if (c > 0) { + gen_atomic_add_fetch(cpu_T0, cpu_A0, t0, ot); + set_cc_op(s1, CC_OP_INCB + ot); + } else { + gen_atomic_sub_fetch(cpu_T0, cpu_A0, t0, ot); + set_cc_op(s1, CC_OP_DECB + ot); + } + tcg_gen_mov_tl(cpu_cc_dst, cpu_T0); + tcg_temp_free(t0); +} + /* if d == OR_TMP0, it means memory operand (address in A0) */ static void gen_inc(DisasContext *s1, TCGMemOp ot, int d, int c) { + if (s1->prefix & PREFIX_LOCK) { + return gen_inc_locked(s1, ot, c); + } if (d != OR_TMP0) { gen_op_mov_v_reg(ot, cpu_T0, d); } else { -- 2.5.0