xref: /openbmc/qemu/include/exec/helper-head.h.inc (revision 2379866c)
1/*
2 * Helper file for declaring TCG helper functions.
3 * Used by other helper files.
4 */
5
6#ifndef EXEC_HELPER_HEAD_H
7#define EXEC_HELPER_HEAD_H
8
9#include "fpu/softfloat-types.h"
10
11#define HELPER(name) glue(helper_, name)
12
13/* Some types that make sense in C, but not for TCG.  */
14#define dh_alias_i32 i32
15#define dh_alias_s32 i32
16#define dh_alias_int i32
17#define dh_alias_i64 i64
18#define dh_alias_s64 i64
19#define dh_alias_i128 i128
20#define dh_alias_f16 i32
21#define dh_alias_f32 i32
22#define dh_alias_f64 i64
23#define dh_alias_ptr ptr
24#define dh_alias_cptr ptr
25#define dh_alias_env ptr
26#define dh_alias_void void
27#define dh_alias_noreturn noreturn
28#define dh_alias(t) glue(dh_alias_, t)
29
30#define dh_ctype_i32 uint32_t
31#define dh_ctype_s32 int32_t
32#define dh_ctype_int int
33#define dh_ctype_i64 uint64_t
34#define dh_ctype_s64 int64_t
35#define dh_ctype_i128 Int128
36#define dh_ctype_f16 uint32_t
37#define dh_ctype_f32 float32
38#define dh_ctype_f64 float64
39#define dh_ctype_ptr void *
40#define dh_ctype_cptr const void *
41#define dh_ctype_env CPUArchState *
42#define dh_ctype_void void
43#define dh_ctype_noreturn G_NORETURN void
44#define dh_ctype(t) dh_ctype_##t
45
46#ifdef COMPILING_PER_TARGET
47# ifdef TARGET_LONG_BITS
48#  if TARGET_LONG_BITS == 32
49#   define dh_alias_tl i32
50#   define dh_typecode_tl dh_typecode_i32
51#  else
52#   define dh_alias_tl i64
53#   define dh_typecode_tl dh_typecode_i64
54#  endif
55# endif
56# define dh_ctype_tl target_ulong
57#endif /* COMPILING_PER_TARGET */
58
59/* We can't use glue() here because it falls foul of C preprocessor
60   recursive expansion rules.  */
61#define dh_retvar_decl0_void void
62#define dh_retvar_decl0_noreturn void
63#define dh_retvar_decl0_i32 TCGv_i32 retval
64#define dh_retvar_decl0_i64 TCGv_i64 retval
65#define dh_retval_decl0_i128 TCGv_i128 retval
66#define dh_retvar_decl0_ptr TCGv_ptr retval
67#define dh_retvar_decl0(t) glue(dh_retvar_decl0_, dh_alias(t))
68
69#define dh_retvar_decl_void
70#define dh_retvar_decl_noreturn
71#define dh_retvar_decl_i32 TCGv_i32 retval,
72#define dh_retvar_decl_i64 TCGv_i64 retval,
73#define dh_retvar_decl_i128 TCGv_i128 retval,
74#define dh_retvar_decl_ptr TCGv_ptr retval,
75#define dh_retvar_decl(t) glue(dh_retvar_decl_, dh_alias(t))
76
77#define dh_retvar_void NULL
78#define dh_retvar_noreturn NULL
79#define dh_retvar_i32 tcgv_i32_temp(retval)
80#define dh_retvar_i64 tcgv_i64_temp(retval)
81#define dh_retvar_i128 tcgv_i128_temp(retval)
82#define dh_retvar_ptr tcgv_ptr_temp(retval)
83#define dh_retvar(t) glue(dh_retvar_, dh_alias(t))
84
85#define dh_typecode_void 0
86#define dh_typecode_noreturn 0
87#define dh_typecode_i32 2
88#define dh_typecode_s32 3
89#define dh_typecode_i64 4
90#define dh_typecode_s64 5
91#define dh_typecode_ptr 6
92#define dh_typecode_i128 7
93#define dh_typecode_int dh_typecode_s32
94#define dh_typecode_f16 dh_typecode_i32
95#define dh_typecode_f32 dh_typecode_i32
96#define dh_typecode_f64 dh_typecode_i64
97#define dh_typecode_cptr dh_typecode_ptr
98#define dh_typecode_env dh_typecode_ptr
99#define dh_typecode(t) dh_typecode_##t
100
101#define dh_callflag_i32  0
102#define dh_callflag_i64  0
103#define dh_callflag_i128 0
104#define dh_callflag_ptr  0
105#define dh_callflag_void 0
106#define dh_callflag_noreturn TCG_CALL_NO_RETURN
107#define dh_callflag(t) glue(dh_callflag_, dh_alias(t))
108
109#define dh_typemask(t, n)  (dh_typecode(t) << (n * 3))
110
111#define dh_arg(t, n) \
112  glue(glue(tcgv_, dh_alias(t)), _temp)(glue(arg, n))
113
114#define dh_arg_decl(t, n) glue(TCGv_, dh_alias(t)) glue(arg, n)
115
116#define DEF_HELPER_0(name, ret) \
117    DEF_HELPER_FLAGS_0(name, 0, ret)
118#define DEF_HELPER_1(name, ret, t1) \
119    DEF_HELPER_FLAGS_1(name, 0, ret, t1)
120#define DEF_HELPER_2(name, ret, t1, t2) \
121    DEF_HELPER_FLAGS_2(name, 0, ret, t1, t2)
122#define DEF_HELPER_3(name, ret, t1, t2, t3) \
123    DEF_HELPER_FLAGS_3(name, 0, ret, t1, t2, t3)
124#define DEF_HELPER_4(name, ret, t1, t2, t3, t4) \
125    DEF_HELPER_FLAGS_4(name, 0, ret, t1, t2, t3, t4)
126#define DEF_HELPER_5(name, ret, t1, t2, t3, t4, t5) \
127    DEF_HELPER_FLAGS_5(name, 0, ret, t1, t2, t3, t4, t5)
128#define DEF_HELPER_6(name, ret, t1, t2, t3, t4, t5, t6) \
129    DEF_HELPER_FLAGS_6(name, 0, ret, t1, t2, t3, t4, t5, t6)
130#define DEF_HELPER_7(name, ret, t1, t2, t3, t4, t5, t6, t7) \
131    DEF_HELPER_FLAGS_7(name, 0, ret, t1, t2, t3, t4, t5, t6, t7)
132
133/* MAX_CALL_IARGS must be set to n if last entry is DEF_HELPER_FLAGS_n. */
134
135#endif /* EXEC_HELPER_HEAD_H */
136