From nobody Mon Feb 9 11:57:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1683902489; cv=none; d=zohomail.com; s=zohoarc; b=Ji2DrTNi21bjve2ESUrf+lFY6jYUmkOpfJn5FVEbIUm/vTIPH77gdd58C9kIMB90OrryiZdGZpjCKOcegYeAnMW5EvueG/ASRC33KSQJHiqHBbT9IPLWxdBCbMlMS4ckomrl6EJ3Oi2cDz5+KiqF5QVeu+MtP3fv56Jz0CJ7FM8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683902489; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=NHxiI1NhG4rA3nZaGSdOO6mlH5N9NfHL+3owTRsYSs4=; b=PsjKsuBcV8AduejXoLifRqi0BC4+7SEW0dTYrehhPHUFSixqJdgMGahyV3i/nLP2a0Zzr/ytHtzgFHfAP5L5wJG5BMZasTDfFfPkpkM4F/NBklcxQJqijQEBcRBgA/wbi1zwjWvZhFi3Gxm8jP3hvsKbycnwkA36wKcaVddkJHo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 168390248957330.575720236125107; Fri, 12 May 2023 07:41:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pxTxK-0006m6-VE; Fri, 12 May 2023 10:41:14 -0400 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 1pxTxJ-0006lE-7i for qemu-devel@nongnu.org; Fri, 12 May 2023 10:41:13 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pxTxF-0004gz-JG for qemu-devel@nongnu.org; Fri, 12 May 2023 10:41:12 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-3f4271185daso59001995e9.2 for ; Fri, 12 May 2023 07:41:09 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id f12-20020a7bcc0c000000b003f17848673fsm28916167wmh.27.2023.05.12.07.41.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 May 2023 07:41:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683902468; x=1686494468; 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=NHxiI1NhG4rA3nZaGSdOO6mlH5N9NfHL+3owTRsYSs4=; b=GrJuo8N9eY+5PfV4Ljz11Zy9T+NVtMeGfoDrQhP8XpZfgOnSOoY7cAhiVnJcAmgYoA Oy269pkMkVqKaPEr8gJEJJ3z1OXXAdEXlbwAAgKQSbGBf7qNoDJV0scONurbf5wl7B1h t/1WxxWqQydzVTNrB6AOdEFoBhN4I006WptYZZ3FBshEYnDzRMfBYBzGpnFRfPFiUGvg CI/uBrurOmvuZ5OQsthqYFZDAFyoKEap5UmT640NMw0bb42M6ddp/fEyykEZKW5fUwyz xmpV94Sy56rPT3eh+M3wrYFwF4yDjTH3+OyoA+/f3CnJBbfVI39RRP6rb1UQs6lHNyQU 5wiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683902468; x=1686494468; 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=NHxiI1NhG4rA3nZaGSdOO6mlH5N9NfHL+3owTRsYSs4=; b=d3COHZdsxZsfknGb4gQPb05tQoi70/dtC+Yx9AM0OdSAaxtFGQz3UJF3+OV6QVhjMn 1uzewxKLo81c2yaWf3ql0avOBxMBKxufQih6BagOhx5ho3yfQjX66QMGI/1NJsD8EuF4 AbJ30Y3vqi2IC2lfLAY657xyEImRRvHAQBwr8Gw404p2wet/y0rYrI/5oTuW8Ix/7ZYy ihbvr+vzpFAEpOqNaPF4y1f76AOmls4X5sEBQEHZaN+v8wk1qZDytyywMOm+ygasdR4T 3ZW+m/0BHKnvKEQUFFHhwHL+NTQDx2EheyZHKpsdpGUU421Jpnu3xRu7eAj/Eemi354D yEZQ== X-Gm-Message-State: AC+VfDyDM5V6QfRwQ7IQEKNSUCiUnSnBfXQvEu3EuqzLdNYPOOBg4q2s qoIksxsw5AqyVeY8O1ZUksL/JA== X-Google-Smtp-Source: ACHHUZ6z/VCrKYGCkPaMtPAiTWDojk+erVjyRBesN7e/kUc0Y7PAXnk1BzYLh8YBdpsSTNh19nIYYA== X-Received: by 2002:a7b:cb94:0:b0:3f4:ec32:69fd with SMTP id m20-20020a7bcb94000000b003f4ec3269fdmr3500814wmi.40.1683902468052; Fri, 12 May 2023 07:41:08 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PATCH 01/20] target/arm: Split out disas_a64_legacy Date: Fri, 12 May 2023 15:40:47 +0100 Message-Id: <20230512144106.3608981-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230512144106.3608981-1-peter.maydell@linaro.org> References: <20230512144106.3608981-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x334.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1683902491614100003 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Split out all of the decode stuff from aarch64_tr_translate_insn. Call it disas_a64_legacy to indicate it will be replaced. Signed-off-by: Richard Henderson [PMM: Rebased] Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/tcg/translate-a64.c | 82 ++++++++++++++++++---------------- 1 file changed, 44 insertions(+), 38 deletions(-) diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index dff391bfe24..8a0ede96440 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -14200,6 +14200,49 @@ static bool btype_destination_ok(uint32_t insn, bo= ol bt, int btype) return false; } =20 +/* C3.1 A64 instruction index by encoding */ +static void disas_a64_legacy(DisasContext *s, uint32_t insn) +{ + switch (extract32(insn, 25, 4)) { + case 0x0: + if (!extract32(insn, 31, 1) || !disas_sme(s, insn)) { + unallocated_encoding(s); + } + break; + case 0x1: case 0x3: /* UNALLOCATED */ + unallocated_encoding(s); + break; + case 0x2: + if (!disas_sve(s, insn)) { + unallocated_encoding(s); + } + break; + case 0x8: case 0x9: /* Data processing - immediate */ + disas_data_proc_imm(s, insn); + break; + case 0xa: case 0xb: /* Branch, exception generation and system insns */ + disas_b_exc_sys(s, insn); + break; + case 0x4: + case 0x6: + case 0xc: + case 0xe: /* Loads and stores */ + disas_ldst(s, insn); + break; + case 0x5: + case 0xd: /* Data processing - register */ + disas_data_proc_reg(s, insn); + break; + case 0x7: + case 0xf: /* Data processing - SIMD and floating point */ + disas_data_proc_simd_fp(s, insn); + break; + default: + assert(FALSE); /* all 15 cases should be handled above */ + break; + } +} + static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cpu) { @@ -14401,44 +14444,7 @@ static void aarch64_tr_translate_insn(DisasContext= Base *dcbase, CPUState *cpu) disas_sme_fa64(s, insn); } =20 - switch (extract32(insn, 25, 4)) { - case 0x0: - if (!extract32(insn, 31, 1) || !disas_sme(s, insn)) { - unallocated_encoding(s); - } - break; - case 0x1: case 0x3: /* UNALLOCATED */ - unallocated_encoding(s); - break; - case 0x2: - if (!disas_sve(s, insn)) { - unallocated_encoding(s); - } - break; - case 0x8: case 0x9: /* Data processing - immediate */ - disas_data_proc_imm(s, insn); - break; - case 0xa: case 0xb: /* Branch, exception generation and system insns */ - disas_b_exc_sys(s, insn); - break; - case 0x4: - case 0x6: - case 0xc: - case 0xe: /* Loads and stores */ - disas_ldst(s, insn); - break; - case 0x5: - case 0xd: /* Data processing - register */ - disas_data_proc_reg(s, insn); - break; - case 0x7: - case 0xf: /* Data processing - SIMD and floating point */ - disas_data_proc_simd_fp(s, insn); - break; - default: - assert(FALSE); /* all 15 cases should be handled above */ - break; - } + disas_a64_legacy(s, insn); =20 /* * After execution of most insns, btype is reset to 0. --=20 2.34.1 From nobody Mon Feb 9 11:57:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1683902736; cv=none; d=zohomail.com; s=zohoarc; b=NDOc2F78RlnsmQutbGHPClVLdbrNKUbRePj+GmW4ACOOxSfUE2zoiy6IgWscCcUp+fI43c6bDeW9o4nnozL1weszbWp4viaqa2rddIWhoDz1mybqDcp4PXNjtPj8WqkgPXawDT2OzzUPY6HQ8RV05EnMfQciagmk6Q/oVqO8GiQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683902736; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Asur4oBWLh7C1YKCBKndI9D3ErAPKyBAV+JBqkyMkBU=; b=ZkyEUzUqrQQn69I02nLeT8SkVB84PWpfI7t32ZcdjOFCh808pBxFJj5D4i57fEaG43tSQvUwrV6/BALIMqCtTmdgh7jc2Ya/EKEwsUR1ioq39IDOTRx7y70u0LuffVZFF+zbaOlSJeTguS16PO06YZ18xUUSF+J+4hfp+uysmFg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 168390273650845.12240954215167; Fri, 12 May 2023 07:45:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pxTxM-0006mI-4b; Fri, 12 May 2023 10:41:16 -0400 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 1pxTxJ-0006lN-JJ for qemu-devel@nongnu.org; Fri, 12 May 2023 10:41:13 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pxTxF-0004h9-U4 for qemu-devel@nongnu.org; Fri, 12 May 2023 10:41:13 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-3f315735514so324552785e9.1 for ; Fri, 12 May 2023 07:41:09 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id f12-20020a7bcc0c000000b003f17848673fsm28916167wmh.27.2023.05.12.07.41.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 May 2023 07:41:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683902468; x=1686494468; 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=Asur4oBWLh7C1YKCBKndI9D3ErAPKyBAV+JBqkyMkBU=; b=Ax819hNIliVjuh/il22qMR3yZBCvRTG3LajZ7fBZNRrHgMWGJ6kzDBKup18jcZtfhD bWnt8jNLpvioBsFvufZTooW6A6df67oOn1WA56pTTrgqIIuVA88hc+sCeLZBQvyfG3ay oR0n+w3WmY4iXfDI9kiDwZafA8ymGbkQ1kJr1KIOFD7C2/zjFMOX/YD63FDpWACw/+Fn Wju/XBv34zsIsrkGlk6Fm2a7tcBNUCpgt2SU1xlQ2KR1NQnY0s1PGLvUPyTJRyCj7a8d lsRZtOJbgqDjdT6vUaSbVPm5ZgJlymE7KiI0/oet8HWFhK3TbeQusvCMwBhHFFcfPu2X /Yag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683902468; x=1686494468; 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=Asur4oBWLh7C1YKCBKndI9D3ErAPKyBAV+JBqkyMkBU=; b=kbNd2Iq+fDhiK3ysELaDV2yOttn5+B8wh864zFOnFbGI/H095YF7I8tFylhCVk8J9h kqdxrtREFOhFj55WbmKa15Lmr0XoY83yrsfFmsWDCGsji+bVt8O7FmPiwXZl+YBsQVKk pBViEIvD10WDPr/XhKnf7+zfVoG1PSB2PyOAQZuUEiYeOz2/ZNKYXNxSNxo35PNO66uu yQwkAWpm7FfDhsKLLZRYZt2R5PGH+gSRezNs4LHcWsN7+tSs4gaE9+BuCisrgMHWUBpZ 049UkqVBPqmySkZEChLxRdzZf7bPPbqE2PShgEScWeBGHV1s7rzUlVF7kidG5lcBXt+C DCsw== X-Gm-Message-State: AC+VfDzTaXM0RMDs8ViSRXJI+m4IDpU7CVcVfPadtP21byUv0Ycz1s15 87/7USyPzVIBDX4G8dxxXJv35w== X-Google-Smtp-Source: ACHHUZ7jOFaYurAN8lD+T3+tDznnweitlBjJAE3PZMlyCifFxYF5fZanPZOhy/cvIBFUbTsvZi5nPw== X-Received: by 2002:a05:600c:4f45:b0:3f4:2bcf:e19 with SMTP id m5-20020a05600c4f4500b003f42bcf0e19mr9035797wmq.8.1683902468514; Fri, 12 May 2023 07:41:08 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PATCH 02/20] target/arm: Create decodetree skeleton for A64 Date: Fri, 12 May 2023 15:40:48 +0100 Message-Id: <20230512144106.3608981-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230512144106.3608981-1-peter.maydell@linaro.org> References: <20230512144106.3608981-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32e.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1683902738514100019 Content-Type: text/plain; charset="utf-8" The A64 translator uses a hand-written decoder for everything except SVE or SME. It's fairly well structured, but it's becoming obvious that it's still more painful to add instructions to than the A32 translator, because putting a new instruction into the right place in a hand-written decoder is much harder than adding new instruction patterns to a decodetree file. As the first step in conversion to decodetree, create the skeleton of the decodetree decoder; where it does not handle instructions we will fall back to the legacy decoder (which will be for everything at the moment, since there are no patterns in a64.decode). Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/tcg/a64.decode | 20 ++++++++++++++++++++ target/arm/tcg/translate-a64.c | 18 +++++++++++------- target/arm/tcg/meson.build | 1 + 3 files changed, 32 insertions(+), 7 deletions(-) create mode 100644 target/arm/tcg/a64.decode diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode new file mode 100644 index 00000000000..43321bbbb05 --- /dev/null +++ b/target/arm/tcg/a64.decode @@ -0,0 +1,20 @@ +# AArch64 A64 allowed instruction decoding +# +# Copyright (c) 2023 Linaro, Ltd +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, see . + +# +# This file is processed by scripts/decodetree.py +# diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 8a0ede96440..7862e9dd4e3 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -56,6 +56,13 @@ enum a64_shift_type { A64_SHIFT_TYPE_ROR =3D 3 }; =20 +/* + * Include the generated decoders. + */ + +#include "decode-sme-fa64.c.inc" +#include "decode-a64.c.inc" + /* Table based decoder typedefs - used when the relevant bits for decode * are too awkwardly scattered across the instruction (eg SIMD). */ @@ -14100,12 +14107,6 @@ static void disas_data_proc_simd_fp(DisasContext *= s, uint32_t insn) } } =20 -/* - * Include the generated SME FA64 decoder. - */ - -#include "decode-sme-fa64.c.inc" - static bool trans_OK(DisasContext *s, arg_OK *a) { return true; @@ -14444,7 +14445,10 @@ static void aarch64_tr_translate_insn(DisasContext= Base *dcbase, CPUState *cpu) disas_sme_fa64(s, insn); } =20 - disas_a64_legacy(s, insn); + + if (!disas_a64(s, insn)) { + disas_a64_legacy(s, insn); + } =20 /* * After execution of most insns, btype is reset to 0. diff --git a/target/arm/tcg/meson.build b/target/arm/tcg/meson.build index 4d99f6dacb3..130ed62fcd7 100644 --- a/target/arm/tcg/meson.build +++ b/target/arm/tcg/meson.build @@ -13,6 +13,7 @@ gen =3D [ decodetree.process('a32-uncond.decode', extra_args: '--static-decode=3Dd= isas_a32_uncond'), decodetree.process('t32.decode', extra_args: '--static-decode=3Ddisas_t3= 2'), decodetree.process('t16.decode', extra_args: ['-w', '16', '--static-deco= de=3Ddisas_t16']), + decodetree.process('a64.decode', extra_args: ['--static-decode=3Ddisas_a= 64']), ] =20 arm_ss.add(gen) --=20 2.34.1 From nobody Mon Feb 9 11:57:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1683902736; cv=none; d=zohomail.com; s=zohoarc; b=KbyGckFe1Z57p+oBDOxLAeS5YU/CdovuHMec0i5YWj8I/L0rAwpmHoW8oKLbMLyHzAOJ6Q7g1UuvoNTAbPIdfkxJxVghTxNEWTXboHAn5+0AoTN+uhtmaf6e5z5oc0xChSEVS6KsjGMVUckE+xdWBg+fZf5nfnvggP2FXKRWMG4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683902736; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=F7ZdreOn7GzP2/qhzWCJzqHK4hMlTf1RtG4DdFV8A+I=; b=ZmhpBAJLPNhtH71+45oxYGJo1YvcqtDSfTfimrvYPO+Mwzb9k99DjPS1ftSI6OoTO9dUi/5scnQdgczQrULtk8jlerNVKkZKfhRMrKDbElo4fcznWWHSXjhalc+Xz4T0rgA83PE1HHrUt9aSjYmWsKXryBD4iJYTgrFocaDh6Q0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1683902736066468.2606690803584; Fri, 12 May 2023 07:45:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pxTxW-0006xZ-JN; Fri, 12 May 2023 10:41:26 -0400 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 1pxTxU-0006uv-Ns for qemu-devel@nongnu.org; Fri, 12 May 2023 10:41:24 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pxTxG-0004hR-O2 for qemu-devel@nongnu.org; Fri, 12 May 2023 10:41:24 -0400 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-30789a4c537so5092239f8f.0 for ; Fri, 12 May 2023 07:41:10 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id f12-20020a7bcc0c000000b003f17848673fsm28916167wmh.27.2023.05.12.07.41.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 May 2023 07:41:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683902469; x=1686494469; 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=F7ZdreOn7GzP2/qhzWCJzqHK4hMlTf1RtG4DdFV8A+I=; b=ruCmCfeAjlWFv6ZAPQ1UCtxDHaOIBb3VUZxb6qXl4HP1Q4Vtwp4zJh6LG6zDL17gqI gQtGlrIR0fUBGWUyD8zMvHUMPAYMc2Xh1Eb5Jyy/oMANuGsrKI1Hz/y3Q06bC9/+RBYN zKzm07JtdFVOu8qwjznHxzsgW4YtdpUDN+rcWSOsbWe6aYTOCWRwekXgjTYRxSWxHBLw 0Z+kUMUrUS5oGJyh1eE2AGyC03HVpg5KftAyIk/8k7RKhA4foVXbViTxRSWQqEYkVy01 eo0GnWXEgTzdTfgSbrE2F7l5GAYuuSR8S3x3nrZYCIkIv2azjQGJrDpgoYXAE8SeGYr/ aGfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683902469; x=1686494469; 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=F7ZdreOn7GzP2/qhzWCJzqHK4hMlTf1RtG4DdFV8A+I=; b=LlYtH9dLm+7PynGCTbOco+mL9Tfi8cZGwT9eNiuw11XGHwqjBmZcSQOHbLdbitDCLk aN5eJCcLjm5+i5zKQUImqxTBKtitGWrlouHu1pHNF3XDpp4gb5nTjIjugt/bRbCSy7wn 8UDxWKbqigmxDXYvm3vytGVNpVmgmj3nSJUdoUVgE4u5Vw4p6p4/NQdQBuvqUb8wYBA3 KLkyVwjfych/rlFuuNPG615YsW0ofOGNfTIJtiDFM/dEOsho6Tw2Ce10D/c2zlBkxeyu VBEeiOPUhK7WrNRB43aaUE5XOQ7l98LBBllfr5DTvXwgNRHiEIpkyQPudCkKUYGiiDCB 6cVg== X-Gm-Message-State: AC+VfDwxDDATabcO8BizypAmTEqgdQm3Zv4W13CBvA1MAfXd05GJbS00 HLr2itvosAn+QtrmVyj3t8F21g== X-Google-Smtp-Source: ACHHUZ4ynFIKNJ5+x8jXIa2gDLJLhQmnWnzpybhkNhtVhLpLJBefNX0KTwxtCON8w7lpqLFTa1SGDg== X-Received: by 2002:adf:e991:0:b0:307:a58f:5f7b with SMTP id h17-20020adfe991000000b00307a58f5f7bmr8780705wrm.64.1683902469393; Fri, 12 May 2023 07:41:09 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PATCH 03/20] target/arm: Pull calls to disas_sve() and disas_sme() out of legacy decoder Date: Fri, 12 May 2023 15:40:49 +0100 Message-Id: <20230512144106.3608981-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230512144106.3608981-1-peter.maydell@linaro.org> References: <20230512144106.3608981-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-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=unavailable 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1683902738306100011 Content-Type: text/plain; charset="utf-8" The SVE and SME decode is already done by decodetree. Pull the calls to these decoders out of the legacy decoder. This doesn't change behaviour because all the patterns in sve.decode and sme.decode already require the bits that the legacy decoder is decoding to have the correct values. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/tcg/translate-a64.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 7862e9dd4e3..2845febb713 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -14205,19 +14205,6 @@ static bool btype_destination_ok(uint32_t insn, bo= ol bt, int btype) static void disas_a64_legacy(DisasContext *s, uint32_t insn) { switch (extract32(insn, 25, 4)) { - case 0x0: - if (!extract32(insn, 31, 1) || !disas_sme(s, insn)) { - unallocated_encoding(s); - } - break; - case 0x1: case 0x3: /* UNALLOCATED */ - unallocated_encoding(s); - break; - case 0x2: - if (!disas_sve(s, insn)) { - unallocated_encoding(s); - } - break; case 0x8: case 0x9: /* Data processing - immediate */ disas_data_proc_imm(s, insn); break; @@ -14239,7 +14226,7 @@ static void disas_a64_legacy(DisasContext *s, uint3= 2_t insn) disas_data_proc_simd_fp(s, insn); break; default: - assert(FALSE); /* all 15 cases should be handled above */ + unallocated_encoding(s); break; } } @@ -14445,8 +14432,9 @@ static void aarch64_tr_translate_insn(DisasContextB= ase *dcbase, CPUState *cpu) disas_sme_fa64(s, insn); } =20 - - if (!disas_a64(s, insn)) { + if (!disas_a64(s, insn) && + !disas_sme(s,insn) && + !disas_sve(s, insn)) { disas_a64_legacy(s, insn); } =20 --=20 2.34.1 From nobody Mon Feb 9 11:57:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1683902483; cv=none; d=zohomail.com; s=zohoarc; b=TVl6Vt0v5uiiZjit9KuCBoGQRN1HB9BqNwZKvQJPK3sL+neb9UJ+MHjHgRteVpp+GUOEc8jCS1N83oo5hLfbzQimniSAcMJcyIO5TCOGI3tCAaF2nCnlSc45w7BaYo2EQvl5ghkoKyVCBCQhMb2EhTO14bW4bPmeUUG8ne0L4nk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683902483; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=aGMeEb09oEnMrpyNK209IcBkUtOebSdaEKZrMIshndE=; b=CxDXEWiSnmlxTeLhVKJgTsRgZNcuncL2VoMBKHf/98RqusKlvwmRZ0V50Od4v5Tcm4uuGe83y6QzB7l+ndZ2wJK+vC0KhfFdwV6Y/h+D21ZU5/9UwZ3otKDDPbdI7IlnLhEsEDogsDBEJ7mNXuAWnc5xz0U5+2f02piEKcekgGg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1683902483104358.41258780988744; Fri, 12 May 2023 07:41:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pxTxL-0006mH-Tw; Fri, 12 May 2023 10:41:15 -0400 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 1pxTxK-0006m5-SE for qemu-devel@nongnu.org; Fri, 12 May 2023 10:41:14 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pxTxH-0004ha-CQ for qemu-devel@nongnu.org; Fri, 12 May 2023 10:41:14 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-3f450815d0bso37254185e9.0 for ; Fri, 12 May 2023 07:41:11 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id f12-20020a7bcc0c000000b003f17848673fsm28916167wmh.27.2023.05.12.07.41.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 May 2023 07:41:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683902470; x=1686494470; 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=aGMeEb09oEnMrpyNK209IcBkUtOebSdaEKZrMIshndE=; b=daK08hxLQ2i3lifTHbEReBfJe+G/1ujqs81fDAvariEV4QSzhLcjSHFxmQR+NDpME1 iDmQLpU8mAx4mrsyCqZ019gpE/4yqKUmqugSnkW6Qa0F+ODkIktZ5/1zNgqfv5C3BwYZ hRmUjhoGXxo8X6qfnLlJDPq2zSI4eDVS4EAFJcwd0rfOvltoANFnfWXF1U1twZgMG/dt IghiQdMOWjjtjEEafMglDQczj0i1zUXxF0XuL5u620sUF1f7LhZd3VzoYhCiQTv1aTR5 M/wqeijcTlyCVpLUi34WddBScXtMSIkSzH8lVHawpx41HfwIFROeOcXXDl39ZbXNk+w+ jKtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683902470; x=1686494470; 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=aGMeEb09oEnMrpyNK209IcBkUtOebSdaEKZrMIshndE=; b=RaF6VkrtAZ5ja0s1zUGO0DP7IsTwhyPGD1rki6chAILfJW2ur+lkbg0/sBGbcc0vNh bGPFkbLW0sEwfUCVE44taABc+4c+E2Io/PrhuFT3X6JpN3nu5z0wt1exKuYI3N0vkl9r d+cI8n9ZWlyGp8QQkeB4mQA8/eBZGu4cI6Y1ZncIM99cBJd3p5Xce22lkIlQhH7iqopZ cLmmzD6T1nPvradJQ3TyI02be2KUVRT3CgMnt9ccwWVqGfI64XvvvBjZMG/sa3ZyKUVW uc8K0dAYDUgmNG2DSICEvQUEdCbWWegF0m7dYvC/Q6aP8lgvrRJiTTnvmHDgvs0uoaEd SYGw== X-Gm-Message-State: AC+VfDzOMNbSxkVQihl6mRnzvVADS+sD4DkQMlBbrS7iM3HC2UYIMUxj OKhQ5p947TJKOxiVkZVUIiyeQA== X-Google-Smtp-Source: ACHHUZ4uGV/j990UZ9scgnBLtAwTvs3+Wy4oyzXfCe9CZZg8qF+kkaN95URquO1nzT5Y9oDdzD/hAA== X-Received: by 2002:a1c:750a:0:b0:3f4:16bc:bd19 with SMTP id o10-20020a1c750a000000b003f416bcbd19mr16088948wmc.23.1683902469997; Fri, 12 May 2023 07:41:09 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PATCH 04/20] target/arm: Convert PC-rel addressing to decodetree Date: Fri, 12 May 2023 15:40:50 +0100 Message-Id: <20230512144106.3608981-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230512144106.3608981-1-peter.maydell@linaro.org> References: <20230512144106.3608981-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x333.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1683902485019100003 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Convert the ADR and ADRP instructions. Signed-off-by: Richard Henderson [PMM: Rebased] Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/tcg/a64.decode | 13 ++++++++++++ target/arm/tcg/translate-a64.c | 38 +++++++++++++--------------------- 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode index 43321bbbb05..bcf46fc37d7 100644 --- a/target/arm/tcg/a64.decode +++ b/target/arm/tcg/a64.decode @@ -18,3 +18,16 @@ # # This file is processed by scripts/decodetree.py # + +&ri rd imm + + +### Data Processing - Immediate + +# PC-rel addressing + +%imm_pcrel 5:s19 29:2 +@pcrel . .. ..... ................... rd:5 &ri imm=3D%imm_pcr= el + +ADR 0 .. 10000 ................... ..... @pcrel +ADRP 1 .. 10000 ................... ..... @pcrel diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 2845febb713..ce3e8b1d08e 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -4179,31 +4179,24 @@ static void disas_ldst(DisasContext *s, uint32_t in= sn) } } =20 -/* PC-rel. addressing - * 31 30 29 28 24 23 5 4 0 - * +----+-------+-----------+-------------------+------+ - * | op | immlo | 1 0 0 0 0 | immhi | Rd | - * +----+-------+-----------+-------------------+------+ +/* + * PC-rel. addressing */ -static void disas_pc_rel_adr(DisasContext *s, uint32_t insn) + +static bool trans_ADR(DisasContext *s, arg_ri *a) { - unsigned int page, rd; - int64_t offset; + gen_pc_plus_diff(s, cpu_reg(s, a->rd), a->imm); + return true; +} =20 - page =3D extract32(insn, 31, 1); - /* SignExtend(immhi:immlo) -> offset */ - offset =3D sextract64(insn, 5, 19); - offset =3D offset << 2 | extract32(insn, 29, 2); - rd =3D extract32(insn, 0, 5); +static bool trans_ADRP(DisasContext *s, arg_ri *a) +{ + int64_t offset =3D (int64_t)a->imm << 12; =20 - if (page) { - /* ADRP (page based) */ - offset <<=3D 12; - /* The page offset is ok for CF_PCREL. */ - offset -=3D s->pc_curr & 0xfff; - } - - gen_pc_plus_diff(s, cpu_reg(s, rd), offset); + /* The page offset is ok for CF_PCREL. */ + offset -=3D s->pc_curr & 0xfff; + gen_pc_plus_diff(s, cpu_reg(s, a->rd), offset); + return true; } =20 /* @@ -4656,9 +4649,6 @@ static void disas_extract(DisasContext *s, uint32_t i= nsn) static void disas_data_proc_imm(DisasContext *s, uint32_t insn) { switch (extract32(insn, 23, 6)) { - case 0x20: case 0x21: /* PC-rel. addressing */ - disas_pc_rel_adr(s, insn); - break; case 0x22: /* Add/subtract (immediate) */ disas_add_sub_imm(s, insn); break; --=20 2.34.1 From nobody Mon Feb 9 11:57:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1683902638; cv=none; d=zohomail.com; s=zohoarc; b=lUKZt+AhB2NiZORyvhHjRl9qRllgarGuy1z0miYQazKMjw/wgeUOmEzGfTt2yMYzvvfu+zmrj387f3Qf+y3o+RvmgM/tssdujRANmxMPjSeK83k8ZMEY2saWvFZyc7i8XYT2ht4vDPf+CugQQZ8yL1TlAVcUB5CYVHKZI2EABB0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683902638; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=frqXOGogEVBk8JyygFWcnqFlkBDGHEdOnDw7HOu9/7M=; b=ShZuXmS58WR8AanErzayIYPJxrUqOIxU52SN7y7Y0hQl0VTr9xqhlUKl0OD16HTuzQwveetLHoldymWK0RlQ4MM1LlZPNZLPiC8RFmgq3WkKwZ+XI9asbt4mCFRJkHRF9bzZ18rA3inbsf3QIZigih0szjVgFPwalyuNUKNXpSQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1683902638719550.8669484530062; Fri, 12 May 2023 07:43:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pxTxU-0006uw-Pp; Fri, 12 May 2023 10:41:24 -0400 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 1pxTxT-0006uD-MV for qemu-devel@nongnu.org; Fri, 12 May 2023 10:41:23 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pxTxI-0004hm-0t for qemu-devel@nongnu.org; Fri, 12 May 2023 10:41:23 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-3f450815d02so24664265e9.0 for ; Fri, 12 May 2023 07:41:11 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id f12-20020a7bcc0c000000b003f17848673fsm28916167wmh.27.2023.05.12.07.41.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 May 2023 07:41:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683902470; x=1686494470; 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=frqXOGogEVBk8JyygFWcnqFlkBDGHEdOnDw7HOu9/7M=; b=L2jGYeUJ91L9SrZS2hUvj+PBeNDTthLHkHDr3tVMIgBnqFDLOp4rMphCVqGTFfjeUe +/Iv6hL9fKg/gHG5xA1aPrKP7a36lUKaCJabo+Lisq/GIWI7SAVcMsaXeuMlpeF3lRkm kBm3yG8iq9O6KvBcxkhkUeO6ZXYOlRu/bWT5HWFDwQTjs7tJl1eQKWNjry7GAgCs2RV7 uHb4FpAQTEktZqgvnv0RsHuPhTnFXHjxhZdkza0YIh1mmBoJ51STsxuGcSqyjtiEbybZ 9lGgqP9GY8xTXx4IevD9/qXGmgW8o8UPWjNukZgwj9oqfSD+qI88BHV9zmVOO5ptwi6f IfTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683902470; x=1686494470; 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=frqXOGogEVBk8JyygFWcnqFlkBDGHEdOnDw7HOu9/7M=; b=h+kOe1RRJKWrSxkwzxc+jBS7pEfc+jmmOLK4UN20RkCwncNdtEjCvPQDDIJx+cBbFT 4ovSB78CgmSnl2OQh9Z0kU7+SUWYcJtoy9rGFlViEFI2o5Sl4r/e5phnmbmvtN9KiRpj 9WHgQ9XuWpHJbDhKDwJLjnFt40XBKafQLId5cERclSVAyzvGtS+FYcPTif7MBDpa8PTI Yin3yCvNL9f87pnOj4biVyOgLfY+pwOJon/hNHZwmbZE14bKSV9wjJXYojflFVUOyBFt YoGtlxk4Pcy1qyL9EhpVdPjsLPdKJboW1lnawM1A8RVvg0D9ahhW8RSQnij6zIJ32KXb 26pw== X-Gm-Message-State: AC+VfDwrvSy8yqtvHeQeiFA/ptUdcK7I45KNA1mB/pTaMIdJe0ttab5i qHjn5s+a7vP0FwZGNEP+fQwHq0zG7IMBRoDOzwU= X-Google-Smtp-Source: ACHHUZ4JpGpdiBBSMaJcZcptrE3F3d5AJcSUhiU8MIV+WCATYfKGpgOCjfUx7CJX1LvHXlZ74XhTGQ== X-Received: by 2002:a1c:7303:0:b0:3f1:6e88:5785 with SMTP id d3-20020a1c7303000000b003f16e885785mr17723289wmb.14.1683902470501; Fri, 12 May 2023 07:41:10 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PATCH 05/20] target/arm: Split gen_add_CC and gen_sub_CC Date: Fri, 12 May 2023 15:40:51 +0100 Message-Id: <20230512144106.3608981-6-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230512144106.3608981-1-peter.maydell@linaro.org> References: <20230512144106.3608981-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x336.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=unavailable 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1683902640032100006 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Split out specific 32-bit and 64-bit functions. These carry the same signature as tcg_gen_add_i64, and so will be easier to pass as callbacks. Retain gen_add_CC and gen_sub_CC during conversion. Signed-off-by: Richard Henderson [PMM: rebased] Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/tcg/translate-a64.c | 149 +++++++++++++++++++-------------- 1 file changed, 84 insertions(+), 65 deletions(-) diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index ce3e8b1d08e..a3bccbd708a 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -682,83 +682,102 @@ static inline void gen_logic_CC(int sf, TCGv_i64 res= ult) } =20 /* dest =3D T0 + T1; compute C, N, V and Z flags */ +static void gen_add64_CC(TCGv_i64 dest, TCGv_i64 t0, TCGv_i64 t1) +{ + TCGv_i64 result, flag, tmp; + result =3D tcg_temp_new_i64(); + flag =3D tcg_temp_new_i64(); + tmp =3D tcg_temp_new_i64(); + + tcg_gen_movi_i64(tmp, 0); + tcg_gen_add2_i64(result, flag, t0, tmp, t1, tmp); + + tcg_gen_extrl_i64_i32(cpu_CF, flag); + + gen_set_NZ64(result); + + tcg_gen_xor_i64(flag, result, t0); + tcg_gen_xor_i64(tmp, t0, t1); + tcg_gen_andc_i64(flag, flag, tmp); + tcg_gen_extrh_i64_i32(cpu_VF, flag); + + tcg_gen_mov_i64(dest, result); +} + +static void gen_add32_CC(TCGv_i64 dest, TCGv_i64 t0, TCGv_i64 t1) +{ + TCGv_i32 t0_32 =3D tcg_temp_new_i32(); + TCGv_i32 t1_32 =3D tcg_temp_new_i32(); + TCGv_i32 tmp =3D tcg_temp_new_i32(); + + tcg_gen_movi_i32(tmp, 0); + tcg_gen_extrl_i64_i32(t0_32, t0); + tcg_gen_extrl_i64_i32(t1_32, t1); + tcg_gen_add2_i32(cpu_NF, cpu_CF, t0_32, tmp, t1_32, tmp); + tcg_gen_mov_i32(cpu_ZF, cpu_NF); + tcg_gen_xor_i32(cpu_VF, cpu_NF, t0_32); + tcg_gen_xor_i32(tmp, t0_32, t1_32); + tcg_gen_andc_i32(cpu_VF, cpu_VF, tmp); + tcg_gen_extu_i32_i64(dest, cpu_NF); +} + static void gen_add_CC(int sf, TCGv_i64 dest, TCGv_i64 t0, TCGv_i64 t1) { if (sf) { - TCGv_i64 result, flag, tmp; - result =3D tcg_temp_new_i64(); - flag =3D tcg_temp_new_i64(); - tmp =3D tcg_temp_new_i64(); - - tcg_gen_movi_i64(tmp, 0); - tcg_gen_add2_i64(result, flag, t0, tmp, t1, tmp); - - tcg_gen_extrl_i64_i32(cpu_CF, flag); - - gen_set_NZ64(result); - - tcg_gen_xor_i64(flag, result, t0); - tcg_gen_xor_i64(tmp, t0, t1); - tcg_gen_andc_i64(flag, flag, tmp); - tcg_gen_extrh_i64_i32(cpu_VF, flag); - - tcg_gen_mov_i64(dest, result); + gen_add64_CC(dest, t0, t1); } else { - /* 32 bit arithmetic */ - TCGv_i32 t0_32 =3D tcg_temp_new_i32(); - TCGv_i32 t1_32 =3D tcg_temp_new_i32(); - TCGv_i32 tmp =3D tcg_temp_new_i32(); - - tcg_gen_movi_i32(tmp, 0); - tcg_gen_extrl_i64_i32(t0_32, t0); - tcg_gen_extrl_i64_i32(t1_32, t1); - tcg_gen_add2_i32(cpu_NF, cpu_CF, t0_32, tmp, t1_32, tmp); - tcg_gen_mov_i32(cpu_ZF, cpu_NF); - tcg_gen_xor_i32(cpu_VF, cpu_NF, t0_32); - tcg_gen_xor_i32(tmp, t0_32, t1_32); - tcg_gen_andc_i32(cpu_VF, cpu_VF, tmp); - tcg_gen_extu_i32_i64(dest, cpu_NF); + gen_add32_CC(dest, t0, t1); } } =20 /* dest =3D T0 - T1; compute C, N, V and Z flags */ +static void gen_sub64_CC(TCGv_i64 dest, TCGv_i64 t0, TCGv_i64 t1) +{ + /* 64 bit arithmetic */ + TCGv_i64 result, flag, tmp; + + result =3D tcg_temp_new_i64(); + flag =3D tcg_temp_new_i64(); + tcg_gen_sub_i64(result, t0, t1); + + gen_set_NZ64(result); + + tcg_gen_setcond_i64(TCG_COND_GEU, flag, t0, t1); + tcg_gen_extrl_i64_i32(cpu_CF, flag); + + tcg_gen_xor_i64(flag, result, t0); + tmp =3D tcg_temp_new_i64(); + tcg_gen_xor_i64(tmp, t0, t1); + tcg_gen_and_i64(flag, flag, tmp); + tcg_gen_extrh_i64_i32(cpu_VF, flag); + tcg_gen_mov_i64(dest, result); +} + +static void gen_sub32_CC(TCGv_i64 dest, TCGv_i64 t0, TCGv_i64 t1) +{ + /* 32 bit arithmetic */ + TCGv_i32 t0_32 =3D tcg_temp_new_i32(); + TCGv_i32 t1_32 =3D tcg_temp_new_i32(); + TCGv_i32 tmp; + + tcg_gen_extrl_i64_i32(t0_32, t0); + tcg_gen_extrl_i64_i32(t1_32, t1); + tcg_gen_sub_i32(cpu_NF, t0_32, t1_32); + tcg_gen_mov_i32(cpu_ZF, cpu_NF); + tcg_gen_setcond_i32(TCG_COND_GEU, cpu_CF, t0_32, t1_32); + tcg_gen_xor_i32(cpu_VF, cpu_NF, t0_32); + tmp =3D tcg_temp_new_i32(); + tcg_gen_xor_i32(tmp, t0_32, t1_32); + tcg_gen_and_i32(cpu_VF, cpu_VF, tmp); + tcg_gen_extu_i32_i64(dest, cpu_NF); +} + static void gen_sub_CC(int sf, TCGv_i64 dest, TCGv_i64 t0, TCGv_i64 t1) { if (sf) { - /* 64 bit arithmetic */ - TCGv_i64 result, flag, tmp; - - result =3D tcg_temp_new_i64(); - flag =3D tcg_temp_new_i64(); - tcg_gen_sub_i64(result, t0, t1); - - gen_set_NZ64(result); - - tcg_gen_setcond_i64(TCG_COND_GEU, flag, t0, t1); - tcg_gen_extrl_i64_i32(cpu_CF, flag); - - tcg_gen_xor_i64(flag, result, t0); - tmp =3D tcg_temp_new_i64(); - tcg_gen_xor_i64(tmp, t0, t1); - tcg_gen_and_i64(flag, flag, tmp); - tcg_gen_extrh_i64_i32(cpu_VF, flag); - tcg_gen_mov_i64(dest, result); + gen_sub64_CC(dest, t0, t1); } else { - /* 32 bit arithmetic */ - TCGv_i32 t0_32 =3D tcg_temp_new_i32(); - TCGv_i32 t1_32 =3D tcg_temp_new_i32(); - TCGv_i32 tmp; - - tcg_gen_extrl_i64_i32(t0_32, t0); - tcg_gen_extrl_i64_i32(t1_32, t1); - tcg_gen_sub_i32(cpu_NF, t0_32, t1_32); - tcg_gen_mov_i32(cpu_ZF, cpu_NF); - tcg_gen_setcond_i32(TCG_COND_GEU, cpu_CF, t0_32, t1_32); - tcg_gen_xor_i32(cpu_VF, cpu_NF, t0_32); - tmp =3D tcg_temp_new_i32(); - tcg_gen_xor_i32(tmp, t0_32, t1_32); - tcg_gen_and_i32(cpu_VF, cpu_VF, tmp); - tcg_gen_extu_i32_i64(dest, cpu_NF); + gen_sub32_CC(dest, t0, t1); } } =20 --=20 2.34.1 From nobody Mon Feb 9 11:57:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1683902540; cv=none; d=zohomail.com; s=zohoarc; b=U8iTyiK1uNUIFpE4H9hBHs+9ldUQycp+82wLP+TNMvSrGx8Ih09WilXe5VZblMtKuLxwgItRcHGQz9BIxBAg6pU/7RDboVe/aKg0A4m2ECieUkHDWvrpstrfpftputuMRmRFm9aZYPnnFHReesFkymVYDfyOrGXWhgJUZiQ0BSo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683902540; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fCW6odWriUlkFP9ztOtiryfrd1rXN9E7W52Klvr/U7Q=; b=VCPKinKjw5K68f4+Q9VNJdogoJUI4dhGRFXDOWdVfRGeZrbf+XSsvEgZ/iaI1EW7qhNYcoXoLlmCNXc7nNtkWv4D+hx0hXMFpg0GlCtYyJLTm2hT9WmcsWvJD/dikulBpAXLRi9I4O0GIiWbotEBb/APUhOzxChUlGUmRivWU8A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1683902540892307.73011910296157; Fri, 12 May 2023 07:42:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pxTxY-00070f-SV; Fri, 12 May 2023 10:41:28 -0400 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 1pxTxW-0006wU-1y for qemu-devel@nongnu.org; Fri, 12 May 2023 10:41:26 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pxTxI-0004hw-9O for qemu-devel@nongnu.org; Fri, 12 May 2023 10:41:24 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-3f423ac6e2dso45987705e9.2 for ; Fri, 12 May 2023 07:41:11 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id f12-20020a7bcc0c000000b003f17848673fsm28916167wmh.27.2023.05.12.07.41.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 May 2023 07:41:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683902471; x=1686494471; 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=fCW6odWriUlkFP9ztOtiryfrd1rXN9E7W52Klvr/U7Q=; b=Ae3zuFBX6iD0ZHS5CXameQJP07VptOLYx0nVeFvsTkPsCOgu/YEX25Lrbf3lF4Foaf rIQE5rlKyrtCGvp+doZVeMdKd8TAcGvAv1wzzrBKAJT65TrZosqDTRx3t40hVzEggXBF VsqSBEdovPymT7X//8PZFho4mtpzREecVCHRAwdyad+3kgUBTgwDl4puiPoW2BOyrSrn OMJutdCZolZgXk6Z9bTOh/Z7bbR628lQ4fbhCGOXA2hYkpakfql9QX0Y8RDiR1Frk6Tc GaEVCAU0u8JHUzrlDijT4rwHJ62ngEKup8RPgWF4n8ZUChK9Qg4m1hBObGagbwugRBBC KXdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683902471; x=1686494471; 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=fCW6odWriUlkFP9ztOtiryfrd1rXN9E7W52Klvr/U7Q=; b=c893tYTDrMr4unE0bfTDkjCI47+FD/q07BjMFGv4AJIHISVE7Mtu6oHQZdU6otfOG4 nt0qtqo6i4sUN25cZRsbPsFeTX8qeQ7twSDY5YHpXvnAelejf8YU/e5Ll8LX1epLhlzx OZxuIMH9UVRXGlqo5uYSGrcpbtrnX9Mj/ckPu4LY+KDlwjCzlZ/LmoFZQUxdts+m8b5y YIiXRM6sVqAxULoLCsF8UZyXtlP23e0FP+xUZunjgYP1fWiLtX4KEuF+dCoiS76xDM3o IbgQtuXPs/3palGjCvY0fO5fpkaZ7g4N+6+Vh7nAdabDmZvL1iOC76mScuFp6Q7T4Gt8 GrVw== X-Gm-Message-State: AC+VfDydSFQL+7Xi4g6X53OGHwl2bFt48SikFklisllQaUcPnwS1eKcJ WHWyqKVcJt1u5s/rxnDGa856KYsMQhSk4B+QUHo= X-Google-Smtp-Source: ACHHUZ7WxeAvcshpytxwswMldmIlrFBJFpwx/pOIhs+wv7GP7ro+AlkoiM21yuTH8OfyoqqOFOYtbw== X-Received: by 2002:a7b:cc93:0:b0:3f4:2bb3:a5c9 with SMTP id p19-20020a7bcc93000000b003f42bb3a5c9mr9520770wma.8.1683902471015; Fri, 12 May 2023 07:41:11 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PATCH 06/20] target/arm: Convert Add/subtract (immediate) to decodetree Date: Fri, 12 May 2023 15:40:52 +0100 Message-Id: <20230512144106.3608981-7-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230512144106.3608981-1-peter.maydell@linaro.org> References: <20230512144106.3608981-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32a.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1683902541890100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Convert the ADD and SUB (immediate) instructions. Signed-off-by: Richard Henderson [PMM: Rebased; adjusted to use translate.h's TRANS macro] Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/tcg/translate.h | 5 +++ target/arm/tcg/a64.decode | 17 ++++++++ target/arm/tcg/translate-a64.c | 73 ++++++++++------------------------ 3 files changed, 42 insertions(+), 53 deletions(-) diff --git a/target/arm/tcg/translate.h b/target/arm/tcg/translate.h index f02d4685b4c..a9d1f4adc28 100644 --- a/target/arm/tcg/translate.h +++ b/target/arm/tcg/translate.h @@ -220,6 +220,11 @@ static inline int rsub_8(DisasContext *s, int x) return 8 - x; } =20 +static inline int shl_12(DisasContext *s, int x) +{ + return x << 12; +} + static inline int neon_3same_fp_size(DisasContext *s, int x) { /* Convert 0=3D=3Dfp32, 1=3D=3Dfp16 into a MO_* value */ diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode index bcf46fc37d7..30c2ac7e271 100644 --- a/target/arm/tcg/a64.decode +++ b/target/arm/tcg/a64.decode @@ -20,6 +20,7 @@ # =20 &ri rd imm +&rri_sf rd rn imm sf =20 =20 ### Data Processing - Immediate @@ -31,3 +32,19 @@ =20 ADR 0 .. 10000 ................... ..... @pcrel ADRP 1 .. 10000 ................... ..... @pcrel + +# Add/subtract (immediate) + +%imm12_sh12 10:12 !function=3Dshl_12 +@addsub_imm sf:1 .. ...... . imm:12 rn:5 rd:5 +@addsub_imm12 sf:1 .. ...... . ............ rn:5 rd:5 imm=3D%imm12_sh12 + +ADD_i . 00 100010 0 ............ ..... ..... @addsub_imm +ADD_i . 00 100010 1 ............ ..... ..... @addsub_imm12 +ADDS_i . 01 100010 0 ............ ..... ..... @addsub_imm +ADDS_i . 01 100010 1 ............ ..... ..... @addsub_imm12 + +SUB_i . 10 100010 0 ............ ..... ..... @addsub_imm +SUB_i . 10 100010 1 ............ ..... ..... @addsub_imm12 +SUBS_i . 11 100010 0 ............ ..... ..... @addsub_imm +SUBS_i . 11 100010 1 ............ ..... ..... @addsub_imm12 diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index a3bccbd708a..fb12122a3fb 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -4198,6 +4198,22 @@ static void disas_ldst(DisasContext *s, uint32_t ins= n) } } =20 +typedef void ArithTwoOp(TCGv_i64, TCGv_i64, TCGv_i64); + +static bool gen_rri(DisasContext *s, arg_rri_sf *a, + bool rd_sp, bool rn_sp, ArithTwoOp *fn) +{ + TCGv_i64 tcg_rn =3D rn_sp ? cpu_reg_sp(s, a->rn) : cpu_reg(s, a->rn); + TCGv_i64 tcg_rd =3D rd_sp ? cpu_reg_sp(s, a->rd) : cpu_reg(s, a->rd); + TCGv_i64 tcg_imm =3D tcg_constant_i64(a->imm); + + fn(tcg_rd, tcg_rn, tcg_imm); + if (!a->sf) { + tcg_gen_ext32u_i64(tcg_rd, tcg_rd); + } + return true; +} + /* * PC-rel. addressing */ @@ -4220,57 +4236,11 @@ static bool trans_ADRP(DisasContext *s, arg_ri *a) =20 /* * Add/subtract (immediate) - * - * 31 30 29 28 23 22 21 10 9 5 4 0 - * +--+--+--+-------------+--+-------------+-----+-----+ - * |sf|op| S| 1 0 0 0 1 0 |sh| imm12 | Rn | Rd | - * +--+--+--+-------------+--+-------------+-----+-----+ - * - * sf: 0 -> 32bit, 1 -> 64bit - * op: 0 -> add , 1 -> sub - * S: 1 -> set flags - * sh: 1 -> LSL imm by 12 */ -static void disas_add_sub_imm(DisasContext *s, uint32_t insn) -{ - int rd =3D extract32(insn, 0, 5); - int rn =3D extract32(insn, 5, 5); - uint64_t imm =3D extract32(insn, 10, 12); - bool shift =3D extract32(insn, 22, 1); - bool setflags =3D extract32(insn, 29, 1); - bool sub_op =3D extract32(insn, 30, 1); - bool is_64bit =3D extract32(insn, 31, 1); - - TCGv_i64 tcg_rn =3D cpu_reg_sp(s, rn); - TCGv_i64 tcg_rd =3D setflags ? cpu_reg(s, rd) : cpu_reg_sp(s, rd); - TCGv_i64 tcg_result; - - if (shift) { - imm <<=3D 12; - } - - tcg_result =3D tcg_temp_new_i64(); - if (!setflags) { - if (sub_op) { - tcg_gen_subi_i64(tcg_result, tcg_rn, imm); - } else { - tcg_gen_addi_i64(tcg_result, tcg_rn, imm); - } - } else { - TCGv_i64 tcg_imm =3D tcg_constant_i64(imm); - if (sub_op) { - gen_sub_CC(is_64bit, tcg_result, tcg_rn, tcg_imm); - } else { - gen_add_CC(is_64bit, tcg_result, tcg_rn, tcg_imm); - } - } - - if (is_64bit) { - tcg_gen_mov_i64(tcg_rd, tcg_result); - } else { - tcg_gen_ext32u_i64(tcg_rd, tcg_result); - } -} +TRANS(ADD_i, gen_rri, a, 1, 1, tcg_gen_add_i64) +TRANS(SUB_i, gen_rri, a, 1, 1, tcg_gen_sub_i64) +TRANS(ADDS_i, gen_rri, a, 0, 1, a->sf ? gen_add64_CC : gen_add32_CC) +TRANS(SUBS_i, gen_rri, a, 0, 1, a->sf ? gen_sub64_CC : gen_sub32_CC) =20 /* * Add/subtract (immediate, with tags) @@ -4668,9 +4638,6 @@ static void disas_extract(DisasContext *s, uint32_t i= nsn) static void disas_data_proc_imm(DisasContext *s, uint32_t insn) { switch (extract32(insn, 23, 6)) { - case 0x22: /* Add/subtract (immediate) */ - disas_add_sub_imm(s, insn); - break; case 0x23: /* Add/subtract (immediate, with tags) */ disas_add_sub_imm_with_tags(s, insn); break; --=20 2.34.1 From nobody Mon Feb 9 11:57:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1683902738; cv=none; d=zohomail.com; s=zohoarc; b=keQ2/cpTzQg0aq+ylAhrl8YccAL6zVWVeLW69cAi0mUp4o8B9A3yg0offXoofLDojxQtdfv/tNmzXy2Uzn3f1Dw6ldbF7HCbXO+nsHXtJvk9REUiZ9moj5wkoQchWFZdM5UEF+IA4vgnidUIGlV3SDj5v+NXvMYgwltfXOc5q+U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683902738; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hQ1oqtC4DuCr//tYDK0BhT/RRzDG+KYHXcvP6HahZio=; b=WeoDC/7R5uWOr21XDb8mYWmNXFV1PQzn5UTsc6cVZOy9kIjHeGEPPgMXboWRraPASSg0XOGVXAfaSRKUhtHGtivXvVyV7IQyfcRsUv1wWg9MGIYPmbVI97e6YtgpeCYDLUzToSiYycJQI/ta7L9bJasWM/xx4wz0tsRgJ2NPYg4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1683902738764389.82542449906305; Fri, 12 May 2023 07:45:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pxTxW-0006xI-FF; Fri, 12 May 2023 10:41:26 -0400 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 1pxTxV-0006vD-0D for qemu-devel@nongnu.org; Fri, 12 May 2023 10:41:25 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pxTxJ-0004iH-Ki for qemu-devel@nongnu.org; Fri, 12 May 2023 10:41:24 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-3f435658d23so39601665e9.3 for ; Fri, 12 May 2023 07:41:12 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id f12-20020a7bcc0c000000b003f17848673fsm28916167wmh.27.2023.05.12.07.41.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 May 2023 07:41:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683902471; x=1686494471; 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=hQ1oqtC4DuCr//tYDK0BhT/RRzDG+KYHXcvP6HahZio=; b=Lv05wGfSZYTUjO36rR0B0NTQR/2Q2ApVA3ljqstbWN4wLDb2dXME6kg831QQXdj7dE wklNzgMMBcSaOrdWJ/bCH4pwSdQsOZkt11e4Kl5oL2+itLRSgiCEoB7Dnd6XZTEG4iZJ 471ut/tz3yz2ztvQvZBii88MI/2xrjGRK+Dy+GgmB+9dKYSwq6O33eMItD6+93mJ0gfG 6VEbFjJ5NdRp9uVi+PkyTKwREN2XgMqgW6OvbrRixf6rT5gwWr67PElUNbBMmzaMYW4q D7NUlCxMdwiyi/FhxI8blGXQUdsLNWwN0ufSiEomw5iWLQr7NcAqpN5cKx4rTWtLtHwR dN3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683902471; x=1686494471; 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=hQ1oqtC4DuCr//tYDK0BhT/RRzDG+KYHXcvP6HahZio=; b=OHt4IWI9vM1t4xrjauoHqu7AaCfZFPLNuUgXoWfDl/Qwj+PBAR58mrLS4MgUx/pbAT FIkLE/KtiLUm9ao2Hu85D/znnuU4fmwjK8Q4wgee0z/mByAp4HSnwFPfLsqgPt7ibTUS WPi8yZjOIvmFrf8SZPNE8+MRGCWunGPL+n0i+FVCISPLW8LfNBpbsD/cH578eP40K8fG 4K2RZ5KhXOqzzN+rAHwFPF3/L4Dkvd9c0fv3XExpQO0cn0x3wSz1Y0ttGBSCF6sKDw5I ra+I2vKc1NWGkVg33nS07FSos90QJX5uv4bgxXd6o3HkOReVqRmbjxaRX5VQHW4RaF3p JmYA== X-Gm-Message-State: AC+VfDz8NmJBCfofnpBeR5GaWF+9vcgOs+OBrIVy5L5k67Cxy54xZxJR PwRbVi1uRGVqgwoooUkVgcEpzQ== X-Google-Smtp-Source: ACHHUZ548s3N1EpAvoYj/rBb1YEGDAiXjQkqeN5xoqVAMdzrqW08ogOhavn+xLBQdj4nSSBIswQDAA== X-Received: by 2002:a05:600c:2047:b0:3f4:2452:9675 with SMTP id p7-20020a05600c204700b003f424529675mr12909989wmg.0.1683902471601; Fri, 12 May 2023 07:41:11 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PATCH 07/20] target/arm: Convert Add/subtract (immediate with tags) to decodetree Date: Fri, 12 May 2023 15:40:53 +0100 Message-Id: <20230512144106.3608981-8-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230512144106.3608981-1-peter.maydell@linaro.org> References: <20230512144106.3608981-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32e.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1683902740616100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Convert the ADDG and SUBG (immediate) instructions. Signed-off-by: Richard Henderson [PMM: Rebased; use TRANS_FEAT()] Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/tcg/a64.decode | 8 +++++++ target/arm/tcg/translate-a64.c | 38 ++++++++++------------------------ 2 files changed, 19 insertions(+), 27 deletions(-) diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode index 30c2ac7e271..ed03d9e1349 100644 --- a/target/arm/tcg/a64.decode +++ b/target/arm/tcg/a64.decode @@ -48,3 +48,11 @@ SUB_i . 10 100010 0 ............ ..... ..... = @addsub_imm SUB_i . 10 100010 1 ............ ..... ..... @addsub_imm12 SUBS_i . 11 100010 0 ............ ..... ..... @addsub_imm SUBS_i . 11 100010 1 ............ ..... ..... @addsub_imm12 + +# Add/subtract (immediate with tags) + +&rri_tag rd rn uimm6 uimm4 +@addsub_imm_tag . .. ...... . uimm6:6 .. uimm4:4 rn:5 rd:5 &rri_tag + +ADDG_i 1 00 100011 0 ...... 00 .... ..... ..... @addsub_imm_tag +SUBG_i 1 10 100011 0 ...... 00 .... ..... ..... @addsub_imm_tag diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index fb12122a3fb..3636eaadce6 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -4244,49 +4244,36 @@ TRANS(SUBS_i, gen_rri, a, 0, 1, a->sf ? gen_sub64_C= C : gen_sub32_CC) =20 /* * Add/subtract (immediate, with tags) - * - * 31 30 29 28 23 22 21 16 14 10 9 5 4 0 - * +--+--+--+-------------+--+---------+--+-------+-----+-----+ - * |sf|op| S| 1 0 0 0 1 1 |o2| uimm6 |o3| uimm4 | Rn | Rd | - * +--+--+--+-------------+--+---------+--+-------+-----+-----+ - * - * op: 0 -> add, 1 -> sub */ -static void disas_add_sub_imm_with_tags(DisasContext *s, uint32_t insn) + +static bool gen_add_sub_imm_with_tags(DisasContext *s, arg_rri_tag *a, + bool sub_op) { - int rd =3D extract32(insn, 0, 5); - int rn =3D extract32(insn, 5, 5); - int uimm4 =3D extract32(insn, 10, 4); - int uimm6 =3D extract32(insn, 16, 6); - bool sub_op =3D extract32(insn, 30, 1); TCGv_i64 tcg_rn, tcg_rd; int imm; =20 - /* Test all of sf=3D1, S=3D0, o2=3D0, o3=3D0. */ - if ((insn & 0xa040c000u) !=3D 0x80000000u || - !dc_isar_feature(aa64_mte_insn_reg, s)) { - unallocated_encoding(s); - return; - } - - imm =3D uimm6 << LOG2_TAG_GRANULE; + imm =3D a->uimm6 << LOG2_TAG_GRANULE; if (sub_op) { imm =3D -imm; } =20 - tcg_rn =3D cpu_reg_sp(s, rn); - tcg_rd =3D cpu_reg_sp(s, rd); + tcg_rn =3D cpu_reg_sp(s, a->rn); + tcg_rd =3D cpu_reg_sp(s, a->rd); =20 if (s->ata) { gen_helper_addsubg(tcg_rd, cpu_env, tcg_rn, tcg_constant_i32(imm), - tcg_constant_i32(uimm4)); + tcg_constant_i32(a->uimm4)); } else { tcg_gen_addi_i64(tcg_rd, tcg_rn, imm); gen_address_with_allocation_tag0(tcg_rd, tcg_rd); } + return true; } =20 +TRANS_FEAT(ADDG_i, aa64_mte_insn_reg, gen_add_sub_imm_with_tags, a, false) +TRANS_FEAT(SUBG_i, aa64_mte_insn_reg, gen_add_sub_imm_with_tags, a, true) + /* The input should be a value in the bottom e bits (with higher * bits zero); returns that value replicated into every element * of size e in a 64 bit integer. @@ -4638,9 +4625,6 @@ static void disas_extract(DisasContext *s, uint32_t i= nsn) static void disas_data_proc_imm(DisasContext *s, uint32_t insn) { switch (extract32(insn, 23, 6)) { - case 0x23: /* Add/subtract (immediate, with tags) */ - disas_add_sub_imm_with_tags(s, insn); - break; case 0x24: /* Logical (immediate) */ disas_logic_imm(s, insn); break; --=20 2.34.1 From nobody Mon Feb 9 11:57:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1683902814; cv=none; d=zohomail.com; s=zohoarc; b=lxkAlPJa95AKATss37B3UPF3OVqac3Gf1G6bPSbK8zkSocGpNuWGVT5F4spU2/uekvawAbpqMzvqCEUtiLXX+W49oNBe5QwM4XRHR1qx1AnBGEeduJX5xN8o4cMi1m5CyWjHxG1047wJ7gnoavLPX+N5qCYp8TzxIjWKg9ka4yc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683902814; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=revwXBl9aAHbzWWzTWkngt/4BFcUn4Y6B3F5VwQ0pkc=; b=TKx54t0pCV+eVFX+n+upOAu28586oNgX2mgxbgR0Q8hgddcM+EC+iX7yYSFMjpRFONDaOKQ7so4Nhmn12yrhzamRY/CfZThWGi/ZOhQvLNquTedaVSyQJQ9WRLMun66TwViiPPbZ153tmjvP3aLMMupITDbh8DUWOgEq75KGrsQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1683902814342750.5548466626598; Fri, 12 May 2023 07:46:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pxTxZ-00072l-HC; Fri, 12 May 2023 10:41:29 -0400 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 1pxTxX-0006zm-RS for qemu-devel@nongnu.org; Fri, 12 May 2023 10:41:27 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pxTxK-0004iP-IT for qemu-devel@nongnu.org; Fri, 12 May 2023 10:41:27 -0400 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-3078fa679a7so6634540f8f.3 for ; Fri, 12 May 2023 07:41:14 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id f12-20020a7bcc0c000000b003f17848673fsm28916167wmh.27.2023.05.12.07.41.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 May 2023 07:41:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683902472; x=1686494472; 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=revwXBl9aAHbzWWzTWkngt/4BFcUn4Y6B3F5VwQ0pkc=; b=AebWqY1uM8EQ5unNUediWojh8XSgR7Q+xa6neZmITkvjsoxr2i8cXx5qfFz9gvSQMi Xd6GHZEREsd8n2jOvNBUTFr0UhlGPvXVAeoKBFLRtA2e/jmDqTcgzviSVq60CkrJc4u6 T6ZtWMrSwHTzFKNAr5ogQ3c64ke+Kq/chIuPD4YVQdBckgaoqzSnN+3pUBQLERSal4BH 85WReke8FfOrmHs8xZGGUDvIVZnZWXvtXV0iFwHrAjY9Zu+j+5ihMudbF6YcGgqCf38b IErwnfrP9mxz73d/vmdUsw5AXR/4kHh5PuRYtR/uM7bE5B/RHQqszHpXpG/VCo/XC2/W BoMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683902472; x=1686494472; 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=revwXBl9aAHbzWWzTWkngt/4BFcUn4Y6B3F5VwQ0pkc=; b=cZwX5NPiQNBblMRr2gl1KucmGtEb+PExCVn2qkl+Z//7dp0iE7uWqIGzL6WDFGhQex FuUf2I2qbKkHIw+KbgqVesIpmW42plYF/FQGDaWO9RvC2neXyvtTcLRxOVL9Ijh6UxPN pRBNalMz5llMx7VZb9DjEkcn4/R0lR1GeSoBalUKDH8u/rcIoXjumj1tBpy4gQ8TNOsT 3f+il2KsZD0f2dPDBdIENYVbirNZ5+Oz+ZY6+Uuaz1XswFV0rvXlofWI4RH8ozLsGjE3 4PKHvM9xN7A+e/QcS/rRlpNa7T/kzKbxdkqJGSb1TWgwxRM8Q34iEzns6tpo9FoeZAiu KbPg== X-Gm-Message-State: AC+VfDzLlmoAUdtfWnCvwDJDlLvLux3Dx/nTyDxxO3cI9Y1PpGlWt4JN lM91dW8wetUFxti44vk2xhPWjA== X-Google-Smtp-Source: ACHHUZ6YxPS9NFzKoJzG7XG7tSZXi8+wE+PcbE8SFB6ZV36uROWTTHqS8yiPC2pKJlLMCgdoukHtxQ== X-Received: by 2002:a5d:58f4:0:b0:306:8f5b:1b49 with SMTP id f20-20020a5d58f4000000b003068f5b1b49mr18647587wrd.47.1683902472114; Fri, 12 May 2023 07:41:12 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PATCH 08/20] target/arm: Replace bitmask64 with MAKE_64BIT_MASK Date: Fri, 12 May 2023 15:40:54 +0100 Message-Id: <20230512144106.3608981-9-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230512144106.3608981-1-peter.maydell@linaro.org> References: <20230512144106.3608981-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42a.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=unavailable 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1683902814755100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Use the bitops.h macro rather than rolling our own here. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/tcg/translate-a64.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 3636eaadce6..ca944344a6b 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -4288,13 +4288,6 @@ static uint64_t bitfield_replicate(uint64_t mask, un= signed int e) return mask; } =20 -/* Return a value with the bottom len bits set (where 0 < len <=3D 64) */ -static inline uint64_t bitmask64(unsigned int length) -{ - assert(length > 0 && length <=3D 64); - return ~0ULL >> (64 - length); -} - /* Simplified variant of pseudocode DecodeBitMasks() for the case where we * only require the wmask. Returns false if the imms/immr/immn are a reser= ved * value (ie should cause a guest UNDEF exception), and true if they are @@ -4350,10 +4343,10 @@ bool logic_imm_decode_wmask(uint64_t *result, unsig= ned int immn, /* Create the value of one element: s+1 set bits rotated * by r within the element (which is e bits wide)... */ - mask =3D bitmask64(s + 1); + mask =3D MAKE_64BIT_MASK(0, s + 1); if (r) { mask =3D (mask >> r) | (mask << (e - r)); - mask &=3D bitmask64(e); + mask &=3D MAKE_64BIT_MASK(0, e); } /* ...then replicate the element over the whole 64 bit value */ mask =3D bitfield_replicate(mask, e); --=20 2.34.1 From nobody Mon Feb 9 11:57:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1683902638; cv=none; d=zohomail.com; s=zohoarc; b=MSft2LiouuYbK9bG1Wb6yZ2mgz+2Sqrx5fzy+B/WP1Ffz+rOXDRc86H/i/ult3D2qCeNAJ8tcIywFpqMEeLUgq2mVDMMuOLqSpWlkjcvwV+bX3TWF7bl3Ent93oDmKGG6a/fiDsIYeTI61d4fn7ATDo1mcypaWFGjVNukMOJwCI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683902638; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8VmUpPNfulKIqx7VImc6HCqVD/o1vD/KA6yv49cC5Pk=; b=BafMgIlO83Wh0sqtWZ56E0MoS74fztkmbt7NzLGyV6AxBUD35zqUkLaDNdnpyUYC5MENaLOgcxFpW8ST95H9qXyFezD/2m1FJV33LrvOOVhQVx3RESOh5V0JLYqTYfzDlwc0MmhdS7TZK+APzVZDZrgomZvPaAKNef0ajWNS1gQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1683902638648756.9686177215491; Fri, 12 May 2023 07:43:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pxTxb-000776-LS; Fri, 12 May 2023 10:41:31 -0400 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 1pxTxX-0006zS-E4 for qemu-devel@nongnu.org; Fri, 12 May 2023 10:41:27 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pxTxK-0004ik-0B for qemu-devel@nongnu.org; Fri, 12 May 2023 10:41:27 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-3f4449fa085so26633345e9.0 for ; Fri, 12 May 2023 07:41:13 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id f12-20020a7bcc0c000000b003f17848673fsm28916167wmh.27.2023.05.12.07.41.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 May 2023 07:41:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683902472; x=1686494472; 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=8VmUpPNfulKIqx7VImc6HCqVD/o1vD/KA6yv49cC5Pk=; b=WkN4qbdM4TZboZpOGxUiETjS0PMDx1HDufS6f1CtR1/CbGT/soJ+SoccohO+jgh/Ou 5A65QMaee5+XmT0HfGem39r/DLRS4jXO4L3uxeWNHAJlgI3XAZv9TdnQ4t3PT6fJ5bj+ fos/VQJ9WbZcp69m1Sur4NDzbfW6uIIILcbG9e6jF18Dz5jA7Xd0suLPS6f947gIvtnC t4l206ru/yDzb/hgX0VXwiE2BriiZHKNctEIE+0LJ6Sk//QkHCHIyqSl6KV4cphdotzH sKdWB7gpR15LFi/eHY0EU25HF7pk0xBlJAHvQ5s9NKxJPcMFBjX9fd2TFGWHAMUOIanG JOnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683902472; x=1686494472; 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=8VmUpPNfulKIqx7VImc6HCqVD/o1vD/KA6yv49cC5Pk=; b=TG+V9S+AeTajHtOSxzb3i9voBTMjzgH7Fs4puTCUS4XPH4ZraMI2RMMk5O2I3cwMAu TiADMKkp0emCb522Og72d1PR60MldYEtTgpOWWX5nsOomwjSORJOAW6vC4sb+Cv7P3Fg H4rOyJDlQayg8W1Uq+1e28f3Gu1JAmor7cbYzfLk0ncqa0AdVHmTpor4hujNP1K9QROR nErEljS5v36nlzt50bORF1twG1+FY/sdMguEzChWHGp1NNL+5T3JKyrqYVAVw/wslKVY GujNBQ/WBLv6LFGoWbkS4s2Heiv9lFiV+KngTmm7msVxDGrxqm0zBL7twpO+xMUGT2iu rn9w== X-Gm-Message-State: AC+VfDzFO2KQSaWhAYO0l8rNHTTsimsu/3k5wWdoMphoEav471NiGk7n cVwPfwez4Lndq5taBlqTzVLa5ydUoaBs4CUwJ+I= X-Google-Smtp-Source: ACHHUZ55MmbWyHHtxBWIwoFlSLSjvOqtsAw4v3lxzWlCnx2l8PTEp9YaBrGm0WifI5RDbKiKDGqTIQ== X-Received: by 2002:a05:600c:22ca:b0:3f4:2158:289b with SMTP id 10-20020a05600c22ca00b003f42158289bmr15127227wmg.18.1683902472594; Fri, 12 May 2023 07:41:12 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PATCH 09/20] target/arm: Convert Logical (immediate) to decodetree Date: Fri, 12 May 2023 15:40:55 +0100 Message-Id: <20230512144106.3608981-10-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230512144106.3608981-1-peter.maydell@linaro.org> References: <20230512144106.3608981-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32a.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1683902640367100009 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Convert the ADD, ORR, EOR, ANDS (immediate) instructions. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell [PMM: rebased] Signed-off-by: Peter Maydell --- target/arm/tcg/a64.decode | 15 ++++++ target/arm/tcg/translate-a64.c | 94 +++++++++++----------------------- 2 files changed, 44 insertions(+), 65 deletions(-) diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode index ed03d9e1349..1933afa457b 100644 --- a/target/arm/tcg/a64.decode +++ b/target/arm/tcg/a64.decode @@ -56,3 +56,18 @@ SUBS_i . 11 100010 1 ............ ..... ..... = @addsub_imm12 =20 ADDG_i 1 00 100011 0 ...... 00 .... ..... ..... @addsub_imm_tag SUBG_i 1 10 100011 0 ...... 00 .... ..... ..... @addsub_imm_tag + +# Logical (immediate) + +&rri_log rd rn sf dbm +@logic_imm_64 1 .. ...... dbm:13 rn:5 rd:5 &rri_log sf=3D1 +@logic_imm_32 0 .. ...... 0 dbm:12 rn:5 rd:5 &rri_log sf=3D0 + +AND_i . 00 100100 . ...... ...... ..... ..... @logic_imm_64 +AND_i . 00 100100 . ...... ...... ..... ..... @logic_imm_32 +ORR_i . 01 100100 . ...... ...... ..... ..... @logic_imm_64 +ORR_i . 01 100100 . ...... ...... ..... ..... @logic_imm_32 +EOR_i . 10 100100 . ...... ...... ..... ..... @logic_imm_64 +EOR_i . 10 100100 . ...... ...... ..... ..... @logic_imm_32 +ANDS_i . 11 100100 . ...... ...... ..... ..... @logic_imm_64 +ANDS_i . 11 100100 . ...... ...... ..... ..... @logic_imm_32 diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index ca944344a6b..1273c4de456 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -4288,7 +4288,12 @@ static uint64_t bitfield_replicate(uint64_t mask, un= signed int e) return mask; } =20 -/* Simplified variant of pseudocode DecodeBitMasks() for the case where we +/* + * Logical (immediate) + */ + +/* + * Simplified variant of pseudocode DecodeBitMasks() for the case where we * only require the wmask. Returns false if the imms/immr/immn are a reser= ved * value (ie should cause a guest UNDEF exception), and true if they are * valid, in which case the decoded bit pattern is written to result. @@ -4354,78 +4359,40 @@ bool logic_imm_decode_wmask(uint64_t *result, unsig= ned int immn, return true; } =20 -/* Logical (immediate) - * 31 30 29 28 23 22 21 16 15 10 9 5 4 0 - * +----+-----+-------------+---+------+------+------+------+ - * | sf | opc | 1 0 0 1 0 0 | N | immr | imms | Rn | Rd | - * +----+-----+-------------+---+------+------+------+------+ - */ -static void disas_logic_imm(DisasContext *s, uint32_t insn) +static bool gen_rri_log(DisasContext *s, arg_rri_log *a, bool set_cc, + void (*fn)(TCGv_i64, TCGv_i64, int64_t)) { - unsigned int sf, opc, is_n, immr, imms, rn, rd; TCGv_i64 tcg_rd, tcg_rn; - uint64_t wmask; - bool is_and =3D false; + uint64_t imm; =20 - sf =3D extract32(insn, 31, 1); - opc =3D extract32(insn, 29, 2); - is_n =3D extract32(insn, 22, 1); - immr =3D extract32(insn, 16, 6); - imms =3D extract32(insn, 10, 6); - rn =3D extract32(insn, 5, 5); - rd =3D extract32(insn, 0, 5); - - if (!sf && is_n) { - unallocated_encoding(s); - return; + /* Some immediate field values are reserved. */ + if (!logic_imm_decode_wmask(&imm, extract32(a->dbm, 12, 1), + extract32(a->dbm, 0, 6), + extract32(a->dbm, 6, 6))) { + return false; + } + if (!a->sf) { + imm &=3D 0xffffffffull; } =20 - if (opc =3D=3D 0x3) { /* ANDS */ - tcg_rd =3D cpu_reg(s, rd); - } else { - tcg_rd =3D cpu_reg_sp(s, rd); - } - tcg_rn =3D cpu_reg(s, rn); + tcg_rd =3D set_cc ? cpu_reg(s, a->rd) : cpu_reg_sp(s, a->rd); + tcg_rn =3D cpu_reg(s, a->rn); =20 - if (!logic_imm_decode_wmask(&wmask, is_n, imms, immr)) { - /* some immediate field values are reserved */ - unallocated_encoding(s); - return; + fn(tcg_rd, tcg_rn, imm); + if (set_cc) { + gen_logic_CC(a->sf, tcg_rd); } - - if (!sf) { - wmask &=3D 0xffffffff; - } - - switch (opc) { - case 0x3: /* ANDS */ - case 0x0: /* AND */ - tcg_gen_andi_i64(tcg_rd, tcg_rn, wmask); - is_and =3D true; - break; - case 0x1: /* ORR */ - tcg_gen_ori_i64(tcg_rd, tcg_rn, wmask); - break; - case 0x2: /* EOR */ - tcg_gen_xori_i64(tcg_rd, tcg_rn, wmask); - break; - default: - assert(FALSE); /* must handle all above */ - break; - } - - if (!sf && !is_and) { - /* zero extend final result; we know we can skip this for AND - * since the immediate had the high 32 bits clear. - */ + if (!a->sf) { tcg_gen_ext32u_i64(tcg_rd, tcg_rd); } - - if (opc =3D=3D 3) { /* ANDS */ - gen_logic_CC(sf, tcg_rd); - } + return true; } =20 +TRANS(AND_i, gen_rri_log, a, false, tcg_gen_andi_i64) +TRANS(ORR_i, gen_rri_log, a, false, tcg_gen_ori_i64) +TRANS(EOR_i, gen_rri_log, a, false, tcg_gen_xori_i64) +TRANS(ANDS_i, gen_rri_log, a, true, tcg_gen_andi_i64) + /* * Move wide (immediate) * @@ -4618,9 +4585,6 @@ static void disas_extract(DisasContext *s, uint32_t i= nsn) static void disas_data_proc_imm(DisasContext *s, uint32_t insn) { switch (extract32(insn, 23, 6)) { - case 0x24: /* Logical (immediate) */ - disas_logic_imm(s, insn); - break; case 0x25: /* Move wide (immediate) */ disas_movw_imm(s, insn); break; --=20 2.34.1 From nobody Mon Feb 9 11:57:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1683902594; cv=none; d=zohomail.com; s=zohoarc; b=lOh1LNmOD1dAyczMoFR8mf2BXe0DMSIF8UEx/xFL+yEPmhKAz7rdLoJrp8v/lUsKKt0FuyqcyDvxCFMdobracMvycs1PokI0Z2Gf2Lik5eWGpzpR6GUOaZ30mxXOIL0B4WkMprmM34zPs9QxOX+I30WATNsmMdZrhcADS6bR+bE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683902594; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Nzdtd8sSIBwgurLXo/J3BqpDdo3UGdPx+81efDnWFSc=; b=VzCwH/S/zOZcEHCsoWU3VaKwN6oX4EMkIAgGhOiu+rq0pmMhtbwEKRGw8abtPAfPuzVuQgPzOguaGxyxB4Wx8pbZe/oC2NysYVyZVlYOROiZJ6tLFEYtn0cM+dzFxYgUh4tAaYk3D1sYMXJ0cuKQaAIT9/uvJD4GDJgZeCOywhw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 168390259478326.981696930845715; Fri, 12 May 2023 07:43:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pxTxb-00076R-8O; Fri, 12 May 2023 10:41:31 -0400 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 1pxTxY-00071Y-T3 for qemu-devel@nongnu.org; Fri, 12 May 2023 10:41:28 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pxTxK-0004j2-IP for qemu-devel@nongnu.org; Fri, 12 May 2023 10:41:28 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-3f415a90215so77656135e9.0 for ; Fri, 12 May 2023 07:41:13 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id f12-20020a7bcc0c000000b003f17848673fsm28916167wmh.27.2023.05.12.07.41.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 May 2023 07:41:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683902473; x=1686494473; 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=Nzdtd8sSIBwgurLXo/J3BqpDdo3UGdPx+81efDnWFSc=; b=nYq+L2cqItWFFHTDHAFPB6RmQyZyQWl7BQo8w/cldvMZ3F/Tc/DUAabHWbwiBwSFLM 8k4adEW3y3ckjvILkQ+Uu8lsTqXNPMN/cExxmljZVqYlqqI+QbICf8tviZ4T1Y1FzqYt qcES4CXyp+XAi8t/yRbZ/DQlQ3vqXKxDpdmgy6ZVRg2QB+31q3diFG6UkLyfwu4ICQSq sYomkmWjahQejtbuLugL/19Qjs6APkDhgTJYyjOE42qBgMaPs0a9qH6GC6T+24o7PU4p kesXbGLpBOXTRocIICXjCgzzKCaF8GMXuAO+MnkvDRDRbsILlEjhV2ATBAIMcC2kg3w5 yR3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683902473; x=1686494473; 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=Nzdtd8sSIBwgurLXo/J3BqpDdo3UGdPx+81efDnWFSc=; b=TByXLUzy3MqIQCz3LZmiLmzW9ZP9II4qiVi5yXW9Lb5RNJb0mGxeZqLSWccnGaFG8A f1MuYJ6ps4it8D04Dk9/selsB7nw8wEV+g+8UYvQ6Hlk32Ej6WlA6/1tfrCBTi3Zb8Sc mkb62ordqyrtqBQCZomOMC6E/yU3jB8CKX5rOYBEd4ZUti3E4wy/oxZEgbIKalRmKi+F U386v4ns1NIwLiSxjP2NRiItNZmzK/VOYHI4kI3U38pe1Ic4Pydux6Z+EwSgc2bbX/iJ C1JNbAI8DtNOUEQghcJoRBuSWeNutSXNCVgQf5F5xmzeNINWOkMZVNDMpY1juUF8RD6t Pwdg== X-Gm-Message-State: AC+VfDwrrbEwRRfkinujYF7BAbIBfMrA3vZyD4QuFE9G60s+5bh6yoI/ YwKs+u9+hSj2DiFFoXHPS/DnZQ== X-Google-Smtp-Source: ACHHUZ7vTSiv+aHnGPEfNJqa8ZN3TjFNEpti17LkcOoR8qz+nnYpGtQo3MQBrEsLcCnC0udQOMUDMw== X-Received: by 2002:a7b:ca42:0:b0:3f1:6fb3:ffcc with SMTP id m2-20020a7bca42000000b003f16fb3ffccmr16752655wml.22.1683902473125; Fri, 12 May 2023 07:41:13 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PATCH 10/20] target/arm: Convert Move wide (immediate) to decodetree Date: Fri, 12 May 2023 15:40:56 +0100 Message-Id: <20230512144106.3608981-11-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230512144106.3608981-1-peter.maydell@linaro.org> References: <20230512144106.3608981-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32e.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1683902596271100005 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Convert the MON, MOVZ, MOVK instructions. Signed-off-by: Richard Henderson [PMM: Rebased] Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/tcg/a64.decode | 13 ++++++ target/arm/tcg/translate-a64.c | 73 ++++++++++++++-------------------- 2 files changed, 42 insertions(+), 44 deletions(-) diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode index 1933afa457b..350b37c8f37 100644 --- a/target/arm/tcg/a64.decode +++ b/target/arm/tcg/a64.decode @@ -71,3 +71,16 @@ EOR_i . 10 100100 . ...... ...... ..... ..... = @logic_imm_64 EOR_i . 10 100100 . ...... ...... ..... ..... @logic_imm_32 ANDS_i . 11 100100 . ...... ...... ..... ..... @logic_imm_64 ANDS_i . 11 100100 . ...... ...... ..... ..... @logic_imm_32 + +# Move wide (immediate) + +&movw rd sf imm hw +@movw_64 1 .. ...... hw:2 imm:16 rd:5 &movw sf=3D1 +@movw_32 0 .. ...... 0 hw:1 imm:16 rd:5 &movw sf=3D0 + +MOVN . 00 100101 .. ................ ..... @movw_64 +MOVN . 00 100101 .. ................ ..... @movw_32 +MOVZ . 10 100101 .. ................ ..... @movw_64 +MOVZ . 10 100101 .. ................ ..... @movw_32 +MOVK . 11 100101 .. ................ ..... @movw_64 +MOVK . 11 100101 .. ................ ..... @movw_32 diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 1273c4de456..a36b98925fb 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -4395,52 +4395,40 @@ TRANS(ANDS_i, gen_rri_log, a, true, tcg_gen_andi_i6= 4) =20 /* * Move wide (immediate) - * - * 31 30 29 28 23 22 21 20 5 4 0 - * +--+-----+-------------+-----+----------------+------+ - * |sf| opc | 1 0 0 1 0 1 | hw | imm16 | Rd | - * +--+-----+-------------+-----+----------------+------+ - * - * sf: 0 -> 32 bit, 1 -> 64 bit - * opc: 00 -> N, 10 -> Z, 11 -> K - * hw: shift/16 (0,16, and sf only 32, 48) */ -static void disas_movw_imm(DisasContext *s, uint32_t insn) + +static bool trans_MOVZ(DisasContext *s, arg_movw *a) { - int rd =3D extract32(insn, 0, 5); - uint64_t imm =3D extract32(insn, 5, 16); - int sf =3D extract32(insn, 31, 1); - int opc =3D extract32(insn, 29, 2); - int pos =3D extract32(insn, 21, 2) << 4; - TCGv_i64 tcg_rd =3D cpu_reg(s, rd); + int pos =3D a->hw << 4; + tcg_gen_movi_i64(cpu_reg(s, a->rd), (uint64_t)a->imm << pos); + return true; +} =20 - if (!sf && (pos >=3D 32)) { - unallocated_encoding(s); - return; - } +static bool trans_MOVN(DisasContext *s, arg_movw *a) +{ + int pos =3D a->hw << 4; + uint64_t imm =3D a->imm; =20 - switch (opc) { - case 0: /* MOVN */ - case 2: /* MOVZ */ - imm <<=3D pos; - if (opc =3D=3D 0) { - imm =3D ~imm; - } - if (!sf) { - imm &=3D 0xffffffffu; - } - tcg_gen_movi_i64(tcg_rd, imm); - break; - case 3: /* MOVK */ - tcg_gen_deposit_i64(tcg_rd, tcg_rd, tcg_constant_i64(imm), pos, 16= ); - if (!sf) { - tcg_gen_ext32u_i64(tcg_rd, tcg_rd); - } - break; - default: - unallocated_encoding(s); - break; + imm =3D ~(imm << pos); + if (!a->sf) { + imm =3D (uint32_t)imm; } + tcg_gen_movi_i64(cpu_reg(s, a->rd), imm); + return true; +} + +static bool trans_MOVK(DisasContext *s, arg_movw *a) +{ + int pos =3D a->hw << 4; + TCGv_i64 tcg_rd, tcg_im; + + tcg_rd =3D cpu_reg(s, a->rd); + tcg_im =3D tcg_constant_i64(a->imm); + tcg_gen_deposit_i64(tcg_rd, tcg_rd, tcg_im, pos, 16); + if (!a->sf) { + tcg_gen_ext32u_i64(tcg_rd, tcg_rd); + } + return true; } =20 /* Bitfield @@ -4585,9 +4573,6 @@ static void disas_extract(DisasContext *s, uint32_t i= nsn) static void disas_data_proc_imm(DisasContext *s, uint32_t insn) { switch (extract32(insn, 23, 6)) { - case 0x25: /* Move wide (immediate) */ - disas_movw_imm(s, insn); - break; case 0x26: /* Bitfield */ disas_bitfield(s, insn); break; --=20 2.34.1 From nobody Mon Feb 9 11:57:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1683902737; cv=none; d=zohomail.com; s=zohoarc; b=LoMLVAODItP2IfxvxaYHRnoLkJsi6S4dOPnIsRknEJOcNVKsIVEAeHuzWjV5U7Wbm5gVDUDnSUJxoo5YAu7OisV1cHiufqOh7INxFo440TyYfp6LdjhGPkgBKLOQFGsXiyHMG2K5GoyhtdGEmcsvZX0YzRY52hcTahc9c3mN4RA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683902737; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=B7nyR7O1R/Xj3JLca+ITi9DYuDIC2bfZZm42nTKWjuM=; b=N9K2WfMTUb4gru9L0FN3q3Pg/3CKr9vNQInWm0fDYrdqxGx8WRGOj97+WVNlnXKq+O49wU+A5d4l3JAhrFG2T7PnOxzGUWbdii3ol8O1mb364AbaVutaaCgi9pzn2dy9YwmqbgEytyFpd5Wab4DN88rFKhD4L0RWMPztYVlBQqE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1683902737114495.7796386365625; Fri, 12 May 2023 07:45:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pxTxf-0007AU-2D; Fri, 12 May 2023 10:41:35 -0400 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 1pxTxa-00074g-BH for qemu-devel@nongnu.org; Fri, 12 May 2023 10:41:30 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pxTxL-0004jN-7n for qemu-devel@nongnu.org; Fri, 12 May 2023 10:41:30 -0400 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-306f2b42a86so6675666f8f.3 for ; Fri, 12 May 2023 07:41:14 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id f12-20020a7bcc0c000000b003f17848673fsm28916167wmh.27.2023.05.12.07.41.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 May 2023 07:41:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683902473; x=1686494473; 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=B7nyR7O1R/Xj3JLca+ITi9DYuDIC2bfZZm42nTKWjuM=; b=CXfpV45F7L784+TxMCo4L8LJOinY7JibefPKU3zr+KdYvDfafa0UpeABMqBCmjTXCf jFqmx7oqqe7yKDfVAaLgS64UquFmW/kjab5vrTe6m2LdADTQRJIr5gKCNmRSSm+Xw2r0 UhNyyDV3qhS4CEpxdEANvySr905mzLn7NZYuJIhaRs/YusscjeTgTdPQqofDm4buNdky WMT8jCQaSGk7E+FAznGqPM29BDcZs5jXMnQevbwTG7zngEJT+na58w+NtG5SLU44sXsK C7rrIYJVlBq1q+ufMhtgvfgCihLObey/dLTbEQsquoqZRtecQszBUmp+mBd6O1buk2cF LIIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683902473; x=1686494473; 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=B7nyR7O1R/Xj3JLca+ITi9DYuDIC2bfZZm42nTKWjuM=; b=H4N5P06+s/1RfrsdaYVHn/dJ5wQrx4pP53ua0+ynVPVdIwS0YRUmGQWBhBW0NsUDh6 b1ZVPo8Ugwagw/UVLOzqrgM/lejwKRKwBwkEwD6ZHwe5ONlHmBtCWn9bN4CmnR+MPhhK M3nE9Iq4QVRB8EI4IovQss+1Z33Qyi18s11LRu+rtqeZcV3HTEimx3GRcCrncRnoDZov BEewkLBKeOzYhDaTKo5bqaasDYwbtgs4k3A2pCIm09yWscpbIUP1aOrNqJ6HT14TMo0D rnpgbC0XCtX/LuesMhoABc6l7NK98OawSpr8yp6hin6gs8ujBlt5w3E735Q5HMdVdWzw /fyQ== X-Gm-Message-State: AC+VfDw03iQFM+pWAyUDGqAgQgvEXFS3b29+mKUUH0TLwNJbk5bdX6wR 08l0ia73C9hx+3sZVl/J4PKEma+nlJuhKxt7TdU= X-Google-Smtp-Source: ACHHUZ6B4RxV5qU9hopxqcIj/nLjK18h9TFdcUaQxtu0YseZB2ibtQYqZl+lRqtNBkBANXkg/RHhrg== X-Received: by 2002:adf:d092:0:b0:306:31fb:1c3d with SMTP id y18-20020adfd092000000b0030631fb1c3dmr16725735wrh.32.1683902473599; Fri, 12 May 2023 07:41:13 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PATCH 11/20] target/arm: Convert Bitfield to decodetree Date: Fri, 12 May 2023 15:40:57 +0100 Message-Id: <20230512144106.3608981-12-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230512144106.3608981-1-peter.maydell@linaro.org> References: <20230512144106.3608981-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42c.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=unavailable 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1683902738325100013 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Convert the BFM, SBFM, UBFM instructions. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell [PMM: Rebased] Signed-off-by: Peter Maydell --- target/arm/tcg/a64.decode | 13 +++ target/arm/tcg/translate-a64.c | 144 ++++++++++++++++++--------------- 2 files changed, 94 insertions(+), 63 deletions(-) diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode index 350b37c8f37..4d5709f9857 100644 --- a/target/arm/tcg/a64.decode +++ b/target/arm/tcg/a64.decode @@ -84,3 +84,16 @@ MOVZ . 10 100101 .. ................ ..... = @movw_64 MOVZ . 10 100101 .. ................ ..... @movw_32 MOVK . 11 100101 .. ................ ..... @movw_64 MOVK . 11 100101 .. ................ ..... @movw_32 + +# Bitfield + +&bitfield rd rn sf immr imms +@bitfield_64 1 .. ...... 1 immr:6 imms:6 rn:5 rd:5 &bitfield sf=3D1 +@bitfield_32 0 .. ...... 0 0 immr:5 0 imms:5 rn:5 rd:5 &bitfield sf=3D0 + +SBFM . 00 100110 . ...... ...... ..... ..... @bitfield_64 +SBFM . 00 100110 . ...... ...... ..... ..... @bitfield_32 +BFM . 01 100110 . ...... ...... ..... ..... @bitfield_64 +BFM . 01 100110 . ...... ...... ..... ..... @bitfield_32 +UBFM . 10 100110 . ...... ...... ..... ..... @bitfield_64 +UBFM . 10 100110 . ...... ...... ..... ..... @bitfield_32 diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index a36b98925fb..f5649de60a8 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -4431,82 +4431,103 @@ static bool trans_MOVK(DisasContext *s, arg_movw *= a) return true; } =20 -/* Bitfield - * 31 30 29 28 23 22 21 16 15 10 9 5 4 0 - * +----+-----+-------------+---+------+------+------+------+ - * | sf | opc | 1 0 0 1 1 0 | N | immr | imms | Rn | Rd | - * +----+-----+-------------+---+------+------+------+------+ +/* + * Bitfield */ -static void disas_bitfield(DisasContext *s, uint32_t insn) + +static bool trans_SBFM(DisasContext *s, arg_SBFM *a) { - unsigned int sf, n, opc, ri, si, rn, rd, bitsize, pos, len; - TCGv_i64 tcg_rd, tcg_tmp; + TCGv_i64 tcg_rd =3D cpu_reg(s, a->rd); + TCGv_i64 tcg_tmp =3D read_cpu_reg(s, a->rn, 1); + unsigned int bitsize =3D a->sf ? 64 : 32; + unsigned int ri =3D a->immr; + unsigned int si =3D a->imms; + unsigned int pos, len; =20 - sf =3D extract32(insn, 31, 1); - opc =3D extract32(insn, 29, 2); - n =3D extract32(insn, 22, 1); - ri =3D extract32(insn, 16, 6); - si =3D extract32(insn, 10, 6); - rn =3D extract32(insn, 5, 5); - rd =3D extract32(insn, 0, 5); - bitsize =3D sf ? 64 : 32; - - if (sf !=3D n || ri >=3D bitsize || si >=3D bitsize || opc > 2) { - unallocated_encoding(s); - return; - } - - tcg_rd =3D cpu_reg(s, rd); - - /* Suppress the zero-extend for !sf. Since RI and SI are constrained - to be smaller than bitsize, we'll never reference data outside the - low 32-bits anyway. */ - tcg_tmp =3D read_cpu_reg(s, rn, 1); - - /* Recognize simple(r) extractions. */ if (si >=3D ri) { /* Wd =3D Wn */ len =3D (si - ri) + 1; - if (opc =3D=3D 0) { /* SBFM: ASR, SBFX, SXTB, SXTH, SXTW */ - tcg_gen_sextract_i64(tcg_rd, tcg_tmp, ri, len); - goto done; - } else if (opc =3D=3D 2) { /* UBFM: UBFX, LSR, UXTB, UXTH */ - tcg_gen_extract_i64(tcg_rd, tcg_tmp, ri, len); - return; + tcg_gen_sextract_i64(tcg_rd, tcg_tmp, ri, len); + if (!a->sf) { + tcg_gen_ext32u_i64(tcg_rd, tcg_rd); } - /* opc =3D=3D 1, BFXIL fall through to deposit */ + } else { + /* Wd<32+s-r,32-r> =3D Wn */ + len =3D si + 1; + pos =3D (bitsize - ri) & (bitsize - 1); + + if (len < ri) { + /* + * Sign extend the destination field from len to fill the + * balance of the word. Let the deposit below insert all + * of those sign bits. + */ + tcg_gen_sextract_i64(tcg_tmp, tcg_tmp, 0, len); + len =3D ri; + } + + /* + * We start with zero, and we haven't modified any bits outside + * bitsize, therefore no final zero-extension is unneeded for !sf. + */ + tcg_gen_deposit_z_i64(tcg_rd, tcg_tmp, pos, len); + } + return true; +} + +static bool trans_UBFM(DisasContext *s, arg_UBFM *a) +{ + TCGv_i64 tcg_rd =3D cpu_reg(s, a->rd); + TCGv_i64 tcg_tmp =3D read_cpu_reg(s, a->rn, 1); + unsigned int bitsize =3D a->sf ? 64 : 32; + unsigned int ri =3D a->immr; + unsigned int si =3D a->imms; + unsigned int pos, len; + + tcg_rd =3D cpu_reg(s, a->rd); + tcg_tmp =3D read_cpu_reg(s, a->rn, 1); + + if (si >=3D ri) { + /* Wd =3D Wn */ + len =3D (si - ri) + 1; + tcg_gen_extract_i64(tcg_rd, tcg_tmp, ri, len); + } else { + /* Wd<32+s-r,32-r> =3D Wn */ + len =3D si + 1; + pos =3D (bitsize - ri) & (bitsize - 1); + tcg_gen_deposit_z_i64(tcg_rd, tcg_tmp, pos, len); + } + return true; +} + +static bool trans_BFM(DisasContext *s, arg_BFM *a) +{ + TCGv_i64 tcg_rd =3D cpu_reg(s, a->rd); + TCGv_i64 tcg_tmp =3D read_cpu_reg(s, a->rn, 1); + unsigned int bitsize =3D a->sf ? 64 : 32; + unsigned int ri =3D a->immr; + unsigned int si =3D a->imms; + unsigned int pos, len; + + tcg_rd =3D cpu_reg(s, a->rd); + tcg_tmp =3D read_cpu_reg(s, a->rn, 1); + + if (si >=3D ri) { + /* Wd =3D Wn */ tcg_gen_shri_i64(tcg_tmp, tcg_tmp, ri); + len =3D (si - ri) + 1; pos =3D 0; } else { - /* Handle the ri > si case with a deposit - * Wd<32+s-r,32-r> =3D Wn - */ + /* Wd<32+s-r,32-r> =3D Wn */ len =3D si + 1; pos =3D (bitsize - ri) & (bitsize - 1); } =20 - if (opc =3D=3D 0 && len < ri) { - /* SBFM: sign extend the destination field from len to fill - the balance of the word. Let the deposit below insert all - of those sign bits. */ - tcg_gen_sextract_i64(tcg_tmp, tcg_tmp, 0, len); - len =3D ri; - } - - if (opc =3D=3D 1) { /* BFM, BFXIL */ - tcg_gen_deposit_i64(tcg_rd, tcg_rd, tcg_tmp, pos, len); - } else { - /* SBFM or UBFM: We start with zero, and we haven't modified - any bits outside bitsize, therefore the zero-extension - below is unneeded. */ - tcg_gen_deposit_z_i64(tcg_rd, tcg_tmp, pos, len); - return; - } - - done: - if (!sf) { /* zero extend final result */ + tcg_gen_deposit_i64(tcg_rd, tcg_rd, tcg_tmp, pos, len); + if (!a->sf) { tcg_gen_ext32u_i64(tcg_rd, tcg_rd); } + return true; } =20 /* Extract @@ -4573,9 +4594,6 @@ static void disas_extract(DisasContext *s, uint32_t i= nsn) static void disas_data_proc_imm(DisasContext *s, uint32_t insn) { switch (extract32(insn, 23, 6)) { - case 0x26: /* Bitfield */ - disas_bitfield(s, insn); - break; case 0x27: /* Extract */ disas_extract(s, insn); break; --=20 2.34.1 From nobody Mon Feb 9 11:57:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1683902736; cv=none; d=zohomail.com; s=zohoarc; b=CdHujcxTjLqtQUNgG1tkcm1p+rAlw8X5hFRkKkUaJMZNFWC0BememPfih5C0wukZAvwwfUOYhlo5dXVH0asth14nJEvvWpU2naxp8zxOtjrhMeXQmkGgaqZq+u+FiBC3Ff830KWdJEq3g0Q0e55SrB7Eym7JTZl2THiIx0Nna+Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683902736; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=WFWx3ixalVla371utWzQEGMgJNlwfauaj/lO3THOe6A=; b=fmii4rNbfQCWRhFBxkPUxsS1iky7ulTP2/oWoQkInEtUUU5pZ9u9d4WbEqfltRYupbL5JJCKpvP3lkzoSLZEkhbktjmvyPkGBRK43JF4tp3xz57tuIY3/9QP0xF3gsl82GSptmtrBmIFXNrAL0WOoc4COeAYZXGOO2x0UA8Rw30= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1683902736166509.21008077853355; Fri, 12 May 2023 07:45:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pxTxe-00078d-3t; Fri, 12 May 2023 10:41:34 -0400 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 1pxTxb-000771-G2 for qemu-devel@nongnu.org; Fri, 12 May 2023 10:41:31 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pxTxL-0004jX-Ex for qemu-devel@nongnu.org; Fri, 12 May 2023 10:41:31 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-3f4249b7badso62551975e9.3 for ; Fri, 12 May 2023 07:41:15 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id f12-20020a7bcc0c000000b003f17848673fsm28916167wmh.27.2023.05.12.07.41.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 May 2023 07:41:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683902474; x=1686494474; 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=WFWx3ixalVla371utWzQEGMgJNlwfauaj/lO3THOe6A=; b=ku+z6cFiemc4DZHymCGKwkJxpqK3J+aKORnaxL/NjGGpyj9J5vaY8bmzXWI4zTLs2f 1zCjg3GKSgPGy2Bfu3HugZybZZyfAPBLM5LsHJha9GS4s/Zq/OrNRF1YWNcfqZcURvsS F3ZRfahKlt0mKkyCSwfSpIraMWNtz+ah+y+MLbDD9gDYXxvywP2c6eiVfu+hO10CI4Yh muzWJQxqOW17LmZ9VHD295O5QRiDJK8iKUiSaMYGLCIKtKfjBxgfZl/ohiHfLYM9md5r y/nq3PdNhjOum2jKpfRd+O0AEUGEvj9ItPBHgB2mVWtrYwUK3UnVeybIksoA9iKO0/gS 3+qA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683902474; x=1686494474; 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=WFWx3ixalVla371utWzQEGMgJNlwfauaj/lO3THOe6A=; b=IpslGZ4BgTL+XJkriieiQSQb3zyEsPeqCHIQ3XgrReONByW7Yf641EBvMeoC9URjBU 7/AnLVMVALngb5YDMfIiE23wZClxFFRVKdfmUkKU8GJo5KuPDniaKscFE4O+5PMwUaj8 wP0kQn0lIGXa1OSEuYX1mBmNAmITKW/48eAjQAY6eJhMTvGAj+0GYLwKRU9RQ2BqOxyg Cy1SVS7rhFXNccv4C4ttoaNFS3iM7JB0yG4OV1vJscbeYl2U/DYfMdVOnmQnMtGxTsYY aKRpJKshsLOk3WKseTiwDFHZCWo2B6KuHXKHrwr3F5Hvxme0DTO1tdvWtn+PwOcQrE33 n0aA== X-Gm-Message-State: AC+VfDwg325N0CiOnYD1kpK3n/bOdusK0uq1ALrbhvqy6F1GhJNPK5DB AcVhrd78PSEtTK+j1nuPRlngTg== X-Google-Smtp-Source: ACHHUZ5765byb+20W7XU4Sl+mVNC5/FG8yDVcCNsFt2jE9YyoJDOfGhxr8jpM0JK9L3/g75mhxBR7g== X-Received: by 2002:a05:600c:cf:b0:3f4:29c2:61e6 with SMTP id u15-20020a05600c00cf00b003f429c261e6mr10509339wmm.34.1683902474026; Fri, 12 May 2023 07:41:14 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PATCH 12/20] target/arm: Convert Extract instructions to decodetree Date: Fri, 12 May 2023 15:40:58 +0100 Message-Id: <20230512144106.3608981-13-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230512144106.3608981-1-peter.maydell@linaro.org> References: <20230512144106.3608981-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32d.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=unavailable 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1683902738328100014 Content-Type: text/plain; charset="utf-8" Convert the EXTR instruction to decodetree (this is the only one in the 'Extract" class). This is the last of the dp-immediate insns in the legacy decoder, so we can now remove disas_data_proc_imm(). Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/tcg/a64.decode | 9 ++++ target/arm/tcg/translate-a64.c | 94 +++++++++++----------------------- 2 files changed, 38 insertions(+), 65 deletions(-) diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode index 4d5709f9857..eb5d4cb0d57 100644 --- a/target/arm/tcg/a64.decode +++ b/target/arm/tcg/a64.decode @@ -97,3 +97,12 @@ BFM . 01 100110 . ...... ...... ..... ..... = @bitfield_64 BFM . 01 100110 . ...... ...... ..... ..... @bitfield_32 UBFM . 10 100110 . ...... ...... ..... ..... @bitfield_64 UBFM . 10 100110 . ...... ...... ..... ..... @bitfield_32 + +# Extract + +&extract rd rn rm imm sf +@extract_64 1 .. ...... 1 . rm:5 imm:6 rn:5 rd:5 &extract sf=3D1 +@extract_32 0 .. ...... 0 . rm:5 0 imm:5 rn:5 rd:5 &extract sf=3D0 + +EXTR . 00 100111 . 0 ..... ...... ..... ..... @extract_64 +EXTR . 00 100111 . 0 ..... ...... ..... ..... @extract_32 diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index f5649de60a8..4319559057f 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -4530,77 +4530,44 @@ static bool trans_BFM(DisasContext *s, arg_BFM *a) return true; } =20 -/* Extract - * 31 30 29 28 23 22 21 20 16 15 10 9 5 4 0 - * +----+------+-------------+---+----+------+--------+------+------+ - * | sf | op21 | 1 0 0 1 1 1 | N | o0 | Rm | imms | Rn | Rd | - * +----+------+-------------+---+----+------+--------+------+------+ - */ -static void disas_extract(DisasContext *s, uint32_t insn) +static bool trans_EXTR(DisasContext *s, arg_extract *a) { - unsigned int sf, n, rm, imm, rn, rd, bitsize, op21, op0; + TCGv_i64 tcg_rd, tcg_rm, tcg_rn; =20 - sf =3D extract32(insn, 31, 1); - n =3D extract32(insn, 22, 1); - rm =3D extract32(insn, 16, 5); - imm =3D extract32(insn, 10, 6); - rn =3D extract32(insn, 5, 5); - rd =3D extract32(insn, 0, 5); - op21 =3D extract32(insn, 29, 2); - op0 =3D extract32(insn, 21, 1); - bitsize =3D sf ? 64 : 32; + tcg_rd =3D cpu_reg(s, a->rd); =20 - if (sf !=3D n || op21 || op0 || imm >=3D bitsize) { - unallocated_encoding(s); - } else { - TCGv_i64 tcg_rd, tcg_rm, tcg_rn; - - tcg_rd =3D cpu_reg(s, rd); - - if (unlikely(imm =3D=3D 0)) { - /* tcg shl_i32/shl_i64 is undefined for 32/64 bit shifts, - * so an extract from bit 0 is a special case. - */ - if (sf) { - tcg_gen_mov_i64(tcg_rd, cpu_reg(s, rm)); - } else { - tcg_gen_ext32u_i64(tcg_rd, cpu_reg(s, rm)); - } + if (unlikely(a->imm =3D=3D 0)) { + /* + * tcg shl_i32/shl_i64 is undefined for 32/64 bit shifts, + * so an extract from bit 0 is a special case. + */ + if (a->sf) { + tcg_gen_mov_i64(tcg_rd, cpu_reg(s, a->rm)); } else { - tcg_rm =3D cpu_reg(s, rm); - tcg_rn =3D cpu_reg(s, rn); + tcg_gen_ext32u_i64(tcg_rd, cpu_reg(s, a->rm)); + } + } else { + tcg_rm =3D cpu_reg(s, a->rm); + tcg_rn =3D cpu_reg(s, a->rn); =20 - if (sf) { - /* Specialization to ROR happens in EXTRACT2. */ - tcg_gen_extract2_i64(tcg_rd, tcg_rm, tcg_rn, imm); + if (a->sf) { + /* Specialization to ROR happens in EXTRACT2. */ + tcg_gen_extract2_i64(tcg_rd, tcg_rm, tcg_rn, a->imm); + } else { + TCGv_i32 t0 =3D tcg_temp_new_i32(); + + tcg_gen_extrl_i64_i32(t0, tcg_rm); + if (a->rm =3D=3D a->rn) { + tcg_gen_rotri_i32(t0, t0, a->imm); } else { - TCGv_i32 t0 =3D tcg_temp_new_i32(); - - tcg_gen_extrl_i64_i32(t0, tcg_rm); - if (rm =3D=3D rn) { - tcg_gen_rotri_i32(t0, t0, imm); - } else { - TCGv_i32 t1 =3D tcg_temp_new_i32(); - tcg_gen_extrl_i64_i32(t1, tcg_rn); - tcg_gen_extract2_i32(t0, t0, t1, imm); - } - tcg_gen_extu_i32_i64(tcg_rd, t0); + TCGv_i32 t1 =3D tcg_temp_new_i32(); + tcg_gen_extrl_i64_i32(t1, tcg_rn); + tcg_gen_extract2_i32(t0, t0, t1, a->imm); } + tcg_gen_extu_i32_i64(tcg_rd, t0); } } -} - -/* Data processing - immediate */ -static void disas_data_proc_imm(DisasContext *s, uint32_t insn) -{ - switch (extract32(insn, 23, 6)) { - case 0x27: /* Extract */ - disas_extract(s, insn); - break; - default: - unallocated_encoding(s); - break; - } + return true; } =20 /* Shift a TCGv src by TCGv shift_amount, put result in dst. @@ -14125,9 +14092,6 @@ static bool btype_destination_ok(uint32_t insn, boo= l bt, int btype) static void disas_a64_legacy(DisasContext *s, uint32_t insn) { switch (extract32(insn, 25, 4)) { - case 0x8: case 0x9: /* Data processing - immediate */ - disas_data_proc_imm(s, insn); - break; case 0xa: case 0xb: /* Branch, exception generation and system insns */ disas_b_exc_sys(s, insn); break; --=20 2.34.1 From nobody Mon Feb 9 11:57:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1683902593; cv=none; d=zohomail.com; s=zohoarc; b=krgTCpSA0oXe5QEOmu2CHiP/qXfb78UxR8ZOcBoS0Mj2tqSSkcAkKvh5ILlYqKiCETl8l1PysZkcn4NarB268bJR1H1CHhFt7kNH62AQeYoIu1Jt6zEMBeAGzuE2ujM9qXA4FQbLko49xvkUHE5zHZRd1+Jv4UYoc3ytXjnfXD4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683902593; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=yE0yzHpn5HGcapGUBNgyOVRbnrVrPALQXSeI3NGRfYY=; b=YF0nqElEXh8rM6IjmjVdCkvnHxweCYn7Oixs/YJIYuwqrjwH/XB/LuZYolyy9sKIj1AMmf/ZeofbQOqi5IM4lgcYkFkx0UgKcMgC2GHQxc3vwqJA+3cL4jaR4xki+OnO0ovOGkD2rU6Bzv4VpMYnRHkycSlXZ7ZWjtVLQNEiYak= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1683902593624763.2178468520102; Fri, 12 May 2023 07:43:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pxTxd-000786-Vz; Fri, 12 May 2023 10:41:34 -0400 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 1pxTxa-00074H-44 for qemu-devel@nongnu.org; Fri, 12 May 2023 10:41:30 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pxTxL-0004ha-7n for qemu-devel@nongnu.org; Fri, 12 May 2023 10:41:29 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-3f450815d0bso37254905e9.0 for ; Fri, 12 May 2023 07:41:14 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id f12-20020a7bcc0c000000b003f17848673fsm28916167wmh.27.2023.05.12.07.41.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 May 2023 07:41:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683902474; x=1686494474; 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=yE0yzHpn5HGcapGUBNgyOVRbnrVrPALQXSeI3NGRfYY=; b=oQjj7qB42CPYtTl76vhjZFi/EX9EAeVNb6zOSysosMns+hVeTIFqt9FICZsed15em4 VfLsML4g0iWJQj+CbfrK6lzg5tWus1lW95e1fAEbKhq0TxoXozPPfqC19i6UM0ie4GFB U82tZnRsbNqd5SOMTN2Kf0Uzk9c6AiTVyg2f0yBJEx+aGEqwvqCQp1PRR0YJYkMO2Ouo YsIgsPbqnZ9/6y/YGOoglfzqgz/EXo5/lbVGOElGdRC42Oo6SkYiqK+GzRz6o0aFt/Cm zWOnwdEOhV40qWfQ771xUhTmx/EYJAJKLll4z9JFcOsV6jD4NtRB6IxeCaobfWkkUuUx vksA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683902474; x=1686494474; 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=yE0yzHpn5HGcapGUBNgyOVRbnrVrPALQXSeI3NGRfYY=; b=LK6WXYARftG5SIGVKHqEkvyfX9xyANyLXzb0Rr6yBCrdutRWDXPaBDqe/pweI1Xfze SX4ba7LPv4aWZvlOOXHfi113PXEi54DpFDlt+Mt7dV0vPrY2l8HFYMt5Abv1PRnexAzV JKl27UjaUUhFXA+jZGLUbm69ANxZxzI03s1dEvVrjkmO8NpObS+wP5PCGj8rWSQgKOvi nJ69ppaYA2Caw4NrmwIsdmxeLLVwGL62vZrDvdTm+neHK6aGkeBk9fDiSx9be65T/bUj ceqn7EiqvmFKLNojaU8Y2XOdQ/gSPAJs+kc8oqZaPMdXFU/ZJZoOKICqLI7qRXNlohOW 1qxA== X-Gm-Message-State: AC+VfDw3lVOy7OFF52egGDIbtmWRlP7xXv+Q/g2N9U7VVQ79XsIeaiOS g5d9wFty4ed1G9UfqRH8/UNkQw== X-Google-Smtp-Source: ACHHUZ6Li1oT92ebrBx8hrYQsM3oq71ovycR3Fye/wcZcrKlf8b44Aay7lcnGFe7VhIHtMnoVRenuQ== X-Received: by 2002:a7b:cd09:0:b0:3f1:80a7:bfb2 with SMTP id f9-20020a7bcd09000000b003f180a7bfb2mr17292469wmj.32.1683902474500; Fri, 12 May 2023 07:41:14 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PATCH 13/20] target/arm: Convert unconditional branch immediate to decodetree Date: Fri, 12 May 2023 15:40:59 +0100 Message-Id: <20230512144106.3608981-14-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230512144106.3608981-1-peter.maydell@linaro.org> References: <20230512144106.3608981-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x333.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1683902595662100003 Content-Type: text/plain; charset="utf-8" Convert the unconditional branch immediate insns B and BL to decodetree. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/tcg/a64.decode | 9 +++++++++ target/arm/tcg/translate-a64.c | 31 +++++++++++-------------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode index eb5d4cb0d57..d54c6522028 100644 --- a/target/arm/tcg/a64.decode +++ b/target/arm/tcg/a64.decode @@ -21,6 +21,7 @@ =20 &ri rd imm &rri_sf rd rn imm sf +&i imm =20 =20 ### Data Processing - Immediate @@ -106,3 +107,11 @@ UBFM . 10 100110 . ...... ...... ..... ....= . @bitfield_32 =20 EXTR . 00 100111 . 0 ..... ...... ..... ..... @extract_64 EXTR . 00 100111 . 0 ..... ...... ..... ..... @extract_32 + +# Branches + +%imm26 0:s26 !function=3Dtimes_4 +@branch . ..... .......................... &i imm=3D%imm26 + +B 0 00101 .......................... @branch +BL 1 00101 .......................... @branch diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 4319559057f..fe6b4a68288 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -1319,24 +1319,19 @@ static inline AArch64DecodeFn *lookup_disas_fn(cons= t AArch64DecodeTable *table, * match up with those in the manual. */ =20 -/* Unconditional branch (immediate) - * 31 30 26 25 0 - * +----+-----------+-------------------------------------+ - * | op | 0 0 1 0 1 | imm26 | - * +----+-----------+-------------------------------------+ - */ -static void disas_uncond_b_imm(DisasContext *s, uint32_t insn) +static bool trans_B(DisasContext *s, arg_i *a) { - int64_t diff =3D sextract32(insn, 0, 26) * 4; - - if (insn & (1U << 31)) { - /* BL Branch with link */ - gen_pc_plus_diff(s, cpu_reg(s, 30), curr_insn_len(s)); - } - - /* B Branch / BL Branch with link */ reset_btype(s); - gen_goto_tb(s, 0, diff); + gen_goto_tb(s, 0, a->imm); + return true; +} + +static bool trans_BL(DisasContext *s, arg_i *a) +{ + gen_pc_plus_diff(s, cpu_reg(s, 30), curr_insn_len(s)); + reset_btype(s); + gen_goto_tb(s, 0, a->imm); + return true; } =20 /* Compare and branch (immediate) @@ -2413,10 +2408,6 @@ static void disas_uncond_b_reg(DisasContext *s, uint= 32_t insn) static void disas_b_exc_sys(DisasContext *s, uint32_t insn) { switch (extract32(insn, 25, 7)) { - case 0x0a: case 0x0b: - case 0x4a: case 0x4b: /* Unconditional branch (immediate) */ - disas_uncond_b_imm(s, insn); - break; case 0x1a: case 0x5a: /* Compare & branch (immediate) */ disas_comp_b_imm(s, insn); break; --=20 2.34.1 From nobody Mon Feb 9 11:57:05 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1683902608; cv=none; d=zohomail.com; s=zohoarc; b=mBw1hPo5oSVNEB/vCg4JXenlGxQOus6Eom0SozSdHE4Jz217TXw/mWbDJUmxCFIo1EU654P1o4YqX4judIow+Aj8+ZfGtEQjWa+CrnXAf0OhFv/clLQGbW4Wk3tVn0ePZK0kEKytc5uHO6Q11f4Jw92VnWuoC9lbFMIaGvXbjBg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683902608; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=b35BwkiFX8fqUrD1Px2IqZe/3AgM9JZzroufYhPa+ao=; b=AGlQh59DSkHHz659Smx74msiXkfdAXtM8OOXHKuhHa0Y4MswzLgisKEgVGKbxhPnIKz7WUsvOxh82nDn4O+cSUtCNojFJUWDZIFEwEOMCSZ027mmUn/2UfSaLmOSUMru3macc3B9Nwnyuod4EtzkagiidR5oMWR9iIbdkM7W9wk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1683902608437300.52900273319074; Fri, 12 May 2023 07:43:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pxTxg-0007Dt-LQ; Fri, 12 May 2023 10:41:36 -0400 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 1pxTxc-00077P-1t for qemu-devel@nongnu.org; Fri, 12 May 2023 10:41:32 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pxTxM-0004jx-BH for qemu-devel@nongnu.org; Fri, 12 May 2023 10:41:31 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-3f41d087b3bso71927505e9.0 for ; Fri, 12 May 2023 07:41:15 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id f12-20020a7bcc0c000000b003f17848673fsm28916167wmh.27.2023.05.12.07.41.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 May 2023 07:41:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683902475; x=1686494475; 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=b35BwkiFX8fqUrD1Px2IqZe/3AgM9JZzroufYhPa+ao=; b=T+6MivRRfHt3BSCGB3BusxGwRHqVnDHhfj9xEfoH3GHrSzmrOmRUDMgHQ4Ycmrryjo IrYa9RPZq9Tc+rvZYUn1fZwlzXotwO6j6ZbvDWO3STd3QCeDU/eubyxbmhOzhwDyRxVz Gm1sWD1azfTbu5dF1hKxdM2lV4jT9Ts84bQ20NKJN/pC1iv+r1vW8uxppLYuFS6+tHbU bU4P8TU8lhb2KOPSoax5pjsKn0p2c2KdBR/C9RPtR4BgD3jC1KxHNP5/B37z63JUVE4T rutEdjja6pd5i+9m/aRncZwFxFpO+6GIxhGawHWl8+NwVia9cM6Qx+uTJBEblcaTY61n CjeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683902475; x=1686494475; 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=b35BwkiFX8fqUrD1Px2IqZe/3AgM9JZzroufYhPa+ao=; b=WQfOndPaU+cADiwkWzy47ciecVYzC870rKhhHniikuYJV9CTytQpJ8Fc51r54vbN2z TZUcItw+/D5/9JelWSrdknDK+5vpI2lRk+idE7RjVjjF4Ho0n98lf8L7QZOgcSai2Xh1 gnlfEOXLIOAK907/5IAgbPIfKP65lsy7lk/4itUc2y/GIZxCFTdAwmuFNiBd48uPoUJX M2CgMBCsA8HtiQfNggH1ND+wf0sEt/YQEJA21lGfyGoEop8aUmuw1Hds7lmZu7n0fETj n+3L2bQhnhs9Ikrf09aEqr65P8MI7/3shdXx4XVI5VycXwiW9Td3DevdVgoCHN2PUPq7 L5fQ== X-Gm-Message-State: AC+VfDxS4t+cbCOLrT2/xvndu94wzgb5eo8NF55DhI7giZD0sSk9hunE qgHtz6BA8Ev99dRpEquIJ2Cnnh8hx5oOQPAcXDk= X-Google-Smtp-Source: ACHHUZ6awIx5vllupVVf46rtl53UmNd2sfI1LhwoWPGpPs4V76YHRjl+P27m1sYY7v1vxIKyfzL33g== X-Received: by 2002:a1c:e90c:0:b0:3f1:952a:4bf0 with SMTP id q12-20020a1ce90c000000b003f1952a4bf0mr17441034wmc.33.1683902474982; Fri, 12 May 2023 07:41:14 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PATCH 14/20] target/arm: Convert CBZ, CBNZ to decodetree Date: Fri, 12 May 2023 15:41:00 +0100 Message-Id: <20230512144106.3608981-15-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230512144106.3608981-1-peter.maydell@linaro.org> References: <20230512144106.3608981-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32d.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1683902610201100003 Content-Type: text/plain; charset="utf-8" Convert the compare-and-branch-immediate insns CBZ and CBNZ to decodetree. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/tcg/a64.decode | 6 ++++++ target/arm/tcg/translate-a64.c | 26 ++++++-------------------- 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode index d54c6522028..86220569e13 100644 --- a/target/arm/tcg/a64.decode +++ b/target/arm/tcg/a64.decode @@ -115,3 +115,9 @@ EXTR . 00 100111 . 0 ..... ...... ..... ....= . @extract_32 =20 B 0 00101 .......................... @branch BL 1 00101 .......................... @branch + +%imm19 5:s19 !function=3Dtimes_4 +&cbz rt imm sf nz +@cbz sf:1 ...... nz:1 ................... rt:5 &cbz imm=3D%imm19 + +CBZ . 011010 . ................... ..... @cbz diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index fe6b4a68288..5da551385bd 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -1334,33 +1334,22 @@ static bool trans_BL(DisasContext *s, arg_i *a) return true; } =20 -/* Compare and branch (immediate) - * 31 30 25 24 23 5 4 0 - * +----+-------------+----+---------------------+--------+ - * | sf | 0 1 1 0 1 0 | op | imm19 | Rt | - * +----+-------------+----+---------------------+--------+ - */ -static void disas_comp_b_imm(DisasContext *s, uint32_t insn) + +static bool trans_CBZ(DisasContext *s, arg_cbz *a) { - unsigned int sf, op, rt; - int64_t diff; DisasLabel match; TCGv_i64 tcg_cmp; =20 - sf =3D extract32(insn, 31, 1); - op =3D extract32(insn, 24, 1); /* 0: CBZ; 1: CBNZ */ - rt =3D extract32(insn, 0, 5); - diff =3D sextract32(insn, 5, 19) * 4; - - tcg_cmp =3D read_cpu_reg(s, rt, sf); + tcg_cmp =3D read_cpu_reg(s, a->rt, a->sf); reset_btype(s); =20 match =3D gen_disas_label(s); - tcg_gen_brcondi_i64(op ? TCG_COND_NE : TCG_COND_EQ, + tcg_gen_brcondi_i64(a->nz ? TCG_COND_NE : TCG_COND_EQ, tcg_cmp, 0, match.label); gen_goto_tb(s, 0, 4); set_disas_label(s, match); - gen_goto_tb(s, 1, diff); + gen_goto_tb(s, 1, a->imm); + return true; } =20 /* Test and branch (immediate) @@ -2408,9 +2397,6 @@ static void disas_uncond_b_reg(DisasContext *s, uint3= 2_t insn) static void disas_b_exc_sys(DisasContext *s, uint32_t insn) { switch (extract32(insn, 25, 7)) { - case 0x1a: case 0x5a: /* Compare & branch (immediate) */ - disas_comp_b_imm(s, insn); - break; case 0x1b: case 0x5b: /* Test & branch (immediate) */ disas_test_b_imm(s, insn); break; --=20 2.34.1 From nobody Mon Feb 9 11:57:05 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1683902737; cv=none; d=zohomail.com; s=zohoarc; b=JzlJn7KYU3WuK8tUpBsuJEA5aRwtyubeqH8aPzxpyo1ThjJ/vgZR0SL+pCch9fg1Wb8a2oQTJkxo2dAKqYigti4nW+OmAOO1xH/g7F9/AUEB6a0of4HZ8ntbRNVpo1Piadvu5AE7hkMm3v82Ckj6fvXVF5WfyItV0ADGsXKyD0k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683902737; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MFhepMGaE0XG072ziJIvurTDqYdBHGuPC3+MsbwqRWw=; b=J066g4RRPzPl6QdvIPBS9+daWI6AgpmVtU8N8G8IB4eVl+aBo56Ub+lLrxik32ly5eYIl6OiSJvKQZd/j7DmsvFA+VoeRV1WedbSb7opfLanZudisvEtux/6ek58v90wyGjYm4AlTdBUVnqD0rZZmtiRSg8hxKm3/ZP2fb7lWs4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1683902737081361.8703494704912; Fri, 12 May 2023 07:45:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pxTxf-0007Bc-Bi; Fri, 12 May 2023 10:41:35 -0400 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 1pxTxd-00078O-Cf for qemu-devel@nongnu.org; Fri, 12 May 2023 10:41:33 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pxTxM-0004k3-QR for qemu-devel@nongnu.org; Fri, 12 May 2023 10:41:33 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-3f42bcf5df1so45805235e9.3 for ; Fri, 12 May 2023 07:41:16 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id f12-20020a7bcc0c000000b003f17848673fsm28916167wmh.27.2023.05.12.07.41.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 May 2023 07:41:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683902475; x=1686494475; 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=MFhepMGaE0XG072ziJIvurTDqYdBHGuPC3+MsbwqRWw=; b=L5by0c0KR0Xk86y/A7dMZxjdDPWyGzOW6xvd3kUtHH9By/zWfql0StrJp+u8E9R5FL oehq9vON9HI+KKG3TssdJKPZNO32UpBtHz2VpZw9V2hpx2fefhZClp3XD8bm0rfstEXC IEGzHOOyHiKIhSOiB/a7HB2k0Cd21gkm4RhIYV0PRKly0K4A7TLKg7oFGwERrHXmn4Sv V8HSadY6BJt82OZKiTGjGeAFnLCWwkxZWI9IaKCVMzvEqqqBbs3vKJaUe5LYYc2f0xXa 6477JE7Q9ZIBjvd7liHpa1cbsCgqn6INfge81wT6Es9IpC3KpZgF7vSsVmFsZqdKnNQM 5oJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683902475; x=1686494475; 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=MFhepMGaE0XG072ziJIvurTDqYdBHGuPC3+MsbwqRWw=; b=eD28ls2sh68+NX5pFfjCbLm/blJmnYX97uN2NRJpTvCfBT+OCqWxVQXW3GjIXKQb2O 3a2HQPl+QAz8Qxc6fxXAqg7Ciaf+zCQrCBs2LIiP53aKSh8yY2fUvuOuEZy8wsfztx5w hnqFSsMT9BqblcdAm95KfthT8a8XJ0+vdcloih7dz1X7YKA/XPK9DEU+38iT8DZmewGC iKBNJm4nZIn52+cfk6IpBMIP08hyAWuFNR+KP35B8tYtBdZxPpZVsjMGypYXUg5xgW6+ RmYj7TiUD1PbRp0Cah7j6sG9SbcYErcfKOrYyhT+YePip1MUi7TVD78NoNvtVpvxN4br J81w== X-Gm-Message-State: AC+VfDwQC/8zOcFJh//U5XraNRrCKyyfmSdOx4zhJq7qXu/0VdSHe2Un jmy3OpZSpogNrjJC5b8rXaqJfQ== X-Google-Smtp-Source: ACHHUZ5pQh3ooLXj+4CQpnnjNYRR/74V8Qkl3nGBARIzbWNPi1S3ToCt8dJvGVD7LDz43wJkV4qYKQ== X-Received: by 2002:a1c:ed04:0:b0:3f4:f03b:56d7 with SMTP id l4-20020a1ced04000000b003f4f03b56d7mr3117608wmh.16.1683902475454; Fri, 12 May 2023 07:41:15 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PATCH 15/20] target/arm: Convert TBZ, TBNZ to decodetree Date: Fri, 12 May 2023 15:41:01 +0100 Message-Id: <20230512144106.3608981-16-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230512144106.3608981-1-peter.maydell@linaro.org> References: <20230512144106.3608981-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32b.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1683902738312100012 Content-Type: text/plain; charset="utf-8" Convert the test-and-branch-immediate insns TBZ and TBNZ to decodetree. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/tcg/a64.decode | 7 +++++++ target/arm/tcg/translate-a64.c | 25 +++++-------------------- 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode index 86220569e13..68dc820ece0 100644 --- a/target/arm/tcg/a64.decode +++ b/target/arm/tcg/a64.decode @@ -121,3 +121,10 @@ BL 1 00101 .......................... @br= anch @cbz sf:1 ...... nz:1 ................... rt:5 &cbz imm=3D%imm19 =20 CBZ . 011010 . ................... ..... @cbz + +%imm14 5:s14 !function=3Dtimes_4 +%imm31_19 31:1 19:5 +&tbz rt imm nz bitpos +@tbz . ...... nz:1 ..... .............. rt:5 &tbz imm=3D%imm14= bitpos=3D%imm31_19 + +TBZ . 011011 . ..... .............. ..... @tbz diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 5da551385bd..bd59d0616e3 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -1352,35 +1352,23 @@ static bool trans_CBZ(DisasContext *s, arg_cbz *a) return true; } =20 -/* Test and branch (immediate) - * 31 30 25 24 23 19 18 5 4 0 - * +----+-------------+----+-------+-------------+------+ - * | b5 | 0 1 1 0 1 1 | op | b40 | imm14 | Rt | - * +----+-------------+----+-------+-------------+------+ - */ -static void disas_test_b_imm(DisasContext *s, uint32_t insn) +static bool trans_TBZ(DisasContext *s, arg_tbz *a) { - unsigned int bit_pos, op, rt; - int64_t diff; DisasLabel match; TCGv_i64 tcg_cmp; =20 - bit_pos =3D (extract32(insn, 31, 1) << 5) | extract32(insn, 19, 5); - op =3D extract32(insn, 24, 1); /* 0: TBZ; 1: TBNZ */ - diff =3D sextract32(insn, 5, 14) * 4; - rt =3D extract32(insn, 0, 5); - tcg_cmp =3D tcg_temp_new_i64(); - tcg_gen_andi_i64(tcg_cmp, cpu_reg(s, rt), (1ULL << bit_pos)); + tcg_gen_andi_i64(tcg_cmp, cpu_reg(s, a->rt), (1ULL << a->bitpos)); =20 reset_btype(s); =20 match =3D gen_disas_label(s); - tcg_gen_brcondi_i64(op ? TCG_COND_NE : TCG_COND_EQ, + tcg_gen_brcondi_i64(a->nz ? TCG_COND_NE : TCG_COND_EQ, tcg_cmp, 0, match.label); gen_goto_tb(s, 0, 4); set_disas_label(s, match); - gen_goto_tb(s, 1, diff); + gen_goto_tb(s, 1, a->imm); + return true; } =20 /* Conditional branch (immediate) @@ -2397,9 +2385,6 @@ static void disas_uncond_b_reg(DisasContext *s, uint3= 2_t insn) static void disas_b_exc_sys(DisasContext *s, uint32_t insn) { switch (extract32(insn, 25, 7)) { - case 0x1b: case 0x5b: /* Test & branch (immediate) */ - disas_test_b_imm(s, insn); - break; case 0x2a: /* Conditional branch (immediate) */ disas_cond_b_imm(s, insn); break; --=20 2.34.1 From nobody Mon Feb 9 11:57:05 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1683902595; cv=none; d=zohomail.com; s=zohoarc; b=WjUuMzIMrHFZSTjhKhlLbQ3//9AHX3noXNTHp4pDBLjBMXo1T2zk2PvmquPvmMOi4VemmnA8EgjCb2zSKAjWkKIFSgnnLd8LqyyhkpjX1lnCRkBgWIotfaINjsaRN0H08TfuSkDtsHcDO/jm+blFkkSTjIUTCrZNTT03weum6to= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683902595; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=F0QOGVZAMk1HDBJjf1QtYWjsE8LxD2Kt5Aw9i/wccVs=; b=ly2SqaV83Ubg28xT4iQbssGya+Z+CKTdh587S5+6Oat+Kh/oQI6NBcoEWewfTYnfNgeLRfF8EBz3X5YgsKBxaWIE2MoWipf6DmjDVu3Y0WPeKEP0FWBIPXAuhE53QKpjdD3CNbifmWkAjZZJjtLJ4kxBAUDnCF2BqjBSSpEzh4I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1683902595212800.5744930238329; Fri, 12 May 2023 07:43:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pxTxh-0007FK-L0; Fri, 12 May 2023 10:41:37 -0400 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 1pxTxe-00078s-4D for qemu-devel@nongnu.org; Fri, 12 May 2023 10:41:34 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pxTxN-0004kK-J1 for qemu-devel@nongnu.org; Fri, 12 May 2023 10:41:33 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-3f42711865eso41131645e9.0 for ; Fri, 12 May 2023 07:41:17 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id f12-20020a7bcc0c000000b003f17848673fsm28916167wmh.27.2023.05.12.07.41.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 May 2023 07:41:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683902476; x=1686494476; 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=F0QOGVZAMk1HDBJjf1QtYWjsE8LxD2Kt5Aw9i/wccVs=; b=e7Qb+rhigALwzcgzgZYFBQIjyO/pBcHh5qdGWR1C58pO5LTJv31OQTIV15N4rzZHwL VWDMD726soFoVF0IQKKMGZH6rJ99hZgiYqeifE6mV5K6mxo/PS4ArtlGGJ1M2rTGAFtp 74ngztRX5Ao13zy7nqdUdBb5bmVuH3PWTFEvrioA4RJbYK7nrgVCSewdy6MfwMDA0S43 ie3K0rkMmXNwduyeEHD7aQ4Ha1nNxgx5TeWL+DSVEqi4Q0aUz98sCSwdJtOGp0S1gHRP Drsm5UGQiY40aGBPfb5dzoXjGi7xFSz1cT5ad3sc0NyISh7L7JzK1iMzww//V+oSyoky lRBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683902476; x=1686494476; 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=F0QOGVZAMk1HDBJjf1QtYWjsE8LxD2Kt5Aw9i/wccVs=; b=UCjLoLq+DdvhItP8LQrMTOF/zpj7X9NgEqa7nM0m73Mv+DFlqa8PeTWTkq3Vku0MuF SWs1qoEMrwOa9f52ixmME0PFF7RTineqPQfbYelNFXtukDYgZeIi4ndj/ZSoXFDjCKkM ttAB9blNZNVuZJ+NyE35n/WpnBb1FBTWYqW50Na27mOAJTav2Rac406Bo8NjxHTYa3+6 J+izFjSJ+7uexX8PBrHKCVdD8pC/K32c7SYm11dRS0r+e+5zIFBqD58aewHHmcbvAuVS 1laWT13fpXq/6kcsn0J8yphOq3zsSlBaOQFKVmofWnlfo/23/5SqSIOhq/l2+xxz478G 78fQ== X-Gm-Message-State: AC+VfDyZGAmUg3dv+fEYG6B+nB7S7tV/a7wk/RcP09MgSLR8QvH6kKlW DJKvP0n7t83riCTjLqCLAzNhkw== X-Google-Smtp-Source: ACHHUZ7ocunhUQvJ7KqZxb/6SNCscAzRncwhRfKQe0TgSpRCjq7XpECftWIGlbP3OeaFjOYtBpvjZw== X-Received: by 2002:a1c:7917:0:b0:3f4:2bb3:a5ba with SMTP id l23-20020a1c7917000000b003f42bb3a5bamr8931976wme.3.1683902476010; Fri, 12 May 2023 07:41:16 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PATCH 16/20] target/arm: Convert conditional branch insns to decodetree Date: Fri, 12 May 2023 15:41:02 +0100 Message-Id: <20230512144106.3608981-17-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230512144106.3608981-1-peter.maydell@linaro.org> References: <20230512144106.3608981-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x336.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=unavailable 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1683902596890100007 Content-Type: text/plain; charset="utf-8" Convert the immediate conditional branch insn B.cond to decodetree. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/tcg/a64.decode | 2 ++ target/arm/tcg/translate-a64.c | 30 ++++++------------------------ 2 files changed, 8 insertions(+), 24 deletions(-) diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode index 68dc820ece0..8514235a723 100644 --- a/target/arm/tcg/a64.decode +++ b/target/arm/tcg/a64.decode @@ -128,3 +128,5 @@ CBZ . 011010 . ................... ..... @c= bz @tbz . ...... nz:1 ..... .............. rt:5 &tbz imm=3D%imm14= bitpos=3D%imm31_19 =20 TBZ . 011011 . ..... .............. ..... @tbz + +B_cond 0101010 0 ................... 0 cond:4 imm=3D%imm19 diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index bd59d0616e3..724dca8c579 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -1371,36 +1371,21 @@ static bool trans_TBZ(DisasContext *s, arg_tbz *a) return true; } =20 -/* Conditional branch (immediate) - * 31 25 24 23 5 4 3 0 - * +---------------+----+---------------------+----+------+ - * | 0 1 0 1 0 1 0 | o1 | imm19 | o0 | cond | - * +---------------+----+---------------------+----+------+ - */ -static void disas_cond_b_imm(DisasContext *s, uint32_t insn) +static bool trans_B_cond(DisasContext *s, arg_B_cond *a) { - unsigned int cond; - int64_t diff; - - if ((insn & (1 << 4)) || (insn & (1 << 24))) { - unallocated_encoding(s); - return; - } - diff =3D sextract32(insn, 5, 19) * 4; - cond =3D extract32(insn, 0, 4); - reset_btype(s); - if (cond < 0x0e) { + if (a->cond < 0x0e) { /* genuinely conditional branches */ DisasLabel match =3D gen_disas_label(s); - arm_gen_test_cc(cond, match.label); + arm_gen_test_cc(a->cond, match.label); gen_goto_tb(s, 0, 4); set_disas_label(s, match); - gen_goto_tb(s, 1, diff); + gen_goto_tb(s, 1, a->imm); } else { /* 0xe and 0xf are both "always" conditions */ - gen_goto_tb(s, 0, diff); + gen_goto_tb(s, 0, a->imm); } + return true; } =20 /* HINT instruction group, including various allocated HINTs */ @@ -2385,9 +2370,6 @@ static void disas_uncond_b_reg(DisasContext *s, uint3= 2_t insn) static void disas_b_exc_sys(DisasContext *s, uint32_t insn) { switch (extract32(insn, 25, 7)) { - case 0x2a: /* Conditional branch (immediate) */ - disas_cond_b_imm(s, insn); - break; case 0x6a: /* Exception generation / System */ if (insn & (1 << 24)) { if (extract32(insn, 22, 2) =3D=3D 0) { --=20 2.34.1 From nobody Mon Feb 9 11:57:05 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1683902806; cv=none; d=zohomail.com; s=zohoarc; b=VHMaQIiIuq0pco5sCkCbWEwExEUiEXE9cvItH5NbyGwlz7SecoF0pnw4hGuV7DvaVU7XiH7sM+au2OISMzkowhA7svhSFIjeJd1pF98lCg2edA8FSudrBkr/dXHkcu+8nEUf9U2H0WK6ReVEqBD5T5R/nO4Y0f6ZFj6dFUX05g0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683902806; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7akZCgLrkYKZD7/0pb1eqcMpMk4KlEV9ol5sKLINuho=; b=bxOQPrLCJc6zSU/slTqrPTz2pGjysjvFpWeeWqeBYdlGS6CYDnA7dqV2q4K6n7J76YL5EbBfpiZV+S93k4qfxY3dAkpJ+zXq4vK7aqpPujqGi3xR+FxNzHtVK277e6ZBHa59LVllVz2Mz8ZG+tlVj523IOesS2457SMvKizZjvs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 168390280679291.45200293170933; Fri, 12 May 2023 07:46:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pxTxi-0007GT-Hp; Fri, 12 May 2023 10:41:38 -0400 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 1pxTxf-0007Bs-HV for qemu-devel@nongnu.org; Fri, 12 May 2023 10:41:35 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pxTxN-0004kV-QC for qemu-devel@nongnu.org; Fri, 12 May 2023 10:41:35 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-3f450815d0bso37255165e9.0 for ; Fri, 12 May 2023 07:41:17 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id f12-20020a7bcc0c000000b003f17848673fsm28916167wmh.27.2023.05.12.07.41.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 May 2023 07:41:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683902476; x=1686494476; 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=7akZCgLrkYKZD7/0pb1eqcMpMk4KlEV9ol5sKLINuho=; b=S4Bit7qzbXrjHGHTQyzbgMvLjId/Yfp3+3xhmGJkAAZt3e1JLcUPST27Zx5365U4B9 TNVGgDwDUsRnt4BdKXNTWTadhJWvt6FYixZRGwO0aI7bYuZcVJeFMfqIWJHrUczxz38n ljEq2uidVHv+Yx23P+oppeZOg3T1ze2a/nadwchcGwWjW5fHhO+y8VmMX1+gcTGUnroq sXa9PBS8UMjVMO/Am8YsWaMAUpH5DVJgP1+zbXzyH2rNyVxoQhC+33aIf7a7ByroZDz/ AI3QWUGaTaZjIsdPfBfXuoNIbudA/PUXIq1+H8Gyw50hzl7FRffWy95K67zq6lk+8lRO HNkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683902476; x=1686494476; 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=7akZCgLrkYKZD7/0pb1eqcMpMk4KlEV9ol5sKLINuho=; b=kCJtCiUuBhKidiCzFyfIaWzqHUzXCoPa+8s3tpyWP3DL++aQP0XxxCHdsxJX8kUxi+ ErdQmSeSeGxPQAi9VZYchN9rnyL7f7M9lslseJeJh4u96uYlVzYXvPGDd4EPNnik3nxo b4zYhkMz0XbArLbOplvZYQyb21Lms2o94Oe36qG97o/E4k3RLSHSNJapA4CmKXJkF6GQ eGYTw4jgtKm/iUDhdipm6c7+6LgAA5tOzfwgQ8UXvKHDZFfIW/XOWeHHvmljr0lsbHTJ n3NUUcjIoKS46RGiKULq/GHobMrxZEsnXoukobm/KbXl5wmrAuwsx4xikemxtg7pGis1 4YvQ== X-Gm-Message-State: AC+VfDwnlk2llF1sa11Be5k9vmGTL5rpEb1b1DmclfkSR2beZcT9lvJf /l37k9B7TqduC1KDpR2p0k1Ugw== X-Google-Smtp-Source: ACHHUZ4wxGVQpqxP2aiafx2m8SO6zlZplUI+01yeQTNLF32dFNn40dJGzCwSnOFzrewL4IFnXTbx8g== X-Received: by 2002:a7b:cb46:0:b0:3f1:82a1:122 with SMTP id v6-20020a7bcb46000000b003f182a10122mr17709755wmj.21.1683902476493; Fri, 12 May 2023 07:41:16 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PATCH 17/20] target/arm: Convert BR, BLR, RET to decodetree Date: Fri, 12 May 2023 15:41:03 +0100 Message-Id: <20230512144106.3608981-18-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230512144106.3608981-1-peter.maydell@linaro.org> References: <20230512144106.3608981-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32c.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1683902807326100001 Content-Type: text/plain; charset="utf-8" Convert the simple (non-pointer-auth) BR, BLR and RET insns to decodetree. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/tcg/a64.decode | 5 ++++ target/arm/tcg/translate-a64.c | 55 ++++++++++++++++++++++++++++++---- 2 files changed, 54 insertions(+), 6 deletions(-) diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode index 8514235a723..aa035f39558 100644 --- a/target/arm/tcg/a64.decode +++ b/target/arm/tcg/a64.decode @@ -19,6 +19,7 @@ # This file is processed by scripts/decodetree.py # =20 +&r rn &ri rd imm &rri_sf rd rn imm sf &i imm @@ -130,3 +131,7 @@ CBZ . 011010 . ................... ..... @c= bz TBZ . 011011 . ..... .............. ..... @tbz =20 B_cond 0101010 0 ................... 0 cond:4 imm=3D%imm19 + +BR 1101011 0000 11111 000000 rn:5 00000 &r +BLR 1101011 0001 11111 000000 rn:5 00000 &r +RET 1101011 0010 11111 000000 rn:5 00000 &r diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 724dca8c579..853a01ac5be 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -1388,6 +1388,53 @@ static bool trans_B_cond(DisasContext *s, arg_B_cond= *a) return true; } =20 +static void set_btype_for_br(DisasContext *s, int rn) +{ + if (dc_isar_feature(aa64_bti, s)) { + /* BR to {x16,x17} or !guard -> 1, else 3. */ + set_btype(s, rn =3D=3D 16 || rn =3D=3D 17 || !s->guarded_page ? 1 = : 3); + } +} + +static void set_btype_for_blr(DisasContext *s) +{ + if (dc_isar_feature(aa64_bti, s)) { + /* BLR sets BTYPE to 2, regardless of source guarded page. */ + set_btype(s, 2); + } +} + +static bool trans_BR(DisasContext *s, arg_r *a) +{ + gen_a64_set_pc(s, cpu_reg(s, a->rn)); + set_btype_for_br(s, a->rn); + s->base.is_jmp =3D DISAS_JUMP; + return true; +} + +static bool trans_BLR(DisasContext *s, arg_r *a) +{ + TCGv_i64 dst =3D cpu_reg(s, a->rn); + TCGv_i64 lr =3D cpu_reg(s, 30); + if (dst =3D=3D lr) { + TCGv_i64 tmp =3D tcg_temp_new_i64(); + tcg_gen_mov_i64(tmp, dst); + dst =3D tmp; + } + gen_pc_plus_diff(s, lr, curr_insn_len(s)); + gen_a64_set_pc(s, dst); + set_btype_for_blr(s); + s->base.is_jmp =3D DISAS_JUMP; + return true; +} + +static bool trans_RET(DisasContext *s, arg_r *a) +{ + gen_a64_set_pc(s, cpu_reg(s, a->rn)); + s->base.is_jmp =3D DISAS_JUMP; + return true; +} + /* HINT instruction group, including various allocated HINTs */ static void handle_hint(DisasContext *s, uint32_t insn, unsigned int op1, unsigned int op2, unsigned int c= rm) @@ -2186,12 +2233,8 @@ static void disas_uncond_b_reg(DisasContext *s, uint= 32_t insn) btype_mod =3D opc; switch (op3) { case 0: - /* BR, BLR, RET */ - if (op4 !=3D 0) { - goto do_unallocated; - } - dst =3D cpu_reg(s, rn); - break; + /* BR, BLR, RET : handled in decodetree */ + goto do_unallocated; =20 case 2: case 3: --=20 2.34.1 From nobody Mon Feb 9 11:57:05 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1683902801; cv=none; d=zohomail.com; s=zohoarc; b=I/4L3BaCJatfEL/WhnfR1IPSGCjuqU8KppuqiMBM65Z8+yPWoJiq62yO6UBmHu7zU9MYX8P2cwx3H5bE5AX8OIWJlgaDryKz3g/Qitlmimr1eSsfwzLlESoxAcXC2ZX84tZSHm57AOOCNKLJd4i9JSgccUu0vKkq9KC2IM1z4fk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683902801; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=WvyKjvvZPjQfu6e5IbjWblRQ9GYWJyDmT7w7l2HjFqA=; b=gUnMEL+kyqtcs3BDFz4BgTXstLcVEWoMjgabu6J44x85Ml0AMdW9l5/OWCFy2h716afzOjINC7kEt7otqruadb9YY4IMEJxabpJb22klIFvImenzUtD1qrRBFzP6u+w67lePlk64dHHgkkqGC/hvRZhFvg73uWEVPGoXX8ejMJM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1683902801473883.0600748712343; Fri, 12 May 2023 07:46:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pxTxi-0007GS-Hw; Fri, 12 May 2023 10:41:38 -0400 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 1pxTxe-0007AB-Ug for qemu-devel@nongnu.org; Fri, 12 May 2023 10:41:35 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pxTxN-0004hZ-Nc for qemu-devel@nongnu.org; Fri, 12 May 2023 10:41:34 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-3f435658d23so39602465e9.3 for ; Fri, 12 May 2023 07:41:17 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id f12-20020a7bcc0c000000b003f17848673fsm28916167wmh.27.2023.05.12.07.41.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 May 2023 07:41:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683902477; x=1686494477; 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=WvyKjvvZPjQfu6e5IbjWblRQ9GYWJyDmT7w7l2HjFqA=; b=lFbkBrdfNE3wAiKgOej/kiP6mk04mRza8oOnjdGKyDWCfz8KvLtljwspZLglN87ej8 k02cabAugs1qIUx0ee074FO9ri1M+ePLisf04Vb0t019Q+PSOviSq5oB2Xae+Q85F0oL 5Mz6ELVYMHyGmV+j99fq6tGON9UV9Nrn7Ywp0p/FsjtuD/JnNt4Pz4L1eBfVrBAIoLCx aYifTfmd7C+fjWb6rx5drRF2GhKDlIqF3QmAeRcjxIPSBy84ivR27/9ps91WweLATKw2 1JeNfIXqM5uivvIlg0iFo7lDvn2aN6qlOjJQap0uE4OK9TlOC/bRTfqpga+XsUS7CH9e LnsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683902477; x=1686494477; 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=WvyKjvvZPjQfu6e5IbjWblRQ9GYWJyDmT7w7l2HjFqA=; b=VToXIPTRhAPGenl/AOn2ldKuKN5fJ9qaOCEBklFt7aAJHvkfLj8MC+5BZFocfvSGf1 QzmNUyrXyDWw331QCwgw0gZB8UcUaGAk+mFg0XkZZwH7/md3Ya92aI9qyIxs1JlTPrNr uf+1aWPIBTvlWy85bncv2JdpgT4lnEzJTjvtNf4zOhX6c5yJRj9RBRauLHtc8sjnNYeb P0czYoUcprcdx6XKF9kvS9Hogomxnc1Oy67Lu+HrCovMxHRH7EX/AQrz93pOK3JyNKGj wMyzNRrAeMTk+lP7TjH9ttFdDRsbYfTAjvBBzdRyLPZsW9jJLSGdM65MMZ3Sitsl9+d1 qypg== X-Gm-Message-State: AC+VfDx332IcjxuV27xIQji/3LJ0yezz9VmoUwGBwvLbsqXWdyjUGu3i tfsowNZHnMdl/W8PozD1ON2HSw== X-Google-Smtp-Source: ACHHUZ6o6iIXmcxmD9DXUBD2dL4qyfNd1hZP9bS58m9vSSMTXC73KnX6HNEgDUYXrhOfEotlUhrZrA== X-Received: by 2002:a1c:750a:0:b0:3f4:16bc:bd19 with SMTP id o10-20020a1c750a000000b003f416bcbd19mr16089233wmc.23.1683902476963; Fri, 12 May 2023 07:41:16 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PATCH 18/20] target/arm: Convert BRA[AB]Z, BLR[AB]Z, RETA[AB] to decodetree Date: Fri, 12 May 2023 15:41:04 +0100 Message-Id: <20230512144106.3608981-19-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230512144106.3608981-1-peter.maydell@linaro.org> References: <20230512144106.3608981-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32a.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1683902802761100001 Content-Type: text/plain; charset="utf-8" Convert the single-register pointer-authentication variants of BR, BLR, RET to decodetree. (BRAA/BLRAA are in a different branch of the legacy decoder and will be dealt with in the next commit.) Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/tcg/a64.decode | 7 ++ target/arm/tcg/translate-a64.c | 132 +++++++++++++++++++-------------- 2 files changed, 84 insertions(+), 55 deletions(-) diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode index aa035f39558..22e3a5cea0c 100644 --- a/target/arm/tcg/a64.decode +++ b/target/arm/tcg/a64.decode @@ -135,3 +135,10 @@ B_cond 0101010 0 ................... 0 cond:4= imm=3D%imm19 BR 1101011 0000 11111 000000 rn:5 00000 &r BLR 1101011 0001 11111 000000 rn:5 00000 &r RET 1101011 0010 11111 000000 rn:5 00000 &r + +&braz rn m +BRAZ 1101011 0000 11111 00001 m:1 rn:5 11111 &braz # BRAAZ, B= RABZ +BLRAZ 1101011 0001 11111 00001 m:1 rn:5 11111 &braz # BLRAAZ, = BLRABZ + +&reta m +RETA 1101011 0010 11111 00001 m:1 11111 11111 &reta # RETAA, R= ETAB diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 853a01ac5be..e5b9171313b 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -1435,6 +1435,75 @@ static bool trans_RET(DisasContext *s, arg_r *a) return true; } =20 +static TCGv_i64 auth_branch_target(DisasContext *s, TCGv_i64 dst, + TCGv_i64 modifier, bool use_key_a) +{ + TCGv_i64 truedst; + /* + * Return the branch target for a BRAA/RETA/etc, which is either + * just the destination dst, or that value with the pauth check + * done and the code removed from the high bits. + */ + if (!s->pauth_active) { + return dst; + } + + truedst =3D tcg_temp_new_i64(); + if (use_key_a) { + gen_helper_autia(truedst, cpu_env, dst, modifier); + } else { + gen_helper_autib(truedst, cpu_env, dst, modifier); + } + return truedst; +} + +static bool trans_BRAZ(DisasContext *s, arg_braz *a) +{ + TCGv_i64 dst; + + if (!dc_isar_feature(aa64_pauth, s)) { + return false; + } + + dst =3D auth_branch_target(s, cpu_reg(s, a->rn), tcg_constant_i64(0), = !a->m); + gen_a64_set_pc(s, dst); + set_btype_for_br(s, a->rn); + s->base.is_jmp =3D DISAS_JUMP; + return true; +} + +static bool trans_BLRAZ(DisasContext *s, arg_braz *a) +{ + TCGv_i64 dst, lr; + + if (!dc_isar_feature(aa64_pauth, s)) { + return false; + } + + dst =3D auth_branch_target(s, cpu_reg(s, a->rn), tcg_constant_i64(0), = !a->m); + lr =3D cpu_reg(s, 30); + if (dst =3D=3D lr) { + TCGv_i64 tmp =3D tcg_temp_new_i64(); + tcg_gen_mov_i64(tmp, dst); + dst =3D tmp; + } + gen_pc_plus_diff(s, lr, curr_insn_len(s)); + gen_a64_set_pc(s, dst); + set_btype_for_blr(s); + s->base.is_jmp =3D DISAS_JUMP; + return true; +} + +static bool trans_RETA(DisasContext *s, arg_reta *a) +{ + TCGv_i64 dst; + + dst =3D auth_branch_target(s, cpu_reg(s, 30), cpu_X[31], !a->m); + gen_a64_set_pc(s, dst); + s->base.is_jmp =3D DISAS_JUMP; + return true; +} + /* HINT instruction group, including various allocated HINTs */ static void handle_hint(DisasContext *s, uint32_t insn, unsigned int op1, unsigned int op2, unsigned int c= rm) @@ -2227,61 +2296,14 @@ static void disas_uncond_b_reg(DisasContext *s, uin= t32_t insn) } =20 switch (opc) { - case 0: /* BR */ - case 1: /* BLR */ - case 2: /* RET */ - btype_mod =3D opc; - switch (op3) { - case 0: - /* BR, BLR, RET : handled in decodetree */ - goto do_unallocated; - - case 2: - case 3: - if (!dc_isar_feature(aa64_pauth, s)) { - goto do_unallocated; - } - if (opc =3D=3D 2) { - /* RETAA, RETAB */ - if (rn !=3D 0x1f || op4 !=3D 0x1f) { - goto do_unallocated; - } - rn =3D 30; - modifier =3D cpu_X[31]; - } else { - /* BRAAZ, BRABZ, BLRAAZ, BLRABZ */ - if (op4 !=3D 0x1f) { - goto do_unallocated; - } - modifier =3D tcg_constant_i64(0); - } - if (s->pauth_active) { - dst =3D tcg_temp_new_i64(); - if (op3 =3D=3D 2) { - gen_helper_autia(dst, cpu_env, cpu_reg(s, rn), modifie= r); - } else { - gen_helper_autib(dst, cpu_env, cpu_reg(s, rn), modifie= r); - } - } else { - dst =3D cpu_reg(s, rn); - } - break; - - default: - goto do_unallocated; - } - /* BLR also needs to load return address */ - if (opc =3D=3D 1) { - TCGv_i64 lr =3D cpu_reg(s, 30); - if (dst =3D=3D lr) { - TCGv_i64 tmp =3D tcg_temp_new_i64(); - tcg_gen_mov_i64(tmp, dst); - dst =3D tmp; - } - gen_pc_plus_diff(s, lr, curr_insn_len(s)); - } - gen_a64_set_pc(s, dst); - break; + case 0: + case 1: + case 2: + /* + * BR, BLR, RET, RETAA, RETAB, BRAAZ, BRABZ, BLRAAZ, BLRABZ: + * handled in decodetree + */ + goto do_unallocated; =20 case 8: /* BRAA */ case 9: /* BLRAA */ --=20 2.34.1 From nobody Mon Feb 9 11:57:05 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1683902639; cv=none; d=zohomail.com; s=zohoarc; b=aDGBIlHewdKao5eYvn7Wm/anIenXwHynQV6xcxTfL3od3tVsc9o1Jowjko/FZK7ronlfF2LkN9s4VH/QTA2PDVVgrMJK475zcwiapw3RJCnTCFbSlZe8HV4pJgnFEDVx3GcLYahluSRvPFM6hExjO1nfK58btujBY6gcNojBkMc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683902639; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=GF8g2QoTmndROU3FsqM7UEXXY4XAnJ/UXHPir51B1xY=; b=bjYrs7E6aNGGwjZvv18+LiAQcGWIxza4nT8SmjLWSjbDFXTDt+8nTMMEvvXeUUZCSqiTbwQeA8ELxiqUi1ijCHvY6IIduv08nU4Mcg9A1fiiZFpdLUqxXhkCg2cB/x0ogpqtMu/DtUAgGXlp4h0UzHTG9Yv2a1nM5F8tioXwgKk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1683902639271354.8671543560149; Fri, 12 May 2023 07:43:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pxTxn-0007Lv-Jw; Fri, 12 May 2023 10:41:43 -0400 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 1pxTxl-0007Ig-DE for qemu-devel@nongnu.org; Fri, 12 May 2023 10:41:41 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pxTxO-0004ky-Og for qemu-devel@nongnu.org; Fri, 12 May 2023 10:41:41 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-3f4249b7badso62552705e9.3 for ; Fri, 12 May 2023 07:41:18 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id f12-20020a7bcc0c000000b003f17848673fsm28916167wmh.27.2023.05.12.07.41.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 May 2023 07:41:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683902477; x=1686494477; 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=GF8g2QoTmndROU3FsqM7UEXXY4XAnJ/UXHPir51B1xY=; b=xSzc+wRyXpcTJr0ESaLVYkmy3ZAMSTe2fAxwLJv4FI32cgfuhWoMUhgja3QlOdLDVz M8QYalsqlcvGplOsmWKgCcyHWtMDtyQ0B/taW54YYAhXD8p6WR85r4imrOu3510ivk5C sarT6ti3VfzBB3Tj7ukoF7fpBBjiGgMqlTrmWA6YSqe6K6+zk8g+EPOsDhfq81hb2EAs 2s7VJavOtTtaZ50Rl8/KuTgjkrJEATT8+00pVrzVekDsF2rhS9HJeIK5WJu3wcEHkUW8 OQqRDTULFeD/L2da7BMJyLsyC+ryibyR6zMVEklzcLoIj0cxhtgpmeNAbDrlT0skKqKQ t/qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683902477; x=1686494477; 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=GF8g2QoTmndROU3FsqM7UEXXY4XAnJ/UXHPir51B1xY=; b=LxfSHlhZ01xggKWagkSFpvy8JVN89l0EGO2GXSXcWKw9sUdvVznCH/xbr/T6xMc3Ad xLzHxPfe81hV2FxgIGaD9XJCkcFIhXx7ID0m2CRnlDFg44A6P+AhmdmXXzynwYMzvPIy 7VMmdnVuiktYDMy+wXc9X3dgMS6q+t9a5WIc5ZUwuF+j9cdoTG9LOARL354vutNK92sJ ZtuQAlKWXJSXT8I/dONspW3lCTXjw+NqufGDUtpweSdyMxH4CrT+Xd/kQx6MikUjRLUW ZI0xNJSRYL+ZBRcETWoXQ1rRslTt9iGHO3AP4n+5Ma6Au46zgPWPqQWi0aQUpPbnChAo BKMA== X-Gm-Message-State: AC+VfDx3k2pJANjM7cWQX2zNINwNLSETwTJ4+hVo7Efc6WMPKRU1E8ij t7t9/L5MO93ji5Jjv1OKJvx2WQ== X-Google-Smtp-Source: ACHHUZ7OLXf70nLnZRb3X01Xyyi2DJZk0bOz4ErNxMSX6Nwrap+ogedl2Nqe4bcfm3XQNVnOs0eSNw== X-Received: by 2002:a05:600c:22cf:b0:3f4:ef3c:a89f with SMTP id 15-20020a05600c22cf00b003f4ef3ca89fmr3610935wmg.1.1683902477411; Fri, 12 May 2023 07:41:17 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PATCH 19/20] target/arm: Convert BRAA, BRAB, BLRAA, BLRAB to decodetree Date: Fri, 12 May 2023 15:41:05 +0100 Message-Id: <20230512144106.3608981-20-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230512144106.3608981-1-peter.maydell@linaro.org> References: <20230512144106.3608981-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x331.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, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_TEMPERROR=0.01 autolearn=unavailable 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1683902640384100010 Content-Type: text/plain; charset="utf-8" Convert the last four BR-with-pointer-auth insns to decodetree. The remaining cases in the outer switch in disas_uncond_b_reg() all return early rather than leaving the case statement, so we can delete the now-unused code at the end of that function. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/tcg/a64.decode | 4 ++ target/arm/tcg/translate-a64.c | 97 ++++++++++++++-------------------- 2 files changed, 43 insertions(+), 58 deletions(-) diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode index 22e3a5cea0c..5b055efdc19 100644 --- a/target/arm/tcg/a64.decode +++ b/target/arm/tcg/a64.decode @@ -142,3 +142,7 @@ BLRAZ 1101011 0001 11111 00001 m:1 rn:5 11111= &braz # BLRAAZ, BLRABZ =20 &reta m RETA 1101011 0010 11111 00001 m:1 11111 11111 &reta # RETAA, R= ETAB + +&bra rn rm m +BRA 1101011 1000 11111 00001 m:1 rn:5 rm:5 &bra # BRAA, BRAB +BLRA 1101011 1001 11111 00001 m:1 rn:5 rm:5 &bra # BLRAA, BLRAB diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index e5b9171313b..54e3571a89c 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -1504,6 +1504,41 @@ static bool trans_RETA(DisasContext *s, arg_reta *a) return true; } =20 +static bool trans_BRA(DisasContext *s, arg_bra *a) +{ + TCGv_i64 dst; + + if (!dc_isar_feature(aa64_pauth, s)) { + return false; + } + dst =3D auth_branch_target(s, cpu_reg(s,a->rn), cpu_reg_sp(s, a->rm), = !a->m); + gen_a64_set_pc(s, dst); + set_btype_for_br(s, a->rn); + s->base.is_jmp =3D DISAS_JUMP; + return true; +} + +static bool trans_BLRA(DisasContext *s, arg_bra *a) +{ + TCGv_i64 dst, lr; + + if (!dc_isar_feature(aa64_pauth, s)) { + return false; + } + dst =3D auth_branch_target(s, cpu_reg(s, a->rn), cpu_reg_sp(s, a->rm),= !a->m); + lr =3D cpu_reg(s, 30); + if (dst =3D=3D lr) { + TCGv_i64 tmp =3D tcg_temp_new_i64(); + tcg_gen_mov_i64(tmp, dst); + dst =3D tmp; + } + gen_pc_plus_diff(s, lr, curr_insn_len(s)); + gen_a64_set_pc(s, dst); + set_btype_for_blr(s); + s->base.is_jmp =3D DISAS_JUMP; + return true; +} + /* HINT instruction group, including various allocated HINTs */ static void handle_hint(DisasContext *s, uint32_t insn, unsigned int op1, unsigned int op2, unsigned int c= rm) @@ -2281,7 +2316,6 @@ static void disas_exc(DisasContext *s, uint32_t insn) static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) { unsigned int opc, op2, op3, rn, op4; - unsigned btype_mod =3D 2; /* 0: BR, 1: BLR, 2: other */ TCGv_i64 dst; TCGv_i64 modifier; =20 @@ -2299,45 +2333,14 @@ static void disas_uncond_b_reg(DisasContext *s, uin= t32_t insn) case 0: case 1: case 2: + case 8: + case 9: /* - * BR, BLR, RET, RETAA, RETAB, BRAAZ, BRABZ, BLRAAZ, BLRABZ: - * handled in decodetree + * BR, BLR, RET, RETAA, RETAB, BRAAZ, BRABZ, BLRAAZ, BLRABZ, + * BRAA, BLRAA: handled in decodetree */ goto do_unallocated; =20 - case 8: /* BRAA */ - case 9: /* BLRAA */ - if (!dc_isar_feature(aa64_pauth, s)) { - goto do_unallocated; - } - if ((op3 & ~1) !=3D 2) { - goto do_unallocated; - } - btype_mod =3D opc & 1; - if (s->pauth_active) { - dst =3D tcg_temp_new_i64(); - modifier =3D cpu_reg_sp(s, op4); - if (op3 =3D=3D 2) { - gen_helper_autia(dst, cpu_env, cpu_reg(s, rn), modifier); - } else { - gen_helper_autib(dst, cpu_env, cpu_reg(s, rn), modifier); - } - } else { - dst =3D cpu_reg(s, rn); - } - /* BLRAA also needs to load return address */ - if (opc =3D=3D 9) { - TCGv_i64 lr =3D cpu_reg(s, 30); - if (dst =3D=3D lr) { - TCGv_i64 tmp =3D tcg_temp_new_i64(); - tcg_gen_mov_i64(tmp, dst); - dst =3D tmp; - } - gen_pc_plus_diff(s, lr, curr_insn_len(s)); - } - gen_a64_set_pc(s, dst); - break; - case 4: /* ERET */ if (s->current_el =3D=3D 0) { goto do_unallocated; @@ -2407,28 +2410,6 @@ static void disas_uncond_b_reg(DisasContext *s, uint= 32_t insn) unallocated_encoding(s); return; } - - switch (btype_mod) { - case 0: /* BR */ - if (dc_isar_feature(aa64_bti, s)) { - /* BR to {x16,x17} or !guard -> 1, else 3. */ - set_btype(s, rn =3D=3D 16 || rn =3D=3D 17 || !s->guarded_page = ? 1 : 3); - } - break; - - case 1: /* BLR */ - if (dc_isar_feature(aa64_bti, s)) { - /* BLR sets BTYPE to 2, regardless of source guarded page. */ - set_btype(s, 2); - } - break; - - default: /* RET or none of the above. */ - /* BTYPE will be set to 0 by normal end-of-insn processing. */ - break; - } - - s->base.is_jmp =3D DISAS_JUMP; } =20 /* Branches, exception generating and system instructions */ --=20 2.34.1 From nobody Mon Feb 9 11:57:05 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1683902508; cv=none; d=zohomail.com; s=zohoarc; b=VYK9a53lsHx53blboknfGQ5GaanpWGmYLXrSwZg9bzkz8BfJIYF4xREwKG99lnzgVMkvDFOMzZGeW/pnPTDCjFYirVWxozh6C8/OnCczHvOtlefrazv1DgrFyKsmGhEgLmm6W6ch9vj01WYE8vmcdc/lDAHSfzEZ6IsjnLcZi18= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683902508; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fG7jKUscSVjJMlHsTaJJ5ClPxjke4FkCI7ENnqBR0Mk=; b=H7VslnI6e7N8t63ZGkEPRHJRknqoJBBt2cUBxnIuL53coj1PRrhJrteELTi26BdHkIigjELXLDkmktLZMbY8ie3oqUq7aokDsXP0QciZ73QHC3jDjxOGZxouOg3ctOlG+Q0KsqqoKhv9jmBq94gVkP/8OHQJZmNE1cCUUKZSmpo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1683902508350589.2059477646754; Fri, 12 May 2023 07:41:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pxTxj-0007Hh-SD; Fri, 12 May 2023 10:41:39 -0400 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 1pxTxh-0007Fc-TA for qemu-devel@nongnu.org; Fri, 12 May 2023 10:41:37 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pxTxO-0004gz-MA for qemu-devel@nongnu.org; Fri, 12 May 2023 10:41:37 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-3f4271185daso59004395e9.2 for ; Fri, 12 May 2023 07:41:18 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id f12-20020a7bcc0c000000b003f17848673fsm28916167wmh.27.2023.05.12.07.41.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 May 2023 07:41:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683902478; x=1686494478; 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=fG7jKUscSVjJMlHsTaJJ5ClPxjke4FkCI7ENnqBR0Mk=; b=IUgadMk7Xn+d2m4u+Ax0olBGmwqCSWLgWJGFWktAPgQLR+xMBbFI3WLYXQ7Q1t07XF 8ELzKL+HWzKDtGr3KJG2jsryLO/BG2wL+S6aEwKYlFZ7dmed4Cj+AoMvaJCR5iNxcCNN B+ufy5YUih0W1x8kcSteLbYMC1RqAEhZgoCGWeqVOhvoGWt+YC5FigV73FiE8rHtwD0T jIAda6Yk+oJ9LIOZgOJOS/JBRgk+xm7049VPgPWldUISupbk6I50vB6RlJFBnyDZRVjm sMlRG4bCp/iIL9dpe/SKic1sCRWUo+jE8iwvA04grWetSGkvFtgNUuPewpIyBAkvf501 EvEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683902478; x=1686494478; 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=fG7jKUscSVjJMlHsTaJJ5ClPxjke4FkCI7ENnqBR0Mk=; b=fNPi9cE/stq1l85ABAm4DJXp55Fvv/Li918HxuIxHSIalugFrG7sgQg96WlvaC3+Pw F5w7PQifBZLjxGy7SR0o6j+V1nqEQdQKDma2MxUXQGtLne83g6FcVeFUBSg49OVLsDWE sl4ErY5cfOUEQW5Z4rt74BsoInnkvssLV0fGgz1NehcHsyX6wMbKgJbq+56KNxZvCFRF reYGgZJfi51//1VLecIqogZZpwzknzx1yOu6xHUv23croKOfVcxsgxrDp0gj80hwZjMK 5nEw/S6jSA/aBc+7lsHC46szfzvypJP7hr2UDJf7Gw3wKa0MGSmu3HwRhN9EIZCy5L2K VeNQ== X-Gm-Message-State: AC+VfDzK0HdhtAc4SJreeYwZf/+ijU8Gx9CPXdRVfIsS9lMdQorBmJCi 7NW6UROg/00yfIw//VMRo+POhQ== X-Google-Smtp-Source: ACHHUZ7LyC3JhWUSbwsWdQDq2HCmzmaKwRDgGgG96TCFEq8cZhxEm+VcuKIayan0LpktmnnTs47P/g== X-Received: by 2002:a05:600c:2182:b0:3f4:2255:8608 with SMTP id e2-20020a05600c218200b003f422558608mr13880897wme.31.1683902477823; Fri, 12 May 2023 07:41:17 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PATCH 20/20] target/arm: Convert ERET, ERETAA, ERETAB to decodetree Date: Fri, 12 May 2023 15:41:06 +0100 Message-Id: <20230512144106.3608981-21-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230512144106.3608981-1-peter.maydell@linaro.org> References: <20230512144106.3608981-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x334.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1683902509814100003 Content-Type: text/plain; charset="utf-8" Convert the exception-return insns ERET, ERETA and ERETB to decodetree. These were the last insns left in the legacy decoder function disas_uncond_reg_b(), which allows us to remove it. The old decoder explicitly decoded the DRPS instruction, only in order to call unallocated_encoding() on it, exactly as would have happened if it hadn't decoded it. This is because this insn always UNDEFs unless the CPU is in halting-debug state, which we don't emulate. So we list the pattern in a comment in a64.decode, but don't actively decode it. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/tcg/a64.decode | 8 ++ target/arm/tcg/translate-a64.c | 160 +++++++++++---------------------- 2 files changed, 60 insertions(+), 108 deletions(-) diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode index 5b055efdc19..ae2874017d8 100644 --- a/target/arm/tcg/a64.decode +++ b/target/arm/tcg/a64.decode @@ -146,3 +146,11 @@ RETA 1101011 0010 11111 00001 m:1 11111 111= 11 &reta # RETAA, RETAB &bra rn rm m BRA 1101011 1000 11111 00001 m:1 rn:5 rm:5 &bra # BRAA, BRAB BLRA 1101011 1001 11111 00001 m:1 rn:5 rm:5 &bra # BLRAA, BLRAB + +ERET 1101011 0100 11111 000000 11111 00000 +ERETA 1101011 0100 11111 00001 m:1 11111 11111 &reta # ERETAA, = ERETAB + +# We don't need to decode DRPS because it always UNDEFs except when +# the processor is in halting debug state (which we don't implement). +# The pattern is listed here as documentation. +# DRPS 1101011 0101 11111 000000 11111 00000 diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 54e3571a89c..2cd31f85d79 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -1539,6 +1539,58 @@ static bool trans_BLRA(DisasContext *s, arg_bra *a) return true; } =20 +static bool trans_ERET(DisasContext *s, arg_ERET *a) +{ + TCGv_i64 dst; + + if (s->current_el =3D=3D 0) { + return false; + } + if (s->fgt_eret) { + gen_exception_insn_el(s, 0, EXCP_UDEF, 0, 2); + return true; + } + dst =3D tcg_temp_new_i64(); + tcg_gen_ld_i64(dst, cpu_env, + offsetof(CPUARMState, elr_el[s->current_el])); + + if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { + gen_io_start(); + } + + gen_helper_exception_return(cpu_env, dst); + /* Must exit loop to check un-masked IRQs */ + s->base.is_jmp =3D DISAS_EXIT; + return true; +} + +static bool trans_ERETA(DisasContext *s, arg_reta *a) +{ + TCGv_i64 dst; + + if (!dc_isar_feature(aa64_pauth, s)) { + return false; + } + /* The FGT trap takes precedence over an auth trap. */ + if (s->fgt_eret) { + gen_exception_insn_el(s, 0, EXCP_UDEF, a->m ? 3 : 2, 2); + return true; + } + dst =3D tcg_temp_new_i64(); + tcg_gen_ld_i64(dst, cpu_env, + offsetof(CPUARMState, elr_el[s->current_el])); + + dst =3D auth_branch_target(s, dst, cpu_X[31], !a->m); + if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { + gen_io_start(); + } + + gen_helper_exception_return(cpu_env, dst); + /* Must exit loop to check un-masked IRQs */ + s->base.is_jmp =3D DISAS_EXIT; + return true; +} + /* HINT instruction group, including various allocated HINTs */ static void handle_hint(DisasContext *s, uint32_t insn, unsigned int op1, unsigned int op2, unsigned int c= rm) @@ -2307,111 +2359,6 @@ static void disas_exc(DisasContext *s, uint32_t ins= n) } } =20 -/* Unconditional branch (register) - * 31 25 24 21 20 16 15 10 9 5 4 0 - * +---------------+-------+-------+-------+------+-------+ - * | 1 1 0 1 0 1 1 | opc | op2 | op3 | Rn | op4 | - * +---------------+-------+-------+-------+------+-------+ - */ -static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) -{ - unsigned int opc, op2, op3, rn, op4; - TCGv_i64 dst; - TCGv_i64 modifier; - - opc =3D extract32(insn, 21, 4); - op2 =3D extract32(insn, 16, 5); - op3 =3D extract32(insn, 10, 6); - rn =3D extract32(insn, 5, 5); - op4 =3D extract32(insn, 0, 5); - - if (op2 !=3D 0x1f) { - goto do_unallocated; - } - - switch (opc) { - case 0: - case 1: - case 2: - case 8: - case 9: - /* - * BR, BLR, RET, RETAA, RETAB, BRAAZ, BRABZ, BLRAAZ, BLRABZ, - * BRAA, BLRAA: handled in decodetree - */ - goto do_unallocated; - - case 4: /* ERET */ - if (s->current_el =3D=3D 0) { - goto do_unallocated; - } - switch (op3) { - case 0: /* ERET */ - if (op4 !=3D 0) { - goto do_unallocated; - } - if (s->fgt_eret) { - gen_exception_insn_el(s, 0, EXCP_UDEF, syn_erettrap(op3), = 2); - return; - } - dst =3D tcg_temp_new_i64(); - tcg_gen_ld_i64(dst, cpu_env, - offsetof(CPUARMState, elr_el[s->current_el])); - break; - - case 2: /* ERETAA */ - case 3: /* ERETAB */ - if (!dc_isar_feature(aa64_pauth, s)) { - goto do_unallocated; - } - if (rn !=3D 0x1f || op4 !=3D 0x1f) { - goto do_unallocated; - } - /* The FGT trap takes precedence over an auth trap. */ - if (s->fgt_eret) { - gen_exception_insn_el(s, 0, EXCP_UDEF, syn_erettrap(op3), = 2); - return; - } - dst =3D tcg_temp_new_i64(); - tcg_gen_ld_i64(dst, cpu_env, - offsetof(CPUARMState, elr_el[s->current_el])); - if (s->pauth_active) { - modifier =3D cpu_X[31]; - if (op3 =3D=3D 2) { - gen_helper_autia(dst, cpu_env, dst, modifier); - } else { - gen_helper_autib(dst, cpu_env, dst, modifier); - } - } - break; - - default: - goto do_unallocated; - } - if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { - gen_io_start(); - } - - gen_helper_exception_return(cpu_env, dst); - /* Must exit loop to check un-masked IRQs */ - s->base.is_jmp =3D DISAS_EXIT; - return; - - case 5: /* DRPS */ - if (op3 !=3D 0 || op4 !=3D 0 || rn !=3D 0x1f) { - goto do_unallocated; - } else { - unallocated_encoding(s); - } - return; - - default: - do_unallocated: - unallocated_encoding(s); - return; - } -} - /* Branches, exception generating and system instructions */ static void disas_b_exc_sys(DisasContext *s, uint32_t insn) { @@ -2427,9 +2374,6 @@ static void disas_b_exc_sys(DisasContext *s, uint32_t= insn) disas_exc(s, insn); } break; - case 0x6b: /* Unconditional branch (register) */ - disas_uncond_b_reg(s, insn); - break; default: unallocated_encoding(s); break; --=20 2.34.1