From patchwork Wed Aug 12 22:30:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 247644 Delivered-To: patch@linaro.org Received: by 2002:a92:cc90:0:0:0:0:0 with SMTP id x16csp770373ilo; Wed, 12 Aug 2020 15:42:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwEleXBQ48HhmikApNqIlhcQmOUVaaXfO/Caf9Yj3f9tSddWOSKRlpnAki3KIcrBYgZwUT1 X-Received: by 2002:a25:c345:: with SMTP id t66mr2435344ybf.218.1597272162776; Wed, 12 Aug 2020 15:42:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597272162; cv=none; d=google.com; s=arc-20160816; b=vfpdKwVdJIO2w3f0iM58xu6w1dCAdTaW4HSXjPiuSypw2+o0skrgQUOsNH1BiF8HwY vUGmyi4Zuv68lmHimgzDH0Bkub1x0lt4QOUN8XCHfpKOxjBEt+yKdCbQQs6DVTh0Vj64 Q2NzY18o/pHl9VUjGIOqOV5dQp21NHdQaOopd2OE6FdlsHGXWhIftzKWS4i79qO8CcS7 JOS0UkKMSLkiYLfJsJyTYuCKAV4zWE66l9jyU5Tfl45CcxdcAX8DE1COQAoXsCaDkUYw Yd9i9Q+p1fkz4jnrMv7zJ46DM72YR+9q5x6LYYuRzktMm5RgiRbEDkI6u+gYQChJxQ/4 LVDw== 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=r8JEQz2eBqSJ2uXuW09rg/aTRbfvxh0SErI0Y4oFI+w=; b=MLetZAiZEJ9aEacwyWLjb3/7CIePzOuEmsfqghcXhEU+7qXlj7cPhlPvxnP88GUcEO xs41pA+/uu8EnSmbYxgvoZOhLH5WYDHqZ5tw2mlOT8g/1ljZYTiukPEi6hd+gYzuYhhJ ckidjsZO2VDQtgdnVX8tBF36SjZFv3MRochPPqPflTAjveiJkD8w+CAloPHmdKVE5TJN ak3GmJJ44oYCkn6YAQ9AAFyPpX6/aqz7Y4Ay8jEWEuad3C8PSZ2pBC9fnScEqYuzYpnE AlFKARBdmKZWilCE2zsnM0nSO467Wmf/0Sph6QIIAUqXXNZXH4m+h9fvvCcYipB8WnRs pllg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=U7Vsq2Jl; 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 128si3615062yba.124.2020.08.12.15.42.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 12 Aug 2020 15:42:42 -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=U7Vsq2Jl; 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]:34698 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k5zSA-0003ay-86 for patch@linaro.org; Wed, 12 Aug 2020 18:42:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39496) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5zQU-0002H3-T8 for qemu-devel@nongnu.org; Wed, 12 Aug 2020 18:40:54 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:56480) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5zQR-0005oE-G5 for qemu-devel@nongnu.org; Wed, 12 Aug 2020 18:40:54 -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=1597272051; x=1628808051; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jL8la5SaUZPFPaXp7NmU6atCG+J2ay2cXyu6f42UdYk=; b=U7Vsq2JlUdP2GEvpWk4Ll1GNZHvN8mhXt6YyZUhVF5yHenJOzKLP567V GfaN4wg2e6r620d8zYwR7xVtsM5nojcFWQQl/Ai16TqM3ybnMsnpk44xY F7hZVfbf01skr0kTCVva2+cXbwKKdfZrErZkZK1Uk+71VlKzyOzGqvC1U ypiesdaxgjd0il2JjjZ6yLR6znsbdFIDFvusHz53PrTNKIClHqyUEjg/A JFPsMEjxD+oyJy4d0vZ/585NNYvKi8+MBaE5mlFYxBJPlynIiHNiScpKL QTSnUqGhRdgI5dNDJDyQSlL5CyAGo8a/0+iu7Q8f7MeJHdtBq7vxGDvKc g==; IronPort-SDR: IHjIddzMoa+1SJF0yKhZ8CqUSecXAy9SuMGtHEobRFtPeUoakoLGPagvK/84GeeCvAXqa7hQ/4 ZpCSXyPfc60I1yLluLRW2te5ecvfzh3ocfzs7Pl/TeOoJwMHeXRmWp8pf1MeNqCcXBuqjcvqFv MQOAOavjboeKUDIU/XtYZArzc8PA5yRaD3nUkPelcQ/yX0ypTe2a0Dk47T+2rUKneTIPa7mt3/ tT1LhQZSCGTNWO34pSF3zdl4uI9Q5/p+TuSmQTp5LdfbK18Trv7v1mP8pZTf8yeQSWFzP7meLI ekY= X-IronPort-AV: E=Sophos;i="5.76,305,1592841600"; d="scan'208";a="144853391" 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:48 +0800 IronPort-SDR: jOg/EHds++OtJwZ3ex23mJ1GzL2XtWPiJZllGk6pqqT4H+Q4OpBNXRPGgxgAX/ld2g7BL6aMPn AynOnvZbmK6w== 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: rue34bdCbrZGzJ8YLTkWsavkovnKh618O2lgNGaANsLHkNaGB2KByteYN1EudBhmhY7nE8lmAB JRj1CYNO6dHA== 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 02/20] target/riscv: Generalize gen_nanbox_fpr to gen_nanbox_s Date: Wed, 12 Aug 2020 15:30:27 -0700 Message-Id: <20200812223045.96803-3-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 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: LIU Zhiwei Message-Id: <20200724002807.441147-3-richard.henderson@linaro.org> Signed-off-by: Alistair Francis --- target/riscv/insn_trans/trans_rvf.inc.c | 16 +--------------- target/riscv/translate.c | 11 +++++++++++ 2 files changed, 12 insertions(+), 15 deletions(-) -- 2.27.0 diff --git a/target/riscv/insn_trans/trans_rvf.inc.c b/target/riscv/insn_trans/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) -/* - * 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 = tcg_temp_new(); @@ -46,7 +32,7 @@ static bool trans_flw(DisasContext *ctx, arg_flw *a) tcg_gen_addi_tl(t0, t0, a->imm); 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]); 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 ext) return ctx->misa & ext; } +/* + * 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);