From patchwork Fri Jul 1 17:04:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 9210261 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D07CB607D6 for ; Fri, 1 Jul 2016 17:19:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE0FA28531 for ; Fri, 1 Jul 2016 17:19:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B2E3B286A4; Fri, 1 Jul 2016 17:19:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 326FC28531 for ; Fri, 1 Jul 2016 17:19:03 +0000 (UTC) Received: from localhost ([::1]:34687 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bJ25m-0002ac-8N for patchwork-qemu-devel@patchwork.kernel.org; Fri, 01 Jul 2016 13:19:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53675) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bJ1sM-0002LK-SP for qemu-devel@nongnu.org; Fri, 01 Jul 2016 13:05:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bJ1sI-0005PK-Rn for qemu-devel@nongnu.org; Fri, 01 Jul 2016 13:05:10 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:35850) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bJ1sI-0005OC-HS for qemu-devel@nongnu.org; Fri, 01 Jul 2016 13:05:06 -0400 Received: by mail-pf0-x242.google.com with SMTP id i123so10452534pfg.3 for ; Fri, 01 Jul 2016 10:05:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=Ru+XJ9D7P3ryJivMVnnbZkRXlItciZm32Ux9uv4SL8Q=; b=fdp2l257gQMJ3jrItP7Lg7pbWV8abPI+gHqyDyhZp+qEPu0hoqPXdJbt4f9ku/x3ls Ls9yB+2ycPqtyUzfJn5WnOqtQ5Lj7WZz0kOpYfGXjmxg98MFCdSWmd1eM4Y2hZDqI2dY Sq97HebrymVY8T4tPfjhuFM3AZcRqyra/EgW7fGn4/WgoZ9utkzJm2hm8oUEBDX3YgB0 mc0c9FCHfowN+nUK6Rp/C5fyEOJi//eUUxZAUlsvNYLOe+EXuusrmS0+UMscNBJHgUQN XePyS0m+zeKwVoR/DYF/qZj9IUNb/syqQ7xV8p26xRBdkXtdLQ2jXJEjwA8/CipcnRx1 1Hbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=Ru+XJ9D7P3ryJivMVnnbZkRXlItciZm32Ux9uv4SL8Q=; b=J+AnmJ6TKWhwHyD6d0g2iEvICB9vMs/cRFMfRl/qrMyOtCckpre3LyOyi7sDSrbd3g nmYRwp63dab1wKk8azz25WiohvwGdb9iJyzwCj29QBqMdZuGCncu0gIotzfEeLsJ0OGy Ant8WLVcKLMW+uZibavt39leIobdzFTzKCNnDY4U5tvkOayN660/T7qbQwThKijRS1i3 3sUPwGXU5wDNYaFTjslWzWZ3xQv8c2/KcW6MfbeghYvkw4hoiCx9pbqp5Yg+9R8ZZFU6 ym126BucHwwcPS2NHF9G58fuCPzd7pGYwFxH6XHnbZqP+5Z2dcohbWRYCS7FypV7ucCo J3tQ== X-Gm-Message-State: ALyK8tL8ahADi+SGVGhH+ezZVpMXTIONXiRnxC+oP0F4Qi9T78RskSr2WIHPTxOQCW5heg== X-Received: by 10.98.39.68 with SMTP id n65mr33479639pfn.153.1467392705877; Fri, 01 Jul 2016 10:05:05 -0700 (PDT) Received: from bigtime.twiddle.net (71-37-54-227.tukw.qwest.net. [71.37.54.227]) by smtp.gmail.com with ESMTPSA id ff9sm2652229pac.5.2016.07.01.10.05.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Jul 2016 10:05:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jul 2016 10:04:39 -0700 Message-Id: <1467392693-22715-14-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1467392693-22715-1-git-send-email-rth@twiddle.net> References: <1467392693-22715-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c00::242 Subject: [Qemu-devel] [PATCH v2 13/27] target-i386: emulate LOCK'ed INC using atomic helper X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, serge.fdrv@gmail.com, cota@braap.org, alex.bennee@linaro.org, peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: "Emilio G. Cota" [rth: Merge gen_inc_locked back into gen_inc to share cc update.] Signed-off-by: Emilio G. Cota Message-Id: <1467054136-10430-14-git-send-email-cota@braap.org> Signed-off-by: Richard Henderson --- target-i386/translate.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/target-i386/translate.c b/target-i386/translate.c index 58bc954..3f10ff0 100644 --- a/target-i386/translate.c +++ b/target-i386/translate.c @@ -1362,21 +1362,23 @@ static void gen_op(DisasContext *s1, int op, TCGMemOp ot, int d) /* if d == OR_TMP0, it means memory operand (address in A0) */ static void gen_inc(DisasContext *s1, TCGMemOp ot, int d, int c) { - if (d != OR_TMP0) { - gen_op_mov_v_reg(ot, cpu_T0, d); + if (s1->prefix & PREFIX_LOCK) { + tcg_gen_movi_tl(cpu_T0, c > 0 ? 1 : -1); + tcg_gen_atomic_add_fetch_tl(cpu_T0, cpu_A0, cpu_T0, + s1->mem_index, ot | MO_LE); } else { - gen_op_ld_v(s1, ot, cpu_T0, cpu_A0); + if (d != OR_TMP0) { + gen_op_mov_v_reg(ot, cpu_T0, d); + } else { + gen_op_ld_v(s1, ot, cpu_T0, cpu_A0); + } + tcg_gen_addi_tl(cpu_T0, cpu_T0, (c > 0 ? 1 : -1)); + gen_op_st_rm_T0_A0(s1, ot, d); } + gen_compute_eflags_c(s1, cpu_cc_src); - if (c > 0) { - tcg_gen_addi_tl(cpu_T0, cpu_T0, 1); - set_cc_op(s1, CC_OP_INCB + ot); - } else { - tcg_gen_addi_tl(cpu_T0, cpu_T0, -1); - set_cc_op(s1, CC_OP_DECB + ot); - } - gen_op_st_rm_T0_A0(s1, ot, d); tcg_gen_mov_tl(cpu_cc_dst, cpu_T0); + set_cc_op(s1, (c > 0 ? CC_OP_INCB : CC_OP_DECB) + ot); } static void gen_shift_flags(DisasContext *s, TCGMemOp ot, TCGv result,