From nobody Tue Nov 11 22:37:30 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1566228029; cv=none; d=zoho.com; s=zohoarc; b=Qezd12qpinGyz1CR8kc2jOITduJVBHegO9DfSYqbnpsij2ilP0qvqEcC/pSuxAMKNuA+ua8DeyMF5556G6UbPJfk4B9IGT3jgvgRPYahwoGABPIOya1MVJhBkTZFCf6HdMu4XZ++5cu/1WZdcRsZaeDIu3lrQT4OiZdUnwpuGFU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566228029; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=aAsgcvP1KNeiO2DyuHvEBM+1rf528V/HzEzeINYjmQQ=; b=Be1axQJuT5OtKO6R3j4YEZbStz7myXx69jvNrGmRdw71VJIJ7KHvLGRXDbEAccJCCxgIFMOKi7e+NqE4cmXWHgzr6EkD/MKLpblPu7yPKARYk0aA09tD5mbSODj1Qg0fzLLed1pg0WT9Wrk/dxYDyQTijy5lX5q2zgo1t2iWSNk= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1566228028905791.5055698002901; Mon, 19 Aug 2019 08:20:28 -0700 (PDT) Received: from localhost ([::1]:54280 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzjSK-0004By-2U for importer@patchew.org; Mon, 19 Aug 2019 11:20: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) 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) 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-Google-Smtp-Source: APXvYqzOb3flQFpF/coP68QsC0S0Rp+nwTy6EsLIlNSvOA5qc00fB/LgSUjQkCy+4DF+sB+Ie8k9XQ== X-Received: by 2002:a65:690f:: with SMTP id s15mr19835734pgq.432.1566227866271; Mon, 19 Aug 2019 08:17:46 -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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 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 =20 Syntax:: =20 - field_def :=3D '%' identifier ( unnamed_field )+ ( !function=3Dident= ifier )? + field_def :=3D '%' identifier ( unnamed_field )* ( !function=3Dident= ifier )? unnamed_field :=3D number ':' ( 's' ) number =20 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 def= ine disjoint fields. If ``!function`` is specified, the concatenated result is passed through t= he named function, taking and returning an integral value. =20 +One may use ``!function`` with zero ``unnamed_fields``. This case is call= ed +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. =20 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: =20 =20 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 =3D base.mask self.sign =3D base.sign @@ -266,6 +266,27 @@ class FunctionField: # end FunctionField =20 =20 +class ParameterField: + """Class representing a pseudo-field read from a function""" + def __init__(self, func): + self.mask =3D 0 + self.sign =3D 0 + self.func =3D func + + def __str__(self): + return self.func + + def str_extract(self): + return self.func + '(ctx)' + + def __eq__(self, other): + return self.func =3D=3D 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): =20 if width > insnwidth: error(lineno, 'field too large') - if len(subs) =3D=3D 1: - f =3D subs[0] + if len(subs) =3D=3D 0: + if func: + f =3D ParameterField(func) + else: + error(lineno, 'field with no value') else: - mask =3D 0 - for s in subs: - if mask & s.mask: - error(lineno, 'field components overlap') - mask |=3D s.mask - f =3D MultiField(subs, mask) - if func: - f =3D FunctionField(func, f) + if len(subs) =3D=3D 1: + f =3D subs[0] + else: + mask =3D 0 + for s in subs: + if mask & s.mask: + error(lineno, 'field components overlap') + mask |=3D s.mask + f =3D MultiField(subs, mask) + if func: + f =3D FunctionField(func, f) =20 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 late= r. +# 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 late= r. +# See the COPYING.LIB file in the top-level directory. + +# "Field" as parameter pulled from DisasContext. +%foo !function=3Dfoo +foo 00000000000000000000000000000000 %foo --=20 2.17.1