From patchwork Thu Jun 21 01:53:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 139425 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1483294lji; Wed, 20 Jun 2018 19:14:51 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJljfSWCgcUQQ1e1Oth9dvsIoK4tDCHR6If/8WxZzmqNq7zwm9XbyySCHZ0fxZ0Ob4gT9qX X-Received: by 2002:aed:25cb:: with SMTP id y11-v6mr21365585qtc.333.1529547291022; Wed, 20 Jun 2018 19:14:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529547291; cv=none; d=google.com; s=arc-20160816; b=VWM9CWqyssffaCUmoyOUui+e5EoxsdsYSgmYHANsrhKADs2MLHEa81x3qo+DaJYy1v YX6+3evDEghQeoFzcEioFcpNO4wi0QYHVizIr32lZ3Tm8s/aa2lZdejSJ5pxjVjiRGbI QdY8wGzS1GGHg7lvYUT4BjlPUphEDRpZN5AV87gppeYVx6AURU+62ubLzx/LmTOfxn8H 5SHhOLfKU48mEMAII7TEdCfNpLaZlfxKv7BaoYmh+ExbqUHAxL27yKqdYdIe7uAhItxF 3LdpfGF+ctBv5OSGLWxoAL1Q4xFIGT509Tp1VDzNgAlSNPngEFktE7DmYvwzPPmQ82H0 xWHQ== 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=QIBCwmPy3yQFPEkh4dvSFFLAvuGXcxOXoxq2dHESWn8=; b=TBHpZy8GZuvMxtBHXvhGD9Bk+VjVitpsrj9bVQhmMXaCAvbomLILtNlyfu+ZFUadWe pcUkv1VxRv0gik27HvHAXcOT7L2kffCMohbmoqXPvaOlxnZIfx6AnEq7bArIlsuHvnX5 h6Q5X/a8V+ju5NN9DxxPyB4ApJogeb1gi/ku3yPIFgEVPv/z3nFFoMoccZ2yYJe+fP/g hHuYlG1bPPhrZEUyl+lvyeS9DC8aCa9fWWt7UEmtBI0azmWZdHCH1a2+OTfHOS8d1cYU epIdn9SNQYFKiEnwvEE6wLx5f3qiP8eCy/oakILJR1kRoIFoquu/42EqckMETf9GP29n Gl6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Ek5cy461; 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 h46-v6si3405156qth.404.2018.06.20.19.14.50 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 20 Jun 2018 19:14:51 -0700 (PDT) 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=Ek5cy461; 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]:52583 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fVp7a-00030R-H8 for patch@linaro.org; Wed, 20 Jun 2018 22:14:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39417) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fVooK-0004lG-5v for qemu-devel@nongnu.org; Wed, 20 Jun 2018 21:55:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fVooI-0003OZ-U0 for qemu-devel@nongnu.org; Wed, 20 Jun 2018 21:54:56 -0400 Received: from mail-pg0-x22d.google.com ([2607:f8b0:400e:c05::22d]:36153) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fVooI-0003O6-LC for qemu-devel@nongnu.org; Wed, 20 Jun 2018 21:54:54 -0400 Received: by mail-pg0-x22d.google.com with SMTP id m5-v6so647544pgd.3 for ; Wed, 20 Jun 2018 18:54:54 -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; bh=QIBCwmPy3yQFPEkh4dvSFFLAvuGXcxOXoxq2dHESWn8=; b=Ek5cy461GCteWjNZEZ4h8VxhkYlxZpZFz6sBIoWOWbxKs/Muui3X9hvs/WNjeB0ZG1 as7Ck+Z2hRa363uvHF0LkkU+fjgdUOV9Zd//CShEw0AJhxBcGif+scg/H+Izs4D/QNV2 sSFuaQ4QR4jgdQ8s5lUfYlu2W2HWihXR3SSDg= 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=QIBCwmPy3yQFPEkh4dvSFFLAvuGXcxOXoxq2dHESWn8=; b=lnPP407+rDxRNxQy1ZfotS2WAXRVWTnkivpr/I1rLp5aK8LmVrrOOGPys1aMS0hm1+ MUwpte4Xxibw2D48QiK5+1JyTq07l7yCNBZ1px8UorGOI6kbDfO0vhPlTzfykFVUaiMe rBINQYiKi+/DSuTjJhaL8do0SzK87j6Vc5iuSqlxN/qozIb2UA3+awQvOc31d1iyXvea WPCp3VhsItMJFmr3W1zqEJXjr24OPvPDPE8ecI93W6M56qtz1IshcLSGvlj6P9Ebp4uf /pIELLZrkh2qMaNzV3TcTpqW4p0381y+BHXShu0k5rzGUkE/A9/rShGRfr2Gd0jjZh9+ I3TA== X-Gm-Message-State: APt69E3P2MIYWLrj+3tBZmYthJPTvRyG7dGJcRl+WKY6hNxZ+oQyD2GW ebEjAswuC2uf5kAr/EiHGx4q/CFK+cI= X-Received: by 2002:a63:8048:: with SMTP id j69-v6mr21062875pgd.429.1529546093325; Wed, 20 Jun 2018 18:54:53 -0700 (PDT) Received: from cloudburst.twiddle.net (mta-98-147-121-51.hawaii.rr.com. [98.147.121.51]) by smtp.gmail.com with ESMTPSA id a27-v6sm6187946pfc.18.2018.06.20.18.54.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Jun 2018 18:54:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 20 Jun 2018 15:53:49 -1000 Message-Id: <20180621015359.12018-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180621015359.12018-1-richard.henderson@linaro.org> References: <20180621015359.12018-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::22d Subject: [Qemu-devel] [PATCH v5 25/35] 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: peter.maydell@linaro.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 | 77 ++++++++++++++++++++++++++++++++++++++ target/arm/sve.decode | 9 +++++ 4 files changed, 108 insertions(+) -- 2.17.1 Reviewed-by: Peter Maydell diff --git a/target/arm/helper-sve.h b/target/arm/helper-sve.h index 37fa9eb9bb..36168c5bb2 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 497efbf3a8..3b7a2f58c1 100644 --- a/target/arm/sve_helper.c +++ b/target/arm/sve_helper.c @@ -3262,6 +3262,14 @@ DO_ZPZ_FP(sve_fcvtzu_sd, uint64_t, , vfp_float32_to_uint64_rtz) DO_ZPZ_FP(sve_fcvtzu_ds, uint64_t, , helper_vfp_touizd) DO_ZPZ_FP(sve_fcvtzu_dd, uint64_t, , vfp_float64_to_uint64_rtz) +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(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(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 fd94c5337e..15e4f2888b 100644 --- a/target/arm/translate-sve.c +++ b/target/arm/translate-sve.c @@ -4040,6 +4040,83 @@ static bool trans_FCVTZU_dd(DisasContext *s, arg_rpr_esz *a, uint32_t insn) return 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 bool trans_FRINTI(DisasContext *s, arg_rpr_esz *a, uint32_t insn) +{ + if (a->esz == 0) { + return false; + } + return do_zpz_ptr(s, a->rd, a->rn, a->pg, a->esz == MO_16, + frint_fns[a->esz - 1]); +} + +static bool 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) { + return false; + } + return do_zpz_ptr(s, a->rd, a->rn, a->pg, a->esz == MO_16, fns[a->esz - 1]); +} + +static bool do_frint_mode(DisasContext *s, arg_rpr_esz *a, int mode) +{ + if (a->esz == 0) { + return false; + } + if (sve_access_check(s)) { + unsigned vsz = vec_full_reg_size(s); + TCGv_i32 tmode = tcg_const_i32(mode); + TCGv_ptr 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); + } + return true; +} + +static bool trans_FRINTN(DisasContext *s, arg_rpr_esz *a, uint32_t insn) +{ + return do_frint_mode(s, a, float_round_nearest_even); +} + +static bool trans_FRINTP(DisasContext *s, arg_rpr_esz *a, uint32_t insn) +{ + return do_frint_mode(s, a, float_round_up); +} + +static bool trans_FRINTM(DisasContext *s, arg_rpr_esz *a, uint32_t insn) +{ + return do_frint_mode(s, a, float_round_down); +} + +static bool trans_FRINTZ(DisasContext *s, arg_rpr_esz *a, uint32_t insn) +{ + return do_frint_mode(s, a, float_round_to_zero); +} + +static bool trans_FRINTA(DisasContext *s, arg_rpr_esz *a, uint32_t insn) +{ + return do_frint_mode(s, a, float_round_ties_away); +} + static bool trans_SCVTF_hh(DisasContext *s, arg_rpr_esz *a, uint32_t insn) { return 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 c4597d4fbe..eeab3d485f 100644 --- a/target/arm/sve.decode +++ b/target/arm/sve.decode @@ -840,6 +840,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