From patchwork Thu Feb 28 05:24:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 159308 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp229077jad; Wed, 27 Feb 2019 21:25:24 -0800 (PST) X-Google-Smtp-Source: AHgI3IbM5SQGe/MJYHxMAQau+uzZw06ZIzxcYcxx2rq7NnraXrjZ0+RwjJt2o9VLAWwAeJfuWYpF X-Received: by 2002:a25:2084:: with SMTP id g126mr5039966ybg.313.1551331524599; Wed, 27 Feb 2019 21:25:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551331524; cv=none; d=google.com; s=arc-20160816; b=HGUdKcGf9/nDF/TyCSrn/erNPgE/0MS67TsNFTyqDaaa7uWaGyezaMlWx+qpNA3r/f +4k+wfd9d3bfWQVzFvHH7ORoeptL9SjXXcgmTl10TGi69XiFacPOnbco94BPugGgHcrg Khmn/OiM+7qzLLHAz7ioEnDZe8Mm7fcVLmYicK6K54tPUEHcVWCaldRSJtAaR+2ORBwt odpff0Uml70M99Agcu2N0CRU2LEt4dFPHH06vpyahNwIeGMQk83EwN+lu6bXLiYuwdFR 90IvKFERe9GldmO/sGcM0/tleUDDFjcrcf4ZR0ukEWMWPHVIopsswALSH5aj3mkBLoQv +TzQ== 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=iyy89pd+gZqtt0lBzyMGPXvkLyMrFCMUc8ekV6OQwAg=; b=JMrfq2vA9mkND1R4NFltJhQz+DM5gpBaVA77RChq2uiqqkQjm0Jh2AXwOcmedj48iy gcOxJUdPsm08Zv59D6yn/sZQnT7hY1FGdrnenqWl6KZEL0ApNYHPNZVYVuiJ6Mwf5T0M wye+0V+iJLSLCDSE4WvaqF7OJbvQFSJ67UTZK4tfslKJImVd+1vaMN3NVHQH3sT3D9j3 277lVD7TW6ibGF6pkNcrIRrxwDFN+gCM1+EcWkU5D1QvzawD7ISkZ8Hi2NB9hKa6XuCP SSvrv/Cx+8d2EfAfsf7CM3zKxExCKk3EFMqB9oCb4Iw5o/UtHlemXiI6NMDLb6vh3jqp vQsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=G5z4UT9M; 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 l12si9784374ybp.102.2019.02.27.21.25.24 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 27 Feb 2019 21:25:24 -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=G5z4UT9M; 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]:60543 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzECC-0005gT-2U for patch@linaro.org; Thu, 28 Feb 2019 00:25:24 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59624) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzEBg-0005g3-8R for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:24:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gzEBe-0003mT-7K for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:24:52 -0500 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]:37247) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gzEBc-0003he-7B for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:24:50 -0500 Received: by mail-pf1-x42f.google.com with SMTP id s22so9148952pfh.4 for ; Wed, 27 Feb 2019 21:24:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=iyy89pd+gZqtt0lBzyMGPXvkLyMrFCMUc8ekV6OQwAg=; b=G5z4UT9MxyOxrmI+h/B8RPlqZChOAAhwWim2eObxWl2t3UVOR91rENwVyGtMiTXJyI cQYuhsoczW36hlEH77xLWSek34bL2/pbojZEdQS1suUD8nXhW7PLbJy40m1depojPpdp luXSn5xqj907EvhGmrGotgLkNUDC/DkJ40EAZVBFbKcfp8K0Z/88AzmgMwoMk4b2myu+ rxNW+pxn0Jq18u9qKG5/tFQNkSLU7sY8/hR5iZCGufRbY3oNjQlPAyC38Tpo9WFA0727 lsx/EbdIfqJzn3HegJcE3wKpY9aZleiYxP2AXsNSS5RcdFbGd/s8xNMuvmwOISereSDc aLcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=iyy89pd+gZqtt0lBzyMGPXvkLyMrFCMUc8ekV6OQwAg=; b=C912dnuO7pXQAD9DiW7U7mweHgTOwn6CW21rB8vgLomu2L+VlAbFDmjYa1hUJONij4 Vh4OdSPM3Swxa/BsD2jE8IxI7By5kKfbZrjlzf8o7qKgEa06OeCBkjz7xhJg+P2BeD9q ZtqaENgUtDipgpl9CfAwGh2yadrUkXfRwfTZE3ONy/EJqay10cVna0OEgyzy+5qz2EbY J07bEZ1Kcm2HW7e9y8ziMBufTrLFgXICNv5kkH1m17yxrVzDE4Z+mVbc+rqRTUjfC41O 0+Y3wN7fvrKaX0xvMwXeNXPZYUPp07N2FB3H/rsII7y7qVEULPTbhiqOuQ22S5K3VkY1 0rvA== X-Gm-Message-State: AHQUAubes3uvNyToLdVX+5JzJIODWufn6TbancHQzLhNcVJLjfvGDcdh CDBWg/UX5zaGhtD5fNu7YAOQEpOsu1I= X-Received: by 2002:a63:618d:: with SMTP id v135mr6678781pgb.238.1551331476316; Wed, 27 Feb 2019 21:24:36 -0800 (PST) Received: from cloudburst.dc.rr.com (cpe-72-132-251-149.dc.res.rr.com. [72.132.251.149]) by smtp.gmail.com with ESMTPSA id u13sm32758371pfa.169.2019.02.27.21.24.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 27 Feb 2019 21:24:35 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 27 Feb 2019 21:24:25 -0800 Message-Id: <20190228052432.32571-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190228052432.32571-1-richard.henderson@linaro.org> References: <20190228052432.32571-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::42f Subject: [Qemu-devel] [PATCH v2 1/8] MAINTAINERS: Add scripts/decodetree.py to the TCG section X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kbastian@mail.uni-paderborn.de, f4bug@amsat.org Errors-To: qemu-devel-bounces+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 7be8c578ea..34364a77ce 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -117,6 +117,7 @@ F: cpus.c F: exec.c F: accel/tcg/ F: accel/stubs/tcg-stub.c +F: scripts/decodetree.py F: include/exec/cpu*.h F: include/exec/exec-all.h F: include/exec/helper*.h From patchwork Thu Feb 28 05:24:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 159313 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp230919jad; Wed, 27 Feb 2019 21:28:23 -0800 (PST) X-Google-Smtp-Source: AHgI3IZflDNtZG8tIGbiX5+ugTUA/r41RN6qL/mJhhCQ9bettbF7r/nKYyFopu0qRBcexJRJ9A4i X-Received: by 2002:a25:6b41:: with SMTP id o1mr4985204ybm.135.1551331703321; Wed, 27 Feb 2019 21:28:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551331703; cv=none; d=google.com; s=arc-20160816; b=Wutk++YpmQOa7Nq9+yUu6uo6MGbmADdcEGIfP87bI1BGGe9iRf3lk1ixhQ92npl7o1 Frde8/uPqY0qMyQSKhmWq7XaOzFkgr6mI+Nfj/RBiej1z+CLW+WLNHoFtPcSjc+NRUy4 pEv5K5FKUusWzha+5HvZbWGYYG0QqfgAr3laBNj8XRq2EGr1kVhFZBsCZ43v2a59N1Ko HuVjotI3WAxb+N3v2frMyA9gtP4sjKF6Ff5RSIa+fKcLZPBkDV/bk6NlC9T3K1SEf8J2 zDweLJgFN9lqZ6bS+Rw+yVmWFHhV/ShY0sS6pw/iY19BNjkzBDFv7HEt1vR9uT0fJed5 KGgQ== 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=v8rnbCpTEczIgXqRljoCrowmHGwCxczvAy5UTYQaU7c=; b=PVa8qWeSEpgA7TA/aYhOzhY3HSi/v8BxByiEpXWS6RT73qAsBO3zESidFtuBdFvu3Z Wbakf7zHeE4TwZF5eYiXU5CLsBQ1pv8S/h+RP8TcTfGXi7E7mLMYdTPfeXmgxFrZGBrw F7Vgvj9jlcpb1UkDhk4WDCTcUXPd3mYXjukZQcv4+Vy2gcnxr8p8gB+MC5CXRNoqpLVv dUx295LYzKign0vzxjAp5lD9mb+coso5v/tXntkTXO/NncDGhxbisqaSYXPTmCFDM49b w/81/qRkd1e5xKCo+ZfBlvT1Z5e2WObvoQuN3OXcIgNeUsenux6qePwHdvgCoP11Xwum hyRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=mdSEp8yV; 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 v38si9994099ywh.347.2019.02.27.21.28.23 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 27 Feb 2019 21:28:23 -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=mdSEp8yV; 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]:60604 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzEF4-00087B-PG for patch@linaro.org; Thu, 28 Feb 2019 00:28:22 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59711) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzEBl-0005iz-41 for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:24:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gzEBg-0003oq-D8 for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:24:54 -0500 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:38028) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gzEBe-0003iK-5n for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:24:52 -0500 Received: by mail-pg1-x543.google.com with SMTP id m2so9117330pgl.5 for ; Wed, 27 Feb 2019 21:24:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=v8rnbCpTEczIgXqRljoCrowmHGwCxczvAy5UTYQaU7c=; b=mdSEp8yVSOisLlqcv8GJFeRVuiEVvNrUXiOCTYPEwN3L3wmHA5Cek96jocwIkkyudM ZLGPeMoS4MdNw06zvxpDQpeFvUhbx3XILFOz5sWutiFxvREe2zAvLPR5GFQaiQGJdgxW jm8jIbLK+YOXPFCRuiRhBCkwTKp/fDTNEVvgBGIi9u0fs+jkF481aMZullt6YA7rQDxe exR9J+eGRpN91ajpwDUvTbINkyXNQ569oHcJqmFPlFqZ2IvcswZMxLe1yG1cwzZsjqxW 4gL3nE7LPqOx1YgWyPlFYTiNlJJenzQVNL+MgL+WYIVG6HdeD55vfDmbXeND+VKUY8c2 a4tQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=v8rnbCpTEczIgXqRljoCrowmHGwCxczvAy5UTYQaU7c=; b=I9p19D4nZylXU4iKEfW4drbVbkS6IsMhlZnbgNEVac818DPupyM/MNdVMYGFJw4i9K cqYI+ujcrwfOJw5C6lQOg18nWsxACWlyDBe0tAvDC7NLIH2LGNqz4H1g4a8e5vgO9I0L DWB4gdp37wl2jNP/rqsDYXsus9K97nIbgHo2dOJaHRWqUI0cE8jRO39YdG6FNUGpfmlR btIykoALHKqKMpKSWVQd3jTX4/jJB5T7+aICC9Ipri3XIrNCLDJBcR4Ac4zwP/RtUIYz 7YQ4frxe3So7oqe/PPXyNQkZmbcFyIlLX+O0mR50dH3f8L4sNbSBiepeRFgzmC7REpwF dc7g== X-Gm-Message-State: AHQUAuY8EQI+U7u3bMyZhB4bW8Apf+lPExAru12hPHNBRWXo+k3TBWR/ Bwb760+cpP9jtVPUKIPqDT1E24Vh5mY= X-Received: by 2002:a65:6383:: with SMTP id h3mr6577337pgv.11.1551331477880; Wed, 27 Feb 2019 21:24:37 -0800 (PST) Received: from cloudburst.dc.rr.com (cpe-72-132-251-149.dc.res.rr.com. [72.132.251.149]) by smtp.gmail.com with ESMTPSA id u13sm32758371pfa.169.2019.02.27.21.24.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 27 Feb 2019 21:24:37 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 27 Feb 2019 21:24:26 -0800 Message-Id: <20190228052432.32571-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190228052432.32571-1-richard.henderson@linaro.org> References: <20190228052432.32571-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::543 Subject: [Qemu-devel] [PATCH v2 2/8] decodetree: Move documentation to docs/devel/decodetree.rst X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kbastian@mail.uni-paderborn.de, f4bug@amsat.org Errors-To: qemu-devel-bounces+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. Signed-off-by: Richard Henderson --- MAINTAINERS | 1 + docs/devel/decodetree.rst | 156 ++++++++++++++++++++++++++++++++++++++ scripts/decodetree.py | 134 +------------------------------- 3 files changed, 158 insertions(+), 133 deletions(-) create mode 100644 docs/devel/decodetree.rst -- 2.17.2 Reviewed-by: Bastian Koppelmann diff --git a/MAINTAINERS b/MAINTAINERS index 34364a77ce..120cd7bff0 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -118,6 +118,7 @@ F: exec.c F: accel/tcg/ F: accel/stubs/tcg-stub.c F: scripts/decodetree.py +F: docs/devel/decodetree.rst F: include/exec/cpu*.h F: include/exec/exec-all.h F: include/exec/helper*.h diff --git a/docs/devel/decodetree.rst b/docs/devel/decodetree.rst new file mode 100644 index 0000000000..d9be30b2db --- /dev/null +++ b/docs/devel/decodetree.rst @@ -0,0 +1,156 @@ +======================== +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/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 Feb 28 05:24:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 159309 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp229087jad; Wed, 27 Feb 2019 21:25:26 -0800 (PST) X-Google-Smtp-Source: APXvYqye+ZuiG2WZrRdErmTNw1xbAVxbAMl7nU2Cs/CYQyHfQVrA9c3WiLO9QL6ik4bipAVba9Ew X-Received: by 2002:a25:e6c7:: with SMTP id d190mr728748ybh.296.1551331526084; Wed, 27 Feb 2019 21:25:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551331526; cv=none; d=google.com; s=arc-20160816; b=Q+mbNEKYI7lRu8aDngufXV8zCAKM1ag91vDB7J+dPoUL6kZzglN3zBy5pwYxpVgmug aqvOkHH0Wfc3CCbBJD5/CpSHQSXtnvOjZRh4Pl1fCxGzstiJSa+llYAsKZGlEKX3FCEi XNH1SkPrDC3MQhRPMkhK13cY9zbvokBpg7xB3k3K/ZTgg07gpXTUs2wx1KhxuJ0XywdR VtnzQUtTfsvw/RPnPofYO+QpF7y8J5WHI8fVbe0NQTMZR77ctyQCW94XgcmOVFJOnBfh fPdoajSk0yIDxlKwX80iASLNhWhQPsCviA3ZZtN5NCBkzw0/gk0UQduLCo8ESv2FvgM4 QBgA== 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=bhUfeH7Y88x0TUB0opJCJd9CwNlMyBnOlAFYaYt2ezU=; b=C70UwryX52bdAY9ArVVt3aGJkT+V+hO7+55jHS1QkQ6V2PJeFCLxxem0cNBuyvtt9n CJV3t0K33iaqdiN6cwaIe0wO3hHx9e3IKZhhQ+W4IfD01Hi+SkAYwoEq1w+0mI9q6DVE 7Trztx2slyuWa613NuThVNWqp8HxZeQWHOIUJyVR7R3rTsgnbSqtCPwB70YfyEkOpC8c JOTElqNLu2+ut4zoUJffaFhBuo2ecOvTW9zJEBcuOOK6lj0JhmbQz50yRGhsOdxRjboW bu61+99fD0G+5dl3miI18p2frY0IJYzVnkU0WduPDQ3AFUs8PskRhj66ZxmfKvrbhlHb 4V9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=AyPBiZQ5; 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 e64si34871ybe.164.2019.02.27.21.25.26 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 27 Feb 2019 21:25:26 -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=AyPBiZQ5; 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]:60547 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzECD-0005h9-Fl for patch@linaro.org; Thu, 28 Feb 2019 00:25:25 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59623) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzEBg-0005g2-8Y for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:24:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gzEBe-0003mp-8c for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:24:52 -0500 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:42295) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gzEBc-0003ie-74 for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:24:50 -0500 Received: by mail-pl1-x644.google.com with SMTP id v11so3735235plg.9 for ; Wed, 27 Feb 2019 21:24:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bhUfeH7Y88x0TUB0opJCJd9CwNlMyBnOlAFYaYt2ezU=; b=AyPBiZQ5OMa9X3JAZ+zA3rsSq67zV0M0WORdQUs0YtFwXi9y8SJTio0JP2SrUGrOWt AqpsM6XzIzW2Z2+qtBpM2wXMcCjP4zbBtoc1jsOqu9tZaT/axUJYaUlMpCuMWwSYvS4d Dh5L+BgKcE8ssZSJTL/C4gG7ZWR5knKwvSfeqkjFEAkqh5Q4u6GjNHFC1BgbsAgyApAb 9odfq5uMxHHsHkFPRyTv8cmFJ95TioOtsceTH9mypyZoEpbZ8rgpBLL3CHeJt4eGcZnl ZzW/Wn9ZwZiIDzOE1RHeEalEosLYj/y++vT0hHTJBoD7FiJAla4eW6fNhp8P8eRflUSG I8MQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bhUfeH7Y88x0TUB0opJCJd9CwNlMyBnOlAFYaYt2ezU=; b=mo4B8kJaTBWLYinyKwfqgQAzBZ4vsUrodczW9/q7NvBnGTiltipTwQ3kq/8Mt3KtWr 1gGjmubyN8kAmMpoJqjXMJj7uju6wCnXzrYhUOVAgZmNBYi2B+Q2XxwMVtaKGqyU8VHF SkCn271oX0SpQhpp0bk0FHl4kiRQTedxT7oJusnd16g+WAf6hv8Q15X2CTjITtUozAUH O0ik70qVSfJlClC2nDj+v60WkmGcpfylItET0GdGK7EJvbVoYVtEDdqi90/y3SRbRLDN JQOhk3YNkZZuVoRW89gp5hTF1z+HoBztYKWbkqBG6DRXGLPpGdQymZXmajBj9/xeDnPy 97Bw== X-Gm-Message-State: AHQUAuYvXpEv/mScK+Rco0FFx3SakGHk2Epy8ZShPaNckfig7aFdvhEx pb+L37kD1UqQc3Ers9ZgTqhRTsSgc4U= X-Received: by 2002:a17:902:9a43:: with SMTP id x3mr6007751plv.173.1551331479260; Wed, 27 Feb 2019 21:24:39 -0800 (PST) Received: from cloudburst.dc.rr.com (cpe-72-132-251-149.dc.res.rr.com. [72.132.251.149]) by smtp.gmail.com with ESMTPSA id u13sm32758371pfa.169.2019.02.27.21.24.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 27 Feb 2019 21:24:38 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 27 Feb 2019 21:24:27 -0800 Message-Id: <20190228052432.32571-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190228052432.32571-1-richard.henderson@linaro.org> References: <20190228052432.32571-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::644 Subject: [Qemu-devel] [PATCH v2 3/8] decodetree: Document the usefulness of argument sets X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kbastian@mail.uni-paderborn.de, f4bug@amsat.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Cc: Bastian Koppelmann Signed-off-by: Richard Henderson --- docs/devel/decodetree.rst | 7 +++++++ 1 file changed, 7 insertions(+) -- 2.17.2 Reviewed-by: Bastian Koppelmann 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 Feb 28 05:24:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 159311 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp230696jad; Wed, 27 Feb 2019 21:28:02 -0800 (PST) X-Google-Smtp-Source: AHgI3IYq1A8JxrmY394LoVP4ztbT9DZ0dvPAJtpk7Jek4mieRqvfp182HM+l+oRlu4zFIxHz6o5j X-Received: by 2002:a25:24c6:: with SMTP id k189mr5105213ybk.79.1551331681695; Wed, 27 Feb 2019 21:28:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551331681; cv=none; d=google.com; s=arc-20160816; b=Nh0+8m3ni2vOhyWVpkkdoWeM2iIU2MuYc5dFcSJ72NhQ3UhYvtDdROqkDRbKkUqymi 6+wQ4hnEMGi+CvTxt66q+g4do53fEbAF80UQ0hLeCNYHuVj0gJgbRBB1SSeeG9kt1eX0 rSYX0DTlfXtUFCu0P0ZtJpesYz+cjVJnFWat7vLX1Ar3zTAAXiKhAiMJxlR3a0hNd+y5 D3vXFyV93Nyl5nicrCxEVXtZdH2oyD3jh/nPGswxO7U00zJUnF89/f0kO1tEWGUALu4x ZzLw5737gVhiJxnO9h6nJ7vXD6euY0cN3mky+ZLEkULnpRCZuNuhws3/Zr4U6+GQKcYN Y1TQ== 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=ly4sWkvSen1DxxEi63lOwYa1d+H+ZcVgNHw9wURQ1/6xlnIlaTLYCQx6jn7FVSKyx6 0G7MmzRyeohz2S3cnTv+H1WIdL4HpNipnKywzWxrGog32zkGS38E8XS+iUmV0nSh0XGo BQSL8FWyQ+HThQEUcb6XtWqyF3uCjVOXS6Nx4zaEMEtn0O3f0f48qvGzF8doAYoTzfRc si3N6mwvwIPEszVw63j0qDsQoGddXenkJVFwZ4D5CuSYrp6mei0t+g3L4rK5yXOHGStT FNjtD5tpeejtGeRIzZD/J32OYp+soA4/kchdjutlFOtHr3K2Sjs2qHIW/NIiwWgyhqLv 8Buw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=wONT4Efh; 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 o12si9995496ybk.74.2019.02.27.21.28.01 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 27 Feb 2019 21:28: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=wONT4Efh; 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]:60589 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzEEj-0006z7-7b for patch@linaro.org; Thu, 28 Feb 2019 00:28:01 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59684) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzEBi-0005gS-9q for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:24:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gzEBg-0003o0-6q for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:24:54 -0500 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]:38465) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gzEBe-0003jL-6J for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:24:50 -0500 Received: by mail-pf1-x431.google.com with SMTP id n125so9145724pfn.5 for ; Wed, 27 Feb 2019 21:24:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dJ9V0cdUMTbTLS+jTfS4ibWwVyEFxtj+1fJtRE1MNSo=; b=wONT4EfhI2k5t+03Iak6wJqJica1WlKv6+CxUZB5c+4ZdiB7Ch5Ryeq0Xt5WjRn0Il Xzw91KBpyGzL7dNHzeQmT7STVn/23zdXpioqQbBY0doiG6tiXDwqDRHFo1Ft5BNNOpTv 3HEl01NWPDqywmtiP7aZXmy3eFtZm9/YSB97CYjrFL267ZZ5XteYTmZCYl0Ttcyyns+Z Q9llwNRsYwgMzihDbju3QQ+68RoLdfdYfb2fc7t7iHvyd7SXwbbZIQasaC1Up+nXJjKI Y7NDqAnr9mGIQeA275a4NbB5M/GSAqo+asKFkj4NyJWgRMHIIWu0+qSWwJOWoj7qfb9Y TcKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dJ9V0cdUMTbTLS+jTfS4ibWwVyEFxtj+1fJtRE1MNSo=; b=fKtMXL5DPzb37FaBhvqXBYmL9zresrvpE2yfXxDs9ayyBnf3euqAVYkd87eeFVpicf UarwCtPyTpe76vq66ROqlyrxYG4SR5bFWsqb/8/V0Y/68ZycEWmimcQsDn/akGcwHwh1 5FzL9oabnIShE3RyDOA+trPM1GhU1Z5OHViMtKQnq7GFkKrjCKLe4r7WVmrKudBnV2V8 xpnvrMI3sBVGcm5GCFHFG8WIIwONKVd5THaWRrUhrkSRne1uJ2kl8ay6DqXryWmcIeC+ vag+Je52j074Elrkur80JjNAIdFqk/wprrUYSCNDybwR63TAjq32UQRw8iaHctL4kopN 7yvg== X-Gm-Message-State: AHQUAuaIK1P+YKxIqukOC3EPX7uQylUK5+rfzPiLu+5Rr1NzE0xlDed1 vMgVkVyx+XlgD+Ka/lxGJqyQcxUT4G8= X-Received: by 2002:a65:6105:: with SMTP id z5mr6721861pgu.434.1551331480784; Wed, 27 Feb 2019 21:24:40 -0800 (PST) Received: from cloudburst.dc.rr.com (cpe-72-132-251-149.dc.res.rr.com. [72.132.251.149]) by smtp.gmail.com with ESMTPSA id u13sm32758371pfa.169.2019.02.27.21.24.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 27 Feb 2019 21:24:40 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 27 Feb 2019 21:24:28 -0800 Message-Id: <20190228052432.32571-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190228052432.32571-1-richard.henderson@linaro.org> References: <20190228052432.32571-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::431 Subject: [Qemu-devel] [PATCH v2 4/8] decodetree: Ensure build_tree does not include values outside insnmask X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kbastian@mail.uni-paderborn.de, f4bug@amsat.org Errors-To: qemu-devel-bounces+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 Feb 28 05:24:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 159312 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp230871jad; Wed, 27 Feb 2019 21:28:18 -0800 (PST) X-Google-Smtp-Source: AHgI3IYZjOCPsmZJvx3o2jyi5dAP1aSmNv2px4vP9wGpjaviWg4IARmWp5xFT52dCx2+Tjaobi9y X-Received: by 2002:a0d:cb96:: with SMTP id n144mr4111723ywd.87.1551331698386; Wed, 27 Feb 2019 21:28:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551331698; cv=none; d=google.com; s=arc-20160816; b=NSrn05RX8D6vQ0kvyiMEfnLBFXIdziDM3SvvDEFZU3QNe8MK04nndH1KQ+Jlxtf+pD nUusR3zVsGR/gEryK7elakzQvQX6kDbNrApLCx/OADfMmqtrS6dE62gUtSkdytaZ8bF2 VNNFTTC3/o+o5fqV7GzhZEX++c4mBL5ChTu1Lke15zOFglNHw8yjA+4p+jdhuvHrHxtw fLLJK4oiUWLxx3AQeEfrnDzQjDl+g++GJ5R6KjZ6GU9ID9kGuZe6f92Pszlgfqt0kXyZ m4wusefQ2K/BuU30gKKw79oE1s6CH2Xr4UW0KaFZUqKTQ2qKsPYk+quDlScVAOAqZGvw CmZw== 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=q7BmrH4sjrNhoBHqeKigtEhx9qwjct0IB15Jx7wduro=; b=xff8A+bJ6tIqJHXdfg5c9ETKDnx6ggV2FUuqo4lfisy2RLmHbIr8b1hSMkGmTsF3SP +RdbltSNE0CK/gPeODqmt3iLUPwjs8paURTLm14EaMGn/iNL4/XSElQvOPJtBmRU9/TO F5Y8ngTvlGwe0nzDRMa4xt0WZ1cWJ+USGFDfJu431iwFYsGvp3evNrRZQ1eENlTaLmT5 cblBQgDvt0X1uy7laG+DsTRYohlcpDUqmOfT/JxgdHOO3F/v8d6/xHbUhl1jaXzxMEI+ nS5riv8v2lhqYOH4fzAhw6uoAEo3HIQFZyljbWhWu06J9WX3JjN+AnQPzIwzGrN9PkOt GT2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=pPYZ9u8P; 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 6si9608008ybr.58.2019.02.27.21.28.18 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 27 Feb 2019 21:28: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=pPYZ9u8P; 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]:60600 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzEEz-00082b-UU for patch@linaro.org; Thu, 28 Feb 2019 00:28:17 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59621) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzEBg-0005g0-8A for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:24:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gzEBe-0003ms-8k for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:24:52 -0500 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]:42937) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gzEBc-0003jp-75 for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:24:50 -0500 Received: by mail-pg1-x534.google.com with SMTP id b2so9108653pgl.9 for ; Wed, 27 Feb 2019 21:24:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=q7BmrH4sjrNhoBHqeKigtEhx9qwjct0IB15Jx7wduro=; b=pPYZ9u8PLh+51c8aUzwZl9hmq8dhaEKMpCWh7jQwJFdL54eKhV3F84IVsXl5H55f+v oEZcoLqDdMYb6ynQOV1B5GOPV6V94PoBK6tTfY0fOAxmTnZpc3J1rCQUui0KR9fujK7m 85jJ6XEj34+rWP9ZmyrsBbwwGykT4Hd6uuWxG1YB7kO1/Y1C/O9kalmlv5IdqwfCq5p3 mbC2LrG1YzGhhBthLQ1oP7KiElpapR/KPy2O+CJdBVbrRWgMuoDvEKnwX8a5DXcghhS9 M1KlM+kaYFaiU3n+7Edz2M9H2Jkihao8FgkxOz3eFEfRoeDsPVtWWcdTlsrPysH0WG+I UJLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=q7BmrH4sjrNhoBHqeKigtEhx9qwjct0IB15Jx7wduro=; b=ZGGo/lmi4gqs5lQa08vHlQprwcvQHjoRIZdW15wt/eSKh58mtvkMA3dICYRgdKJUUB JGz6BDdRsNotAXgCCSz54K2i0OzagiyvOZ90uOJHWelHkLgj/mj2RZrtdZ3Rm77wTeW3 LQZlhEtGB/jYDK8CAqrJxzvqzHU2+xGuVK4ONm4wzYfRT3vac8gLQImcppDichrhBGbL Xp1n49yTydOyjYuRT7FxVW6un2Zi+fWr+M7PxNpS0t/d3jhQkOZ9xExYRBGm3h+L2M/z cw9OMbOqlmxL2kig1U5O9OVQgdLjooxyWaSp3cKufxFqc5FlAc4cKqfDNOzB/rZiG9QW MtCg== X-Gm-Message-State: AHQUAuZQ0jaoaUWOeAO6oHjcWFBNSHohIB3psAsmKTkovoLnAD/kliAZ marZNSObXLk7pfQdys/E1yra00Qqz1k= X-Received: by 2002:a65:6483:: with SMTP id e3mr6621039pgv.273.1551331482191; Wed, 27 Feb 2019 21:24:42 -0800 (PST) Received: from cloudburst.dc.rr.com (cpe-72-132-251-149.dc.res.rr.com. [72.132.251.149]) by smtp.gmail.com with ESMTPSA id u13sm32758371pfa.169.2019.02.27.21.24.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 27 Feb 2019 21:24:41 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 27 Feb 2019 21:24:29 -0800 Message-Id: <20190228052432.32571-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190228052432.32571-1-richard.henderson@linaro.org> References: <20190228052432.32571-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::534 Subject: [Qemu-devel] [PATCH v2 5/8] decodetree: Do not unconditionaly return from Pattern.output_code X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kbastian@mail.uni-paderborn.de, f4bug@amsat.org Errors-To: qemu-devel-bounces+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 Feb 28 05:24:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 159314 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp232861jad; Wed, 27 Feb 2019 21:31:13 -0800 (PST) X-Google-Smtp-Source: AHgI3IZkjj4Wauj3vWMPdorpFePVBnoOuSusv2gZGdcBxcTHkQmmfJKuaoxxEoUXgGIicmDCjyiN X-Received: by 2002:a81:25d7:: with SMTP id l206mr4322386ywl.253.1551331873757; Wed, 27 Feb 2019 21:31:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551331873; cv=none; d=google.com; s=arc-20160816; b=fEJVhzMXdaGJFhzfEiV9z1ss8nAzJACcQn0kG8tBhARLo1YNR2pOrhqu46+Lt7xaGd COyh+hNvuNNioL5w/x8letTAZN6OfURq7dCP4alO8SrkSlOQo415PbFaVGt94PQGEsxX r5Kt+kDSLC7ux0wQnyiqXACCGzAkaQOf8oBX72pmH2zlixAU8h+OzDX7STcdAJbBdIAA NfbOvTgPnqJ2B2dRZpyZm7RdYdkEWZJb6zKEN5da6b250k3j8uYBCMZ8Ain0ytNNwKpA 3ml1PujKfP0WlTTUqUwcni08aE5qCYKhSeGLQ5KAAsuE5DeR5xrEccPO/EWIMNWeBpRq bsUA== 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=+lg5QUonTqYML7nEvv2sRq/KVhbJP2uTOKti8/DWcYM=; b=UBXlumcJTfTJQOZoowc6LNuk6KiqAPyi9ofCxJVQfU4QTC9DINQggbN+WwQq27Hk5j bfZkA7QHTPhwjLWaXiyMs5i37Fa+FYz6oF5EcZEAyeuGU637Okg8u7afSXY36GsxCAPy R+Lk/8FIDykD6sqjr4bEZjT3kgkL1EC0G0m85o49Y/iUIUZ5QiDh32zHRKXP6V759GZT vKJ/cXdjRv3caFqm/k6hlsYHA371mO6bldstuVUsbEed98UKOTK11G76wF9EqV8kvrlx unkFGCNf7pwVXe0rcGtISytJwzlvHTxAV+GmMd+xbrH9trmZikS7VZWmW751FC1ZV5Ca yCjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=S3WxZNXF; 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 c5si5989512ybo.222.2019.02.27.21.31.13 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 27 Feb 2019 21:31:13 -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=S3WxZNXF; 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]:60654 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzEHp-0001Vv-AX for patch@linaro.org; Thu, 28 Feb 2019 00:31:13 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59625) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzEBg-0005g4-8V for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:24:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gzEBe-0003mf-7v for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:24:52 -0500 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:34195) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gzEBc-0003kH-AO for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:24:50 -0500 Received: by mail-pl1-x641.google.com with SMTP id d15so9173633plr.1 for ; Wed, 27 Feb 2019 21:24:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+lg5QUonTqYML7nEvv2sRq/KVhbJP2uTOKti8/DWcYM=; b=S3WxZNXFQcQ2zdVk9iOLWYEMTIpjbDmN26vqOWgdI7yw8GYo4AIrxkRaIArvzaD9xB EGfUDpSepd1hoY42+ZJgOxPloj8rzxvQiYbRW8GNaujG0WyKn8zfF1FAGztE8NPl7s7W iQpnV5jdQpRoNG7ABc8hb6GoUODDrb5IG1DfyBPjLITns6yHvD3191gpS9dzoBm8Ttkz LKwgvA4I9Q5x8UxDYJ90RVyjMGxtVyBnSt/DOyHaM+Yg/emad0oY13+cuADz0DQ9qjt3 gOqOt6tdmwJoNEg7w/TGQ7fWcvPHl9I87aRjfw3XFbgkqxgpvH5hCCmXtD5nVHdaGko+ x2bQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+lg5QUonTqYML7nEvv2sRq/KVhbJP2uTOKti8/DWcYM=; b=YSXvE8tegXbWjFcjKv6l3uz6+NpMha/XqKUzMUIngTcIW5b4nISk/+O5dIawp6eDVg L9quUq+7lMZbNj/dvFkfIwcd8bZi8m11xJoFPxu35JjmzFkEj/8t2m+3juQr1E8Ak1Qr SqQbJAAND5W2uoPOX/ueB+hDNpI1xBl7FibHpPDNLHM+wMpszGF7f8+LHYaPTl1qZEOq b1U64fJLu8rTzm+NXMxPMvX0o4tx/hCPz3oREVvadO6OjuGKLpQMEE7WLKkBq0JiZYOc faSLXwJSfcY+4z/xN3xrsPDC1WTJSlVPQyig0iUOsnjsqJiUrX1vF9TlMo5j7ZGEG2Fo wQIg== X-Gm-Message-State: AHQUAuYgECYNDbWNJ9ONbm0yEa3CEZNTM9rzGimWX33Ia7Rw9oEOQRZw hdh2UNNqCQXnwPdYM9xjNQMpGFwoNxU= X-Received: by 2002:a17:902:930b:: with SMTP id bc11mr6205354plb.101.1551331483735; Wed, 27 Feb 2019 21:24:43 -0800 (PST) Received: from cloudburst.dc.rr.com (cpe-72-132-251-149.dc.res.rr.com. [72.132.251.149]) by smtp.gmail.com with ESMTPSA id u13sm32758371pfa.169.2019.02.27.21.24.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 27 Feb 2019 21:24:43 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 27 Feb 2019 21:24:30 -0800 Message-Id: <20190228052432.32571-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190228052432.32571-1-richard.henderson@linaro.org> References: <20190228052432.32571-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::641 Subject: [Qemu-devel] [PATCH v2 6/8] decodetree: Allow grouping of overlapping patterns X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kbastian@mail.uni-paderborn.de, f4bug@amsat.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- docs/devel/decodetree.rst | 58 +++++++++++++++ scripts/decodetree.py | 144 +++++++++++++++++++++++++++++++++++--- 2 files changed, 191 insertions(+), 11 deletions(-) -- 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..4596a9da02 100755 --- a/scripts/decodetree.py +++ b/scripts/decodetree.py @@ -31,6 +31,7 @@ fields = {} arguments = {} formats = {} patterns = [] +allpatterns = [] translate_prefix = 'trans' translate_scope = 'static ' @@ -353,6 +354,46 @@ 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.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 +546,7 @@ def parse_generic(lineno, is_format, name, toks): global arguments global formats global patterns + global allpatterns global re_ident global insnwidth global insnmask @@ -649,6 +691,7 @@ def parse_generic(lineno, is_format, name, toks): pat = 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 +710,61 @@ 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 + + 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 +774,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 +793,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 @@ -846,6 +967,7 @@ def main(): global arguments global formats global patterns + global allpatterns global translate_scope global translate_prefix global output_fd @@ -907,7 +1029,7 @@ def main(): # Make sure that the argument sets are the same, and declare the # function only once. out_pats = {} - 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: From patchwork Thu Feb 28 05:24:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 159310 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp230636jad; Wed, 27 Feb 2019 21:27:55 -0800 (PST) X-Google-Smtp-Source: AHgI3IaA2C9cP4/frgu7+wlRcveEk0WR+ptq3tBZMywSAC72hF+f6oPEHYsihZnJagUjoyT+73qk X-Received: by 2002:a25:a181:: with SMTP id a1mr5167772ybi.260.1551331675476; Wed, 27 Feb 2019 21:27:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551331675; cv=none; d=google.com; s=arc-20160816; b=a30g+hUgQhubxJJG45gT8e1LUsg1bfOONDQb7M7xgWUDBKQ6RJv+nvCXGCybmnP1l9 YGQ7OPxLSJXDQx/8ei9yvo28rFpRyONhC1NM1arKAE1Eg0GTyek12kQ0zaYfhtYJiu4H 65/udySMMw6vpoSRWBOVtnuE91a/V67N43l8VW6k2qdyLojdnS9WraTAcmE+6amhjM9e TAfeRaaFGTDmkwajFnazZcQVL72q0WK/536qgIBv3HOcaj8TgMYpsf7E+NgmG0hQvMvZ +hn8UulvgNRD4eixpCMBLoAKMZoAmCGhhxtIP7/ojp6z3ZaIdrQMmsYykNKvFTZZ4nEp XLaQ== 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=duYJLy/s+Uat1e7s1nSJAb7UVjBZnwz1clEtsrnH2barJt+4LoErqS3c42yucFCoax O3PYm53whKZjTYM+PlGZjnH0H4VYwblpN5PFkF267FVTv1XAWNo7oa3u9eg8FQXcVH4I G35FYEKaPSuk2nMK2/7q3bkreakRc7YPAAgEkL72Y3ZReY5Pf94Yt06via5CYiVhFRk5 DLj0+6WZIZvp04PTVjpy7e8mbL+SnSFcnzQC/1OQwJSTHUsKvflPbzT+bTO2SdR3eYox N9tZkh6lFWj6lMs++OY3mEMRG6yQqMQU2VBuEc3eUTcuSH82lbhwH2KBngGe2i4gq3fG 32aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=eSIR8T7q; 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 y9si6346940ybp.245.2019.02.27.21.27.55 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 27 Feb 2019 21:27: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=eSIR8T7q; 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]:60585 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzEEc-0006r7-Tl for patch@linaro.org; Thu, 28 Feb 2019 00:27:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59622) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzEBg-0005g1-8H for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:24:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gzEBe-0003mZ-7n for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:24:52 -0500 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:45354) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gzEBc-0003kf-81 for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:24:50 -0500 Received: by mail-pl1-x642.google.com with SMTP id r14so9142862pls.12 for ; Wed, 27 Feb 2019 21:24:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8ulPBZ7h8lwje33FAm/1yxM4mNmEPfuMt2JEIkVfEzs=; b=eSIR8T7qebdfYMduSHNv62RSpVKAKNaP8oLD/HWXhITjOwQSZ2qoDNXU0agwjmdwGd wZkNuH+QZkOf9XhWMAmeo1FpFqI5cuyGdkpSDhWy1cJnAwSrmH8ZVHv0yuK/G3Q162OP C3y/zLKBzsoJgY56FtO1UX9rCo2QiMXiovfvJ1NqHup68IW265fmEEZWeXNPySkNWKnp /1DgOWXImk57sFlcnUXewvDMajL++jBTCqwilr4+acleXQoRnajebohIYhixrUVS8mUy Sk/x+oY6e3Drfabm63q5e6/YwrOPa6FOrawYB37ioSfE3D0HUYZYIu6U0O+Dqi/oB1ws vbnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8ulPBZ7h8lwje33FAm/1yxM4mNmEPfuMt2JEIkVfEzs=; b=Q59AfXDVsrPDhzYUz+khFpGiUKaWvfcx2qKoTlbMzFYhY9ADrd7OkjgGD/YJL9JIay av4X0O0Uk15DOPtcwtLQWpD8cL6DHLtG0HXaSv9GGUIbt+4QXk790VG4DOlcANQ94q7I FmqQl+0RWI6Ke6PH6xs7XOhVrIp4MH5e5a9I9qvXB2Q2X90EcO0BM/Cj+/aICifj0Ety K6YzRjoCfcpp5Q1zxdtqO7wmSA+zvxWIPWG/VDJ5vrxdhNbQHo2d44rqkrm6xEII6Qpl HKoafZq14sk0z13rE2Tpz+ZEe4/tyB7M7uXkYCwSQ9EnjlWTuEXJkiUvdBOL5AJJaFM6 WmMA== X-Gm-Message-State: AHQUAub8MbG1wJ+3CPexlMWVQhhRw6HthTjomRr0OxZ55sDZYrNiek15 Pcvq5eWBs9TBivAFHPQ8V78hLkIoRmo= X-Received: by 2002:a17:902:1aa:: with SMTP id b39mr6107471plb.317.1551331485114; Wed, 27 Feb 2019 21:24:45 -0800 (PST) Received: from cloudburst.dc.rr.com (cpe-72-132-251-149.dc.res.rr.com. [72.132.251.149]) by smtp.gmail.com with ESMTPSA id u13sm32758371pfa.169.2019.02.27.21.24.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 27 Feb 2019 21:24:44 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 27 Feb 2019 21:24:31 -0800 Message-Id: <20190228052432.32571-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190228052432.32571-1-richard.henderson@linaro.org> References: <20190228052432.32571-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::642 Subject: [Qemu-devel] [PATCH v2 7/8] test/decode: Add tests for PatternGroups X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kbastian@mail.uni-paderborn.de, f4bug@amsat.org Errors-To: qemu-devel-bounces+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 Feb 28 05:24:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 159316 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp234066jad; Wed, 27 Feb 2019 21:32:45 -0800 (PST) X-Google-Smtp-Source: AHgI3IaSUnH8AAvusc0i9fpzImgsyU98yKngZe10inLHRbquZ9JyFs16NIB3JudR+vcP34xPzjp7 X-Received: by 2002:a81:98d3:: with SMTP id p202mr4230387ywg.49.1551331965348; Wed, 27 Feb 2019 21:32:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551331965; cv=none; d=google.com; s=arc-20160816; b=RtbTQlP6L50vcEiMfz2rDLKF0XaGa9tZGVjjzrQNGr9tpcPVhQa1Rdn1Sl79Bs9Fi3 d3dxTsV1rAvx0KE7gO+BqkEZueh02vlXe/Rh6R8LcgXSEdF3b27MFQxY+ZZETePZoggt ZdyPa9ppbX62LQ4vYNH/DKPskmVj8D7oZ2e24N/0z2oaa9xnAiEttkv/PbO9PEmc4bDp qvGN15gXFRzwdSQHEC4V3NkZuRwNKgXg6Jlp3eZGDb5D86ksybncgL+HnpWSzTCjotXT bz4sewxel2+AJDoAwU9StKSEpO7Pc6NueFaJlGSB3Lb6d+QKjgPycKCKtG8Evy0Z6wu7 PUcg== 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=c6s1o0/tKrgJ5/rgCDTrhJ440px5Ud09QTssoKTEFOo=; b=URVgsX0fka0/LgrtlXhAhfW0vPKP4oFakCNxZOyiHsirDwwlYnyKt35oKBG9ysEyEw n9VoEqGwB+8tpIfJHV0UMoTCaTn/53FmVxon3emDWhrKF4oNhA095pyASxE7WAWShBg3 7u/Sk27EeSAhTF/2PaeNPZdE8mFRXjkH4C5k43lHowD5nKeo6R5o38mrG1Lk/hk55mMs YvKNW2cklLRv6YVN7AWfdI3MWhfqNQ/VPZWkfTTs8lWoRHl895ZJAB2m18YpDhhnn6kW 3UYX7o06NpvptkiTOivyVkG/Jzk9Gr4+CofeYkjyro9yoaa7AS0RoWP9W0MVHKFEN5VB So6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=aWB7gxPx; 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 r2si9523860ybg.48.2019.02.27.21.32.45 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 27 Feb 2019 21:32:45 -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=aWB7gxPx; 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]:60664 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzEJI-0002Q7-Un for patch@linaro.org; Thu, 28 Feb 2019 00:32:44 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59717) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzEBn-0005lo-Fk for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:25:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gzEBi-0003qF-Bj for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:24:56 -0500 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:38744) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gzEBg-0003n9-9u for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:24:54 -0500 Received: by mail-pl1-x642.google.com with SMTP id g37so6350525plb.5 for ; Wed, 27 Feb 2019 21:24:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=c6s1o0/tKrgJ5/rgCDTrhJ440px5Ud09QTssoKTEFOo=; b=aWB7gxPxKifsyIpxQjhXW2NOSj1l0HB4JSfgFw9Y1cu1KFL6xNBxGhQ0G88qLEE8Sy GzM1W95cRZImqG7835sNP8HP4BdGRu4Gis326fzuSoHOzwGCEa4nnuZUHzhTbHHxj4/r IGIMfI7uofOQoNgJutDdC1Fj4WKUowHEa5BZT3q3nZ3+YgDqxSLxJIIk7NdigCBwOSTQ v6JL4flv3eBRP8Hf8hnz6LJtJUMxoQZYqaIJc/zb2nA97DH1nFO3S7b0oO7aK6FilHMl m+tNxAPK4jNZvXPKBmExOzM999w2R1f1jFAj7Mnk7gonuJE53nkiwhys33X3FXEbXhMS TnIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=c6s1o0/tKrgJ5/rgCDTrhJ440px5Ud09QTssoKTEFOo=; b=twm1EdF/u6+E7pdSL5pCbvSJ2g3Ej92EPdTeODY8hOCHKOR49NWu5PdBRrjS0nAhz/ aLlUBvgItwSv3WM41EWfvtCRByatwXCTNu9Q9AX9DQgK6G6cnJssPbb1P7eY1Is3FsLY 93K3Bjpg8mZ4HKB13IcFlXLcKu+8HSj1JzVEvTfdz0QFzRgXrUlco7Z6/b4WfIKLa0ge mAFr61MfU3uLSkTS6Y7hXc9dcsdjxO4dOt67hfS+XvBgJwpnxYNAGeJ8IJ+C01b2EiTy 6LxcWyKve9GSOI8j4z/GMYyPBNXcizIQdAKhlTxolIS7nInz9149DnSqCjtTbppRqcaw Lbsg== X-Gm-Message-State: AHQUAuZXX7GaoZZTqktM5GddjtDjHpvuITjaE9/LWfqZ6YckegPlYcSe HdcBYmncji/uhgoGToCnyRdSwtfgPoA= X-Received: by 2002:a17:902:9a95:: with SMTP id w21mr6059802plp.118.1551331486510; Wed, 27 Feb 2019 21:24:46 -0800 (PST) Received: from cloudburst.dc.rr.com (cpe-72-132-251-149.dc.res.rr.com. [72.132.251.149]) by smtp.gmail.com with ESMTPSA id u13sm32758371pfa.169.2019.02.27.21.24.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 27 Feb 2019 21:24:45 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 27 Feb 2019 21:24:32 -0800 Message-Id: <20190228052432.32571-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190228052432.32571-1-richard.henderson@linaro.org> References: <20190228052432.32571-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::642 Subject: [Qemu-devel] [PATCH v2 8/8] decodetree: Add --static-decode option X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kbastian@mail.uni-paderborn.de, f4bug@amsat.org Errors-To: qemu-devel-bounces+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 4596a9da02..68979b73a0 100755 --- a/scripts/decodetree.py +++ b/scripts/decodetree.py @@ -980,7 +980,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: @@ -991,6 +992,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 Feb 28 05:40:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 159317 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp240029jad; Wed, 27 Feb 2019 21:41:28 -0800 (PST) X-Google-Smtp-Source: AHgI3IY5//is2YmvFhmXdKorDMrQhrHdeG7rrfmRivfvpPlJEXtaZQ9b9SQHrYZuOHsNXGjKD2EL X-Received: by 2002:a81:6604:: with SMTP id a4mr4310442ywc.510.1551332488640; Wed, 27 Feb 2019 21:41:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551332488; cv=none; d=google.com; s=arc-20160816; b=ooC0AwIQ/9TOs4/RkF2Rx7PPh35AUkSWBBSIR6a7yIaLz/mjqnHl172ZtY61QsHZa4 kD3uTyiQZinTQXXOPxmrg+rGyhCGiM3ZIrevlXbKOL4lJfqnkoJ6T7m0yAEToc0ZzDKU lk8ZFFhflHYY9CQMCcw5mAtL9zNv/YqOHAk5YWDmzETBwLpdUo+fxt+TxSlW9YhyYEbO UEQoas2+3CtAJMYWFkSDf1e0pd3dMIkXKOxAd/SSw8GdqcGqJ8e+Nb0hAacit81/ZZE0 csXWafuKLCSqa6DkBDbj5acEteIKvqOa6J7/dQB3rlA3lx1g2CBVuBTXVI1bwzosMtT4 yS/w== 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=MdXTm4UWGBbEsgbr9yj2lFEwhlkWHo6z5Hh6lERaMMo=; b=F2EkfZuvosvR+t8w2hj58herX8Bfe81sVG7rRn+Tny8VHrADc9eMC7FyOPRLcs4UOQ kknDhaD4DamYouOMDy30jfKamLT6NpSr0sOodEDrdt97bh/0VU9GUBJSJ8n7Kc3d0yCT cUy+SPD1MzmHRCAH2pErclV/NGJy/k9LffGAyYBvagdshC1LhwioTm6ICrfxLBqpVMRe WezjnCbq+FAt28KD3hD4Cv9c6S3wgrgDAcC28PUqw4KZSNztU8uONqGzxIrGW1G+Ey5L npzjTL1y/SNMF17XWbBQ+XjpVwLoDEy0wKRNgZhwPfCNSFRh7r6KONWu4jxQ+9aLXIoB 9EEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=pkeHvQvN; 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 i12si9629580ybp.85.2019.02.27.21.41.28 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 27 Feb 2019 21:41:28 -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=pkeHvQvN; 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]:60767 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzERk-0004Tx-8G for patch@linaro.org; Thu, 28 Feb 2019 00:41:28 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34060) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzEQY-00046y-4R for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:40:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gzEQX-0003rq-EY for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:40:14 -0500 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]:43192) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gzEQX-0003oT-63 for qemu-devel@nongnu.org; Thu, 28 Feb 2019 00:40:13 -0500 Received: by mail-pl1-x62a.google.com with SMTP id m10so9157948plt.10 for ; Wed, 27 Feb 2019 21:40:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=MdXTm4UWGBbEsgbr9yj2lFEwhlkWHo6z5Hh6lERaMMo=; b=pkeHvQvNC9SdlVpVSj8poG35FSI55qNsLTj+MGBUltx+9l2WVgk3CwMTQMSd9ZCade x0DvVuAz6PE2WZRELl3H8sDdgGqB4y4bP5oKV2kX61voY4vv29X7Opx1pja+e964GbS7 0FrYetdElJy0WSLUWSR0giNi6tsT1HY2nlLIokgDzCkR+KhQJdJQUY0jA5vOoxal8Rx+ ocg1m0qjejkh/afRlRKKOMo7pbBXz/y3FA12Euy9h1pqRNN6cUwDL9Cf+RIoL8ShnyoC uHn6DOe3cz/K9TFwOsuxkOSfTJsCmxuBmheH2WpFdr1l7HDztVUg4JXvJJX3X9KrZu6T DGmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=MdXTm4UWGBbEsgbr9yj2lFEwhlkWHo6z5Hh6lERaMMo=; b=udm6EA3ENRJA3xKa1nckCAwT/2IHBj16UFqR75x8JgIJXabzSntf9ySycnnIZwrpo1 DZLygh1uoLhYVFLbfjeYGCYXPnjAa/EYyqsbUVb0WCU6MfOJ8GL2tSU+YGiO8cp2AJNh cJYDJOZ0uQlWuSAsF5YL2M7OZBKC0isiz8BePD/6PO3dn2cF7ONFIW/qp8EmwJMEYpd3 0FIkHIryLY1FWHGFs9ePlfBxpQUEILo7LxPeTdCFMfLNtCSw9ANwrMqEZdxY72oNuKuX D4NewEmYmgyhvkYPMuw6F7cy4u6br1SYt2t1ux+sv6TqDTseuUP9lSMNoroAMv/4DYSQ h6xQ== X-Gm-Message-State: AHQUAuZmvshRHtyLqlze4rZwuIGQNHcsGF36gG6SKY960WLs2F9phD3Z ns5An0I/2pLQFKxiJl2eRjoeT0jxGu4= X-Received: by 2002:a17:902:7202:: with SMTP id ba2mr6037258plb.147.1551332409929; Wed, 27 Feb 2019 21:40:09 -0800 (PST) Received: from cloudburst.dc.rr.com ([2605:e000:100e:478c:cfa2:eb27:db4f:e85]) by smtp.gmail.com with ESMTPSA id k27sm13833477pgb.70.2019.02.27.21.40.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 27 Feb 2019 21:40:09 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 27 Feb 2019 21:40:07 -0800 Message-Id: <20190228054007.779-1-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190228052432.32571-1-richard.henderson@linaro.org> References: <20190228052432.32571-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::62a Subject: [Qemu-devel] [PATCH 9/8] decodetree: Produce clean output for an empty input file X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: f4bug@amsat.org Errors-To: qemu-devel-bounces+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 --- One more small fix that should have gone with the v2 patchset. --- 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 68979b73a0..1785769eec 100755 --- a/scripts/decodetree.py +++ b/scripts/decodetree.py @@ -1050,15 +1050,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: