From patchwork Mon Feb 8 17:03:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 8252531 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 21E69BEEE5 for ; Mon, 8 Feb 2016 17:09:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 72BB5203B7 for ; Mon, 8 Feb 2016 17:09:41 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 62EE7203C3 for ; Mon, 8 Feb 2016 17:09:40 +0000 (UTC) Received: from localhost ([::1]:46893 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSpJj-0005Nv-KE for patchwork-qemu-devel@patchwork.kernel.org; Mon, 08 Feb 2016 12:09:39 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43519) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSpE2-0003WG-0A for qemu-devel@nongnu.org; Mon, 08 Feb 2016 12:03:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aSpE1-0006ou-3N for qemu-devel@nongnu.org; Mon, 08 Feb 2016 12:03:45 -0500 Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]:36277) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSpE0-0006oo-SW for qemu-devel@nongnu.org; Mon, 08 Feb 2016 12:03:45 -0500 Received: by mail-wm0-x22d.google.com with SMTP id p63so123142179wmp.1 for ; Mon, 08 Feb 2016 09:03:44 -0800 (PST) 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=2GYSctgF3PjTlMh6s471zT/+uRUXRWXQSI/EUYrM8XU=; b=gClHAn4cr3hljtKSjmQN/tsXiwdIWWXbjDhSLfWfDD90aRx2cIQcuRCPhBwc3Yso9S qwIglx4f9SZcdqoBWBBgFpeme5qRszK73BaII5/A2XPmT/Pv7LFvJaf5RK67W/pBITwd YPYxhw4M5Hs2cxTGcov8oBwjNGvyH9oeiRbKI6lcGQETmWlZoQHtdvVuJjGOITIT3Txr AUN37/meRSyL4u4ztyakfrQO1WLWybBIcgtmjrE+IeWT4UQu79Wp4XHwODZkNfBIK6xh 0CFxz/6UI2L5hKTyLbM23GDMmnQZ44VdvlODkXxEJ6rZtYwqfntG6WzKyXn2Tc5r5YQE C7eQ== 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=2GYSctgF3PjTlMh6s471zT/+uRUXRWXQSI/EUYrM8XU=; b=F6h/CfUyUepQBWtB/QLSBG4vLZpsCSdwlNkQZdDXbv4QFXY6VmPGeI+AM41S7KIb5e XcrlARthcw4LyztylSU3sYAyoI4u4YM8W1XGxmwp8124ca5u9XeHhOhFGGClB5aYwJVL U1Ai12D5M6nQXRpkGJ6ymCCqxEDQSPvaRLDQ6B//2NQ3U2GeiBos3QPin7iEtl12tssh 1iSiIn4KUg+brMFkm0GpHd91REeLjP1Nz9ccIbxi+FM9wQ4+HDqcdh2YdFcnA2uBOPth F/oqsHQmPJhA+CfkavJwvNOB66tPvbVrhYLIHgP4gjRN7rqKdNgl9G6MjUIK4qkIjMGn oSbw== X-Gm-Message-State: AG10YORvYreUw5OtckMg5SZdWyyOi1SIX5E2Ihw7uNnU8R9MCg2SiRexS7rigwvdDxXe5w== X-Received: by 10.194.250.39 with SMTP id yz7mr32358438wjc.92.1454951024199; Mon, 08 Feb 2016 09:03:44 -0800 (PST) Received: from 640k.lan (94-39-141-130.adsl-ull.clienti.tiscali.it. [94.39.141.130]) by smtp.gmail.com with ESMTPSA id b1sm30651442wjy.0.2016.02.08.09.03.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Feb 2016 09:03:43 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 8 Feb 2016 18:03:08 +0100 Message-Id: <1454950999-64128-18-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1454950999-64128-1-git-send-email-pbonzini@redhat.com> References: <1454950999-64128-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::22d Cc: Richard Henderson Subject: [Qemu-devel] [PULL 17/28] target-i386: Introduce mo_stacksize X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Richard Henderson Centralize computation of a MO_SIZE for the stack pointer. Signed-off-by: Richard Henderson Message-Id: <1450379966-28198-3-git-send-email-rth@twiddle.net> Signed-off-by: Paolo Bonzini --- target-i386/translate.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/target-i386/translate.c b/target-i386/translate.c index fd168f0..57dfec8 100644 --- a/target-i386/translate.c +++ b/target-i386/translate.c @@ -304,6 +304,12 @@ static inline TCGMemOp mo_pushpop(DisasContext *s, TCGMemOp ot) } } +/* Select the size of the stack pointer. */ +static inline TCGMemOp mo_stacksize(DisasContext *s) +{ + return CODE64(s) ? MO_64 : s->ss32 ? MO_32 : MO_16; +} + /* Select only size 64 else 32. Used for SSE operand sizes. */ static inline TCGMemOp mo_64_32(TCGMemOp ot) { @@ -2289,31 +2295,22 @@ gen_svm_check_intercept(DisasContext *s, target_ulong pc_start, uint64_t type) static inline void gen_stack_update(DisasContext *s, int addend) { -#ifdef TARGET_X86_64 - if (CODE64(s)) { - gen_op_add_reg_im(MO_64, R_ESP, addend); - } else -#endif - if (s->ss32) { - gen_op_add_reg_im(MO_32, R_ESP, addend); - } else { - gen_op_add_reg_im(MO_16, R_ESP, addend); - } + gen_op_add_reg_im(mo_stacksize(s), R_ESP, addend); } /* Generate a push. It depends on ss32, addseg and dflag. */ static void gen_push_v(DisasContext *s, TCGv val) { - TCGMemOp a_ot, d_ot = mo_pushpop(s, s->dflag); + TCGMemOp d_ot = mo_pushpop(s, s->dflag); + TCGMemOp a_ot = mo_stacksize(s); int size = 1 << d_ot; TCGv new_esp = cpu_A0; tcg_gen_subi_tl(cpu_A0, cpu_regs[R_ESP], size); if (CODE64(s)) { - a_ot = MO_64; + /* No special handling. */ } else if (s->ss32) { - a_ot = MO_32; if (s->addseg) { new_esp = cpu_tmp4; tcg_gen_mov_tl(new_esp, cpu_A0); @@ -2322,7 +2319,6 @@ static void gen_push_v(DisasContext *s, TCGv val) tcg_gen_ext32u_tl(cpu_A0, cpu_A0); } } else { - a_ot = MO_16; new_esp = cpu_tmp4; tcg_gen_ext16u_tl(cpu_A0, cpu_A0); tcg_gen_mov_tl(new_esp, cpu_A0);