From patchwork Thu Mar 7 18:56:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 159917 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp7809114jad; Thu, 7 Mar 2019 11:23:25 -0800 (PST) X-Google-Smtp-Source: APXvYqwF3BTuYOK7VQczGVWpqQdtshlwDZpZmB6XD8kNj4WRYaHXnfWDDVNwMrqIgCFxu+7f0v0z X-Received: by 2002:a81:24c9:: with SMTP id k192mr11047608ywk.19.1551986605608; Thu, 07 Mar 2019 11:23:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551986605; cv=none; d=google.com; s=arc-20160816; b=T/ou8PFMxp7BjP4HpVh7NwmfJL6lP8POUymvUbTwgFDYEpRNBRMuDfpixRAH3N9q2p pkee6onmDsDagdjg+F51R1D1XoKXkD5Ro5saCYpvVQ5ZRTqfbHy0hkaILs4dVNpug8AS 2qGxjWKiYlOfcIePBv6/zBs8auUBxxO2Ir0IjtKAuVAAnvC//jLRqmZFsCIoMkdP2/v3 MNpauQ09pZlos8PDxs6t3WlOXDMj5s9H1M/j6MGQJinJopihVVJWwFL6H5XXGxUF3c6x j4aVcRgIU6Ja2ZNpo06XARYJ3+3+7f9GIJdrInhi8lD5+fafwVscxHDHQbfnB/l5l7kw wVMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=kCTue3ZIN+Hg8JaIGo5lEDuOvEyVLF8voxwauJJWXLA=; b=ivo2ObZCBK+Dp9bOp4gz7fEfXyDm945GMgKhg6RIOyJvHqnSd0YY/ZRe4V+n976xue zdc9V8Uu/wP10SH3sl6r1jUNtdnxc4yXyT+z8hxjggmzUzVyDu+JmyjOfqVfbVzxao1e IzkgXGIP/4dl3uhnSVn0He0WnyalH9wlwsXCOen186Tak1ceLFLh5F91AGEISF6RyUER aUDA+0mbCe6RLPh2HFX6H+sPpfNnzwiZ+tBNcycEnomv4ikgyncHS4O0rPokxAmgXlzM QhGHZonEuuEw8mSiDYKHHhxLWEn/1vYD09K1QMo+hYglOVUbmuyUMFV/1bubYq/+l4R/ nRQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="BWGD1uZ/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id i125si3150015ybb.452.2019.03.07.11.23.25 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Mar 2019 11:23:25 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="BWGD1uZ/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:58007 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1yc1-00073s-4x for patch@linaro.org; Thu, 07 Mar 2019 14:23:25 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36500) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1yBw-0001AQ-RW for qemu-devel@nongnu.org; Thu, 07 Mar 2019 13:56:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h1yBv-0002Kq-VW for qemu-devel@nongnu.org; Thu, 07 Mar 2019 13:56:28 -0500 Received: from mail-pg1-x531.google.com ([2607:f8b0:4864:20::531]:40326) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h1yBv-0002Jn-K4 for qemu-devel@nongnu.org; Thu, 07 Mar 2019 13:56:27 -0500 Received: by mail-pg1-x531.google.com with SMTP id u9so11972105pgo.7 for ; Thu, 07 Mar 2019 10:56:27 -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=kCTue3ZIN+Hg8JaIGo5lEDuOvEyVLF8voxwauJJWXLA=; b=BWGD1uZ/FFY4SrsEJ/Dbh1scvYru1eLSceNv3nOFOjyfVTbg7xRqth5/vF4t7132ZG B9dhSRE1l4AM06eVCu4YlJzdcyKY9Nf1jN86CPeon8OkjUCQsKteSueCgW4j1djsI6PG gN+yiDZ+pkj0DyaCWXsx8WQk5eEI2YvqyUTmQJ1D24zx9C43kODUVDxgzMOMpNXGMZiX AlQhorWPNdf6P7zJcBXz/ywqe+wX7Rpem/7QFcEXPae0Z+eBkkPpXLe2Jjhn5V1/BcbI wqD2cBuu9Z22iDYWPkPJeCT4kBkuLbeAV/kih6vuuZaaEnchQyZipwhJK/AOO59Q7Lc5 wG0w== 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=kCTue3ZIN+Hg8JaIGo5lEDuOvEyVLF8voxwauJJWXLA=; b=aU2teEl3oEtxeea4LyeHzlFzO4vtrh9oultgfxi1xHflAY/3FxZJIkCOnXcC05GFxb iSk0fmlPaTpIBSM/IcEor6f/qQnlX9BRNt2bQsvvEYTFUlSH5aAksNtTHvsdVlV3BP+p 7I/rjN+SkfAl4z6WgKjhI2KyhRGrPbN0QrYe3T3dpZ2GHVCCuw+Vt7ff+jZie44QOkQZ WEfHDrCbq68YnG92Mi+IgU0soHGA+f7Uy0eDhRP3sNIHlnH0G8xDlzcIBmxoCN455sK+ o9vasOWsIZqaZt4GvATXv0RQw3MW9ZSfeyB66v1fSPZonqqIClG/BFIav7e4Cc5GUN5s 8m/A== X-Gm-Message-State: APjAAAWm1KjdQKZG/K7dCVDA34vsnjy6KTLCUGWzLt9GuKMMBbh7aFui 45NBeYdzO3D1XEhEUg7KH57FK0hz7Eg= X-Received: by 2002:a62:4817:: with SMTP id v23mr14016471pfa.81.1551984985785; Thu, 07 Mar 2019 10:56:25 -0800 (PST) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id g12sm8801973pgr.76.2019.03.07.10.56.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Mar 2019 10:56:24 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 7 Mar 2019 10:56:11 -0800 Message-Id: <20190307185622.29026-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190307185622.29026-1-richard.henderson@linaro.org> References: <20190307185622.29026-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::531 Subject: [Qemu-devel] [PATCH v3 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: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20181110211313.6922-2-f4bug@amsat.org> Signed-off-by: Richard Henderson --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) -- 2.17.2 diff --git a/MAINTAINERS b/MAINTAINERS index 074ad46d47..af1df70be1 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 From patchwork Thu Mar 7 18:56:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 159919 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp7812104jad; Thu, 7 Mar 2019 11:26:55 -0800 (PST) X-Google-Smtp-Source: APXvYqwOutpOtVPkLulxpoCJOsmbfn01zU1oP6tN7uZgjv/mkvbPUAS4VJWt2YEFhdM16xOV3UKK X-Received: by 2002:a25:2c58:: with SMTP id s85mr13407096ybs.4.1551986815530; Thu, 07 Mar 2019 11:26:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551986815; cv=none; d=google.com; s=arc-20160816; b=b/u0nXrAUQTZppcHTYXUzmSGzNtHYSAQUF/cm75hUxEPA7WJsf/Klb/PfYEdv1V1j9 c82SrxkjKvgygigJSibMKGe8DBsqNTVzHOD7Jg3a3TpzeWB1z1xAlgcd7892pDOFKPfv QBqn2cqfoU0RV4RFKx6LmqMSLeZtUZR28wboSNGavS4YajEo24KVhGeWi6gakdQv7fxM N4Fge/Zi0EiGV0BMYV8wXgxSbgdFEaprnMoEGk2hVyDolUL4Jv4UvYeSa4BtJJD3cCWx D8iRSDu9UZMFFkYWKgtK0UKoPUp5ZPQwtcqyqqC3xZ3iTn3FptTkWrRS3lSkqxnOiAJi HD7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=RtOaFatfBg7bCw1Qa6jeylA0+YO8VNlxQZzt+PR1e9A=; b=nmq2aFHofjJ5kR1L0bmWhO1b/xI5o7dLF1Y+k6bR8z+3q6pUTwDMge8JczMVuCrilC rl/NLeICYAzr3RUy90WTec465lh4Z6LZH+1KwQoLd7OcZD1n543c8ONGxllk2QYlJZHf H1gA/XdlUAOGNS4+m41AuFJDoADLzvqIcG/ykrGKrySJ9wF0Zfzx6XkgSS8xYkmu+eka e/FthZD5svfwzvLbaonHUsRtrQCMXAw0zW0ZO+Xa/CJSwkc7sVZ6vjUL6ljockoJJFjy j5ereTperhKGI5W6GqpMP8Fhx/ShkJU81qT7VsExOhBjTC+KlHzE/QQ7Vwt9KIASMISp PrCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=SDjD5jAm; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id g6si3548166ywc.383.2019.03.07.11.26.55 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Mar 2019 11:26:55 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=SDjD5jAm; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:58115 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1yfO-0001h6-UG for patch@linaro.org; Thu, 07 Mar 2019 14:26:55 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36611) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1yBz-0001Ck-3O for qemu-devel@nongnu.org; Thu, 07 Mar 2019 13:56:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h1yBx-0002Mi-6g for qemu-devel@nongnu.org; Thu, 07 Mar 2019 13:56:31 -0500 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:41566) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h1yBw-0002LG-Sz for qemu-devel@nongnu.org; Thu, 07 Mar 2019 13:56:29 -0500 Received: by mail-pg1-x542.google.com with SMTP id k11so10994184pgb.8 for ; Thu, 07 Mar 2019 10:56:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=RtOaFatfBg7bCw1Qa6jeylA0+YO8VNlxQZzt+PR1e9A=; b=SDjD5jAmvLIVeTvGJTlyRJDM/uBRrhZB6Bhf35mHsKRyNQHESdnhfi1zqeOsB6rukU bCINjt6doAk6froQWaFlj5gtIUKoIxGt6mBXflf5DxlgzWgdkF4nZRg6WnHiu5tZoS+2 B2UkoPm081EzGU22fJ5ip/+KghEcDR0Hf7bY3sk0FToEbmJU+E0gEL9MyEiYgeNECZvQ 9R7+3UnhfkhP3ozbRxQX/Gt08hnjY50xKrEBhpGmvqmrdj1ovXLFDOb48kOPxC8yw0Vq icv30LeQzwZLRmCW/ZrPEW6Spi4Bh9skGAfTYft9ir0/CjFwdDwqo+3i6C84cyiBe49g p/5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=RtOaFatfBg7bCw1Qa6jeylA0+YO8VNlxQZzt+PR1e9A=; b=HA4zd3ncx63Wl8O6ymXr3pdzRtkg8zKozoREiuWFENwnAsF8+58Z3GayY87BlldJER 8aBCRyNy45UV2kGNrbhtPbM/KFAt1CTiFr0yEL/nNrm0kPSO04I2BCYTpoMCu78SQBYC W1qs81GhDVirOSOY/kaxUG5nlnz7z441q3RQOqjpRbuThFv7QL73e89QSeaPE0eRcxF7 m5jNvRpnrDul/7gKZCubYVT4rYUq/cPG0imc8sO5UudP4cmMOHGsWyvr/+BYSoN0Dnwr SkJhzCu90ne95v7ZhFUm938pwrPisPkSmYuaTtMtKrHkHfjQWtOGVR61XkGlGnfflCYp 6ABA== X-Gm-Message-State: APjAAAV6mv21j/FGABabpYYKDcqz/qcGhjPuAJzU4MPbaoOXrM+Tp8kz sb6NrsIuxrWLx6b1iQMiOm6AecD1qOk= X-Received: by 2002:a65:5a81:: with SMTP id c1mr12576952pgt.217.1551984987132; Thu, 07 Mar 2019 10:56:27 -0800 (PST) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id g12sm8801973pgr.76.2019.03.07.10.56.25 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Mar 2019 10:56:26 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 7 Mar 2019 10:56:12 -0800 Message-Id: <20190307185622.29026-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190307185622.29026-1-richard.henderson@linaro.org> References: <20190307185622.29026-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::542 Subject: [Qemu-devel] [PATCH v3 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 -- 2.17.2 diff --git a/MAINTAINERS b/MAINTAINERS index af1df70be1..820024a808 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 @@ +======================== +Decodetree Specification +======================== + +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) == 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 +====== + +Syntax:: + + field_def := '%' identifier ( unnamed_field )+ ( !function=identifier )? + unnamed_field := 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`` are +present, they are concatenated. In this way one can define disjoint fields. + +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: + ++---------------------------+---------------------------------------------+ +| Input | Generated code | ++===========================+=============================================+ +| %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=expand_shimm8 | extract(i, 13, 1)) | ++---------------------------+---------------------------------------------+ + +Argument Sets +============= + +Syntax:: + + args_def := '&' identifier ( args_elt )+ ( !extern )? + args_elt := 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 +======= + +Syntax:: + + fmt_def := '@' identifier ( fmt_elt )+ + fmt_elt := fixedbit_elt | field_elt | field_ref | args_ref + fixedbit_elt := [01.-]+ + field_elt := identifier ':' 's'? number + field_ref := '%' identifier | identifier '=' '%' identifier + args_ref := '&' 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 +======== + +Syntax:: + + pat_def := identifier ( pat_elt )+ + pat_elt := fixedbit_elt | field_elt | field_ref | args_ref | fmt_ref | const_elt + fmt_ref := '@' identifier + const_elt := identifier '=' 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 cd0fa6c9ba..6b9a6ba71c 100644 --- a/docs/devel/index.rst +++ b/docs/devel/index.rst @@ -18,4 +18,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 @@ # # 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) == 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 := '%' identifier ( unnamed_field )+ ( !function=identifier )? -# unnamed_field := 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 are -# present, they are concatenated. In this way one can define disjoint fields. -# -# 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=expand_shimm8 -# -- expand_shimm8(sextract(i, 5, 8) << 1 -# | extract(i, 13, 1)) -# -# *** Argument set syntax: -# -# args_def := '&' identifier ( args_elt )+ ( !extern )? -# args_elt := 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 := '@' identifier ( fmt_elt )+ -# fmt_elt := fixedbit_elt | field_elt | field_ref | args_ref -# fixedbit_elt := [01.-]+ -# field_elt := identifier ':' 's'? number -# field_ref := '%' identifier | identifier '=' '%' identifier -# args_ref := '&' 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 := identifier ( pat_elt )+ -# pat_elt := fixedbit_elt | field_elt | field_ref -# | args_ref | fmt_ref | const_elt -# fmt_ref := '@' identifier -# const_elt := identifier '=' 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. # import os From patchwork Thu Mar 7 18:56:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 159914 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp7802147jad; Thu, 7 Mar 2019 11:15:52 -0800 (PST) X-Google-Smtp-Source: APXvYqwFFKfBTjI1T0t7wVoU4sJnpY2EmBgJXT4cmiSboqDH08LeTAaA9t5/OjJNkDkJQkg99pD3 X-Received: by 2002:a81:62c4:: with SMTP id w187mr11324814ywb.106.1551986152305; Thu, 07 Mar 2019 11:15:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551986152; cv=none; d=google.com; s=arc-20160816; b=uy4A3vi/GJDMRSpjxqyoaHq1wH5ojqBYjR/Tb0vi4ePe7vVTG3o9eGS4NbOSVXjQ2d p/RZ5jy6Pm+tmxe76t0nxCqRue5i2o0CBGYOGr5wv0NP1HQFCnzv3Slfss8PDsPS12rP 0mhCTdtSHOb1J2clhKV/9qLWsHq1LUct+M/iWX/1PlUCj9XDaOxjH9sizs67+pJhmb7A 2A4H+4xQsBmIaV3OLHUjmBajsmwcAi06E4kfo5+t+OqILwhKCRC2EiLk2W1nS3yjgnpM DwBVfILROKBP/KbLyN2uehwcfjioPb0jFFyp8zUgji05CrYQt0ye16mBOmu2zDMdOND1 p0cQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=2rJysuN4kOcM861oITn+8gqeEuwCTb6zNf90hFLC10A=; b=qxazvDaqGxS2p1/QL4KlcFsYBlHTEWMQG0cwRClEastrFO8GTdSv7k3I39Oq9eSIt3 UOEauVPmp5Az3ffWU4z/fxwwghTZSEvcJLqFAytguaXI7n0/NKo+Owh5bvtNOEMMqmOm pq8HKAAGOBoPYmnQOskEVOffv46RrnMXkT4T/EDuAkcOUByEpFBzoR40XsQ7A9B3O1dm 9nGGAVAWS0d5nNEggLx7EliMnnWjM76N2RPktITigYSTpngMG88jYokguSJi9XXvN4E+ TN3DlvRx33lArapgjlAqljOTnRFCfvPmOS2/I/xvPHyKVWmvyeAeuNHrhVj56K4VFmKK V9kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=CF8ZRVOl; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id k77si3218870ybk.468.2019.03.07.11.15.52 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Mar 2019 11:15:52 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=CF8ZRVOl; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:57852 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1yUh-0000Un-PB for patch@linaro.org; Thu, 07 Mar 2019 14:15:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36590) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1yBy-0001CJ-KF for qemu-devel@nongnu.org; Thu, 07 Mar 2019 13:56:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h1yBx-0002NT-PG for qemu-devel@nongnu.org; Thu, 07 Mar 2019 13:56:30 -0500 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:33948) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h1yBx-0002MJ-HH for qemu-devel@nongnu.org; Thu, 07 Mar 2019 13:56:29 -0500 Received: by mail-pg1-x541.google.com with SMTP id i130so11979805pgd.1 for ; Thu, 07 Mar 2019 10:56:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=2rJysuN4kOcM861oITn+8gqeEuwCTb6zNf90hFLC10A=; b=CF8ZRVOlzQE7okwBZAEuw7VvlxKJJCdZWq+1vJGWseZnFIlyfXmDccsWLu3HRZTZBr rqL1U3lNt8QOlwpLM/YRxfrCMzJi8a2LeLCjnW9/w7tCScmkM9uZdqCIi8dv6VbEBlKR nVOgEICyK3AyGEYiqp2O/+sWoEswY/yUUs+C7YgDkGNaIEh6mt/Ax/V/+RoKG8+r8qlp SohIc7bfWCtVBpE7QcjCDs99LnxA5nKH347fyzP7bingBA/KTZK/QU33vy0KXlb2q0eW ORFlphJWU0zRniEVN8t33us80Kh+K6Mesv5DU13J+5hrhNNiOXnhwyQVOMp6jinySMzi +ugA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=2rJysuN4kOcM861oITn+8gqeEuwCTb6zNf90hFLC10A=; b=TUNAbH7eS6qT3dEUjPJBybb8JUlmvyNiZzcq8vQ881dvZk2Z8FUzo1SqooJxYDDB7h YefPhH0NUI7m0WfkP4+s/3MwHopg70DhZAs0CLpoWOeW9AujYJKL/flGzH52qh0caPKX Gn2YSvBggC1ymj6oyPvL8Xb7LOAHNtOmD+MKj8xqbS4Y00iafZH8u3LVNRXZnTnzei42 RIOYI+cvCOhFnETgkRTziwVaj7xJyYNo6+0FGJeLEr6aW4Lm5fyvTX6uNI6cU+VXupHX Cp4+MekKvXtRFqgT5S1K8C5HDv71LY9JBrA/OYKOg1i37CCj/FHtO7WgGIBF88pVPlBZ neOA== X-Gm-Message-State: APjAAAXSi/kwsqpciHumXhdHBO8pQfBdHanXed2xeG4BMsEvIyaCJYnU 7X18lX8LV71wNWkPklQtluWAzG3krCQ= X-Received: by 2002:a62:2008:: with SMTP id g8mr14005842pfg.121.1551984988152; Thu, 07 Mar 2019 10:56:28 -0800 (PST) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id g12sm8801973pgr.76.2019.03.07.10.56.27 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Mar 2019 10:56:27 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 7 Mar 2019 10:56:13 -0800 Message-Id: <20190307185622.29026-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190307185622.29026-1-richard.henderson@linaro.org> References: <20190307185622.29026-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::541 Subject: [Qemu-devel] [PATCH v3 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: Bastian Koppelmann Signed-off-by: Richard Henderson --- docs/devel/decodetree.rst | 7 +++++++ 1 file changed, 7 insertions(+) -- 2.17.2 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 arguments. If ``!extern`` is specified, the backing structure is assumed to have been already declared, typically via a second decoder. +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:: ®3 ra rb rc From patchwork Thu Mar 7 18:56:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 159915 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp7802614jad; Thu, 7 Mar 2019 11:16:19 -0800 (PST) X-Google-Smtp-Source: APXvYqwz1+jms9hVrJLef1d+V08UClAcPKdBzM5QTUBsld2uzdN/M2VEpX4WymL4I691RRfeWCPe X-Received: by 2002:a0d:df50:: with SMTP id i77mr11559782ywe.392.1551986179001; Thu, 07 Mar 2019 11:16:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551986178; cv=none; d=google.com; s=arc-20160816; b=LMITLR//Lq8QVeoAaPUC928V4PmDh63OjzoyrxkJQo6jj7wEn2kosE4w8REt54GS8Y sUYb5UMm3qrE1gPN55rQNgj6vsFNyKVasUio8OEFeWhSYS6qaFi8/jpVWnyBfEHrbYFF UsAzzYNAygU1jg4nKPoVBvjoZ6KelNsfNzvaVz99M8pK/F/fWdCOZVS8y3W8e1lH97XO ddnNh1bk7Zu82pC3WHiBgwzs5z9j9/BiU1Zs0m9lR6XcwTZQrSuosiOzbX5smOSje3og wctSV0/f1HUBMBmhe6X15c4telTm7a6OR83IWLdsvf7c9zCEOXnOMGGJnLUY6gczzIf1 pUKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=dJ9V0cdUMTbTLS+jTfS4ibWwVyEFxtj+1fJtRE1MNSo=; b=DPyLAB5iqaafEdlcywfLwEjOWB/MzvFKkxmS2ELZVs4r+3fQggqtTTwrY4sk4rxpww oi7cmTJL1YbXEbqatNQJA+SQ/g1IozF6z1hXyXhann1ZYiDiB/E8HGhm3VQ2pkOt1TOq zYcqva91xPajf/aer0xtfT/Y7hZd4VenSTnwJrs7U0xBj7KGbF5XkI1OFu05orSxK+A4 15+HnqsqscDGphMJmFaqAdmpVAdTmtsS5TNDMn+XJOKeS2BSLbj16wy0vwWK4xC48FwA ehT8qAvJaOcrQLoBjWr732lK8rTqdRg5YgSq8wPIFXnjlNPWMaDzXlVi9NFwfLvr4mVa 5pfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="gCOW/RZc"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id b83si3189039ywb.306.2019.03.07.11.16.18 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Mar 2019 11:16:18 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="gCOW/RZc"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:57903 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1yV8-0001tH-E1 for patch@linaro.org; Thu, 07 Mar 2019 14:16:18 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36623) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1yBz-0001Da-MM for qemu-devel@nongnu.org; Thu, 07 Mar 2019 13:56:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h1yBy-0002Oi-TO for qemu-devel@nongnu.org; Thu, 07 Mar 2019 13:56:31 -0500 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]:37203) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h1yBy-0002No-Lx for qemu-devel@nongnu.org; Thu, 07 Mar 2019 13:56:30 -0500 Received: by mail-pf1-x431.google.com with SMTP id s22so12132580pfh.4 for ; Thu, 07 Mar 2019 10:56:30 -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=gCOW/RZcPaY22U0C74yvhAWAnCX/GtoJOui/RlgicvqQ3bzqEbvHhQttnatlMfmsf7 VLZvnYip0o090beN+vaDY3lgcEJ7fNSdmZ2NdhplzAIOtlXee1eMNKrbs31bWxUIqR1t xANy5NZd02ZKb2to14EoM0jbX0AWuyrY0qCPGDa6rpEjyY2RZLcN8O1kMB65gwB2HRUz 75qt64pprTy8PbSIpLwuyvupRNbbe1NPxF9VVd6zGja9ozi4w5CTM8d13OvhPl0NS9AR Op4852Nmffr+TsP0Cr2xQ2uH06YkJbM3P/pEZXm1fOUt0MQysXHHXsrCz2Tinrq32I0F 5U1g== 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=mOwRBokQUJdccmLg6M0tqKteSp9mJE/bkHYBsR8SaKNSuf3QJKXHrWglmRz5vFT/iN bFFXg8ahjozmyirXI57nS+yv9GImaFgtwO/EtVxUYN1k+WcpOlmxwrYTyB3+mNQ6Qb5V n9zSX/jxaTiiAt9ZAW4LDFGxijYIoTM8oQgtlYJ7dnzOrCei/aTNEwXWD8O8CJsacVXX PhLkp9vAfV4WymoxXhnSWsYIdNyPFgAS1FwAbcp6E5YnAi7LiqBqwkaQ174Hug5RiB/L Vb9I88HTUr/aGJb3kfwcOcxfcsQSXB1fVY7tEYUxxyIg5Q2rnrqHakr5iAsX5dINJts9 6mcA== X-Gm-Message-State: APjAAAWkDh/GC5W9boJo8PfzvVkqT+9KEgjJrtr4eLVZ3jyogy5m9l8K e3meE/94r0ZPiU1DKIewJFWC2G0a9Us= X-Received: by 2002:a17:902:2947:: with SMTP id g65mr14290573plb.258.1551984989230; Thu, 07 Mar 2019 10:56:29 -0800 (PST) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id g12sm8801973pgr.76.2019.03.07.10.56.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Mar 2019 10:56:28 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 7 Mar 2019 10:56:14 -0800 Message-Id: <20190307185622.29026-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190307185622.29026-1-richard.henderson@linaro.org> References: <20190307185622.29026-1-richard.henderson@linaro.org> MIME-Version: 1.0 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 v3 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: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé Reproduced with "scripts/decodetree.py /dev/null". Reviewed-by: Bastian Koppelmann Reviewed-by: Eduardo Habkost Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- scripts/decodetree.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.17.2 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: def build_tree(pats, outerbits, outermask): # Find the intersection of all remaining fixedmask. - innermask = ~outermask + innermask = ~outermask & insnmask for i in pats: innermask &= i.fixedmask From patchwork Thu Mar 7 18:56:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 159922 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp7813946jad; Thu, 7 Mar 2019 11:29:01 -0800 (PST) X-Google-Smtp-Source: APXvYqwu+uReN+AfXn83SE8vZQaWt7+wFi0WgHXG7v1HfJkt760iegvEBzaf2f7WaAZC3OMNXWtp X-Received: by 2002:a25:c3c6:: with SMTP id t189mr13196150ybf.471.1551986941915; Thu, 07 Mar 2019 11:29:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551986941; cv=none; d=google.com; s=arc-20160816; b=rpdKUsd2dsJGtqZ62Hp62/esZMHP6mw1hhj41PYdI1stit2koUEh97ObN7kauqnRik qvjrhks+kUyCm4TXn80vHC0F5SQ2zLGbH5Tq5rIzZOb288HeFanTkiR/dNKrgjn03yNM u8Jni9yU9HhNYWkoM5ACGv0spyYq7VJQZ4mmVYJER9bz34w6j7Kp4LLya7qth+YDpVbo N0uqUCS7/mR7XTkWfNqjd6uC5dNOV+2u6YbF09sTZ9PKAzI40MUJcMRAONgwgNnoI05K 2la0qguorkbdnY3PSIsG31yf617fUezTzGamtpkSPZIhRv/zzggH0fbdzsbzQVI8ENzq XbjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=q7BmrH4sjrNhoBHqeKigtEhx9qwjct0IB15Jx7wduro=; b=laOArhl6aZ5WGyq7zuQAWzojVDA3WH/aXpG23VltEJlqYrJEwMXcq1YAQvD60PDmMM 3lbQG3xxXvCxUEGanF+9UlAkXnK8Z0d1VoM+33IrPVc0WvXkwLM11xHyAyFro+MXYNuR UVor5MYZXtCaxNY8Ks+ebScqVcEegsoQJrnxHPOfVhDrfADF06AuKa3G/ldoBoC7kEU1 izIwto5Zcl9psoBFtUJ93BpkGUCLegEoBEmGQXBNyzzlHPt/vei06B/1aY2Yk7sEYUHI 0sDkiA51K7El3aGVtSslXRYamfLNmvqC46KXH0bnUAdP93Z4FyQBzkCdRCKh7xTdjsAN 82MA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=tP6lcPio; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id z184si3131985yba.175.2019.03.07.11.29.01 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Mar 2019 11:29:01 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=tP6lcPio; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:58145 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1yhR-0003v2-Fq for patch@linaro.org; Thu, 07 Mar 2019 14:29:01 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36681) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1yC0-0001F3-UW for qemu-devel@nongnu.org; Thu, 07 Mar 2019 13:56:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h1yC0-0002Pn-2R for qemu-devel@nongnu.org; Thu, 07 Mar 2019 13:56:32 -0500 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]:45863) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h1yBz-0002P3-RE for qemu-devel@nongnu.org; Thu, 07 Mar 2019 13:56:32 -0500 Received: by mail-pg1-x52c.google.com with SMTP id 125so11734010pgc.12 for ; Thu, 07 Mar 2019 10:56:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=q7BmrH4sjrNhoBHqeKigtEhx9qwjct0IB15Jx7wduro=; b=tP6lcPioXmPej7M8Be2wsHD715dt20oxt1SN7MhVVuQqW8IRDE7CEL8tQhEPUgUg1I yaxJSk++TYLVe/VwbGQNuICg9cMO4rELUsQVVOEM7fYUkO9szYLLbNQP2kzwxrNswkRB pvz8NtSqYfwMfJTd1p+QL54A3CAqDbNN+DLCwVLOUiygU0ijXevCZvK09wbUCgdovTUY iJZzURFQPRbd7y4QUlX8HNR1jAboMeR6sUiC7/u7dM9fPU283fyPBkZYG8kF2UNmvq1n zBGPelQQd2p5jFypqBJGXotIlksDUzrYq11H/MS35rIXIGrUJKvUtdfD2Mlc5mAsNKOo gfdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=q7BmrH4sjrNhoBHqeKigtEhx9qwjct0IB15Jx7wduro=; b=ozO2f8TLSb9kFygnloBGFg++07k6RezfmnJeR33oq7/6wkoHhE8FKt0kzNZLLlEs+Z R+ZyRHeLfEu11ORjQ5XoLDUCkLrVovJsua1LmfRHlGJdBN8rWUMlJ6R2A5cslxr4KbB/ qZMYVWA/XgKajtZsrroyHjChB5Q+fN6Z61hpWyqajUXTDWIjXJz4AKvbceTvLoNkuPuL LoC54I+gOpFF/STbySPusGpB47CKa9W/BMlnNeE6hVILj+fCZfK99fkf3EJDuIGZrBfV wcXjVG6q2+zHn7uERyZwgstbecVz4uc+MR8A/IBKXUXrWrNOOMaP5MwMmZY7HDhOv+n7 eORA== X-Gm-Message-State: APjAAAV3rLQBvnGKdacgGBFxpR2MJJgmt8GeZP4KTE0iwjLtH2kxMWMk dp7nRudjIdvxFUbFyP1FPipg8Gv4Jwk= X-Received: by 2002:a17:902:4181:: with SMTP id f1mr14515380pld.280.1551984990532; Thu, 07 Mar 2019 10:56:30 -0800 (PST) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id g12sm8801973pgr.76.2019.03.07.10.56.29 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Mar 2019 10:56:29 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 7 Mar 2019 10:56:15 -0800 Message-Id: <20190307185622.29026-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190307185622.29026-1-richard.henderson@linaro.org> References: <20190307185622.29026-1-richard.henderson@linaro.org> MIME-Version: 1.0 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] [PATCH v3 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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é Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Bastian Koppelmann Signed-off-by: Richard Henderson --- scripts/decodetree.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) -- 2.17.2 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, ' = ', 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 @@ -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 @@ -932,6 +932,7 @@ def main(): output(i4, '} u;\n\n') t.output_code(4, False, 0, 0) + output(i4, 'return false;\n') output('}\n') From patchwork Thu Mar 7 18:56:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 159924 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp7817904jad; Thu, 7 Mar 2019 11:32:54 -0800 (PST) X-Google-Smtp-Source: APXvYqyPHbUdDc7TFY2Y7jbzMXuTsXJpOvc58anFgElJ0fQRz2jbyE34NmTw8iuOtK9Av81o/C07 X-Received: by 2002:a81:3c0c:: with SMTP id j12mr11230589ywa.112.1551987174143; Thu, 07 Mar 2019 11:32:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551987174; cv=none; d=google.com; s=arc-20160816; b=Jz2wyEj4qEnnT9Vn7mUk+CgD9nmOsq6wzAVtS9HHYd3MY2flwxSqPNq0FKJ4AY/zxi SIi+j1WxVocBZSZ6gg5YapVOGLrf68hC8njFs4SnSXI5HRCWIOscbaHQnx+rqjPZFTAQ BErCLCCtPJQk6DTEbo8IQ7TyVk1wchPfRFtFG+RfzG3XsMjEW5lAvBysNZDHCdOjBiPr Xt0bOgnR3We4NLrL6DE49KgUtR/1rgJOXjUtBJfG0aae9yzUlRRspbOy+ncd7NZonWjp UxFsJ07FgLWu9/FiWY6VEGK6EACCs2bRyzGt7xOda6z4xAcZGAdpplAFgbK1RGZRYuni IA/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=hgojEYmIDD7XJb+s9BI/CLRGrGGpvClWsB8GPd1kTkY=; b=eADA51raTA6Y/dplNTnzg8J5epQeIn/txyelaPxuHejGhyBJKc2AaanhXujSPeQwdy rQZ1g1R9UKlBCaXNMealpMtfTMs6f7XoX9zLUpZsjxiHa9/yx8mUYHKP9nsUfOW0OG3b a5xF/6nQykt98KWawsD3FCZ7LVWscWa+D6Fxi2h+avD3Cq+gVEn6W2qWpwh7AgnVJ/R+ zlbPsEre3sFq2eK54I8Xutvh0CIfOjS0k3Htq/UQwjvI6Z6RJR+Y2Wh9nmXDFkJOY7X6 56uYckv5XrBWIQr7bQepGQBsLnm6Rnk621s71O1oD/VbCBfMPtFKnhypX3lYCD7BWcmW 9QgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=TyeJ3mhj; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id l137si3178653ywc.61.2019.03.07.11.32.53 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Mar 2019 11:32:54 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=TyeJ3mhj; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:58218 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1ylB-0006nT-KC for patch@linaro.org; Thu, 07 Mar 2019 14:32:53 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36717) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1yC3-0001Jd-EG for qemu-devel@nongnu.org; Thu, 07 Mar 2019 13:56:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h1yC1-0002RX-Jm for qemu-devel@nongnu.org; Thu, 07 Mar 2019 13:56:35 -0500 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]:46591) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h1yC1-0002QW-9E for qemu-devel@nongnu.org; Thu, 07 Mar 2019 13:56:33 -0500 Received: by mail-pg1-x536.google.com with SMTP id 196so11977817pgf.13 for ; Thu, 07 Mar 2019 10:56:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=hgojEYmIDD7XJb+s9BI/CLRGrGGpvClWsB8GPd1kTkY=; b=TyeJ3mhj6wgklc1vZ/uGwG9chlBDb2SkTSIwwpUzOKjMN9x/ZTcKZw9upIMHzWv1uj T70azdJsC0pHaGLMwEFTs/N7mB8XJ7ymC14TTphg+ZC3MmOStENQY5JcCgzhINzvLhoO Khk/r3y7IRNIfYdmShHBfGGSexkXBf2w/+FndPnKk8LCci9oD8V3VP2OKefV0/d/f/6A IOI2WfIBVw7N3qt6nj5qg+WEVw8QmrAXwdd98IMgO1W/E0xNAwVRmMPvOjQ7KTN92giP cvjhucpR7dBx2lEjbM08hTqjif/s4pC+SuTL74LmVO+FDlVBj4lZ343O+kucch0yDGll bu8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=hgojEYmIDD7XJb+s9BI/CLRGrGGpvClWsB8GPd1kTkY=; b=MOYrvTRFbw4sQ9Ak7BBwLcQJe42j8PriDbvbLtGEDlvpndOXXvbJRFBOGRZD8y5XsQ kwReKO6oJhbi/xH5P80h6k++7UXTXLBgy8rRiulvkFpb21X6vMEiYUuZgofDZ3OWQvoL R/zTSVaJAFbEUsB8610N5zs90TFaq8A0k2F5c/3DbinViNVTGMuYJOW5AgDikzIRHEQR /DYBBKMe3QJ8YJQImI+jIazfhYL+5jazvSugwApSlGIeAT9y50wHZ7/stsbXQ9AdB41c Z15dLzfvIS4CszQQ1inOXu2lkUMNTeqOO+ZfHU7nnFSlGVh6OtYUlyO1LaJ0hrbOujNM yphA== X-Gm-Message-State: APjAAAWnK7IZ3fTqUmG7MlxDN2XfjIwgiGc9Mo3Slklp27gTpRGjped/ GSN10hT8Kgdc+bljhNGLfHvUsvnRlIw= X-Received: by 2002:a17:902:b115:: with SMTP id q21mr13884645plr.272.1551984991733; Thu, 07 Mar 2019 10:56:31 -0800 (PST) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id g12sm8801973pgr.76.2019.03.07.10.56.30 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Mar 2019 10:56:31 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 7 Mar 2019 10:56:16 -0800 Message-Id: <20190307185622.29026-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190307185622.29026-1-richard.henderson@linaro.org> References: <20190307185622.29026-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] [PATCH v3 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- docs/devel/decodetree.rst | 58 +++++++ scripts/decodetree.py | 162 +++++++++++++++--- .../decode/err_pattern_group_overlap1.decode | 6 + 3 files changed, 204 insertions(+), 22 deletions(-) create mode 100644 tests/decode/err_pattern_group_overlap1.decode -- 2.17.2 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:: trans_addl_i(ctx, &arg_opi, insn) + +Pattern Groups +============== + +Syntax:: + + group := '{' ( 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) == 0x00000000) { + /* 000010.. ........ 00000010 010..... */ + if ((insn & 0x0000001f) == 0x00000000) { + /* 000010.. ........ 00000010 01000000 */ + extract_decode_Fmt_0(&u.f_decode0, insn); + if (trans_nop(ctx, &u.f_decode0)) return true; + } + if ((insn & 0x03e00000) == 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..c4e8cb52f7 100755 --- a/scripts/decodetree.py +++ b/scripts/decodetree.py @@ -31,6 +31,7 @@ fields = {} arguments = {} formats = {} patterns = [] +allpatterns = [] translate_prefix = 'trans' translate_scope = 'static ' @@ -300,13 +301,7 @@ class General: self.fields = flds def __str__(self): - r = self.name - if self.base: - r = r + ' ' + self.base.name - else: - r = r + ' ' + str(self.fields) - r = r + ' ' + str_match_bits(self.fixedbits, self.fixedmask) - return r + return self.name + ' ' + str_match_bits(self.fixedbits, self.fixedmask) def str1(self, i): return str_indent(i) + self.__str__() @@ -353,6 +348,47 @@ class Pattern(General): # end Pattern +class MultiPattern(General): + """Class representing an overlapping set of instruction patterns""" + + def __init__(self, lineno, pats, fixb, fixm, udfm): + self.file = input_file + self.lineno = lineno + self.pats = pats + self.base = None + self.fixedbits = fixb + self.fixedmask = fixm + self.undefmask = udfm + + def __str__(self): + r = "{" + for p in self.pats: + r = 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 = str_indent(i) + for p in self.pats: + if outermask != p.fixedmask: + innermask = p.fixedmask & ~outermask + innerbits = p.fixedbits & ~outermask + output(ind, 'if ((insn & ', + '0x{0:08x}) == 0x{1:08x}'.format(innermask, innerbits), + ') {\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 = Pattern(name, lineno, fmt, fixedbits, fixedmask, undefmask, fieldmask, flds) patterns.append(pat) + allpatterns.append(pat) # Validate the masks that we have assembled. if fieldmask & fixedmask: @@ -667,17 +705,63 @@ def parse_generic(lineno, is_format, name, toks): .format(allbits ^ insnmask)) # end parse_general +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 = insnmask + undefmask = 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 &= p.fixedmask + undefmask &= p.undefmask + if p.lineno < lineno: + lineno = p.lineno + + if fixedmask == 0: + error(lineno, 'no overlap in patterns within braces') + + fixedbits = None + for p in pats: + thisbits = p.fixedbits & fixedmask + if fixedbits is None: + fixedbits = thisbits + elif fixedbits != thisbits: + error(p.lineno, 'fixedbits mismatch within braces', + '(0x{0:08x} != 0x{1:08x})'.format(thisbits, fixedbits)) + + mp = MultiPattern(lineno, pats, fixedbits, fixedmask, undefmask) + patterns.append(mp) +# end build_multi_pattern def parse_file(f): """Parse all of the patterns within a file""" + global patterns + # Read all of the lines of the file. Concatenate lines # ending in backslash; discard empty lines and comments. toks = [] lineno = 0 + nesting = 0 + saved_pats = [] + for line in f: lineno += 1 + # Expand and strip spaces, to find indent. + line = line.rstrip() + line = line.expandtabs() + len1 = len(line) + line = line.lstrip() + len2 = len(line) + # Discard comments end = line.find('#') if end >= 0: @@ -687,10 +771,18 @@ def parse_file(f): if len(toks) != 0: # Next line after continuation toks.extend(t) - elif len(t) == 0: - # Empty line - continue else: + # Allow completely blank lines. + if len1 == 0: + continue + indent = len1 - len2 + # Empty line due to comment. + if len(t) == 0: + # Indentation must be correct, even for comment lines. + if indent != nesting: + error(lineno, 'indentation ', indent, ' != ', nesting) + continue + start_lineno = lineno toks = t # Continuation? @@ -698,21 +790,47 @@ def parse_file(f): toks.pop() continue - if len(toks) < 2: - error(lineno, 'short line') - name = toks[0] del toks[0] + # End nesting? + if name == '}': + if nesting == 0: + error(start_lineno, 'mismatched close brace') + if len(toks) != 0: + error(start_lineno, 'extra tokens after close brace') + nesting -= 2 + if indent != nesting: + error(start_lineno, 'indentation ', indent, ' != ', nesting) + pats = patterns + patterns = saved_pats.pop() + build_multi_pattern(lineno, pats) + toks = [] + continue + + # Everything else should have current indentation. + if indent != nesting: + error(start_lineno, 'indentation ', indent, ' != ', nesting) + + # Start nesting? + if name == '{': + if len(toks) != 0: + error(start_lineno, 'extra tokens after open brace') + saved_pats.append(patterns) + patterns = [] + nesting += 2 + toks = [] + continue + # Determine the type of object needing to be parsed. if name[0] == '%': - parse_field(lineno, name[1:], toks) + parse_field(start_lineno, name[1:], toks) elif name[0] == '&': - parse_arguments(lineno, name[1:], toks) + parse_arguments(start_lineno, name[1:], toks) elif name[0] == '@': - 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 = [] # end parse_file @@ -789,11 +907,10 @@ def build_tree(pats, outerbits, outermask): innermask &= i.fixedmask if innermask == 0: - pnames = [] + text = '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 += '\n' + p.file + ':' + str(p.lineno) + ': ' + str(p) + error_with_file(pats[0].file, pats[0].lineno, text) fullmask = outermask | innermask @@ -846,6 +963,7 @@ def main(): global arguments global formats global patterns + global allpatterns global translate_scope global translate_prefix global output_fd @@ -907,7 +1025,7 @@ def main(): # Make sure that the argument sets are the same, and declare the # function only once. out_pats = {} - for i in patterns: + for i in allpatterns: if i.name in out_pats: p = out_pats[i.name] if i.base.base != 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 +} + From patchwork Thu Mar 7 18:56:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 159923 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp7814190jad; Thu, 7 Mar 2019 11:29:18 -0800 (PST) X-Google-Smtp-Source: APXvYqxLxLVRtT1DGsKpzkhT5BzPjyUtKa6nI8+IUXIWk5GoycWczoFB0LrraPtr/yMV8fKRiBEg X-Received: by 2002:a25:5887:: with SMTP id m129mr12430994ybb.275.1551986958650; Thu, 07 Mar 2019 11:29:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551986958; cv=none; d=google.com; s=arc-20160816; b=suKhRLFxDgenJU5y4zJuP+NslxZY8e4g+sbEbOMDrtro9lS/QPHlJaNBJmlwoA4AwI YJy4x8zVreIXX/t8z8oF0ArPdwDKrUrh5dL6cBYlnc5aLgi+znUmwvJdeNA/o2RTalVc Dtj2Gl1umsvuKREpRqmjLCf/NljrylbGyVMEtRctXcpyU8ywD01/otJ0S3qA5CwlsCop tXEr/4xzxxvlkTBd6YH4QT2c+McLq0WSuQdOV9vSS/CmXRkT9Yec8na0DiJWSylqSLMg YVyQJP4qiVatLmHSopb6dANW1OmMIII4xPG++eDjOOqy5+FqAzG3dL/+908ywNkfCupK 6oDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=8ulPBZ7h8lwje33FAm/1yxM4mNmEPfuMt2JEIkVfEzs=; b=Y7J6f/KprS+937eWIPcoZEblJ3Vyz4FGlY/kSG/lURnv3VTdtJCHaPVoVSXNtMZMpK rhrAuVx9/ZFUUjjX/4M3A1AZh+5n7gWXF9FfY0tVAKOngyGUPNokURb7DwGzwAyNQDW/ WsZdJkn9RbTMBSLUHi8ErBev+r/3cvfKSCg8YUnRtDZAFJr7+PTGzpVoLhYRD5xtoD0x PNP/qlGXGlgfUYk12s8W/nGPx81KiDdqdFx48lUcdoTrq44EANDFYMCZ9Xtv0fqIYtmc yPAYJnxv1mZll3SR4CUAeniDwXhpWhCUMfbMgzjg6/iQYnfCOIcKyYf0Bch9HEt3Vspg 96lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=qnqihsD3; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id i197si3235029yba.323.2019.03.07.11.29.18 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Mar 2019 11:29:18 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=qnqihsD3; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:58161 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1yhi-0004f1-3o for patch@linaro.org; Thu, 07 Mar 2019 14:29:18 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36720) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1yC3-0001Jn-Kc for qemu-devel@nongnu.org; Thu, 07 Mar 2019 13:56:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h1yC2-0002T4-K7 for qemu-devel@nongnu.org; Thu, 07 Mar 2019 13:56:35 -0500 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:42275) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h1yC2-0002Rl-D0 for qemu-devel@nongnu.org; Thu, 07 Mar 2019 13:56:34 -0500 Received: by mail-pf1-x444.google.com with SMTP id n74so12130371pfi.9 for ; Thu, 07 Mar 2019 10:56:34 -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=qnqihsD3fUGd9BIQPTmpfdY0ITbunut5L1lazHUSLDGoPvD1F6cEX2de3Y+ACEnI/S vKiqWnkO/KRCUAURDkjn1KDF4+OQrXf43b+LMp87BubvRUKVvrJn7n4r1umr/yLrmo+1 l275TaY2A6q9DoIiMA3WQ7r2AA55h6z5y9LFYrU28GH9VmZxOTQJnZYy4y0MWF0qEl52 EjxT6re5V1hEyM8YCFoROrn7YV6VCTfYjwRoeEMpHGHkjzD9XCDNIPdTZWf2rPxbaVN+ nmywtSry8JiKDcA7n0ZuwAEhTMw3zLLwRGiqArtlrF2P1xAgAM3IiJuGYGvj9od9Jm8f wS2w== 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=jkyA+ZfcUcc9hyHCjxCg7oREmXLyqzH4uomEsLlzauNQ20Y9A+YOSXWalKoYVXddN9 y0SF9K5JVIfqBCIInbMJXYP2D+6epx9G/a12xm2ofX5ffu5L4ol4+tGSkHpLgz2Z+5Pz tUOO2wIWb2LfU2e6sHuCQ3Z4LbntcxUzEwEibYodH5nRa9OUqCNCfVvAwBJH8PYwDBQv He2Ybz5mhRU+/dv8FfygTVYp13pwhfEdTwZtHnzcUAvDEHe+vkWAZUGM0zcU1tiZ341J rMR7iKeLMO/se8CPUK85Ovd+VmBFfzGYLZSEVbxBbLQVYOveaqbjSQYN7i+1MrcewXg6 n9sg== X-Gm-Message-State: APjAAAUMncij21P6E1oN//ROeMC2TPoggr9wjoJhLmag4dOSGC4C+LDt gGyJcXEB+lEW1bD8oWgGAwaQREV9BnE= X-Received: by 2002:a17:902:9306:: with SMTP id bc6mr14104362plb.59.1551984992991; Thu, 07 Mar 2019 10:56:32 -0800 (PST) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id g12sm8801973pgr.76.2019.03.07.10.56.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Mar 2019 10:56:32 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 7 Mar 2019 10:56:17 -0800 Message-Id: <20190307185622.29026-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190307185622.29026-1-richard.henderson@linaro.org> References: <20190307185622.29026-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::444 Subject: [Qemu-devel] [PATCH v3 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: Bastian Koppelmann Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 -- 2.17.2 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 +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 later. +# 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/err_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 later. +# 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/err_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 later. +# 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 later. +# 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/succ_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 later. +# 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 + } + } + } +} From patchwork Thu Mar 7 18:56:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 159918 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp7811039jad; Thu, 7 Mar 2019 11:25:42 -0800 (PST) X-Google-Smtp-Source: APXvYqxsQua7yJ6XeyEesTDlT+pCfgQj5PjLJC06i/07Fjq/jSouRxrnFsDSgPTmPERBU55bPnO2 X-Received: by 2002:a25:1c55:: with SMTP id c82mr13171694ybc.324.1551986742578; Thu, 07 Mar 2019 11:25:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551986742; cv=none; d=google.com; s=arc-20160816; b=xM+ROlYnjJXGbkYbwKbXJ1UOvHTzFSzZNonyQ1hi6S7GzuU86rFhLFyqkx/VfsXyHa HuaojDlY55bueN4B2W1qdDA944U+BsUMss1eTORduPVUo4SdryHaMl8NCPRAzK5twbsW mLoUs0EyE/7GtIaCbXLeF/riL1gxFqMdZnpYVxPV0erk6W1Rq+GDbI9HZZjEsy7brLAx gHiEBGzZWNn+jUbFJCTlQQcKofkV67M6WscdE6amrYM57s5cuMrKD7R+L4jLUZPJUgfm E20mGyQm1n9Dd5uTkwhEiNjPwGfzTDOAvb8rliqlybo9OnFu4NQ8OQRVdXYqiCnwmevY 1Lbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=gU/SPg6KnQhqJVn2XRVC0z9PymxQlPpRj5lZHRANorQ=; b=nF4aFlwysB/qo5OTcQJnziFiSQXlr1l6p3EqKAb7+xZZvcnTUlp4iD2LkH8BdPT9fh O/XGT0bFw7y54Dn5vMDqFCwYZaK3YCKJHyZE93I80IZYBu+CAD2+i4czTNHmq7TzobBY +GeFqEGvta2b26nBQUBHdPZxIG+gmmrelyL1I2tyITwB5Oc9rk+N9TPaomXtVx8v2vCK hE+iWmhRyck50FyS6IVoqruZTLGnaD3AXhZjk7FGltXmXRk6YGSmMeB611Mw6LDARy4x khv50oGjAm6bOptTsyVx39sG+isJoXsVh5nDtRdUWtvhhM+OsxEP0RELyQw0emipspmX q6dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=i+GhINxq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id s9si3252296ybg.275.2019.03.07.11.25.42 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Mar 2019 11:25:42 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=i+GhINxq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:58048 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1yeE-0000VS-2Q for patch@linaro.org; Thu, 07 Mar 2019 14:25:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36740) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1yC4-0001L7-Je for qemu-devel@nongnu.org; Thu, 07 Mar 2019 13:56:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h1yC3-0002UE-Qy for qemu-devel@nongnu.org; Thu, 07 Mar 2019 13:56:36 -0500 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]:34608) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h1yC3-0002Tg-K7 for qemu-devel@nongnu.org; Thu, 07 Mar 2019 13:56:35 -0500 Received: by mail-pg1-x52e.google.com with SMTP id i130so11979987pgd.1 for ; Thu, 07 Mar 2019 10:56:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=gU/SPg6KnQhqJVn2XRVC0z9PymxQlPpRj5lZHRANorQ=; b=i+GhINxqdEoO/3AY3H2rt1md8xwjIIcI+i0mP8vOXSOFaFTXvu1AUEcnrGaM8dLABM VI1QViUVet6c2K1v6WsWVnOqJBSVOOwCgAslity6stTDED/XEeT1nqwA3wz9eNuY1Dp7 Hy41BKW8jLzStrCeuNpLXx7ZdLrGk/0J68Ul+T7uIjn0d/A9n+10ySUL9AJSEVYitG4X rB4RW6FBDhwiaJysRViH4E4l+fd/cjMrPGjEuK7I7y97IorlxmcXhX4UNQQ+ldrJ/DYg jJFyrcUzDWstOoNnAeDOWhhwJL+RaQ5Xh9/xaN30VmtH7iIj0iHKVGvvCpudQ5ViElsN ucTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=gU/SPg6KnQhqJVn2XRVC0z9PymxQlPpRj5lZHRANorQ=; b=g9wzmjX6CplihIz/v7dBW9XaWQPHTLS+/icDzWvS73rawMJEn7chS9wRXClEpkTYWE 2YmDteXxvkqGkQFWCurb5QIgkV9+/ObQ/XH/FSEw2+2OD+dC6s7yWmlp1cx/oZBbj8jK zRNDXed0ER0FG402GCAmjWHOKnpFJdsoksn5bucoNKIxLJdsuaoIDSZAmUFvKLzWCmRj W594VuDONxcTHNg4I88xS4R1OihqF//F72X3fbhvWKKHSUNj/Obmp4igOQpbDtYdAex1 RX4WFCjwObWfoJ4Pc1UKJuVbRa9YldkzGtiwcoQdFhgz20FvtWviZTgri/PAUZUWpqVR so9w== X-Gm-Message-State: APjAAAXsfTSxmU6JA67yjWrEA7mEQaT+prUYtr7qCnUadIWKmp17KbPN WLHwmIWVWPshUWuTU9y5GzoajtzbUo8= X-Received: by 2002:a63:2c8b:: with SMTP id s133mr12642001pgs.448.1551984994198; Thu, 07 Mar 2019 10:56:34 -0800 (PST) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id g12sm8801973pgr.76.2019.03.07.10.56.33 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Mar 2019 10:56:33 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 7 Mar 2019 10:56:18 -0800 Message-Id: <20190307185622.29026-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190307185622.29026-1-richard.henderson@linaro.org> References: <20190307185622.29026-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::52e Subject: [Qemu-devel] [PATCH v3 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Like --decode, but do not drop 'static' qualifier. Signed-off-by: Richard Henderson --- scripts/decodetree.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) -- 2.17.2 diff --git a/scripts/decodetree.py b/scripts/decodetree.py index c4e8cb52f7..d6f94d902f 100755 --- a/scripts/decodetree.py +++ b/scripts/decodetree.py @@ -976,7 +976,8 @@ def main(): decode_scope = 'static ' - long_opts = ['decode=', 'translate=', 'output=', 'insnwidth='] + long_opts = ['decode=', 'translate=', 'output=', 'insnwidth=', + 'static-decode='] try: (opts, args) = getopt.getopt(sys.argv[1:], 'o:w:', long_opts) except getopt.GetoptError as err: @@ -987,6 +988,8 @@ def main(): elif o == '--decode': decode_function = a decode_scope = '' + elif o == '--static-decode': + decode_function = a elif o == '--translate': translate_prefix = a translate_scope = '' From patchwork Thu Mar 7 18:56:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 159925 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp7819944jad; Thu, 7 Mar 2019 11:35:01 -0800 (PST) X-Google-Smtp-Source: APXvYqwU7oRmjqiH1G9u+p7yrku+aq9Ej4lM8bI9ZP/1iugnBhVnkqxEf+ajFkY0VvWVHxf6rknb X-Received: by 2002:a25:ce81:: with SMTP id x123mr7337827ybe.355.1551987301706; Thu, 07 Mar 2019 11:35:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551987301; cv=none; d=google.com; s=arc-20160816; b=mIZSQjNEVFXhg+s86IuS7un63Mucf6K9872sfO6LBZfkwVeLyW1jrzXFOXFJWhvoAf VMMYoFZ3uPWMze6j9LhsM5DhCLjk1iJG3XEs1e7FUbcClTFA6AbbwZLhPQEoaOT1aWuL reDDUjFEh0PQdQFpcbVaF7jdYwACFVDQ+JrqwPZc3kxNoZIoyE8Kl8MK69M+thuMtR7X X/8Expzzv9IvQHRHR5YYkhtUTHNIH8jIczgvOTbJU6EPo/B0wJPbQVFlPncU9b9XjTl2 RJIyeFKXx2JXWBZhMC/G4Xn8srVl+EJlBTA8e+y15FWVEDM3TyQAeRrDFydoeTo2IXjV Mr6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=nb3CidBChl134y1TBDXVYHO3HOjy8S8/AsRiehSmyXs=; b=CfH8BfHQOMsO3CoVIfpb8S0YgWI7txIZSpZ/ewmBJhCSsLOL6JqG5rSU9jCPFY1+nl dwLd2GZdN8fsQHTU7vur3YxBvYTeuUJcbNSZnECzedlyW9IRZaJt0AFqbptsf49P9wMU FYDzKxmD5dPqp1k6oduWsSdu2CO342HcJDUeoVBau2MDg2dr9/WkKhcHhPsqxgLWGjJM ioto++UVtah/Vm1Aa+x2pKKzc6CiaZqRISRiceeBFzNi/5wydZhtjk9ClsmTusf8fz5b 3UbXvUmNVZTFSjVTGS/mrhb3qlDkgq4/uDFqKITSaTgoU0K6QWLBng62tB+msmojy0MI rCDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YM0WJzgr; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id o84si3405979ywd.343.2019.03.07.11.35.01 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Mar 2019 11:35:01 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YM0WJzgr; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:58232 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1ynF-00084z-85 for patch@linaro.org; Thu, 07 Mar 2019 14:35:01 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36767) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1yC5-0001MO-Of for qemu-devel@nongnu.org; Thu, 07 Mar 2019 13:56:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h1yC4-0002V8-VK for qemu-devel@nongnu.org; Thu, 07 Mar 2019 13:56:37 -0500 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]:44143) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h1yC4-0002UX-Nt for qemu-devel@nongnu.org; Thu, 07 Mar 2019 13:56:36 -0500 Received: by mail-pf1-x42d.google.com with SMTP id a3so12127032pff.11 for ; Thu, 07 Mar 2019 10:56:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=nb3CidBChl134y1TBDXVYHO3HOjy8S8/AsRiehSmyXs=; b=YM0WJzgrVmluEe37gjXMmk53xEqeC4szBEt+xRDyV7jqXQ5r++fvxU11hoJwc3fA37 nz9eDzw6NuhYSdSmYtLEQtf10MKjTwKsTP0kI1n16XgopAOIDNAIT6NTg9FuK2EvM/VY cw0egwDe/w7f76b6IyKnEOISENivjx4vYj+uoT9PpdCa2/qPp5PtxZEKmVx8qo2DNN9n ZVUhNs1X3LIFQm2H5UB2qJxeaRW5HYiLK6cCgR98TPiNCtFKFvagyqM/pG/9tYQtm8KV SRl6SWqrwLySZYNY8b3bHMIGfjPqS+fY/spiqdCXQg7r5Ey5Ew12EJ2qrN5gaNRVxde/ +H2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=nb3CidBChl134y1TBDXVYHO3HOjy8S8/AsRiehSmyXs=; b=UDvoT4KXIjaEkt1FkhyJA7jEvs9eyf+J+QTK1vPSVgi50UjjCvIowyo3iP/M0O4Rpo p+Sy+Ew6XIR+bDLEPZ/ZCuGivNfrnecElURTctfIyXjozxU5gmVWwE4gaK7eSG6qBEFX C3GUwQNasDQnOlZ3hW6mntrLfFwo5aApMe+govAvtPgCQHbTb98nUDB2iAuhUQcH/Ve5 xsHld/oe1tAPsmlqhk3rRzGE3P4XSCqnU7eDG+0nngeDNQhWnzy6cxobcNt8ly54XSOR pNOqCg+5LUibnm9b6tvi8mDM1Z9MRvbEFTOSityILNiFF0wb+0tXxaWhvKqF6LAzn/H9 WbXQ== X-Gm-Message-State: APjAAAUat+QI2hdwuSRyf20GFce82G2/jhCJYrwrqMzDHIyoBv030JYI AxFRz56wfRFeNs2JAsSG9/wcIGT/5rA= X-Received: by 2002:a17:902:27a8:: with SMTP id d37mr14304230plb.164.1551984995341; Thu, 07 Mar 2019 10:56:35 -0800 (PST) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id g12sm8801973pgr.76.2019.03.07.10.56.34 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Mar 2019 10:56:34 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 7 Mar 2019 10:56:19 -0800 Message-Id: <20190307185622.29026-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190307185622.29026-1-richard.henderson@linaro.org> References: <20190307185622.29026-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::42d Subject: [Qemu-devel] [PATCH v3 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.17.2 diff --git a/scripts/decodetree.py b/scripts/decodetree.py index d6f94d902f..57d4c9297e 100755 --- a/scripts/decodetree.py +++ b/scripts/decodetree.py @@ -1046,15 +1046,16 @@ def main(): '(DisasContext *ctx, ', insntype, ' insn)\n{\n') i4 = str_indent(4) - output(i4, 'union {\n') - for n in sorted(arguments.keys()): - f = arguments[n] - output(i4, i4, f.struct_name(), ' f_', f.name, ';\n') - output(i4, '} u;\n\n') - t.output_code(4, False, 0, 0) + if len(allpatterns) != 0: + output(i4, 'union {\n') + for n in sorted(arguments.keys()): + f = 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') if output_file: From patchwork Thu Mar 7 18:56:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 159916 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp7805258jad; Thu, 7 Mar 2019 11:19:11 -0800 (PST) X-Google-Smtp-Source: APXvYqxU/sLNDNJzdIoHnRddncRLW46slQ7Mcj2lSIPRl1Ah1l+M6MFEDkCNq8qe1/fMZCLhgWkw X-Received: by 2002:a25:2ac5:: with SMTP id q188mr7783733ybq.350.1551986350985; Thu, 07 Mar 2019 11:19:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551986350; cv=none; d=google.com; s=arc-20160816; b=tLyeoSQ74hOwh/6U+6wS34RlDr1Kkf0Css2tugMV4iy+ZysiMapNwYl9tRrOX1bD3o 9gyFuRNHTblFb5Yw+e0iNU0p13LV/zRfoYKs299fCAPstk0wl+O/jRbGYtjE5WAdV+XB Ghbhnbe6hkfYGQB0Dxrxp9KpCwY53cfLyKOfksvlmtJdwvYePBomxapsDvs+SNAfw0pE Squ0aK+z3Ohm9pN87JIedEh2xA6VXB16yiboe4VmIxuCWT8yqHSw3bxrS4eq8fSO2KrR o8TzImgtgKwb27aIEreP0MyLJmNzRv3zwqfoGzB8jxpb6KF4whWqUgfZquR7ChpU24Eb rHvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=8Qpoj351apEkpY9/mgEdL00Ikni8O4a8d1d83kx7GEU=; b=rKvOvf9h/mDdTsYrfk3xw04R1wGFIXcyJjvQkeJcy1Z+ohnLDcFMDSpVOj2P90SSB9 dtFvhb88poQnx3pCNwWhM9aEsFFn+YYJwuqdMrJFAXbNW2Wwir29A/2RjX5+wERVQs/p ljLu5vrMoD+JhrFiOjpC1TPWLPy3IpIZxFTRW+huuLiBrCnJ/gYQskpH9PSZM5pKJomj D2dEm6zEyXL/SXo4jFSASeE0AlEBg9km6IPEYOmFEFdUZxcWGNX4iPqYudU5xkkeH5zc niwFeLicL7zRNqZ2GnH3SzNgmiJgfAEWy7X9t1AcMq4ITvhQywicPp8PQ2f/0GZpx06I LMEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=jhP5Re6Z; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c206si3128358ybb.484.2019.03.07.11.19.10 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Mar 2019 11:19:10 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=jhP5Re6Z; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:57923 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1yXu-000473-Dr for patch@linaro.org; Thu, 07 Mar 2019 14:19:10 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36797) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1yC6-0001Nl-Tz for qemu-devel@nongnu.org; Thu, 07 Mar 2019 13:56:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h1yC6-0002W9-5n for qemu-devel@nongnu.org; Thu, 07 Mar 2019 13:56:38 -0500 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]:47076) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h1yC5-0002VP-VJ for qemu-devel@nongnu.org; Thu, 07 Mar 2019 13:56:38 -0500 Received: by mail-pf1-x42b.google.com with SMTP id g6so12126497pfh.13 for ; Thu, 07 Mar 2019 10:56:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=8Qpoj351apEkpY9/mgEdL00Ikni8O4a8d1d83kx7GEU=; b=jhP5Re6Zozp32f3WUeJcvoeNcXRSAV+PI7QCbjxXEcgYMUTv5WU7MCXXNlbCI+d2Td ltzNksNSEmphQw2TwzznmzbsEhv645nOMzuT4vW56Wrvgzzisl3IhJ/th95guKyGFjdU IwwMa/eXtUywbm24SN1l054Dne7Nt2YJ/Jq6eoI19cAXuicxV+Fc4D2DmCWBDTkX0OTU c+KGOBAs/MmlsiLwUJbJFRMii3D8ruyzUP8DrlbixD9rg2vInV33gecIM5zZ/wK7JZo/ hl6gyCGdD+O6QpM5GKXNVMadVhI4UWZzv8EiqF1dEQr6QVPgklj91HM4vt50HBqSFMhR EJ9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=8Qpoj351apEkpY9/mgEdL00Ikni8O4a8d1d83kx7GEU=; b=A9knpHlIyo474Z16F5755WoLRHMWuF+mXol4hWcKYxi5wd6U3MLkHzHgE/ibq4DVN0 /rdSftaY1Kt+7gKVDBu6T6UATeoOjltZBDUsz/H76XOgEQtecr+x38cGn4fybAJhT+3U cW+Hg4D33LMRaUZNW0lCjAo5OF1sdYc82UOVOCGwiruu4r22w8izG+aKMVDnpX2JS/ms aADx0r7HvQzsXLxiPhH8PpTIBR9hxET43oxXSXs5I647OfClZ8ciVgpDPBSoUGZkTvUj b59/M3i3R0mAj2Mk6m5NhUqhyxwsMCWi4PT9G7yYcNzv0dk1PdSLsie82Poie4uVkcrd 2FPQ== X-Gm-Message-State: APjAAAWVlYDL5q5pGTeWfg6IZ+q2PWyspgUILrbTyPWNPCGPcjdZAlcy Xq6wY7epU1rdnWS/IFLfz+/wKh2bpvM= X-Received: by 2002:a63:ce:: with SMTP id 197mr12576262pga.212.1551984996558; Thu, 07 Mar 2019 10:56:36 -0800 (PST) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id g12sm8801973pgr.76.2019.03.07.10.56.35 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Mar 2019 10:56:35 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 7 Mar 2019 10:56:20 -0800 Message-Id: <20190307185622.29026-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190307185622.29026-1-richard.henderson@linaro.org> References: <20190307185622.29026-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::42b Subject: [Qemu-devel] [PATCH v3 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- scripts/decodetree.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.17.2 diff --git a/scripts/decodetree.py b/scripts/decodetree.py index 57d4c9297e..eef32f695f 100755 --- a/scripts/decodetree.py +++ b/scripts/decodetree.py @@ -589,7 +589,7 @@ def parse_generic(lineno, is_format, name, toks): continue # 'Foo=number' sets an argument field to a constant value - if re_fullmatch(re_ident + '=[0-9]+', t): + if re_fullmatch(re_ident + '=[+-]?[0-9]+', t): (fname, value) = t.split('=') value = int(value) flds = add_field(lineno, flds, fname, ConstField(value)) From patchwork Thu Mar 7 18:56:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 159926 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp7820277jad; Thu, 7 Mar 2019 11:35:21 -0800 (PST) X-Google-Smtp-Source: APXvYqxhB/LNhQZ4mRRhyZ3y7EgydJcn7IRUCprPnPtxrqM6kH1rZIda3GE52RlKVC/48hELzexK X-Received: by 2002:a81:ac4f:: with SMTP id z15mr11557814ywj.59.1551987321673; Thu, 07 Mar 2019 11:35:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551987321; cv=none; d=google.com; s=arc-20160816; b=ucL49sj3AcT2uwgR2RUQ6I3AVSyckEVRif0kLEn2ycfVd+cM7YNrwPqhEkOdNqa46m BKMo0v0l+AvXxG/fCRX53Gk0Sk9HtMuh4WGPUpu6hD741aWS+o590VsYPYbfTeHv6Hni Mnw+VaEzSOMDsnBeY0lenxsurz2Y6EoWYVdg6TBK+qRV60X0SK3aOaW5FDIEgx93WSdU bhauPX9q+lim0wgz8nJvf0edgD5vLubTynLElBOtRsq9Ue+z9iXdgmMIGdHveuj6ztlD PecvPTIeECUhlp7QSJt4MIfsqXeWQJG6PDt1vZArdifnJTXy8+QmUWJwNlkBQKtBW+HG zJmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=TQcVd3Dqy6iFhltS0ecXUxe7EPe6saLCfPnA5OwEVjU=; b=rJdYhk89bI8lmsuGaC/BfZxAD3Oan8BHFkjmgj+FbiGPX3kufKXr37mZ1fCLIBr04s LrraEsYnFP7U8BcTCChl0a6Iuv1Rtw7Uo95sVM4P9jXcpevVjNpxATEB/gZfk9WgXKKB 2itoJUlhXPDPpvSXEBRZh/BhPuXBwUeox2VTAzmTOL8/WnjPeHPOg6gF3vHnuF0UDeII SYJCZEyMQrUGdHaQLawRUDcT9qbZ04d7UCwwUBKw3CFLWtAB9umXblDS3pg4izNCa7iG ycmW2GtZBN6gD+hGlTDa0kSn5/qJNV8t2o5IUmnGIqst3+TRNH35PKGE/PWtQoI2Re5b 7wEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=A7kI5ztX; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 191si3152489ybr.410.2019.03.07.11.35.21 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Mar 2019 11:35:21 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=A7kI5ztX; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:58270 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1ynZ-0000V6-7L for patch@linaro.org; Thu, 07 Mar 2019 14:35:21 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36866) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1yC8-0001PO-8Y for qemu-devel@nongnu.org; Thu, 07 Mar 2019 13:56:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h1yC7-0002XT-CM for qemu-devel@nongnu.org; Thu, 07 Mar 2019 13:56:40 -0500 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]:42649) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h1yC7-0002WK-5K for qemu-devel@nongnu.org; Thu, 07 Mar 2019 13:56:39 -0500 Received: by mail-pf1-x433.google.com with SMTP id n74so12130511pfi.9 for ; Thu, 07 Mar 2019 10:56:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=TQcVd3Dqy6iFhltS0ecXUxe7EPe6saLCfPnA5OwEVjU=; b=A7kI5ztXPu1ZM/XkK3JUosr+U0o4dXU8wVVCG/8Cr6c+4r/YD19vPw2H3e8iSRXEqr 6EYY+3EbEK9b0IhSe/o8FV5kp3K4YNcETBJB5HJMJbFfBmA7Ut/cLdZS3VrBEG2hLgch SzHmf33p65kbSGud/z2ny+lRL2Vq4uEeVumuwuChRILgVKkcTFnQnUHU5b1H8yd6HI4s a8YSWQAy30vVmKu4el49vM8tj+KtZGQGYcJgN5Fh7MN2qABZEyHb7OFTfOsiZHc9swao hFdvqcT7GluUqBRzbzAC9ZII8CPATjQfmYjsOXaKHIX41ePLScrag4QrHotzrQ0PIBIf PkLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=TQcVd3Dqy6iFhltS0ecXUxe7EPe6saLCfPnA5OwEVjU=; b=NGMQ34nlG6Se05YgUV6BgmoUJhejr2tonaOS8IDvY6EuC6t70vHPElmWeFH1+mdCr6 wEMGHqdUbVXr+1OsfbYREY3As1IiwOunlOSqmposa9dIpsVkHSPAb9xYQIfmfvvxVGRw cY3fx9uOL8DLCcBEkKr65lnzaf76+1JCThb1vVHFf5SWRHVRKlc/Wux1xHNij0szlA8G wfXuc6eVO0f474YlJPabfpUC4Py0YhMVzLok/+iYLEkASXmVhDLqnDK4KlR2+mZQaC+E 3TUqcxr8mW3h3U7h4gFsTJwV9qYKY2h7OyDVlMJfp4s4hQAYPqmqRAEjEi5hInnbNZwn vfZw== X-Gm-Message-State: APjAAAVyQ8PyR82J7IopUzchom8vnGcsEHAwYmrE0s7RcW/FLIpBIB2u xstoO/N0bevbkWBJ7LtFbsHAeeY1VZg= X-Received: by 2002:a17:902:bb86:: with SMTP id m6mr14281271pls.4.1551984997661; Thu, 07 Mar 2019 10:56:37 -0800 (PST) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id g12sm8801973pgr.76.2019.03.07.10.56.36 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Mar 2019 10:56:37 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 7 Mar 2019 10:56:21 -0800 Message-Id: <20190307185622.29026-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190307185622.29026-1-richard.henderson@linaro.org> References: <20190307185622.29026-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::433 Subject: [Qemu-devel] [PATCH v3 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.17.2 diff --git a/scripts/decodetree.py b/scripts/decodetree.py index eef32f695f..f8df89e072 100755 --- a/scripts/decodetree.py +++ b/scripts/decodetree.py @@ -312,7 +312,8 @@ class Format(General): """Class representing an instruction format""" def extract_name(self): - return 'extract_' + self.name + global decode_function + return decode_function + '_extract_' + self.name def output_extract(self): output('static void ', self.extract_name(), '(', From patchwork Thu Mar 7 18:56:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 159920 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp7813181jad; Thu, 7 Mar 2019 11:28:09 -0800 (PST) X-Google-Smtp-Source: APXvYqxBm9O5twih91TQVt11Xyni6PCO3jlIPUofLfFQRYwIG8frLzL9zGvz/Yk5BmS4Ga013tUC X-Received: by 2002:a81:3347:: with SMTP id z68mr11353897ywz.11.1551986889790; Thu, 07 Mar 2019 11:28:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551986889; cv=none; d=google.com; s=arc-20160816; b=X/25YUSqHZ4MmXz9c1qrHNEbWuMO8Bx2Hl9uigNESukvbBHRIt+juKMaOXU89K2NY4 OI3aRq4xIxVX+Y9gbCMVjKZz6cpxgKzEEOZvK7fsyvMFkLwse4Hq4rCSqO5Bhx0VWcOm ydKvhWimWhAr+iWVDpNKQnrgbBR/VmQ0cTjx7Fdb+6mnUpYs+SEzbwcudtBphZJ1RqWt O+nLzsQgViOPlsJyFPF7cBTR4En7Rh8B0OSmxg3y2WL4e7d0Joht6W5TfBdlI0C2rkQs FwqxNBGwmcuUQtqaxEX+Q9JmcBEKevxEADqt+MO7QMN72NJ4eODSmX5/GDcOMrXAUwb6 R+/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=nW8JphH6Qh+JwrnKEHPQE427juS/l8m1uTk3laZENPE=; b=LWDqhDiGMQBHhdDlA7J6TWQCFsTvmcbvZQ0eIiRKol8T2pdvPSKaDx9Ui30YKn8Fcs RUCjgc8egsOuIu9DLwi7/OV0N2xvSOGkR4QEaLm1+FlQSJwLt3ilwCxoWV34gKyeXXzD Rq79NBcIXr6Ar5Yq0i7L8oZo9ymGuLn0Fy52rtCCUOnNdUdjTghQO7KgWJNMPYIMWI7a FllrXfNtvjCuPo6CQISj2LItnqnZaufnCbwsnENFW4lyl4GPMq9fQVO5Y913/tVVfw2X SjYBJ1CkYPnSWRl4pXo6r4nWuzuZReHLL9FOKNkh5qmheAg3BJe6/cDadmnahgz+J4PH 74sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="rS/BGypu"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a4si3302236ybp.426.2019.03.07.11.28.09 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Mar 2019 11:28:09 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="rS/BGypu"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:58129 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1ygb-000311-7F for patch@linaro.org; Thu, 07 Mar 2019 14:28:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36933) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1yC9-0001Qv-Ow for qemu-devel@nongnu.org; Thu, 07 Mar 2019 13:56:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h1yC8-0002ZP-N5 for qemu-devel@nongnu.org; Thu, 07 Mar 2019 13:56:41 -0500 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]:33904) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h1yC8-0002Xz-EA for qemu-devel@nongnu.org; Thu, 07 Mar 2019 13:56:40 -0500 Received: by mail-pf1-x432.google.com with SMTP id u9so12138361pfn.1 for ; Thu, 07 Mar 2019 10:56:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=nW8JphH6Qh+JwrnKEHPQE427juS/l8m1uTk3laZENPE=; b=rS/BGypu/qEfjzfSehSc224dhT/p4UOaZRercF5tbrLIsz6PzMA4LwA+WLCyNh++8V +jkJeC8kvdEewwuX82aYoEXS2NCO2Ol1BbWc+TRvijXqXs3WfkVvZ6Xhyp7zHB1AAVW/ 3yr+pI3zi6Iq1s1K1DqOSR11+B7VsFeIWJ1zXbbIDMBxntUatdvnGehTLW7KdBWeYYup obTxWz65rwZUwt4JWlA4j5bdlHaBmh8SuzZlvZaNdRzd2jnSIAW/XIKmoRNBmv3xtj4m WzjDBVvrqY2axl5bagc9lUshTUSvfe1uMsMflqJB+Eg768T4In08QCwcIcshWRNmpbTU TrCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=nW8JphH6Qh+JwrnKEHPQE427juS/l8m1uTk3laZENPE=; b=S5gMvMi4y3gOHutFu8fEZHPFsxRfi7fXnCacTf9xQRfg7pLgKc2Yi8uhuAPfSWJY5f AL7jPnVGzSrAddD4zaVauS/yX14Kiiyuw5jSYYE/3bMzRr/oZ9mw8+kuTT0nw6wcK1os XEONxoPpyVRYsolLWtNygvQ0C7uLK3oPfiDUK8f2V57xCbiuHMgLLSTNNeHW+rjhnMeW OMJR7qcM273jcJU/2V7YgTKBsgSxB0ieDOm1UiH+ZayWQXwATvdMcLO/51q55xjxLmCR cMy099uK/JCdrnOBUxIW2PrlnI2mABOxVW9VLt592aXC7wqcUQL/bBCSDKl8+dP59vsz jLKg== X-Gm-Message-State: APjAAAX8zX9L4kmmuXikFpACmQii5q2JGQJX1lZif4cvfyyMXhVBQIOz rtPpYhCD62kK5fIb+0142rBYSEYBWNM= X-Received: by 2002:a63:d542:: with SMTP id v2mr12828091pgi.52.1551984998961; Thu, 07 Mar 2019 10:56:38 -0800 (PST) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id g12sm8801973pgr.76.2019.03.07.10.56.37 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Mar 2019 10:56:38 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 7 Mar 2019 10:56:22 -0800 Message-Id: <20190307185622.29026-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190307185622.29026-1-richard.henderson@linaro.org> References: <20190307185622.29026-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::432 Subject: [Qemu-devel] [PATCH v3 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 -- 2.17.2 diff --git a/scripts/decodetree.py b/scripts/decodetree.py index f8df89e072..7e890ecf1a 100755 --- a/scripts/decodetree.py +++ b/scripts/decodetree.py @@ -622,6 +622,8 @@ def parse_generic(lineno, is_format, name, toks): sign = True flen = flen[1:] shift = int(flen, 10) + if shift + width > insnwidth: + error(lineno, 'field {0} exceeds insnwidth'.format(fname)) f = Field(sign, insnwidth - width - shift, shift) flds = add_field(lineno, flds, fname, f) fixedbits <<= 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 later. +# 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 later. +# 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 later. +# 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 later. +# See the COPYING.LIB file in the top-level directory. + +# Diagnose too few bits (31 of 32) +one 0 s:30