From patchwork Mon May 5 23:19:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 887476 Delivered-To: patch@linaro.org Received: by 2002:a5d:430f:0:b0:38f:210b:807b with SMTP id h15csp2289923wrq; Mon, 5 May 2025 16:22:31 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUS35gaaoAGvrFwElGltw0LxsukZbFTsyAw4DS01oV3Cqd7nvzfgx1nFdCs2oanzIexsFOqZA==@linaro.org X-Google-Smtp-Source: AGHT+IHxTL06cANOZpPapNemmljzU7HmxSJmBu2DguN+APkz/OucRq+aVMYcWNIT4NLh7eGocMTd X-Received: by 2002:a05:622a:549:b0:476:b783:c94d with SMTP id d75a77b69052e-4910dbfa950mr10606061cf.35.1746487351179; Mon, 05 May 2025 16:22:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1746487351; cv=none; d=google.com; s=arc-20240605; b=VvwPY59OWvqbmXZKWOQnRk1P0SY86HNQH912I6xAz5eFrVmZMPE6sKplS+77scloyQ KNmTgw2pN83499asIAByPdOkLw3CV6SoT0sLtGebfivEFRHlyG9poxJ51chjxGqQV1/6 spGFRQL5Y97uvcHKM4Mxg9uNC1IpUMpX8I7z7pirWe8oek4jPU8RPJ1AFwRfREGr67NI EXgjKelXeFs8WcUCwqgii63I1Zfgax1xx9ZI3xKb2o4QBxs8cPQJkzwOCYpc/hR8IQ7V h+iZ30y9zX70EHT8l7U4B5bBkCfK0se5VAYF6s/pd9RNfqH49t06xIctsSAaBd4fIee6 JnIg== 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=cDb7EHZEjLo7h3rZVcHObRDfwFiVArFxWp0gbUWTYQ0=; fh=sKdX4/MHbRvqsf1uWWiw/b4mRzIm0SRNXacICL4/ZgI=; b=JGIU7iG5Gmc2UgMGYbzyosbti47ZGQCSB41bBpLNhnCqoLEIRSs0W+EHww0WO85m6/ rXD5BxScGXkLUf4mvPbNhZISGx1LLOCeKLmm7Ac2HoWeUl+RWSEZgUpUR7h8wwJ4KKIZ hYgpP1z03vsHE2pO3x09kJ7RbfciWltt7d4bWYcpgTPEvTba5zSARQuVqLjo6xwR/krJ 0PILdRBC2NrEWRkKD8i754kKHsklZVD/+ab1/j3VaAC+GaRXCWT5Jq4JtNW/C5r5SSu9 xkcTbAvpFaygzNSeJift9xPn6Lwl5HIpOBS2M98LpCOMPidy6xRIbrUqNv2usHu50g9W z5gA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FtMy2tA+; 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 d75a77b69052e-48f66b5fd01si32429441cf.422.2025.05.05.16.22.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 05 May 2025 16:22:31 -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=FtMy2tA+; 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 1uC57A-0006Ok-3t; Mon, 05 May 2025 19:20:48 -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 1uC56z-0006FN-G3 for qemu-devel@nongnu.org; Mon, 05 May 2025 19:20:37 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uC56w-0003Yc-Nx for qemu-devel@nongnu.org; Mon, 05 May 2025 19:20:37 -0400 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-224019ad9edso75532445ad.1 for ; Mon, 05 May 2025 16:20:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1746487233; x=1747092033; 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=cDb7EHZEjLo7h3rZVcHObRDfwFiVArFxWp0gbUWTYQ0=; b=FtMy2tA+U7qjLmbD0ajIfQO6mrVdzMf2BYWNuYVjOHjshyQlHMe/bwW8V++1iWgJd8 euF6whQ4k8OvdEgaP4/KZ6UFtlLf6ySU4TzWwIdLj6pFXfvszAKcsHF2Ihe8BUN+P7jm zAVRk5vYSC/EMzU333cad+n15XlS5ajpIvYDefo6ktcS+7rxmLNf9ZCe5TrqE/O5lF+H l2waWPk2+psAsPx2FWVrDTeZGKPnGByVLQKX3TC5mZA5cCI3Ut1nFoAuZyXTIrGUtjR8 VzMZDObU5WbD2bBbKG5tNgsDd4hHNxLffuc2cON6KjfAoSHz1RK4vMtZ7XhxgGDOZdRs aH5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746487233; x=1747092033; 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=cDb7EHZEjLo7h3rZVcHObRDfwFiVArFxWp0gbUWTYQ0=; b=FuTAE9OoBlqRFAHvs91D4gK+san/2M37xp5k/pgC7O9O7lkj4OMnP4fWApwEBB/BC6 CD8ZD+Rg9F8aLUwPGy5XFuGE3JGBcSFM6JzwDDNX/i/4qQny01Ml0vMT2QppsuFlDo7u bHMAmJ2U/Q5sglDjDdqZo/UUR7M3pyIfUnsUCBvvni4mw+HIRWv3/j9gaayxvsQaz/BO 3Zxx349gULtDqQXPWTPXZyXB1L0QHxYyfsGRpEc3BWxjdxZ7/sDy4iIl/0iVbuKVws0s BVVLaD4HEHX/4K7BXhRmS8tFpDwzD2ThsAKZWqQ8AMp2Kyv+IglARQ1Z04Pr7BpH2/De 4Ngw== X-Gm-Message-State: AOJu0YxtVZZfipXT+wK/CGnDyf24Leafj7J0lgSW0RD7WualB0PfA5Ka yeZHH8RsL6XTBtFtaStQn/v9HTaX84jHxCZ2v40V/pGiESZBJAfVsGdPIKY0j7ehO6pIrgQkkfs wl8A= X-Gm-Gg: ASbGncsI+TupDx5TP23C6QOHldrK7LIxzU6ynbG1xrmSdD+n+s13/SAElL2tYR1j6Ed Hza4a/jOrAMwtKN7BbSYHw7sLPutURZzFb0WGwlvPLB4U5OlZd+ergs1+7L7d4NfhFHzgD/g/Mt +9poUNdrzsg+V7LZAyD3FDCnErWxdemNsHT6XeLFH30he6Ss4DsxwsrF0frII/biTWQy/myDEf0 GQ4DQlukqPgP6RX3efKxN1YXAP/qyTGwhmk5EycwD08XEZ7Y2+Q4MvBCkm2g1NP7Y/3JZbt/3Tp 9HNsK5/o/KIWeA8bVb7CRlUwF7s8PJfr3lalLDag X-Received: by 2002:a17:903:3c68:b0:223:635d:3e38 with SMTP id d9443c01a7336-22e35fdf7edmr13552305ad.15.1746487233076; Mon, 05 May 2025 16:20:33 -0700 (PDT) Received: from pc.. ([38.41.223.211]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-22e1522917asm60981715ad.201.2025.05.05.16.20.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 May 2025 16:20:32 -0700 (PDT) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org, anjo@rev.ng, Peter Maydell , alex.bennee@linaro.org, kvm@vger.kernel.org, Paolo Bonzini , =?utf-8?q?Philipp?= =?utf-8?q?e_Mathieu-Daud=C3=A9?= , qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v6 14/50] tcg: add vaddr type for helpers Date: Mon, 5 May 2025 16:19:39 -0700 Message-ID: <20250505232015.130990-15-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250505232015.130990-1-pierrick.bouvier@linaro.org> References: <20250505232015.130990-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pl1-x62c.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=unavailable 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 --- 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 aa300a2f8ba..72bfd3485aa 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -188,6 +188,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 @@ -216,6 +217,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 c4e866e9c34..51ec8e04bdc 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -2368,6 +2368,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));