From patchwork Mon Aug 19 15:17:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 171644 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp3127571ily; Mon, 19 Aug 2019 08:18:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqx+vHbxkEL5Riw+p21ikU3Q24cb9FhJ7t0bT4o8YSQ8T/pR1Z4UgCw1FuqhejaeiwWuInlN X-Received: by 2002:ac8:53cd:: with SMTP id c13mr21321552qtq.361.1566227904767; Mon, 19 Aug 2019 08:18:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566227904; cv=none; d=google.com; s=arc-20160816; b=uetudcS669MsAIBcUjIURRFFqBTIHmbqkxhDRj7hFbzssQ9i7qlp5lT7sCCYNDevUD KzAGGJxElqYPQlQx+GDxtLHr+skcT/gdcDkFKXatkMZi6To+eaz77u4D6/t/qbZwbucL VUIdJ3GGJ+KFwqbGr/WG7vhYjgfJM8PZfM9DsDNgdpScod9OzZaHbxYNiBE2jDvQwJng PwuKG5y61jpKuewwjyfTZR4GP+WgJBPmX+s3W3i1cNvu1kUPKlVq5td+RDuhh2BahIMZ I1h+lkLilxSVlDM3BU8bXaz4dXStNTIrgnRNfEgR3EsebafSTifzHdfrtbgMToFDzwkf HdFQ== 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=aAsgcvP1KNeiO2DyuHvEBM+1rf528V/HzEzeINYjmQQ=; b=v7pFhB+mYXCM4oZR4fZcpMBPVI3J1e+/4SVbrIAFPh1ce+jNPPGQVUIeiPFYoaOEmf wOsStE0jJXmy0uTNk5DMLRoTRCyLWLHUR1CB4ryjiuTSz6zQ9IEJgLiiBPOpjJbwOulu FX0ldyZXB7B5THQ9nbpRlbo0kLrE64sCZe8u75teqTZw9Qn2rWXOJe5VrthoK6kTTJ9D kOFdxeaD8sD3wPMLJt2IQWPVDnwjFF5UUk34mu806ywLtahCdmjGIdmkDow5FhQuVZzy ZB2gwDKv7Wp/vhc6vZPh4sSBvQZUNlyn+Fo89pFSQeE9ODW4ipwt4HDv5MslLhVwaAYD ntpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YabwG0qD; 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 d83si4540322qkb.99.2019.08.19.08.18.24 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 19 Aug 2019 08:18:24 -0700 (PDT) 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=YabwG0qD; 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 ([::1]:54262 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzjQO-0002Wx-49 for patch@linaro.org; Mon, 19 Aug 2019 11:18:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53024) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzjPy-0002Uw-4F for qemu-devel@nongnu.org; Mon, 19 Aug 2019 11:17:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hzjPw-0002Wl-Pm for qemu-devel@nongnu.org; Mon, 19 Aug 2019 11:17:58 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]:37084) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hzjPw-0002Qi-FP for qemu-devel@nongnu.org; Mon, 19 Aug 2019 11:17:56 -0400 Received: by mail-pf1-x431.google.com with SMTP id 129so1347046pfa.4 for ; Mon, 19 Aug 2019 08:17:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=aAsgcvP1KNeiO2DyuHvEBM+1rf528V/HzEzeINYjmQQ=; b=YabwG0qDHJQ3zR8wemiC7oSISh8CtnYF2SufRC1eX5C2WRTHZXnzd9i9BpHaVhS1i2 iMpwDXxZyGK0mj7EFqUf4gTB5rBTvRs7Gms8/fdIafSscK8JrEB3fZ/hcAH1d3hCmgmI VIjqJ2I0cTnhmh93LAaTEqQQCJYxPtOq79Ur7XKtgZ0OUAUpbKS789Hv3uIW+l83H+Hi JQ/OCi6ydmFemLzC99zLwQf2UEktbvSWQk6afWkEBDKiJdn0NfgfKLNv7cAH0dvAbrIL K3DA+5FAOHfFf4cFUqqcL+91XRSSLWV+unSq+e3tJxzTpY0BZcfvDsKl0Gx54J33hdB8 HALw== 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=aAsgcvP1KNeiO2DyuHvEBM+1rf528V/HzEzeINYjmQQ=; b=mJvN5E+d+t4rFVcgcY251/fo2MzdbjMcfWphC3FLGhNzcnoEVkbxpWAol36xnFJBs5 jtvIKtJX4pCkkRRzwxewGDT1gWbGxYBlKx2Isg+R0pD4GPaJZJFL+icRtRRaUIoruhxU UUhm39zTCC7qb4lwDv3VjQGPd0pWSlYKNbDWQV3KHyVfAPzwwSOsdH7qr8pJfA/jpcHu uc7VYXfbw7Gthi7sA3crfeECSlenMwBtZJJMDng3VD9g4XqGR/CeowaIDyNRDCQgAQSz Nl3++CcvFHXduiiQ3hrIcXmaG2rMWC7aD8Qz369n1w8nOVI4gwYrww8Wh1AizprQxd6N lpRA== X-Gm-Message-State: APjAAAUVK4TANPsx4VbWysRVz4U6gDQ+hxCbOkjuLL1K1GcBxejSQiB8 q2PGaacfZrmr1keAc9zjCpZ2XX5Q8ck= X-Received: by 2002:a65:690f:: with SMTP id s15mr19835734pgq.432.1566227866271; Mon, 19 Aug 2019 08:17:46 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id r27sm21020406pgn.25.2019.08.19.08.17.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2019 08:17:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 19 Aug 2019 08:17:41 -0700 Message-Id: <20190819151743.17267-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190819151743.17267-1-richard.henderson@linaro.org> References: <20190819151743.17267-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::431 Subject: [Qemu-devel] [PULL 1/3] decodetree: Allow !function with no input bits X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Call this form a "parameter", returning a value extracted from the DisasContext. Reviewed-by: Philippe Mathieu-Daude Signed-off-by: Richard Henderson --- docs/devel/decodetree.rst | 8 ++++- scripts/decodetree.py | 49 ++++++++++++++++++++++++------- tests/decode/err_field6.decode | 5 ++++ tests/decode/succ_function.decode | 6 ++++ 4 files changed, 56 insertions(+), 12 deletions(-) create mode 100644 tests/decode/err_field6.decode create mode 100644 tests/decode/succ_function.decode -- 2.17.1 diff --git a/docs/devel/decodetree.rst b/docs/devel/decodetree.rst index 44ac621ea8..ce7f52308f 100644 --- a/docs/devel/decodetree.rst +++ b/docs/devel/decodetree.rst @@ -23,7 +23,7 @@ Fields Syntax:: - field_def := '%' identifier ( unnamed_field )+ ( !function=identifier )? + field_def := '%' identifier ( unnamed_field )* ( !function=identifier )? unnamed_field := number ':' ( 's' ) number For *unnamed_field*, the first number is the least-significant bit position @@ -34,6 +34,12 @@ 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. +One may use ``!function`` with zero ``unnamed_fields``. This case is called +a *parameter*, and the named function is only passed the ``DisasContext`` +and returns an integral value extracted from there. + +A field with no ``unnamed_fields`` and no ``!function`` is in error. + 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. diff --git a/scripts/decodetree.py b/scripts/decodetree.py index d7a59d63ac..f6f7368774 100755 --- a/scripts/decodetree.py +++ b/scripts/decodetree.py @@ -245,7 +245,7 @@ class ConstField: class FunctionField: - """Class representing a field passed through an expander""" + """Class representing a field passed through a function""" def __init__(self, func, base): self.mask = base.mask self.sign = base.sign @@ -266,6 +266,27 @@ class FunctionField: # end FunctionField +class ParameterField: + """Class representing a pseudo-field read from a function""" + def __init__(self, func): + self.mask = 0 + self.sign = 0 + self.func = func + + def __str__(self): + return self.func + + def str_extract(self): + return self.func + '(ctx)' + + def __eq__(self, other): + return self.func == other.func + + def __ne__(self, other): + return not self.__eq__(other) +# end ParameterField + + class Arguments: """Class representing the extracted fields of a format""" def __init__(self, nm, flds, extern): @@ -433,17 +454,23 @@ def parse_field(lineno, name, toks): if width > insnwidth: error(lineno, 'field too large') - if len(subs) == 1: - f = subs[0] + if len(subs) == 0: + if func: + f = ParameterField(func) + else: + error(lineno, 'field with no value') else: - mask = 0 - for s in subs: - if mask & s.mask: - error(lineno, 'field components overlap') - mask |= s.mask - f = MultiField(subs, mask) - if func: - f = FunctionField(func, f) + if len(subs) == 1: + f = subs[0] + else: + mask = 0 + for s in subs: + if mask & s.mask: + error(lineno, 'field components overlap') + mask |= s.mask + f = MultiField(subs, mask) + if func: + f = FunctionField(func, f) if name in fields: error(lineno, 'duplicate field', name) diff --git a/tests/decode/err_field6.decode b/tests/decode/err_field6.decode new file mode 100644 index 0000000000..a719884572 --- /dev/null +++ b/tests/decode/err_field6.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 no bits in field +%field diff --git a/tests/decode/succ_function.decode b/tests/decode/succ_function.decode new file mode 100644 index 0000000000..7751b1784e --- /dev/null +++ b/tests/decode/succ_function.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. + +# "Field" as parameter pulled from DisasContext. +%foo !function=foo +foo 00000000000000000000000000000000 %foo From patchwork Mon Aug 19 15:17:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 171645 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp3129562ily; Mon, 19 Aug 2019 08:19:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqxmyGBkUHIlom22BfmKw8tMf/yTf2OhJfB3NE+emkOD6+Gr0GUid+emEHiitqIQ8SbD/E8y X-Received: by 2002:ac8:d02:: with SMTP id q2mr21153196qti.289.1566227989854; Mon, 19 Aug 2019 08:19:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566227989; cv=none; d=google.com; s=arc-20160816; b=zsE93y6Q3CpQnUorgFRVxPX5ZAWve4lHaAc00RqB+/a9gid6LG2JIqZpAM7LehpIBI MBjSm9K3/Q/OLtahl+p0aBgVq81lhkQD/J1v8wabO3mbltsD+JeN7gedkwqHj7qIjmP2 NHFe3fHX28o8QjZQf5HfwashAS5u+DofrgnTZpVjddHFRelc47VkrA8E/pkGC+miyweW ROEUgvs201kCqa4eHTSs2vcBcxO/7FSQ+2ndt8k7gqhR9uCTD5dPxU3x6a/S9izpLq7R 1UOZ3QJCv131hv3nfMOYhKlttoAvPlQrHOrDE0/FDZGV9sV24ROik/y47sckdQSaDPhx qEpg== 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=kcQQwhe8tbvIkqlEv04wiqdNqDeAeBEJXEVRAMnwP74=; b=0GhJwRcp82MIABQxQ7Bv3kOpka2ijvWuTufn9usXT28pj4XWe9NQEyUv1T5sUtugDg GBlxOPG6qzlciwYzUGYClS7ihiefczO1JOYfC7j3SvZ+Xk5LfnR3vsUCyTmJ3gTk9uyh 4QA4kmKHXE/+/c+kkGiMq4kysmlI6ifu94wDFPMptabGD0q1Zy6uyvf8npFuXesdG8ZH lqXKcwf1z4hsVZB7F6aUkhEMb/LHy9QWI7pyOexSZdP+v8G7cKOmoVhlzANCGVl1sot9 waRZtKJVVkxBjm21gbPgyhhiGYpmaSqWHuji2anyTjxgCankMHWNGUB4SfJTIm0lOSH9 IPIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=oOzgaKQv; 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 194si8579887qkj.71.2019.08.19.08.19.49 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 19 Aug 2019 08:19:49 -0700 (PDT) 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=oOzgaKQv; 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 ([::1]:54268 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzjRl-0002Yt-1W for patch@linaro.org; Mon, 19 Aug 2019 11:19:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53023) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzjPy-0002Uv-45 for qemu-devel@nongnu.org; Mon, 19 Aug 2019 11:17:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hzjPw-0002WZ-P6 for qemu-devel@nongnu.org; Mon, 19 Aug 2019 11:17:58 -0400 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]:33699) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hzjPw-0002RC-HE for qemu-devel@nongnu.org; Mon, 19 Aug 2019 11:17:56 -0400 Received: by mail-pl1-x629.google.com with SMTP id go14so1115905plb.0 for ; Mon, 19 Aug 2019 08:17:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kcQQwhe8tbvIkqlEv04wiqdNqDeAeBEJXEVRAMnwP74=; b=oOzgaKQvX9pX/pHo6fX2nRrnGGPWGfe1iUDvPjg+1Kl2hE2p834EWd1J4syElgmY3h qk7LBj12kFb9hxgtpBcwF9agEJ6jut9pECh4IjyKszOsLrpDSEZnmnz9krH0ngRrT85c dlgsyh5nxj44XprDhOUtGuMoByKVvVkM1P59b3SIuHQE0SgJNnusCC5MImBMOoc4Dnr9 ihiYft2gltHWjaZJfarlh0WukArNCt9nBNbnP9iyuePd3G9wMMwZAULX/retuIhLyIBq caEna1GOpggAFfh5ker2q+7iA9imJY7XONJ8PXD/NDEkTdbVUufbkRSmUwJM1zmcHWm4 lhDA== 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=kcQQwhe8tbvIkqlEv04wiqdNqDeAeBEJXEVRAMnwP74=; b=iX8Ux+BoR8H0ZzQ+v0Xjwu3t3s70LsX1S1xCJK0fIStU8QHHVepLAtcAvpNrgW4GYa FBXCHX1RqRmunOwOUkXMebYXXFpYEJ42Q1Qet90MUdBcrO3Iths7+gYB9fwJ+hPG0K6D /eAzmDSGv+Jx58BahHh84fw/gnQhZf9naDJjvcQrxjp+v0IYJOLFOn8W+P0VUELSxDWL xyTqitOn7CbpBE0JLDV5SSX8BaZ4qYS8Piq1Idm9qqM3pxQMOwE23cg0DquOJxRU+yWb ePfm/npwvHtozWalqEwB8i799d1+LTyoaVPdPYzwIztjLtShqkGdMtA5mYVYYox8h/7N 8XoA== X-Gm-Message-State: APjAAAVFFwHK60xEeP72uCbmQZ80kfB4YyVbfXlUf7xdQya2wCU9wM7a 9LUZeBXAeXV46E5wZBJTxiJhXBloFSc= X-Received: by 2002:a17:902:834c:: with SMTP id z12mr9134007pln.8.1566227867525; Mon, 19 Aug 2019 08:17:47 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id r27sm21020406pgn.25.2019.08.19.08.17.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2019 08:17:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 19 Aug 2019 08:17:42 -0700 Message-Id: <20190819151743.17267-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190819151743.17267-1-richard.henderson@linaro.org> References: <20190819151743.17267-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::629 Subject: [Qemu-devel] [PULL 2/3] decodetree: Suppress redundant declaration warnings X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We can tell that a decodetree input file is "secondary" when it uses an argument set marked "!extern". This indicates that at least one of the insn translation functions will have already been declared by the "primary" input file, but given only the secondary we cannot tell which. Avoid redundant declaration warnings by suppressing them with pragmas. Tested-by: Philippe Mathieu-Daudé Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alistair Francis Suggested-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- scripts/decodetree.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) -- 2.17.1 diff --git a/scripts/decodetree.py b/scripts/decodetree.py index f6f7368774..d8c59cab60 100755 --- a/scripts/decodetree.py +++ b/scripts/decodetree.py @@ -33,6 +33,7 @@ arguments = {} formats = {} patterns = [] allpatterns = [] +anyextern = False translate_prefix = 'trans' translate_scope = 'static ' @@ -482,12 +483,14 @@ def parse_arguments(lineno, name, toks): """Parse one argument set from TOKS at LINENO""" global arguments global re_ident + global anyextern flds = [] extern = False for t in toks: if re_fullmatch('!extern', t): extern = True + anyextern = True continue if not re_fullmatch(re_ident, t): error(lineno, 'invalid argument set token "{0}"'.format(t)) @@ -1188,6 +1191,7 @@ def main(): global insnmask global decode_function global variablewidth + global anyextern decode_scope = 'static ' @@ -1248,6 +1252,19 @@ def main(): # A single translate function can be invoked for different patterns. # Make sure that the argument sets are the same, and declare the # function only once. + # + # If we're sharing formats, we're likely also sharing trans_* functions, + # but we can't tell which ones. Prevent issues from the compiler by + # suppressing redundant declaration warnings. + if anyextern: + output("#ifdef CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE\n", + "# pragma GCC diagnostic push\n", + "# pragma GCC diagnostic ignored \"-Wredundant-decls\"\n", + "# ifdef __clang__\n" + "# pragma GCC diagnostic ignored \"-Wtypedef-redefinition\"\n", + "# endif\n", + "#endif\n\n") + out_pats = {} for i in allpatterns: if i.name in out_pats: @@ -1259,6 +1276,11 @@ def main(): out_pats[i.name] = i output('\n') + if anyextern: + output("#ifdef CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE\n", + "# pragma GCC diagnostic pop\n", + "#endif\n\n") + for n in sorted(formats.keys()): f = formats[n] f.output_extract() From patchwork Mon Aug 19 15:17:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 171643 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp3127483ily; Mon, 19 Aug 2019 08:18:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqwGoeh5BaB7ljMlcFOZudCLRBMOZSP0DRlBplMBPNCFagEVGEEBVByAfDEWCK+JdH3dLIsW X-Received: by 2002:a0c:f706:: with SMTP id w6mr10717365qvn.98.1566227901694; Mon, 19 Aug 2019 08:18:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566227901; cv=none; d=google.com; s=arc-20160816; b=SYV1q0udKqXbneWtT5XSExqd/tf+830fp5DfC2VujdrxPjjl+eIa5Vw7DZPx0qN40O i3AFgnnIyrlDrqgn1wiZLRhg42x8aA7D/6FNywu3kEi+2p7CIfE5oQ8Ljk27dbGA3PVf TZroUPqzW0R7NQPXshf/L8JgQV9AYYwUgXaj2zezaQjlLL8OM8ji5z1VGJ3SNeqXL2S2 vgpURZ2US2L+Dv5I83CXnSQrgElKKZYBAARKO9m8JTn3qDGARhnWZYKPNV/Bxl9OoZ8o bWa5lnVqlXBgd18lLku572oWFE31C4o+vO/SzwOCueCYGuQnISXyrCSiE2G4aO2ZRcvK 5Raw== 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=FYIOkeCFDs+BgfZApqGQTYKi9ofiCzdQQpabShx+clA=; b=SQR6mMH4E278JGFBhe6R+wWrjdiKcm7oBd4vuQ5Wc4+PiX4ObX+7Jfp9fa+DN3Pg6i vL4W3sa8wb5wyW+gIL9lSgxA2svF+3e86LWoYR+3+GY++pRE7zvuZjCX49iXJTBBEEEr H70L/+Akfu+pm3vj3PLdL88kcOVjeXJFRpvkAeTw3o/ZgYukJkzxk/H6TjwPiMr1r5O+ MKWToO20qNeTKZkN77BuBSbX4CxKO5cMjpDC6+IgfHpaenS/3vsS1uEACV291OwBreSH iMHfUW3i0Ufsapb+VgTEKHlipfTv5jM0heCyVS/DfLCABcqWyopZru0FVklQDyL+Scfq KPjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ltAd+58Y; 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 k11si7879904qvc.158.2019.08.19.08.18.21 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 19 Aug 2019 08:18:21 -0700 (PDT) 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=ltAd+58Y; 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 ([::1]:54258 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzjQL-0002Vh-3e for patch@linaro.org; Mon, 19 Aug 2019 11:18:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53018) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzjPy-0002Ut-3H for qemu-devel@nongnu.org; Mon, 19 Aug 2019 11:17:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hzjPw-0002Wn-Pk for qemu-devel@nongnu.org; Mon, 19 Aug 2019 11:17:57 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]:35964) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hzjPw-0002Rn-Iq for qemu-devel@nongnu.org; Mon, 19 Aug 2019 11:17:56 -0400 Received: by mail-pf1-x42d.google.com with SMTP id w2so1349214pfi.3 for ; Mon, 19 Aug 2019 08:17:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FYIOkeCFDs+BgfZApqGQTYKi9ofiCzdQQpabShx+clA=; b=ltAd+58YwCh5eaUQEsu2K4Js+5xQgGw9JIVMFYOr/3Jb49QKktf0Wb/JhDgils9xXZ iY51U5XNUY5VZMVWwBxeRzVALpmDZsvajMSGsVbP/0WGChTxiL8a4BOkln1bv0v4ioi1 +basAvd3MtrGMdhCKpaWh3UUafeJFcI4Jod6L7/qK+Zqx6/uZ+GSRWIOmUwUl5GdcIUX bvdmXYn0G/9VhlFaCTRDeK8JQoGxjuOjQMYA0MytTRqmO/nMEc4A2OFzbPUgu+6oBArE 7YIOK0FaiczpHILdMOnWdqJdPqVATWtd2rBglf8Oca8JIbaTFkHX7q/KOnC0Ujhklagz /fCg== 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=FYIOkeCFDs+BgfZApqGQTYKi9ofiCzdQQpabShx+clA=; b=V55bCHpQnZmj0vpjDXNJas0eOsDTqPJKukXk5Adi18ZVWea4fdv78XQ1ifWczWR3vv +5zybmPxmPa+VlJIeB6rq2Yq3s0NJg2SsCi8m4GQ34IryNSBL05kMsndDg2CS55jnMgB Y+oEJiowrfj5uMBoaUGjMfjhOalEoY2PAIcK8VwIGajTxv+Zd1AFr4zbY7Q5ZEKxQup8 yGw1FMdoqoWmfWhxZ67rQreB/BokQ6SetWO9+W4u7hr9DeToJDyuVyp/x48IwkkwtwfA rg7VmRPqL/5G9JKgjNPqd4GLrIEqD06jsLhE8Djw8srIonAk0Ywg/xp1HBOcqErIuCmU r49g== X-Gm-Message-State: APjAAAXwA48XM8V0soxj+oPUkNaT6laXLQ3oGOknbYYd/pEaQjyvYYdb EvkUgvjzANyIqBDCvDLXtLMrE+livQc= X-Received: by 2002:a65:458d:: with SMTP id o13mr20056311pgq.34.1566227868801; Mon, 19 Aug 2019 08:17:48 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id r27sm21020406pgn.25.2019.08.19.08.17.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2019 08:17:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 19 Aug 2019 08:17:43 -0700 Message-Id: <20190819151743.17267-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190819151743.17267-1-richard.henderson@linaro.org> References: <20190819151743.17267-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::42d Subject: [Qemu-devel] [PULL 3/3] target/riscv: Remove redundant declaration pragmas X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" These are now generated by decodetree itself. Tested-by: Philippe Mathieu-Daudé Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alistair Francis Acked-by: Palmer Dabbelt Signed-off-by: Richard Henderson --- target/riscv/translate.c | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) -- 2.17.1 diff --git a/target/riscv/translate.c b/target/riscv/translate.c index 8d6ab73258..adeddb85f6 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -708,26 +708,9 @@ static bool gen_shift(DisasContext *ctx, arg_r *a, #include "insn_trans/trans_rvd.inc.c" #include "insn_trans/trans_privileged.inc.c" -/* - * Auto-generated decoder. - * Note that the 16-bit decoder reuses some of the trans_* functions - * initially declared by the 32-bit decoder, which results in duplicate - * declaration warnings. Suppress them. - */ -#ifdef CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wredundant-decls" -# ifdef __clang__ -# pragma GCC diagnostic ignored "-Wtypedef-redefinition" -# endif -#endif - +/* Include the auto-generated decoder for 16 bit insn */ #include "decode_insn16.inc.c" -#ifdef CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE -# pragma GCC diagnostic pop -#endif - static void decode_opc(DisasContext *ctx) { /* check for compressed insn */