tcg: add vaddr type for helpers

Defined as an alias of i32/i64 depending on host pointer size.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-id: 20250512180502.2395029-13-pierrick.bouvier@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Pierrick Bouvier 2025-05-12 11:04:26 -07:00 committed by Peter Maydell
parent b757ae80c6
commit 21a75f792f
4 changed files with 31 additions and 0 deletions

View file

@ -58,6 +58,17 @@
# define dh_ctype_tl target_ulong # define dh_ctype_tl target_ulong
#endif /* COMPILING_PER_TARGET */ #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 /* We can't use glue() here because it falls foul of C preprocessor
recursive expansion rules. */ recursive expansion rules. */
#define dh_retvar_decl0_void void #define dh_retvar_decl0_void void

View file

@ -14,6 +14,7 @@
TCGv_i32 tcg_constant_i32(int32_t val); TCGv_i32 tcg_constant_i32(int32_t val);
TCGv_i64 tcg_constant_i64(int64_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(TCGType type, unsigned vece, int64_t val);
TCGv_vec tcg_constant_vec_matching(TCGv_vec match, unsigned vece, int64_t val); TCGv_vec tcg_constant_vec_matching(TCGv_vec match, unsigned vece, int64_t val);

View file

@ -189,6 +189,7 @@ typedef tcg_target_ulong TCGArg;
* TCGv_i64 : 64 bit integer type * TCGv_i64 : 64 bit integer type
* TCGv_i128 : 128 bit integer type * TCGv_i128 : 128 bit integer type
* TCGv_ptr : a host pointer 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 * TCGv_vec : a host vector type; the exact size is not exposed
to the CPU front-end code. to the CPU front-end code.
* TCGv : an integer type the same size as target_ulong * 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 struct TCGv_vec_d *TCGv_vec;
typedef TCGv_ptr TCGv_env; 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 */ /* call flags */
/* Helper does not read globals (either directly or through an exception). It /* Helper does not read globals (either directly or through an exception). It
implies TCG_CALL_NO_WRITE_GLOBALS. */ 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); 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) static inline TCGv_vec temp_tcgv_vec(TCGTemp *t)
{ {
return (TCGv_vec)temp_tcgv_i32(t); return (TCGv_vec)temp_tcgv_i32(t);

View file

@ -2367,6 +2367,11 @@ TCGv_i64 tcg_constant_i64(int64_t val)
return temp_tcgv_i64(tcg_constant_internal(TCG_TYPE_I64, 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) TCGv_ptr tcg_constant_ptr_int(intptr_t val)
{ {
return temp_tcgv_ptr(tcg_constant_internal(TCG_TYPE_PTR, val)); return temp_tcgv_ptr(tcg_constant_internal(TCG_TYPE_PTR, val));