From patchwork Mon Feb 8 17:03:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 8252481 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 2069CBEEED for ; Mon, 8 Feb 2016 17:08:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6D621203DB for ; Mon, 8 Feb 2016 17:08:00 +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 957A3203DF for ; Mon, 8 Feb 2016 17:07:59 +0000 (UTC) Received: from localhost ([::1]:46878 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSpI6-000285-St for patchwork-qemu-devel@patchwork.kernel.org; Mon, 08 Feb 2016 12:07:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43661) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSpE9-0003lF-Od for qemu-devel@nongnu.org; Mon, 08 Feb 2016 12:03:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aSpE5-0006rX-Ig for qemu-devel@nongnu.org; Mon, 08 Feb 2016 12:03:53 -0500 Received: from mail-wm0-x230.google.com ([2a00:1450:400c:c09::230]:38172) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSpE5-0006r6-Cj for qemu-devel@nongnu.org; Mon, 08 Feb 2016 12:03:49 -0500 Received: by mail-wm0-x230.google.com with SMTP id p63so124741007wmp.1 for ; Mon, 08 Feb 2016 09:03:49 -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=8Swm3uNXWFstOv57utXc5ol37xRTCULATD9NGv9MNZM=; b=aAphZ5kUibWDwscAd5CImdaIdxZeqJTlMOzPGXmaab0D4+C+UJl16ERvZlKYH/2Ehz g+lZHcz85C4/I/diDCPDKWniONmUt1uchrdYv8Zdhg6O+GLTyIHMOZtA3V9x5tnE0tHg KeNF+o8LpFibkPaP1pYfLH5qLBnejeIjqqAanPnyuGhH12u0tUj1XtvRXJ5lF0Kq5t+w aYjMm2BBvgbenMF4/xKXwPcIaqaL73aQ+GPjFk4usv1Fg6BtClJphH4DF3EH4SRH3G+O a37Kb9kt02Ocb1kxzsWic0THR/EST9OgBkOTR/3Gnbqycpk4tUhKKfF3BQlVRIdtoZIT fkHA== 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=8Swm3uNXWFstOv57utXc5ol37xRTCULATD9NGv9MNZM=; b=PeqvBG8bAioKUtFRWCGi4e9IZLLnn6uee/liYkfAHqb9L+snjlHZCM6q61TRqh+FKu z0gf1xcYuJWLQ2M5yVlFla41kmt/CUn0OaHABk4j0E+1hJsBXpMmvKyyWuaG8HNDvDtF 2BIsAaxEtz+yGXCQm1soeSHWVG54B0KppJz51XCaAb8i7W/+0I7FQwz6iH718yGX5rpM Z5CZZKFaRktcw3cVbpp7XEQ/VgHRI87N0QzSS01QWxxnjLkSsTSB/85FntCEb0GY+g1Q UYffTQjqE7b2xY2YZ72ul+PPZjp5Jk6EzgTvrp3r74jf3HDkEBzZZi1gryh1eMMSlTbS NXvw== X-Gm-Message-State: AG10YORXaIRpYIQV0nBg7K1qGXUZXOxeXXiSflCI4Nep395gMvwjPYM8xu2LCwuzuL40LA== X-Received: by 10.194.121.167 with SMTP id ll7mr34491716wjb.113.1454951028781; Mon, 08 Feb 2016 09:03:48 -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.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Feb 2016 09:03:48 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 8 Feb 2016 18:03:12 +0100 Message-Id: <1454950999-64128-22-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::230 Cc: Richard Henderson Subject: [Qemu-devel] [PULL 21/28] target-i386: Use gen_lea_v_seg in pusha/popa 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 More centralization of handling of segment bases. Also fixes the note about 16-bit wrap around not fully handled. Signed-off-by: Richard Henderson Message-Id: <1450379966-28198-7-git-send-email-rth@twiddle.net> Signed-off-by: Paolo Bonzini --- target-i386/translate.c | 50 +++++++++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/target-i386/translate.c b/target-i386/translate.c index 2a6a90a..78168aa 100644 --- a/target-i386/translate.c +++ b/target-i386/translate.c @@ -2298,45 +2298,41 @@ static inline void gen_stack_A0(DisasContext *s) gen_lea_v_seg(s, s->ss32 ? MO_32 : MO_16, cpu_regs[R_ESP], R_SS, -1); } -/* NOTE: wrap around in 16 bit not fully handled */ static void gen_pusha(DisasContext *s) { + TCGMemOp s_ot = s->ss32 ? MO_32 : MO_16; + TCGMemOp d_ot = s->dflag; + int size = 1 << d_ot; int i; - gen_op_movl_A0_reg(R_ESP); - gen_op_addl_A0_im(-(8 << s->dflag)); - if (!s->ss32) - tcg_gen_ext16u_tl(cpu_A0, cpu_A0); - tcg_gen_mov_tl(cpu_T[1], cpu_A0); - if (s->addseg) - gen_op_addl_A0_seg(s, R_SS); - for(i = 0;i < 8; i++) { - gen_op_mov_v_reg(MO_32, cpu_T[0], 7 - i); - gen_op_st_v(s, s->dflag, cpu_T[0], cpu_A0); - gen_op_addl_A0_im(1 << s->dflag); + + for (i = 0; i < 8; i++) { + tcg_gen_addi_tl(cpu_A0, cpu_regs[R_ESP], (i - 8) * size); + gen_lea_v_seg(s, s_ot, cpu_A0, R_SS, -1); + gen_op_st_v(s, d_ot, cpu_regs[7 - i], cpu_A0); } - gen_op_mov_reg_v(MO_16 + s->ss32, R_ESP, cpu_T[1]); + + gen_stack_update(s, -8 * size); } -/* NOTE: wrap around in 16 bit not fully handled */ static void gen_popa(DisasContext *s) { + TCGMemOp s_ot = s->ss32 ? MO_32 : MO_16; + TCGMemOp d_ot = s->dflag; + int size = 1 << d_ot; int i; - gen_op_movl_A0_reg(R_ESP); - if (!s->ss32) - tcg_gen_ext16u_tl(cpu_A0, cpu_A0); - tcg_gen_mov_tl(cpu_T[1], cpu_A0); - tcg_gen_addi_tl(cpu_T[1], cpu_T[1], 8 << s->dflag); - if (s->addseg) - gen_op_addl_A0_seg(s, R_SS); - for(i = 0;i < 8; i++) { + + for (i = 0; i < 8; i++) { /* ESP is not reloaded */ - if (i != 3) { - gen_op_ld_v(s, s->dflag, cpu_T[0], cpu_A0); - gen_op_mov_reg_v(s->dflag, 7 - i, cpu_T[0]); + if (7 - i == R_ESP) { + continue; } - gen_op_addl_A0_im(1 << s->dflag); + tcg_gen_addi_tl(cpu_A0, cpu_regs[R_ESP], i * size); + gen_lea_v_seg(s, s_ot, cpu_A0, R_SS, -1); + gen_op_ld_v(s, d_ot, cpu_T[0], cpu_A0); + gen_op_mov_reg_v(d_ot, 7 - i, cpu_T[0]); } - gen_op_mov_reg_v(MO_16 + s->ss32, R_ESP, cpu_T[1]); + + gen_stack_update(s, 8 * size); } static void gen_enter(DisasContext *s, int esp_addend, int level)