From nobody Tue Apr 15 03:59:03 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1685473548; cv=none; d=zohomail.com; s=zohoarc; b=Jw6thwvmqTzyfohDbwjl7Hm8UpKOZY8xsOx3Am9IcXY2xpwF723PsZoDQRld695PEo3w4Gj48H1tvJyhs4Xqs9NZNiIk6Ws90emacuLaoGIwmRJYwfDziVelOKspYfPt9/W4a6fNYqXn8il2uYWPTzz/7/hR2addMx45O8T+6m0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685473548; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=SOSY1OWrbK4eSo0NG6B7wYDOM6jJQSGNupGv5PeOSxU=; b=XeZoFndaz7rNl86ckctFnoNeE6XAH03Z4xZzKH28yP99B89oOqGA25J/tTtW2XvEp276bX7saQgNHTKGrznwCMEYg2uyjH+gp9ZV7x9c2vo6LsZEID6lQukfEwTi8VCOPLH3fN7rJEyUYxGam+sNHDp1O5OysJUzvi/fqA9ykLs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685473548795578.7223341409343; Tue, 30 May 2023 12:05:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q44ab-0001sR-Ge; Tue, 30 May 2023 15:01:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q44Zq-0000t6-RO for qemu-devel@nongnu.org; Tue, 30 May 2023 15:00:16 -0400 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q44Zo-00019c-Nj for qemu-devel@nongnu.org; Tue, 30 May 2023 15:00:14 -0400 Received: by mail-pj1-x1034.google.com with SMTP id 98e67ed59e1d1-2563a4b6285so2742413a91.2 for ; Tue, 30 May 2023 12:00:12 -0700 (PDT) Received: from stoup.. ([2602:ae:1598:4c01:35a2:c45d:7485:f488]) by smtp.gmail.com with ESMTPSA id g18-20020a63fa52000000b0051f14839bf3sm9128496pgk.34.2023.05.30.12.00.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 May 2023 12:00:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685473211; x=1688065211; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SOSY1OWrbK4eSo0NG6B7wYDOM6jJQSGNupGv5PeOSxU=; b=PT34K9MXldOFNIa8qEkbe+Mhze36kuVCEsuWonrdMPbIrlL1BN4Cy1yRsqLGrkwi1g YdYJJb8X2teVfqA/Oyb6/wvzBotO84Z/+XmfHexX0Tdcf92XEr6aNosRTSpUIThFfO3g LjuE69pdraxkIZJyW8CJkK8eYXwn9tkWxTnRA30NuupumootTs/bx8DiDOf+INnf+mvC Ee08jjCOwwha9CD26zGDQyAf3PR/cnmBXWfkyzcwkrrRZxQIQSFu5B1FshVquJY9+7s1 V3QBQycVsh1xucKApmj2n/JgCSYT1QpZWFI9CedSnzJSvrmKHQJkNRtMtOJjNE1UoRN+ +ITA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685473211; x=1688065211; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SOSY1OWrbK4eSo0NG6B7wYDOM6jJQSGNupGv5PeOSxU=; b=KdQwhyS6jSSoJniloDZ0QSFQ4Zh+pEagtGJ/sUngZUtDpwcHSY4aDyOxzIAB1syTpe luYFwUQYQsFxMA/QHXth/otUPe5QFa8TU3jAitrFbjfu/8glK+OflqqIXYKroL0gNohs vISTNpBcnadAq3+Pcedf/Hkia52aUiXc+jQf8iPY8fDD1Y249VlDAsIXK25bUAIfQ0ZU tTpZbJmzKonUr4Rzu0hAxLRW9/fXjOQwZnLxCCnVRN814HY3PbvS1GsFqHblSxkQuTNr DymUN7j2WmI96k292j3K1Z9nrs6Gzps9SRANi+iwBFyY/yNIABdizr42DFJgWHf3SPqC 6C5Q== X-Gm-Message-State: AC+VfDz27lAKzuxAPFfnsL1sdQjDsdq1J1PZhV4LAE1ViVuXHkoqIOs4 ueowsmqyPJ0bhf5dNJrCLegSmURwGIlu+RK2I38= X-Google-Smtp-Source: ACHHUZ7v9i2SYvAa7cMN9T+iQvz8ixsQBqJ5tSM4zEZL/2xw0BHgv6DwdD+DgouFrTh1V+Ac+sFdaw== X-Received: by 2002:a17:90b:4c06:b0:250:6c76:fd9b with SMTP id na6-20020a17090b4c0600b002506c76fd9bmr3097147pjb.38.1685473211161; Tue, 30 May 2023 12:00:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Peter Maydell Subject: [PULL 23/27] docs: Document decodetree named field syntax Date: Tue, 30 May 2023 11:59:45 -0700 Message-Id: <20230530185949.410208-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230530185949.410208-1-richard.henderson@linaro.org> References: <20230530185949.410208-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=2607:f8b0:4864:20::1034; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1034.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1685473549847100006 Content-Type: text/plain; charset="utf-8" From: Peter Maydell Document the named field syntax that we want to implement for the decodetree script. This allows a field to be defined in terms of some other field that the instruction pattern has already set, for example: %sz_imm 10:3 sz:3 !function=3Dexpand_sz_imm to allow a function to be passed both an immediate field from the instruction and also a sz value which might have been specified by the instruction pattern directly (sz=3D1, etc) rather than being a simple field within the instruction. Note that the restriction on not having the format referring to the pattern and the pattern referring to the format simultaneously is a restriction of the decoder generator rather than inherently being a silly thing to do. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-Id: <20230523120447.728365-3-peter.maydell@linaro.org> --- docs/devel/decodetree.rst | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/docs/devel/decodetree.rst b/docs/devel/decodetree.rst index 49ea50c2a7..e3392aa705 100644 --- a/docs/devel/decodetree.rst +++ b/docs/devel/decodetree.rst @@ -23,22 +23,42 @@ Fields =20 Syntax:: =20 - field_def :=3D '%' identifier ( unnamed_field )* ( !function=3Dident= ifier )? + field_def :=3D '%' identifier ( field )* ( !function=3Didentifier )? + field :=3D unnamed_field | named_field unnamed_field :=3D number ':' ( 's' ) number + named_field :=3D identifier ':' ( 's' ) number =20 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`` a= re -present, they are concatenated. In this way one can define disjoint field= s. +present, the field is considered signed. + +A *named_field* refers to some other field in the instruction pattern +or format. Regardless of the length of the other field where it is +defined, it will be inserted into this field with the specified +signedness and bit width. + +Field definitions that involve loops (i.e. where a field is defined +directly or indirectly in terms of itself) are errors. + +A format can include fields that refer to named fields that are +defined in the instruction pattern(s) that use the format. +Conversely, an instruction pattern can include fields that refer to +named fields that are defined in the format it uses. However you +cannot currently do both at once (i.e. pattern P uses format F; F has +a field A that refers to a named field B that is defined in P, and P +has a field C that refers to a named field D that is defined in F). + +If multiple ``fields`` are present, they are concatenated. +In this way one can define disjoint fields. =20 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 +One may use ``!function`` with zero ``fields``. This case is called a *parameter*, and the named function is only passed the ``DisasContext`` and returns an integral value extracted from there. =20 -A field with no ``unnamed_fields`` and no ``!function`` is in error. +A field with no ``fields`` and no ``!function`` is in error. =20 Field examples: =20 @@ -56,6 +76,9 @@ Field examples: | %shimm8 5:s8 13:1 | expand_shimm8(sextract(i, 5, 8) << 1 | | | !function=3Dexpand_shimm8 | extract(i, 13, 1)) = | +---------------------------+---------------------------------------------+ +| %sz_imm 10:2 sz:3 | expand_sz_imm(extract(i, 10, 2) << 3 | | +| !function=3Dexpand_sz_imm | extract(a->sz, 0, 3)) = | ++---------------------------+---------------------------------------------+ =20 Argument Sets =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --=20 2.34.1