From nobody Sun Nov 9 11:37:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1551331633904540.9289355606571; Wed, 27 Feb 2019 21:27:13 -0800 (PST) Received: from localhost ([127.0.0.1]:60583 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzEDl-0006qv-T9 for importer@patchew.org; Thu, 28 Feb 2019 00:27:01 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59624) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzEBg-0005g3-8R for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:24:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gzEBe-0003mT-7K for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:24:52 -0500 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]:37247) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gzEBc-0003he-7B for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:24:50 -0500 Received: by mail-pf1-x42f.google.com with SMTP id s22so9148952pfh.4 for ; Wed, 27 Feb 2019 21:24:37 -0800 (PST) Received: from cloudburst.dc.rr.com (cpe-72-132-251-149.dc.res.rr.com. [72.132.251.149]) by smtp.gmail.com with ESMTPSA id u13sm32758371pfa.169.2019.02.27.21.24.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 27 Feb 2019 21:24:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=iyy89pd+gZqtt0lBzyMGPXvkLyMrFCMUc8ekV6OQwAg=; b=G5z4UT9MxyOxrmI+h/B8RPlqZChOAAhwWim2eObxWl2t3UVOR91rENwVyGtMiTXJyI cQYuhsoczW36hlEH77xLWSek34bL2/pbojZEdQS1suUD8nXhW7PLbJy40m1depojPpdp luXSn5xqj907EvhGmrGotgLkNUDC/DkJ40EAZVBFbKcfp8K0Z/88AzmgMwoMk4b2myu+ rxNW+pxn0Jq18u9qKG5/tFQNkSLU7sY8/hR5iZCGufRbY3oNjQlPAyC38Tpo9WFA0727 lsx/EbdIfqJzn3HegJcE3wKpY9aZleiYxP2AXsNSS5RcdFbGd/s8xNMuvmwOISereSDc aLcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=iyy89pd+gZqtt0lBzyMGPXvkLyMrFCMUc8ekV6OQwAg=; b=C912dnuO7pXQAD9DiW7U7mweHgTOwn6CW21rB8vgLomu2L+VlAbFDmjYa1hUJONij4 Vh4OdSPM3Swxa/BsD2jE8IxI7By5kKfbZrjlzf8o7qKgEa06OeCBkjz7xhJg+P2BeD9q ZtqaENgUtDipgpl9CfAwGh2yadrUkXfRwfTZE3ONy/EJqay10cVna0OEgyzy+5qz2EbY J07bEZ1Kcm2HW7e9y8ziMBufTrLFgXICNv5kkH1m17yxrVzDE4Z+mVbc+rqRTUjfC41O 0+Y3wN7fvrKaX0xvMwXeNXPZYUPp07N2FB3H/rsII7y7qVEULPTbhiqOuQ22S5K3VkY1 0rvA== X-Gm-Message-State: AHQUAubes3uvNyToLdVX+5JzJIODWufn6TbancHQzLhNcVJLjfvGDcdh CDBWg/UX5zaGhtD5fNu7YAOQEpOsu1I= X-Google-Smtp-Source: AHgI3IaJqkwz6IFHkSLPqoHk/EAye0OhRnNWNfiAHgHpfnxG1JZ4f+EgU2N3ncp1SrmxAH4g8kPYUQ== X-Received: by 2002:a63:618d:: with SMTP id v135mr6678781pgb.238.1551331476316; Wed, 27 Feb 2019 21:24:36 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 27 Feb 2019 21:24:25 -0800 Message-Id: <20190228052432.32571-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190228052432.32571-1-richard.henderson@linaro.org> References: <20190228052432.32571-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::42f Subject: [Qemu-devel] [PATCH v2 1/8] MAINTAINERS: Add scripts/decodetree.py to the TCG section X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kbastian@mail.uni-paderborn.de, f4bug@amsat.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20181110211313.6922-2-f4bug@amsat.org> Signed-off-by: Richard Henderson --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index 7be8c578ea..34364a77ce 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -117,6 +117,7 @@ F: cpus.c F: exec.c F: accel/tcg/ F: accel/stubs/tcg-stub.c +F: scripts/decodetree.py F: include/exec/cpu*.h F: include/exec/exec-all.h F: include/exec/helper*.h --=20 2.17.2 From nobody Sun Nov 9 11:37:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1551331773226375.2013781265522; Wed, 27 Feb 2019 21:29:33 -0800 (PST) Received: from localhost ([127.0.0.1]:60608 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzEG9-0000RZ-67 for importer@patchew.org; Thu, 28 Feb 2019 00:29:29 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59711) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzEBl-0005iz-41 for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:24:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gzEBg-0003oq-D8 for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:24:54 -0500 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:38028) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gzEBe-0003iK-5n for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:24:52 -0500 Received: by mail-pg1-x543.google.com with SMTP id m2so9117330pgl.5 for ; Wed, 27 Feb 2019 21:24:39 -0800 (PST) Received: from cloudburst.dc.rr.com (cpe-72-132-251-149.dc.res.rr.com. [72.132.251.149]) by smtp.gmail.com with ESMTPSA id u13sm32758371pfa.169.2019.02.27.21.24.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 27 Feb 2019 21:24:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=v8rnbCpTEczIgXqRljoCrowmHGwCxczvAy5UTYQaU7c=; b=mdSEp8yVSOisLlqcv8GJFeRVuiEVvNrUXiOCTYPEwN3L3wmHA5Cek96jocwIkkyudM ZLGPeMoS4MdNw06zvxpDQpeFvUhbx3XILFOz5sWutiFxvREe2zAvLPR5GFQaiQGJdgxW jm8jIbLK+YOXPFCRuiRhBCkwTKp/fDTNEVvgBGIi9u0fs+jkF481aMZullt6YA7rQDxe exR9J+eGRpN91ajpwDUvTbINkyXNQ569oHcJqmFPlFqZ2IvcswZMxLe1yG1cwzZsjqxW 4gL3nE7LPqOx1YgWyPlFYTiNlJJenzQVNL+MgL+WYIVG6HdeD55vfDmbXeND+VKUY8c2 a4tQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=v8rnbCpTEczIgXqRljoCrowmHGwCxczvAy5UTYQaU7c=; b=I9p19D4nZylXU4iKEfW4drbVbkS6IsMhlZnbgNEVac818DPupyM/MNdVMYGFJw4i9K cqYI+ujcrwfOJw5C6lQOg18nWsxACWlyDBe0tAvDC7NLIH2LGNqz4H1g4a8e5vgO9I0L DWB4gdp37wl2jNP/rqsDYXsus9K97nIbgHo2dOJaHRWqUI0cE8jRO39YdG6FNUGpfmlR btIykoALHKqKMpKSWVQd3jTX4/jJB5T7+aICC9Ipri3XIrNCLDJBcR4Ac4zwP/RtUIYz 7YQ4frxe3So7oqe/PPXyNQkZmbcFyIlLX+O0mR50dH3f8L4sNbSBiepeRFgzmC7REpwF dc7g== X-Gm-Message-State: AHQUAuY8EQI+U7u3bMyZhB4bW8Apf+lPExAru12hPHNBRWXo+k3TBWR/ Bwb760+cpP9jtVPUKIPqDT1E24Vh5mY= X-Google-Smtp-Source: AHgI3IbWRLK8/B1CKp7jcclA2GV39wqSxXBHwfaymPG++s0EFcM6WS4D7485pgxIhbXHtIFYR41yaQ== X-Received: by 2002:a65:6383:: with SMTP id h3mr6577337pgv.11.1551331477880; Wed, 27 Feb 2019 21:24:37 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 27 Feb 2019 21:24:26 -0800 Message-Id: <20190228052432.32571-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190228052432.32571-1-richard.henderson@linaro.org> References: <20190228052432.32571-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::543 Subject: [Qemu-devel] [PATCH v2 2/8] decodetree: Move documentation to docs/devel/decodetree.rst X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kbastian@mail.uni-paderborn.de, f4bug@amsat.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" One great big block comment isn't the best way to document the syntax of a language. Signed-off-by: Richard Henderson Reviewed-by: Bastian Koppelmann --- MAINTAINERS | 1 + docs/devel/decodetree.rst | 156 ++++++++++++++++++++++++++++++++++++++ scripts/decodetree.py | 134 +------------------------------- 3 files changed, 158 insertions(+), 133 deletions(-) create mode 100644 docs/devel/decodetree.rst diff --git a/MAINTAINERS b/MAINTAINERS index 34364a77ce..120cd7bff0 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -118,6 +118,7 @@ F: exec.c F: accel/tcg/ F: accel/stubs/tcg-stub.c F: scripts/decodetree.py +F: docs/devel/decodetree.rst F: include/exec/cpu*.h F: include/exec/exec-all.h F: include/exec/helper*.h diff --git a/docs/devel/decodetree.rst b/docs/devel/decodetree.rst new file mode 100644 index 0000000000..d9be30b2db --- /dev/null +++ b/docs/devel/decodetree.rst @@ -0,0 +1,156 @@ +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +Decodetree Specification +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +A *decodetree* is built from instruction *patterns*. A pattern may +represent a single architectural instruction or a group of same, depending +on what is convenient for further processing. + +Each pattern has both *fixedbits* and *fixedmask*, the combination of which +describes the condition under which the pattern is matched:: + + (insn & fixedmask) =3D=3D fixedbits + +Each pattern may have *fields*, which are extracted from the insn and +passed along to the translator. Examples of such are registers, +immediates, and sub-opcodes. + +In support of patterns, one may declare *fields*, *argument sets*, and +*formats*, each of which may be re-used to simplify further definitions. + +Fields +=3D=3D=3D=3D=3D=3D + +Syntax:: + + field_def :=3D '%' identifier ( unnamed_field )+ ( !function=3Dident= ifier )? + unnamed_field :=3D number ':' ( 's' ) number + +For *unnamed_field*, the first number is the least-significant bit position +of the field and the second number is the length of the field. If the 's'= is +present, the field is considered signed. If multiple ``unnamed_fields`` a= re +present, they are concatenated. In this way one can define disjoint field= s. + +If ``!function`` is specified, the concatenated result is passed through t= he +named function, taking and returning an integral value. + +FIXME: the fields of the structure into which this result will be stored +is restricted to ``int``. Which means that we cannot expand 64-bit items. + +Field examples: + ++---------------------------+---------------------------------------------+ +| Input | Generated code | ++=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+ +| %disp 0:s16 | sextract(i, 0, 16) | ++---------------------------+---------------------------------------------+ +| %imm9 16:6 10:3 | extract(i, 16, 6) << 3 | extract(i, 10, 3) | ++---------------------------+---------------------------------------------+ +| %disp12 0:s1 1:1 2:10 | sextract(i, 0, 1) << 11 | | +| | extract(i, 1, 1) << 10 | | +| | extract(i, 2, 10) | ++---------------------------+---------------------------------------------+ +| %shimm8 5:s8 13:1 | expand_shimm8(sextract(i, 5, 8) << 1 | | +| !function=3Dexpand_shimm8 | extract(i, 13, 1)) = | ++---------------------------+---------------------------------------------+ + +Argument Sets +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Syntax:: + + args_def :=3D '&' identifier ( args_elt )+ ( !extern )? + args_elt :=3D identifier + +Each *args_elt* defines an argument within the argument set. +Each argument set will be rendered as a C structure "arg_$name" +with each of the fields being one of the member arguments. + +If ``!extern`` is specified, the backing structure is assumed +to have been already declared, typically via a second decoder. + +Argument set examples:: + + ®3 ra rb rc + &loadstore reg base offset + + +Formats +=3D=3D=3D=3D=3D=3D=3D + +Syntax:: + + fmt_def :=3D '@' identifier ( fmt_elt )+ + fmt_elt :=3D fixedbit_elt | field_elt | field_ref | args_ref + fixedbit_elt :=3D [01.-]+ + field_elt :=3D identifier ':' 's'? number + field_ref :=3D '%' identifier | identifier '=3D' '%' identifier + args_ref :=3D '&' identifier + +Defining a format is a handy way to avoid replicating groups of fields +across many instruction patterns. + +A *fixedbit_elt* describes a contiguous sequence of bits that must +be 1, 0, or don't care. The difference between '.' and '-' +is that '.' means that the bit will be covered with a field or a +final 0 or 1 from the pattern, and '-' means that the bit is really +ignored by the cpu and will not be specified. + +A *field_elt* describes a simple field only given a width; the position of +the field is implied by its position with respect to other *fixedbit_elt* +and *field_elt*. + +If any *fixedbit_elt* or *field_elt* appear, then all bits must be defined. +Padding with a *fixedbit_elt* of all '.' is an easy way to accomplish that. + +A *field_ref* incorporates a field by reference. This is the only way to +add a complex field to a format. A field may be renamed in the process +via assignment to another identifier. This is intended to allow the +same argument set be used with disjoint named fields. + +A single *args_ref* may specify an argument set to use for the format. +The set of fields in the format must be a subset of the arguments in +the argument set. If an argument set is not specified, one will be +inferred from the set of fields. + +It is recommended, but not required, that all *field_ref* and *args_ref* +appear at the end of the line, not interleaving with *fixedbit_elf* or +*field_elt*. + +Format examples:: + + @opr ...... ra:5 rb:5 ... 0 ....... rc:5 + @opi ...... ra:5 lit:8 1 ....... rc:5 + +Patterns +=3D=3D=3D=3D=3D=3D=3D=3D + +Syntax:: + + pat_def :=3D identifier ( pat_elt )+ + pat_elt :=3D fixedbit_elt | field_elt | field_ref | args_ref | fmt_= ref | const_elt + fmt_ref :=3D '@' identifier + const_elt :=3D identifier '=3D' number + +The *fixedbit_elt* and *field_elt* specifiers are unchanged from formats. +A pattern that does not specify a named format will have one inferred +from a referenced argument set (if present) and the set of fields. + +A *const_elt* allows a argument to be set to a constant value. This may +come in handy when fields overlap between patterns and one has to +include the values in the *fixedbit_elt* instead. + +The decoder will call a translator function for each pattern matched. + +Pattern examples:: + + addl_r 010000 ..... ..... .... 0000000 ..... @opr + addl_i 010000 ..... ..... .... 0000000 ..... @opi + +which will, in part, invoke:: + + trans_addl_r(ctx, &arg_opr, insn) + +and:: + + trans_addl_i(ctx, &arg_opi, insn) diff --git a/scripts/decodetree.py b/scripts/decodetree.py index e342d278b8..33e32ee87f 100755 --- a/scripts/decodetree.py +++ b/scripts/decodetree.py @@ -17,139 +17,7 @@ =20 # # Generate a decoding tree from a specification file. -# -# The tree is built from instruction "patterns". A pattern may represent -# a single architectural instruction or a group of same, depending on what -# is convenient for further processing. -# -# Each pattern has "fixedbits" & "fixedmask", the combination of which -# describes the condition under which the pattern is matched: -# -# (insn & fixedmask) =3D=3D fixedbits -# -# Each pattern may have "fields", which are extracted from the insn and -# passed along to the translator. Examples of such are registers, -# immediates, and sub-opcodes. -# -# In support of patterns, one may declare fields, argument sets, and -# formats, each of which may be re-used to simplify further definitions. -# -# *** Field syntax: -# -# field_def :=3D '%' identifier ( unnamed_field )+ ( !function=3Dident= ifier )? -# unnamed_field :=3D number ':' ( 's' ) number -# -# For unnamed_field, the first number is the least-significant bit positio= n of -# the field and the second number is the length of the field. If the 's' = is -# present, the field is considered signed. If multiple unnamed_fields are -# present, they are concatenated. In this way one can define disjoint fie= lds. -# -# If !function is specified, the concatenated result is passed through the -# named function, taking and returning an integral value. -# -# FIXME: the fields of the structure into which this result will be stored -# is restricted to "int". Which means that we cannot expand 64-bit items. -# -# Field examples: -# -# %disp 0:s16 -- sextract(i, 0, 16) -# %imm9 16:6 10:3 -- extract(i, 16, 6) << 3 | extract(i, 10, 3) -# %disp12 0:s1 1:1 2:10 -- sextract(i, 0, 1) << 11 -# | extract(i, 1, 1) << 10 -# | extract(i, 2, 10) -# %shimm8 5:s8 13:1 !function=3Dexpand_shimm8 -# -- expand_shimm8(sextract(i, 5, 8) << 1 -# | extract(i, 13, 1)) -# -# *** Argument set syntax: -# -# args_def :=3D '&' identifier ( args_elt )+ ( !extern )? -# args_elt :=3D identifier -# -# Each args_elt defines an argument within the argument set. -# Each argument set will be rendered as a C structure "arg_$name" -# with each of the fields being one of the member arguments. -# -# If !extern is specified, the backing structure is assumed to -# have been already declared, typically via a second decoder. -# -# Argument set examples: -# -# ®3 ra rb rc -# &loadstore reg base offset -# -# *** Format syntax: -# -# fmt_def :=3D '@' identifier ( fmt_elt )+ -# fmt_elt :=3D fixedbit_elt | field_elt | field_ref | args_ref -# fixedbit_elt :=3D [01.-]+ -# field_elt :=3D identifier ':' 's'? number -# field_ref :=3D '%' identifier | identifier '=3D' '%' identifier -# args_ref :=3D '&' identifier -# -# Defining a format is a handy way to avoid replicating groups of fields -# across many instruction patterns. -# -# A fixedbit_elt describes a contiguous sequence of bits that must -# be 1, 0, [.-] for don't care. The difference between '.' and '-' -# is that '.' means that the bit will be covered with a field or a -# final [01] from the pattern, and '-' means that the bit is really -# ignored by the cpu and will not be specified. -# -# A field_elt describes a simple field only given a width; the position of -# the field is implied by its position with respect to other fixedbit_elt -# and field_elt. -# -# If any fixedbit_elt or field_elt appear then all bits must be defined. -# Padding with a fixedbit_elt of all '.' is an easy way to accomplish that. -# -# A field_ref incorporates a field by reference. This is the only way to -# add a complex field to a format. A field may be renamed in the process -# via assignment to another identifier. This is intended to allow the -# same argument set be used with disjoint named fields. -# -# A single args_ref may specify an argument set to use for the format. -# The set of fields in the format must be a subset of the arguments in -# the argument set. If an argument set is not specified, one will be -# inferred from the set of fields. -# -# It is recommended, but not required, that all field_ref and args_ref -# appear at the end of the line, not interleaving with fixedbit_elf or -# field_elt. -# -# Format examples: -# -# @opr ...... ra:5 rb:5 ... 0 ....... rc:5 -# @opi ...... ra:5 lit:8 1 ....... rc:5 -# -# *** Pattern syntax: -# -# pat_def :=3D identifier ( pat_elt )+ -# pat_elt :=3D fixedbit_elt | field_elt | field_ref -# | args_ref | fmt_ref | const_elt -# fmt_ref :=3D '@' identifier -# const_elt :=3D identifier '=3D' number -# -# The fixedbit_elt and field_elt specifiers are unchanged from formats. -# A pattern that does not specify a named format will have one inferred -# from a referenced argument set (if present) and the set of fields. -# -# A const_elt allows a argument to be set to a constant value. This may -# come in handy when fields overlap between patterns and one has to -# include the values in the fixedbit_elt instead. -# -# The decoder will call a translator function for each pattern matched. -# -# Pattern examples: -# -# addl_r 010000 ..... ..... .... 0000000 ..... @opr -# addl_i 010000 ..... ..... .... 0000000 ..... @opi -# -# which will, in part, invoke -# -# trans_addl_r(ctx, &arg_opr, insn) -# and -# trans_addl_i(ctx, &arg_opi, insn) +# See the syntax and semantics in docs/devel/decodetree.rst. # =20 import os --=20 2.17.2 From nobody Sun Nov 9 11:37:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1551331633905648.3312635437416; Wed, 27 Feb 2019 21:27:13 -0800 (PST) Received: from localhost ([127.0.0.1]:60587 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzEDo-0006sk-PM for importer@patchew.org; Thu, 28 Feb 2019 00:27:04 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59623) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzEBg-0005g2-8Y for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:24:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gzEBe-0003mp-8c for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:24:52 -0500 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:42295) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gzEBc-0003ie-74 for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:24:50 -0500 Received: by mail-pl1-x644.google.com with SMTP id v11so3735235plg.9 for ; Wed, 27 Feb 2019 21:24:40 -0800 (PST) Received: from cloudburst.dc.rr.com (cpe-72-132-251-149.dc.res.rr.com. [72.132.251.149]) by smtp.gmail.com with ESMTPSA id u13sm32758371pfa.169.2019.02.27.21.24.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 27 Feb 2019 21:24:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bhUfeH7Y88x0TUB0opJCJd9CwNlMyBnOlAFYaYt2ezU=; b=AyPBiZQ5OMa9X3JAZ+zA3rsSq67zV0M0WORdQUs0YtFwXi9y8SJTio0JP2SrUGrOWt AqpsM6XzIzW2Z2+qtBpM2wXMcCjP4zbBtoc1jsOqu9tZaT/axUJYaUlMpCuMWwSYvS4d Dh5L+BgKcE8ssZSJTL/C4gG7ZWR5knKwvSfeqkjFEAkqh5Q4u6GjNHFC1BgbsAgyApAb 9odfq5uMxHHsHkFPRyTv8cmFJ95TioOtsceTH9mypyZoEpbZ8rgpBLL3CHeJt4eGcZnl ZzW/Wn9ZwZiIDzOE1RHeEalEosLYj/y++vT0hHTJBoD7FiJAla4eW6fNhp8P8eRflUSG I8MQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bhUfeH7Y88x0TUB0opJCJd9CwNlMyBnOlAFYaYt2ezU=; b=mo4B8kJaTBWLYinyKwfqgQAzBZ4vsUrodczW9/q7NvBnGTiltipTwQ3kq/8Mt3KtWr 1gGjmubyN8kAmMpoJqjXMJj7uju6wCnXzrYhUOVAgZmNBYi2B+Q2XxwMVtaKGqyU8VHF SkCn271oX0SpQhpp0bk0FHl4kiRQTedxT7oJusnd16g+WAf6hv8Q15X2CTjITtUozAUH O0ik70qVSfJlClC2nDj+v60WkmGcpfylItET0GdGK7EJvbVoYVtEDdqi90/y3SRbRLDN JQOhk3YNkZZuVoRW89gp5hTF1z+HoBztYKWbkqBG6DRXGLPpGdQymZXmajBj9/xeDnPy 97Bw== X-Gm-Message-State: AHQUAuYvXpEv/mScK+Rco0FFx3SakGHk2Epy8ZShPaNckfig7aFdvhEx pb+L37kD1UqQc3Ers9ZgTqhRTsSgc4U= X-Google-Smtp-Source: AHgI3IZBbBQ03cwfjZX8oRiMDiEAy796SGz0IaXj9yymVIcQP6+NKfrI6BsPESPMJmHvjgk1fBOqmg== X-Received: by 2002:a17:902:9a43:: with SMTP id x3mr6007751plv.173.1551331479260; Wed, 27 Feb 2019 21:24:39 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 27 Feb 2019 21:24:27 -0800 Message-Id: <20190228052432.32571-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190228052432.32571-1-richard.henderson@linaro.org> References: <20190228052432.32571-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::644 Subject: [Qemu-devel] [PATCH v2 3/8] decodetree: Document the usefulness of argument sets X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kbastian@mail.uni-paderborn.de, f4bug@amsat.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Cc: Bastian Koppelmann Signed-off-by: Richard Henderson Reviewed-by: Bastian Koppelmann --- docs/devel/decodetree.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/devel/decodetree.rst b/docs/devel/decodetree.rst index d9be30b2db..62cb7f687c 100644 --- a/docs/devel/decodetree.rst +++ b/docs/devel/decodetree.rst @@ -69,6 +69,13 @@ with each of the fields being one of the member argument= s. If ``!extern`` is specified, the backing structure is assumed to have been already declared, typically via a second decoder. =20 +Argument sets are useful when one wants to define helper functions +for the translator functions that can perform operations on a common +set of arguments. This can ensure, for instance, that the ``AND`` +pattern and the ``OR`` pattern put their operands into the same named +structure, so that a common ``gen_logic_insn`` may be able to handle +the operations common between the two. + Argument set examples:: =20 ®3 ra rb rc --=20 2.17.2 From nobody Sun Nov 9 11:37:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1551331637296103.94054201946778; Wed, 27 Feb 2019 21:27:17 -0800 (PST) Received: from localhost ([127.0.0.1]:60589 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzEDs-0006z7-7F for importer@patchew.org; Thu, 28 Feb 2019 00:27:08 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59684) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzEBi-0005gS-9q for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:24:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gzEBg-0003o0-6q for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:24:54 -0500 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]:38465) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gzEBe-0003jL-6J for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:24:50 -0500 Received: by mail-pf1-x431.google.com with SMTP id n125so9145724pfn.5 for ; Wed, 27 Feb 2019 21:24:42 -0800 (PST) Received: from cloudburst.dc.rr.com (cpe-72-132-251-149.dc.res.rr.com. [72.132.251.149]) by smtp.gmail.com with ESMTPSA id u13sm32758371pfa.169.2019.02.27.21.24.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 27 Feb 2019 21:24:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dJ9V0cdUMTbTLS+jTfS4ibWwVyEFxtj+1fJtRE1MNSo=; b=wONT4EfhI2k5t+03Iak6wJqJica1WlKv6+CxUZB5c+4ZdiB7Ch5Ryeq0Xt5WjRn0Il Xzw91KBpyGzL7dNHzeQmT7STVn/23zdXpioqQbBY0doiG6tiXDwqDRHFo1Ft5BNNOpTv 3HEl01NWPDqywmtiP7aZXmy3eFtZm9/YSB97CYjrFL267ZZ5XteYTmZCYl0Ttcyyns+Z Q9llwNRsYwgMzihDbju3QQ+68RoLdfdYfb2fc7t7iHvyd7SXwbbZIQasaC1Up+nXJjKI Y7NDqAnr9mGIQeA275a4NbB5M/GSAqo+asKFkj4NyJWgRMHIIWu0+qSWwJOWoj7qfb9Y TcKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dJ9V0cdUMTbTLS+jTfS4ibWwVyEFxtj+1fJtRE1MNSo=; b=fKtMXL5DPzb37FaBhvqXBYmL9zresrvpE2yfXxDs9ayyBnf3euqAVYkd87eeFVpicf UarwCtPyTpe76vq66ROqlyrxYG4SR5bFWsqb/8/V0Y/68ZycEWmimcQsDn/akGcwHwh1 5FzL9oabnIShE3RyDOA+trPM1GhU1Z5OHViMtKQnq7GFkKrjCKLe4r7WVmrKudBnV2V8 xpnvrMI3sBVGcm5GCFHFG8WIIwONKVd5THaWRrUhrkSRne1uJ2kl8ay6DqXryWmcIeC+ vag+Je52j074Elrkur80JjNAIdFqk/wprrUYSCNDybwR63TAjq32UQRw8iaHctL4kopN 7yvg== X-Gm-Message-State: AHQUAuaIK1P+YKxIqukOC3EPX7uQylUK5+rfzPiLu+5Rr1NzE0xlDed1 vMgVkVyx+XlgD+Ka/lxGJqyQcxUT4G8= X-Google-Smtp-Source: AHgI3IbIpkP6zbeHqktbYYesV/86tRhiibUHDszv7vts/KOH/Wl8nSL8OeVM5fmdw6bMrddG/07svw== X-Received: by 2002:a65:6105:: with SMTP id z5mr6721861pgu.434.1551331480784; Wed, 27 Feb 2019 21:24:40 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 27 Feb 2019 21:24:28 -0800 Message-Id: <20190228052432.32571-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190228052432.32571-1-richard.henderson@linaro.org> References: <20190228052432.32571-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::431 Subject: [Qemu-devel] [PATCH v2 4/8] decodetree: Ensure build_tree does not include values outside insnmask X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kbastian@mail.uni-paderborn.de, f4bug@amsat.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 Reproduced with "scripts/decodetree.py /dev/null". Reviewed-by: Bastian Koppelmann Reviewed-by: Eduardo Habkost Signed-off-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- scripts/decodetree.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/decodetree.py b/scripts/decodetree.py index 33e32ee87f..e26d8253f2 100755 --- a/scripts/decodetree.py +++ b/scripts/decodetree.py @@ -784,7 +784,7 @@ class Tree: =20 def build_tree(pats, outerbits, outermask): # Find the intersection of all remaining fixedmask. - innermask =3D ~outermask + innermask =3D ~outermask & insnmask for i in pats: innermask &=3D i.fixedmask =20 --=20 2.17.2 From nobody Sun Nov 9 11:37:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1551331768049372.20405030400855; Wed, 27 Feb 2019 21:29:28 -0800 (PST) Received: from localhost ([127.0.0.1]:60606 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzEG5-0000Mf-2k for importer@patchew.org; Thu, 28 Feb 2019 00:29:25 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59621) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzEBg-0005g0-8A for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:24:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gzEBe-0003ms-8k for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:24:52 -0500 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]:42937) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gzEBc-0003jp-75 for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:24:50 -0500 Received: by mail-pg1-x534.google.com with SMTP id b2so9108653pgl.9 for ; Wed, 27 Feb 2019 21:24:43 -0800 (PST) Received: from cloudburst.dc.rr.com (cpe-72-132-251-149.dc.res.rr.com. [72.132.251.149]) by smtp.gmail.com with ESMTPSA id u13sm32758371pfa.169.2019.02.27.21.24.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 27 Feb 2019 21:24:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=q7BmrH4sjrNhoBHqeKigtEhx9qwjct0IB15Jx7wduro=; b=pPYZ9u8PLh+51c8aUzwZl9hmq8dhaEKMpCWh7jQwJFdL54eKhV3F84IVsXl5H55f+v oEZcoLqDdMYb6ynQOV1B5GOPV6V94PoBK6tTfY0fOAxmTnZpc3J1rCQUui0KR9fujK7m 85jJ6XEj34+rWP9ZmyrsBbwwGykT4Hd6uuWxG1YB7kO1/Y1C/O9kalmlv5IdqwfCq5p3 mbC2LrG1YzGhhBthLQ1oP7KiElpapR/KPy2O+CJdBVbrRWgMuoDvEKnwX8a5DXcghhS9 M1KlM+kaYFaiU3n+7Edz2M9H2Jkihao8FgkxOz3eFEfRoeDsPVtWWcdTlsrPysH0WG+I UJLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=q7BmrH4sjrNhoBHqeKigtEhx9qwjct0IB15Jx7wduro=; b=ZGGo/lmi4gqs5lQa08vHlQprwcvQHjoRIZdW15wt/eSKh58mtvkMA3dICYRgdKJUUB JGz6BDdRsNotAXgCCSz54K2i0OzagiyvOZ90uOJHWelHkLgj/mj2RZrtdZ3Rm77wTeW3 LQZlhEtGB/jYDK8CAqrJxzvqzHU2+xGuVK4ONm4wzYfRT3vac8gLQImcppDichrhBGbL Xp1n49yTydOyjYuRT7FxVW6un2Zi+fWr+M7PxNpS0t/d3jhQkOZ9xExYRBGm3h+L2M/z cw9OMbOqlmxL2kig1U5O9OVQgdLjooxyWaSp3cKufxFqc5FlAc4cKqfDNOzB/rZiG9QW MtCg== X-Gm-Message-State: AHQUAuZQ0jaoaUWOeAO6oHjcWFBNSHohIB3psAsmKTkovoLnAD/kliAZ marZNSObXLk7pfQdys/E1yra00Qqz1k= X-Google-Smtp-Source: AHgI3IaneHgQQyJ04Te7v/dYoq6dM0/QK5hAuRSSSHfydEhXJO6DSHBB02CiFsJXioIGgx7wNYPmcw== X-Received: by 2002:a65:6483:: with SMTP id e3mr6621039pgv.273.1551331482191; Wed, 27 Feb 2019 21:24:42 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 27 Feb 2019 21:24:29 -0800 Message-Id: <20190228052432.32571-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190228052432.32571-1-richard.henderson@linaro.org> References: <20190228052432.32571-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::534 Subject: [Qemu-devel] [PATCH v2 5/8] decodetree: Do not unconditionaly return from Pattern.output_code X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kbastian@mail.uni-paderborn.de, f4bug@amsat.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) As a consequence, the 'return false' gets pushed up one level. This will allow us to perform some other action when the translator returns failure. Tested-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Bastian Koppelmann Signed-off-by: Richard Henderson --- scripts/decodetree.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/decodetree.py b/scripts/decodetree.py index e26d8253f2..cc5fa1a8ab 100755 --- a/scripts/decodetree.py +++ b/scripts/decodetree.py @@ -348,8 +348,8 @@ class Pattern(General): output(ind, self.base.extract_name(), '(&u.f_', arg, ', insn);= \n') for n, f in self.fields.items(): output(ind, 'u.f_', arg, '.', n, ' =3D ', f.str_extract(), ';\= n') - output(ind, 'return ', translate_prefix, '_', self.name, - '(ctx, &u.f_', arg, ');\n') + output(ind, 'if (', translate_prefix, '_', self.name, + '(ctx, &u.f_', arg, ')) return true;\n') # end Pattern =20 =20 @@ -777,8 +777,8 @@ class Tree: output(ind, ' /* ', str_match_bits(innerbits, innermask), ' */\n') s.output_code(i + 4, extracted, innerbits, innermask) + output(ind, ' return false;\n') output(ind, '}\n') - output(ind, 'return false;\n') # end Tree =20 =20 @@ -932,6 +932,7 @@ def main(): output(i4, '} u;\n\n') =20 t.output_code(4, False, 0, 0) + output(i4, 'return false;\n') =20 output('}\n') =20 --=20 2.17.2 From nobody Sun Nov 9 11:37:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1551331853490634.265277051294; Wed, 27 Feb 2019 21:30:53 -0800 (PST) Received: from localhost ([127.0.0.1]:60654 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzEHS-0001Vv-FI for importer@patchew.org; Thu, 28 Feb 2019 00:30:50 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59625) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzEBg-0005g4-8V for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:24:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gzEBe-0003mf-7v for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:24:52 -0500 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:34195) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gzEBc-0003kH-AO for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:24:50 -0500 Received: by mail-pl1-x641.google.com with SMTP id d15so9173633plr.1 for ; Wed, 27 Feb 2019 21:24:45 -0800 (PST) Received: from cloudburst.dc.rr.com (cpe-72-132-251-149.dc.res.rr.com. [72.132.251.149]) by smtp.gmail.com with ESMTPSA id u13sm32758371pfa.169.2019.02.27.21.24.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 27 Feb 2019 21:24:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+lg5QUonTqYML7nEvv2sRq/KVhbJP2uTOKti8/DWcYM=; b=S3WxZNXFQcQ2zdVk9iOLWYEMTIpjbDmN26vqOWgdI7yw8GYo4AIrxkRaIArvzaD9xB EGfUDpSepd1hoY42+ZJgOxPloj8rzxvQiYbRW8GNaujG0WyKn8zfF1FAGztE8NPl7s7W iQpnV5jdQpRoNG7ABc8hb6GoUODDrb5IG1DfyBPjLITns6yHvD3191gpS9dzoBm8Ttkz LKwgvA4I9Q5x8UxDYJ90RVyjMGxtVyBnSt/DOyHaM+Yg/emad0oY13+cuADz0DQ9qjt3 gOqOt6tdmwJoNEg7w/TGQ7fWcvPHl9I87aRjfw3XFbgkqxgpvH5hCCmXtD5nVHdaGko+ x2bQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+lg5QUonTqYML7nEvv2sRq/KVhbJP2uTOKti8/DWcYM=; b=YSXvE8tegXbWjFcjKv6l3uz6+NpMha/XqKUzMUIngTcIW5b4nISk/+O5dIawp6eDVg L9quUq+7lMZbNj/dvFkfIwcd8bZi8m11xJoFPxu35JjmzFkEj/8t2m+3juQr1E8Ak1Qr SqQbJAAND5W2uoPOX/ueB+hDNpI1xBl7FibHpPDNLHM+wMpszGF7f8+LHYaPTl1qZEOq b1U64fJLu8rTzm+NXMxPMvX0o4tx/hCPz3oREVvadO6OjuGKLpQMEE7WLKkBq0JiZYOc faSLXwJSfcY+4z/xN3xrsPDC1WTJSlVPQyig0iUOsnjsqJiUrX1vF9TlMo5j7ZGEG2Fo wQIg== X-Gm-Message-State: AHQUAuYgECYNDbWNJ9ONbm0yEa3CEZNTM9rzGimWX33Ia7Rw9oEOQRZw hdh2UNNqCQXnwPdYM9xjNQMpGFwoNxU= X-Google-Smtp-Source: AHgI3IYeecnNJQw1sA8EnKbmhFC12/npWLs6CK4tTIf6efj0QzpUG/oNbPIB0WPwvVwOnNUNJfYBnw== X-Received: by 2002:a17:902:930b:: with SMTP id bc11mr6205354plb.101.1551331483735; Wed, 27 Feb 2019 21:24:43 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 27 Feb 2019 21:24:30 -0800 Message-Id: <20190228052432.32571-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190228052432.32571-1-richard.henderson@linaro.org> References: <20190228052432.32571-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::641 Subject: [Qemu-devel] [PATCH v2 6/8] decodetree: Allow grouping of overlapping patterns X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kbastian@mail.uni-paderborn.de, f4bug@amsat.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson --- docs/devel/decodetree.rst | 58 +++++++++++++++ scripts/decodetree.py | 144 +++++++++++++++++++++++++++++++++++--- 2 files changed, 191 insertions(+), 11 deletions(-) diff --git a/docs/devel/decodetree.rst b/docs/devel/decodetree.rst index 62cb7f687c..44ac621ea8 100644 --- a/docs/devel/decodetree.rst +++ b/docs/devel/decodetree.rst @@ -161,3 +161,61 @@ which will, in part, invoke:: and:: =20 trans_addl_i(ctx, &arg_opi, insn) + +Pattern Groups +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Syntax:: + + group :=3D '{' ( pat_def | group )+ '}' + +A *group* begins with a lone open-brace, with all subsequent lines +indented two spaces, and ending with a lone close-brace. Groups +may be nested, increasing the required indentation of the lines +within the nested group to two spaces per nesting level. + +Unlike ungrouped patterns, grouped patterns are allowed to overlap. +Conflicts are resolved by selecting the patterns in order. If all +of the fixedbits for a pattern match, its translate function will +be called. If the translate function returns false, then subsequent +patterns within the group will be matched. + +The following example from PA-RISC shows specialization of the *or* +instruction:: + + { + { + nop 000010 ----- ----- 0000 001001 0 00000 + copy 000010 00000 r1:5 0000 001001 0 rt:5 + } + or 000010 rt2:5 r1:5 cf:4 001001 0 rt:5 + } + +When the *cf* field is zero, the instruction has no side effects, +and may be specialized. When the *rt* field is zero, the output +is discarded and so the instruction has no effect. When the *rt2* +field is zero, the operation is ``reg[rt] | 0`` and so encodes +the canonical register copy operation. + +The output from the generator might look like:: + + switch (insn & 0xfc000fe0) { + case 0x08000240: + /* 000010.. ........ ....0010 010..... */ + if ((insn & 0x0000f000) =3D=3D 0x00000000) { + /* 000010.. ........ 00000010 010..... */ + if ((insn & 0x0000001f) =3D=3D 0x00000000) { + /* 000010.. ........ 00000010 01000000 */ + extract_decode_Fmt_0(&u.f_decode0, insn); + if (trans_nop(ctx, &u.f_decode0)) return true; + } + if ((insn & 0x03e00000) =3D=3D 0x00000000) { + /* 00001000 000..... 00000010 010..... */ + extract_decode_Fmt_1(&u.f_decode1, insn); + if (trans_copy(ctx, &u.f_decode1)) return true; + } + } + extract_decode_Fmt_2(&u.f_decode2, insn); + if (trans_or(ctx, &u.f_decode2)) return true; + return false; + } diff --git a/scripts/decodetree.py b/scripts/decodetree.py index cc5fa1a8ab..4596a9da02 100755 --- a/scripts/decodetree.py +++ b/scripts/decodetree.py @@ -31,6 +31,7 @@ fields =3D {} arguments =3D {} formats =3D {} patterns =3D [] +allpatterns =3D [] =20 translate_prefix =3D 'trans' translate_scope =3D 'static ' @@ -353,6 +354,46 @@ class Pattern(General): # end Pattern =20 =20 +class MultiPattern(General): + """Class representing an overlapping set of instruction patterns""" + + def __init__(self, lineno, pats, fixb, fixm, udfm): + self.lineno =3D lineno + self.pats =3D pats + self.base =3D None + self.fixedbits =3D fixb + self.fixedmask =3D fixm + self.undefmask =3D udfm + + def __str__(self): + r =3D "{" + for p in self.pats: + r =3D r + ' ' + str(p) + return r + "}" + + def output_decl(self): + for p in self.pats: + p.output_decl() + + def output_code(self, i, extracted, outerbits, outermask): + global translate_prefix + ind =3D str_indent(i) + for p in self.pats: + if outermask !=3D p.fixedmask: + innermask =3D p.fixedmask & ~outermask + innerbits =3D p.fixedbits & ~outermask + output(ind, 'if ((insn & ', + '0x{0:08x}) =3D=3D 0x{1:08x}'.format(innermask, inn= erbits), + ') {\n') + output(ind, ' /* ', + str_match_bits(p.fixedbits, p.fixedmask), ' */\n') + p.output_code(i + 4, extracted, p.fixedbits, p.fixedmask) + output(ind, '}\n') + else: + p.output_code(i, extracted, p.fixedbits, p.fixedmask) +#end MultiPattern + + def parse_field(lineno, name, toks): """Parse one instruction field from TOKS at LINENO""" global fields @@ -505,6 +546,7 @@ def parse_generic(lineno, is_format, name, toks): global arguments global formats global patterns + global allpatterns global re_ident global insnwidth global insnmask @@ -649,6 +691,7 @@ def parse_generic(lineno, is_format, name, toks): pat =3D Pattern(name, lineno, fmt, fixedbits, fixedmask, undefmask, fieldmask, flds) patterns.append(pat) + allpatterns.append(pat) =20 # Validate the masks that we have assembled. if fieldmask & fixedmask: @@ -667,17 +710,61 @@ def parse_generic(lineno, is_format, name, toks): .format(allbits ^ insnmask)) # end parse_general =20 +def build_multi_pattern(lineno, pats): + """Validate the Patterns going into a MultiPattern.""" + global patterns + global insnmask + + if len(pats) < 2: + error(lineno, 'less than two patterns within braces') + + fixedmask =3D insnmask + undefmask =3D insnmask + + for p in pats: + fixedmask &=3D p.fixedmask + undefmask &=3D p.undefmask + if p.lineno < lineno: + lineno =3D p.lineno + + if fixedmask =3D=3D 0: + error(lineno, 'no overlap in patterns within braces') + + fixedbits =3D None + for p in pats: + thisbits =3D p.fixedbits & fixedmask + if fixedbits is None: + fixedbits =3D thisbits + elif fixedbits !=3D thisbits: + error(p.lineno, 'fixedbits mismatch within braces', + '(0x{0:08x} !=3D 0x{1:08x})'.format(thisbits, fixedbits)) + + mp =3D MultiPattern(lineno, pats, fixedbits, fixedmask, undefmask) + patterns.append(mp) +# end build_multi_pattern =20 def parse_file(f): """Parse all of the patterns within a file""" =20 + global patterns + # Read all of the lines of the file. Concatenate lines # ending in backslash; discard empty lines and comments. toks =3D [] lineno =3D 0 + nesting =3D 0 + saved_pats =3D [] + for line in f: lineno +=3D 1 =20 + # Expand and strip spaces, to find indent. + line =3D line.rstrip() + line =3D line.expandtabs() + len1 =3D len(line) + line =3D line.lstrip() + len2 =3D len(line) + # Discard comments end =3D line.find('#') if end >=3D 0: @@ -687,10 +774,18 @@ def parse_file(f): if len(toks) !=3D 0: # Next line after continuation toks.extend(t) - elif len(t) =3D=3D 0: - # Empty line - continue else: + # Allow completely blank lines. + if len1 =3D=3D 0: + continue + indent =3D len1 - len2 + # Empty line due to comment. + if len(t) =3D=3D 0: + # Indentation must be correct, even for comment lines. + if indent !=3D nesting: + error(lineno, 'indentation ', indent, ' !=3D ', nestin= g) + continue + start_lineno =3D lineno toks =3D t =20 # Continuation? @@ -698,21 +793,47 @@ def parse_file(f): toks.pop() continue =20 - if len(toks) < 2: - error(lineno, 'short line') - name =3D toks[0] del toks[0] =20 + # End nesting? + if name =3D=3D '}': + if nesting =3D=3D 0: + error(start_lineno, 'mismatched close brace') + if len(toks) !=3D 0: + error(start_lineno, 'extra tokens after close brace') + nesting -=3D 2 + if indent !=3D nesting: + error(start_lineno, 'indentation ', indent, ' !=3D ', nest= ing) + pats =3D patterns + patterns =3D saved_pats.pop() + build_multi_pattern(lineno, pats) + toks =3D [] + continue + + # Everything else should have current indentation. + if indent !=3D nesting: + error(start_lineno, 'indentation ', indent, ' !=3D ', nesting) + + # Start nesting? + if name =3D=3D '{': + if len(toks) !=3D 0: + error(start_lineno, 'extra tokens after open brace') + saved_pats.append(patterns) + patterns =3D [] + nesting +=3D 2 + toks =3D [] + continue + # Determine the type of object needing to be parsed. if name[0] =3D=3D '%': - parse_field(lineno, name[1:], toks) + parse_field(start_lineno, name[1:], toks) elif name[0] =3D=3D '&': - parse_arguments(lineno, name[1:], toks) + parse_arguments(start_lineno, name[1:], toks) elif name[0] =3D=3D '@': - parse_generic(lineno, True, name[1:], toks) + parse_generic(start_lineno, True, name[1:], toks) else: - parse_generic(lineno, False, name, toks) + parse_generic(start_lineno, False, name, toks) toks =3D [] # end parse_file =20 @@ -846,6 +967,7 @@ def main(): global arguments global formats global patterns + global allpatterns global translate_scope global translate_prefix global output_fd @@ -907,7 +1029,7 @@ def main(): # Make sure that the argument sets are the same, and declare the # function only once. out_pats =3D {} - for i in patterns: + for i in allpatterns: if i.name in out_pats: p =3D out_pats[i.name] if i.base.base !=3D p.base.base: --=20 2.17.2 From nobody Sun Nov 9 11:37:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1551331633978125.6718545340417; Wed, 27 Feb 2019 21:27:13 -0800 (PST) Received: from localhost ([127.0.0.1]:60585 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzEDl-0006r7-Rf for importer@patchew.org; Thu, 28 Feb 2019 00:27:01 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59622) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzEBg-0005g1-8H for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:24:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gzEBe-0003mZ-7n for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:24:52 -0500 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:45354) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gzEBc-0003kf-81 for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:24:50 -0500 Received: by mail-pl1-x642.google.com with SMTP id r14so9142862pls.12 for ; Wed, 27 Feb 2019 21:24:46 -0800 (PST) Received: from cloudburst.dc.rr.com (cpe-72-132-251-149.dc.res.rr.com. [72.132.251.149]) by smtp.gmail.com with ESMTPSA id u13sm32758371pfa.169.2019.02.27.21.24.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 27 Feb 2019 21:24:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8ulPBZ7h8lwje33FAm/1yxM4mNmEPfuMt2JEIkVfEzs=; b=eSIR8T7qebdfYMduSHNv62RSpVKAKNaP8oLD/HWXhITjOwQSZ2qoDNXU0agwjmdwGd wZkNuH+QZkOf9XhWMAmeo1FpFqI5cuyGdkpSDhWy1cJnAwSrmH8ZVHv0yuK/G3Q162OP C3y/zLKBzsoJgY56FtO1UX9rCo2QiMXiovfvJ1NqHup68IW265fmEEZWeXNPySkNWKnp /1DgOWXImk57sFlcnUXewvDMajL++jBTCqwilr4+acleXQoRnajebohIYhixrUVS8mUy Sk/x+oY6e3Drfabm63q5e6/YwrOPa6FOrawYB37ioSfE3D0HUYZYIu6U0O+Dqi/oB1ws vbnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8ulPBZ7h8lwje33FAm/1yxM4mNmEPfuMt2JEIkVfEzs=; b=Q59AfXDVsrPDhzYUz+khFpGiUKaWvfcx2qKoTlbMzFYhY9ADrd7OkjgGD/YJL9JIay av4X0O0Uk15DOPtcwtLQWpD8cL6DHLtG0HXaSv9GGUIbt+4QXk790VG4DOlcANQ94q7I FmqQl+0RWI6Ke6PH6xs7XOhVrIp4MH5e5a9I9qvXB2Q2X90EcO0BM/Cj+/aICifj0Ety K6YzRjoCfcpp5Q1zxdtqO7wmSA+zvxWIPWG/VDJ5vrxdhNbQHo2d44rqkrm6xEII6Qpl HKoafZq14sk0z13rE2Tpz+ZEe4/tyB7M7uXkYCwSQ9EnjlWTuEXJkiUvdBOL5AJJaFM6 WmMA== X-Gm-Message-State: AHQUAub8MbG1wJ+3CPexlMWVQhhRw6HthTjomRr0OxZ55sDZYrNiek15 Pcvq5eWBs9TBivAFHPQ8V78hLkIoRmo= X-Google-Smtp-Source: AHgI3IYj5TkpwM8ogAsz4YQF5y68SZUa93t/Asomtk4ZzArT6N1FUk4nhxywkLkLN6C1Adv5n0z9Sg== X-Received: by 2002:a17:902:1aa:: with SMTP id b39mr6107471plb.317.1551331485114; Wed, 27 Feb 2019 21:24:45 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 27 Feb 2019 21:24:31 -0800 Message-Id: <20190228052432.32571-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190228052432.32571-1-richard.henderson@linaro.org> References: <20190228052432.32571-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::642 Subject: [Qemu-devel] [PATCH v2 7/8] test/decode: Add tests for PatternGroups X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kbastian@mail.uni-paderborn.de, f4bug@amsat.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Bastian Koppelmann This adds one test that supposed to succeed to test deep nesting of pattern groups which is rarely exercised by targets using decode tree. The remaining tests exercise various fail conditions. Signed-off-by: Bastian Koppelmann Message-Id: <20190227120217.20794-1-kbastian@mail.uni-paderborn.de> Signed-off-by: Richard Henderson --- tests/decode/check.sh | 6 ++++++ tests/decode/err_pattern_group_empty.decode | 6 ++++++ tests/decode/err_pattern_group_ident1.decode | 10 +++++++++ tests/decode/err_pattern_group_ident2.decode | 11 ++++++++++ tests/decode/err_pattern_group_nest1.decode | 13 ++++++++++++ tests/decode/succ_pattern_group_nest1.decode | 22 ++++++++++++++++++++ 6 files changed, 68 insertions(+) create mode 100644 tests/decode/err_pattern_group_empty.decode create mode 100644 tests/decode/err_pattern_group_ident1.decode create mode 100644 tests/decode/err_pattern_group_ident2.decode create mode 100644 tests/decode/err_pattern_group_nest1.decode create mode 100644 tests/decode/succ_pattern_group_nest1.decode diff --git a/tests/decode/check.sh b/tests/decode/check.sh index 79a06c37cd..95445a0115 100755 --- a/tests/decode/check.sh +++ b/tests/decode/check.sh @@ -15,4 +15,10 @@ for i in err_*.decode; do fi done =20 +for i in succ_*.decode; do + if ! $PYTHON $DECODETREE $i > /dev/null 2> /dev/null; then + echo FAIL:$i 1>&2 + fi +done + exit $E diff --git a/tests/decode/err_pattern_group_empty.decode b/tests/decode/err= _pattern_group_empty.decode new file mode 100644 index 0000000000..abbff6b528 --- /dev/null +++ b/tests/decode/err_pattern_group_empty.decode @@ -0,0 +1,6 @@ +# This work is licensed under the terms of the GNU LGPL, version 2 or late= r. +# See the COPYING.LIB file in the top-level directory. + +# empty groups are not allowed +{ +} diff --git a/tests/decode/err_pattern_group_ident1.decode b/tests/decode/er= r_pattern_group_ident1.decode new file mode 100644 index 0000000000..3e65fab2f9 --- /dev/null +++ b/tests/decode/err_pattern_group_ident1.decode @@ -0,0 +1,10 @@ +# This work is licensed under the terms of the GNU LGPL, version 2 or late= r. +# See the COPYING.LIB file in the top-level directory. + +%sub1 0:8 + +# Make sure that indentation is enforced +{ + top 00000000 00000000 00000000 00000000 + sub1 00000000 00000000 00000000 ........ %sub1 +} diff --git a/tests/decode/err_pattern_group_ident2.decode b/tests/decode/er= r_pattern_group_ident2.decode new file mode 100644 index 0000000000..bc859233b1 --- /dev/null +++ b/tests/decode/err_pattern_group_ident2.decode @@ -0,0 +1,11 @@ +# This work is licensed under the terms of the GNU LGPL, version 2 or late= r. +# See the COPYING.LIB file in the top-level directory. + +%sub1 0:8 + +# Make sure that indentation is enforced +{ + top 00000000 00000000 00000000 00000000 + sub1 00000000 00000000 00000000 ........ %sub1 +# comments are suposed to be indented +} diff --git a/tests/decode/err_pattern_group_nest1.decode b/tests/decode/err= _pattern_group_nest1.decode new file mode 100644 index 0000000000..92e971c3c5 --- /dev/null +++ b/tests/decode/err_pattern_group_nest1.decode @@ -0,0 +1,13 @@ +# This work is licensed under the terms of the GNU LGPL, version 2 or late= r. +# See the COPYING.LIB file in the top-level directory. + +%sub1 0:8 +%sub2 8:8 +%sub3 16:8 +%sub4 24:8 + +# Groups with no overlap are supposed to fail +{ + top 00000000 00000000 00000000 00000000 + sub4 ........ ........ ........ ........ %sub1 %sub2 %sub3 %sub4 +} diff --git a/tests/decode/succ_pattern_group_nest1.decode b/tests/decode/su= cc_pattern_group_nest1.decode new file mode 100644 index 0000000000..77b0f48b49 --- /dev/null +++ b/tests/decode/succ_pattern_group_nest1.decode @@ -0,0 +1,22 @@ +# This work is licensed under the terms of the GNU LGPL, version 2 or late= r. +# See the COPYING.LIB file in the top-level directory. + +%sub1 0:8 +%sub2 8:8 +%sub3 16:8 +%sub4 24:7 + +# Make sure deep netsting works, as few targets will actually exercise it +{ + top 00000000 00000000 00000000 00000000 + { + sub1 00000000 00000000 00000000 ........ %sub1 + { + sub2 00000000 00000000 ........ ........ %sub1 %sub2 + { + sub3 00000000 ........ ........ ........ %sub1 %sub2 %sub3 + sub4 0....... ........ ........ ........ %sub1 %sub2 %sub3 %sub4 + } + } + } +} --=20 2.17.2 From nobody Sun Nov 9 11:37:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1551332018361269.39851681876667; Wed, 27 Feb 2019 21:33:38 -0800 (PST) Received: from localhost ([127.0.0.1]:60666 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzEJz-0002gT-1i for importer@patchew.org; Thu, 28 Feb 2019 00:33:27 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59717) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzEBn-0005lo-Fk for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:25:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gzEBi-0003qF-Bj for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:24:56 -0500 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:38744) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gzEBg-0003n9-9u for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:24:54 -0500 Received: by mail-pl1-x642.google.com with SMTP id g37so6350525plb.5 for ; Wed, 27 Feb 2019 21:24:50 -0800 (PST) Received: from cloudburst.dc.rr.com (cpe-72-132-251-149.dc.res.rr.com. [72.132.251.149]) by smtp.gmail.com with ESMTPSA id u13sm32758371pfa.169.2019.02.27.21.24.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 27 Feb 2019 21:24:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=c6s1o0/tKrgJ5/rgCDTrhJ440px5Ud09QTssoKTEFOo=; b=aWB7gxPxKifsyIpxQjhXW2NOSj1l0HB4JSfgFw9Y1cu1KFL6xNBxGhQ0G88qLEE8Sy GzM1W95cRZImqG7835sNP8HP4BdGRu4Gis326fzuSoHOzwGCEa4nnuZUHzhTbHHxj4/r IGIMfI7uofOQoNgJutDdC1Fj4WKUowHEa5BZT3q3nZ3+YgDqxSLxJIIk7NdigCBwOSTQ v6JL4flv3eBRP8Hf8hnz6LJtJUMxoQZYqaIJc/zb2nA97DH1nFO3S7b0oO7aK6FilHMl m+tNxAPK4jNZvXPKBmExOzM999w2R1f1jFAj7Mnk7gonuJE53nkiwhys33X3FXEbXhMS TnIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=c6s1o0/tKrgJ5/rgCDTrhJ440px5Ud09QTssoKTEFOo=; b=twm1EdF/u6+E7pdSL5pCbvSJ2g3Ej92EPdTeODY8hOCHKOR49NWu5PdBRrjS0nAhz/ aLlUBvgItwSv3WM41EWfvtCRByatwXCTNu9Q9AX9DQgK6G6cnJssPbb1P7eY1Is3FsLY 93K3Bjpg8mZ4HKB13IcFlXLcKu+8HSj1JzVEvTfdz0QFzRgXrUlco7Z6/b4WfIKLa0ge mAFr61MfU3uLSkTS6Y7hXc9dcsdjxO4dOt67hfS+XvBgJwpnxYNAGeJ8IJ+C01b2EiTy 6LxcWyKve9GSOI8j4z/GMYyPBNXcizIQdAKhlTxolIS7nInz9149DnSqCjtTbppRqcaw Lbsg== X-Gm-Message-State: AHQUAuZXX7GaoZZTqktM5GddjtDjHpvuITjaE9/LWfqZ6YckegPlYcSe HdcBYmncji/uhgoGToCnyRdSwtfgPoA= X-Google-Smtp-Source: AHgI3IbSOjglO13YNpggSN3kWn+abrBGefgMB5L4Z4tCiyzg5vZhLbPfVBpcX5NGSk1i29BswTJm8Q== X-Received: by 2002:a17:902:9a95:: with SMTP id w21mr6059802plp.118.1551331486510; Wed, 27 Feb 2019 21:24:46 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 27 Feb 2019 21:24:32 -0800 Message-Id: <20190228052432.32571-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190228052432.32571-1-richard.henderson@linaro.org> References: <20190228052432.32571-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::642 Subject: [Qemu-devel] [PATCH v2 8/8] decodetree: Add --static-decode option X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kbastian@mail.uni-paderborn.de, f4bug@amsat.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Like --decode, but do not drop 'static' qualifier. Signed-off-by: Richard Henderson --- scripts/decodetree.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/decodetree.py b/scripts/decodetree.py index 4596a9da02..68979b73a0 100755 --- a/scripts/decodetree.py +++ b/scripts/decodetree.py @@ -980,7 +980,8 @@ def main(): =20 decode_scope =3D 'static ' =20 - long_opts =3D ['decode=3D', 'translate=3D', 'output=3D', 'insnwidth=3D= '] + long_opts =3D ['decode=3D', 'translate=3D', 'output=3D', 'insnwidth=3D= ', + 'static-decode=3D'] try: (opts, args) =3D getopt.getopt(sys.argv[1:], 'o:w:', long_opts) except getopt.GetoptError as err: @@ -991,6 +992,8 @@ def main(): elif o =3D=3D '--decode': decode_function =3D a decode_scope =3D '' + elif o =3D=3D '--static-decode': + decode_function =3D a elif o =3D=3D '--translate': translate_prefix =3D a translate_scope =3D '' --=20 2.17.2 From nobody Sun Nov 9 11:37:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1551332466343511.7734798257044; Wed, 27 Feb 2019 21:41:06 -0800 (PST) Received: from localhost ([127.0.0.1]:60767 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzERL-0004Tx-Cl for importer@patchew.org; Thu, 28 Feb 2019 00:41:03 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34060) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzEQY-00046y-4R for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:40:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gzEQX-0003rq-EY for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:40:14 -0500 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]:43192) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gzEQX-0003oT-63 for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:40:13 -0500 Received: by mail-pl1-x62a.google.com with SMTP id m10so9157948plt.10 for ; Wed, 27 Feb 2019 21:40:11 -0800 (PST) Received: from cloudburst.dc.rr.com ([2605:e000:100e:478c:cfa2:eb27:db4f:e85]) by smtp.gmail.com with ESMTPSA id k27sm13833477pgb.70.2019.02.27.21.40.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 27 Feb 2019 21:40:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=MdXTm4UWGBbEsgbr9yj2lFEwhlkWHo6z5Hh6lERaMMo=; b=pkeHvQvNC9SdlVpVSj8poG35FSI55qNsLTj+MGBUltx+9l2WVgk3CwMTQMSd9ZCade x0DvVuAz6PE2WZRELl3H8sDdgGqB4y4bP5oKV2kX61voY4vv29X7Opx1pja+e964GbS7 0FrYetdElJy0WSLUWSR0giNi6tsT1HY2nlLIokgDzCkR+KhQJdJQUY0jA5vOoxal8Rx+ ocg1m0qjejkh/afRlRKKOMo7pbBXz/y3FA12Euy9h1pqRNN6cUwDL9Cf+RIoL8ShnyoC uHn6DOe3cz/K9TFwOsuxkOSfTJsCmxuBmheH2WpFdr1l7HDztVUg4JXvJJX3X9KrZu6T DGmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=MdXTm4UWGBbEsgbr9yj2lFEwhlkWHo6z5Hh6lERaMMo=; b=udm6EA3ENRJA3xKa1nckCAwT/2IHBj16UFqR75x8JgIJXabzSntf9ySycnnIZwrpo1 DZLygh1uoLhYVFLbfjeYGCYXPnjAa/EYyqsbUVb0WCU6MfOJ8GL2tSU+YGiO8cp2AJNh cJYDJOZ0uQlWuSAsF5YL2M7OZBKC0isiz8BePD/6PO3dn2cF7ONFIW/qp8EmwJMEYpd3 0FIkHIryLY1FWHGFs9ePlfBxpQUEILo7LxPeTdCFMfLNtCSw9ANwrMqEZdxY72oNuKuX D4NewEmYmgyhvkYPMuw6F7cy4u6br1SYt2t1ux+sv6TqDTseuUP9lSMNoroAMv/4DYSQ h6xQ== X-Gm-Message-State: AHQUAuZmvshRHtyLqlze4rZwuIGQNHcsGF36gG6SKY960WLs2F9phD3Z ns5An0I/2pLQFKxiJl2eRjoeT0jxGu4= X-Google-Smtp-Source: AHgI3IaUZpWaxNWb33yXdfrI7/FPwDUydqHEuooqtfYjkMS2t6glKjSuQ1yn1uhJgID8nuo+AtaBKA== X-Received: by 2002:a17:902:7202:: with SMTP id ba2mr6037258plb.147.1551332409929; Wed, 27 Feb 2019 21:40:09 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 27 Feb 2019 21:40:07 -0800 Message-Id: <20190228054007.779-1-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190228052432.32571-1-richard.henderson@linaro.org> References: <20190228052432.32571-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::62a Subject: [Qemu-devel] [PATCH 9/8] decodetree: Produce clean output for an empty input file X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: f4bug@amsat.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This is interesting for bisection, where an output file is plumbed, but does not yet have patterns. Signed-off-by: Richard Henderson --- One more small fix that should have gone with the v2 patchset. --- scripts/decodetree.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/scripts/decodetree.py b/scripts/decodetree.py index 68979b73a0..1785769eec 100755 --- a/scripts/decodetree.py +++ b/scripts/decodetree.py @@ -1050,15 +1050,16 @@ def main(): '(DisasContext *ctx, ', insntype, ' insn)\n{\n') =20 i4 =3D str_indent(4) - output(i4, 'union {\n') - for n in sorted(arguments.keys()): - f =3D arguments[n] - output(i4, i4, f.struct_name(), ' f_', f.name, ';\n') - output(i4, '} u;\n\n') =20 - t.output_code(4, False, 0, 0) + if len(allpatterns) !=3D 0: + output(i4, 'union {\n') + for n in sorted(arguments.keys()): + f =3D arguments[n] + output(i4, i4, f.struct_name(), ' f_', f.name, ';\n') + output(i4, '} u;\n\n') + t.output_code(4, False, 0, 0) + output(i4, 'return false;\n') - output('}\n') =20 if output_file: --=20 2.17.2