From patchwork Fri Mar 1 20:05:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 159512 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp1146017jad; Fri, 1 Mar 2019 12:10:43 -0800 (PST) X-Google-Smtp-Source: APXvYqy5oAJlgnQByySqbD0e9w/qLZmfHprYXOkagbvX3/y8JDLjAjdDSaCeLX2Wu9m65FNAvO2r X-Received: by 2002:a81:4ed6:: with SMTP id c205mr5149202ywb.13.1551471043885; Fri, 01 Mar 2019 12:10:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551471043; cv=none; d=google.com; s=arc-20160816; b=wTj5XFPkkHx1ojqXbVRP9SPn0etTK8JFxP12oLOknrR5owBPLFbHGRvlW/j5iEJON3 UQh76epcxWd+rAVHrsDbuzPmeVvEV9XfQiuusImhmSdeNswK8YrYy+PgiE3A2JsBfA7E 4srYoESWXeTLGVlb2CBKAKp2ZL2MSqk7mhS+iFiXsdo2MLPpaj3oWAlp9zDKEX/qS9Ag CQFSRf6qPvF1uw7HgG/lEKAfIcNmEu6XvBF7B2M3NSzChfbxwqi/SxJphNtcOBQ9OODe vCGCefln+fV9j9QbxsdZyFqF2FLwjFzbe/PB7lSAhuGsKWloTaV04Dowddh+MknkAh7l Y34w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=tUyLPFYqwpjAIVN/Lq+PNWoyDi0ukBwdF+if0JEltxc=; b=N56SJsIK+aZ8OrPaY+VPqQAMbWh+G4KTTbsXbUlTW0joZbHbm/12DI99A4+iTWeFdY HOjQArR+hC1uLxQ2JDLdeaOqEJl5R0F0sJNSLYNYMhbJaOwDtw3/VGcQa6GHsBexkNPP ARXlKRj9YNfsWDLlGZ2no3mHXB2iOrq9BsgJAHDLBS+B01DYJMDdQBsBMfmLwm4C7j/a iJWVZeE3PPCVdWruIgjkpr2ppO0/nJs0fA0AIR+d3nBZjP9pDgt+0p29y3DZc6IpOMIl QkpFl/FkEafx+9unW0T3mLyY13jze2HSlLIKh/YEjW7NcRb979sqDvF398mywZBg9T+i d3nQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=M0j7hOzD; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d185si13463501ywe.27.2019.03.01.12.10.43 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Mar 2019 12:10:43 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=M0j7hOzD; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:43486 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzoUV-0002Ap-AU for patch@linaro.org; Fri, 01 Mar 2019 15:10:43 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44719) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzoPd-0004kO-JL for qemu-devel@nongnu.org; Fri, 01 Mar 2019 15:05:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gzoPM-0001rz-H6 for qemu-devel@nongnu.org; Fri, 01 Mar 2019 15:05:29 -0500 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]:45111) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gzoPJ-0001lJ-RT for qemu-devel@nongnu.org; Fri, 01 Mar 2019 15:05:23 -0500 Received: by mail-pg1-x52a.google.com with SMTP id y4so11905105pgc.12 for ; Fri, 01 Mar 2019 12:05:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tUyLPFYqwpjAIVN/Lq+PNWoyDi0ukBwdF+if0JEltxc=; b=M0j7hOzDI/Fi8wWVeYBBJgnfFzTuxhPgVNo8jCiFMfnl6sIPovfBCGz82abnluic1x 1zkX3HZhjxQ770OcHWifaeuAD5CVOjxAVhg/gAskNZeRPKW8Xq5SgdvqOANOmRK+MN8n eE5Ahkj9Yf8IDwDlQATNG7sZpDzsxGfYoxHHlPz8xkDexBwVX4Wowl3slqwIPgWhIUyt ihRAmfHJ5PnBpROO8tiS9bqDinWqINVS7JoWP5D/eRQvEC07W2RrPK4AiKHaUsYT79PQ LfDRAuwwKOuykHZ5Mp/dL2RRF4ESpcSTEJz9NnIIC5RZllX8zVswk15cXPaxYXBO/aui 9ojg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=tUyLPFYqwpjAIVN/Lq+PNWoyDi0ukBwdF+if0JEltxc=; b=fBQFZcVXcuXWIW4XgAuhrObF0n7ceSvGoeFiBg4JWZn2cFuHAhm4iXwXqzdVkLKJPL B+swLKtMSqVTNVeMTBR+QVrxsWOHI2sTuoLk3dOy8NnyVglgFf+d7UbFaH8XbFaBxmfQ j8AUKxxFnuHW267ONQDyxzuDUz2dQTk25Jy/dI62Pg247qtfXB0M3M6sAeav7OwwAVLN ECaVTgjzvwRR2MRE7Sn6lYCE78WclxWqfmh05ZMHHfY3h5GSlJV8w7FpSJDOTPTQoqNd RGQuJYvTgF0pXYeFqC5Op3//RS/qed5h7Kx2ubRYzUrpTSZiH+qDunSeir+EGgYfM7vn f2dQ== X-Gm-Message-State: APjAAAWKgL3HwOLA5A63LAYCE5ejQdBuZBzTwx4WojjLdQ0nrQUFZk7r YuLd1E4yxzkumbWpT8KNjNkjXkjCGB0= X-Received: by 2002:a65:520a:: with SMTP id o10mr6736883pgp.276.1551470718125; Fri, 01 Mar 2019 12:05:18 -0800 (PST) Received: from cloudburst.twiddle.net (cpe-72-132-238-51.dc.res.rr.com. [72.132.238.51]) by smtp.gmail.com with ESMTPSA id x8sm31869206pfn.137.2019.03.01.12.05.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Mar 2019 12:05:17 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Mar 2019 12:05:00 -0800 Message-Id: <20190301200501.16533-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190301200501.16533-1-richard.henderson@linaro.org> References: <20190301200501.16533-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::52a Subject: [Qemu-devel] [PATCH v3 09/10] target/arm: Restructure handle_fp_1src_{single, double} 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 Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This will allow sharing code that adjusts rmode beyond the existing users. Tested-by: Laurent Desnogues Signed-off-by: Richard Henderson --- target/arm/translate-a64.c | 90 +++++++++++++++++++++----------------- 1 file changed, 49 insertions(+), 41 deletions(-) -- 2.17.2 diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index c2b9e800c8..94184ea5af 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -5686,55 +5686,59 @@ static void handle_fp_1src_half(DisasContext *s, int opcode, int rd, int rn) /* Floating-point data-processing (1 source) - single precision */ static void handle_fp_1src_single(DisasContext *s, int opcode, int rd, int rn) { + void (*gen_fpst)(TCGv_i32, TCGv_i32, TCGv_ptr); + TCGv_i32 tcg_op, tcg_res; TCGv_ptr fpst; - TCGv_i32 tcg_op; - TCGv_i32 tcg_res; + int rmode = -1; - fpst = get_fpstatus_ptr(false); tcg_op = read_fp_sreg(s, rn); tcg_res = tcg_temp_new_i32(); switch (opcode) { case 0x0: /* FMOV */ tcg_gen_mov_i32(tcg_res, tcg_op); - break; + goto done; case 0x1: /* FABS */ gen_helper_vfp_abss(tcg_res, tcg_op); - break; + goto done; case 0x2: /* FNEG */ gen_helper_vfp_negs(tcg_res, tcg_op); - break; + goto done; case 0x3: /* FSQRT */ gen_helper_vfp_sqrts(tcg_res, tcg_op, cpu_env); - break; + goto done; case 0x8: /* FRINTN */ case 0x9: /* FRINTP */ case 0xa: /* FRINTM */ case 0xb: /* FRINTZ */ case 0xc: /* FRINTA */ - { - TCGv_i32 tcg_rmode = tcg_const_i32(arm_rmode_to_sf(opcode & 7)); - - gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); - gen_helper_rints(tcg_res, tcg_op, fpst); - - gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); - tcg_temp_free_i32(tcg_rmode); + rmode = arm_rmode_to_sf(opcode & 7); + gen_fpst = gen_helper_rints; break; - } case 0xe: /* FRINTX */ - gen_helper_rints_exact(tcg_res, tcg_op, fpst); + gen_fpst = gen_helper_rints_exact; break; case 0xf: /* FRINTI */ - gen_helper_rints(tcg_res, tcg_op, fpst); + gen_fpst = gen_helper_rints; break; default: - abort(); + g_assert_not_reached(); } - write_fp_sreg(s, rd, tcg_res); - + fpst = get_fpstatus_ptr(false); + if (rmode >= 0) { + TCGv_i32 tcg_rmode = tcg_const_i32(rmode); + gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); + gen_fpst(tcg_res, tcg_op, fpst); + gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); + tcg_temp_free_i32(tcg_rmode); + } else { + gen_fpst(tcg_res, tcg_op, fpst); + } tcg_temp_free_ptr(fpst); + + done: + write_fp_sreg(s, rd, tcg_res); tcg_temp_free_i32(tcg_op); tcg_temp_free_i32(tcg_res); } @@ -5742,9 +5746,10 @@ static void handle_fp_1src_single(DisasContext *s, int opcode, int rd, int rn) /* Floating-point data-processing (1 source) - double precision */ static void handle_fp_1src_double(DisasContext *s, int opcode, int rd, int rn) { + void (*gen_fpst)(TCGv_i64, TCGv_i64, TCGv_ptr); + TCGv_i64 tcg_op, tcg_res; TCGv_ptr fpst; - TCGv_i64 tcg_op; - TCGv_i64 tcg_res; + int rmode = -1; switch (opcode) { case 0x0: /* FMOV */ @@ -5752,48 +5757,51 @@ static void handle_fp_1src_double(DisasContext *s, int opcode, int rd, int rn) return; } - fpst = get_fpstatus_ptr(false); tcg_op = read_fp_dreg(s, rn); tcg_res = tcg_temp_new_i64(); switch (opcode) { case 0x1: /* FABS */ gen_helper_vfp_absd(tcg_res, tcg_op); - break; + goto done; case 0x2: /* FNEG */ gen_helper_vfp_negd(tcg_res, tcg_op); - break; + goto done; case 0x3: /* FSQRT */ gen_helper_vfp_sqrtd(tcg_res, tcg_op, cpu_env); - break; + goto done; case 0x8: /* FRINTN */ case 0x9: /* FRINTP */ case 0xa: /* FRINTM */ case 0xb: /* FRINTZ */ case 0xc: /* FRINTA */ - { - TCGv_i32 tcg_rmode = tcg_const_i32(arm_rmode_to_sf(opcode & 7)); - - gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); - gen_helper_rintd(tcg_res, tcg_op, fpst); - - gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); - tcg_temp_free_i32(tcg_rmode); + rmode = arm_rmode_to_sf(opcode & 7); + gen_fpst = gen_helper_rintd; break; - } case 0xe: /* FRINTX */ - gen_helper_rintd_exact(tcg_res, tcg_op, fpst); + gen_fpst = gen_helper_rintd_exact; break; case 0xf: /* FRINTI */ - gen_helper_rintd(tcg_res, tcg_op, fpst); + gen_fpst = gen_helper_rintd; break; default: - abort(); + g_assert_not_reached(); } - write_fp_dreg(s, rd, tcg_res); - + fpst = get_fpstatus_ptr(false); + if (rmode >= 0) { + TCGv_i32 tcg_rmode = tcg_const_i32(rmode); + gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); + gen_fpst(tcg_res, tcg_op, fpst); + gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); + tcg_temp_free_i32(tcg_rmode); + } else { + gen_fpst(tcg_res, tcg_op, fpst); + } tcg_temp_free_ptr(fpst); + + done: + write_fp_dreg(s, rd, tcg_res); tcg_temp_free_i64(tcg_op); tcg_temp_free_i64(tcg_res); }