From patchwork Sun Aug 18 06:39:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 171557 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1458061ily; Sat, 17 Aug 2019 23:40:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqy5ZTTjIqZyfrhKojtbdqk8/wflfYy7LITwP3WM/UFezOukdr8Ka5UjETr/H9beVC+qJoYr X-Received: by 2002:ac8:1a36:: with SMTP id v51mr15823288qtj.201.1566110452278; Sat, 17 Aug 2019 23:40:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566110452; cv=none; d=google.com; s=arc-20160816; b=iNMpV5aIw1XEV6S0D74tgnF3+dNWFs8FOOmnQ+e4Wp9NloNCu5TV+sV+tgJBz6HCXg vhMUzilZ+KP0Xz5Nutav+GDFsQmxVI0Y+1Av7UQGFlcB8YEo+3mvbhJHgqtsn0RU6ItQ QcVimfcrGC9aydIziKmMyzxdXorjcz/53w0Y+DOpBfcS8wXR0GTg/PpzjKMLWd2JeHtr MfqUEJ3wMz1UT9tX95YEylF/wcGBKRsF/rE+d8s5epg8cS3L93ObGdYLicC+ZFZ6M1tp m5PAEuVZHXLIyaHUfQh4M9G5Y6SQE7ugDIUp3bhkQ5KRSGTgb8/iDXRzCrS9HHydjMaw H8/Q== 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=ndW1MBgJZz0GTxmVD7WEDsm+sYC3ktueJpfSWfiaaTM=; b=LlIJxTd5B6hYNY1P3kU63qL669WBKLjupie4FD5fORbb3dqQ8EyajIIW+oxSRJ4kX7 j4dxGM+E1os0XaZhZpuWYbpcFo7CHU0c2z+mBOfT6QENsj/YdUCAv8PFKvlY4SEHBKY/ 3BvoYl+C0GP3As2HuPH6N5J/KScHYgnRM+M3PzcwysdxezqZh2XKGSzV/go4j9WxTBua OdI4Yd7Ml9gqv0NL6kymr/CHHJMfmG11tiQmj1ESx2clIB2O6zV8R1KDA6DZIEV8suyh BF7jWE5B4oGZUw3958nos4jJ0QzRxBz5j5GdKwX5q9ReKhMXLqxJXEQBSDffmzdH5YCy CBtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=qoY56WUD; 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 y47si6550931qtk.345.2019.08.17.23.40.52 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 17 Aug 2019 23:40:52 -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=qoY56WUD; 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]:39456 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzErz-00057E-I0 for patch@linaro.org; Sun, 18 Aug 2019 02:40:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36390) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzErF-00056J-NH for qemu-devel@nongnu.org; Sun, 18 Aug 2019 02:40:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hzErE-0000k7-Ev for qemu-devel@nongnu.org; Sun, 18 Aug 2019 02:40:05 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]:53149) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hzErE-0000jl-9G for qemu-devel@nongnu.org; Sun, 18 Aug 2019 02:40:04 -0400 Received: by mail-wm1-x332.google.com with SMTP id o4so340101wmh.2 for ; Sat, 17 Aug 2019 23:40:04 -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=ndW1MBgJZz0GTxmVD7WEDsm+sYC3ktueJpfSWfiaaTM=; b=qoY56WUDRp6DtmMmltOtCtCTw4MUD/Bv76rI9FOuCrfsHp08pjhiZ2MYi5yxJehjcQ w4e346MZwjgUBxjJmHNW8rSTLlN5uPvPJ0Gv8gtlRQjpTprkmQ3VhHq0y+tpzjhmrlSQ DmYe39POfLI2JSnftP+vCzTolbTgB+7Vl4B5xsDs5JMthov+VfrV16uMWwqyn6DlNs1X V2F+s5WOXScUBu5en1rdPYenF8M0e2F3Cgz8RoB55s6g8bBWD0QFIH2tX8zZ3blq8Z+k gfs9b0eRdPhcLlI7Ee0KKmF/npsP0hiw71wA5K7qWsOvQvX8H9FYaRFZ/Ah8OBuYrQC6 mYUw== 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=ndW1MBgJZz0GTxmVD7WEDsm+sYC3ktueJpfSWfiaaTM=; b=RAlzgTyujKqFXylhj+1feHCUg0TsEQBptJTfHfHUljXhypjfI4xZ3aTFEUt4jQFx7E LIYLbE31FYnSjejbT6/ipwIPXuGMLdVUNFeIrqFUr4bkUcQHKA0JzT4wDajnO6JkXnSJ wNx2ID5kmkI6NuTIoawnbaXaTtdsiDNSjvKFs03QPT0XIR3NAXX9v8Xlavhj98uu7jy/ 4rok6xiLgxqaL46kAKRD3s+Xt+W98kl8C9OViH/y4jYGo/Jp8SQa2ZKuHIavS+JOmNqg Ao2jgl6zgtotUvLON79XnS6kTbGxKYedVSLuJarj44iSe9QXDB784oQaAeA/RYH+Jr9b dWtg== X-Gm-Message-State: APjAAAWLkm12ExoJaSvh+XfTYjYVQV24za9xfPE1/Sivf9vF2u+CM5NM NY8RxXuJ/UTt/89QCwJWe06ctjCTQTU= X-Received: by 2002:a1c:1d86:: with SMTP id d128mr13225477wmd.123.1566110403060; Sat, 17 Aug 2019 23:40:03 -0700 (PDT) Received: from cloudburst.Home ([2a02:c7f:a69:1700:8897:9507:94c2:b98d]) by smtp.gmail.com with ESMTPSA id r5sm9015435wmh.35.2019.08.17.23.40.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Aug 2019 23:40:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 18 Aug 2019 07:39:57 +0100 Message-Id: <20190818063959.14533-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190818063959.14533-1-richard.henderson@linaro.org> References: <20190818063959.14533-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::332 Subject: [Qemu-devel] [PATCH v2 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. 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 Reviewed-by: Philippe Mathieu-Daude 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..31e2f04ecb 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 FunctionField + + 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 Sun Aug 18 06:39:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 171559 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1459026ily; Sat, 17 Aug 2019 23:42:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqzvVsWqoSOr7Q6SodawxrQO6HD5fVud44gyFbx9FSaOUP3rKdI5mZJr1s9WU2UUNR8LrVgv X-Received: by 2002:a05:620a:1254:: with SMTP id a20mr15876845qkl.162.1566110539243; Sat, 17 Aug 2019 23:42:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566110539; cv=none; d=google.com; s=arc-20160816; b=V9ATy39B/zhRhFnht4k4QCJ8KuxyTxBH6qBaJxB+QfrlQSOmSDWsKuXrYWJNM+SRDq gFCbSMfBoD2N4Xy+NV70O7LCcvFEF0hSBQxBsZH6DZrDMBY+1PwOChKOD8bWoyKV8ElM 5Yu37elsGuA+UDMCX9DKSStcG2tubO742/8XBzadNuZ2ERyG2fGv9NpOKaOgCUIlhYO0 pHJwq9RFaW5iF1+W8AjNxTDoqSu9GhLR8I/mqeooH4Bh43FBBnguOS0/PPJpd7kXdyQV 44NZEXZcUPupR1BlkeoRBH4oY56CeMlUGtqNT2oyE1XhPOUO50YI1+tBWUcvusGM/We7 00cg== 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=tKxbBo5PP5QzWeZGavSTCFjk6sHISgddhsvvpM6xVYM=; b=SnqSlI8VeaMHxtPwex9+yjV5wEQYjzZiVKX+Bong64o5JuST6VBEnQDHNr52EkRAFe mmg+SZPAry2EDW92B1hJ0LEfo9+TVHOsGGdCYi8AA51SxpawcUJJ5ILu8poZtv5waV0m VPtsnGnFJrACmV3h0RqaNYQ9BtGsglOrO6X/PKRDa6qXW3JVDW0sLuyYOntyWOjN1ZqH K4TJG+T98FiIwWis8FXGSNAvII3SXihpDu7McwPkNkJBYYplwQcjk0tpQW8C8f04/LzL 9A5cr3UaL6+V7FJS8iOUS+PYbeRRQgCaIQrS2qngi3V2DN+SdKLdpl+JaCsObGOusHq/ J1Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=QrWWzm8E; 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 k29si6673560qtc.262.2019.08.17.23.42.19 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 17 Aug 2019 23:42:19 -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=QrWWzm8E; 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]:39487 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzEtO-0007o2-QL for patch@linaro.org; Sun, 18 Aug 2019 02:42:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36401) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzErG-00056P-K3 for qemu-devel@nongnu.org; Sun, 18 Aug 2019 02:40:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hzErF-0000kZ-EB for qemu-devel@nongnu.org; Sun, 18 Aug 2019 02:40:06 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:44391) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hzErF-0000kC-8K for qemu-devel@nongnu.org; Sun, 18 Aug 2019 02:40:05 -0400 Received: by mail-wr1-x429.google.com with SMTP id p17so5409153wrf.11 for ; Sat, 17 Aug 2019 23:40:05 -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=tKxbBo5PP5QzWeZGavSTCFjk6sHISgddhsvvpM6xVYM=; b=QrWWzm8EiDh7WQPpLMtGfaJRXKnuIwFPVtvShtsqBBwHC/LXMWst5dTO5QoQMxIBMo rBG/GwsyU6BdjbVRZbphzqiU/N556v97REuB7Vms8OxweRc6DQO9R0Pwwm617wHM+Jd2 lPFNSAMmJHGcXDxx1eI5ONHTPmuwmdvASQOd41oedznlBgtMtLvFPLk9CbfjIU2uU0GY o6+EUuzMMEPPIeKm2UqOPUeB5SyBp6I3Kvmim73WljLny4YbM3iJuztqICrz6nVJJR9g OudK3nUmfhxHR++7NEFUwPeZUBVHG5/simi/kAE1lCnFUdha0KtEXEvVubyJQR+AY8tx xpVg== 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=tKxbBo5PP5QzWeZGavSTCFjk6sHISgddhsvvpM6xVYM=; b=HKoNQVd37wb8uJBLmkMpo21biaH8yVJBeFJ/6VKGy/BQdY+CrrK++T3k51Lwn2Ttgs liCqosHPLr4RQVouon3oElv0Ukr1WF+1P7Fglzd5bjQCG0iRpcAPFygkN4lHoU2fUiu0 /EjlArgYXn3Krz04lUoCzoixvmyGXDh6Yt+DJ6m+m8TvOzAA0y7g+Fg7Amx9XcTdQX3Q 5tNR5QK9YcI2iiaUUFAEX5yfeApimGXwpM1/GD4Wj181jor4SaV7UuTfclwH47Jq4c5S VBn2L/4dRsXq6rxvwPyvBC4mjLTBNUpq5dZ7U6pLuPz6WXqQFtBYgEndwDIZpFEh54u2 8dLw== X-Gm-Message-State: APjAAAXdbeZ50F0uYTxlB71vUz5t+Nx80+s+3IPuKKZYuOEnGoaHw3wn Ymtn+iGfd/EXyvx5svvjTkFdxVDgc+U= X-Received: by 2002:adf:8bd8:: with SMTP id w24mr19589296wra.273.1566110404020; Sat, 17 Aug 2019 23:40:04 -0700 (PDT) Received: from cloudburst.Home ([2a02:c7f:a69:1700:8897:9507:94c2:b98d]) by smtp.gmail.com with ESMTPSA id r5sm9015435wmh.35.2019.08.17.23.40.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Aug 2019 23:40:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 18 Aug 2019 07:39:58 +0100 Message-Id: <20190818063959.14533-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190818063959.14533-1-richard.henderson@linaro.org> References: <20190818063959.14533-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: 2a00:1450:4864:20::429 Subject: [Qemu-devel] [PATCH v2 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 31e2f04ecb..12c1cd0ddb 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 Sun Aug 18 06:39:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 171558 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1458109ily; Sat, 17 Aug 2019 23:40:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqzR1x9k8qg/VOOsQ+fSxeR5d5TmFiZN3FFMBElDSnp30IFqiYUrh9OZsxSCdr87fhbY3HQw X-Received: by 2002:ac8:24ce:: with SMTP id t14mr16436952qtt.246.1566110456474; Sat, 17 Aug 2019 23:40:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566110456; cv=none; d=google.com; s=arc-20160816; b=aeEJTgBfFtJH16pYZFFWDEOWvzfwEmHPdIm+6GCuxu7fH4/Z+JVAI0jth1dj2r//jy qyPIIoQje6YwJzUVP+5UX9pS0p2z0fYzTWzGF6tbqAibjL+RbVvvC3KnilN38HYekWW7 OL4MOatxDFcrMQmJZ4kZSSkPRZLhhgjH1hfvzPaWLFmIqRedL15hsMvOwDZDPl9E1gex ZBvOsJVtdlWWhw1CtovHxPM45VLPnZnepFMmCm1TwZAnwsJMWFUJPZuvqoBzJazsiRfk 0XZ+ZKdrOMJVT47SQqwUHmdnPC6D5S6xAJ4eJoHy21wKmoQIXQknp4/yHOI3eVBkxzwY a8GQ== 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=0DnDEadKIDpru13c66y/4Vc9BejJq5p22ZK5RT9Dp9yAZekExvyQF1etHaA1KXv2s7 oJbivA0z1YrGy0j2EAInSs7cG7k6f7N8DWjyGvDb7WzWzRJBrKhef4Q9fL0W9R8Vb6gN EHROrHHKswllxJ8SegYx59R9AtUWRNQTRsyI9YzEAleBevPV/jAYL5SfITDBQaWLBwit dkrUZr6DqUE3cRkm11kghIE4uca3J05yqBYvBU+HNhv64n8WS1dVRdVUovngcexTm+Tk 3z1vHZyqR5VCwOtO1rnjBR+t5tib4iRfYgkmKVJGg30zcfivvf0JYCDuoymU0keUbA3h zw2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=BxZybswZ; 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 d47si6751527qta.287.2019.08.17.23.40.56 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 17 Aug 2019 23:40:56 -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=BxZybswZ; 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]:39462 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzEs3-0005Bn-Rw for patch@linaro.org; Sun, 18 Aug 2019 02:40:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36412) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzErH-00056m-Dt for qemu-devel@nongnu.org; Sun, 18 Aug 2019 02:40:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hzErG-0000l6-D7 for qemu-devel@nongnu.org; Sun, 18 Aug 2019 02:40:07 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:35168) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hzErG-0000kj-7A for qemu-devel@nongnu.org; Sun, 18 Aug 2019 02:40:06 -0400 Received: by mail-wr1-x443.google.com with SMTP id k2so5419293wrq.2 for ; Sat, 17 Aug 2019 23:40:06 -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=BxZybswZd7mlu+zDCl5EE89cpB9LSXMOaG1bQ9ORBc/RUuO4kufMVcGrJq1K5jYFnz XAGVT6NFoIp1yASZaG5MGtdTK2bKh0BbogAC2vkDnX7xuRHosUOJ0NIypSm5stslzAK/ A5UsOJl1JeTiStn9qdHGVzwV3wcDYt+CfpxbKc4UPV45IPExGZ4auhe8Sc32UnCkDEkX wo3tNxrTFI4b4HoBW4WqCjI55n+EmJhAcS5+8Tg04JCsu/CnG3a9/W1jyhy51vbgV/ru 7rTqTybEHzi1T/cMMfY+xnsq4ed+J2u6mNDtBcMUbKyvAXlf4+P4Exe2PZYbCCY6CmBg JgKQ== 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=Ul/cNb5OL2FFR2IfHczTlVhWZ9CdJ5kPjwbJ1ELNfibTfCVG9Ue0H1UEYQQfpRRhOS nMUS9Q8zUPb63+tmXd3nixBTFqPBtKhur8I34S96SY9qFGpvYdUs/RhNTGuLLGludaE5 lRxlEsDGmJLOyWZ0BZOGjusFjKlHyWPSlYvJe988QkuKtW1oyrSaqwQJ2gpQeEEUklW+ 8NI1A87v6Madfl7GJIuaVv+7SEs2THSAZvaMhZ0gyVyyY5W3vX4kGsEWclZ9NSDPB/PR 5Y+9zrdIWk+0v/rLp4qBjT6N25OkU65TndrkUogpnWvgDTc297+V4TxGG0ocQ/5Hibi7 qeug== X-Gm-Message-State: APjAAAUXms8aobn2/CuLkFlwXlCUuEvWT/PtUuKMODNXOtOkV4a+JHr/ q0fchHpYDwkXDMzFcb/iP8scUOwyHck= X-Received: by 2002:adf:f705:: with SMTP id r5mr19188340wrp.342.1566110405026; Sat, 17 Aug 2019 23:40:05 -0700 (PDT) Received: from cloudburst.Home ([2a02:c7f:a69:1700:8897:9507:94c2:b98d]) by smtp.gmail.com with ESMTPSA id r5sm9015435wmh.35.2019.08.17.23.40.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Aug 2019 23:40:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 18 Aug 2019 07:39:59 +0100 Message-Id: <20190818063959.14533-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190818063959.14533-1-richard.henderson@linaro.org> References: <20190818063959.14533-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: 2a00:1450:4864:20::443 Subject: [Qemu-devel] [PATCH v2 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 */