From nobody Fri May 10 13:34:13 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1595550584; cv=none; d=zohomail.com; s=zohoarc; b=eCu6nM6y6YViry45S3FPqXpUjEMT5y0kTOVTCRe2Z2b5tXpf8wVOisYuCsrTObS5LPQbw2dlWux8KkYS4kEogxe0aFh8qxbK+O4rxMMAOZVSUWumoxAPn1deDhgPcZLT5ItTU+PaBoomlPTD7UQEWJ7++4Q962h+lixI1KWOY10= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595550584; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Sujhg6CWtGD0cTKixZpHYTp8eVUCvTssOp7pcX2qTrI=; b=EqIEOVGoL2LZmEo+hwmJnJaxQ+/8Gqt+WpsJG6YRVI9BiHfqn+8tlVOplIvJ/680HdzH3jmUxNz9IKjyvNGiZRjY5xmmkDX7olKTcMy3rz1mmk/y7M/lDzHhDAvkIpWKY2yqXzEQBzjgFKfjtSOKuk6L3ObX8sHynIrMx+Ekcg4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1595550584516614.7040476508998; Thu, 23 Jul 2020 17:29:44 -0700 (PDT) Received: from localhost ([::1]:51200 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jylap-0001hJ-BX for importer@patchew.org; Thu, 23 Jul 2020 20:29:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54324) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jylZP-00009y-5E for qemu-devel@nongnu.org; Thu, 23 Jul 2020 20:28:15 -0400 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]:54950) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jylZM-0008EL-0U for qemu-devel@nongnu.org; Thu, 23 Jul 2020 20:28:14 -0400 Received: by mail-pj1-x102c.google.com with SMTP id mn17so4186522pjb.4 for ; Thu, 23 Jul 2020 17:28:11 -0700 (PDT) Received: from localhost.localdomain (216-160-65-90.tukw.qwest.net. [216.160.65.90]) by smtp.gmail.com with ESMTPSA id q20sm4224635pfn.111.2020.07.23.17.28.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2020 17:28:09 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=Sujhg6CWtGD0cTKixZpHYTp8eVUCvTssOp7pcX2qTrI=; b=YkqmLXlsxvplRqaok+VAYFaN+60GrEEVw+VRXsOcWmtUC8TNIS1aBSMveiA7vU0uUY DjQzlaRYDFazEHFj5e8Qzm2kv6UqoZrCzZGFVxeOEWGNQsB9icnHYmSZ9NfvB1ba0q7N DtCIHVwcZIa65Kg5SLVwGlGheLrFLeaHodesZXG5ppKt2cGtSoNHhht3S2xlwH5gX49j HYkdia3Pr0Gqm5gSRQXVkLaSUvwH6VeZl7n1Bodh5CLnJr6c2iRUQodN+3NKrrUVsarY PTRNuHO1blHv/ATEx+8G9QxpjA0taenmEj7znN5VVfIztIegu8VnARH2cvUCtSLx8kGZ GViw== 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:mime-version:content-transfer-encoding; bh=Sujhg6CWtGD0cTKixZpHYTp8eVUCvTssOp7pcX2qTrI=; b=UT+XsbqMs/9Nz6EG8lE/QLABnWdo0t0zjt9MfqKx76fTjm8yFtwoD3IjGsRZW5Zvak +ZmStAgARqj2zyspuoSGjoXgCTyLUfvhUyzIgWu5+bvpDa178I8WWcCwW5eQHQSfYJPr ihjObeH77u7k/7T5CtK3wIeDmKNddEjxeb6V9FzvRni1rdsU0jko9fsGK2jHsA36u2kq Pe6jGoiTh2iKfXVeq5EzSQ4PaJ7vPO7n/ScJROLEtPAZ6txC8tJqL97ZAjS1NUxYPcOd a7PY46xlYE6MGPHN/MV1otrYMJ/5QVPQSial+40vICVHq0jR9cqJOuRS1elj/bhwFcqi jLVQ== X-Gm-Message-State: AOAM531q2o8MeMg9scQx0fKYYPvb4wgcNbZ+iaFGKKqdiwU2Tt0KRV7w U3T1gLNPvvj4+uNeCBBkzUkGHrxP9zI= X-Google-Smtp-Source: ABdhPJzWg/t15KWfWrUgHe8cEmsVqTbxk7u7i5cF5iplcBKskoAMx72FZyU+LPXoW9WOb5jyoJDmNw== X-Received: by 2002:a17:90a:71c4:: with SMTP id m4mr2934335pjs.178.1595550490256; Thu, 23 Jul 2020 17:28:10 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 1/7] target/riscv: Generate nanboxed results from fp helpers Date: Thu, 23 Jul 2020 17:28:01 -0700 Message-Id: <20200724002807.441147-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200724002807.441147-1-richard.henderson@linaro.org> References: <20200724002807.441147-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::102c; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102c.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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: frank.chang@sifive.com, alistair23@gmail.com, qemu-riscv@nongnu.org, zhiwei_liu@c-sky.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Make sure that all results from single-precision scalar helpers are properly nan-boxed to 64-bits. Signed-off-by: Richard Henderson Reviewed-by: Chih-Min Chao Reviewed-by: LIU Zhiwei --- target/riscv/internals.h | 5 +++++ target/riscv/fpu_helper.c | 42 +++++++++++++++++++++------------------ 2 files changed, 28 insertions(+), 19 deletions(-) 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 =20 +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, uint3= 2_t rm) set_float_rounding_mode(softrm, &env->fp_status); } =20 +static uint64_t do_fmadd_s(CPURISCVState *env, uint64_t frs1, uint64_t frs= 2, + uint64_t frs3, int flags) +{ + return nanbox_s(float32_muladd(frs1, frs2, frs3, flags, &env->fp_statu= s)); +} + 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); } =20 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 frs= 1, 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); } =20 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 fr= s1, 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); } =20 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 f= rs1, 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); } =20 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, =20 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)); } =20 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)); } =20 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)); } =20 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)); } =20 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)); } =20 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)); } =20 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)); } =20 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) =20 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)); } =20 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)); } =20 #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)); } =20 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 =20 @@ -266,7 +270,7 @@ uint64_t helper_fmax_d(CPURISCVState *env, uint64_t frs= 1, uint64_t frs2) =20 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)); } =20 uint64_t helper_fcvt_d_s(CPURISCVState *env, uint64_t rs1) --=20 2.25.1 From nobody Fri May 10 13:34:13 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1595550718; cv=none; d=zohomail.com; s=zohoarc; b=YApvojdqSWxzrvjEA2qOJrUJnnDD/jZfBAvG5ydLB5vd8293ApsebHBILXkS5GPX+Rm4R27+AqHXuTT2Zw/DFiT1l6A8LOesMCtvZhkGPDj01ozqB6iuInPJZexyKmqRte7UJK5SqyXUf+Mgmk87/jX19HIWyjpEAmq7V164RGU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595550718; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=82BoFk+pEx0CdeF7uaEVVUl7SfuHCvWy8t85i9SZsTQ=; b=Z9pMsld+1ADSu2Gtdw9BBfg99JqUcm+GZL+RwNLEUKJFL3xogyPLgAH5nK7ixhaDLTjKGOsF4G4kTurcAYXALj7teAMpLt8Uvvj+O9/e4G5o37Zv4CN7OMxY9su9QvGt9pOvLyb6cyxkQgoQXRDQmI510juMQcCDxJEKWgs5hPU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1595550718495694.2419888770974; Thu, 23 Jul 2020 17:31:58 -0700 (PDT) Received: from localhost ([::1]:56816 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jylcz-00047P-3U for importer@patchew.org; Thu, 23 Jul 2020 20:31:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54340) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jylZP-0000At-SG for qemu-devel@nongnu.org; Thu, 23 Jul 2020 20:28:15 -0400 Received: from mail-pj1-x1044.google.com ([2607:f8b0:4864:20::1044]:38926) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jylZN-0008EZ-I0 for qemu-devel@nongnu.org; Thu, 23 Jul 2020 20:28:15 -0400 Received: by mail-pj1-x1044.google.com with SMTP id b92so4130208pjc.4 for ; Thu, 23 Jul 2020 17:28:13 -0700 (PDT) Received: from localhost.localdomain (216-160-65-90.tukw.qwest.net. [216.160.65.90]) by smtp.gmail.com with ESMTPSA id q20sm4224635pfn.111.2020.07.23.17.28.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2020 17:28:11 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=82BoFk+pEx0CdeF7uaEVVUl7SfuHCvWy8t85i9SZsTQ=; b=Fn8IZXpAc7MCaiuiZ25JlQA2LabEcam/2/IMXdJ1O4uKpkwnUqRnzzCDzancnQTF5A teIzdq/yAZu1fRlcYa60F7K94ld7EZ2wAkXCBQ8P5aFyQZg3MAEBSKVZoJRo1KUkdfVK UqCpis03sVLQgTpoQmDTkqT5URfXQL/E+lHHdNBaJWzeYtXIGUKT63RTZCaUnI83Tjhn 0L8sOS1LM9sZd1cL3G4wjQq5C1ti5qX4vBIKkYbGZlu640cKpfiltb7l4yJCSspNmgPM 1RaFlM0Wz0aCUZ9q4OSENlaP4lxCBvfslKKcJ0LbcpQC9QYkMo1J1Z7kVVboWg12+JX2 gn7g== 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:mime-version:content-transfer-encoding; bh=82BoFk+pEx0CdeF7uaEVVUl7SfuHCvWy8t85i9SZsTQ=; b=VFFgVgxphbtOYFeu9AE/eAcweygVAt/XikeCAD95WOwTqFsXpmT/CalFideg0IcOVz LijupAmLUhrvLu5HaZCQ2x4FOLR96wR+jNl6P7OLT88j87o99DS4ScKNUL+rUaR+XcY5 yWYNOUbg5cYjSOf9b2CDkq41+Tt7dY2K+/e/CGQgn9KDfEaT6rf6bLFPRSg0rzSV6w5V dR3dmzxODZQ0uY/cjW40C/8a3T+h9UwwkXz1kUpznHoKax6AxVxYHDgH49S2qYYp5t0Y 7C6aswomuETPDrPzmkxWA6J2e2S+9JlLsDsJfYP7FAZIdFfVffDpznW51jbB51eYvz8S 2RMQ== X-Gm-Message-State: AOAM531YWgFtozyCL0/iV1qW3uwH91NJFkaLcUY0YgraPVvTYlewBj9t XKQVjr4yObtiDEkoQoaz94v9Dqb/Atk= X-Google-Smtp-Source: ABdhPJxB/kyIx0JQ3A1RWxiiWUx45JeZQ0oeQnQRBpYlj4sr6vwC3gFYkPU4oCiLT9TizJgBvzVB3A== X-Received: by 2002:a17:90a:2367:: with SMTP id f94mr2932434pje.20.1595550491869; Thu, 23 Jul 2020 17:28:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 2/7] target/riscv: Generalize gen_nanbox_fpr to gen_nanbox_s Date: Thu, 23 Jul 2020 17:28:02 -0700 Message-Id: <20200724002807.441147-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200724002807.441147-1-richard.henderson@linaro.org> References: <20200724002807.441147-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1044; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1044.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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: frank.chang@sifive.com, alistair23@gmail.com, qemu-riscv@nongnu.org, zhiwei_liu@c-sky.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Do not depend on the RVD extension, take input and output via TCGv_i64 instead of fpu regno. Move the function to translate.c so that it can be used in multiple trans_*.inc.c files. Signed-off-by: Richard Henderson Reviewed-by: Chih-Min Chao Reviewed-by: LIU Zhiwei --- target/riscv/insn_trans/trans_rvf.inc.c | 16 +--------------- target/riscv/translate.c | 11 +++++++++++ 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/target/riscv/insn_trans/trans_rvf.inc.c b/target/riscv/insn_tr= ans/trans_rvf.inc.c index 3bfd8881e7..c7057482e8 100644 --- a/target/riscv/insn_trans/trans_rvf.inc.c +++ b/target/riscv/insn_trans/trans_rvf.inc.c @@ -23,20 +23,6 @@ return false; \ } while (0) =20 -/* - * RISC-V requires NaN-boxing of narrower width floating - * point values. This applies when a 32-bit value is - * assigned to a 64-bit FP register. Thus this does not - * apply when the RVD extension is not present. - */ -static void gen_nanbox_fpr(DisasContext *ctx, int regno) -{ - if (has_ext(ctx, RVD)) { - tcg_gen_ori_i64(cpu_fpr[regno], cpu_fpr[regno], - MAKE_64BIT_MASK(32, 32)); - } -} - static bool trans_flw(DisasContext *ctx, arg_flw *a) { TCGv t0 =3D tcg_temp_new(); @@ -46,7 +32,7 @@ static bool trans_flw(DisasContext *ctx, arg_flw *a) tcg_gen_addi_tl(t0, t0, a->imm); =20 tcg_gen_qemu_ld_i64(cpu_fpr[a->rd], t0, ctx->mem_idx, MO_TEUL); - gen_nanbox_fpr(ctx, a->rd); + gen_nanbox_s(cpu_fpr[a->rd], cpu_fpr[a->rd]); =20 tcg_temp_free(t0); mark_fs_dirty(ctx); diff --git a/target/riscv/translate.c b/target/riscv/translate.c index 9632e79cf3..12a746da97 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -90,6 +90,17 @@ static inline bool has_ext(DisasContext *ctx, uint32_t e= xt) return ctx->misa & ext; } =20 +/* + * RISC-V requires NaN-boxing of narrower width floating point values. + * This applies when a 32-bit value is assigned to a 64-bit FP register. + * For consistency and simplicity, we nanbox results even when the RVD + * extension is not present. + */ +static void gen_nanbox_s(TCGv_i64 out, TCGv_i64 in) +{ + tcg_gen_ori_i64(out, in, MAKE_64BIT_MASK(32, 32)); +} + static void generate_exception(DisasContext *ctx, int excp) { tcg_gen_movi_tl(cpu_pc, ctx->base.pc_next); --=20 2.25.1 From nobody Fri May 10 13:34:13 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1595550828; cv=none; d=zohomail.com; s=zohoarc; b=ZrUL7am/EpOQHRdwJl5ph+5JvtWza46eczsud01IydlZoPU4wlyu5X6X6zwV0mdHY1txVQ8pLCJb9hAt1Brsr/GIo2fgE/iY0hyAHpNqbVnz6kALSkUldJBWaTn0dNXfrHAqnZh0wFP4xxpl7WPcxhmv+siNrQxYtWRJahY3I4g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595550828; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9BL1gLZ55ebPF1CU6VCPP/FzwVosXUicPzzehG55MPU=; b=Zxxj2Uqygd1gJVtVaIyrmxgtVfL10NT3MeCC++6jxFNLaP34YsYrwaMWUFRY4kSzsnP+p5YjPP9rETelI1Gdc6GUuQSMdR86WVWJcpYaQ3WvmPkSA7KIaU+y7814uYEiHZsLTDNIdVqMi/4r76nBTIvqjAIJXt4WRN2H81QWyaE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1595550828089491.14785446859037; Thu, 23 Jul 2020 17:33:48 -0700 (PDT) Received: from localhost ([::1]:60366 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jylek-0005fF-Rx for importer@patchew.org; Thu, 23 Jul 2020 20:33:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54366) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jylZQ-0000Cy-S5 for qemu-devel@nongnu.org; Thu, 23 Jul 2020 20:28:16 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:45279) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jylZO-0008En-LU for qemu-devel@nongnu.org; Thu, 23 Jul 2020 20:28:16 -0400 Received: by mail-pf1-x444.google.com with SMTP id z3so4050144pfn.12 for ; Thu, 23 Jul 2020 17:28:14 -0700 (PDT) Received: from localhost.localdomain (216-160-65-90.tukw.qwest.net. [216.160.65.90]) by smtp.gmail.com with ESMTPSA id q20sm4224635pfn.111.2020.07.23.17.28.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2020 17:28:12 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=9BL1gLZ55ebPF1CU6VCPP/FzwVosXUicPzzehG55MPU=; b=qaRmjisPRMx6Bj6xIKHQ+UdKBYDsba74xVnhAR/AseeiXethgPO4Ue8+YgGEfrVr2S NX2L6e6SXP4LBkkNUEUt6Cz3f30tlg80W3cNgAwUs+q7QawJj52t1s+cBp10VvFJ0qZI zVOKxeduGUSxDzzRHWZDf9H4grMztliHSmGyLf6OMzmyYJADYwdVk8uXtzdk0oI8sWUr VFemrrl8l/PDHOa8zC5rsMKk5+My0bCXP66BogF923FxdpeySyUCTqLYFUEOeRdm+wqc xS57ZQuSY1nKS/x42WEj4qKW9kXtMIYvaxDJz3OBQuXDcSep7Na7izjkvH4rirQKw9XE peyA== 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:mime-version:content-transfer-encoding; bh=9BL1gLZ55ebPF1CU6VCPP/FzwVosXUicPzzehG55MPU=; b=CWq3wOxzTpvTCe3EY2+wWs9tPmQKlZsDgggFeoW2TqNUSr5cSkP43Ud5L2Yj/Qt4JP DI+G/jdEr+kBNrAFrY2oOCiivo5ouPkTovpYdGBPRW1KkAgkqSjPoEZvWcmCLM+SZpHS MclKBkgd3pFsB0uDaM53C6ZN5Nk8//J1vqe2oYWaCcWJXALJF9ueGmMDob6CJzXLol3p obEE0l97mK654puR3rMZw6vCun5oNJBO+eNgfyB0efQY6o8gFPP+TZqcKLFLu6ZcPSQn 2nZOWhfcg/3RbSasdeme00rtZspNPJo/2pHj4DVkXIq73sqLBzFJPZsw92r8H6AWqVy5 HrRg== X-Gm-Message-State: AOAM533pHDYBHZL+sNoPX25t2GP5xq/pewfB/skRx/KvnUlGIzxF/YCx hMdfReTAWPxJ2EMZw18Zs+cdWS/8sJ0= X-Google-Smtp-Source: ABdhPJwi8c+oFUbvG8EnpiHUGBnDqiPGHTdg0NBAkioxO4MP0/y98SNPP57NWBkGg78qzE4B7MF3dQ== X-Received: by 2002:a62:8688:: with SMTP id x130mr6546500pfd.280.1595550493032; Thu, 23 Jul 2020 17:28:13 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 3/7] target/riscv: Generate nanboxed results from trans_rvf.inc.c Date: Thu, 23 Jul 2020 17:28:03 -0700 Message-Id: <20200724002807.441147-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200724002807.441147-1-richard.henderson@linaro.org> References: <20200724002807.441147-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::444; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x444.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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: frank.chang@sifive.com, alistair23@gmail.com, qemu-riscv@nongnu.org, zhiwei_liu@c-sky.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Make sure that all results from inline single-precision scalar operations are properly nan-boxed to 64-bits. Signed-off-by: Richard Henderson Reviewed-by: Chih-Min Chao Reviewed-by: LIU Zhiwei --- target/riscv/insn_trans/trans_rvf.inc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/target/riscv/insn_trans/trans_rvf.inc.c b/target/riscv/insn_tr= ans/trans_rvf.inc.c index c7057482e8..264d3139f1 100644 --- a/target/riscv/insn_trans/trans_rvf.inc.c +++ b/target/riscv/insn_trans/trans_rvf.inc.c @@ -167,6 +167,7 @@ static bool trans_fsgnj_s(DisasContext *ctx, arg_fsgnj_= s *a) tcg_gen_deposit_i64(cpu_fpr[a->rd], cpu_fpr[a->rs2], cpu_fpr[a->rs= 1], 0, 31); } + gen_nanbox_s(cpu_fpr[a->rd], cpu_fpr[a->rd]); mark_fs_dirty(ctx); return true; } @@ -183,6 +184,7 @@ static bool trans_fsgnjn_s(DisasContext *ctx, arg_fsgnj= n_s *a) tcg_gen_deposit_i64(cpu_fpr[a->rd], t0, cpu_fpr[a->rs1], 0, 31); tcg_temp_free_i64(t0); } + gen_nanbox_s(cpu_fpr[a->rd], cpu_fpr[a->rd]); mark_fs_dirty(ctx); return true; } @@ -199,6 +201,7 @@ static bool trans_fsgnjx_s(DisasContext *ctx, arg_fsgnj= x_s *a) tcg_gen_xor_i64(cpu_fpr[a->rd], cpu_fpr[a->rs1], t0); tcg_temp_free_i64(t0); } + gen_nanbox_s(cpu_fpr[a->rd], cpu_fpr[a->rd]); mark_fs_dirty(ctx); return true; } @@ -369,6 +372,7 @@ static bool trans_fmv_w_x(DisasContext *ctx, arg_fmv_w_= x *a) #else tcg_gen_extu_i32_i64(cpu_fpr[a->rd], t0); #endif + gen_nanbox_s(cpu_fpr[a->rd], cpu_fpr[a->rd]); =20 mark_fs_dirty(ctx); tcg_temp_free(t0); --=20 2.25.1 From nobody Fri May 10 13:34:13 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1595550596; cv=none; d=zohomail.com; s=zohoarc; b=h/aXkvALhfKxSscRJz/V0OljfYC6f+YUdCW/sHTc5uHW9sf5R6VOODZ0MTf7dp0jTwZ3Ryw/H+m2OkiE5SgHwU/4NlVaWYs5uv4bVIAUSIsCD7Ab3q9wMgYYjnRFUum1oMGhwrSuFoAqbV50x4uTGqmNPFRnyqFcjBLaevxr5mg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595550596; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1utSzpi1MINPmUJjhg3agUHxuOyctwcD9LWDx9rrV3c=; b=LiW4jIrGxHDcjlt2A4IVuePJIuSSw4wbgs4xeNYL/p90k/uW25cmZogRlSQU7ZL2ZIHtVs4l627643Zv3BGsm0ALaLJW+FEDbRR4XAy3gybMA9tdWhsE068MdeH7JXFWt+malaW+8OX0Vm3N1TQ2jVI5E1Ze5RXveiuE7M086og= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1595550596978157.46029807860975; Thu, 23 Jul 2020 17:29:56 -0700 (PDT) Received: from localhost ([::1]:51686 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jylaz-0001tD-Od for importer@patchew.org; Thu, 23 Jul 2020 20:29:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54398) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jylZR-0000Eg-Uv for qemu-devel@nongnu.org; Thu, 23 Jul 2020 20:28:17 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:34392) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jylZQ-0008FJ-8M for qemu-devel@nongnu.org; Thu, 23 Jul 2020 20:28:17 -0400 Received: by mail-pf1-x441.google.com with SMTP id u185so4083502pfu.1 for ; Thu, 23 Jul 2020 17:28:15 -0700 (PDT) Received: from localhost.localdomain (216-160-65-90.tukw.qwest.net. [216.160.65.90]) by smtp.gmail.com with ESMTPSA id q20sm4224635pfn.111.2020.07.23.17.28.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2020 17:28:13 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=1utSzpi1MINPmUJjhg3agUHxuOyctwcD9LWDx9rrV3c=; b=BX3os+dBMrPKAVnAg6Hs3+uW5fHDk4sEPnmly9Wm6Vy3UAdxNxYbi/DQUPzxE0VFAe N2AAmSLNZCXoacFEZvUECt4t9ofGTm2TMO9VJPq9Q6Meit7cRM6LAsefIbwcZ1fCmtNc Vf0+y/SCIGkm9d0TzmtlTiNtcAngfGYbc2efADMQD4qMzmc/jBFXXfBTc2KECX7OGNOV kJk0kwhm6WoyYsG2OQZHD/3lCuyh0PkR7oyTXTBxgk5VdaSWVfWA77DzuAbpR0m16Gj5 dU6fHkR2PSAWaNHVdLbFUIWOMWdnwvla3ngU0tduCVvdDTNQL+mEMLiNmII+G7+zyuyj hQqg== 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:mime-version:content-transfer-encoding; bh=1utSzpi1MINPmUJjhg3agUHxuOyctwcD9LWDx9rrV3c=; b=Le5ceZbTl5j+nEezX+Sc5gG8CWbOHDv4Xxo68FOPyK3oL9vv8fpJPffMfk0/AcB2/R 2cFPiQVbUNInbYMgFd4lnaTvvcMrJrN15EBf8z+7aXwkQk4SPWpx76YXIzB/xqmeTA2s WRSUNpycqvN/aHjmal87Ta0JHZIgJsJdATiIMsNFY/7h35LQczBsLNLG8ZoDY6gola4O 4oHwUE/8rMaPOoaACq910rQVzK/vEKCAhqxI0PKFtPh0hnjkFmKuKa1tyNQ+NNM7p7ar FtSeyuqLZDtGgId0XrvcgBfsDYVq0o92+1ep592QOQuON8envHi+zePjC5DyjFpqqfya P1tg== X-Gm-Message-State: AOAM531OKV77J/zo0Ii3SVXWdXmitgsw04iUN4oIRE43P8AU9KHqsbZW KAP8LmHNflbnb32Ih3VuWXPToEe+FS4= X-Google-Smtp-Source: ABdhPJwpyHrRHNjXbT9AG9hrl2LW2N918UjbVD6bp5xBWR0k8zH1Axok4Rry+/JPzd7nh3mTRoQAqA== X-Received: by 2002:a62:7847:: with SMTP id t68mr5716296pfc.112.1595550494530; Thu, 23 Jul 2020 17:28:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 4/7] target/riscv: Check nanboxed inputs to fp helpers Date: Thu, 23 Jul 2020 17:28:04 -0700 Message-Id: <20200724002807.441147-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200724002807.441147-1-richard.henderson@linaro.org> References: <20200724002807.441147-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::441; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x441.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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: frank.chang@sifive.com, alistair23@gmail.com, qemu-riscv@nongnu.org, zhiwei_liu@c-sky.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" If a 32-bit input is not properly nanboxed, then the input is replaced with the default qnan. Signed-off-by: Richard Henderson Reviewed-by: Chih-Min Chao Reviewed-by: LIU Zhiwei --- target/riscv/internals.h | 11 +++++++ target/riscv/fpu_helper.c | 64 ++++++++++++++++++++++++++++----------- 2 files changed, 57 insertions(+), 18 deletions(-) diff --git a/target/riscv/internals.h b/target/riscv/internals.h index 9f4ba7d617..f1a546dba6 100644 --- a/target/riscv/internals.h +++ b/target/riscv/internals.h @@ -43,4 +43,15 @@ static inline uint64_t nanbox_s(float32 f) return f | MAKE_64BIT_MASK(32, 32); } =20 +static inline float32 check_nanbox_s(uint64_t f) +{ + uint64_t mask =3D MAKE_64BIT_MASK(32, 32); + + if (likely((f & mask) =3D=3D mask)) { + return (uint32_t)f; + } else { + return 0x7fc00000u; /* default qnan */ + } +} + #endif diff --git a/target/riscv/fpu_helper.c b/target/riscv/fpu_helper.c index 72541958a7..bb346a8249 100644 --- a/target/riscv/fpu_helper.c +++ b/target/riscv/fpu_helper.c @@ -81,9 +81,12 @@ void helper_set_rounding_mode(CPURISCVState *env, uint32= _t rm) set_float_rounding_mode(softrm, &env->fp_status); } =20 -static uint64_t do_fmadd_s(CPURISCVState *env, uint64_t frs1, uint64_t frs= 2, - uint64_t frs3, int flags) +static uint64_t do_fmadd_s(CPURISCVState *env, uint64_t rs1, uint64_t rs2, + uint64_t rs3, int flags) { + float32 frs1 =3D check_nanbox_s(rs1); + float32 frs2 =3D check_nanbox_s(rs2); + float32 frs3 =3D check_nanbox_s(rs3); return nanbox_s(float32_muladd(frs1, frs2, frs3, flags, &env->fp_statu= s)); } =20 @@ -139,74 +142,97 @@ uint64_t helper_fnmadd_d(CPURISCVState *env, uint64_t= frs1, uint64_t frs2, float_muladd_negate_product, &env->fp_status); } =20 -uint64_t helper_fadd_s(CPURISCVState *env, uint64_t frs1, uint64_t frs2) +uint64_t helper_fadd_s(CPURISCVState *env, uint64_t rs1, uint64_t rs2) { + float32 frs1 =3D check_nanbox_s(rs1); + float32 frs2 =3D check_nanbox_s(rs2); return nanbox_s(float32_add(frs1, frs2, &env->fp_status)); } =20 -uint64_t helper_fsub_s(CPURISCVState *env, uint64_t frs1, uint64_t frs2) +uint64_t helper_fsub_s(CPURISCVState *env, uint64_t rs1, uint64_t rs2) { + float32 frs1 =3D check_nanbox_s(rs1); + float32 frs2 =3D check_nanbox_s(rs2); return nanbox_s(float32_sub(frs1, frs2, &env->fp_status)); } =20 -uint64_t helper_fmul_s(CPURISCVState *env, uint64_t frs1, uint64_t frs2) +uint64_t helper_fmul_s(CPURISCVState *env, uint64_t rs1, uint64_t rs2) { + float32 frs1 =3D check_nanbox_s(rs1); + float32 frs2 =3D check_nanbox_s(rs2); return nanbox_s(float32_mul(frs1, frs2, &env->fp_status)); } =20 -uint64_t helper_fdiv_s(CPURISCVState *env, uint64_t frs1, uint64_t frs2) +uint64_t helper_fdiv_s(CPURISCVState *env, uint64_t rs1, uint64_t rs2) { + float32 frs1 =3D check_nanbox_s(rs1); + float32 frs2 =3D check_nanbox_s(rs2); return nanbox_s(float32_div(frs1, frs2, &env->fp_status)); } =20 -uint64_t helper_fmin_s(CPURISCVState *env, uint64_t frs1, uint64_t frs2) +uint64_t helper_fmin_s(CPURISCVState *env, uint64_t rs1, uint64_t rs2) { + float32 frs1 =3D check_nanbox_s(rs1); + float32 frs2 =3D check_nanbox_s(rs2); return nanbox_s(float32_minnum(frs1, frs2, &env->fp_status)); } =20 -uint64_t helper_fmax_s(CPURISCVState *env, uint64_t frs1, uint64_t frs2) +uint64_t helper_fmax_s(CPURISCVState *env, uint64_t rs1, uint64_t rs2) { + float32 frs1 =3D check_nanbox_s(rs1); + float32 frs2 =3D check_nanbox_s(rs2); return nanbox_s(float32_maxnum(frs1, frs2, &env->fp_status)); } =20 -uint64_t helper_fsqrt_s(CPURISCVState *env, uint64_t frs1) +uint64_t helper_fsqrt_s(CPURISCVState *env, uint64_t rs1) { + float32 frs1 =3D check_nanbox_s(rs1); return nanbox_s(float32_sqrt(frs1, &env->fp_status)); } =20 -target_ulong helper_fle_s(CPURISCVState *env, uint64_t frs1, uint64_t frs2) +target_ulong helper_fle_s(CPURISCVState *env, uint64_t rs1, uint64_t rs2) { + float32 frs1 =3D check_nanbox_s(rs1); + float32 frs2 =3D check_nanbox_s(rs2); return float32_le(frs1, frs2, &env->fp_status); } =20 -target_ulong helper_flt_s(CPURISCVState *env, uint64_t frs1, uint64_t frs2) +target_ulong helper_flt_s(CPURISCVState *env, uint64_t rs1, uint64_t rs2) { + float32 frs1 =3D check_nanbox_s(rs1); + float32 frs2 =3D check_nanbox_s(rs2); return float32_lt(frs1, frs2, &env->fp_status); } =20 -target_ulong helper_feq_s(CPURISCVState *env, uint64_t frs1, uint64_t frs2) +target_ulong helper_feq_s(CPURISCVState *env, uint64_t rs1, uint64_t rs2) { + float32 frs1 =3D check_nanbox_s(rs1); + float32 frs2 =3D check_nanbox_s(rs2); return float32_eq_quiet(frs1, frs2, &env->fp_status); } =20 -target_ulong helper_fcvt_w_s(CPURISCVState *env, uint64_t frs1) +target_ulong helper_fcvt_w_s(CPURISCVState *env, uint64_t rs1) { + float32 frs1 =3D check_nanbox_s(rs1); return float32_to_int32(frs1, &env->fp_status); } =20 -target_ulong helper_fcvt_wu_s(CPURISCVState *env, uint64_t frs1) +target_ulong helper_fcvt_wu_s(CPURISCVState *env, uint64_t rs1) { + float32 frs1 =3D check_nanbox_s(rs1); return (int32_t)float32_to_uint32(frs1, &env->fp_status); } =20 #if defined(TARGET_RISCV64) -uint64_t helper_fcvt_l_s(CPURISCVState *env, uint64_t frs1) +uint64_t helper_fcvt_l_s(CPURISCVState *env, uint64_t rs1) { + float32 frs1 =3D check_nanbox_s(rs1); return float32_to_int64(frs1, &env->fp_status); } =20 -uint64_t helper_fcvt_lu_s(CPURISCVState *env, uint64_t frs1) +uint64_t helper_fcvt_lu_s(CPURISCVState *env, uint64_t rs1) { + float32 frs1 =3D check_nanbox_s(rs1); return float32_to_uint64(frs1, &env->fp_status); } #endif @@ -233,8 +259,9 @@ uint64_t helper_fcvt_s_lu(CPURISCVState *env, uint64_t = rs1) } #endif =20 -target_ulong helper_fclass_s(uint64_t frs1) +target_ulong helper_fclass_s(uint64_t rs1) { + float32 frs1 =3D check_nanbox_s(rs1); return fclass_s(frs1); } =20 @@ -275,7 +302,8 @@ uint64_t helper_fcvt_s_d(CPURISCVState *env, uint64_t r= s1) =20 uint64_t helper_fcvt_d_s(CPURISCVState *env, uint64_t rs1) { - return float32_to_float64(rs1, &env->fp_status); + float32 frs1 =3D check_nanbox_s(rs1); + return float32_to_float64(frs1, &env->fp_status); } =20 uint64_t helper_fsqrt_d(CPURISCVState *env, uint64_t frs1) --=20 2.25.1 From nobody Fri May 10 13:34:13 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1595550897; cv=none; d=zohomail.com; s=zohoarc; b=QIa+GFjLaGfZ92MCF8sHfzvYXiymyK63ytCAXDFxAsSJAKKhuHgrjCTBiA5iw/BNfXxIhL2/Shnik/6R8oKLCCt3KFAWd/bthc3zrY28J+KmgvQqaFlOsfhXuVvxCBuJTi8Pz11AaQZVnESr3kfiLqY5Zh/0B8dn4cw310Zuf9g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595550897; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=uOTwXorMBOXrFmJmINeMsaqUEEGcVRjeFDnFBQo8HEo=; b=e82NHc8df1n7FVrxKZQHTgNnfxiTmbqXtYZjUj7C9cnJtag2oL52nZ2eBVpR3gZxG01m0aIOGoLV7+ksmnmopDiRkRgGqjQ4c3ha9OrCD/HzfeIHR7z3Za3MZr+/L1JCBxxqZ6s/CSden68AJtk79F4uqYFt1JK+MBKt56hk4aQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 159555089779343.7915319246938; Thu, 23 Jul 2020 17:34:57 -0700 (PDT) Received: from localhost ([::1]:34276 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jylfs-0006bN-FU for importer@patchew.org; Thu, 23 Jul 2020 20:34:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54434) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jylZT-0000Hn-7u for qemu-devel@nongnu.org; Thu, 23 Jul 2020 20:28:19 -0400 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:41936) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jylZR-0008FZ-CU for qemu-devel@nongnu.org; Thu, 23 Jul 2020 20:28:18 -0400 Received: by mail-pl1-x642.google.com with SMTP id d1so3489045plr.8 for ; Thu, 23 Jul 2020 17:28:16 -0700 (PDT) Received: from localhost.localdomain (216-160-65-90.tukw.qwest.net. [216.160.65.90]) by smtp.gmail.com with ESMTPSA id q20sm4224635pfn.111.2020.07.23.17.28.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2020 17:28:14 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=uOTwXorMBOXrFmJmINeMsaqUEEGcVRjeFDnFBQo8HEo=; b=OWorXomajix5u8n2V0P5mG7310nVjhH15eJMmSgUcM9IiGU6L0Jnf/5LjfF+qHDm/u +9OEjhWzyUw5JlL9N8UkxLRvemDZnpBYa693YQ4fAW4DJS1OAeUDGOeg2uT3qaIz5KNL wngMvliPXXJZJZToqr883aF+QrPciIGLvwEK1QTHx5e7wXoZDzIkqkiS5CBFeWu+5eu7 Wl43aw6l7UrFiCIXAwk4AylJo+LLf2GA76VOhFOrAlTSjvrsCfWadJTIy3IzIUqIyq/F OygLzaVjbBQT1JieoZLWvmvWgNKzkknEYJwPWMl/ZJ1h6btpxNn3SRR6fZCSZr2wrmNk 3h/g== 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:mime-version:content-transfer-encoding; bh=uOTwXorMBOXrFmJmINeMsaqUEEGcVRjeFDnFBQo8HEo=; b=id0o4b9NY/nNw/Q96ypeCo+kW+BbiFbgT2D8mhpmCHucy1HkNqk8MrBd18xbac88Ph 8BgCFztvuW7QSsVC2bPzMf8RQtONyd2b1p0xuTnMiikVn4XBct9N7t7hijxwBLh1mazc T2sw9A63dvDHktGxQsu8VwZQZF+WW4T1afN835swNNIWLNak1oQ0hcWUFT8yS3bkr3TK Dpjen/PhNrcPJKj9DCo7Zm74uhx/jru1rIGsZocLjAMnSmb/kFicT+HtcYvn26htPBC7 twEeviQ00e5kRQMU1VLcehGE5yKWrpX3SrGcKofZZLaKH4are2Rbvh3fafNpqhNRelM9 y/4g== X-Gm-Message-State: AOAM532Rm0byNEvwpt7TjeKghJ+j1o+qompslbG8Wu+l2gLVs3x9ZTS9 LNhis3+/qwCEGc/4Uf7ThsMTtNJqA4o= X-Google-Smtp-Source: ABdhPJwl8uVFVOUmkuYLNztuogGhRxfNxGr6QF7tQHDHoD06giqNVb2pExkoWH7ebit3c1AIgf8C4Q== X-Received: by 2002:a17:90a:c085:: with SMTP id o5mr2918973pjs.196.1595550495670; Thu, 23 Jul 2020 17:28:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 5/7] target/riscv: Check nanboxed inputs in trans_rvf.inc.c Date: Thu, 23 Jul 2020 17:28:05 -0700 Message-Id: <20200724002807.441147-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200724002807.441147-1-richard.henderson@linaro.org> References: <20200724002807.441147-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::642; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x642.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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: frank.chang@sifive.com, alistair23@gmail.com, qemu-riscv@nongnu.org, zhiwei_liu@c-sky.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" If a 32-bit input is not properly nanboxed, then the input is replaced with the default qnan. The only inline expansion is for the sign-changing set of instructions: FSGNJ.S, FSGNJX.S, FSGNJN.S. Signed-off-by: Richard Henderson Reviewed-by: Chih-Min Chao Reviewed-by: LIU Zhiwei --- target/riscv/insn_trans/trans_rvf.inc.c | 71 +++++++++++++++++++------ target/riscv/translate.c | 18 +++++++ 2 files changed, 73 insertions(+), 16 deletions(-) diff --git a/target/riscv/insn_trans/trans_rvf.inc.c b/target/riscv/insn_tr= ans/trans_rvf.inc.c index 264d3139f1..f9a9e0643a 100644 --- a/target/riscv/insn_trans/trans_rvf.inc.c +++ b/target/riscv/insn_trans/trans_rvf.inc.c @@ -161,47 +161,86 @@ static bool trans_fsgnj_s(DisasContext *ctx, arg_fsgn= j_s *a) { REQUIRE_FPU; REQUIRE_EXT(ctx, RVF); + if (a->rs1 =3D=3D a->rs2) { /* FMOV */ - tcg_gen_mov_i64(cpu_fpr[a->rd], cpu_fpr[a->rs1]); + gen_check_nanbox_s(cpu_fpr[a->rd], cpu_fpr[a->rs1]); } else { /* FSGNJ */ - tcg_gen_deposit_i64(cpu_fpr[a->rd], cpu_fpr[a->rs2], cpu_fpr[a->rs= 1], - 0, 31); + TCGv_i64 rs1 =3D tcg_temp_new_i64(); + TCGv_i64 rs2 =3D tcg_temp_new_i64(); + + gen_check_nanbox_s(rs1, cpu_fpr[a->rs1]); + gen_check_nanbox_s(rs2, cpu_fpr[a->rs2]); + + /* This formulation retains the nanboxing of rs2. */ + tcg_gen_deposit_i64(cpu_fpr[a->rd], rs2, rs1, 0, 31); + tcg_temp_free_i64(rs1); + tcg_temp_free_i64(rs2); } - gen_nanbox_s(cpu_fpr[a->rd], cpu_fpr[a->rd]); mark_fs_dirty(ctx); return true; } =20 static bool trans_fsgnjn_s(DisasContext *ctx, arg_fsgnjn_s *a) { + TCGv_i64 rs1, rs2, mask; + REQUIRE_FPU; REQUIRE_EXT(ctx, RVF); + + rs1 =3D tcg_temp_new_i64(); + gen_check_nanbox_s(rs1, cpu_fpr[a->rs1]); + if (a->rs1 =3D=3D a->rs2) { /* FNEG */ - tcg_gen_xori_i64(cpu_fpr[a->rd], cpu_fpr[a->rs1], INT32_MIN); + tcg_gen_xori_i64(cpu_fpr[a->rd], rs1, MAKE_64BIT_MASK(31, 1)); } else { - TCGv_i64 t0 =3D tcg_temp_new_i64(); - tcg_gen_not_i64(t0, cpu_fpr[a->rs2]); - tcg_gen_deposit_i64(cpu_fpr[a->rd], t0, cpu_fpr[a->rs1], 0, 31); - tcg_temp_free_i64(t0); + rs2 =3D tcg_temp_new_i64(); + gen_check_nanbox_s(rs2, cpu_fpr[a->rs2]); + + /* + * Replace bit 31 in rs1 with inverse in rs2. + * This formulation retains the nanboxing of rs1. + */ + mask =3D tcg_const_i64(~MAKE_64BIT_MASK(31, 1)); + tcg_gen_andc_i64(rs2, mask, rs2); + tcg_gen_and_i64(rs1, mask, rs1); + tcg_gen_or_i64(cpu_fpr[a->rd], rs1, rs2); + + tcg_temp_free_i64(mask); + tcg_temp_free_i64(rs2); } - gen_nanbox_s(cpu_fpr[a->rd], cpu_fpr[a->rd]); + tcg_temp_free_i64(rs1); + mark_fs_dirty(ctx); return true; } =20 static bool trans_fsgnjx_s(DisasContext *ctx, arg_fsgnjx_s *a) { + TCGv_i64 rs1, rs2; + REQUIRE_FPU; REQUIRE_EXT(ctx, RVF); + + rs1 =3D tcg_temp_new_i64(); + gen_check_nanbox_s(rs1, cpu_fpr[a->rs1]); + if (a->rs1 =3D=3D a->rs2) { /* FABS */ - tcg_gen_andi_i64(cpu_fpr[a->rd], cpu_fpr[a->rs1], ~INT32_MIN); + tcg_gen_andi_i64(cpu_fpr[a->rd], rs1, ~MAKE_64BIT_MASK(31, 1)); } else { - TCGv_i64 t0 =3D tcg_temp_new_i64(); - tcg_gen_andi_i64(t0, cpu_fpr[a->rs2], INT32_MIN); - tcg_gen_xor_i64(cpu_fpr[a->rd], cpu_fpr[a->rs1], t0); - tcg_temp_free_i64(t0); + rs2 =3D tcg_temp_new_i64(); + gen_check_nanbox_s(rs2, cpu_fpr[a->rs2]); + + /* + * Xor bit 31 in rs1 with that in rs2. + * This formulation retains the nanboxing of rs1. + */ + tcg_gen_andi_i64(rs2, rs2, MAKE_64BIT_MASK(31, 1)); + tcg_gen_xor_i64(cpu_fpr[a->rd], rs1, rs2); + + tcg_temp_free_i64(rs2); } - gen_nanbox_s(cpu_fpr[a->rd], cpu_fpr[a->rd]); + tcg_temp_free_i64(rs1); + mark_fs_dirty(ctx); return true; } diff --git a/target/riscv/translate.c b/target/riscv/translate.c index 12a746da97..bf35182776 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -101,6 +101,24 @@ static void gen_nanbox_s(TCGv_i64 out, TCGv_i64 in) tcg_gen_ori_i64(out, in, MAKE_64BIT_MASK(32, 32)); } =20 +/* + * A narrow n-bit operation, where n < FLEN, checks that input operands + * are correctly Nan-boxed, i.e., all upper FLEN - n bits are 1. + * If so, the least-significant bits of the input are used, otherwise the + * input value is treated as an n-bit canonical NaN (v2.2 section 9.2). + * + * Here, the result is always nan-boxed, even the canonical nan. + */ +static void gen_check_nanbox_s(TCGv_i64 out, TCGv_i64 in) +{ + TCGv_i64 t_max =3D tcg_const_i64(0xffffffff00000000ull); + TCGv_i64 t_nan =3D tcg_const_i64(0xffffffff7fc00000ull); + + tcg_gen_movcond_i64(TCG_COND_GEU, out, in, t_max, in, t_nan); + tcg_temp_free_i64(t_max); + tcg_temp_free_i64(t_nan); +} + static void generate_exception(DisasContext *ctx, int excp) { tcg_gen_movi_tl(cpu_pc, ctx->base.pc_next); --=20 2.25.1 From nobody Fri May 10 13:34:13 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1595550718; cv=none; d=zohomail.com; s=zohoarc; b=ZdgVn2ke2mKWsnpKnqoT0ha+yCseqPcmbA79OrrrJm06lhO8ctuA7V/uODAb8Ef6LE8BxjwjaPk2KEyhYsfTHdajWIg3J1y5am5O+UQUU3fO1mhdcNK6fBo9RTSZh4TrGHcVKCQ3P8H2YeNQcOJtKo5aFh1flTLDwbZQPI+aRIo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595550718; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=47EQx+PBbhx6NH5LPqB93rYv/z3gdVWS3BnfZRGSId8=; b=hNWyaSX63cIsbfqyFnQ6Kw8Oc2ewUnEiF22ey12TdSTJPFp1Lu4ptN3D+Bbzuth61gIAtjzmLIjTVND9JDSY+5ebXTO1h8rYSPaDDYUWRoDOJzTrFe+bG44VDQaVp8nAxqAOrRZJnNR1uv1Fym7lYPnX/E7elsHbBMgn3m86IOU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1595550718895102.73703943005057; Thu, 23 Jul 2020 17:31:58 -0700 (PDT) Received: from localhost ([::1]:56840 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jylcz-00047z-Me for importer@patchew.org; Thu, 23 Jul 2020 20:31:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54454) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jylZU-0000Jr-19 for qemu-devel@nongnu.org; Thu, 23 Jul 2020 20:28:20 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:39100) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jylZS-0008Fs-Bu for qemu-devel@nongnu.org; Thu, 23 Jul 2020 20:28:19 -0400 Received: by mail-pf1-x441.google.com with SMTP id x72so4065146pfc.6 for ; Thu, 23 Jul 2020 17:28:17 -0700 (PDT) Received: from localhost.localdomain (216-160-65-90.tukw.qwest.net. [216.160.65.90]) by smtp.gmail.com with ESMTPSA id q20sm4224635pfn.111.2020.07.23.17.28.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2020 17:28:16 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=47EQx+PBbhx6NH5LPqB93rYv/z3gdVWS3BnfZRGSId8=; b=jQ8XhIEFA1hpQtBf3QL6Fj9jVCKQFtXKBtmd3yDdhdpo0eZdO3ehCjYQ5Y2N2ha16c mYgvhfjZXkl0j+9TglvnuRhTIbx+O44rTpE9p3GpgzD2VQ2gvrVjTlAxXt86SNZ2rZr2 8YkQ3WwWOaXhXJp+geNvk53/tqTUpRdGYqRHfm41MdIw/dubiYsCILx2iOeWXzPGvo+A 9PLm9uwdhZBdGrguFIWdSE2LhFlnvSOayuJDZujtQW6LQM9T6zMP24opIhseEjsnB9ef s4iI15eMiMZZtVqN3QDbPib/401Ac3HA2w/JeXSeYK2YT2NLIPXCnBEEIKY22I/9e6or IAYA== 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:mime-version:content-transfer-encoding; bh=47EQx+PBbhx6NH5LPqB93rYv/z3gdVWS3BnfZRGSId8=; b=sqQOFVZ44Ih1pq7QW4BaQaG+60mQdQ6CF+fSTnw1b8xSuPsh0+DLIwAVCZD+13sukg tk4Q4HrvYoqajJuMWysDnKNXaShN/o04MwNM68Cnpabn7dgT5m56NbGcURNVCLL8koXJ BHe5YmPlkq1oadefjDU323CG14W8hGoKWlXyS0OF01Ei9NUgywatNgezLo6hJk9t059p QLm+IDrfaTWXRBovqrnKujUCpXm2U3SNRy8ODThTuIXuf1d8Hmmmo2Npa/LByWtrXEOm N5ZapNswzJeRJ2qHKQ9tIKt5T0E95KQUV4BHV3p/2Tk36e2zcVKnHtc3jUoZhLtAkA1I szsQ== X-Gm-Message-State: AOAM5316crFakZ2KLTqvgBHT6Ur/PJgWxD1SahLuQi3JxGlvRKZpgEwi OF6mgLNePB/D2+Y7aLBQe4DTIEGLRow= X-Google-Smtp-Source: ABdhPJyiUJ1O5lAytZTGnfBF6Ez5cNLIA8nUT0xPa2ZJIRKqfWX4UU2AziPFBPkIilCMKGDCAhkmRg== X-Received: by 2002:a62:2b96:: with SMTP id r144mr6447012pfr.272.1595550496829; Thu, 23 Jul 2020 17:28:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 6/7] target/riscv: Clean up fmv.w.x Date: Thu, 23 Jul 2020 17:28:06 -0700 Message-Id: <20200724002807.441147-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200724002807.441147-1-richard.henderson@linaro.org> References: <20200724002807.441147-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::441; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x441.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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: frank.chang@sifive.com, alistair23@gmail.com, qemu-riscv@nongnu.org, zhiwei_liu@c-sky.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: LIU Zhiwei Use tcg_gen_extu_tl_i64 to avoid the ifdef. Signed-off-by: LIU Zhiwei Message-Id: <20200626205917.4545-7-zhiwei_liu@c-sky.com> Signed-off-by: Richard Henderson Reviewed-by: Chih-Min Chao --- target/riscv/insn_trans/trans_rvf.inc.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/target/riscv/insn_trans/trans_rvf.inc.c b/target/riscv/insn_tr= ans/trans_rvf.inc.c index f9a9e0643a..0d04677a02 100644 --- a/target/riscv/insn_trans/trans_rvf.inc.c +++ b/target/riscv/insn_trans/trans_rvf.inc.c @@ -406,11 +406,7 @@ static bool trans_fmv_w_x(DisasContext *ctx, arg_fmv_w= _x *a) TCGv t0 =3D tcg_temp_new(); gen_get_gpr(t0, a->rs1); =20 -#if defined(TARGET_RISCV64) - tcg_gen_mov_i64(cpu_fpr[a->rd], t0); -#else - tcg_gen_extu_i32_i64(cpu_fpr[a->rd], t0); -#endif + tcg_gen_extu_tl_i64(cpu_fpr[a->rd], t0); gen_nanbox_s(cpu_fpr[a->rd], cpu_fpr[a->rd]); =20 mark_fs_dirty(ctx); --=20 2.25.1 From nobody Fri May 10 13:34:13 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1595550987; cv=none; d=zohomail.com; s=zohoarc; b=J8zB4sKmCGHrJoNkuM6UPIWhy/sx6qdWItOl3DJrUfSDnGeX/z+37Dp5Cecbo5hZTgIIno7m29ukgFTlvqhDPg5Jb/dDzILbLykWJMAgV3XqpCroOTzVNdWVmh+thnMT5jkQI7bs4KxGCpv1uhL2F5DQGDy+sd5vFYlfNuAwLiU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595550987; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=jQCpNdFJsrF3Bpi0rRRCXqsUrN96754LDnpff+tQIzo=; b=QuLx6CWUAqHxmio0xGlI722yYE6o+ERIQho16XRB4AlY23jmWY5yN8TVrgyJplo8zyoOpfB3Cc4zbqNBoN+HOiQCETQ/EzqHBmYw25oVHaMDwp2N9jtbT8MsDHekw8pEkbssOieXYuRml0docwTOwrKBXml6+8odo1sWQ1xrbEs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 159555098678671.57474714171133; Thu, 23 Jul 2020 17:36:26 -0700 (PDT) Received: from localhost ([::1]:37148 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jylhJ-0007xL-JZ for importer@patchew.org; Thu, 23 Jul 2020 20:36:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54470) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jylZV-0000ML-5y for qemu-devel@nongnu.org; Thu, 23 Jul 2020 20:28:21 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]:46606) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jylZT-0008GF-KL for qemu-devel@nongnu.org; Thu, 23 Jul 2020 20:28:20 -0400 Received: by mail-pf1-x431.google.com with SMTP id a23so4051334pfk.13 for ; Thu, 23 Jul 2020 17:28:19 -0700 (PDT) Received: from localhost.localdomain (216-160-65-90.tukw.qwest.net. [216.160.65.90]) by smtp.gmail.com with ESMTPSA id q20sm4224635pfn.111.2020.07.23.17.28.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2020 17:28:17 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=jQCpNdFJsrF3Bpi0rRRCXqsUrN96754LDnpff+tQIzo=; b=FScUEfH+7aJujA9JSdolRAFuUDhHsshCEERdH9W9YZSRKL/KK/ZQsHZL+zn+iNOTsk FJAmFC0hc3hPsj3xkJEUkQpUG+TS1RPZDrhIKySvy2ApU0W9w1NYKkALTK+ONPCTrpws J5WH6aOhDU6jrfUwYLZzk61TkcUHDnAIydTHzdvoZZrhHZWiVNAiQSmrVqUttLZRRhAl ClcKyQDVEaI+Wd5IGe+Iw5wV86HJ93TnaHhInjRwCOprPbSMmozOxl6ya3bfaiKuhYWa HHVGd4ETYkVEfcJ0DoY5nr2ydDGeVVDSvZrfda7/wc32U8Znms5Kzw9GBjsb8Eb7q8fQ b5Xw== 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:mime-version:content-transfer-encoding; bh=jQCpNdFJsrF3Bpi0rRRCXqsUrN96754LDnpff+tQIzo=; b=Jcwk7SqWzBQtYjjJOD6MU8w3oYMnqsmyfXiIfyjGy1TcdERh6B1psLH89gS4lUob9A 5QT9BJ1OblU99K2llyQEdIbV4W/x+a2cGr4D7QhxowDcxxGDJ8qEBibnj0X9Li1qFD8O r+M+cnFgjEbSqJz1GCkmJjuFOYihhmT4Q7EXpdR7FzEihfOpIpJhCACFyGWkv8dXdDFM ZnsLpJYBnJPe6bgOY3dD2iy76zBezhAkjN9qKxqzUpYRjVPQAUaUtqC6TNtn/w2m0fqY tqi6J8AiAQzf4QmGCf2zbDEVLmGZxl7gl+3hQzjCGTKQR3tRhe5Q8xgeT7QirMSPbUL0 fZ4g== X-Gm-Message-State: AOAM5323H2cHOT5Xe0aNuJmRxnsObgv/ifB4ARMOH0VALLOU33hZKu/r fsGC7pSgHZB6dXImaK8DJc/tz0tF8dw= X-Google-Smtp-Source: ABdhPJwJpM0IToCX7H1EapTXmYY8AmBjtWlS0t+IfEhdMMHDFQjM4DNvrOefl4ODTNMaCzGEDy0FNA== X-Received: by 2002:a65:6416:: with SMTP id a22mr6212003pgv.392.1595550497983; Thu, 23 Jul 2020 17:28:17 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 7/7] target/riscv: check before allocating TCG temps Date: Thu, 23 Jul 2020 17:28:07 -0700 Message-Id: <20200724002807.441147-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200724002807.441147-1-richard.henderson@linaro.org> References: <20200724002807.441147-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::431; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x431.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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: frank.chang@sifive.com, alistair23@gmail.com, qemu-riscv@nongnu.org, zhiwei_liu@c-sky.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: LIU Zhiwei Signed-off-by: LIU Zhiwei Message-Id: <20200626205917.4545-5-zhiwei_liu@c-sky.com> Signed-off-by: Richard Henderson Reviewed-by: Chih-Min Chao --- target/riscv/insn_trans/trans_rvd.inc.c | 8 ++++---- target/riscv/insn_trans/trans_rvf.inc.c | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/target/riscv/insn_trans/trans_rvd.inc.c b/target/riscv/insn_tr= ans/trans_rvd.inc.c index ea1044f13b..4f832637fa 100644 --- a/target/riscv/insn_trans/trans_rvd.inc.c +++ b/target/riscv/insn_trans/trans_rvd.inc.c @@ -20,10 +20,10 @@ =20 static bool trans_fld(DisasContext *ctx, arg_fld *a) { - TCGv t0 =3D tcg_temp_new(); - gen_get_gpr(t0, a->rs1); REQUIRE_FPU; REQUIRE_EXT(ctx, RVD); + TCGv t0 =3D tcg_temp_new(); + gen_get_gpr(t0, a->rs1); tcg_gen_addi_tl(t0, t0, a->imm); =20 tcg_gen_qemu_ld_i64(cpu_fpr[a->rd], t0, ctx->mem_idx, MO_TEQ); @@ -35,10 +35,10 @@ static bool trans_fld(DisasContext *ctx, arg_fld *a) =20 static bool trans_fsd(DisasContext *ctx, arg_fsd *a) { - TCGv t0 =3D tcg_temp_new(); - gen_get_gpr(t0, a->rs1); REQUIRE_FPU; REQUIRE_EXT(ctx, RVD); + TCGv t0 =3D tcg_temp_new(); + gen_get_gpr(t0, a->rs1); tcg_gen_addi_tl(t0, t0, a->imm); =20 tcg_gen_qemu_st_i64(cpu_fpr[a->rs2], t0, ctx->mem_idx, MO_TEQ); diff --git a/target/riscv/insn_trans/trans_rvf.inc.c b/target/riscv/insn_tr= ans/trans_rvf.inc.c index 0d04677a02..16df9c5ee2 100644 --- a/target/riscv/insn_trans/trans_rvf.inc.c +++ b/target/riscv/insn_trans/trans_rvf.inc.c @@ -25,10 +25,10 @@ =20 static bool trans_flw(DisasContext *ctx, arg_flw *a) { - TCGv t0 =3D tcg_temp_new(); - gen_get_gpr(t0, a->rs1); REQUIRE_FPU; REQUIRE_EXT(ctx, RVF); + TCGv t0 =3D tcg_temp_new(); + gen_get_gpr(t0, a->rs1); tcg_gen_addi_tl(t0, t0, a->imm); =20 tcg_gen_qemu_ld_i64(cpu_fpr[a->rd], t0, ctx->mem_idx, MO_TEUL); @@ -41,11 +41,11 @@ static bool trans_flw(DisasContext *ctx, arg_flw *a) =20 static bool trans_fsw(DisasContext *ctx, arg_fsw *a) { + REQUIRE_FPU; + REQUIRE_EXT(ctx, RVF); TCGv t0 =3D tcg_temp_new(); gen_get_gpr(t0, a->rs1); =20 - REQUIRE_FPU; - REQUIRE_EXT(ctx, RVF); tcg_gen_addi_tl(t0, t0, a->imm); =20 tcg_gen_qemu_st_i64(cpu_fpr[a->rs2], t0, ctx->mem_idx, MO_TEUL); --=20 2.25.1