From patchwork Mon May 12 18:04:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 889367 Delivered-To: patch@linaro.org Received: by 2002:adf:fd8a:0:b0:3a1:f579:ae88 with SMTP id d10csp1739512wrr; Mon, 12 May 2025 11:07:19 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWFLhjhEYY+IuT9njCD5ywqayBj86KZb4JxRy9YtKh20SckotPXOyoMjvQwRsxl9szGWRWLGw==@linaro.org X-Google-Smtp-Source: AGHT+IF+EcASsczdFYeAvQ6AooS9oGv82KV1Y46AVoDv77k4jva+v9c5rTxbLun/SexEnBqj5fUN X-Received: by 2002:ad4:5f8c:0:b0:6e6:5f28:9874 with SMTP id 6a1803df08f44-6f6e4795a48mr233100966d6.2.1747073239175; Mon, 12 May 2025 11:07:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1747073239; cv=none; d=google.com; s=arc-20240605; b=et6+YZYCwjb+l9WrAhbg6qCuTwmeNcd1VBzpl2CA95E6FmxCbH/VORH11ZyVuHvtsZ xSsOOxfWYBlPZyn8aRMBD3NTS2IZWS/ITK+HjgeWzyLfQvH2CVRnNf/HwDMMkQcp4r7O JGtBx5PmcoVkgid2+tYtJM4f0Rh5eM509SQehKXu2ifXJTtYsLyDGQPrASQNPZU2VUxS uknth/Xw9nrMCaZ9H9ac/EO6oBA8TiI8Ec1tEXZN1CuNDCx3XYxoidrYTV9IbwI9I1FX aV54h2Und/89N8GP9nfIhsGdCdN6wpJtKcUQ7OTiJt0KZbEJ8v6amnfDr7jbGa1p1V7e FQoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=IIdA4T0anNoDoCvg3AtaMVguafAAS4gjefvUsXl2qzE=; fh=PlN3fUhDtems6Bb7y59zYD8EwBcqcc7pnzqldojq+us=; b=aGG4cDjNnPfsNwlwIjGuBgz51YlWf7piEk7KZiQYsC5m7UPYdwzFNEShgtw0WDPDds 9EexVV5RhnSpDMPN6HMx0ZXsNHvifZOkkzo9ZIPEl8UN93LiuOpRqhC3hUnx58Te9w6Y tyfH2FQ98j3EOgar4oFyiIJS3X2tgZMCQ/KpDkcms5W+LCuOsY33Pqf5sD6zChFTjLOb 0VjOwj6K/HpxxH+UzFU1iSiAQ0WCR1U3Jh/tqa5g2f7PbVqU6UtNfaKFFegKtrjMz/qq rNnMKNyglsIrC8g5dqJDxmePcS+QVA2zdWCgDvbTC16ke/d6BiTh0pvFc6uB+6DxKc0M 0Mjg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yj+3Jbdc; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6f6e3a58e09si91123536d6.425.2025.05.12.11.07.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 May 2025 11:07: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=pass header.i=@linaro.org header.s=google header.b=yj+3Jbdc; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uEXXY-0003S7-RL; Mon, 12 May 2025 14:06:14 -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 1uEXWp-0002RN-MR for qemu-devel@nongnu.org; Mon, 12 May 2025 14:05:30 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uEXWm-0008Uc-5O for qemu-devel@nongnu.org; Mon, 12 May 2025 14:05:27 -0400 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-2301ac32320so15177675ad.1 for ; Mon, 12 May 2025 11:05:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1747073123; x=1747677923; darn=nongnu.org; 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=IIdA4T0anNoDoCvg3AtaMVguafAAS4gjefvUsXl2qzE=; b=yj+3JbdcmzRIzVbaI62ZY5obXOHkGRcv2O/6yb1xo60ZEQwQ0escEfrCRS7/TVq8cZ tG/cBX9YfC9k3g4TthFHOKQ5Krm4iVuka4M1HPERFieLliqZLwUBv3Z9Mx/ZM4eODV7f rwWRMh6yJDDcfaEm1e0lnmqvoDNpQNFhiI598GpLoiZKDBQEHpBeMb4X428MalivDdwm gawgREnl+5QJ5aM+DwbG2ZjgWTdFsrQCr6flg3SQxf6BtXEZ3GYCGT+IJavIyC+8XaCu pfwpHXeezLbSJjH/I4bRvjoe166JPowjiD732Mzx9CE4tOdvCn62sa+S06o7LRlovB3Z dD+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747073123; x=1747677923; 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=IIdA4T0anNoDoCvg3AtaMVguafAAS4gjefvUsXl2qzE=; b=m4Qc+4y00hylxe9djEApccs3SsG4tt2Kml0pzSRypgvyc6DoJW8EXxx60oEnGjUP0Q f8aTfLXgssaOYo6PshVdpiuswPF3N9oe/ODTGhnzurOcynSezcbyaVAoxoJFdSPrP3ce FreCMlYumiSdcUf8oN8nIhgi3aUiZXd3xgz+kmcAmlxmfbdlf2F+gz/WGAHnwz5ilRuZ EbPQS/f+dk5EnwqC2LPbJZXTvzxT6DGYagVxBDXozbMNzxTJBENmzzt40x9Xg0AG2ARJ r1RlX8ey0BefCISm2oxlR5HAI1OevJSi6mAdJ5/Z8/gjbZJbP8x9drO4/uLXZxyHYzmm BItQ== X-Gm-Message-State: AOJu0YydsYM1KqLOaN+nnsCcCyuMZfWntw90td57vIHIQblS+OjMorrJ gIxS63h885ON4RCMWyD9dApMCJ7sVwqLtvdDA5ZUwP7U03zpFwNCwHiRYyV8naKszvzrhjIjnFe l X-Gm-Gg: ASbGncumXX+5td1AC2u8zBCQoFZs43El9DwZHURVMZOmEBY5mD8wWqNVQnihv0Te9A4 ngar3seLueyqVBp4jDR7GlmVk4OQgi5ZQVXn/cnNZFLupYBeLErPeAcx/u5C6FOSsVQmgcThXAM Pjam6hbfIByhkvo3Vp90Ox4XKd7Ac+T6Wc3mW1P3NRvp5rnMxm7/+Z3PSd12Sl4j6zpggiFCo7K eJ6Dk+qyRXtKSqeV/iZVERPPJwYIvnoQrtz1/gZZXDMdkTMSj2O267tJZahsfSsadWUR0Fq1oNh D+8SJbtapQYwvPpJs7gvaEYTAGMOvZDDjVmq95UPD4SKqQX3kxE= X-Received: by 2002:a17:902:e88d:b0:226:38ff:1d6a with SMTP id d9443c01a7336-22fc8b1b1d6mr194043645ad.7.1747073122675; Mon, 12 May 2025 11:05:22 -0700 (PDT) Received: from pc.. ([38.41.223.211]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-22fc82a2e4fsm65792005ad.232.2025.05.12.11.05.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 May 2025 11:05:22 -0700 (PDT) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , kvm@vger.kernel.org, alex.bennee@linaro.org, anjo@rev.ng, qemu-arm@nongnu.org, Peter Maydell , Paolo Bonzini , Richard Henderson , Pierrick Bouvier Subject: [PATCH v8 12/48] tcg: add vaddr type for helpers Date: Mon, 12 May 2025 11:04:26 -0700 Message-ID: <20250512180502.2395029-13-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250512180502.2395029-1-pierrick.bouvier@linaro.org> References: <20250512180502.2395029-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pl1-x632.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.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 Defined as an alias of i32/i64 depending on host pointer size. Reviewed-by: Richard Henderson Signed-off-by: Pierrick Bouvier Reviewed-by: Philippe Mathieu-Daudé --- include/tcg/tcg-op-common.h | 1 + include/tcg/tcg.h | 14 ++++++++++++++ include/exec/helper-head.h.inc | 11 +++++++++++ tcg/tcg.c | 5 +++++ 4 files changed, 31 insertions(+) diff --git a/include/tcg/tcg-op-common.h b/include/tcg/tcg-op-common.h index b439bdb385a..e1071adebf2 100644 --- a/include/tcg/tcg-op-common.h +++ b/include/tcg/tcg-op-common.h @@ -14,6 +14,7 @@ TCGv_i32 tcg_constant_i32(int32_t val); TCGv_i64 tcg_constant_i64(int64_t val); +TCGv_vaddr tcg_constant_vaddr(uintptr_t val); TCGv_vec tcg_constant_vec(TCGType type, unsigned vece, int64_t val); TCGv_vec tcg_constant_vec_matching(TCGv_vec match, unsigned vece, int64_t val); diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index a8c00c72cc8..3fa5a7aed2c 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -189,6 +189,7 @@ typedef tcg_target_ulong TCGArg; * TCGv_i64 : 64 bit integer type * TCGv_i128 : 128 bit integer type * TCGv_ptr : a host pointer type + * TCGv_vaddr: an integer type wide enough to hold a target pointer type * TCGv_vec : a host vector type; the exact size is not exposed to the CPU front-end code. * TCGv : an integer type the same size as target_ulong @@ -217,6 +218,14 @@ typedef struct TCGv_ptr_d *TCGv_ptr; typedef struct TCGv_vec_d *TCGv_vec; typedef TCGv_ptr TCGv_env; +#if __SIZEOF_POINTER__ == 4 +typedef TCGv_i32 TCGv_vaddr; +#elif __SIZEOF_POINTER__ == 8 +typedef TCGv_i64 TCGv_vaddr; +#else +# error "sizeof pointer is different from {4,8}" +#endif /* __SIZEOF_POINTER__ */ + /* call flags */ /* Helper does not read globals (either directly or through an exception). It implies TCG_CALL_NO_WRITE_GLOBALS. */ @@ -577,6 +586,11 @@ static inline TCGv_ptr temp_tcgv_ptr(TCGTemp *t) return (TCGv_ptr)temp_tcgv_i32(t); } +static inline TCGv_vaddr temp_tcgv_vaddr(TCGTemp *t) +{ + return (TCGv_vaddr)temp_tcgv_i32(t); +} + static inline TCGv_vec temp_tcgv_vec(TCGTemp *t) { return (TCGv_vec)temp_tcgv_i32(t); diff --git a/include/exec/helper-head.h.inc b/include/exec/helper-head.h.inc index bce5db06ef3..5b248fd7138 100644 --- a/include/exec/helper-head.h.inc +++ b/include/exec/helper-head.h.inc @@ -58,6 +58,17 @@ # define dh_ctype_tl target_ulong #endif /* COMPILING_PER_TARGET */ +#if __SIZEOF_POINTER__ == 4 +# define dh_alias_vaddr i32 +# define dh_typecode_vaddr dh_typecode_i32 +#elif __SIZEOF_POINTER__ == 8 +# define dh_alias_vaddr i64 +# define dh_typecode_vaddr dh_typecode_i64 +#else +# error "sizeof pointer is different from {4,8}" +#endif /* __SIZEOF_POINTER__ */ +# define dh_ctype_vaddr uintptr_t + /* We can't use glue() here because it falls foul of C preprocessor recursive expansion rules. */ #define dh_retvar_decl0_void void diff --git a/tcg/tcg.c b/tcg/tcg.c index 648333a9fb7..ae27a2607df 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -2367,6 +2367,11 @@ TCGv_i64 tcg_constant_i64(int64_t val) return temp_tcgv_i64(tcg_constant_internal(TCG_TYPE_I64, val)); } +TCGv_vaddr tcg_constant_vaddr(uintptr_t val) +{ + return temp_tcgv_vaddr(tcg_constant_internal(TCG_TYPE_PTR, val)); +} + TCGv_ptr tcg_constant_ptr_int(intptr_t val) { return temp_tcgv_ptr(tcg_constant_internal(TCG_TYPE_PTR, val));