From patchwork Thu Jun 2 21:48:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 578182 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5806:0:0:0:0 with SMTP id j6csp980711max; Thu, 2 Jun 2022 15:56:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwGjOFbQYyxGp6V4RHfPydyggzeL4dXr9em3LKb3i/tNYNR8Pg9cd7PDzgU2lOWuilgiGw9 X-Received: by 2002:a05:622a:612:b0:2f3:d4af:c2fc with SMTP id z18-20020a05622a061200b002f3d4afc2fcmr5295424qta.185.1654210602771; Thu, 02 Jun 2022 15:56:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654210602; cv=none; d=google.com; s=arc-20160816; b=E+a/ss1Ot1/yYLWCvKQvRzMAG2ku5aPiW+iq9gXxBmUnj6d6F3LrFM1ITf+1IrDShR smSsqzoD/cTQ8AprzPS0yaAuoPFpJPQznohvlGspD1qcYE9UVMzOAXWAZPwK0es2/Fnw zSBwCLceCUXfraZcZd4/VfGthD6AC2r3furea7MlsNDlnEUnFPD9tJizvWuSPZgNdM6x vW7afwVliJcMWAuz1MVhR/dIYP/BhrWyLqtSTmvCSpmE7swtLmjuCUpFk4CgSu7Yxckj L89vLMzBj1U7sO/3hhvsgePFtK0zxTwGk1zGw5kFI+q6ektZP7mdYfH55AaNVZ9RqxEP 6o4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=asM1RIMMm/LbRASBkWsCTEFIsFdYgesXksTZnMcbxew=; b=ym2zR4YlZLNXBwmsTwlyLpvjNSrrKcVoskzo+oBBwPkHbOu4l15Dd1M0+DeAb4BfBq NWxVCF+ERfL8bkaXA3ssW3T75KxFCqQ9m5rL+LYEGNT1j7zPVj50aV/kfnN0Qm61zF/A RRNlbpH7AWwT0AY/ZlFrXhtIHcLCPhun/wXqB3Yp0cPRFQFhQwT23PlVijA1rEg84rmH W++SecNY+jdlu6s3LrjI0KETEotflZViIXhx88jAXvkgpMKTiDo5X3E7xfvHgTvx4zWO 1RbeY9Q2EUzcA/r4/xbnX6F7Ge5jSH0n+ANTccCxDngJ5JBlj+stq+nqgZ81SsooRnuT EfHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=taIkIsel; 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=pass (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 kl1-20020a056214518100b004622e11dfacsi2501066qvb.389.2022.06.02.15.56.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Jun 2022 15:56:42 -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=pass header.i=@linaro.org header.s=google header.b=taIkIsel; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:36478 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nwtkA-0005gi-Bk for patch@linaro.org; Thu, 02 Jun 2022 18:56:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38510) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nwskI-0001d9-42 for qemu-devel@nongnu.org; Thu, 02 Jun 2022 17:52:49 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]:42908) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nwskF-0000v8-BW for qemu-devel@nongnu.org; Thu, 02 Jun 2022 17:52:45 -0400 Received: by mail-pf1-x431.google.com with SMTP id 187so5797180pfu.9 for ; Thu, 02 Jun 2022 14:52:42 -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=asM1RIMMm/LbRASBkWsCTEFIsFdYgesXksTZnMcbxew=; b=taIkIselXkd8Iy3nT2sdEa+OJ32gxnfUF50Tqodz9ZG02pD3i2zc6KP4/hKnZNxRCO 9H3h97N0abl6CevaPuIHQWwZZYnqbEU6zWnfAgnZgbqwuH/HDCx/k8oBkU595nw25OIH dQLQWI37Qj7oZ6+qBUd0sv6V7eaxevonj2kr0WTp4WzBIVRSMjFsbfrtbz/QYJsFG1Qc sBEGZXyFGMGITw7kWkfVVOqDKLWx6sak/XTuuKjuVIj9PmuKYDFAJw/XTQT2ISctlEC0 3Gn/uPxoOdFSYv8NizsTcA+Sf0k1Wfz33r0YZzMOYkn6vvm7tdt1gdGV9kCp4juzBl3E E9QQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=asM1RIMMm/LbRASBkWsCTEFIsFdYgesXksTZnMcbxew=; b=muqfwgGDShRL86o6bhqaueUpUgQX/hKYgaPALOrngaTK0TKHG8PbafrrTugKpo1Mqm sFnhYAdtbO72aKojsyfGQ9kBJr6fJPkceeJV5oLbKs7cMYeqXaNCLx+czLJ5kK0Y6+WL /5SaxwJhfc/5fmOPt3OS5g+NoB6rq3BWhood1d2EckCM0AKneVrjL9lJG3TMlYXzDMtj Wz5Ag0s7ICAP4IJ4fss8BW+W8bzwS5cRXumjok9K8OJuUngAiGLxDJ5CNyEieIWyINBN +lcNXdXqJt+yA1FVVxnP3bovtF1gSFsIu0B0p9TuVu35iiMLI8UOUcKfg8DD406NuRnH AK7g== X-Gm-Message-State: AOAM531H1tWfS5KR4Lu05EMXW8fz+IT/jr6U3HZ64aTToT03CqfYAHr8 UdEpeq5C4DE5VuuX9hg01NYSrgu5JD8OmA== X-Received: by 2002:a63:8ac3:0:b0:3fc:948b:a1d9 with SMTP id y186-20020a638ac3000000b003fc948ba1d9mr6020152pgd.50.1654206762005; Thu, 02 Jun 2022 14:52:42 -0700 (PDT) Received: from stoup.. (174-21-71-225.tukw.qwest.net. [174.21.71.225]) by smtp.gmail.com with ESMTPSA id e14-20020a170902ed8e00b0015edfccfdb5sm4039605plj.50.2022.06.02.14.52.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jun 2022 14:52:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 54/71] target/arm: Implement PSEL Date: Thu, 2 Jun 2022 14:48:36 -0700 Message-Id: <20220602214853.496211-55-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220602214853.496211-1-richard.henderson@linaro.org> References: <20220602214853.496211-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::431; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x431.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- target/arm/sve.decode | 20 +++++++++++++ target/arm/translate-sve.c | 57 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) diff --git a/target/arm/sve.decode b/target/arm/sve.decode index bbdaac6ac7..bf561c270a 100644 --- a/target/arm/sve.decode +++ b/target/arm/sve.decode @@ -1674,3 +1674,23 @@ BFMLALT_zzxw 01100100 11 1 ..... 0100.1 ..... ..... @rrxr_3a esz=2 ### SVE2 floating-point bfloat16 dot-product (indexed) BFDOT_zzxz 01100100 01 1 ..... 010000 ..... ..... @rrxr_2 esz=2 + +### SVE broadcast predicate element + +&psel esz pd pn pm rv imm +%psel_rv 16:2 !function=plus_12 +%psel_imm_b 22:2 19:2 +%psel_imm_h 22:2 20:1 +%psel_imm_s 22:2 +%psel_imm_d 23:1 +@psel ........ .. . ... .. .. pn:4 . pm:4 . pd:4 \ + &psel rv=%psel_rv + +PSEL 00100101 .. 1 ..1 .. 01 .... 0 .... 0 .... \ + @psel esz=0 imm=%psel_imm_b +PSEL 00100101 .. 1 .10 .. 01 .... 0 .... 0 .... \ + @psel esz=1 imm=%psel_imm_h +PSEL 00100101 .. 1 100 .. 01 .... 0 .... 0 .... \ + @psel esz=2 imm=%psel_imm_s +PSEL 00100101 .1 1 000 .. 01 .... 0 .... 0 .... \ + @psel esz=3 imm=%psel_imm_d diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c index adf0cd3e68..58d0894e15 100644 --- a/target/arm/translate-sve.c +++ b/target/arm/translate-sve.c @@ -7379,3 +7379,60 @@ static bool do_BFMLAL_zzxw(DisasContext *s, arg_rrxr_esz *a, bool sel) TRANS_FEAT(BFMLALB_zzxw, aa64_sve_bf16, do_BFMLAL_zzxw, a, false) TRANS_FEAT(BFMLALT_zzxw, aa64_sve_bf16, do_BFMLAL_zzxw, a, true) + +static bool trans_PSEL(DisasContext *s, arg_psel *a) +{ + int vl = vec_full_reg_size(s); + int pl = pred_gvec_reg_size(s); + int elements = vl >> a->esz; + TCGv_i64 tmp, didx, dbit; + TCGv_ptr ptr; + + if (!dc_isar_feature(aa64_sme, s)) { + return false; + } + if (!sve_access_check(s)) { + return true; + } + + tmp = tcg_temp_new_i64(); + dbit = tcg_temp_new_i64(); + didx = tcg_temp_new_i64(); + ptr = tcg_temp_new_ptr(); + + /* Compute the predicate element. */ + tcg_gen_addi_i64(tmp, cpu_reg(s, a->rv), a->imm); + if (is_power_of_2(elements)) { + tcg_gen_andi_i64(tmp, tmp, elements - 1); + } else { + tcg_gen_remu_i64(tmp, tmp, tcg_constant_i64(elements)); + } + + /* Extract the predicate byte and bit indices. */ + tcg_gen_shli_i64(tmp, tmp, a->esz); + tcg_gen_andi_i64(dbit, tmp, 7); + tcg_gen_shri_i64(didx, tmp, 3); + if (HOST_BIG_ENDIAN) { + tcg_gen_xori_i64(didx, didx, 7); + } + + /* Load the predicate word. */ + tcg_gen_trunc_i64_ptr(ptr, didx); + tcg_gen_add_ptr(ptr, ptr, cpu_env); + tcg_gen_ld8u_i64(tmp, ptr, pred_full_reg_offset(s, a->pm)); + + /* Extract the predicate bit and replicate to MO_64. */ + tcg_gen_shr_i64(tmp, tmp, dbit); + tcg_gen_andi_i64(tmp, tmp, 1); + tcg_gen_neg_i64(tmp, tmp); + + /* Apply to either copy the source, or write zeros. */ + tcg_gen_gvec_ands(MO_64, pred_full_reg_offset(s, a->pd), + pred_full_reg_offset(s, a->pn), tmp, pl, pl); + + tcg_temp_free_i64(tmp); + tcg_temp_free_i64(dbit); + tcg_temp_free_i64(didx); + tcg_temp_free_ptr(ptr); + return true; +}