From patchwork Tue May 25 22:58:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 447343 Delivered-To: patch@linaro.org Received: by 2002:a02:7a1b:0:0:0:0:0 with SMTP id a27csp4699563jac; Tue, 25 May 2021 15:59:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJytU6EsEL47YU7FsojB13OTsIORU6s57tkBadOlRs8EwaNzGL06a8C+RVwm3TIDQCn/SHh0 X-Received: by 2002:a6b:b48a:: with SMTP id d132mr24067844iof.167.1621983548008; Tue, 25 May 2021 15:59:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621983548; cv=none; d=google.com; s=arc-20160816; b=K/PWjE7icqdwqDtRntjtToJ0RUmDtzw2hEE1/nvuqwiu/Q0RFX2vPYUqjow585VjYA 2DJe7/mVaJFSVjRDnaZrvKiNnVdrsPez0C7auWH3u1T5sZJsr5qNmJub+j7ctSXOwMhR DyWVvAwrMQOfRnKc+Tx38VHjfDqAdfdgVCrHsRblX6LfsEjLLoIl5zfPoWS46sUHE7mX tgBmvfQYNT1ZxOK5Ye61T0/JzwbKnsWdbz/0//FNYb0GOS64bOFb91wBY+ntc7FPcZ8A w3S01r6uhxsrQYE4aPi43xv0r5lrpe9otoTpAxwJ29u0hGnQEt/cK+AaqHWdO0mEratC w1Jg== 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 :dkim-signature; bh=0La4bELq+QRQvGpWtveOOb2coHQOmlKGzXDvXUy3i7s=; b=pbM3ACcW8sVLAhIiAFhrnH+kAU0WUBr7E2wUayIiR3vZuyfcJT15MsBF1ahxjmPUgQ 02JGB9HFAh/kjv1NTbEYCKvO/M48lKGFRlsnHvR+R1SanS5IYs0KE1xt3hCiWa4jU99B zCV/MeiIzYF8PZZy+B2EsIcJzc+ZH8fpPsrI9U+H4n54vnzqc4kryJZkp3YGolXzJ5kq iShHkxF0jkommfXoI0PFQl/SG3ehukA9iUa3AlizW5uU1rKmZE3XC5MgoZbAUuD0DJB7 yEZCzXv8Je52Qy/bPc6Vv95jZupY8UMewE1I7nJujARH0AjVxPvxvyl5RaTQUPgs+Dvq nnTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=W4PIKBxr; 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 o10si13779766ilf.52.2021.05.25.15.59.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 May 2021 15:59:07 -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=@linaro.org header.s=google header.b=W4PIKBxr; 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 ([::1]:56096 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1llg0x-0003Qf-Cg for patch@linaro.org; Tue, 25 May 2021 18:59:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52694) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1llg0Q-0002Y2-RA for qemu-devel@nongnu.org; Tue, 25 May 2021 18:58:34 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]:47087) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1llg0D-0004nY-PU for qemu-devel@nongnu.org; Tue, 25 May 2021 18:58:34 -0400 Received: by mail-pf1-x42c.google.com with SMTP id y15so13376876pfn.13 for ; Tue, 25 May 2021 15:58:21 -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=0La4bELq+QRQvGpWtveOOb2coHQOmlKGzXDvXUy3i7s=; b=W4PIKBxrD+per+6GVtdQnBXuRfHCgnIuWI6kHj7YFnIe0tD18zKt4IvjDU+SvfZLVP bhWkYzTDJL6bxVPBgwswCURElfyxWRF4u3ErNHgd4lnf9n8xKdDhyIP7nCzwVsUTYkx/ T5IIdckW5gu2OO6ohiTMjorcVmwrzzqZaE1/Xgr6wb+5jQz++umw5iNRq9mC1pRRMYAs kvEThWs0Vu4Vu8r2CqNd8PzCwZffiWXZj6PWaJ7G2Ybao44BPQ4wddgQ3sx1WQtRv5tE E1P3N73QNMJYcc4bOVfcDF4dIMHdIrQtWb3hE+0byekk35mn8u5PvdSSTM4Q+FBVtSzL 6Y3w== 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=0La4bELq+QRQvGpWtveOOb2coHQOmlKGzXDvXUy3i7s=; b=CqBKFNFO8z2gP60lKKby/p5DfvJh9LouiXTHcPxBowBNVfOytTg5BabzT7CO1jnxxg xDIwlxN6rmn6nZhNZd3NbhbYTfsdARWxf0uy9U7Ojsz9DtUYWt8kFoHjteT3/Nx/67B/ 1J3OqShRxFPN64ZIQllTC46OOlBtrXKJluPMbnxSCPxs3ki0e0D/EqHF5Mr/N7MIfMA3 8Gd2aLtQk3bts4LWrqSHUERPvSvqE4rQZVlCqV4r1x6k+KjU6d67m6r56ZOXhQcqKedg IvH7EOfK6ahX3zExscOG7zefv48xJ1MmH0wgrO+ckL/kHQgWg51G38vim5y3lvprl4OB ANfQ== X-Gm-Message-State: AOAM530PRXwNpUUPLOepdSTmbO6uHQ1y3DC0PNuLgySrMAU8zDLKO6MG MRjUhM5Y1GzdgqVQpMN3jdzKggk7XHFTLQ== X-Received: by 2002:a05:6a00:1630:b029:2c0:a1eb:d77 with SMTP id e16-20020a056a001630b02902c0a1eb0d77mr32345282pfc.81.1621983500454; Tue, 25 May 2021 15:58:20 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id l6sm1669928pjf.28.2021.05.25.15.58.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 May 2021 15:58:20 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 03/12] target/arm: Implement scalar float32 to bfloat16 conversion Date: Tue, 25 May 2021 15:58:08 -0700 Message-Id: <20210525225817.400336-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210525225817.400336-1-richard.henderson@linaro.org> References: <20210525225817.400336-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42c; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42c.google.com 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=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: Peter Maydell , qemu-arm@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This is the 64-bit BFCVT and the 32-bit VCVT{B,T}.BF16.F32. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/helper.h | 1 + target/arm/vfp.decode | 2 ++ target/arm/translate-a64.c | 19 +++++++++++++++++++ target/arm/translate-vfp.c | 24 ++++++++++++++++++++++++ target/arm/vfp_helper.c | 5 +++++ 5 files changed, 51 insertions(+) -- 2.25.1 diff --git a/target/arm/helper.h b/target/arm/helper.h index 23ccb0f72f..9977a827e9 100644 --- a/target/arm/helper.h +++ b/target/arm/helper.h @@ -143,6 +143,7 @@ DEF_HELPER_3(vfp_cmped, void, f64, f64, env) DEF_HELPER_2(vfp_fcvtds, f64, f32, env) DEF_HELPER_2(vfp_fcvtsd, f32, f64, env) +DEF_HELPER_FLAGS_2(bfcvt, TCG_CALL_NO_RWG, i32, f32, ptr) DEF_HELPER_2(vfp_uitoh, f16, i32, ptr) DEF_HELPER_2(vfp_uitos, f32, i32, ptr) diff --git a/target/arm/vfp.decode b/target/arm/vfp.decode index 6f7f28f9a4..52535d9b0b 100644 --- a/target/arm/vfp.decode +++ b/target/arm/vfp.decode @@ -205,6 +205,8 @@ VCVT_f64_f16 ---- 1110 1.11 0010 .... 1011 t:1 1.0 .... \ # VCVTB and VCVTT to f16: Vd format is always vd_sp; # Vm format depends on size bit +VCVT_b16_f32 ---- 1110 1.11 0011 .... 1001 t:1 1.0 .... \ + vd=%vd_sp vm=%vm_sp VCVT_f16_f32 ---- 1110 1.11 0011 .... 1010 t:1 1.0 .... \ vd=%vd_sp vm=%vm_sp VCVT_f16_f64 ---- 1110 1.11 0011 .... 1011 t:1 1.0 .... \ diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 510cb6ca5e..90605d7dce 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -6273,6 +6273,9 @@ static void handle_fp_1src_single(DisasContext *s, int opcode, int rd, int rn) case 0x3: /* FSQRT */ gen_helper_vfp_sqrts(tcg_res, tcg_op, cpu_env); goto done; + case 0x6: /* BFCVT */ + gen_fpst = gen_helper_bfcvt; + break; case 0x8: /* FRINTN */ case 0x9: /* FRINTP */ case 0xa: /* FRINTM */ @@ -6550,6 +6553,22 @@ static void disas_fp_1src(DisasContext *s, uint32_t insn) } break; + case 0x6: + switch (type) { + case 1: /* BFCVT */ + if (!dc_isar_feature(aa64_bf16, s)) { + goto do_unallocated; + } + if (!fp_access_check(s)) { + return; + } + handle_fp_1src_single(s, opcode, rd, rn); + break; + default: + goto do_unallocated; + } + break; + default: do_unallocated: unallocated_encoding(s); diff --git a/target/arm/translate-vfp.c b/target/arm/translate-vfp.c index 3da84f30a0..d8271dbaac 100644 --- a/target/arm/translate-vfp.c +++ b/target/arm/translate-vfp.c @@ -3025,6 +3025,30 @@ static bool trans_VCVT_f64_f16(DisasContext *s, arg_VCVT_f64_f16 *a) return true; } +static bool trans_VCVT_b16_f32(DisasContext *s, arg_VCVT_b16_f32 *a) +{ + TCGv_ptr fpst; + TCGv_i32 tmp; + + if (!dc_isar_feature(aa32_bf16, s)) { + return false; + } + + if (!vfp_access_check(s)) { + return true; + } + + fpst = fpstatus_ptr(FPST_FPCR); + tmp = tcg_temp_new_i32(); + + vfp_load_reg32(tmp, a->vm); + gen_helper_bfcvt(tmp, tmp, fpst); + tcg_gen_st16_i32(tmp, cpu_env, vfp_f16_offset(a->vd, a->t)); + tcg_temp_free_ptr(fpst); + tcg_temp_free_i32(tmp); + return true; +} + static bool trans_VCVT_f16_f32(DisasContext *s, arg_VCVT_f16_f32 *a) { TCGv_ptr fpst; diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c index 01b9d8557f..fe7a2a5daa 100644 --- a/target/arm/vfp_helper.c +++ b/target/arm/vfp_helper.c @@ -408,6 +408,11 @@ float32 VFP_HELPER(fcvts, d)(float64 x, CPUARMState *env) return float64_to_float32(x, &env->vfp.fp_status); } +uint32_t HELPER(bfcvt)(float32 x, void *status) +{ + return float32_to_bfloat16(x, status); +} + /* * VFP3 fixed point conversion. The AArch32 versions of fix-to-float * must always round-to-nearest; the AArch64 ones honour the FPSCR