From patchwork Sun Dec 1 15:05:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 846508 Delivered-To: patch@linaro.org Received: by 2002:a5d:4cd0:0:b0:385:e875:8a9e with SMTP id c16csp695798wrt; Sun, 1 Dec 2024 07:17:41 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWp+4CW4Sr08I3/tXmg2t2eUr4ASX2QAwEKhdlK2d8tQ0l4b5fbRciKXKaipLOr3TGh5Y04dg==@linaro.org X-Google-Smtp-Source: AGHT+IF5xbf87ndMYH0riDmHdiCMhyIndcuuh0czmeirQg7bjD6yD4/3SZPt0cAL2EQWIf/L95bE X-Received: by 2002:ac8:574d:0:b0:460:e643:d279 with SMTP id d75a77b69052e-466b3675346mr277878151cf.45.1733066260883; Sun, 01 Dec 2024 07:17:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1733066260; cv=none; d=google.com; s=arc-20240605; b=Ln9gMwyUk2X8OwFWQklT+Az+mshY9D045tMgTYjKe2cNNUMEbRIaruc7ONU27dwFVh DMaoTi6nHzCBKA3v2exEgcgd3KWIP9P4PmeRHiV+SA11aXGufNcQtr/jPFMKSA3lXpSK MhnN/OSUP/NczcEl96TSQ/T8nw376mTTFDVE4n2idg0ofiLdrpt9V2WA1z+mAWZAv2tS oDozE2Yr5xsrLZeKUz5Gn+HffM8DvCC2MiO4Su1OFD3Jm2mWyDBSKQPynn2bRsUqyG3f mrbHhV/l0mvtuVRLzv96sA6YZ7wiAT3cBdZDyDWWPvjofX9FCwngzBYiuibVwxgg5Yvf buZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=70aykTODOkdi7LTuMRpkxW0+O38YaCX5SmqDXfk4TvQ=; fh=9Ev+QBUhk6P6vR3LT1wYeDLexozsz44nqjfoyPajZCc=; b=VyJi6Y4do/nc+umZS6mnZgdWaRkendi7FMSiGnokvLHqjZGjhjZpzPgzMiH2DgwtFT vxVX+hMyivzAF6UMAo8WphbP2PMUZk+PaOG1Jnm02KjuAopIpERtXwcagjLDFLZWzzh6 PxzW10Up+OUj6kQzqMFcDT5FrMAfdTM4ibu+VMcq2qi9Y/E3zYOj/mdDVFUwj3eAnAA4 Btf8kdmHvaFK0RtSvy0Ww8rgwYPqtC1C6i+rNWlvN6zW9lEmggHjSwT0uKMq7OiD95ew jvFmef+1kF3MooyPPXE46A3yn47xLcrGWDAoU/NCCGEE2O86WZjnm7+iqUGKzGIUNjzG RjGA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=swBybefu; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-466c445edcfsi92713151cf.655.2024.12.01.07.17.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 01 Dec 2024 07:17:40 -0800 (PST) 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=swBybefu; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tHlWn-0001JX-N0; Sun, 01 Dec 2024 10:06:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tHlWf-0001DB-PY for qemu-devel@nongnu.org; Sun, 01 Dec 2024 10:06:22 -0500 Received: from mail-oo1-xc2c.google.com ([2607:f8b0:4864:20::c2c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tHlWd-00046j-Uk for qemu-devel@nongnu.org; Sun, 01 Dec 2024 10:06:21 -0500 Received: by mail-oo1-xc2c.google.com with SMTP id 006d021491bc7-5f1e364cc22so1196196eaf.2 for ; Sun, 01 Dec 2024 07:06:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733065578; x=1733670378; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=70aykTODOkdi7LTuMRpkxW0+O38YaCX5SmqDXfk4TvQ=; b=swBybefu+MZ/uE2kmqciisj4A8Id3PLRGMXkxHS+lB8RGYKbsLDekdf9/zW1fAM4LV O+uQOMKcgRpPhpCHlv/2MD0A0WFpg/NhVZJli/gWYgzORr0rZsDcNwYuHC5VHNt6dB6d FBa5pT38ZomZ885KLsWTm+6CjSUFPLGN6czp7m/IAE0q31wtkr3Vth0UqZJawRrzRytM bN5poWbE9JVejHT28LeHNhPzi7QznZ7KH73gQV9qRjjY89pb39kBYK/7AhSBlG4kwMZP ag82dK4w2F4mHR1b1o8TVZiSmmOSQThfm5hUj9MZ+G1EvDDx0TOvoNhAovQFEqFfD+GB jGZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733065578; x=1733670378; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=70aykTODOkdi7LTuMRpkxW0+O38YaCX5SmqDXfk4TvQ=; b=PWkMuEsXneQVWV4wx2RySU2zYA8iLngla1QGN8LcZycT+apq1uHRnwnt7z3pxLNQSs O2TYNiHze4SxexHev5+qqUafDp3dijJO0JGIuV91386SBS512V6D0C6GYzYdwtqUGL6v gPz8YZ8EOlMjvZRDvyYkFfSzTCnJXJRwzUbbA60420bjANKhRHw+RdfmmTqb3m7xUOOV 5TvtKDkA24nvjXAeGj2FByxjjzf43HndbIxDJi38rOchhVgLZrqbaCcJBLP9kpDsqRfR +WpFZCqI7Mk5P19YBl5izQq/E9hhcN7b0Q0wzO3ggqjtbQQHu9DhL0M+Z/hN8WQ0QpPb ZSSg== X-Gm-Message-State: AOJu0Yxyl6CQTbMFin/nkeas46xbdYw8J476w3zcFFbWyZlBFKF/vmzx twfZYMYSqYOJ1qf0yxUeYX9ooVMlev+SvqSEcbXFUcYR/koL+y6AfzYtzNo3r0hddk7NxwiXwb5 Jtk0= X-Gm-Gg: ASbGncsMdIttk/5cOptCTO/vtRxT6oC4JQv3ewgROGNPHd6azBbjxMPQ/729kGEeltj 49JitC+iB6m17KlV2O96PAOpr3UFaKZ/r8vaS3rK74xZ/sk8umLMoPAcWoE5pMZguH94aHSlB2C 8LVcqi3BjpQVQCysBTMn7HDg0WUasZtiiugJ7YviDJYuFqCV7lvVXSrb4qtYTA4fZAYOEB0+wIO TeuoV4fJ6uxFJhSI3xIv8Pfa302eSJ8+o6DCvIXnQYorsWRVdJn5yhZpAhygZoNVg7myzG065eR 6nORIIOvD0M11CLZc4sJKMk+YfzTFiJ0/knz X-Received: by 2002:a05:6830:44a2:b0:718:6da0:72b with SMTP id 46e09a7af769-71d65c96d51mr16436397a34.7.1733065577911; Sun, 01 Dec 2024 07:06:17 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-143.totalplay.net. [187.189.51.143]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-71d7254473asm1822220a34.27.2024.12.01.07.06.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Dec 2024 07:06:17 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 07/67] target/arm: Convert RBIT, REV16, REV32, REV64 to decodetree Date: Sun, 1 Dec 2024 09:05:06 -0600 Message-ID: <20241201150607.12812-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241201150607.12812-1-richard.henderson@linaro.org> References: <20241201150607.12812-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::c2c; envelope-from=richard.henderson@linaro.org; helo=mail-oo1-xc2c.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 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-bounces+patch=linaro.org@nongnu.org Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- target/arm/tcg/translate-a64.c | 137 +++++++++++++++------------------ target/arm/tcg/a64.decode | 11 +++ 2 files changed, 72 insertions(+), 76 deletions(-) diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index ca8b644dc7..1805d77f43 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -7684,6 +7684,60 @@ static bool trans_PACGA(DisasContext *s, arg_rrr *a) return false; } +typedef void ArithOneOp(TCGv_i64, TCGv_i64); + +static bool gen_rr(DisasContext *s, int rd, int rn, ArithOneOp fn) +{ + fn(cpu_reg(s, rd), cpu_reg(s, rn)); + return true; +} + +static void gen_rbit32(TCGv_i64 tcg_rd, TCGv_i64 tcg_rn) +{ + TCGv_i32 t32 = tcg_temp_new_i32(); + + tcg_gen_extrl_i64_i32(t32, tcg_rn); + gen_helper_rbit(t32, t32); + tcg_gen_extu_i32_i64(tcg_rd, t32); +} + +static void gen_rev16_xx(TCGv_i64 tcg_rd, TCGv_i64 tcg_rn, TCGv_i64 mask) +{ + TCGv_i64 tcg_tmp = tcg_temp_new_i64(); + + tcg_gen_shri_i64(tcg_tmp, tcg_rn, 8); + tcg_gen_and_i64(tcg_rd, tcg_rn, mask); + tcg_gen_and_i64(tcg_tmp, tcg_tmp, mask); + tcg_gen_shli_i64(tcg_rd, tcg_rd, 8); + tcg_gen_or_i64(tcg_rd, tcg_rd, tcg_tmp); +} + +static void gen_rev16_32(TCGv_i64 tcg_rd, TCGv_i64 tcg_rn) +{ + gen_rev16_xx(tcg_rd, tcg_rn, tcg_constant_i64(0x00ff00ff)); +} + +static void gen_rev16_64(TCGv_i64 tcg_rd, TCGv_i64 tcg_rn) +{ + gen_rev16_xx(tcg_rd, tcg_rn, tcg_constant_i64(0x00ff00ff00ff00ffull)); +} + +static void gen_rev_32(TCGv_i64 tcg_rd, TCGv_i64 tcg_rn) +{ + tcg_gen_bswap32_i64(tcg_rd, tcg_rn, TCG_BSWAP_OZ); +} + +static void gen_rev32(TCGv_i64 tcg_rd, TCGv_i64 tcg_rn) +{ + tcg_gen_bswap64_i64(tcg_rd, tcg_rn); + tcg_gen_rotri_i64(tcg_rd, tcg_rd, 32); +} + +TRANS(RBIT, gen_rr, a->rd, a->rn, a->sf ? gen_helper_rbit64 : gen_rbit32) +TRANS(REV16, gen_rr, a->rd, a->rn, a->sf ? gen_rev16_64 : gen_rev16_32) +TRANS(REV32, gen_rr, a->rd, a->rn, a->sf ? gen_rev32 : gen_rev_32) +TRANS(REV64, gen_rr, a->rd, a->rn, tcg_gen_bswap64_i64) + /* Logical (shifted register) * 31 30 29 28 24 23 22 21 20 16 15 10 9 5 4 0 * +----+-----+-----------+-------+---+------+--------+------+------+ @@ -8302,67 +8356,6 @@ static void handle_cls(DisasContext *s, unsigned int sf, } } -static void handle_rbit(DisasContext *s, unsigned int sf, - unsigned int rn, unsigned int rd) -{ - TCGv_i64 tcg_rd, tcg_rn; - tcg_rd = cpu_reg(s, rd); - tcg_rn = cpu_reg(s, rn); - - if (sf) { - gen_helper_rbit64(tcg_rd, tcg_rn); - } else { - TCGv_i32 tcg_tmp32 = tcg_temp_new_i32(); - tcg_gen_extrl_i64_i32(tcg_tmp32, tcg_rn); - gen_helper_rbit(tcg_tmp32, tcg_tmp32); - tcg_gen_extu_i32_i64(tcg_rd, tcg_tmp32); - } -} - -/* REV with sf==1, opcode==3 ("REV64") */ -static void handle_rev64(DisasContext *s, unsigned int sf, - unsigned int rn, unsigned int rd) -{ - if (!sf) { - unallocated_encoding(s); - return; - } - tcg_gen_bswap64_i64(cpu_reg(s, rd), cpu_reg(s, rn)); -} - -/* REV with sf==0, opcode==2 - * REV32 (sf==1, opcode==2) - */ -static void handle_rev32(DisasContext *s, unsigned int sf, - unsigned int rn, unsigned int rd) -{ - TCGv_i64 tcg_rd = cpu_reg(s, rd); - TCGv_i64 tcg_rn = cpu_reg(s, rn); - - if (sf) { - tcg_gen_bswap64_i64(tcg_rd, tcg_rn); - tcg_gen_rotri_i64(tcg_rd, tcg_rd, 32); - } else { - tcg_gen_bswap32_i64(tcg_rd, tcg_rn, TCG_BSWAP_OZ); - } -} - -/* REV16 (opcode==1) */ -static void handle_rev16(DisasContext *s, unsigned int sf, - unsigned int rn, unsigned int rd) -{ - TCGv_i64 tcg_rd = cpu_reg(s, rd); - TCGv_i64 tcg_tmp = tcg_temp_new_i64(); - TCGv_i64 tcg_rn = read_cpu_reg(s, rn, sf); - TCGv_i64 mask = tcg_constant_i64(sf ? 0x00ff00ff00ff00ffull : 0x00ff00ff); - - tcg_gen_shri_i64(tcg_tmp, tcg_rn, 8); - tcg_gen_and_i64(tcg_rd, tcg_rn, mask); - tcg_gen_and_i64(tcg_tmp, tcg_tmp, mask); - tcg_gen_shli_i64(tcg_rd, tcg_rd, 8); - tcg_gen_or_i64(tcg_rd, tcg_rd, tcg_tmp); -} - /* Data-processing (1 source) * 31 30 29 28 21 20 16 15 10 9 5 4 0 * +----+---+---+-----------------+---------+--------+------+------+ @@ -8388,21 +8381,6 @@ static void disas_data_proc_1src(DisasContext *s, uint32_t insn) #define MAP(SF, O2, O1) ((SF) | (O1 << 1) | (O2 << 7)) switch (MAP(sf, opcode2, opcode)) { - case MAP(0, 0x00, 0x00): /* RBIT */ - case MAP(1, 0x00, 0x00): - handle_rbit(s, sf, rn, rd); - break; - case MAP(0, 0x00, 0x01): /* REV16 */ - case MAP(1, 0x00, 0x01): - handle_rev16(s, sf, rn, rd); - break; - case MAP(0, 0x00, 0x02): /* REV/REV32 */ - case MAP(1, 0x00, 0x02): - handle_rev32(s, sf, rn, rd); - break; - case MAP(1, 0x00, 0x03): /* REV64 */ - handle_rev64(s, sf, rn, rd); - break; case MAP(0, 0x00, 0x04): /* CLZ */ case MAP(1, 0x00, 0x04): handle_clz(s, sf, rn, rd); @@ -8557,6 +8535,13 @@ static void disas_data_proc_1src(DisasContext *s, uint32_t insn) break; default: do_unallocated: + case MAP(0, 0x00, 0x00): /* RBIT */ + case MAP(1, 0x00, 0x00): + case MAP(0, 0x00, 0x01): /* REV16 */ + case MAP(1, 0x00, 0x01): + case MAP(0, 0x00, 0x02): /* REV/REV32 */ + case MAP(1, 0x00, 0x02): + case MAP(1, 0x00, 0x03): /* REV64 */ unallocated_encoding(s); break; } diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode index a23d6a6645..dd44651f34 100644 --- a/target/arm/tcg/a64.decode +++ b/target/arm/tcg/a64.decode @@ -28,6 +28,8 @@ &r rn &rrr rd rn rm &ri rd imm +&rr rd rn +&rr_sf rd rn sf &rri_sf rd rn imm sf &rrr_sf rd rn rm sf &i imm @@ -685,6 +687,15 @@ GMI 1 00 11010110 ..... 000101 ..... ..... @rrr PACGA 1 00 11010110 ..... 001100 ..... ..... @rrr # Data Processing (1-source) + +@rr . .......... ..... ...... rn:5 rd:5 &rr +@rr_sf sf:1 .......... ..... ...... rn:5 rd:5 &rr_sf + +RBIT . 10 11010110 00000 000000 ..... ..... @rr_sf +REV16 . 10 11010110 00000 000001 ..... ..... @rr_sf +REV32 . 10 11010110 00000 000010 ..... ..... @rr_sf +REV64 1 10 11010110 00000 000011 ..... ..... @rr + # Logical (shifted reg) # Add/subtract (shifted reg) # Add/subtract (extended reg)