From patchwork Sat Feb 17 18:23:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 128737 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp1856128ljc; Sat, 17 Feb 2018 11:28:09 -0800 (PST) X-Google-Smtp-Source: AH8x224gJ4rl1stn252/u2fnhm5nHk22T9eJStscJhClnDsWnWeTTONXiCLHuI3qEhepP6LeN5Pi X-Received: by 10.129.41.19 with SMTP id p19mr6434213ywp.233.1518895688979; Sat, 17 Feb 2018 11:28:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518895688; cv=none; d=google.com; s=arc-20160816; b=wA4jRuPHVUax7XMT+SACn5xCNXjNPq1kNoHlDLYV7OQrLxWcGLveK0l/auN241Sav6 kN5fU82ki7JDQ4ZxsXhYwcUqUDLGr1GuuOROk1kdPcz/oQl7qN4Xia/SqcYJRZTBKL9R wSWUZVqms/QSAG2emXUObm4L585WvnvpnesL1swXaC7yn0axE4sGFOFenDNPqX52A0GG Yhmri3TVxbXjdZwwTgFK2ATrCNZhmDi6EFXNgnIg/XxjHaBjjpuoX28skFLKl7Am5QbI ZPha6uzlTt9LMRE9HtSM3s+/zuj3PDiU36J2SFDD4gLq663U5LtTVQZK2GRt5t3Lql38 QNww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=TYEkgvQ2lsVeGMILIUd+qlGVon1fvaQFWVsi7XMK5X8=; b=OPw95+fc3mrCsyQMjKtYsb0Re7dEbkqmU1qh6IMm5l+D7gKn7WOe20AHQXh098tDo7 /GEn9v4JmNaYj70Cn8+ifVwakDuZ79wuR7cHH/2xJ4w5OHokosDG+HjFEV+NDKKmBBGE ZXmer03bdTYIPzq6fdSMQacPoJEF72AXOFjKNRofNzAUnarr5Rr09ZdH5YEw/aOljUcF ocYip2ZOIhLFfYXr60VdmLBG4qcSIUbwip3QKrQV52w+idjQNHMPX+ALpbobTh3F7/0X QCniZOu1VD7pqROZ7paKWLLLjTiBVGwvY7fUIjfRVFrqbPv7Ek5zuK3OOiJ95A/xsvyC I4xA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=OENPRN3p; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id q10si3526476ybj.227.2018.02.17.11.28.08 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 17 Feb 2018 11:28:08 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=OENPRN3p; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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]:50397 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1en89Y-0005tI-8m for patch@linaro.org; Sat, 17 Feb 2018 14:28:08 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41143) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1en7Ai-00025v-8T for qemu-devel@nongnu.org; Sat, 17 Feb 2018 13:25:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1en7Ag-0002Nl-Rc for qemu-devel@nongnu.org; Sat, 17 Feb 2018 13:25:16 -0500 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:39714) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1en7Ag-0002NM-6v for qemu-devel@nongnu.org; Sat, 17 Feb 2018 13:25:14 -0500 Received: by mail-pg0-x241.google.com with SMTP id w17so4356781pgv.6 for ; Sat, 17 Feb 2018 10:25:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=TYEkgvQ2lsVeGMILIUd+qlGVon1fvaQFWVsi7XMK5X8=; b=OENPRN3pDjBKPI8A6Li+DqhGVkcnN9QW73M2G8HKfYT4u72VfuhXjXtj/acxisha3p uld55SKBHwa3xpQbopJgeFGwDMFhZbfngDXiMGwRy4KnqqKGuRZZ13HTiLrtFVU7z1rC /yeQrfM72KiWHSsLT1Rjdp9PZZtjQPOQZQigk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=TYEkgvQ2lsVeGMILIUd+qlGVon1fvaQFWVsi7XMK5X8=; b=uhcRc7JCllQfDsulEr6AmpxjvyUzYP0aPrGGyj63N0WU3bV3onufPlpeT+6Jy8jTRk rQDBY+hTeHSPiKgF4gk0CnXHf93N9skQ1VOQoeNj4AnOy/6zTspiFwvy56olPRiJ7+9R Al6gOH4Ch3r71EPePVK8NShP5w5kBeCBY1llsb7QMitt3NMBrqO2PfUY8tGBTbbBhu2K UCJyLNE/JCeXuhpCfu33TGYF5/QB7LidgS76RerSwmuyBS7C8V7aNNNic5hw4h2apYJr LkAf5cOuVA+SSeXb4O3nyJpLvtj22oB0p+jx5kN9dMa1qkLekzNweS04E5hbpe+EoWiq 5UYw== X-Gm-Message-State: APf1xPCVHuyyTKn/HC5vFbEvrLdqLry+stIRlyRhGLm66xf3fA9OgRnV XRS7EPgC2NsFl64TyxREUmo/K2gbx8w= X-Received: by 10.99.146.3 with SMTP id o3mr8292115pgd.309.1518891912866; Sat, 17 Feb 2018 10:25:12 -0800 (PST) Received: from cloudburst.twiddle.net ([50.0.192.64]) by smtp.gmail.com with ESMTPSA id h15sm13466712pfi.56.2018.02.17.10.25.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 17 Feb 2018 10:25:11 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 17 Feb 2018 10:23:22 -0800 Message-Id: <20180217182323.25885-67-richard.henderson@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180217182323.25885-1-richard.henderson@linaro.org> References: <20180217182323.25885-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::241 Subject: [Qemu-devel] [PATCH v2 66/67] target/arm: Implement SVE floating-point round to integral value X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-arm@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- target/arm/helper-sve.h | 14 ++++++++ target/arm/sve_helper.c | 8 +++++ target/arm/translate-sve.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++ target/arm/sve.decode | 9 ++++++ 4 files changed, 111 insertions(+) -- 2.14.3 Reviewed-by: Peter Maydell diff --git a/target/arm/helper-sve.h b/target/arm/helper-sve.h index 0f5fea9045..749bab0b38 100644 --- a/target/arm/helper-sve.h +++ b/target/arm/helper-sve.h @@ -985,6 +985,20 @@ DEF_HELPER_FLAGS_5(sve_fcvtzu_sd, TCG_CALL_NO_RWG, DEF_HELPER_FLAGS_5(sve_fcvtzu_dd, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_5(sve_frint_h, TCG_CALL_NO_RWG, + void, ptr, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_5(sve_frint_s, TCG_CALL_NO_RWG, + void, ptr, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_5(sve_frint_d, TCG_CALL_NO_RWG, + void, ptr, ptr, ptr, ptr, i32) + +DEF_HELPER_FLAGS_5(sve_frintx_h, TCG_CALL_NO_RWG, + void, ptr, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_5(sve_frintx_s, TCG_CALL_NO_RWG, + void, ptr, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_5(sve_frintx_d, TCG_CALL_NO_RWG, + void, ptr, ptr, ptr, ptr, i32) + DEF_HELPER_FLAGS_5(sve_scvt_hh, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32) DEF_HELPER_FLAGS_5(sve_scvt_sh, TCG_CALL_NO_RWG, diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c index 09f5c77254..7950710be7 100644 --- a/target/arm/sve_helper.c +++ b/target/arm/sve_helper.c @@ -3200,6 +3200,14 @@ DO_ZPZ_FP_D(sve_fcvtzu_sd, uint64_t, float32_to_uint64_round_to_zero) DO_ZPZ_FP_D(sve_fcvtzu_ds, uint64_t, float64_to_uint32_round_to_zero) DO_ZPZ_FP_D(sve_fcvtzu_dd, uint64_t, float64_to_uint64_round_to_zero) +DO_ZPZ_FP(sve_frint_h, uint16_t, H1_2, helper_advsimd_rinth) +DO_ZPZ_FP(sve_frint_s, uint32_t, H1_4, helper_rints) +DO_ZPZ_FP_D(sve_frint_d, uint64_t, helper_rintd) + +DO_ZPZ_FP(sve_frintx_h, uint16_t, H1_2, float16_round_to_int) +DO_ZPZ_FP(sve_frintx_s, uint32_t, H1_4, float32_round_to_int) +DO_ZPZ_FP_D(sve_frintx_d, uint64_t, float64_round_to_int) + DO_ZPZ_FP(sve_scvt_hh, uint16_t, H1_2, int16_to_float16) DO_ZPZ_FP(sve_scvt_sh, uint32_t, H1_4, int32_to_float16) DO_ZPZ_FP(sve_scvt_ss, uint32_t, H1_4, int32_to_float32) diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c index bc865dfd15..5f1c4984b8 100644 --- a/target/arm/translate-sve.c +++ b/target/arm/translate-sve.c @@ -3751,6 +3751,86 @@ static void trans_FCVTZU_dd(DisasContext *s, arg_rpr_esz *a, uint32_t insn) do_zpz_ptr(s, a->rd, a->rn, a->pg, false, gen_helper_sve_fcvtzu_dd); } +static gen_helper_gvec_3_ptr * const frint_fns[3] = { + gen_helper_sve_frint_h, + gen_helper_sve_frint_s, + gen_helper_sve_frint_d +}; + +static void trans_FRINTI(DisasContext *s, arg_rpr_esz *a, uint32_t insn) +{ + if (a->esz == 0) { + unallocated_encoding(s); + } else { + do_zpz_ptr(s, a->rd, a->rn, a->pg, a->esz == MO_16, + frint_fns[a->esz - 1]); + } +} + +static void trans_FRINTX(DisasContext *s, arg_rpr_esz *a, uint32_t insn) +{ + static gen_helper_gvec_3_ptr * const fns[3] = { + gen_helper_sve_frintx_h, + gen_helper_sve_frintx_s, + gen_helper_sve_frintx_d + }; + if (a->esz == 0) { + unallocated_encoding(s); + } else { + do_zpz_ptr(s, a->rd, a->rn, a->pg, a->esz == MO_16, fns[a->esz - 1]); + } +} + +static void do_frint_mode(DisasContext *s, arg_rpr_esz *a, int mode) +{ + unsigned vsz = vec_full_reg_size(s); + TCGv_i32 tmode; + TCGv_ptr status; + + if (a->esz == 0) { + unallocated_encoding(s); + return; + } + + tmode = tcg_const_i32(mode); + status = get_fpstatus_ptr(a->esz == MO_16); + gen_helper_set_rmode(tmode, tmode, status); + + tcg_gen_gvec_3_ptr(vec_full_reg_offset(s, a->rd), + vec_full_reg_offset(s, a->rn), + pred_full_reg_offset(s, a->pg), + status, vsz, vsz, 0, frint_fns[a->esz - 1]); + + gen_helper_set_rmode(tmode, tmode, status); + tcg_temp_free_i32(tmode); + tcg_temp_free_ptr(status); +} + +static void trans_FRINTN(DisasContext *s, arg_rpr_esz *a, uint32_t insn) +{ + do_frint_mode(s, a, float_round_nearest_even); +} + +static void trans_FRINTP(DisasContext *s, arg_rpr_esz *a, uint32_t insn) +{ + do_frint_mode(s, a, float_round_up); +} + +static void trans_FRINTM(DisasContext *s, arg_rpr_esz *a, uint32_t insn) +{ + do_frint_mode(s, a, float_round_down); +} + +static void trans_FRINTZ(DisasContext *s, arg_rpr_esz *a, uint32_t insn) +{ + do_frint_mode(s, a, float_round_to_zero); +} + +static void trans_FRINTA(DisasContext *s, arg_rpr_esz *a, uint32_t insn) +{ + do_frint_mode(s, a, float_round_ties_away); +} + static void trans_SCVTF_hh(DisasContext *s, arg_rpr_esz *a, uint32_t insn) { do_zpz_ptr(s, a->rd, a->rn, a->pg, true, gen_helper_sve_scvt_hh); diff --git a/target/arm/sve.decode b/target/arm/sve.decode index 92dda3a241..e06c0c5279 100644 --- a/target/arm/sve.decode +++ b/target/arm/sve.decode @@ -848,6 +848,15 @@ FCVTZU_sd 01100101 11 011 10 1 101 ... ..... ..... @rd_pg_rn_e0 FCVTZS_dd 01100101 11 011 11 0 101 ... ..... ..... @rd_pg_rn_e0 FCVTZU_dd 01100101 11 011 11 1 101 ... ..... ..... @rd_pg_rn_e0 +# SVE floating-point round to integral value +FRINTN 01100101 .. 000 000 101 ... ..... ..... @rd_pg_rn +FRINTP 01100101 .. 000 001 101 ... ..... ..... @rd_pg_rn +FRINTM 01100101 .. 000 010 101 ... ..... ..... @rd_pg_rn +FRINTZ 01100101 .. 000 011 101 ... ..... ..... @rd_pg_rn +FRINTA 01100101 .. 000 100 101 ... ..... ..... @rd_pg_rn +FRINTX 01100101 .. 000 110 101 ... ..... ..... @rd_pg_rn +FRINTI 01100101 .. 000 111 101 ... ..... ..... @rd_pg_rn + # SVE integer convert to floating-point SCVTF_hh 01100101 01 010 01 0 101 ... ..... ..... @rd_pg_rn_e0 SCVTF_sh 01100101 01 010 10 0 101 ... ..... ..... @rd_pg_rn_e0