From nobody Sun Apr 28 07:26:38 2024 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 155241385842492.08065337381913; Tue, 12 Mar 2019 11:04:18 -0700 (PDT) Received: from localhost ([127.0.0.1]:56958 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3ll7-0003Gr-7y for importer@patchew.org; Tue, 12 Mar 2019 14:04:13 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51835) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3l3P-0006Hc-2E for qemu-devel@nongnu.org; Tue, 12 Mar 2019 13:19:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h3koV-00016l-2n for qemu-devel@nongnu.org; Tue, 12 Mar 2019 13:03:39 -0400 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]:35641) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h3koU-000163-Qd for qemu-devel@nongnu.org; Tue, 12 Mar 2019 13:03:38 -0400 Received: by mail-pg1-x52d.google.com with SMTP id e17so2304023pgd.2 for ; Tue, 12 Mar 2019 10:03:38 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id v22sm17514265pfa.49.2019.03.12.10.03.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Mar 2019 10:03:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PUT01px/Uz20GRQJaDRT0J+ujmf7Wf0Ye4RQ0OpusT8=; b=pMSHDwB1bNXEq2OQcXRWewymT13Tb1TyuA7CaF/MWQ0z9R8IheAZA+p5M/O1ePmJXm uQRprfzXrt5rDeH1OxZQP9tYErm26l846TGDtAjXbJXoJpGjLcqPDX+fO2wMKOFRB74L 9uuGIVDp5bAKMS8W+KazCXRZXWd6++3YAyj/HMDpDSn2BcCtWJ9ORY0jmfGG6xsV4ZEX w6YyBQfAg+DSPLImk++ehADIuEGATvNGnbVmxMJRZLxm/BwzAgOVV+4mtGkt39ggqA9W biepW4lHCsQm+SLjbKiCusY08wuMj8rl7AS6T+er57R8lV+FbjMwobQQpoLGgapjq6Bl da3A== 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=PUT01px/Uz20GRQJaDRT0J+ujmf7Wf0Ye4RQ0OpusT8=; b=WhxbEdejR7Hg+IWF1J0hBS4ick/N33Q7MUl7uUlsYoh8uvWNAQbG6mfiVQJuPzdTd2 i1BjSeXF2YwWSgAmlqmx/yIjB2sz5UDkotK/Zk61u0CSi3nKrQUjQERiHxX/D68/Wbuy Ety5aZfLDWqpDpnFH6eMV71eoFtQJ/IaOlgQO9sQvol0/YpMDEA+9m2rtlDZstSC6Zds GMaAghSdz0/LA48hoxR6DM2CKiT/ap4SL+s+jfhJntO/P30Xc11Zp71N9wQ4mGAXvjOt RIEQIg4erVY3SddMhZthzuwimIGburPwbCoIbkFEAVjfmd+TUhc3JDeFk7z+Gar1Yd7I R58g== X-Gm-Message-State: APjAAAVpD3+anZTHwy59e3D7p6whg7XvV1fWrFkE4zQqyedIjRFAB2LI P3PDHUvzSiZ5WZJVH/AkcHqKhV01svg= X-Google-Smtp-Source: APXvYqx9XcRvtHhYsb3a8YvUiJdYRBF/Dmb5KF3FmGzR/pwNRf6UXnd/MCBRQ7/Maxr3PsfsEn+8vg== X-Received: by 2002:a65:4bce:: with SMTP id p14mr10984051pgr.68.1552410217444; Tue, 12 Mar 2019 10:03:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 12 Mar 2019 10:03:23 -0700 Message-Id: <20190312170334.14005-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190312170334.14005-1-richard.henderson@linaro.org> References: <20190312170334.14005-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::52d Subject: [Qemu-devel] [PULL 01/12] 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: peter.maydell@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= 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 d326756079..3426d3369d 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 Apr 28 07:26:38 2024 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 1552414212085349.3598169335137; Tue, 12 Mar 2019 11:10:12 -0700 (PDT) Received: from localhost ([127.0.0.1]:57047 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3lqq-0008Du-U5 for importer@patchew.org; Tue, 12 Mar 2019 14:10:08 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51125) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3l3P-0005kf-1Z for qemu-devel@nongnu.org; Tue, 12 Mar 2019 13:19:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h3koW-00018G-MY for qemu-devel@nongnu.org; Tue, 12 Mar 2019 13:03:42 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]:45308) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h3koW-00017b-C8 for qemu-devel@nongnu.org; Tue, 12 Mar 2019 13:03:40 -0400 Received: by mail-pf1-x42c.google.com with SMTP id v21so2247075pfm.12 for ; Tue, 12 Mar 2019 10:03:40 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id v22sm17514265pfa.49.2019.03.12.10.03.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Mar 2019 10:03:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6ZHAJwXfZDm7adevkZ6nWf5hMn2SlST8Sb6jn0aG3mo=; b=cRmdF+L+q8F+BK1dQq1K0SgWZP3V2MguUxNUgKa1JLL3AJC5aUXQm5FScprzrSPENT Eeb+XqiDbi9evMYR2KFn0wxGBewEi02XI8xSx4PUj5tdxNQzYhE2iaydoNdvZ/VqcaZS L+j73c0stuIHEoNiKPtoI3SmlM3lpdzHi3hHSKA8Af4T7O2Mhe7mgO/aETB5d5vKyYQn GTrBd86VT0svRO5R/jaxpp/Vaq5ooucAWbrEfjomR8uPWfNDs8pmyI9d6vQlHo0BiDpj hWZ1PHM/VcSYcnV17pUegIEVlOwbaZa+G5ctPtfh+zdfY8a8BtZCoPJxLKjeMefL4H4S dxww== 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=6ZHAJwXfZDm7adevkZ6nWf5hMn2SlST8Sb6jn0aG3mo=; b=Av75dLlDqMxAn4bNAC3etqi+WzsU6yomMZ5o2m3H0HgUvFLqc0OnVZD8L8gjMXiOR7 KC2cZmlmLf92cIx1JEcEWaDqHjssF8yrRF5Hv5Z7vnpw6U4wDovvOpRIJ9o1Yh+AVw0p x5WVGAaiEmzrOoziyyPKT7J4nALSj7S8mwd3StU9RoGGc1T7uYycbVrFOjBYZ3Vpq5zY for+88a4lL5UvB9zlyzqbtcynjbuoKnGTVGUx5CQLq7/2ZFjw6ZNAWRSH4uJmIMHeShK TXSZK7As/KS8zFC1YeWwfoBkd2WyzANsRXoek6fodZbA1Ulu5fwjFKnuMGjhROc2MLCc NQhA== X-Gm-Message-State: APjAAAWbXyKXcr1x9UEzlK0zZWNy3IyrQ8e0CABXLovX9W8qxo1Y3hOE CMEr5J7DQtOZn21POThkBTKNc7RpuKw= X-Google-Smtp-Source: APXvYqzvdMW1rsX/a6VjLCvvQ1wsEiMQaym4BjOfTNChDfbRJu+Kv9m2rE1hyc2HMT7Hd4bcRN2jSQ== X-Received: by 2002:a63:4e1d:: with SMTP id c29mr36447115pgb.433.1552410218683; Tue, 12 Mar 2019 10:03:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 12 Mar 2019 10:03:24 -0700 Message-Id: <20190312170334.14005-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190312170334.14005-1-richard.henderson@linaro.org> References: <20190312170334.14005-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::42c Subject: [Qemu-devel] [PULL 02/12] 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: peter.maydell@linaro.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. Reviewed-by: Bastian Koppelmann Signed-off-by: Richard Henderson --- MAINTAINERS | 1 + docs/devel/decodetree.rst | 156 ++++++++++++++++++++++++++++++++++++++ docs/devel/index.rst | 2 +- scripts/decodetree.py | 134 +------------------------------- 4 files changed, 159 insertions(+), 134 deletions(-) create mode 100644 docs/devel/decodetree.rst diff --git a/MAINTAINERS b/MAINTAINERS index 3426d3369d..564b8dba6e 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/docs/devel/index.rst b/docs/devel/index.rst index 6b11e49caa..ebbab636ce 100644 --- a/docs/devel/index.rst +++ b/docs/devel/index.rst @@ -19,4 +19,4 @@ Contents: migration stable-process testing - + decodetree 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 Apr 28 07:26:38 2024 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 1552414550467696.9257373781973; Tue, 12 Mar 2019 11:15:50 -0700 (PDT) Received: from localhost ([127.0.0.1]:57181 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3lwE-0005WE-90 for importer@patchew.org; Tue, 12 Mar 2019 14:15:42 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50688) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3l3O-0005OA-Q0 for qemu-devel@nongnu.org; Tue, 12 Mar 2019 13:19:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h3koX-00019J-Tc for qemu-devel@nongnu.org; Tue, 12 Mar 2019 13:03:42 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]:44044) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h3koX-00018d-Kk for qemu-devel@nongnu.org; Tue, 12 Mar 2019 13:03:41 -0400 Received: by mail-pf1-x431.google.com with SMTP id a3so2248936pff.11 for ; Tue, 12 Mar 2019 10:03:41 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id v22sm17514265pfa.49.2019.03.12.10.03.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Mar 2019 10:03:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2rJysuN4kOcM861oITn+8gqeEuwCTb6zNf90hFLC10A=; b=P0/WRJYEhx5kprOn9I19vl7u+Ulwf9EnDATaTZKr6L57d4f5qxYOfPV+I5imE5B3/j viUAQhGzb0BBSEQdM8ukUoAcsSHlDyiCWdxEQiJGPwxAKJD9+7UPIzZAdRCwBRBTdKU/ 1BllBy1a6RLDVSuw/Oy20xW69MDpLpbdRZ/GFuAf0JBrkVAHt8+PUI3gQ73Dp3iLloii BQvd0PsClS1/gufx4xMLp35EcRZ9+7vYkraxK/M6v4x6b7Eh+p65VcpRnWalkgBkC7hS wi9IEhf6dX8v126jq/w9HZGs+S+0V0KlA2cxJg3x9UwUzcpFDJmnR1FLTRw2ExlM2fPZ 4rEQ== 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=2rJysuN4kOcM861oITn+8gqeEuwCTb6zNf90hFLC10A=; b=P499Kjfc2npcWu1hqQ6vjZo/OBRV0msQi2Vj6qTlI2Y1FdC8LVxyCFMb/dCeVntK2I Pl9yeSpPbNikWGLLeiaGc96AM9an+ebTobiXb3x0k2GosMKo6uguwm9g9jAVDayC7Ctp der+dafPwbs4XKzqgStPsS2XK3psBAnIf6jxn1jWCXw8rn3N4ruYYo82p+mcBOWSe/gQ h+yi9YAtNpUDUBe9TTtTWMHmqq6klRcAGU6VEDr6oGq2OdLfdx6Tqd5O8w745OAB/a31 BQwIWT1FwQT7FS/VD1lxxxlLJujhEV8QAYcZA3QuqSDl2y8te6L1YfjqBMqJhgUW82nI Ftng== X-Gm-Message-State: APjAAAUfoubNuzDBWjYrBJCBGiKqJAnsKedyH0/NS1B8+c+2B9EzNH5/ 48pYlO+lQn0u748+ME3EsE9BuEWHEKY= X-Google-Smtp-Source: APXvYqzkZtYH+pIKv8lbBiyn6w4LAkrm07sVx7t5GAa16qc4FQB0lSC7adQN7kLzUiYhNMV9hOm1Xg== X-Received: by 2002:a62:ee0e:: with SMTP id e14mr39749171pfi.201.1552410220161; Tue, 12 Mar 2019 10:03:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 12 Mar 2019 10:03:25 -0700 Message-Id: <20190312170334.14005-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190312170334.14005-1-richard.henderson@linaro.org> References: <20190312170334.14005-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::431 Subject: [Qemu-devel] [PULL 03/12] 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: peter.maydell@linaro.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" Reviewed-by: Bastian Koppelmann Signed-off-by: Richard Henderson --- 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 Apr 28 07:26:38 2024 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 1552414158763614.84408835852; Tue, 12 Mar 2019 11:09:18 -0700 (PDT) Received: from localhost ([127.0.0.1]:57041 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3lpy-0007Om-Kr for importer@patchew.org; Tue, 12 Mar 2019 14:09:14 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51871) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3l3N-0006Iy-9R for qemu-devel@nongnu.org; Tue, 12 Mar 2019 13:19:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h3koa-0001BD-H5 for qemu-devel@nongnu.org; Tue, 12 Mar 2019 13:03:45 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]:42551) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h3koa-0001Ah-9Z for qemu-devel@nongnu.org; Tue, 12 Mar 2019 13:03:44 -0400 Received: by mail-pf1-x42c.google.com with SMTP id n74so2251745pfi.9 for ; Tue, 12 Mar 2019 10:03:44 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id v22sm17514265pfa.49.2019.03.12.10.03.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Mar 2019 10:03:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dJ9V0cdUMTbTLS+jTfS4ibWwVyEFxtj+1fJtRE1MNSo=; b=eKzocNzOnmi0zgTPOFgvCw6fVgbHCnHfkc/dC/f++AyRb7Q7Vx3M1jj1s6Pp2tMiF2 iybNRqafdsIJuU7LLHrEdlpKuD9CcVfMW+Pv/McsmwIRRQn0YiaKEM4rChXa1d/9DD29 nius7+3DfzLwBluNNkFVfX55l5D2Tc9dbMErHYWLyqcetpbvbPTQrbGCJ3iBpTnLcC+s OxIxHpPm4+YfA6qlmBThKqZbJDiRYBCcJ9ZpTWpBeFhUIdyM/qKLqacKl/GoRVabOLwL u+PkKScvgaNjYsbmlW3vFRhLuyXg/ubdH+luPDdvVOTOBik0A/0w9a7ASJijCNQ5UzZO +Qmg== 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=bru9GO8fKvMR7CyOdumemSC2+4xrnsfLvM1bhUhzC93Xs1mdI8mECK/Dk6Ii2nRaQx kLPghm0sYFyS+kAWfuaC6hULckU7pe5moMuse5Pv0kQfw5OjVIow12WPM2CqCRRrwCGC gLyd8cYdRK75c6mrCyAKKjFF4IS1AC20clQgloqRiHhK/rAGULviRrjYs+o0WIQ2842m jytS5rX9np2DiqIJ3LhQ8kR87Wz5IxngzRF6PCGwFZ2F3HI5tykbAzxcFHggMjSg9KHQ aXIRVs2UhIieBOb7okN59vMWzKKMtN563W/TWaV/8C8YXXFsKYi8hkpSAD9Q55uGsKdE GJDg== X-Gm-Message-State: APjAAAUaXHUnjjsJaI4j9QQS0s+HZTEJErPE0EC1HnnL9bk2kgZ1kApR mX+mFNIS+8JPuDSyK32Pe1ar/N7RlkQ= X-Google-Smtp-Source: APXvYqxh1eUAEZt67jEDY5kjNRnK2JO1KGiIQPId0tfweGuHffYccx+Egfyaw6zZYwdwKPO2KdOeyQ== X-Received: by 2002:a17:902:6f08:: with SMTP id w8mr41112739plk.5.1552410221751; Tue, 12 Mar 2019 10:03:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 12 Mar 2019 10:03:26 -0700 Message-Id: <20190312170334.14005-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190312170334.14005-1-richard.henderson@linaro.org> References: <20190312170334.14005-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::42c Subject: [Qemu-devel] [PULL 04/12] 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: peter.maydell@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= 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 Apr 28 07:26:38 2024 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 1552413535316983.1910442037502; Tue, 12 Mar 2019 10:58:55 -0700 (PDT) Received: from localhost ([127.0.0.1]:56852 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3lfw-0007LN-9j for importer@patchew.org; Tue, 12 Mar 2019 13:58:52 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51483) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3l3N-0005yw-8W for qemu-devel@nongnu.org; Tue, 12 Mar 2019 13:19:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h3koa-0001Bc-TQ for qemu-devel@nongnu.org; Tue, 12 Mar 2019 13:03:45 -0400 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]:43412) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h3koa-0001At-Ks for qemu-devel@nongnu.org; Tue, 12 Mar 2019 13:03:44 -0400 Received: by mail-pf1-x42b.google.com with SMTP id q17so2254448pfh.10 for ; Tue, 12 Mar 2019 10:03:44 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id v22sm17514265pfa.49.2019.03.12.10.03.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Mar 2019 10:03:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=q7BmrH4sjrNhoBHqeKigtEhx9qwjct0IB15Jx7wduro=; b=E9O8eM8PfIhA+E3vn/WkAVuQUMzX47SPjmcwVyTqBmKAcopmhUDDpN3qsGuK9Q82+x chegLU1RnV3z+L8V/rW9JDAOvnYH9uIrN1Kms+RTa8HNaIzsjUd1Daj/Eu6Yo0emV6Si IWt9gzqY+M1BWHJTyZxBeDVCtdSrogXh7pnNfyDlteMCSQancEYg+bhR7MEMUI2uRF5z jVue087v9Gv93lbXBbLBqSWC2GwNDprGO+88KhPXInjXZBWCd1ui1kuEN9SFg4Zaqejl xRZSPEF+lyvfCWBhcIPpezKCBhSkX6WZHQvCefIDxT3sNzKcm+dUTB1tsdtO08IOjGw7 76jg== 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=A6d8Hq+0Opum3UqC2NzOmQrO3UvN/OSaXxEIJhhly9cLmOREsV/9ZNRP1IEGofxRFC fWCB3Q/sgxMb0jeTL15QuUBRdPOoqPodBSjfJgwN4bkZFgSUBiyWmGRnmSUtMuFrrUXf 03STbf2zWS6fd7g9YQggcBMBCeUDq16G97PXdCviq+MU3HZUAEjy/eQKSL0AD5H2DeeU jwyG4Lhyeryxj9pM9BK/Rr+VmhBLJOeJDjfa/tg8iY6CCJFYqeq9KykK/85tXGE2mswo Ip6QHN6EZESCDmR/PW36i9PWgKZHvgU9F5gQl3oCaB/bxxAFOPrSmP3ZmqaK4Nq/d317 6VBg== X-Gm-Message-State: APjAAAXJRf1g9Zz0xFesFljUifDWi+Ac4+6WPdfkAMj7HObr5FesoqIC YUj1dMIE3WuL7rHCP6x2OHNpyAQP4bE= X-Google-Smtp-Source: APXvYqzmdSk9ZYSFBwZ4VPcEFkj9rXrIhW4VfSPMaoJxc/Xw/j/FyDdx2AYBbtp1ZS74JJaMmgszEQ== X-Received: by 2002:a17:902:7896:: with SMTP id q22mr2936855pll.66.1552410223228; Tue, 12 Mar 2019 10:03:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 12 Mar 2019 10:03:27 -0700 Message-Id: <20190312170334.14005-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190312170334.14005-1-richard.henderson@linaro.org> References: <20190312170334.14005-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::42b Subject: [Qemu-devel] [PULL 05/12] 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: peter.maydell@linaro.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 Apr 28 07:26:38 2024 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 1552414331285248.22320909172504; Tue, 12 Mar 2019 11:12:11 -0700 (PDT) Received: from localhost ([127.0.0.1]:57097 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3lsm-0001ba-4T for importer@patchew.org; Tue, 12 Mar 2019 14:12:08 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51668) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3l3N-00066w-7h for qemu-devel@nongnu.org; Tue, 12 Mar 2019 13:19:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h3kod-0001D6-1w for qemu-devel@nongnu.org; Tue, 12 Mar 2019 13:03:48 -0400 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]:35644) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h3koc-0001CM-IY for qemu-devel@nongnu.org; Tue, 12 Mar 2019 13:03:46 -0400 Received: by mail-pg1-x530.google.com with SMTP id e17so2304306pgd.2 for ; Tue, 12 Mar 2019 10:03:46 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id v22sm17514265pfa.49.2019.03.12.10.03.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Mar 2019 10:03:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=mQxe/h092OHgR+JCDknw6TQ1AQPxGRDcZ6ug5Wf5Zxc=; b=W/+oQRYM/70RNkzkBzLY5Y8QAElZxMfdnI1tNCjrQx1ii2yVDWEKy0BFBGOmSkt0nu ZsgJivKkgtrl4VFWKiAcVbyiCnBXvTjYckLFwRIJdJqKsvAI0P9dwMy2NCIVZQhiApIw 65DxLDykbwbVWoKKPNP2aeD9Ma5dAtN6Xc07AgU3ADkniGT0TTg/KFWnEFHYxsKoNLLI 6tkTNuyTTNLXoSvncWuMbg1tbMkx/NHzLlgagPwHB87K3otlcj7Hh1WvhT07uBBcN6vY f87jV61dV0fHlKZzh0YDbOApoBFqV54Dre2P5J22Qr7ec/3HajW5IRw6IuoVAlaTNq8K 8IQA== 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=mQxe/h092OHgR+JCDknw6TQ1AQPxGRDcZ6ug5Wf5Zxc=; b=V9JIr1gGn9fREF0b5arBEq5NSRELqKFOhMb3gcG+mQDgbxiHqPAIo9xRdQuzJ0GkTE ZzklnfaXoSDjLCEEpMrnyJpqW5I5qKHfR+g83aXuJJVc0VwBqqvSO1gtka+yU0rYP4em /bH0EQ/A7MRDyVxO4LevW3CFWiS9oGhx78HIBwD6ifkqlHXXiG6ICrahbov8H57+iM7h BtdLa/gnHD0gtbmq0RoP6me6RtpBavWrTYiisnOq6uU6V8UZS1FhQy7rtaG4FtLpaRi1 9CCQn5PeCnqCEa6Ehc82lWdjY1WsYIITjpFo913AT+O3m1EkjDwGqgJwxsR4NNOn2OEl 3UGQ== X-Gm-Message-State: APjAAAW/3pdKWckHcoJeP9hdHcG58Km/Lu1LKVjZjHvLU+Me1latwuzs MqxLL6ln7q+/mq3yhuSbNF7EieSj1G0= X-Google-Smtp-Source: APXvYqyBZuWqklICybXMiHYGANlc9qnGUGnSAuNb6UPk0L2FAVY72JzasbY5waFUmoMUzigvjUjBmw== X-Received: by 2002:a17:902:42:: with SMTP id 60mr35423213pla.132.1552410225063; Tue, 12 Mar 2019 10:03:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 12 Mar 2019 10:03:28 -0700 Message-Id: <20190312170334.14005-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190312170334.14005-1-richard.henderson@linaro.org> References: <20190312170334.14005-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::530 Subject: [Qemu-devel] [PULL 06/12] 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: peter.maydell@linaro.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 | 165 +++++++++++++++--- .../decode/err_pattern_group_overlap1.decode | 6 + 3 files changed, 207 insertions(+), 22 deletions(-) create mode 100644 tests/decode/err_pattern_group_overlap1.decode 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..2711c6ca9e 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 ' @@ -300,13 +301,7 @@ class General: self.fields =3D flds =20 def __str__(self): - r =3D self.name - if self.base: - r =3D r + ' ' + self.base.name - else: - r =3D r + ' ' + str(self.fields) - r =3D r + ' ' + str_match_bits(self.fixedbits, self.fixedmask) - return r + return self.name + ' ' + str_match_bits(self.fixedbits, self.fixed= mask) =20 def str1(self, i): return str_indent(i) + self.__str__() @@ -353,6 +348,47 @@ 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.file =3D input_file + 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 +541,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 +686,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 +705,66 @@ 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 + + # Collect fixed/undefmask for all of the children. + # Move the defining lineno back to that of the first child. + for p in pats: + fixedmask &=3D p.fixedmask + undefmask &=3D p.undefmask + if p.lineno < lineno: + lineno =3D p.lineno + + repeat =3D True + while repeat: + 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: + fixedmask &=3D ~(fixedbits ^ thisbits) + break + else: + repeat =3D False + + 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 @@ -789,11 +910,10 @@ def build_tree(pats, outerbits, outermask): innermask &=3D i.fixedmask =20 if innermask =3D=3D 0: - pnames =3D [] + text =3D 'overlapping patterns:' for p in pats: - pnames.append(p.name + ':' + p.file + ':' + str(p.lineno)) - error_with_file(pats[0].file, pats[0].lineno, - 'overlapping patterns:', pnames) + text +=3D '\n' + p.file + ':' + str(p.lineno) + ': ' + str(p) + error_with_file(pats[0].file, pats[0].lineno, text) =20 fullmask =3D outermask | innermask =20 @@ -846,6 +966,7 @@ def main(): global arguments global formats global patterns + global allpatterns global translate_scope global translate_prefix global output_fd @@ -907,7 +1028,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: diff --git a/tests/decode/err_pattern_group_overlap1.decode b/tests/decode/= err_pattern_group_overlap1.decode new file mode 100644 index 0000000000..ebe3030d26 --- /dev/null +++ b/tests/decode/err_pattern_group_overlap1.decode @@ -0,0 +1,6 @@ +one 00000000000000000000000000000000 +{ + two 0000000000000000000000000000000 s:1 + three 000000000000000000000000000000 s:1 0 +} + --=20 2.17.2 From nobody Sun Apr 28 07:26:38 2024 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 155241366122987.3447725002876; Tue, 12 Mar 2019 11:01:01 -0700 (PDT) Received: from localhost ([127.0.0.1]:56909 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3lhx-0000od-3l for importer@patchew.org; Tue, 12 Mar 2019 14:00:57 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51578) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3l3N-000633-65 for qemu-devel@nongnu.org; Tue, 12 Mar 2019 13:19:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h3koj-0001Hu-PD for qemu-devel@nongnu.org; Tue, 12 Mar 2019 13:03:58 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]:46303) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h3koe-0001DA-RL for qemu-devel@nongnu.org; Tue, 12 Mar 2019 13:03:49 -0400 Received: by mail-pf1-x430.google.com with SMTP id s23so2238446pfe.13 for ; Tue, 12 Mar 2019 10:03:47 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id v22sm17514265pfa.49.2019.03.12.10.03.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Mar 2019 10:03:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8ulPBZ7h8lwje33FAm/1yxM4mNmEPfuMt2JEIkVfEzs=; b=KrGhuouC1wk9YoflPvCezNeHMVj/Spq9J4DrWiBfARwf1tXRDLb/IOYpy/pd/KbICW W6Kdi89Cs0GD8WsjNeaVUtkMk0rCwkTd3k7K3WHKGynPLXAZSp1IsVYLu/SlkejBXWFm lFiIos5bnXbUYqJ1fT/1SbU2Qn3yAP3gkInKGIiC/Pa/yuHsHVol9GZkUzesD5QXDWch SJMWqmeZrShJaeFdGqIM6k1FHmHt/Ojy/0eWSM8G7lQZpGN5q51YZwaQ4VlGkcAiyntW 46rOCqoTQrxm+Nk0iwcehRxzNOgtqt9FIsE6BjVbdpcNwQ4gELd+OyUpeuauM4so/WV8 W7Eg== 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=A85At6WKwK9C975q0rYWOzyTEocq5e3P2Thvwgqh7ScddD/rKQg8RkXmseN/kKxJb0 ZqgeGF6c49AHERBJWRPGvCsyHwhk4hnd7aBFhOvvFuJTatq/FgOhfTE6hXaxHlY7E+qW Snuh5VM5Mn/Bmqe/UmEVrEkPgdtHRQz5qjuAPNVoV9d4cAaC7J0sZwMYT07OJQhoHon5 mFMEPqbp9d1MsBdLoYePPCtCIFHhmgoz+HATkgIviv7u4XdxVPGuNQM/TCzFBvLWsaL8 rtRaQj9s319BfQ/kKRB5AB3qb19j3CJkncSqEzqu7rYf7CC8oYID249eGZV96ys6rXiQ BFpA== X-Gm-Message-State: APjAAAWOlQzq9yXweUt3oT2l2rHI9ULprRXey4M2mN5jmob7lgixk0rB iha/KhSjcxuSv4Kb/4Y0vnUCD14zBDU= X-Google-Smtp-Source: APXvYqxMi7hKI26KTFAJUPUeJIVmokMI1HnolHH2bqd4nzpTaWPsBPXK1vsbUIycDSE9ghzcQWI3PA== X-Received: by 2002:a17:902:6804:: with SMTP id h4mr40752244plk.115.1552410226368; Tue, 12 Mar 2019 10:03:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 12 Mar 2019 10:03:29 -0700 Message-Id: <20190312170334.14005-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190312170334.14005-1-richard.henderson@linaro.org> References: <20190312170334.14005-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::430 Subject: [Qemu-devel] [PULL 07/12] 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: peter.maydell@linaro.org, Bastian Koppelmann 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 Apr 28 07:26:38 2024 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 1552413981229173.88366841565733; Tue, 12 Mar 2019 11:06:21 -0700 (PDT) Received: from localhost ([127.0.0.1]:57014 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3ln8-00051e-53 for importer@patchew.org; Tue, 12 Mar 2019 14:06:18 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50763) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3l3N-0005UY-3p for qemu-devel@nongnu.org; Tue, 12 Mar 2019 13:19:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h3koy-0001Re-KZ for qemu-devel@nongnu.org; Tue, 12 Mar 2019 13:04:09 -0400 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]:43798) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h3kow-0001Dt-ID for qemu-devel@nongnu.org; Tue, 12 Mar 2019 13:04:06 -0400 Received: by mail-pg1-x536.google.com with SMTP id l11so2266985pgq.10 for ; Tue, 12 Mar 2019 10:03:49 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id v22sm17514265pfa.49.2019.03.12.10.03.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Mar 2019 10:03:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vuqDnJauXUOQvzdJ4/CCwB1LBv5EZx2qRDR+YiJgFlc=; b=c6Jo3zANZQMHeEPF1NZ9uI0SvwNy3j3u47ooQMC5bOqpSuVxagYJcKC7MqsOCHeDxY ovD2Lkoi65Z/1hti1Ayrd0ZiLK6esRo9NcgFMMnHr2GNc9CyUOByuivBzDr9GHEpKJjd i8HHa1emgSg2BVS0Vt/8e+mU6VtsLPVNj/6ZkOoqhP+mA/L5rA1bR/VOnQlkEanWpTGf UMrNNFl8VI6rhFC1oco4t/p0HGBDFCAipLMLUonFTH4++BbhO6BW8H97BVcr9tMuQZiH EhIYmzC3rqS+8SCflecmTGM5uAghPb28Xc9UIxniVyKv8oQj9zGivud5oE+h8zOEK0CB kjgA== 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=vuqDnJauXUOQvzdJ4/CCwB1LBv5EZx2qRDR+YiJgFlc=; b=Df0fd6DA4AC3QUaJLPtc/8R+AeBMVR9BETOwkuCSsuupHqaDrzP3xyK8eY0wC/v0w5 VcMAiT3ARnGqXsYQVmtHFeSZZl20OXhi8mYcJAyvSVAm6VYkzDi+HBSj+UsQ+3Q67mBh aBT+ePUfeTKWH5CZ9zUF/2w/2xrRVeEp/rvl0jzzp6ggbPVOX2N2jvtWZUkkTpetSISC U6cx+ZnxMKP3F0IsFBmOiMNyyFCMn2Z10OV8uk4P44CXIoats5kFfjAp4NlQHfGxdDW6 QsUgj0gQ4YqRoD6YJm822lY6FHo9wyaxnig3NJNYPYNc1MDVFN+6VtktaEWuxHEw+LEh 6vbA== X-Gm-Message-State: APjAAAXfNoriPflZZQNHQc0f3zSx707QWLp1wI01VmTqNjOzY/hGZUIM fqIiZ9ZOg/37gG2QVFo4oxLx6D6AOQw= X-Google-Smtp-Source: APXvYqy27EwgYP3L+iiBSEu6eaZSyndrLmIMYO6Fn/qQgWthLlK/90enThl9XVSY9WuDSwUgP7opLA== X-Received: by 2002:aa7:9289:: with SMTP id j9mr39968124pfa.130.1552410227722; Tue, 12 Mar 2019 10:03:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 12 Mar 2019 10:03:30 -0700 Message-Id: <20190312170334.14005-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190312170334.14005-1-richard.henderson@linaro.org> References: <20190312170334.14005-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::536 Subject: [Qemu-devel] [PULL 08/12] 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: peter.maydell@linaro.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 2711c6ca9e..6067e940ab 100755 --- a/scripts/decodetree.py +++ b/scripts/decodetree.py @@ -979,7 +979,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: @@ -990,6 +991,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 Apr 28 07:26:38 2024 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 1552413319950467.15215069381577; Tue, 12 Mar 2019 10:55:19 -0700 (PDT) Received: from localhost ([127.0.0.1]:56781 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3lcM-00041I-OO for importer@patchew.org; Tue, 12 Mar 2019 13:55:10 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51919) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3l3K-0006LV-Lo for qemu-devel@nongnu.org; Tue, 12 Mar 2019 13:19:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h3koy-0001S1-Nq for qemu-devel@nongnu.org; Tue, 12 Mar 2019 13:04:09 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]:46304) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h3kow-0001FK-Ma for qemu-devel@nongnu.org; Tue, 12 Mar 2019 13:04:08 -0400 Received: by mail-pf1-x431.google.com with SMTP id s23so2238520pfe.13 for ; Tue, 12 Mar 2019 10:03:50 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id v22sm17514265pfa.49.2019.03.12.10.03.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Mar 2019 10:03:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=oPNQCKMG+eFcSWSqQcxVkSY17qb8SVF1eeKGaPzpR/U=; b=nsZLFTRDGrnfnZfZYu0KdUmP9/etuvvm6PwTYDdtlWaZ9oVEBeu6oM0Vl4eFZb/E7a FSulfKmOgcmTwz9hovaahyAbEVhE5jOIQYlmiuDHVRgovltJmvWe9GNPpeGlJONa83M2 JqxArSUdSLBbM9gDf0S1j8Vl869+x4xkGTEop3J7w4jkA3/ZRDrlrghese6uSqPcnTDj Ov3phFGSHiRIOvSaV+gslAZJdMlB6eFCRyO3hJsVveml2Wz28heJr5VDPXas6YLZ+aBF WUo57C3fvYETx1/i3R7CIZyHYxcdiSpOCexFwyKkwNF8R9U8oPaR4ZfFus2WYzletiRF M+bg== 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=oPNQCKMG+eFcSWSqQcxVkSY17qb8SVF1eeKGaPzpR/U=; b=FoaquuMG8daWjgfhnCRZN0CQtj/tOU6EYnw1n7qWUPma9cQT0CKoevvbhwUq34P4/l BjGi5Q9dYdFVnNxIhvlCV4TT9kHF7MTUnSqGYH7YqUwprgtXpfWFesaw5qcvdXdseHG2 +UZoprs9p4cD/RxZcMvc+zvZP1oZ5hOwptLm5S9Yrv6I6ASQXq6jHO/c87I5lRKBHBwD hUOd1JOYSh4Oaizbb0ZYb4+rPxTTtttQEBz9h7dvrHgT/w06+WlHVQwxC7TqYRQUQCWK rGg+i/Rh1q3RGmiaoqjij+p9a+dxNuX1mYNdL1cNzs56YJzrY8KaOf3Y5dEzuR2ZgVHN PB1w== X-Gm-Message-State: APjAAAVrofcwPnx/Bki2ZJITcnyGN9mOe7+78eEu46OeI4tTYcM/wYfz vKNmMqlJ2yr9xpMYF5MyYJRLt539H2U= X-Google-Smtp-Source: APXvYqwRu1dHtSk1fb6brbCgBdszUhvCH6iahzJYx7v9aq005JZVfsAk5P4sljm6JEaI8azx1dSPfQ== X-Received: by 2002:a17:902:2ac8:: with SMTP id j66mr41674808plb.335.1552410228893; Tue, 12 Mar 2019 10:03:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 12 Mar 2019 10:03:31 -0700 Message-Id: <20190312170334.14005-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190312170334.14005-1-richard.henderson@linaro.org> References: <20190312170334.14005-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::431 Subject: [Qemu-devel] [PULL 09/12] 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: peter.maydell@linaro.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 --- scripts/decodetree.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/scripts/decodetree.py b/scripts/decodetree.py index 6067e940ab..6e7ba278be 100755 --- a/scripts/decodetree.py +++ b/scripts/decodetree.py @@ -1049,15 +1049,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 From nobody Sun Apr 28 07:26:38 2024 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 155241280864442.2637027593596; Tue, 12 Mar 2019 10:46:48 -0700 (PDT) Received: from localhost ([127.0.0.1]:56674 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3lUA-0005Mb-G9 for importer@patchew.org; Tue, 12 Mar 2019 13:46:42 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51578) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3l3K-000633-Ph for qemu-devel@nongnu.org; Tue, 12 Mar 2019 13:18:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h3koy-0001Rk-Lf for qemu-devel@nongnu.org; Tue, 12 Mar 2019 13:04:09 -0400 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]:43789) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h3kow-0001GP-LA for qemu-devel@nongnu.org; Tue, 12 Mar 2019 13:04:06 -0400 Received: by mail-pg1-x52c.google.com with SMTP id l11so2267095pgq.10 for ; Tue, 12 Mar 2019 10:03:51 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id v22sm17514265pfa.49.2019.03.12.10.03.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Mar 2019 10:03:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=juWEfS7NZ8OWLNIMee0mKuVA5Db/G1PLvQaDN8eMxSI=; b=JVwXhhXbMQK59lA5k50B2oIvhlkrTp0fNOSbHMsKRQ6df9gpmqydRRHr4VDd4LR+cY oKQUbayT6jPjvKQ5uJuTsrQBoFYKIEJ6QrIBXkE0EHOxGNv4+xDxrPjdwdn1Jn7BpXh9 KvaHE3zImN1xTYtyfFgNjSQjYF3yBhDgYBIDJ38MQr2N7ES4STWXgmjXV4+JEB0i8jW8 iR6uhbcVU8IJVIM78F74SR5BsQCYd60nIdDYhj+PSr0EVBMxByHUsfXie76+EET6hcCI FB0g2E7kug1L/f5AOYqhKmkNfE6MSFg/2eSg2nwwlx9XydThQmeEjAu18B+XpanYP+yG GSIA== 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=juWEfS7NZ8OWLNIMee0mKuVA5Db/G1PLvQaDN8eMxSI=; b=cSyreJ96/sYeprUNKUj0pHsDZzGgwbwRRaCahu4L3xpylgw8DJm/uEyZ2RF26tuW6M dkLZzzTH708kO3emWbkeuKfTTmyZmuGe4Oyc+zbXiv8qByZsHP+1xsQH0BIf2a4AA2X1 cdkr40d8E9vY28Dx67sBy1HD067kvHvxUAWPHP9CPZTRT007hufWo5UmhdFO+ch4QkCF bhe6pzHIdpuF9L9ZqjfsvYcF9fIDLhb6dtC9afyiF+QElVq53OuVns650KjNC4H6UJ+I rTWjl48s2B03kGJVd/H8gciAvObPtDHwMBWlb4lii9WlJNHjktmbx1oRJyfz+9PtVhFq ioZA== X-Gm-Message-State: APjAAAVO5B427YhiDuFc/oWwdzGbBfl0WqOK4I11O6sHyiNzj29uzT8I QM9K+Y/8bllplplq44GCsZgvdYhl29U= X-Google-Smtp-Source: APXvYqx98tlCPjMdY3y/lWMHQ4iOKhWlNXmjLtgxhsbh3EcFeVDmF5ImIAZj7U+v61C/h14MaC4NyA== X-Received: by 2002:a63:4f61:: with SMTP id p33mr36093394pgl.303.1552410230169; Tue, 12 Mar 2019 10:03:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 12 Mar 2019 10:03:32 -0700 Message-Id: <20190312170334.14005-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190312170334.14005-1-richard.henderson@linaro.org> References: <20190312170334.14005-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::52c Subject: [Qemu-devel] [PULL 10/12] decodetree: Allow +- to begin a number initializing a field 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: peter.maydell@linaro.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 --- scripts/decodetree.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/decodetree.py b/scripts/decodetree.py index 6e7ba278be..f6f58e2fec 100755 --- a/scripts/decodetree.py +++ b/scripts/decodetree.py @@ -589,7 +589,7 @@ def parse_generic(lineno, is_format, name, toks): continue =20 # 'Foo=3Dnumber' sets an argument field to a constant value - if re_fullmatch(re_ident + '=3D[0-9]+', t): + if re_fullmatch(re_ident + '=3D[+-]?[0-9]+', t): (fname, value) =3D t.split('=3D') value =3D int(value) flds =3D add_field(lineno, flds, fname, ConstField(value)) --=20 2.17.2 From nobody Sun Apr 28 07:26:38 2024 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 1552413141476696.4907294243288; Tue, 12 Mar 2019 10:52:21 -0700 (PDT) Received: from localhost ([127.0.0.1]:56755 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3lZX-0001b5-Ep for importer@patchew.org; Tue, 12 Mar 2019 13:52:15 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50688) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3l3K-0005OA-DI for qemu-devel@nongnu.org; Tue, 12 Mar 2019 13:18:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h3koy-0001SI-Tg for qemu-devel@nongnu.org; Tue, 12 Mar 2019 13:04:09 -0400 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]:41050) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h3koy-0001HA-KP for qemu-devel@nongnu.org; Tue, 12 Mar 2019 13:04:08 -0400 Received: by mail-pf1-x429.google.com with SMTP id d25so2256518pfn.8 for ; Tue, 12 Mar 2019 10:03:52 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id v22sm17514265pfa.49.2019.03.12.10.03.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Mar 2019 10:03:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=mqxLPtkQySU2IDq6kuvPZ0RBBVrxjaoE5KbcgZVTzHQ=; b=RFOFpVv+IurhlYc3YAyocf4XTf3YCAo6P38WO8VE/D8K6JZtWm5Zwnrl3y2GujoB3Z L9Twqsf4JbgAR72rHJJkz/ehuKtnPpacYz6HRK47vvE3X4W6GB2dHOXsi5LTZqaVX+3J N0S74T1PmMwDPglB7KHBySJ8oUeanP1z4s9fQ3UqSed6GSe0sm1eCojFTDcbMpsfp9BR Ah28eWpxre1QYeIT7rsue0bYyARfd/5xoggo0t1yoD0rZz7MLcbV/Y4nFKA0kORZEYYc 5wzT6nl0lcTG/pVL6Y0YBthIVW0A3s8PoVFI367liKUJNZ/apJ+ioM5ryUrP/RXpMT44 bHIw== 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=mqxLPtkQySU2IDq6kuvPZ0RBBVrxjaoE5KbcgZVTzHQ=; b=E7a05xIju50xJDjXIIT3ADeaBuNxFdKZewp1KdjF0GqhKTMT92zexOnMdLTv/VWhbU fuX2nLIjduwb07OKjiNfiDse1SYgbvlgmm0eWPfG+Ro7u3ZR8Cea5PFN+azNcFLNptOY +lZ9hjyVtciSJnuExllw5fXGq5kQC9rTiADDGHqz6OmTDUyg7J0Ntn4R/ev9hcq1WujN iOyPWNywbV37uXdWg3tleMHcxNhjWyxZkFejMDHwPpc4DPJzQ2RN7hlhPt8pkMhaWLMO a+nVB7IwP80VPDakqXZHMwicCOOWNNgaM1iSTupwgfxWdySNaITLCGBA5LFbRqPZfOy+ ss3Q== X-Gm-Message-State: APjAAAVsBghwpK8sWMHRd8MFMO4e5jnDQ9V7yV5bJKQ21z2+gmNU869j YpttI90yq9tDshtKYriMKglzlptt/XY= X-Google-Smtp-Source: APXvYqyGZ14d+c2QJ6S7n78op4hYym5+taOPURrzvRwUAqouIDgvYMGI4xIie1fKunkSCkf8D3nBQw== X-Received: by 2002:a62:4553:: with SMTP id s80mr39164183pfa.141.1552410231556; Tue, 12 Mar 2019 10:03:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 12 Mar 2019 10:03:33 -0700 Message-Id: <20190312170334.14005-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190312170334.14005-1-richard.henderson@linaro.org> References: <20190312170334.14005-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::429 Subject: [Qemu-devel] [PULL 11/12] decodetree: Prefix extract function names with decode_function 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: peter.maydell@linaro.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 makes it easier to name Formats within multiple decode files. Signed-off-by: Richard Henderson --- scripts/decodetree.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/decodetree.py b/scripts/decodetree.py index f6f58e2fec..ac158b42d0 100755 --- a/scripts/decodetree.py +++ b/scripts/decodetree.py @@ -312,7 +312,8 @@ class Format(General): """Class representing an instruction format""" =20 def extract_name(self): - return 'extract_' + self.name + global decode_function + return decode_function + '_extract_' + self.name =20 def output_extract(self): output('static void ', self.extract_name(), '(', --=20 2.17.2 From nobody Sun Apr 28 07:26:38 2024 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 1552413488994559.0967579602633; Tue, 12 Mar 2019 10:58:08 -0700 (PDT) Received: from localhost ([127.0.0.1]:56844 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3lfB-0006eR-Uc for importer@patchew.org; Tue, 12 Mar 2019 13:58:06 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51529) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3l3N-00061D-4t for qemu-devel@nongnu.org; Tue, 12 Mar 2019 13:19:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h3kow-0001QP-IK for qemu-devel@nongnu.org; Tue, 12 Mar 2019 13:04:08 -0400 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]:38143) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h3kou-0001Hy-Dc for qemu-devel@nongnu.org; Tue, 12 Mar 2019 13:04:06 -0400 Received: by mail-pf1-x436.google.com with SMTP id n125so2268756pfn.5 for ; Tue, 12 Mar 2019 10:03:54 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id v22sm17514265pfa.49.2019.03.12.10.03.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Mar 2019 10:03:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=U8jWfxjTB06zNjuAV7mfMguhymjQ42j8YO1WeS5mESc=; b=xsH7aTH1ypem/GskMg+ekwHrPBadXraRVOJIwXzTC7EFMqjRd5z8+kqZeNnyd4zi2m wpUblVuSEh5+eSHUwqbyUqJNXpBhmbwQnJ1ZFZ7GRSHfUTMivMnKXB71VvxkKjuCHP4X kPv6WpdOhvj8Ca+1G5C7+TPuiarcaLsg1ewzN4GAJzUFRHZQOQAeSBjs1dWhf70C7Yf/ w1Z/ZXc4OS6pBP7FiRfAjZXYh3V3saQQLtCL64ql+fUJBtyTcSzoXXUBxp21txm9oTYq AGFQ40vEU5+jGn9t3Snwo+/7imA/eFHeCUQoSyALughRULvBH/QqwVkmzoUZUKFVL3AG yeNA== 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=U8jWfxjTB06zNjuAV7mfMguhymjQ42j8YO1WeS5mESc=; b=czq9/jwCIZM28I6HqcXoFlMBYgIlPAUWaPm5Tymj/zkL+CD9T4Fzc2/MVs+IL805RR +yS7n+vAqB4p7tdLerMXcN0L/cDwZoDW9Nv2RNu8jkQsyDF/YtJXhfevtix/5Na1a7Yj Bnm0wnsiKTlS4d42PaEP/XqR30ovcd9eT6UV89J68Mfha7MYEiIcxEJ5AJWDx2cetMzZ EC5FenroBZV74k2dCP9HY+Y757rxEt9AJH2fHC2CqqMYgVqQTJNnm2QSrumtKg7p7Wr/ fltAnwqSUEN0u1wfDTK18U+Aqk3eU2XpwlGNIFoLdioRmBuovJjPsz13mfVdJXbGQDFw nzUw== X-Gm-Message-State: APjAAAXrVTKuz+2q7TbMbW4z+XgDEflzdGUiLVyYrH82roVQ0IBwL5pu gageCAZlB6AKOQqcAovLaQ7RS/KXfRA= X-Google-Smtp-Source: APXvYqzF6xE7dgfe6xkpEHmJuRqMyYaGzqjeTKfNq0xlBVKBwHtZbUBinMmAXFDTwlkuZ4BmM3T64A== X-Received: by 2002:aa7:8a59:: with SMTP id n25mr4908227pfa.251.1552410232995; Tue, 12 Mar 2019 10:03:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 12 Mar 2019 10:03:34 -0700 Message-Id: <20190312170334.14005-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190312170334.14005-1-richard.henderson@linaro.org> References: <20190312170334.14005-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::436 Subject: [Qemu-devel] [PULL 12/12] decodetree: Properly diagnose fields overflowing an insn 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: peter.maydell@linaro.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" Previously this would result in an exception for shifting the field mask by a negative number. Signed-off-by: Richard Henderson --- scripts/decodetree.py | 2 ++ tests/decode/err_width1.decode | 5 +++++ tests/decode/err_width2.decode | 5 +++++ tests/decode/err_width3.decode | 5 +++++ tests/decode/err_width4.decode | 5 +++++ 5 files changed, 22 insertions(+) create mode 100644 tests/decode/err_width1.decode create mode 100644 tests/decode/err_width2.decode create mode 100644 tests/decode/err_width3.decode create mode 100644 tests/decode/err_width4.decode diff --git a/scripts/decodetree.py b/scripts/decodetree.py index ac158b42d0..aa790b596a 100755 --- a/scripts/decodetree.py +++ b/scripts/decodetree.py @@ -622,6 +622,8 @@ def parse_generic(lineno, is_format, name, toks): sign =3D True flen =3D flen[1:] shift =3D int(flen, 10) + if shift + width > insnwidth: + error(lineno, 'field {0} exceeds insnwidth'.format(fname)) f =3D Field(sign, insnwidth - width - shift, shift) flds =3D add_field(lineno, flds, fname, f) fixedbits <<=3D shift diff --git a/tests/decode/err_width1.decode b/tests/decode/err_width1.decode new file mode 100644 index 0000000000..0c14f6d73b --- /dev/null +++ b/tests/decode/err_width1.decode @@ -0,0 +1,5 @@ +# 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. + +# Diagnose too many bits (33 of 32) +one 000000000000000000000000000000000 diff --git a/tests/decode/err_width2.decode b/tests/decode/err_width2.decode new file mode 100644 index 0000000000..47f0acf322 --- /dev/null +++ b/tests/decode/err_width2.decode @@ -0,0 +1,5 @@ +# 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. + +# Diagnose too few bits (31 of 32) +one 0000000000000000000000000000000 diff --git a/tests/decode/err_width3.decode b/tests/decode/err_width3.decode new file mode 100644 index 0000000000..c5fb6b3699 --- /dev/null +++ b/tests/decode/err_width3.decode @@ -0,0 +1,5 @@ +# 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. + +# Diagnose too many bits (33 of 32) +one 0 s:32 diff --git a/tests/decode/err_width4.decode b/tests/decode/err_width4.decode new file mode 100644 index 0000000000..1588a63698 --- /dev/null +++ b/tests/decode/err_width4.decode @@ -0,0 +1,5 @@ +# 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. + +# Diagnose too few bits (31 of 32) +one 0 s:30 --=20 2.17.2