From patchwork Tue Jul 12 19:02:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 9226045 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 DC6B2604DB for ; Tue, 12 Jul 2016 19:32:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C89DF27C8F for ; Tue, 12 Jul 2016 19:32:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BD29527D29; Tue, 12 Jul 2016 19:32:07 +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 0D4FA27C8F for ; Tue, 12 Jul 2016 19:32:07 +0000 (UTC) Received: from localhost ([::1]:42929 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bN3Pa-0004db-4C for patchwork-qemu-devel@patchwork.kernel.org; Tue, 12 Jul 2016 15:32:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56566) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bN2xh-0005cH-P8 for qemu-devel@nongnu.org; Tue, 12 Jul 2016 15:03:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bN2xf-0002lz-K3 for qemu-devel@nongnu.org; Tue, 12 Jul 2016 15:03:16 -0400 Received: from mail-qt0-x243.google.com ([2607:f8b0:400d:c0d::243]:34798) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bN2xf-0002ls-Fk for qemu-devel@nongnu.org; Tue, 12 Jul 2016 15:03:15 -0400 Received: by mail-qt0-x243.google.com with SMTP id c52so884447qte.1 for ; Tue, 12 Jul 2016 12:03:15 -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=kK3ne06fF87jDrS6vwJQWSv4G2vRT/T/tJK6CgBR2jQ=; b=xcFRpVifu6nWbdjjKYTzmdazi7K8WMgWsldY5f/1HePSjT6fRHBsp8G9KP/dsq2cGy 6F2zuhApNKaaRF6dXfqHC4KScC76FC5Us8cvmFHfWng8WL8p11XKMqYwLt92NJVIM9Ni eFDvsn3Y7LCnkLMUjtzgeGvDMNOTYRqlsPaqQ/jHmvR7mnGxYaJJkaMMIOQiHrewComf JLKs7BjfXyviy7Usi6ZIbld+NhZFUDcpgaypoBziKznM8JyIK6VmpDRRMKA1bPghsPVe MvXv6qJ04yhNrqPAYVRa2d6ksE3fJRN1npi9G0Fame62St35caExUohkePOUPUBiT531 H5cw== 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=kK3ne06fF87jDrS6vwJQWSv4G2vRT/T/tJK6CgBR2jQ=; b=i+yNGerVftyT7/jhvW3rDYaO8/DVf4G/FpzLDrISwobH12m4taYXNIyQos6j6Wh06d EAd4OZkPtb6HsprZdcSlSnJjA2vAMAUkeD6HPrl81TKJz0J88dC9i1+BpgNyAxQXkgXa LtKqO8vDR9MF4R0y05tlkliaV8mq8KVyfNxQ0r1Pn4C8uIRcUwS45MzQDBBAi1vqTKhb ZjdUMtRRJ/DsO+VPRwEzT1z8gVMisK7c0hT8w05na/ngMZRAZyad6iR2Oc8Nc5J0efeu FWf+xMkkYNcAOFqlAilRkPKpayGu6rczVn6vhobQ7teTYkI8A7ER8+qN3vhbiFWarsze 0mJg== X-Gm-Message-State: ALyK8tI/XNK8zmveAPUxe5KFNAW5Aun2yzGiNtziiQwDCTO1o080l+CfNEfmx8Ld6byTGw== X-Received: by 10.200.52.193 with SMTP id x1mr5821277qtb.65.1468350195091; Tue, 12 Jul 2016 12:03:15 -0700 (PDT) Received: from bigtime.com (71-37-54-227.tukw.qwest.net. [71.37.54.227]) by smtp.gmail.com with ESMTPSA id u87sm1209716qkl.30.2016.07.12.12.03.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Jul 2016 12:03:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 12 Jul 2016 12:02:17 -0700 Message-Id: <1468350138-9736-24-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1468350138-9736-1-git-send-email-rth@twiddle.net> References: <1468350138-9736-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:400d:c0d::243 Subject: [Qemu-devel] [PULL 23/24] target-sparc: Use cpu_loop_exit_restore from helper_check_ieee_exceptions 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: peter.maydell@linaro.org, mark.cave-ayland@ilande.co.uk Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This avoids needing to save state before every FP operation. Tested-by: Mark Cave-Ayland Signed-off-by: Richard Henderson --- target-sparc/fop_helper.c | 17 +++++++++++++---- target-sparc/translate.c | 6 +----- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/target-sparc/fop_helper.c b/target-sparc/fop_helper.c index cdc58ea..c7fb176 100644 --- a/target-sparc/fop_helper.c +++ b/target-sparc/fop_helper.c @@ -19,12 +19,13 @@ #include "qemu/osdep.h" #include "cpu.h" +#include "exec/exec-all.h" #include "exec/helper-proto.h" #define QT0 (env->qt0) #define QT1 (env->qt1) -target_ulong helper_check_ieee_exceptions(CPUSPARCState *env) +static target_ulong do_check_ieee_exceptions(CPUSPARCState *env, uintptr_t ra) { target_ulong status = get_float_exception_flags(&env->fp_status); target_ulong fsr = env->fsr; @@ -51,12 +52,15 @@ target_ulong helper_check_ieee_exceptions(CPUSPARCState *env) } if ((fsr & FSR_CEXC_MASK) & ((fsr & FSR_TEM_MASK) >> 23)) { + CPUState *cs = CPU(sparc_env_get_cpu(env)); + /* Unmasked exception, generate a trap. Note that while the helper is marked as NO_WG, we can get away with writing to cpu state along the exception path, since TCG generated code will never see the write. */ env->fsr = fsr | FSR_FTT_IEEE_EXCP; - helper_raise_exception(env, TT_FP_EXCP); + cs->exception_index = TT_FP_EXCP; + cpu_loop_exit_restore(cs, ra); } else { /* Accumulate exceptions */ fsr |= (fsr & FSR_CEXC_MASK) << 5; @@ -66,6 +70,11 @@ target_ulong helper_check_ieee_exceptions(CPUSPARCState *env) return fsr; } +target_ulong helper_check_ieee_exceptions(CPUSPARCState *env) +{ + return do_check_ieee_exceptions(env, GETPC()); +} + #define F_HELPER(name, p) void helper_f##name##p(CPUSPARCState *env) #define F_BINOP(name) \ @@ -262,7 +271,7 @@ void helper_fsqrtq(CPUSPARCState *env) ret = glue(size, _compare_quiet)(reg1, reg2, \ &env->fp_status); \ } \ - fsr = helper_check_ieee_exceptions(env); \ + fsr = do_check_ieee_exceptions(env, GETPC()); \ switch (ret) { \ case float_relation_unordered: \ fsr |= (FSR_FCC1 | FSR_FCC0) << FS; \ @@ -293,7 +302,7 @@ void helper_fsqrtq(CPUSPARCState *env) ret = glue(size, _compare_quiet)(src1, src2, \ &env->fp_status); \ } \ - fsr = helper_check_ieee_exceptions(env); \ + fsr = do_check_ieee_exceptions(env, GETPC()); \ switch (ret) { \ case float_relation_unordered: \ fsr |= (FSR_FCC1 | FSR_FCC0) << FS; \ diff --git a/target-sparc/translate.c b/target-sparc/translate.c index dea1b5f..590a58d 100644 --- a/target-sparc/translate.c +++ b/target-sparc/translate.c @@ -3464,7 +3464,7 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn) rs1 = GET_FIELD(insn, 13, 17); rs2 = GET_FIELD(insn, 27, 31); xop = GET_FIELD(insn, 18, 26); - save_state(dc); + switch (xop) { case 0x1: /* fmovs */ cpu_src1_32 = gen_load_fpr_F(dc, rs2); @@ -3639,7 +3639,6 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn) rs1 = GET_FIELD(insn, 13, 17); rs2 = GET_FIELD(insn, 27, 31); xop = GET_FIELD(insn, 18, 26); - save_state(dc); #ifdef TARGET_SPARC64 #define FMOVR(sz) \ @@ -5276,7 +5275,6 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn) if (gen_trap_ifnofpu(dc)) { goto jmp_insn; } - save_state(dc); switch (xop) { case 0x20: /* ldf, load fpreg */ gen_address_mask(dc, cpu_addr); @@ -5390,7 +5388,6 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn) if (gen_trap_ifnofpu(dc)) { goto jmp_insn; } - save_state(dc); switch (xop) { case 0x24: /* stf, store fpreg */ { @@ -5449,7 +5446,6 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn) goto illegal_insn; } } else if (xop > 0x33 && xop < 0x3f) { - save_state(dc); switch (xop) { #ifdef TARGET_SPARC64 case 0x34: /* V9 stfa */