From patchwork Wed Aug 12 22:30:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 247646 Delivered-To: patch@linaro.org Received: by 2002:a92:cc90:0:0:0:0:0 with SMTP id x16csp770975ilo; Wed, 12 Aug 2020 15:43:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhgCwce59pG3CGLpTzUNN4P85uFA0OWi5I3DgNn5EFTDZ1hSHSO39QrQkFbN7gm2fcZ7Uw X-Received: by 2002:a25:3803:: with SMTP id f3mr2450526yba.470.1597272231011; Wed, 12 Aug 2020 15:43:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597272231; cv=none; d=google.com; s=arc-20160816; b=tcRXpZHQ2VghHLvAIgi8DpQ7rq+s4wU94TojeD148mc4vPcnHCzNCtksvAhjhm6Pe3 ZRLsuUKvjj/TS+DURS+4cSlaFHS0nv+rorG88xitmJXBCRH8E4NLl2fw20USyYlOMzh4 i7nVQmslots7C5N3kN91gfjDpON/6XHhv/eucaFyEvcyZl0EkYl9Yh7jO3JxCU0sAXu4 qJybif49lMFRiBDBayP1N4TmmvgnWEdvC1lfS6yQTUq3texUxU78mW/VbeEe1oO4vkVr 4E0Y1qlxaZepgjWJoRvcmXk5xh5T9ZlpPDOOO61Tuh+rHPXf0UODPZQiJLL4tcWl4A4q Xmiw== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :wdcironportexception:ironport-sdr:ironport-sdr:ironport-sdr :dkim-signature; bh=WT6MO139MOesnh4+0DZYz+ad9KpIDjBNkI2OJGxR868=; b=rNv1Mw0TQxpdRHJi5Q2pTPUWgasQlt8wqtPs41KZj8r4ONBWqDeCnItXJaBHHzmSJp ILO0EqTLL4mC+T4BW/ZKR7Rby03ErZ5tZbf4Y823vkphC2xmtks+P8doZeR/MqjI7Uvi wssxIkxbRJkNFH+NMSa7oWCpNa7f7ZCD8AM1c2n6zlAjgJ2Iro+iq5hdVCediHqshvfj 6QhT9sbf5HjyFG50FISLZjKPSuCEPxdTIzY8qPUheURMu3B5E5CZ96fskXJrlAQ0K69t 6lmvSft6MVX0bJQLiAz86gz9DQp119ASU7U+VeNxwALMJ1Ph//rzb1u+iJgBYBV6qTmK atlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=mBBJ90Mr; 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=wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id n188si3526672yba.312.2020.08.12.15.43.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 12 Aug 2020 15:43:51 -0700 (PDT) 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=@wdc.com header.s=dkim.wdc.com header.b=mBBJ90Mr; 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=wdc.com Received: from localhost ([::1]:39890 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k5zTK-0005eg-EI for patch@linaro.org; Wed, 12 Aug 2020 18:43:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39446) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5zQT-0002G6-JO for qemu-devel@nongnu.org; Wed, 12 Aug 2020 18:40:53 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:56479) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5zQQ-0005mK-0t for qemu-devel@nongnu.org; Wed, 12 Aug 2020 18:40:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1597272050; x=1628808050; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/sYwq4jJBFVrhAN6HvnU9aC89Zg8os3gcPnGisptQJw=; b=mBBJ90MrBvWyJ3f2lWXUrNwNIuRPzWKJsEYRo9RTjSmG61YnDRna39F+ wzg+GC6t8oq6PENPuR8bwztWaI4RZPmQHJrm9qJR6I4UA6qWppoFvBZK8 XKSxKCo12umpwnffjhsbn5MzuMzUFygJoEkG9rXDMyS/9RZuUoVWkfN96 hb4sFRbjMrSgmLS3PRyQBUHxB4RUz5XQMvr03VHOUEuHQ3kgjAryfMb8z BpsrZd/shFavGHBB32fmLrl0x7Off/ieuvWSzEWtvWgF+aLKBatFr5PZ6 1P/hy/b1AX3nTW8eKkWo5UWD92klnLiLHLf2TKVuisthrG3h7N0EXTMDl g==; IronPort-SDR: UwQhcaXd3NKmw789Tf4mrCYZ0rFJ6tgYptaBcsBQQ1k089antaB/RjbCRAxaKPnvAB0FsD2zoZ Kanzgg0Hnp3FIPhZQGqh/ZbharDWEYXLQK18QOmry4HBcB+73oPQ/ML/cmjYx+NMqM6t7rl6V6 PCsZmBAe9Tb9vgUwxZ1DJJAqECt76n1xi8dnrOwjYlwhXBaKuyY08hMfLisGxnBZ2St2RvOVxM q/r+R+P0UCcsJEWihga2zuyioz1LR+s0/Zzdfjy6I7gOAC2k3sQLdxmKsrHlkTZ67jDM36rI+E xGI= X-IronPort-AV: E=Sophos;i="5.76,305,1592841600"; d="scan'208";a="144853390" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 13 Aug 2020 06:40:47 +0800 IronPort-SDR: JkJzWU0ElCHVdrhoc7w/6sEo/CuOOIUI0jaENcKDZvCJGRj17G2NmF2fP5K1CFSeqgeR99ktXw AQ/baa3UIN1Q== Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Aug 2020 15:28:38 -0700 IronPort-SDR: 8SiIO+Ee6UoeuDOlGgCjljMtx3khNKQfqen4eCpPre+4tSo/1U+u81Fx45dr48fMdBUMlkVcoV nvDVYY/OcAAw== WDCIronportException: Internal Received: from jbfyk72.ad.shared (HELO risc6-mainframe.hgst.com) ([10.86.59.14]) by uls-op-cesaip01.wdc.com with ESMTP; 12 Aug 2020 15:40:44 -0700 From: Alistair Francis To: qemu-devel@nongnu.org Subject: [PULL 01/20] target/riscv: Generate nanboxed results from fp helpers Date: Wed, 12 Aug 2020 15:30:26 -0700 Message-Id: <20200812223045.96803-2-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200812223045.96803-1-alistair.francis@wdc.com> References: <20200812223045.96803-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=486123ee4=alistair.francis@wdc.com; helo=esa5.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/12 18:40:47 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alistair Francis , Richard Henderson , LIU Zhiwei Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Make sure that all results from single-precision scalar helpers are properly nan-boxed to 64-bits. Signed-off-by: Richard Henderson Reviewed-by: LIU Zhiwei Message-Id: <20200724002807.441147-2-richard.henderson@linaro.org> Signed-off-by: Alistair Francis --- target/riscv/internals.h | 5 +++++ target/riscv/fpu_helper.c | 42 +++++++++++++++++++++------------------ 2 files changed, 28 insertions(+), 19 deletions(-) -- 2.27.0 diff --git a/target/riscv/internals.h b/target/riscv/internals.h index 37d33820ad..9f4ba7d617 100644 --- a/target/riscv/internals.h +++ b/target/riscv/internals.h @@ -38,4 +38,9 @@ target_ulong fclass_d(uint64_t frs1); #define SEW32 2 #define SEW64 3 +static inline uint64_t nanbox_s(float32 f) +{ + return f | MAKE_64BIT_MASK(32, 32); +} + #endif diff --git a/target/riscv/fpu_helper.c b/target/riscv/fpu_helper.c index 4379756dc4..72541958a7 100644 --- a/target/riscv/fpu_helper.c +++ b/target/riscv/fpu_helper.c @@ -81,10 +81,16 @@ void helper_set_rounding_mode(CPURISCVState *env, uint32_t rm) set_float_rounding_mode(softrm, &env->fp_status); } +static uint64_t do_fmadd_s(CPURISCVState *env, uint64_t frs1, uint64_t frs2, + uint64_t frs3, int flags) +{ + return nanbox_s(float32_muladd(frs1, frs2, frs3, flags, &env->fp_status)); +} + uint64_t helper_fmadd_s(CPURISCVState *env, uint64_t frs1, uint64_t frs2, uint64_t frs3) { - return float32_muladd(frs1, frs2, frs3, 0, &env->fp_status); + return do_fmadd_s(env, frs1, frs2, frs3, 0); } uint64_t helper_fmadd_d(CPURISCVState *env, uint64_t frs1, uint64_t frs2, @@ -96,8 +102,7 @@ uint64_t helper_fmadd_d(CPURISCVState *env, uint64_t frs1, uint64_t frs2, uint64_t helper_fmsub_s(CPURISCVState *env, uint64_t frs1, uint64_t frs2, uint64_t frs3) { - return float32_muladd(frs1, frs2, frs3, float_muladd_negate_c, - &env->fp_status); + return do_fmadd_s(env, frs1, frs2, frs3, float_muladd_negate_c); } uint64_t helper_fmsub_d(CPURISCVState *env, uint64_t frs1, uint64_t frs2, @@ -110,8 +115,7 @@ uint64_t helper_fmsub_d(CPURISCVState *env, uint64_t frs1, uint64_t frs2, uint64_t helper_fnmsub_s(CPURISCVState *env, uint64_t frs1, uint64_t frs2, uint64_t frs3) { - return float32_muladd(frs1, frs2, frs3, float_muladd_negate_product, - &env->fp_status); + return do_fmadd_s(env, frs1, frs2, frs3, float_muladd_negate_product); } uint64_t helper_fnmsub_d(CPURISCVState *env, uint64_t frs1, uint64_t frs2, @@ -124,8 +128,8 @@ uint64_t helper_fnmsub_d(CPURISCVState *env, uint64_t frs1, uint64_t frs2, uint64_t helper_fnmadd_s(CPURISCVState *env, uint64_t frs1, uint64_t frs2, uint64_t frs3) { - return float32_muladd(frs1, frs2, frs3, float_muladd_negate_c | - float_muladd_negate_product, &env->fp_status); + return do_fmadd_s(env, frs1, frs2, frs3, + float_muladd_negate_c | float_muladd_negate_product); } uint64_t helper_fnmadd_d(CPURISCVState *env, uint64_t frs1, uint64_t frs2, @@ -137,37 +141,37 @@ uint64_t helper_fnmadd_d(CPURISCVState *env, uint64_t frs1, uint64_t frs2, uint64_t helper_fadd_s(CPURISCVState *env, uint64_t frs1, uint64_t frs2) { - return float32_add(frs1, frs2, &env->fp_status); + return nanbox_s(float32_add(frs1, frs2, &env->fp_status)); } uint64_t helper_fsub_s(CPURISCVState *env, uint64_t frs1, uint64_t frs2) { - return float32_sub(frs1, frs2, &env->fp_status); + return nanbox_s(float32_sub(frs1, frs2, &env->fp_status)); } uint64_t helper_fmul_s(CPURISCVState *env, uint64_t frs1, uint64_t frs2) { - return float32_mul(frs1, frs2, &env->fp_status); + return nanbox_s(float32_mul(frs1, frs2, &env->fp_status)); } uint64_t helper_fdiv_s(CPURISCVState *env, uint64_t frs1, uint64_t frs2) { - return float32_div(frs1, frs2, &env->fp_status); + return nanbox_s(float32_div(frs1, frs2, &env->fp_status)); } uint64_t helper_fmin_s(CPURISCVState *env, uint64_t frs1, uint64_t frs2) { - return float32_minnum(frs1, frs2, &env->fp_status); + return nanbox_s(float32_minnum(frs1, frs2, &env->fp_status)); } uint64_t helper_fmax_s(CPURISCVState *env, uint64_t frs1, uint64_t frs2) { - return float32_maxnum(frs1, frs2, &env->fp_status); + return nanbox_s(float32_maxnum(frs1, frs2, &env->fp_status)); } uint64_t helper_fsqrt_s(CPURISCVState *env, uint64_t frs1) { - return float32_sqrt(frs1, &env->fp_status); + return nanbox_s(float32_sqrt(frs1, &env->fp_status)); } target_ulong helper_fle_s(CPURISCVState *env, uint64_t frs1, uint64_t frs2) @@ -209,23 +213,23 @@ uint64_t helper_fcvt_lu_s(CPURISCVState *env, uint64_t frs1) uint64_t helper_fcvt_s_w(CPURISCVState *env, target_ulong rs1) { - return int32_to_float32((int32_t)rs1, &env->fp_status); + return nanbox_s(int32_to_float32((int32_t)rs1, &env->fp_status)); } uint64_t helper_fcvt_s_wu(CPURISCVState *env, target_ulong rs1) { - return uint32_to_float32((uint32_t)rs1, &env->fp_status); + return nanbox_s(uint32_to_float32((uint32_t)rs1, &env->fp_status)); } #if defined(TARGET_RISCV64) uint64_t helper_fcvt_s_l(CPURISCVState *env, uint64_t rs1) { - return int64_to_float32(rs1, &env->fp_status); + return nanbox_s(int64_to_float32(rs1, &env->fp_status)); } uint64_t helper_fcvt_s_lu(CPURISCVState *env, uint64_t rs1) { - return uint64_to_float32(rs1, &env->fp_status); + return nanbox_s(uint64_to_float32(rs1, &env->fp_status)); } #endif @@ -266,7 +270,7 @@ uint64_t helper_fmax_d(CPURISCVState *env, uint64_t frs1, uint64_t frs2) uint64_t helper_fcvt_s_d(CPURISCVState *env, uint64_t rs1) { - return float64_to_float32(rs1, &env->fp_status); + return nanbox_s(float64_to_float32(rs1, &env->fp_status)); } uint64_t helper_fcvt_d_s(CPURISCVState *env, uint64_t rs1)