From nobody Fri May 17 11:58:52 2024 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=1619895782; cv=none; d=zohomail.com; s=zohoarc; b=TtM09vtmG86+HZEzudEWXskvxXNNNuFglRMWTmNdwrYh19ZVqk4f35Bf/ng/Ktj4qIJ6Ko0MDn+g7etEjWRvo9T+qnRHs0U8459TCtI8+kISGi33Lvqo2HBeEoz7bq4hKGjiMgAVbBCTzuxl850J00Fs5UzsRxJKbkNGfgTAbuE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619895782; h=Content-Type: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=MSp5lRgjBRrXqczyQWvsoXEiHZoFgBy6aeylHhLetBE=; b=K2iXq/e4AwosyNx9g6iH73lvO10ws/D9GPt4smtZa57BTVsh9E/iL3kodm7xQrxAm1Iso2FHIGWTnshxKqn97Otd6ZsuNDErUWhDfO1DO05qR0SpUctmPQUicj9EWFuulbF/JxcpUhrjMLTlxT8wVzraa9tEL6tEDTDqZQ+zDEc= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1619895782856989.3518545621266; Sat, 1 May 2021 12:03:02 -0700 (PDT) Received: from localhost ([::1]:42188 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lcutJ-0000fl-Nr for importer@patchew.org; Sat, 01 May 2021 15:03:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46388) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcui2-0006Ti-HB for qemu-devel@nongnu.org; Sat, 01 May 2021 14:51:24 -0400 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]:40719) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lcuhz-0003lB-Pb for qemu-devel@nongnu.org; Sat, 01 May 2021 14:51:22 -0400 Received: by mail-pj1-x1035.google.com with SMTP id l10-20020a17090a850ab0290155b06f6267so3444760pjn.5 for ; Sat, 01 May 2021 11:51:19 -0700 (PDT) Received: from localhost.localdomain ([71.212.144.24]) by smtp.gmail.com with ESMTPSA id k17sm4971360pfa.68.2021.05.01.11.51.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 May 2021 11:51:17 -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=MSp5lRgjBRrXqczyQWvsoXEiHZoFgBy6aeylHhLetBE=; b=B+44fskOVmU0wMMz5PCemfAGi0+oR2wue0LcxEHZ4Hs/ax9Tl8UqMU4uTgDwJPkWfZ 9nnYBihzTs6U9kmxYgXAJfxO7gRt0zTcoPI4pjsuU3vEScScd5ulovKKt3Tw6CKdsi7s ckrRrvXYGbvT90yh9a+9yohXcM3wYStSaAhSd9c/ofk3XWfn16Usl6SmHBONVxll1MTz +gtwwEeal+ptRE+pFHdlKIgB6WZBAn0BIKUxW0hz7eyhSwnzKzpmvSsMyHldXF5vOSIy 8q/tWpjV6FpAeh6DTa7TtCFmEXHW2kkm2u1HjnJqVsfCR67nLUoBKBd3SFfoZyoeY2Uh Wj1g== 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=MSp5lRgjBRrXqczyQWvsoXEiHZoFgBy6aeylHhLetBE=; b=dx0JDiTNJ8i4hkAjt4eAffuOYJWTCTvWcnuaGdtOe97CsK5bMSJlMaXOE/otxMGl9i OsOWllXnqED/xQLHB+uCdvPUSnO9adYFQop2m/rF42oHEbIrIVkiP6mOkxtQRPaSex5m ZDViuT8vFuG2lha2sreJDHGkwvqc1rHx7/gGf++wGPvnbaGdidsk0ZZk802/J9v6Lf1U ggtB6KLGEt9NsycRRKASQXlkzV1QdFej9X/cizopJ2D0cKlhib8cdxRCzTMLFdD1RHwU K6dURS52Oa6u8AtUuUgGTnGE0sSdUjHT94YpcRoA+Oza87ww+YIbmNJ/oitVARfRfjYZ wS4Q== X-Gm-Message-State: AOAM532L7cMH5m1C7Rvwktqp80FUbT4MR1+sXOnibhneX71JyS9kjcgJ xD9bPEqMNBQ+nL/+tDGniAFym6TENDK8qg== X-Google-Smtp-Source: ABdhPJxF1IuJtbgcCUrTr8uom8KACQHQmADyWaiOuWuu14LtWmLGTfXX3bwOcbIld5v/6I0Uq+6scw== X-Received: by 2002:a17:902:b494:b029:e7:36be:9ce7 with SMTP id y20-20020a170902b494b02900e736be9ce7mr11537495plr.43.1619895078228; Sat, 01 May 2021 11:51:18 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 1/5] exec: Remove accel/tcg/ from include paths Date: Sat, 1 May 2021 11:51:12 -0700 Message-Id: <20210501185116.1338875-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210501185116.1338875-1-richard.henderson@linaro.org> References: <20210501185116.1338875-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::1035; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1035.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 autolearn=ham autolearn_force=no X-Spam_action: no action 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, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Claudio Fontana Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) From: Philippe Mathieu-Daud=C3=A9 When TCG is enabled, the accel/tcg/ include path is added to the project global include search list. This accel/tcg/ directory contains a header named "internal.h" which, while intented to be internal to accel/tcg/, is accessible by all files compiled when TCG is enabled. This might lead to problem with other directories using the same "internal.h" header name: $ git ls-files | fgrep /internal.h accel/tcg/internal.h include/hw/ide/internal.h target/hexagon/internal.h target/mips/internal.h target/ppc/internal.h target/s390x/internal.h As we don't need to expose accel/tcg/ internals to the rest of the code base, simplify by removing it from the include search list, and include the accel/tcg/ public headers relative to the project root search path (which is already in the generic include search path). Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Claudio Fontana Message-Id: <20210413081008.3409459-1-f4bug@amsat.org> Signed-off-by: Richard Henderson --- meson.build | 1 - include/exec/helper-gen.h | 4 ++-- include/exec/helper-proto.h | 4 ++-- include/exec/helper-tcg.h | 4 ++-- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/meson.build b/meson.build index c6f4b0cf5e..d8bb1ec5aa 100644 --- a/meson.build +++ b/meson.build @@ -258,7 +258,6 @@ if not get_option('tcg').disabled() tcg_arch =3D 'riscv' endif add_project_arguments('-iquote', meson.current_source_dir() / 'tcg' / tc= g_arch, - '-iquote', meson.current_source_dir() / 'accel/tcg= ', language: ['c', 'cpp', 'objc']) =20 accelerators +=3D 'CONFIG_TCG' diff --git a/include/exec/helper-gen.h b/include/exec/helper-gen.h index 29c02f85dc..1c2e7a8ed3 100644 --- a/include/exec/helper-gen.h +++ b/include/exec/helper-gen.h @@ -81,8 +81,8 @@ static inline void glue(gen_helper_, name)(dh_retvar_decl= (ret) \ #include "helper.h" #include "trace/generated-helpers.h" #include "trace/generated-helpers-wrappers.h" -#include "tcg-runtime.h" -#include "plugin-helpers.h" +#include "accel/tcg/tcg-runtime.h" +#include "accel/tcg/plugin-helpers.h" =20 #undef DEF_HELPER_FLAGS_0 #undef DEF_HELPER_FLAGS_1 diff --git a/include/exec/helper-proto.h b/include/exec/helper-proto.h index 659f9298e8..ba100793a7 100644 --- a/include/exec/helper-proto.h +++ b/include/exec/helper-proto.h @@ -39,8 +39,8 @@ dh_ctype(ret) HELPER(name) (dh_ctype(t1), dh_ctype(t2), d= h_ctype(t3), \ =20 #include "helper.h" #include "trace/generated-helpers.h" -#include "tcg-runtime.h" -#include "plugin-helpers.h" +#include "accel/tcg/tcg-runtime.h" +#include "accel/tcg/plugin-helpers.h" =20 #undef IN_HELPER_PROTO =20 diff --git a/include/exec/helper-tcg.h b/include/exec/helper-tcg.h index 27870509a2..6888514635 100644 --- a/include/exec/helper-tcg.h +++ b/include/exec/helper-tcg.h @@ -60,8 +60,8 @@ =20 #include "helper.h" #include "trace/generated-helpers.h" -#include "tcg-runtime.h" -#include "plugin-helpers.h" +#include "accel/tcg/tcg-runtime.h" +#include "accel/tcg/plugin-helpers.h" =20 #undef str #undef DEF_HELPER_FLAGS_0 --=20 2.25.1 From nobody Fri May 17 11:58:52 2024 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=1619896630; cv=none; d=zohomail.com; s=zohoarc; b=k+9Az/XIdO65FBY/yGKgfHQVb89qpPZgxbOFRxkVvGi1Ax5ktOSJwlnGRwiAvWzjY1FumtwgNW/T976BiXBiVOGP4wK0Z5VkElbxipItQRxj9aXw9vB53QhiLWO0xlQaRR/2DF0UhSg0kET/La/tM9TlMIuPwCEsdX4igZ50twQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619896630; 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=cDkTlWjDspe7eeKU7hYAA5ZhW5FnQSaWorntDqhx4CU=; b=SwhxTMNjGQIqIqp5dszN5qJjQBjyK8TMoaHYURcPxililMtqvC5KAeAKKzFm9b6G1XT/h/UG8hOItitmExLJQmtDaFgFgQxeCl5lFi4oEkZEbLrLn/6JAv4R7vH+aj5W77C0V8WsHyY5HRPh5ZwNO3eSYn9bR8pHTuB5giCgdLg= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1619896630226823.3084726028369; Sat, 1 May 2021 12:17:10 -0700 (PDT) Received: from localhost ([::1]:47930 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lcv6z-0006DG-3W for importer@patchew.org; Sat, 01 May 2021 15:17:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46414) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcui3-0006Tq-Lk for qemu-devel@nongnu.org; Sat, 01 May 2021 14:51:24 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]:42986) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lcui0-0003lI-Ds for qemu-devel@nongnu.org; Sat, 01 May 2021 14:51:23 -0400 Received: by mail-pl1-x633.google.com with SMTP id v13so671130ple.9 for ; Sat, 01 May 2021 11:51:19 -0700 (PDT) Received: from localhost.localdomain ([71.212.144.24]) by smtp.gmail.com with ESMTPSA id k17sm4971360pfa.68.2021.05.01.11.51.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 May 2021 11:51:18 -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=cDkTlWjDspe7eeKU7hYAA5ZhW5FnQSaWorntDqhx4CU=; b=ADrejI6v+/LH78RZi+37vKZoI4xdjFwPpXiijvuMPxPYr0TvArxci/aY5P45JkNjnA rSB9RCi6GV3TnxliGwWb8CKTFDiNDIa59mxnA53K/agWc6w5jPPZZEb2mwmYci8Neaxv 1sFCOhwa9f5XW81qTyw66mqvXEsVZGowRQbQkeMMmCHJwnjT2iZ09/TtyB82kqzpUr0G 5R+6BSuIU/9iqN7/HC3RwWuRZjT+KVyNA3Esuzi6F0Xowi5uLv3dFlY6Ksy9As2Yy0xg vEwknsn1zGvlEA3wfXac1Vo/3QtxZwG1bs+pjc5AD5KSnugvfwA5vVGMUILzkwD413HO 49qQ== 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=cDkTlWjDspe7eeKU7hYAA5ZhW5FnQSaWorntDqhx4CU=; b=LbOjpFxnnAmzAwIAqkar9gTvZGuFycMMq7Me51ec3Gdf8GN3PxoCztjtAohkxrLtSB p6TSXo0MbXSAFNizgcXNDEqs11pDsuRiEjEFcR4RtU0P0ulfEj4JbX8nQIWQ5yg8/piM mHN/WXTFZU+7XVeuXi3NA07hNN0lA30bhWzUAmFINoMQejDBXo1eQsrl/OcaPdDHD3hu 4C5vn4AuIrRbgiUNNrM+4ucwT4qA4WhrgdfZH1a4J8lC2Rz7AJovNwcMSl2ug9xX+uBK JvfhPnVhAfPI0J4/GhZmiyeq6hGsShEZsefcH/dbb9By0abFFzK4Oh/28NWyknfDpc+7 iZLg== X-Gm-Message-State: AOAM530m9os3/9lLILbFHX0YuKP8+dSYW3/KrL/pSx6eXKB/hEG7Fmwr yKLDphCnLrL591XjYZc0WQ8BNL885vQ5WQ== X-Google-Smtp-Source: ABdhPJwkXmEvRteLKlqnjCj8xjljJOLN+qwtY2Rb+hxgRQyXGGVkyVEjm/L2QFttsYaNyhVOFLc5sg== X-Received: by 2002:a17:90a:cc0b:: with SMTP id b11mr12026989pju.190.1619895078822; Sat, 01 May 2021 11:51:18 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 2/5] decodetree: Introduce whex and whexC helpers Date: Sat, 1 May 2021 11:51:13 -0700 Message-Id: <20210501185116.1338875-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210501185116.1338875-1-richard.henderson@linaro.org> References: <20210501185116.1338875-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::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.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 autolearn=ham autolearn_force=no X-Spam_action: no action 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, Luis Pires Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" Form a hex constant of the appropriate insnwidth. Begin using f-strings on changed lines. Reviewed-by: Luis Pires Signed-off-by: Richard Henderson --- scripts/decodetree.py | 66 +++++++++++++++++++++++++------------------ 1 file changed, 38 insertions(+), 28 deletions(-) diff --git a/scripts/decodetree.py b/scripts/decodetree.py index 4637b633e7..0861e5d503 100644 --- a/scripts/decodetree.py +++ b/scripts/decodetree.py @@ -102,6 +102,21 @@ def str_fields(fields): return r[1:] =20 =20 +def whex(val): + """Return a hex string for val padded for insnwidth""" + global insnwidth + return f'0x{val:0{insnwidth // 4}x}' + + +def whexC(val): + """Return a hex string for val padded for insnwidth, + and with the proper suffix for a C constant.""" + suffix =3D '' + if val >=3D 0x80000000: + suffix =3D 'u' + return whex(val) + suffix + + def str_match_bits(bits, mask): """Return a string pretty-printing BITS/MASK""" global insnwidth @@ -477,11 +492,8 @@ def output_code(self, i, extracted, outerbits, outerma= sk): if outermask !=3D p.fixedmask: innermask =3D p.fixedmask & ~outermask innerbits =3D p.fixedbits & ~outermask - output(ind, 'if ((insn & ', - '0x{0:08x}) =3D=3D 0x{1:08x}'.format(innermask, inn= erbits), - ') {\n') - output(ind, ' /* ', - str_match_bits(p.fixedbits, p.fixedmask), ' */\n') + output(ind, f'if ((insn & {whexC(innermask)}) =3D=3D {whex= C(innerbits)}) {{\n') + output(ind, f' /* {str_match_bits(p.fixedbits, p.fixedm= ask)} */\n') p.output_code(i + 4, extracted, p.fixedbits, p.fixedmask) output(ind, '}\n') else: @@ -500,12 +512,12 @@ def __init__(self, fm, tm): =20 def str1(self, i): ind =3D str_indent(i) - r =3D '{0}{1:08x}'.format(ind, self.fixedmask) + r =3D ind + whex(self.fixedmask) if self.format: r +=3D ' ' + self.format.name r +=3D ' [\n' for (b, s) in self.subs: - r +=3D '{0} {1:08x}:\n'.format(ind, b) + r +=3D ind + f' {whex(b)}:\n' r +=3D s.str1(i + 4) + '\n' r +=3D ind + ']' return r @@ -529,16 +541,16 @@ def output_code(self, i, extracted, outerbits, outerm= ask): if sh > 0: # Propagate SH down into the local functions. def str_switch(b, sh=3Dsh): - return '(insn >> {0}) & 0x{1:x}'.format(sh, b >> sh) + return f'(insn >> {sh}) & {b >> sh:#x}' =20 def str_case(b, sh=3Dsh): - return '0x{0:x}'.format(b >> sh) + return hex(b >> sh) else: def str_switch(b): - return 'insn & 0x{0:08x}'.format(b) + return f'insn & {whexC(b)}' =20 def str_case(b): - return '0x{0:08x}'.format(b) + return whexC(b) =20 output(ind, 'switch (', str_switch(self.thismask), ') {\n') for b, s in sorted(self.subs): @@ -962,19 +974,19 @@ def parse_generic(lineno, parent_pat, name, toks): =20 # Validate the masks that we have assembled. if fieldmask & fixedmask: - error(lineno, 'fieldmask overlaps fixedmask (0x{0:08x} & 0x{1:08x}= )' - .format(fieldmask, fixedmask)) + error(lineno, 'fieldmask overlaps fixedmask ', + f'({whex(fieldmask)} & {whex(fixedmask)})') if fieldmask & undefmask: - error(lineno, 'fieldmask overlaps undefmask (0x{0:08x} & 0x{1:08x}= )' - .format(fieldmask, undefmask)) + error(lineno, 'fieldmask overlaps undefmask ', + f'({whex(fieldmask)} & {whex(undefmask)})') if fixedmask & undefmask: - error(lineno, 'fixedmask overlaps undefmask (0x{0:08x} & 0x{1:08x}= )' - .format(fixedmask, undefmask)) + error(lineno, 'fixedmask overlaps undefmask ', + f'({whex(fixedmask)} & {whex(undefmask)})') if not is_format: allbits =3D fieldmask | fixedmask | undefmask if allbits !=3D insnmask: - error(lineno, 'bits left unspecified (0x{0:08x})' - .format(allbits ^ insnmask)) + error(lineno, 'bits left unspecified ', + f'({whex(allbits ^ insnmask)})') # end parse_general =20 =20 @@ -1104,10 +1116,9 @@ def __init__(self, m, w): =20 def str1(self, i): ind =3D str_indent(i) - r =3D '{0}{1:08x}'.format(ind, self.mask) - r +=3D ' [\n' + r =3D ind + whex(self.mask) + ' [\n' for (b, s) in self.subs: - r +=3D '{0} {1:08x}:\n'.format(ind, b) + r +=3D ind + f' {whex(b)}:\n' r +=3D s.str1(i + 4) + '\n' r +=3D ind + ']' return r @@ -1131,16 +1142,16 @@ def output_code(self, i, extracted, outerbits, oute= rmask): if sh > 0: # Propagate SH down into the local functions. def str_switch(b, sh=3Dsh): - return '(insn >> {0}) & 0x{1:x}'.format(sh, b >> sh) + return f'(insn >> {sh}) & {b >> sh:#x}' =20 def str_case(b, sh=3Dsh): - return '0x{0:x}'.format(b >> sh) + return hex(b >> sh) else: def str_switch(b): - return 'insn & 0x{0:08x}'.format(b) + return f'insn & {whexC(b)}' =20 def str_case(b): - return '0x{0:08x}'.format(b) + return whexC(b) =20 output(ind, 'switch (', str_switch(self.mask), ') {\n') for b, s in sorted(self.subs): @@ -1162,8 +1173,7 @@ def __init__(self, m, w): self.width =3D w =20 def str1(self, i): - ind =3D str_indent(i) - return '{0}{1:08x}'.format(ind, self.mask) + return str_indent(i) + whex(self.mask) =20 def __str__(self): return self.str1(0) --=20 2.25.1 From nobody Fri May 17 11:58:52 2024 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=1619896958; cv=none; d=zohomail.com; s=zohoarc; b=VPDBZQDTPnrfSj+8k8EvipvCOnTU5d9SCiYSbm3Q4oSYHfKibI0ZfV6uc9NLb2IQc+E4SGjnGZlcu/62Nh5wf2M2pHS+a7oXzaQX3Ie1dRoVFdeb8/f9L/685uMj/2G2ZmVkeSW+/tzR2KnJP/h4XMnKza3GzPIlIe6g5tg/w4Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619896958; 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=62gsPCfJVVTudyksYSpOQ+QZs8msMspH2baL2k/3Zs8=; b=gcaF5nJf/XN60kDBZxWOL7p5K0/Ftl1iKhXAUm9GDlVzR46RSRtzZio8o7IVLoNJ72/11Fuy3yz7tY7ZeNdjyg1RqDNrrf0dELDJv//y01anjW6toCs4jS0pnvtE78VT83SbEFRS5NdVNa26OE3f9OyitfjO3jviMOzOQy+5PDY= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1619896958103614.0881425339978; Sat, 1 May 2021 12:22:38 -0700 (PDT) Received: from localhost ([::1]:34270 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lcvCH-0003nA-0e for importer@patchew.org; Sat, 01 May 2021 15:22:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46394) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcui3-0006Tm-0i for qemu-devel@nongnu.org; Sat, 01 May 2021 14:51:24 -0400 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]:44758) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lcui0-0003lu-NY for qemu-devel@nongnu.org; Sat, 01 May 2021 14:51:22 -0400 Received: by mail-pj1-x1031.google.com with SMTP id m6-20020a17090a8586b02901507e1acf0fso1044991pjn.3 for ; Sat, 01 May 2021 11:51:20 -0700 (PDT) Received: from localhost.localdomain ([71.212.144.24]) by smtp.gmail.com with ESMTPSA id k17sm4971360pfa.68.2021.05.01.11.51.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 May 2021 11:51:19 -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=62gsPCfJVVTudyksYSpOQ+QZs8msMspH2baL2k/3Zs8=; b=WOtHaIlBBfI8yhFm7hvzZUG3yHF5o0cxenbWiVhn7qikPYIdCBNDZZw1Uzs5dMu8sd GgVly6SyMQfHNDQTzcu0HTOm9Iv3s28iwv7LvA7FwxGW2XvoRiJn8Avtz5BF9HxIHAN7 D6xFo8L2eLPEqMEaHQDZnJqZcCj5yMujs5dFApib6CXR2z33LItpzJ33bFbJ30/jOqXp t4P3P555Xp+XYGB4Lb7SQ3XptwvZz1ieG7xueqznjzFa5K+8y1V11Phv+Rg3nwQihxwp svXp8ysNA6PjHUN7TFxNb1S19iOslgnq1Jy/taI4C2dDBs4eRkvss428Nuymt5XMWkHu ntdg== 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=62gsPCfJVVTudyksYSpOQ+QZs8msMspH2baL2k/3Zs8=; b=Yoj8bjxpm0dGCmzpSEOmxLjk1IiZoyXmSypvcAlVAYrsNUkEaegWLputwwilpgDNRx g6zBCTokYjl9EkAEohdBu52l7KytnxT0CbUu6HuESV4jv/sT6g9g+AqqfjvC5mJKYFF3 gLxd81g/KG1zRG8n4HGXU79miG/v1IRR3ZQiBLNFJnLhgEpFgFJmCgYqkZeq8T5Ht8Bd jBf6yoJkl9pwzYMIpnbGDeK9vdzqHI2iE8kZpFOTJAC1AVTOyve/IwtHdb/5KE28DU7u KtFN1RsLcam2w4RPVEgCEkeUKiGbws/+zw2WFaX6xEmHJD6c6i187Pj2V2iV/JXQtmYO uZmw== X-Gm-Message-State: AOAM532CYct4P/YtL6PPA/EngzkBtY+N6EaZLUjtHVBMwPApQDg2b/Mp ikYfUYnsXrlp5dtwYTM6C4oJ1SAr9pe2vg== X-Google-Smtp-Source: ABdhPJzGhZzujTnG9oxrLZVbGFGGHTWK1p7OEofoUEitSxO71UNjTJXX2LIynFTgFtoaLJtQAAw0fg== X-Received: by 2002:a17:902:c404:b029:ea:f0a9:6060 with SMTP id k4-20020a170902c404b02900eaf0a96060mr11752669plk.9.1619895079445; Sat, 01 May 2021 11:51:19 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 3/5] decodetree: More use of f-strings Date: Sat, 1 May 2021 11:51:14 -0700 Message-Id: <20210501185116.1338875-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210501185116.1338875-1-richard.henderson@linaro.org> References: <20210501185116.1338875-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::1031; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1031.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 autolearn=ham autolearn_force=no X-Spam_action: no action 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, Luis Pires Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" Reviewed-by: Luis Pires Signed-off-by: Richard Henderson --- scripts/decodetree.py | 50 ++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/scripts/decodetree.py b/scripts/decodetree.py index 0861e5d503..d5da101167 100644 --- a/scripts/decodetree.py +++ b/scripts/decodetree.py @@ -59,9 +59,9 @@ def error_with_file(file, lineno, *args): =20 prefix =3D '' if file: - prefix +=3D '{0}:'.format(file) + prefix +=3D f'{file}:' if lineno: - prefix +=3D '{0}:'.format(lineno) + prefix +=3D f'{lineno}:' if prefix: prefix +=3D ' ' print(prefix, end=3D'error: ', file=3Dsys.stderr) @@ -203,7 +203,7 @@ def str_extract(self): extr =3D 'sextract32' else: extr =3D 'extract32' - return '{0}(insn, {1}, {2})'.format(extr, self.pos, self.len) + return f'{extr}(insn, {self.pos}, {self.len})' =20 def __eq__(self, other): return self.sign =3D=3D other.sign and self.mask =3D=3D other.mask @@ -227,11 +227,11 @@ def str_extract(self): ret =3D '0' pos =3D 0 for f in reversed(self.subs): + ext =3D f.str_extract() if pos =3D=3D 0: - ret =3D f.str_extract() + ret =3D ext else: - ret =3D 'deposit32({0}, {1}, {2}, {3})' \ - .format(ret, pos, 32 - pos, f.str_extract()) + ret =3D f'deposit32({ret}, {pos}, {32 - pos}, {ext})' pos +=3D f.len return ret =20 @@ -675,11 +675,11 @@ def parse_field(lineno, name, toks): subtoks =3D t.split(':') sign =3D False else: - error(lineno, 'invalid field token "{0}"'.format(t)) + error(lineno, f'invalid field token "{t}"') po =3D int(subtoks[0]) le =3D int(subtoks[1]) if po + le > insnwidth: - error(lineno, 'field {0} too large'.format(t)) + error(lineno, f'field {t} too large') f =3D Field(sign, po, le) subs.append(f) width +=3D le @@ -724,9 +724,9 @@ def parse_arguments(lineno, name, toks): anyextern =3D True continue if not re.fullmatch(re_C_ident, t): - error(lineno, 'invalid argument set token "{0}"'.format(t)) + error(lineno, f'invalid argument set token "{t}"') if t in flds: - error(lineno, 'duplicate argument "{0}"'.format(t)) + error(lineno, f'duplicate argument "{t}"') flds.append(t) =20 if name in arguments: @@ -895,14 +895,14 @@ def parse_generic(lineno, parent_pat, name, toks): flen =3D flen[1:] shift =3D int(flen, 10) if shift + width > insnwidth: - error(lineno, 'field {0} exceeds insnwidth'.format(fname)) + error(lineno, f'field {fname} exceeds insnwidth') f =3D Field(sign, insnwidth - width - shift, shift) flds =3D add_field(lineno, flds, fname, f) fixedbits <<=3D shift fixedmask <<=3D shift undefmask <<=3D shift else: - error(lineno, 'invalid token "{0}"'.format(t)) + error(lineno, f'invalid token "{t}"') width +=3D shift =20 if variablewidth and width < insnwidth and width % 8 =3D=3D 0: @@ -914,7 +914,7 @@ def parse_generic(lineno, parent_pat, name, toks): =20 # We should have filled in all of the bits of the instruction. elif not (is_format and width =3D=3D 0) and width !=3D insnwidth: - error(lineno, 'definition has {0} bits'.format(width)) + error(lineno, f'definition has {width} bits') =20 # Do not check for fields overlapping fields; one valid usage # is to be able to duplicate fields via import. @@ -932,8 +932,7 @@ def parse_generic(lineno, parent_pat, name, toks): if arg: for f in flds.keys(): if f not in arg.fields: - error(lineno, 'field {0} not in argument set {1}' - .format(f, arg.name)) + error(lineno, f'field {f} not in argument set {arg.nam= e}') else: arg =3D infer_argument_set(flds) if name in formats: @@ -960,13 +959,12 @@ def parse_generic(lineno, parent_pat, name, toks): arg =3D fmt.base for f in flds.keys(): if f not in arg.fields: - error(lineno, 'field {0} not in argument set {1}' - .format(f, arg.name)) + error(lineno, f'field {f} not in argument set {arg.name}') if f in fmt.fields.keys(): - error(lineno, 'field {0} set by format and pattern'.format= (f)) + error(lineno, f'field {f} set by format and pattern') for f in arg.fields: if f not in flds.keys() and f not in fmt.fields.keys(): - error(lineno, 'field {0} not initialized'.format(f)) + error(lineno, f'field {f} not initialized') pat =3D Pattern(name, lineno, fmt, fixedbits, fixedmask, undefmask, fieldmask, flds, width) parent_pat.pats.append(pat) @@ -1097,7 +1095,7 @@ def parse_file(f, parent_pat): elif re.fullmatch(re_pat_ident, name): parse_generic(start_lineno, parent_pat, name, toks) else: - error(lineno, 'invalid token "{0}"'.format(name)) + error(lineno, f'invalid token "{name}"') toks =3D [] =20 if nesting !=3D 0: @@ -1131,9 +1129,8 @@ def output_code(self, i, extracted, outerbits, outerm= ask): =20 # If we need to load more bytes to test, do so now. if extracted < self.width: - output(ind, 'insn =3D ', decode_function, - '_load_bytes(ctx, insn, {0}, {1});\n' - .format(extracted // 8, self.width // 8)); + output(ind, f'insn =3D {decode_function}_load_bytes', + f'(ctx, insn, {extracted // 8}, {self.width // 8});\n') extracted =3D self.width =20 # Attempt to aid the compiler in producing compact switch statemen= ts. @@ -1184,9 +1181,8 @@ def output_code(self, i, extracted, outerbits, outerm= ask): =20 # If we need to load more bytes, do so now. if extracted < self.width: - output(ind, 'insn =3D ', decode_function, - '_load_bytes(ctx, insn, {0}, {1});\n' - .format(extracted // 8, self.width // 8)); + output(ind, f'insn =3D {decode_function}_load_bytes', + f'(ctx, insn, {extracted // 8}, {self.width // 8});\n') extracted =3D self.width output(ind, 'return insn;\n') # end SizeLeaf @@ -1220,7 +1216,7 @@ def build_size_tree(pats, width, outerbits, outermask= ): for p in pats: pnames.append(p.name + ':' + p.file + ':' + str(p.lineno)) error_with_file(pats[0].file, pats[0].lineno, - 'overlapping patterns size {0}:'.format(width), pn= ames) + f'overlapping patterns size {width}:', pnames) =20 bins =3D {} for i in pats: --=20 2.25.1 From nobody Fri May 17 11:58:52 2024 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=1619897060; cv=none; d=zohomail.com; s=zohoarc; b=gdL9RtmVaan0+TN2QaFA7YnMeBGaCpL3d9jl75RfKjyJUf9uc1MghHRciDW/GjkUx5Q4ee8lMryz41K1cEpv0oeN9mmVXy3W3FLcrNsDjhUJHaUefwSn9WYD8dxodzOhjClc6ntu9YebymIpJ6EJxmrFKCpcDXk4KacFSvMW2us= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619897060; h=Content-Type: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=cUnlPrvK75q4XSJyyRAV3mEtaJHVxQptn5uL4uV7YhQ=; b=f48p0Jv26HVX/QcRkcCFfDQSMMiwg6ZZCgz8Cwy+eSe9/hKdUyvVTsjOp5K2N0h5kTfjTHMcNwglzn9bjaQ16jm3QM3Qg1+mjL4AxzdbQeYVYyOSf6p2oKzjwi4USnmLs/HvZWyCWxBSxc3oQccBPfFN3Qkqhs5unVzfINkQ8eY= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1619897060981885.615400360232; Sat, 1 May 2021 12:24:20 -0700 (PDT) Received: from localhost ([::1]:37546 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lcvDv-00054j-RV for importer@patchew.org; Sat, 01 May 2021 15:24:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46426) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcui6-0006Wx-Jb for qemu-devel@nongnu.org; Sat, 01 May 2021 14:51:27 -0400 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]:39726) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lcui1-0003m7-Gu for qemu-devel@nongnu.org; Sat, 01 May 2021 14:51:26 -0400 Received: by mail-pj1-x102c.google.com with SMTP id z6-20020a17090a1706b0290155e8a752d8so3452664pjd.4 for ; Sat, 01 May 2021 11:51:21 -0700 (PDT) Received: from localhost.localdomain ([71.212.144.24]) by smtp.gmail.com with ESMTPSA id k17sm4971360pfa.68.2021.05.01.11.51.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 May 2021 11:51:20 -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=cUnlPrvK75q4XSJyyRAV3mEtaJHVxQptn5uL4uV7YhQ=; b=MXhKWAJv6ScpVXCZUwqOpLDSMRt0VxxPRuL1iGTYbjf+y4D+O2KkzaI77J+4xzAWgy 0oy4+wmTKEqZIefKkJxUIqcppol69Vs8I9rtUca3wl65H04+oVzjNt/Ym2BQ6b7FHvMi czYJAI2DF6Q/Aa2DjeRn3qcoi3PM4rtuY1Er+hUb2It67fNx7A2IOEd2lpagN4VI94nG M1LeZhsw0ZvpMnYZKBEgnD/D97pj8LXo8xpm5zVssgUTfFmyRJa8M2aUAXxSNwldJ+xK D62C2jpeZHFT+BVXw5VfI3nVvssc1Rq1miUgcwzcXOwYlAUWD3aD+YfStv3yHfiy0kce zC7g== 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=cUnlPrvK75q4XSJyyRAV3mEtaJHVxQptn5uL4uV7YhQ=; b=SjJMkWh8jDhPf/aebC7NDiNNeL9tH4vcijsFnQO5AvOB0RZ8aH2ZXC5BLrxZbLxV8t z2oBe8iFmbLTfaTjGbYGFtcCv3eDeGi+ZCy0xiIMb+Mu9oF+SLbi4d+Niqw2StBIIYrK jp2IJayjZHVAuBEOrQZHxhu2gL6kaVyjEPYC3bveV6JU9vqhUVH6bGNtquwshuLl2Tkg A6zs40oeXlGi/iuvy10qtLhR2c4iqiBwwXqus3bJeykhshmMvaPhGHlrtdu0MtlW8aFi Wn4sS7RWdn0wggV86DAHaEkFE62D8d2+yU4XNMobrp2+Qfa0zGAEuX2se/fRR7d3j1VY FEug== X-Gm-Message-State: AOAM530FaDSuAT9jZ3EzjPLvoA/fdxAHuWmCB3IWWjU7G1FxrDhBVrZt /qvRDgFfPITOZyv+rJNfuIFX2B091aXC9A== X-Google-Smtp-Source: ABdhPJwnj8MSQ+9PHUkPmPxdm2CnwQphwerow8iENYUUOjkzsORLKqCG8spYMca04DNgJmAFFvTw2w== X-Received: by 2002:a17:90a:a4c7:: with SMTP id l7mr11726643pjw.147.1619895080274; Sat, 01 May 2021 11:51:20 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 4/5] decodetree: Add support for 64-bit instructions Date: Sat, 1 May 2021 11:51:15 -0700 Message-Id: <20210501185116.1338875-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210501185116.1338875-1-richard.henderson@linaro.org> References: <20210501185116.1338875-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::102c; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102c.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 autolearn=ham autolearn_force=no X-Spam_action: no action 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, Luis Fernando Fujita Pires , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) From: Luis Fernando Fujita Pires Allow '64' to be specified for the instruction width command line params and use the appropriate extract and deposit functions in that case. This will be used to implement the new 64-bit Power ISA 3.1 instructions. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Luis Pires Message-Id: [rth: Drop the change to the field type; use bitop_width instead of separate variables for extract/deposit; use "ull" for 64-bit constants.] Reviewed-by: Luis Pires Signed-off-by: Richard Henderson --- scripts/decodetree.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/scripts/decodetree.py b/scripts/decodetree.py index d5da101167..f85da45ee3 100644 --- a/scripts/decodetree.py +++ b/scripts/decodetree.py @@ -27,6 +27,7 @@ import getopt =20 insnwidth =3D 32 +bitop_width =3D 32 insnmask =3D 0xffffffff variablewidth =3D False fields =3D {} @@ -112,7 +113,9 @@ def whexC(val): """Return a hex string for val padded for insnwidth, and with the proper suffix for a C constant.""" suffix =3D '' - if val >=3D 0x80000000: + if val >=3D 0x100000000: + suffix =3D 'ull' + elif val >=3D 0x80000000: suffix =3D 'u' return whex(val) + suffix =20 @@ -199,11 +202,9 @@ def __str__(self): return str(self.pos) + ':' + s + str(self.len) =20 def str_extract(self): - if self.sign: - extr =3D 'sextract32' - else: - extr =3D 'extract32' - return f'{extr}(insn, {self.pos}, {self.len})' + global bitop_width + s =3D 's' if self.sign else '' + return f'{s}extract{bitop_width}(insn, {self.pos}, {self.len})' =20 def __eq__(self, other): return self.sign =3D=3D other.sign and self.mask =3D=3D other.mask @@ -224,6 +225,7 @@ def __str__(self): return str(self.subs) =20 def str_extract(self): + global bitop_width ret =3D '0' pos =3D 0 for f in reversed(self.subs): @@ -231,7 +233,7 @@ def str_extract(self): if pos =3D=3D 0: ret =3D ext else: - ret =3D f'deposit32({ret}, {pos}, {32 - pos}, {ext})' + ret =3D f'deposit{bitop_width}({ret}, {pos}, {bitop_width = - pos}, {ext})' pos +=3D f.len return ret =20 @@ -1270,6 +1272,7 @@ def main(): global insntype global insnmask global decode_function + global bitop_width global variablewidth global anyextern =20 @@ -1299,6 +1302,10 @@ def main(): if insnwidth =3D=3D 16: insntype =3D 'uint16_t' insnmask =3D 0xffff + elif insnwidth =3D=3D 64: + insntype =3D 'uint64_t' + insnmask =3D 0xffffffffffffffff + bitop_width =3D 64 elif insnwidth !=3D 32: error(0, 'cannot handle insns of width', insnwidth) else: --=20 2.25.1 From nobody Fri May 17 11:58:52 2024 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=1619896004; cv=none; d=zohomail.com; s=zohoarc; b=TaswWtYwrnp3+E8uaWCJ+7SKFOKLITbI45/dXf4/veyEJZcMIFO/S+m+AonJ062GtTOebT/Y0wKUuo4kUY2LQYVGX4VOmJMqQMnHVT9UuTEgxeJjXNVMjintuPn7CSKSk2CehvGt/KANVaPJDAIZcZY3ExMlkKXsKLZ1C92qhEU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619896004; 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=R/1WAzyuseBP9GbYXdpEWnL72IgMjHrQD+B+K1Ph/uk=; b=VXixKpR3UWnSxaP4PoHlWMCtC/fjQxyIIw/sbx+1umkUcy5jNtNgl7c+wHujoE3KfQ6B8yahCSyu7ZwdI608GZVJW+SH2geIc73koGgb3Om3uySLxAQPfzRtypGAKPt5KtwT60RNwqw8U9MDUNH9u6XYTKlT9tb4UdFbynk91v0= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1619896004045315.6182706468634; Sat, 1 May 2021 12:06:44 -0700 (PDT) Received: from localhost ([::1]:50634 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lcuws-00046E-Vj for importer@patchew.org; Sat, 01 May 2021 15:06:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46420) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcui4-0006Vf-KY for qemu-devel@nongnu.org; Sat, 01 May 2021 14:51:25 -0400 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]:35447) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lcui2-0003mo-8Z for qemu-devel@nongnu.org; Sat, 01 May 2021 14:51:24 -0400 Received: by mail-pj1-x1030.google.com with SMTP id h14-20020a17090aea8eb02901553e1cc649so3490484pjz.0 for ; Sat, 01 May 2021 11:51:21 -0700 (PDT) Received: from localhost.localdomain ([71.212.144.24]) by smtp.gmail.com with ESMTPSA id k17sm4971360pfa.68.2021.05.01.11.51.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 May 2021 11:51:20 -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=R/1WAzyuseBP9GbYXdpEWnL72IgMjHrQD+B+K1Ph/uk=; b=pJA3V8F2rPLHHbx8f3/7AxDF6BvlNE41+Ix+Sy7ORAqkpwrGpf6HiCtvimGcF+dkn9 KYx+dM4d6w0FuEohB4z8/xX1Cx3TDYmae7B+sf4wwEJGq9ZglcIkwvB9+zKlqHHjGLLq 8zg207W8c+WD5E1hp5FTrmhA6AF3mQlqVdF65ydW+wiqTHIq+e1+mL+bWrb+6raKjaD9 adGGQtUJXqt0UfmjM58tFwHgfzKOxF1vx+XEIvtci+fkr9qBTsM0xcsYzMMfQ268wSnD KQ/Z/VfmiQZYsq1OXaNt5FPgOk9D7ovf4LesveFlVpKrkqBvzmenzubAZAm40i43EZ0x QzUA== 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=R/1WAzyuseBP9GbYXdpEWnL72IgMjHrQD+B+K1Ph/uk=; b=tLQUfmYjALO0aFwmzUiqpaKTh1QlWhin8JbTzXRyUxbascNKCNhfK+FZVmzLvq/ozm ZIwPiRQ7bHhLNLWaFPylXARenf0CkoWUuFwDN3xR1cZaLEI9ZuxWtbITncdos8goSBW7 L+B46tVNAS7nVv63C9AwhiCYL6JEmMN9SLSv15AfZzuWO/dCTDkBX+bh7Ah2b4nuQHI+ KDVPoyVMkbGvat7hzuWGrE/1Dp58GB7ASgslaDeDbQtsrU4GomVkeiR3qv8KkCU/2hdh 0j7Yt0cXjXHiQbbtT2BLNF7FYfGGU7KKt0RWfU+UxbhhR0ehOBZwUiql7jQb7L5ZGO6h CVLA== X-Gm-Message-State: AOAM532Tl+DOLjuK1rjjUnVScgnSxUquDEbeNEfDdkQvRwqcMIICJrLI 6TlSlmD24YTcLECsT7ol1CEqWlMQNtdYTw== X-Google-Smtp-Source: ABdhPJyFsu9BIBLWGIZ6J/YEs5xduLANF1U50kk77a+KyKgIb3saBL3E26xREQwJ8DPQYXgfXQl8qA== X-Received: by 2002:a17:902:9693:b029:ee:851f:22e1 with SMTP id n19-20020a1709029693b02900ee851f22e1mr11348011plp.79.1619895080945; Sat, 01 May 2021 11:51:20 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 5/5] decodetree: Extend argument set syntax to allow types Date: Sat, 1 May 2021 11:51:16 -0700 Message-Id: <20210501185116.1338875-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210501185116.1338875-1-richard.henderson@linaro.org> References: <20210501185116.1338875-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::1030; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1030.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 autolearn=ham autolearn_force=no X-Spam_action: no action 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, Luis Pires Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" Rather than force all structure members to be 'int', allow the type of the member to be specified. Reviewed-by: Luis Pires Signed-off-by: Richard Henderson --- docs/devel/decodetree.rst | 11 ++++--- tests/decode/succ_argset_type1.decode | 1 + scripts/decodetree.py | 45 +++++++++++++++++---------- 3 files changed, 36 insertions(+), 21 deletions(-) create mode 100644 tests/decode/succ_argset_type1.decode diff --git a/docs/devel/decodetree.rst b/docs/devel/decodetree.rst index 74f66bf46e..49ea50c2a7 100644 --- a/docs/devel/decodetree.rst +++ b/docs/devel/decodetree.rst @@ -40,9 +40,6 @@ and returns an integral value extracted from there. =20 A field with no ``unnamed_fields`` and no ``!function`` is in error. =20 -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. - Field examples: =20 +---------------------------+---------------------------------------------+ @@ -66,9 +63,14 @@ Argument Sets Syntax:: =20 args_def :=3D '&' identifier ( args_elt )+ ( !extern )? - args_elt :=3D identifier + args_elt :=3D identifier (':' identifier)? =20 Each *args_elt* defines an argument within the argument set. +If the form of the *args_elt* contains a colon, the first +identifier is the argument name and the second identifier is +the argument type. If the colon is missing, the argument +type will be ``int``. + Each argument set will be rendered as a C structure "arg_$name" with each of the fields being one of the member arguments. =20 @@ -86,6 +88,7 @@ Argument set examples:: =20 ®3 ra rb rc &loadstore reg base offset + &longldst reg base offset:int64_t =20 =20 Formats diff --git a/tests/decode/succ_argset_type1.decode b/tests/decode/succ_args= et_type1.decode new file mode 100644 index 0000000000..ed946b420d --- /dev/null +++ b/tests/decode/succ_argset_type1.decode @@ -0,0 +1 @@ +&asdf b:bool c:uint64_t a diff --git a/scripts/decodetree.py b/scripts/decodetree.py index f85da45ee3..a03dc6b5e3 100644 --- a/scripts/decodetree.py +++ b/scripts/decodetree.py @@ -165,11 +165,15 @@ def is_contiguous(bits): return -1 =20 =20 -def eq_fields_for_args(flds_a, flds_b): - if len(flds_a) !=3D len(flds_b): +def eq_fields_for_args(flds_a, arg): + if len(flds_a) !=3D len(arg.fields): return False + # Only allow inference on default types + for t in arg.types: + if t !=3D 'int': + return False for k, a in flds_a.items(): - if k not in flds_b: + if k not in arg.fields: return False return True =20 @@ -313,10 +317,11 @@ def __ne__(self, other): =20 class Arguments: """Class representing the extracted fields of a format""" - def __init__(self, nm, flds, extern): + def __init__(self, nm, flds, types, extern): self.name =3D nm self.extern =3D extern - self.fields =3D sorted(flds) + self.fields =3D flds + self.types =3D types =20 def __str__(self): return self.name + ' ' + str(self.fields) @@ -327,8 +332,8 @@ def struct_name(self): def output_def(self): if not self.extern: output('typedef struct {\n') - for n in self.fields: - output(' int ', n, ';\n') + for (n, t) in zip(self.fields, self.types): + output(f' {t} {n};\n') output('} ', self.struct_name(), ';\n\n') # end Arguments =20 @@ -719,21 +724,27 @@ def parse_arguments(lineno, name, toks): global anyextern =20 flds =3D [] + types =3D [] extern =3D False - for t in toks: - if re.fullmatch('!extern', t): + for n in toks: + if re.fullmatch('!extern', n): extern =3D True anyextern =3D True continue - if not re.fullmatch(re_C_ident, t): - error(lineno, f'invalid argument set token "{t}"') - if t in flds: - error(lineno, f'duplicate argument "{t}"') - flds.append(t) + if re.fullmatch(re_C_ident + ':' + re_C_ident, n): + (n, t) =3D n.split(':') + elif re.fullmatch(re_C_ident, n): + t =3D 'int' + else: + error(lineno, f'invalid argument set token "{n}"') + if n in flds: + error(lineno, f'duplicate argument "{n}"') + flds.append(n) + types.append(t) =20 if name in arguments: error(lineno, 'duplicate argument set', name) - arguments[name] =3D Arguments(name, flds, extern) + arguments[name] =3D Arguments(name, flds, types, extern) # end parse_arguments =20 =20 @@ -760,11 +771,11 @@ def infer_argument_set(flds): global decode_function =20 for arg in arguments.values(): - if eq_fields_for_args(flds, arg.fields): + if eq_fields_for_args(flds, arg): return arg =20 name =3D decode_function + str(len(arguments)) - arg =3D Arguments(name, flds.keys(), False) + arg =3D Arguments(name, flds.keys(), ['int'] * len(flds), False) arguments[name] =3D arg return arg =20 --=20 2.25.1