From patchwork Tue Jun 28 00:39:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 9201655 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 EAEED6075F for ; Tue, 28 Jun 2016 01:40:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB9F3285CE for ; Tue, 28 Jun 2016 01:40:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D039D285D7; Tue, 28 Jun 2016 01:40:06 +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 2E5FC285CE for ; Tue, 28 Jun 2016 01:40:05 +0000 (UTC) Received: from localhost ([::1]:33582 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHhTr-0000Q5-EH for patchwork-qemu-devel@patchwork.kernel.org; Mon, 27 Jun 2016 21:06:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43929) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHh4T-0002zN-VO for qemu-devel@nongnu.org; Mon, 27 Jun 2016 20:40:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bHh4S-0004Y3-Pl for qemu-devel@nongnu.org; Mon, 27 Jun 2016 20:40:09 -0400 Received: from mail-qk0-x241.google.com ([2607:f8b0:400d:c09::241]:34219) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHh4S-0004Xp-LK for qemu-devel@nongnu.org; Mon, 27 Jun 2016 20:40:08 -0400 Received: by mail-qk0-x241.google.com with SMTP id j2so331934qkf.1 for ; Mon, 27 Jun 2016 17:40:08 -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=C8Nc2YigUyWvOIDmrhDmW6EsRL1TOojkUyzBW6Cutx0=; b=RSFJPPBfKyEO97ebFaA0KcGM+EXuFJpZZaeQ1w6thL1wu20BWc5u6u2KwF2ej+hf+w U965XS7joWI4tzmsnFqna2nCEQbd4H8YKzfBfgqjOyKuXhNKoH24sHUc0usclgIP51+s HVqTiT5GlD058gWa95M9Zxpz+9kAUx9woqKxOiV5+1LENmYrpKcLM872+GSj9XzXZhlS O+PKkAkXfGd6cHaP+zp6JxYMTbV5xR2akPMSVkIjtkk6IUTSk23P4y1aqCvHNzqoE8pK yzMjmify/ZeOZ+LIO12rbvaFHp2VC6Zx3s/ckXKg8d2zprUNw8pAgzLp/JprjPPxkyIy Iabg== 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=C8Nc2YigUyWvOIDmrhDmW6EsRL1TOojkUyzBW6Cutx0=; b=SpifxWES1FhMCH06W414ZrGCwvrJuJYfJk1o9M9wCVyQ9OXkAUkOAag9mvhHhFTZkK O57x562ytqUdT4qNPDjafXu/ELB33KVqhGKDYZdXNoLflmMaOXPyQi9APqolRjDVxwwC 7ahB83LIvLaD+NkuAlEAySR9GGo6NZ24/npJdhunyv+xPAzLVHsM5TWO6ew9Ekx78bWY kYAiHlqTamxjOykdCRC2zoq8yX8g8yMN4zX2hO4ij2f4wjX/wCA3kR6yPZvtrTnBoZq2 havpzLkyd3sfo23ZfSCIyVJZj4iInCs3rEXdGFkqpwcT3VIHL+xt3a5Bfu31LsF42GDW BNaQ== X-Gm-Message-State: ALyK8tLfRmhTqlziarCvar7ZlBk+jAv2pjmfYzXOf6botgSoz8dXLWq8i4nQ556ONxROow== X-Received: by 10.55.203.73 with SMTP id d70mr270684qkj.116.1467074408222; Mon, 27 Jun 2016 17:40:08 -0700 (PDT) Received: from bigtime.com (71-37-54-227.tukw.qwest.net. [71.37.54.227]) by smtp.gmail.com with ESMTPSA id 128sm190406qke.10.2016.06.27.17.40.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Jun 2016 17:40:07 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 27 Jun 2016 17:39:12 -0700 Message-Id: <1467074353-26130-24-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1467074353-26130-1-git-send-email-rth@twiddle.net> References: <1467074353-26130-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:c09::241 Subject: [Qemu-devel] [PATCH v4 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: 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. Reviewed-By: Artyom Tarasenko 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 */