All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-arm@nongnu.org, qemu-devel@nongnu.org
Cc: Richard Henderson <richard.henderson@linaro.org>
Subject: [PATCH 02/20] target/arm: Create decodetree skeleton for A64
Date: Fri, 12 May 2023 15:40:48 +0100	[thread overview]
Message-ID: <20230512144106.3608981-3-peter.maydell@linaro.org> (raw)
In-Reply-To: <20230512144106.3608981-1-peter.maydell@linaro.org>

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 <peter.maydell@linaro.org>
---
 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 <http://www.gnu.org/licenses/>.
+
+#
+# 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 = 3
 };
 
+/*
+ * 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)
     }
 }
 
-/*
- * 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(DisasContextBase *dcbase, CPUState *cpu)
         disas_sme_fa64(s, insn);
     }
 
-    disas_a64_legacy(s, insn);
+
+    if (!disas_a64(s, insn)) {
+        disas_a64_legacy(s, insn);
+    }
 
     /*
      * 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 = [
   decodetree.process('a32-uncond.decode', extra_args: '--static-decode=disas_a32_uncond'),
   decodetree.process('t32.decode', extra_args: '--static-decode=disas_t32'),
   decodetree.process('t16.decode', extra_args: ['-w', '16', '--static-decode=disas_t16']),
+  decodetree.process('a64.decode', extra_args: ['--static-decode=disas_a64']),
 ]
 
 arm_ss.add(gen)
-- 
2.34.1



  parent reply	other threads:[~2023-05-12 14:45 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-12 14:40 [PATCH 00/20] target/arm: Start conversion of A64 decoder to decodetree Peter Maydell
2023-05-12 14:40 ` [PATCH 01/20] target/arm: Split out disas_a64_legacy Peter Maydell
2023-05-12 14:40 ` Peter Maydell [this message]
2023-05-13  7:12   ` [PATCH 02/20] target/arm: Create decodetree skeleton for A64 Richard Henderson
2023-05-12 14:40 ` [PATCH 03/20] target/arm: Pull calls to disas_sve() and disas_sme() out of legacy decoder Peter Maydell
2023-05-13  7:13   ` Richard Henderson
2023-05-12 14:40 ` [PATCH 04/20] target/arm: Convert PC-rel addressing to decodetree Peter Maydell
2023-05-12 14:40 ` [PATCH 05/20] target/arm: Split gen_add_CC and gen_sub_CC Peter Maydell
2023-05-12 14:40 ` [PATCH 06/20] target/arm: Convert Add/subtract (immediate) to decodetree Peter Maydell
2023-05-12 14:40 ` [PATCH 07/20] target/arm: Convert Add/subtract (immediate with tags) " Peter Maydell
2023-05-12 14:40 ` [PATCH 08/20] target/arm: Replace bitmask64 with MAKE_64BIT_MASK Peter Maydell
2023-05-12 14:40 ` [PATCH 09/20] target/arm: Convert Logical (immediate) to decodetree Peter Maydell
2023-05-12 14:40 ` [PATCH 10/20] target/arm: Convert Move wide " Peter Maydell
2023-05-12 14:40 ` [PATCH 11/20] target/arm: Convert Bitfield " Peter Maydell
2023-05-12 14:40 ` [PATCH 12/20] target/arm: Convert Extract instructions " Peter Maydell
2023-05-13  7:18   ` Richard Henderson
2023-05-12 14:40 ` [PATCH 13/20] target/arm: Convert unconditional branch immediate " Peter Maydell
2023-05-13  7:19   ` Richard Henderson
2023-05-12 14:41 ` [PATCH 14/20] target/arm: Convert CBZ, CBNZ " Peter Maydell
2023-05-13  7:26   ` Richard Henderson
2023-05-12 14:41 ` [PATCH 15/20] target/arm: Convert TBZ, TBNZ " Peter Maydell
2023-05-13  7:28   ` Richard Henderson
2023-05-12 14:41 ` [PATCH 16/20] target/arm: Convert conditional branch insns " Peter Maydell
2023-05-13  7:28   ` Richard Henderson
2023-05-12 14:41 ` [PATCH 17/20] target/arm: Convert BR, BLR, RET " Peter Maydell
2023-05-13 11:26   ` Richard Henderson
2023-05-12 14:41 ` [PATCH 18/20] target/arm: Convert BRA[AB]Z, BLR[AB]Z, RETA[AB] " Peter Maydell
2023-05-13 11:32   ` Richard Henderson
2023-05-12 14:41 ` [PATCH 19/20] target/arm: Convert BRAA, BRAB, BLRAA, BLRAB " Peter Maydell
2023-05-13 11:34   ` Richard Henderson
2023-05-12 14:41 ` [PATCH 20/20] target/arm: Convert ERET, ERETAA, ERETAB " Peter Maydell
2023-05-13 11:39   ` Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230512144106.3608981-3-peter.maydell@linaro.org \
    --to=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.