2008-11-17 17:43:54 +03:00
|
|
|
/* Helper file for declaring TCG helper functions.
|
2014-04-08 09:31:41 +04:00
|
|
|
Used by other helper files.
|
2008-11-17 17:43:54 +03:00
|
|
|
|
|
|
|
Targets should use DEF_HELPER_N and DEF_HELPER_FLAGS_N to declare helper
|
|
|
|
functions. Names should be specified without the helper_ prefix, and
|
|
|
|
the return and argument types specified. 3 basic types are understood
|
|
|
|
(i32, i64 and ptr). Additional aliases are provided for convenience and
|
|
|
|
to match the types used by the C helper implementation.
|
|
|
|
|
|
|
|
The target helper.h should be included in all files that use/define
|
|
|
|
helper functions. THis will ensure that function prototypes are
|
|
|
|
consistent. In addition it should be included an extra two times for
|
|
|
|
helper.c, defining:
|
|
|
|
GEN_HELPER 1 to produce op generation functions (gen_helper_*)
|
|
|
|
GEN_HELPER 2 to do runtime registration helper functions.
|
|
|
|
*/
|
|
|
|
|
2016-06-29 11:12:57 +03:00
|
|
|
#ifndef EXEC_HELPER_HEAD_H
|
|
|
|
#define EXEC_HELPER_HEAD_H
|
2014-04-08 10:08:47 +04:00
|
|
|
|
2022-12-17 01:52:02 +03:00
|
|
|
#include "fpu/softfloat-types.h"
|
|
|
|
|
2008-11-17 17:43:54 +03:00
|
|
|
#define HELPER(name) glue(helper_, name)
|
|
|
|
|
|
|
|
/* Some types that make sense in C, but not for TCG. */
|
|
|
|
#define dh_alias_i32 i32
|
|
|
|
#define dh_alias_s32 i32
|
|
|
|
#define dh_alias_int i32
|
|
|
|
#define dh_alias_i64 i64
|
|
|
|
#define dh_alias_s64 i64
|
2022-11-11 03:49:52 +03:00
|
|
|
#define dh_alias_i128 i128
|
2018-03-01 14:05:46 +03:00
|
|
|
#define dh_alias_f16 i32
|
2008-11-17 17:43:54 +03:00
|
|
|
#define dh_alias_f32 i32
|
|
|
|
#define dh_alias_f64 i64
|
|
|
|
#define dh_alias_ptr ptr
|
include/exec/helper-head.h: support "const void *" in helper calls
Especially when dealing with out-of-line gvec helpers, it is often
helpful to specify some vector pointers as constant. E.g. when
we have two inputs and one output, marking the two inputs as consts
pointers helps to avoid bugs.
Const pointers can be specified via "cptr", however behave in TCG just
like ordinary pointers. We can specify helpers like:
DEF_HELPER_FLAGS_4(gvec_vbperm, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32)
void HELPER(gvec_vbperm)(void *v1, const void *v2, const void *v3,
uint32_t desc)
And make sure that here, only v1 will be written (as long as const is
not casted away, of course).
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20190221093459.22547-1-david@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2019-02-21 12:34:59 +03:00
|
|
|
#define dh_alias_cptr ptr
|
2008-11-17 17:43:54 +03:00
|
|
|
#define dh_alias_void void
|
2012-03-19 02:16:02 +04:00
|
|
|
#define dh_alias_noreturn noreturn
|
2008-11-17 17:43:54 +03:00
|
|
|
#define dh_alias(t) glue(dh_alias_, t)
|
|
|
|
|
|
|
|
#define dh_ctype_i32 uint32_t
|
|
|
|
#define dh_ctype_s32 int32_t
|
|
|
|
#define dh_ctype_int int
|
|
|
|
#define dh_ctype_i64 uint64_t
|
|
|
|
#define dh_ctype_s64 int64_t
|
2022-11-11 03:49:52 +03:00
|
|
|
#define dh_ctype_i128 Int128
|
2018-05-31 16:50:51 +03:00
|
|
|
#define dh_ctype_f16 uint32_t
|
2008-11-17 17:43:54 +03:00
|
|
|
#define dh_ctype_f32 float32
|
|
|
|
#define dh_ctype_f64 float64
|
|
|
|
#define dh_ctype_ptr void *
|
include/exec/helper-head.h: support "const void *" in helper calls
Especially when dealing with out-of-line gvec helpers, it is often
helpful to specify some vector pointers as constant. E.g. when
we have two inputs and one output, marking the two inputs as consts
pointers helps to avoid bugs.
Const pointers can be specified via "cptr", however behave in TCG just
like ordinary pointers. We can specify helpers like:
DEF_HELPER_FLAGS_4(gvec_vbperm, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32)
void HELPER(gvec_vbperm)(void *v1, const void *v2, const void *v3,
uint32_t desc)
And make sure that here, only v1 will be written (as long as const is
not casted away, of course).
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20190221093459.22547-1-david@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2019-02-21 12:34:59 +03:00
|
|
|
#define dh_ctype_cptr const void *
|
2008-11-17 17:43:54 +03:00
|
|
|
#define dh_ctype_void void
|
2022-04-20 16:26:02 +03:00
|
|
|
#define dh_ctype_noreturn G_NORETURN void
|
2008-11-17 17:43:54 +03:00
|
|
|
#define dh_ctype(t) dh_ctype_##t
|
|
|
|
|
2016-03-15 14:46:10 +03:00
|
|
|
#ifdef NEED_CPU_H
|
|
|
|
# ifdef TARGET_LONG_BITS
|
|
|
|
# if TARGET_LONG_BITS == 32
|
|
|
|
# define dh_alias_tl i32
|
2022-02-17 04:06:22 +03:00
|
|
|
# define dh_typecode_tl dh_typecode_i32
|
2016-03-15 14:46:10 +03:00
|
|
|
# else
|
|
|
|
# define dh_alias_tl i64
|
2022-02-17 04:06:22 +03:00
|
|
|
# define dh_typecode_tl dh_typecode_i64
|
2016-03-15 14:46:10 +03:00
|
|
|
# endif
|
|
|
|
# endif
|
|
|
|
# define dh_ctype_tl target_ulong
|
2022-02-17 04:06:22 +03:00
|
|
|
# define dh_alias_env ptr
|
2016-03-15 14:46:10 +03:00
|
|
|
# define dh_ctype_env CPUArchState *
|
2022-02-17 04:06:22 +03:00
|
|
|
# define dh_typecode_env dh_typecode_ptr
|
2016-03-15 14:46:10 +03:00
|
|
|
#endif
|
|
|
|
|
2008-11-17 17:43:54 +03:00
|
|
|
/* We can't use glue() here because it falls foul of C preprocessor
|
|
|
|
recursive expansion rules. */
|
|
|
|
#define dh_retvar_decl0_void void
|
2012-03-19 02:16:02 +04:00
|
|
|
#define dh_retvar_decl0_noreturn void
|
2008-11-17 17:43:54 +03:00
|
|
|
#define dh_retvar_decl0_i32 TCGv_i32 retval
|
|
|
|
#define dh_retvar_decl0_i64 TCGv_i64 retval
|
2022-11-11 03:49:52 +03:00
|
|
|
#define dh_retval_decl0_i128 TCGv_i128 retval
|
2009-07-19 23:46:09 +04:00
|
|
|
#define dh_retvar_decl0_ptr TCGv_ptr retval
|
2008-11-17 17:43:54 +03:00
|
|
|
#define dh_retvar_decl0(t) glue(dh_retvar_decl0_, dh_alias(t))
|
|
|
|
|
|
|
|
#define dh_retvar_decl_void
|
2012-03-19 02:16:02 +04:00
|
|
|
#define dh_retvar_decl_noreturn
|
2008-11-17 17:43:54 +03:00
|
|
|
#define dh_retvar_decl_i32 TCGv_i32 retval,
|
|
|
|
#define dh_retvar_decl_i64 TCGv_i64 retval,
|
2022-11-11 03:49:52 +03:00
|
|
|
#define dh_retvar_decl_i128 TCGv_i128 retval,
|
2009-07-19 23:46:09 +04:00
|
|
|
#define dh_retvar_decl_ptr TCGv_ptr retval,
|
2008-11-17 17:43:54 +03:00
|
|
|
#define dh_retvar_decl(t) glue(dh_retvar_decl_, dh_alias(t))
|
|
|
|
|
2017-10-15 23:27:56 +03:00
|
|
|
#define dh_retvar_void NULL
|
|
|
|
#define dh_retvar_noreturn NULL
|
|
|
|
#define dh_retvar_i32 tcgv_i32_temp(retval)
|
|
|
|
#define dh_retvar_i64 tcgv_i64_temp(retval)
|
2022-11-11 03:49:52 +03:00
|
|
|
#define dh_retvar_i128 tcgv_i128_temp(retval)
|
2017-10-15 23:27:56 +03:00
|
|
|
#define dh_retvar_ptr tcgv_ptr_temp(retval)
|
2008-11-17 17:43:54 +03:00
|
|
|
#define dh_retvar(t) glue(dh_retvar_, dh_alias(t))
|
|
|
|
|
2021-03-18 19:01:01 +03:00
|
|
|
#define dh_typecode_void 0
|
|
|
|
#define dh_typecode_noreturn 0
|
|
|
|
#define dh_typecode_i32 2
|
|
|
|
#define dh_typecode_s32 3
|
|
|
|
#define dh_typecode_i64 4
|
|
|
|
#define dh_typecode_s64 5
|
|
|
|
#define dh_typecode_ptr 6
|
2022-11-11 03:49:52 +03:00
|
|
|
#define dh_typecode_i128 7
|
2022-02-17 04:06:22 +03:00
|
|
|
#define dh_typecode_int dh_typecode_s32
|
|
|
|
#define dh_typecode_f16 dh_typecode_i32
|
|
|
|
#define dh_typecode_f32 dh_typecode_i32
|
|
|
|
#define dh_typecode_f64 dh_typecode_i64
|
|
|
|
#define dh_typecode_cptr dh_typecode_ptr
|
|
|
|
#define dh_typecode(t) dh_typecode_##t
|
2010-06-15 04:35:27 +04:00
|
|
|
|
2018-11-26 22:32:38 +03:00
|
|
|
#define dh_callflag_i32 0
|
|
|
|
#define dh_callflag_i64 0
|
2022-11-11 03:49:52 +03:00
|
|
|
#define dh_callflag_i128 0
|
2018-11-26 22:32:38 +03:00
|
|
|
#define dh_callflag_ptr 0
|
|
|
|
#define dh_callflag_void 0
|
|
|
|
#define dh_callflag_noreturn TCG_CALL_NO_RETURN
|
|
|
|
#define dh_callflag(t) glue(dh_callflag_, dh_alias(t))
|
|
|
|
|
2021-03-18 19:01:01 +03:00
|
|
|
#define dh_typemask(t, n) (dh_typecode(t) << (n * 3))
|
2010-06-15 04:35:27 +04:00
|
|
|
|
2008-11-17 17:43:54 +03:00
|
|
|
#define dh_arg(t, n) \
|
2017-10-15 23:27:56 +03:00
|
|
|
glue(glue(tcgv_, dh_alias(t)), _temp)(glue(arg, n))
|
2008-11-17 17:43:54 +03:00
|
|
|
|
|
|
|
#define dh_arg_decl(t, n) glue(TCGv_, dh_alias(t)) glue(arg, n)
|
|
|
|
|
|
|
|
#define DEF_HELPER_0(name, ret) \
|
|
|
|
DEF_HELPER_FLAGS_0(name, 0, ret)
|
|
|
|
#define DEF_HELPER_1(name, ret, t1) \
|
|
|
|
DEF_HELPER_FLAGS_1(name, 0, ret, t1)
|
|
|
|
#define DEF_HELPER_2(name, ret, t1, t2) \
|
|
|
|
DEF_HELPER_FLAGS_2(name, 0, ret, t1, t2)
|
|
|
|
#define DEF_HELPER_3(name, ret, t1, t2, t3) \
|
|
|
|
DEF_HELPER_FLAGS_3(name, 0, ret, t1, t2, t3)
|
|
|
|
#define DEF_HELPER_4(name, ret, t1, t2, t3, t4) \
|
|
|
|
DEF_HELPER_FLAGS_4(name, 0, ret, t1, t2, t3, t4)
|
2011-07-12 17:14:47 +04:00
|
|
|
#define DEF_HELPER_5(name, ret, t1, t2, t3, t4, t5) \
|
|
|
|
DEF_HELPER_FLAGS_5(name, 0, ret, t1, t2, t3, t4, t5)
|
2017-12-14 01:52:57 +03:00
|
|
|
#define DEF_HELPER_6(name, ret, t1, t2, t3, t4, t5, t6) \
|
|
|
|
DEF_HELPER_FLAGS_6(name, 0, ret, t1, t2, t3, t4, t5, t6)
|
2020-02-06 01:41:50 +03:00
|
|
|
#define DEF_HELPER_7(name, ret, t1, t2, t3, t4, t5, t6, t7) \
|
|
|
|
DEF_HELPER_FLAGS_7(name, 0, ret, t1, t2, t3, t4, t5, t6, t7)
|
2008-11-17 17:43:54 +03:00
|
|
|
|
2022-11-11 03:09:37 +03:00
|
|
|
/* MAX_CALL_IARGS must be set to n if last entry is DEF_HELPER_FLAGS_n. */
|
|
|
|
|
2016-06-29 11:12:57 +03:00
|
|
|
#endif /* EXEC_HELPER_HEAD_H */
|