From nobody Tue Oct 28 21:08:59 2025 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 15136225538611006.5546533563565; Mon, 18 Dec 2017 10:42:33 -0800 (PST) Received: from localhost ([::1]:52232 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eR0Mv-0007ix-Bt for importer@patchew.org; Mon, 18 Dec 2017 13:42:29 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55508) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eQzUK-00083P-70 for qemu-devel@nongnu.org; Mon, 18 Dec 2017 12:46:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eQzUI-0001pM-6x for qemu-devel@nongnu.org; Mon, 18 Dec 2017 12:46:04 -0500 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:35853) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eQzUH-0001oV-V8 for qemu-devel@nongnu.org; Mon, 18 Dec 2017 12:46:02 -0500 Received: by mail-pf0-x241.google.com with SMTP id p84so9976341pfd.3 for ; Mon, 18 Dec 2017 09:46:01 -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.45.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Dec 2017 09:45:59 -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=zOMNyAcRduqLy3rPHjhFl619bBAjJ5WdPzQQou1JeW8=; b=aV3hinnEjUUyGOCP6X/9vCfCQESge3iMy7lsox0hE4O7mk+34aW4Rf3kVCsOO/zKZm 7/UTJgS86mSZWKgxrSiI/9p1feh0lxFiPJ+H3CbG0te+wqRdPyVj7vg8tRErr8RB1itQ cuEFvPy3a2bX++YMvPmn59Uw/bJ4syGg7mcX4= 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=zOMNyAcRduqLy3rPHjhFl619bBAjJ5WdPzQQou1JeW8=; b=Jtcaq+ZDSMNtNgyF17TSKliOSraDXlotNP5/Jby/qL4NV8DvVk6Dlxew+cRvXga4NV Oc5nah9o7T1SsSupWTINPjPHDsCJ5jiAhJduohU8pT7Tupoy153eUqgZlwQdu+JqgHbP pLGwob4ir97RYXG85u3E9atd4WB6c2s/Bx3lhw77XZxlWEdYACjArtGozVA/Y3pPO+4x FsnI1dizUEWeWUJBBCDhUkpV/pjphRr8kBxilzZ2vHc120xsQAST7K5Ds1h5i6z0nH6B Cw9PnmXrtCij6J2LBWPxXqw5O2XZeukvJYzLDG9orHmetVTfDpx7hqzygv+xXiWpP7xj RSsw== X-Gm-Message-State: AKGB3mI5gYQwTX8x2Fx0z+nLFicrapTCin3FwWWAXRKQ7UQ7QhIt0Is5 90fgh5qcddDC6IR0ypsc4CoC/60nCvc= X-Google-Smtp-Source: ACJfBoscLhzZ+3T3kdFuVNTSgu9v0FyQTAk567OrxBvAuNA5Ku0DpFgSsUqebl2dePpdorOiJLmWug== X-Received: by 10.99.125.69 with SMTP id m5mr389166pgn.415.1513619160510; Mon, 18 Dec 2017 09:46:00 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 18 Dec 2017 09:45:33 -0800 Message-Id: <20171218174552.18871-5-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:c00::241 Subject: [Qemu-devel] [PATCH 04/23] target/arm: Implement PTRUE, PFALSE, SETFFR 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 | 117 +++++++++++++++++++++++++++++++++++++++++= ++++ target/arm/sve.def | 12 +++++ 2 files changed, 129 insertions(+) diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c index 43420fa124..fabf6f0a67 100644 --- a/target/arm/translate-sve.c +++ b/target/arm/translate-sve.c @@ -99,3 +99,120 @@ void trans_BIC_zzz(DisasContext *s, arg_BIC_zzz *a, uin= t32_t insn) { do_zzz_genfn(s, a, tcg_gen_gvec_andc); } + +static uint64_t pred_esz_mask[4] =3D { + 0xffffffffffffffffull, 0x5555555555555555ull, + 0x1111111111111111ull, 0x0101010101010101ull +}; + +/* See the ARM pseudocode DecodePredCount. */ +static unsigned decode_pred_count(unsigned fullsz, int pattern, int esz) +{ + unsigned elements =3D fullsz >> esz; + + switch (pattern) { + case 0x0: /* POW2 */ + return pow2floor(elements); + case 0x1: /* VL1 */ + case 0x2: /* VL2 */ + case 0x3: /* VL3 */ + case 0x4: /* VL4 */ + case 0x5: /* VL5 */ + case 0x6: /* VL6 */ + case 0x7: /* VL7 */ + case 0x8: /* VL8 */ + return MIN(pattern, elements); + case 0x9: /* VL16 */ + case 0xa: /* VL32 */ + case 0xb: /* VL64 */ + case 0xc: /* VL128 */ + case 0xd: /* VL256 */ + return MIN(16 << (pattern - 9), elements); + case 0x1d: /* MUL4 */ + return elements - elements % 4; + case 0x1e: /* MUL3 */ + return elements - elements % 3; + case 0x1f: /* ALL */ + return elements; + default: /* #uimm5 */ + return 0; + } +} + +/* For PTRUE, PTRUES, PFALSE, SETFFR. */ +void trans_pred_set(DisasContext *s, arg_pred_set *a, uint32_t insn) +{ + unsigned fullsz =3D vec_full_reg_size(s); + unsigned numelem, setsz, setalign, allalign, ofs; + uint64_t word, lastword; + TCGv_i64 t; + + numelem =3D decode_pred_count(fullsz, a->pat, a->esz); + + /* Determine what we must store into each bit, and how many. */ + if (numelem =3D=3D 0 || a->i =3D=3D 0) { + lastword =3D word =3D 0; + setsz =3D fullsz; + } else { + setsz =3D numelem << a->esz; + lastword =3D word =3D pred_esz_mask[a->esz]; + if (setsz % 64) { + lastword &=3D ~(-1ull << (setsz % 64)); + } + } + + /* Rescale from bits to bytes. */ + fullsz /=3D 8; + setsz /=3D 8; + + ofs =3D pred_full_reg_offset(s, a->rd); + setalign =3D QEMU_ALIGN_DOWN(setsz, 8); + allalign =3D QEMU_ALIGN_UP(fullsz, 16); + + /* Perform the stores. Use the vector infrastructure if the sizes + are large enough. */ + if (fullsz > 8) { + if (setsz >=3D 16 && setsz % 16 =3D=3D 0) { + tcg_gen_gvec_dup64i(ofs, setsz, allalign, word); + } else if (setsz <=3D 8 && fullsz > 16) { + tcg_gen_gvec_dup64i(ofs, allalign, allalign, 0); + } else if (fullsz - setsz <=3D 8 && fullsz > 16) { + tcg_gen_gvec_dup64i(ofs, allalign, allalign, word); + } else { + unsigned i =3D 0; + + t =3D tcg_temp_new_i64(); + if (setalign > 0) { + tcg_gen_movi_i64(t, word); + for (; i < setalign; i +=3D 8) { + tcg_gen_st_i64(t, cpu_env, ofs + i); + } + } + if (lastword !=3D word) { + tcg_gen_movi_i64(t, lastword); + tcg_gen_st_i64(t, cpu_env, ofs + i); + i +=3D 8; + } + if (i < fullsz) { + tcg_gen_movi_i64(t, 0); + for (; i < fullsz; i +=3D 8) { + tcg_gen_st_i64(t, cpu_env, ofs + i); + } + } + tcg_temp_free_i64(t); + goto done; + } + } + t =3D tcg_const_i64(lastword); + tcg_gen_st_i64(t, cpu_env, ofs + setalign); + tcg_temp_free_i64(t); + + done: + /* PTRUES */ + if (a->s) { + tcg_gen_movi_i32(cpu_NF, -(lastword !=3D 0)); + tcg_gen_movi_i32(cpu_CF, lastword !=3D 0); + tcg_gen_movi_i32(cpu_ZF, lastword =3D=3D 0); + tcg_gen_movi_i32(cpu_VF, 0); + } +} diff --git a/target/arm/sve.def b/target/arm/sve.def index 0f47a21ef0..f802031f51 100644 --- a/target/arm/sve.def +++ b/target/arm/sve.def @@ -25,6 +25,7 @@ # instruction patterns. =20 &rrr_esz rd rn rm esz +&pred_set rd pat esz i s =20 ########################################################################### # Named instruction formats. These are generally used to @@ -43,3 +44,14 @@ AND_zzz 00000100 00 1 ..... 001 100 ..... ..... @rd_r= n_rm ORR_zzz 00000100 01 1 ..... 001 100 ..... ..... @rd_rn_rm EOR_zzz 00000100 10 1 ..... 001 100 ..... ..... @rd_rn_rm BIC_zzz 00000100 11 1 ..... 001 100 ..... ..... @rd_rn_rm + +### SVE Predicate Generation Group + +# SVE initialize predicate (PTRUE, PTRUES) +pred_set 00100101 esz:2 011 00 s:1 111000 pat:5 0 rd:4 &pred_set i=3D1 + +# SVE zero predicate register (PFALSE) +pred_set 00100101 00 011 000 1110 0100 0000 rd:4 &pred_set pat=3D31 esz= =3D0 i=3D0 s=3D0 + +# SVE initialize FFR (SETFFR) +pred_set 00100101 0010 1100 1001 0000 0000 0000 &pred_set pat=3D31 esz= =3D0 rd=3D16 i=3D1 s=3D0 --=20 2.14.3