From patchwork Tue May 23 12:04:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 684898 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1674048wrt; Tue, 23 May 2023 05:05:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ60MzcICO8CMtwgldCIhtotFZZgjncx/EcWouF4ZNgFyTMLIVnHFC76/u74ts2fGE1SpWM+ X-Received: by 2002:a05:620a:6017:b0:75b:23a1:831a with SMTP id dw23-20020a05620a601700b0075b23a1831amr4089744qkb.21.1684843540653; Tue, 23 May 2023 05:05:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684843540; cv=none; d=google.com; s=arc-20160816; b=qfdZd+/q1aTx3cziM+25H9tjpfLVF84n7zOXt8w5CZw1a5XIrIR5PGpLyjv9zxi554 B75PNToR3V+nsrFxYpuZ7NsDVY/Iutdlgu6ho32FrmNdpQ81cspGEKI9Gi6L18xLu44V 8BURwQdR10eYfsv/mDEl30Ldj45H8feIXmAPjdaJjZiIZ4dkLt18kkSL9zwgXcUpUHo8 PX0ujw+u3RPlMowdyI1jIuF2+3PZfdFv0vLn/pEISwg0yfp2uW2YwHhBnRyzAxMqc16y U7Spxn+3Z7ZDww2sHpQOjFc719Lx8UnczaE24jknvmXKShGagFLtIKhKstZejOy8LsJd aqIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=BdpkvDlA4UmVXiobxDu+YLmGZsz0CGX9FJr5LiiDCI0=; b=O4y8nbGLDRkzXqx6vgLn9tw9XfEZFWcvCb6MdF8HcUHZujCv2srsUPpsapcMwOplyM yI2pKJrERNYuDSLYRbnRioPLlB7YAUqAcN/meK9VjtQX3K6/gLbE7EWg5ByjKz0oIYy3 487eI8TzTvVuyBg5vhRrBCeiEXEAk6suGDAGnXZYm+4mrYjbowS76ZIvcu2EAQkB/E5n SIbVAo3V7UCjkjs5IHhNLVepK1jdb3kzwiSOPVr3RpHOBeFgoJiwyBfd8lgdWrc/K2Hy N7bS4XwvwruIe54tz30b6xkSQn03hGY7JonOIC0WgtmB6EnD0HeyKE5YcnhbPENmAbxc FDDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BoxleB2f; 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=pass (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 z24-20020ae9c118000000b007577bd16a23si4610695qki.434.2023.05.23.05.05.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 May 2023 05:05:40 -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=pass header.i=@linaro.org header.s=google header.b=BoxleB2f; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q1Ql6-0002QK-4R; Tue, 23 May 2023 08:04:56 -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 1q1Ql3-0002Oa-PE for qemu-devel@nongnu.org; Tue, 23 May 2023 08:04:53 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q1Ql1-0008QP-N0 for qemu-devel@nongnu.org; Tue, 23 May 2023 08:04:53 -0400 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-306dbad5182so4831567f8f.1 for ; Tue, 23 May 2023 05:04:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684843490; x=1687435490; 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=BdpkvDlA4UmVXiobxDu+YLmGZsz0CGX9FJr5LiiDCI0=; b=BoxleB2f7RstIIcpPHNcsvRnHU8L1GFuE1Al8cFMs94kTlJF5SUvWSUaeklvXVMrVR YXFEFDFlxrYSn2dIsA2bZSk6Y9avndyIKCielqXpXoTXnu7P3lO+VzvB8D63QujxU9V3 nzB1bC7UGRoD1cci8/E4tnSBUQMJrmIJ+3fFsY4qNiVpyeIb0Rv6+ATcDpmmIVp9lfx1 TJWjf3uOQSWBURWt4rGXli8R8qBkaap5TqEmqXXHn54vEEsthKCgmvUQtv2tm+hXSrd7 RLTAeBr2KTgnVZrfUZPr6TMdsvxrxM9ErM88uXPTeZoc2oCtPhekPbMwmyCDg7Gim2S4 Syrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684843490; x=1687435490; 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=BdpkvDlA4UmVXiobxDu+YLmGZsz0CGX9FJr5LiiDCI0=; b=fj8z2SIhi8Y4FdLQgQ5DLpf/fAPq9AE08/Bt58O0L7Myp6+YxeD02R0vmkQXqsZcaD nO59fLNhsbYPq04bVqXm6Rkgo8+73LPOv+aIaPRGoVNTb3WGyIYoCSq6K25guUY0+9xO cRAIaW2CrM7qjGB1nSlDiICwaA8mQ980GIihX7bq3aePcA/7xDnXvqMC2Hlmc5JO+DiE v3l/ynqSK9bH5dU8tRY3APWAO0EmRp6Jr6kIfCuR4bKhnYrf12Tyfb5GH94QkkmNFA2+ 1dSFDfLPeypmEuSaZcPbpFE5BUeOGppu1nhpm8ah4pYDebwLc3rCkwjC0baubRvLiIEw 2G7A== X-Gm-Message-State: AC+VfDxRKS+q3pina0uoEL6obA9jG4DF7E/9MqfCDoJwLJAYmwzHnVKg HV4kxrNgqHJyIFwvMxIK+jvOp0yJrSSZODf4ZIU= X-Received: by 2002:a05:6000:1285:b0:307:a58f:5f7b with SMTP id f5-20020a056000128500b00307a58f5f7bmr10123157wrx.64.1684843489899; Tue, 23 May 2023 05:04:49 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id l17-20020adfe591000000b003079c402762sm10848778wrm.19.2023.05.23.05.04.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 May 2023 05:04:49 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PATCH 2/6] docs: Document decodetree named field syntax Date: Tue, 23 May 2023 13:04:43 +0100 Message-Id: <20230523120447.728365-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230523120447.728365-1-peter.maydell@linaro.org> References: <20230523120447.728365-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x433.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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=expand_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=1, 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 --- 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 49ea50c2a7f..e3392aa7057 100644 --- a/docs/devel/decodetree.rst +++ b/docs/devel/decodetree.rst @@ -23,22 +23,42 @@ Fields Syntax:: - field_def := '%' identifier ( unnamed_field )* ( !function=identifier )? + field_def := '%' identifier ( field )* ( !function=identifier )? + field := unnamed_field | named_field unnamed_field := number ':' ( 's' ) number + named_field := identifier ':' ( '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. +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. 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 +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. -A field with no ``unnamed_fields`` and no ``!function`` is in error. +A field with no ``fields`` and no ``!function`` is in error. Field examples: @@ -56,6 +76,9 @@ Field examples: | %shimm8 5:s8 13:1 | expand_shimm8(sextract(i, 5, 8) << 1 | | | !function=expand_shimm8 | extract(i, 13, 1)) | +---------------------------+---------------------------------------------+ +| %sz_imm 10:2 sz:3 | expand_sz_imm(extract(i, 10, 2) << 3 | | +| !function=expand_sz_imm | extract(a->sz, 0, 3)) | ++---------------------------+---------------------------------------------+ Argument Sets =============