Defined as an alias of i32/i64 depending on host pointer size. Signed-off-by: Pierrick Bouvier <pierrick.bouv...@linaro.org> --- include/tcg/tcg-op-common.h | 1 + include/tcg/tcg.h | 17 +++++++++++++++++ include/exec/helper-head.h.inc | 11 +++++++++++ tcg/tcg.c | 6 ++++++ 4 files changed, 35 insertions(+)
diff --git a/include/tcg/tcg-op-common.h b/include/tcg/tcg-op-common.h index b439bdb385a..7d7375eef44 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(vaddr 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..0eb033aa7d1 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 large 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 @@ -214,6 +215,7 @@ typedef struct TCGv_i64_d *TCGv_i64; typedef struct TCGv_i128_d *TCGv_i128; typedef struct TCGv_ptr_d *TCGv_ptr; typedef struct TCGv_vec_d *TCGv_vec; +typedef struct TCGv_vaddr_d *TCGv_vaddr; typedef TCGv_ptr TCGv_env; /* call flags */ @@ -526,6 +528,11 @@ static inline TCGTemp *tcgv_ptr_temp(TCGv_ptr v) return tcgv_i32_temp((TCGv_i32)v); } +static inline TCGTemp *tcgv_vaddr_temp(TCGv_vaddr v) +{ + return tcgv_i32_temp((TCGv_i32)v); +} + static inline TCGTemp *tcgv_vec_temp(TCGv_vec v) { return tcgv_i32_temp((TCGv_i32)v); @@ -551,6 +558,11 @@ static inline TCGArg tcgv_ptr_arg(TCGv_ptr v) return temp_arg(tcgv_ptr_temp(v)); } +static inline TCGArg tcgv_vaddr_arg(TCGv_vaddr v) +{ + return temp_arg(tcgv_vaddr_temp(v)); +} + static inline TCGArg tcgv_vec_arg(TCGv_vec v) { return temp_arg(tcgv_vec_temp(v)); @@ -572,6 +584,11 @@ static inline TCGv_i128 temp_tcgv_i128(TCGTemp *t) return (TCGv_i128)temp_tcgv_i32(t); } +static inline TCGv_vaddr temp_tcgv_vaddr(TCGTemp *t) +{ + return (TCGv_vaddr)temp_tcgv_i32(t); +} + static inline TCGv_ptr temp_tcgv_ptr(TCGTemp *t) { return (TCGv_ptr)temp_tcgv_i32(t); diff --git a/include/exec/helper-head.h.inc b/include/exec/helper-head.h.inc index bce5db06ef3..b15256ce14d 100644 --- a/include/exec/helper-head.h.inc +++ b/include/exec/helper-head.h.inc @@ -21,6 +21,7 @@ #define dh_alias_f32 i32 #define dh_alias_f64 i64 #define dh_alias_ptr ptr +#define dh_alias_vaddr vaddr #define dh_alias_cptr ptr #define dh_alias_env ptr #define dh_alias_fpst ptr @@ -37,6 +38,7 @@ #define dh_ctype_f16 uint32_t #define dh_ctype_f32 float32 #define dh_ctype_f64 float64 +#define dh_ctype_vaddr uintptr_t #define dh_ctype_ptr void * #define dh_ctype_cptr const void * #define dh_ctype_env CPUArchState * @@ -91,6 +93,15 @@ #define dh_typecode_i64 4 #define dh_typecode_s64 5 #define dh_typecode_ptr 6 + +#if __SIZEOF_POINTER__ == 4 +# define dh_typecode_vaddr dh_typecode_i32 +#elif __SIZEOF_POINTER__ == 8 +# define dh_typecode_vaddr dh_typecode_i64 +#else +# error "sizeof pointer is different from {4,8}" +#endif + #define dh_typecode_i128 7 #define dh_typecode_int dh_typecode_s32 #define dh_typecode_f16 dh_typecode_i32 diff --git a/tcg/tcg.c b/tcg/tcg.c index c4e866e9c34..e86576120c0 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -2368,6 +2368,12 @@ TCGv_i64 tcg_constant_i64(int64_t val) return temp_tcgv_i64(tcg_constant_internal(TCG_TYPE_I64, val)); } +TCGv_vaddr tcg_constant_vaddr(vaddr val) +{ + TCGType type = __SIZEOF_POINTER__ == 8 ? TCG_TYPE_I64 : TCG_TYPE_I32; + return temp_tcgv_vaddr(tcg_constant_internal(type, val)); +} + TCGv_ptr tcg_constant_ptr_int(intptr_t val) { return temp_tcgv_ptr(tcg_constant_internal(TCG_TYPE_PTR, val)); -- 2.47.2