From nobody Mon Feb 9 23:40:37 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513623243844662.8867868111997; Mon, 18 Dec 2017 10:54:03 -0800 (PST) Received: from localhost ([::1]:54113 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eR0Y6-0003Jw-Of for importer@patchew.org; Mon, 18 Dec 2017 13:54:02 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56129) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eQzUn-00005M-1l for qemu-devel@nongnu.org; Mon, 18 Dec 2017 12:46:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eQzUl-0002PO-Q8 for qemu-devel@nongnu.org; Mon, 18 Dec 2017 12:46:33 -0500 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]:46629) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eQzUl-0002OU-IF for qemu-devel@nongnu.org; Mon, 18 Dec 2017 12:46:31 -0500 Received: by mail-pg0-x243.google.com with SMTP id b11so9422099pgu.13 for ; Mon, 18 Dec 2017 09:46:31 -0800 (PST) Received: from cloudburst.twiddle.net (174-21-7-63.tukw.qwest.net. [174.21.7.63]) by smtp.gmail.com with ESMTPSA id t84sm26209657pfe.160.2017.12.18.09.46.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Dec 2017 09:46:29 -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=ZcsLWJR9s9Z/s+Guhqhn6UX16Gk3jGYweos2BoYqHw0=; b=BVnIZh9uEK9fHJyR8NJySHlHo4MFGfJlzf7nR+Y78ASS9/Z5WbQOzuR8vL/7fTxs8I QfT1pgkaIqWeZOkl5AMjq87p8tDHlOLk7qSIZqYfHJsi31J09OeV8cBEBEEc4VKT10kV A5EureNlLIhYJMhQrOer0urk3q8yXu0DPVa6w= 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=ZcsLWJR9s9Z/s+Guhqhn6UX16Gk3jGYweos2BoYqHw0=; b=mzJefX+9jlQq2WZgVoulgop0FGhgQrZ3iJR2I+Sc7UAMiq5wTZZb6ZFxmHRvyDPv/u tIGdCfxbnFNi1F4x0u7s8nPKYS25esEr1QgQQYUuLox1OlHixZ8dEEthmUW++8gECwhy U3Cmr7kxrmhmKbvcFfHwyGr7iAYm3bJCBSiVErBqSvG7B/i+te8Bo6WVW3bHFP/EJX7m LtdbkfNKGBWAs13uVM6D2tDmVlyNXKNEB1yS3kjiFarkklfOvcil0Ya1s6GztXQ5bZr1 IWkgDJB966g6CodnycJ7aY0Gpavwy1on8kdD8/OV9P1JvXN/++Ehy1vjwuPKJ+ykTv+G /DJg== X-Gm-Message-State: AKGB3mJyZsoNUQCiwRRJN9sh8aTuX++nJkFeABx9Gj8pSo/PnBfWMpz7 3EUa4DFUfpkDARvVLQi50NGx4LMpbwM= X-Google-Smtp-Source: ACJfBov6LgaY6UgeL0uaWe94mtHpYcm+28hfyYHUdp+hCglgFEhBS2JiAaUUHcO07VMSULBbrsCVeA== X-Received: by 10.98.51.6 with SMTP id z6mr502052pfz.34.1513619190092; Mon, 18 Dec 2017 09:46:30 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 18 Dec 2017 09:45:52 -0800 Message-Id: <20171218174552.18871-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171218174552.18871-1-richard.henderson@linaro.org> References: <20171218174552.18871-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::243 Subject: [Qemu-devel] [PATCH 23/23] target/arm: Implement SVE Element Count Group, register destinations 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, qemu-arm@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson --- target/arm/translate-sve.c | 103 +++++++++++++++++++++++++++++++++++++++++= ++++ target/arm/sve.def | 18 ++++++++ 2 files changed, 121 insertions(+) diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c index a6c31e0e9c..91eb4e797a 100644 --- a/target/arm/translate-sve.c +++ b/target/arm/translate-sve.c @@ -61,6 +61,11 @@ static int tszimm_shl(int x) return x - tszimm_esz(x); } =20 +static inline int plus1(int x) +{ + return x + 1; +} + /* * Include the generated decoder. */ @@ -815,6 +820,104 @@ static unsigned decode_pred_count(unsigned fullsz, in= t pattern, int esz) } } =20 +void trans_CNT_r(DisasContext *s, arg_CNT_r *a, uint32_t insn) +{ + unsigned fullsz =3D vec_full_reg_size(s); + unsigned numelem =3D decode_pred_count(fullsz, a->pat, a->esz); + + tcg_gen_movi_i64(cpu_reg(s, a->rd), numelem * a->imm); +} + +void trans_INC_DEC_r(DisasContext *s, arg_incdec_cnt *a, uint32_t insn) +{ + unsigned fullsz =3D vec_full_reg_size(s); + unsigned numelem =3D decode_pred_count(fullsz, a->pat, a->esz); + int inc =3D numelem * a->imm * (a->d ? -1 : 1); + TCGv_i64 reg =3D cpu_reg(s, a->rd); + + tcg_gen_addi_i64(reg, reg, inc); +} + +void trans_sat_INC_DEC_r_32(DisasContext *s, arg_incdec_cnt *a, uint32_t i= nsn) +{ + unsigned fullsz =3D vec_full_reg_size(s); + unsigned numelem =3D decode_pred_count(fullsz, a->pat, a->esz); + int inc =3D numelem * a->imm * (a->d ? -1 : 1); + int64_t ibound; + TCGv_i64 reg =3D cpu_reg(s, a->rd); + TCGv_i64 bound; + TCGCond cond; + + /* Use normal 64-bit arithmetic to detect 32-bit overflow. */ + if (a->u) { + tcg_gen_ext32u_i64(reg, reg); + } else { + tcg_gen_ext32s_i64(reg, reg); + } + tcg_gen_addi_i64(reg, reg, inc); + if (a->d) { + if (a->u) { + ibound =3D 0; + cond =3D TCG_COND_LTU; + } else { + ibound =3D INT32_MIN; + cond =3D TCG_COND_LT; + } + } else { + if (a->u) { + ibound =3D UINT32_MAX; + cond =3D TCG_COND_GTU; + } else { + ibound =3D INT32_MAX; + cond =3D TCG_COND_GT; + } + } + bound =3D tcg_const_i64(ibound); + tcg_gen_movcond_i64(cond, reg, reg, bound, bound, reg); + tcg_temp_free_i64(bound); +} + +void trans_sat_INC_DEC_r_64(DisasContext *s, arg_incdec_cnt *a, uint32_t i= nsn) +{ + unsigned fullsz =3D vec_full_reg_size(s); + unsigned numelem =3D decode_pred_count(fullsz, a->pat, a->esz); + int inc =3D numelem * a->imm * (a->d ? -1 : 1); + TCGv_i64 reg =3D cpu_reg(s, a->rd); + TCGv_i64 t0 =3D tcg_temp_new_i64(); + TCGv_i64 t1 =3D tcg_temp_new_i64(); + TCGv_i64 zero; + + if (a->u) { + tcg_gen_addi_i64(t0, reg, inc); + + /* Bound the result. */ + if (a->d) { + tcg_gen_movi_i64(t1, 0); + tcg_gen_movcond_i64(TCG_COND_LTU, reg, t0, reg, t0, t1); + } else { + tcg_gen_movi_i64(t1, -1); + tcg_gen_movcond_i64(TCG_COND_LTU, reg, reg, t0, t0, t1); + } + } else { + /* Detect signed overflow for addition. */ + tcg_gen_xori_i64(t0, reg, inc); + tcg_gen_addi_i64(reg, reg, inc); + tcg_gen_xori_i64(t0, reg, inc); + tcg_gen_andc_i64(t0, t1, t0); + + /* Because we know the increment, we know which way it overflowed.= */ + tcg_gen_movi_i64(t1, a->d ? INT64_MIN : INT64_MAX); + + /* Bound the result. */ + zero =3D tcg_const_i64(0); + tcg_gen_movcond_i64(TCG_COND_LT, reg, t0, zero, t1, reg); + + tcg_temp_free_i64(zero); + } + tcg_temp_free_i64(t0); + tcg_temp_free_i64(t1); +} + /* For PTRUE, PTRUES, PFALSE, SETFFR. */ void trans_pred_set(DisasContext *s, arg_pred_set *a, uint32_t insn) { diff --git a/target/arm/sve.def b/target/arm/sve.def index df2730eb73..da533ba666 100644 --- a/target/arm/sve.def +++ b/target/arm/sve.def @@ -24,6 +24,7 @@ =20 %imm9_16_10 16:s6 10:3 %imm6_22_5 22:1 5:5 +%imm4_16_p1 16:4 !function=3Dplus1 =20 # A combination of tsz:imm3 -- extract esize. %tszimm_esz 22:2 5:5 !function=3Dtszimm_esz @@ -56,6 +57,7 @@ &rprrr_esz rd pg rn rm ra esz &rpri_esz rd pg rn imm esz &pred_set rd pat esz i s +&incdec_cnt rd pat esz imm d u =20 ########################################################################### # Named instruction formats. These are generally used to @@ -101,6 +103,10 @@ @pd_rn_i9 ........ ........ ...... rn:5 . rd:4 &rri imm=3D%imm9_16_10 @rd_rn_i9 ........ ........ ...... rn:5 rd:5 &rri imm=3D%imm9_16_10 =20 +# One register, pattern, and uint4+1. +# User must fill in U and D. +@incdec_cnt ........ esz:2 .. .... ...... pat:5 rd:5 &incdec_cnt imm=3D%i= mm4_16_p1 + ########################################################################### # Instruction patterns. Grouped according to the SVE encodingindex.xhtml. =20 @@ -275,6 +281,18 @@ FEXPA 00000100 .. 1 00000 101110 ..... ..... @rd_rn= _esz # Note size !=3D 0 # SVE floating-point trig select coefficient FTSSEL 00000100 .. 1 ..... 101100 ..... ..... @rd_rn_rm_esz # Note size= !=3D 0 =20 +### SVE Element Count Group + +# SVE element count +CNT_r 00000100 .. 10 .... 1110 0 0 ..... ..... @incdec_cnt d=3D0 u= =3D1 + +# SVE inc/dec register by element count +INC_DEC_r 00000100 .. 11 .... 1110 0 d:1 ..... ..... @incdec_cnt u=3D1 + +# SVE saturating inc/dec register by element count +sat_INC_DEC_r_32 00000100 .. 10 .... 1111 d:1 u:1 ..... ..... @incdec_cnt +sat_INC_DEC_r_64 00000100 .. 11 .... 1111 d:1 u:1 ..... ..... @incdec_cnt + ### SVE Predicate Generation Group =20 # SVE initialize predicate (PTRUE, PTRUES) --=20 2.14.3