numa: add -numa node,memdev= option
[qemu.git] / include / exec / helper-head.h
1 /* Helper file for declaring TCG helper functions.
2 Used by other helper files.
3
4 Targets should use DEF_HELPER_N and DEF_HELPER_FLAGS_N to declare helper
5 functions. Names should be specified without the helper_ prefix, and
6 the return and argument types specified. 3 basic types are understood
7 (i32, i64 and ptr). Additional aliases are provided for convenience and
8 to match the types used by the C helper implementation.
9
10 The target helper.h should be included in all files that use/define
11 helper functions. THis will ensure that function prototypes are
12 consistent. In addition it should be included an extra two times for
13 helper.c, defining:
14 GEN_HELPER 1 to produce op generation functions (gen_helper_*)
15 GEN_HELPER 2 to do runtime registration helper functions.
16 */
17
18 #ifndef DEF_HELPER_H
19 #define DEF_HELPER_H 1
20
21 #include "qemu/osdep.h"
22
23 #define HELPER(name) glue(helper_, name)
24
25 #define GET_TCGV_i32 GET_TCGV_I32
26 #define GET_TCGV_i64 GET_TCGV_I64
27 #define GET_TCGV_ptr GET_TCGV_PTR
28
29 /* Some types that make sense in C, but not for TCG. */
30 #define dh_alias_i32 i32
31 #define dh_alias_s32 i32
32 #define dh_alias_int i32
33 #define dh_alias_i64 i64
34 #define dh_alias_s64 i64
35 #define dh_alias_f32 i32
36 #define dh_alias_f64 i64
37 #ifdef TARGET_LONG_BITS
38 # if TARGET_LONG_BITS == 32
39 # define dh_alias_tl i32
40 # else
41 # define dh_alias_tl i64
42 # endif
43 #endif
44 #define dh_alias_ptr ptr
45 #define dh_alias_void void
46 #define dh_alias_noreturn noreturn
47 #define dh_alias_env ptr
48 #define dh_alias(t) glue(dh_alias_, t)
49
50 #define dh_ctype_i32 uint32_t
51 #define dh_ctype_s32 int32_t
52 #define dh_ctype_int int
53 #define dh_ctype_i64 uint64_t
54 #define dh_ctype_s64 int64_t
55 #define dh_ctype_f32 float32
56 #define dh_ctype_f64 float64
57 #define dh_ctype_tl target_ulong
58 #define dh_ctype_ptr void *
59 #define dh_ctype_void void
60 #define dh_ctype_noreturn void QEMU_NORETURN
61 #define dh_ctype_env CPUArchState *
62 #define dh_ctype(t) dh_ctype_##t
63
64 /* We can't use glue() here because it falls foul of C preprocessor
65 recursive expansion rules. */
66 #define dh_retvar_decl0_void void
67 #define dh_retvar_decl0_noreturn void
68 #define dh_retvar_decl0_i32 TCGv_i32 retval
69 #define dh_retvar_decl0_i64 TCGv_i64 retval
70 #define dh_retvar_decl0_ptr TCGv_ptr retval
71 #define dh_retvar_decl0(t) glue(dh_retvar_decl0_, dh_alias(t))
72
73 #define dh_retvar_decl_void
74 #define dh_retvar_decl_noreturn
75 #define dh_retvar_decl_i32 TCGv_i32 retval,
76 #define dh_retvar_decl_i64 TCGv_i64 retval,
77 #define dh_retvar_decl_ptr TCGv_ptr retval,
78 #define dh_retvar_decl(t) glue(dh_retvar_decl_, dh_alias(t))
79
80 #define dh_retvar_void TCG_CALL_DUMMY_ARG
81 #define dh_retvar_noreturn TCG_CALL_DUMMY_ARG
82 #define dh_retvar_i32 GET_TCGV_i32(retval)
83 #define dh_retvar_i64 GET_TCGV_i64(retval)
84 #define dh_retvar_ptr GET_TCGV_ptr(retval)
85 #define dh_retvar(t) glue(dh_retvar_, dh_alias(t))
86
87 #define dh_is_64bit_void 0
88 #define dh_is_64bit_noreturn 0
89 #define dh_is_64bit_i32 0
90 #define dh_is_64bit_i64 1
91 #define dh_is_64bit_ptr (sizeof(void *) == 8)
92 #define dh_is_64bit(t) glue(dh_is_64bit_, dh_alias(t))
93
94 #define dh_is_signed_void 0
95 #define dh_is_signed_noreturn 0
96 #define dh_is_signed_i32 0
97 #define dh_is_signed_s32 1
98 #define dh_is_signed_i64 0
99 #define dh_is_signed_s64 1
100 #define dh_is_signed_f32 0
101 #define dh_is_signed_f64 0
102 #define dh_is_signed_tl 0
103 #define dh_is_signed_int 1
104 /* ??? This is highly specific to the host cpu. There are even special
105 extension instructions that may be required, e.g. ia64's addp4. But
106 for now we don't support any 64-bit targets with 32-bit pointers. */
107 #define dh_is_signed_ptr 0
108 #define dh_is_signed_env dh_is_signed_ptr
109 #define dh_is_signed(t) dh_is_signed_##t
110
111 #define dh_sizemask(t, n) \
112 ((dh_is_64bit(t) << (n*2)) | (dh_is_signed(t) << (n*2+1)))
113
114 #define dh_arg(t, n) \
115 glue(GET_TCGV_, dh_alias(t))(glue(arg, n))
116
117 #define dh_arg_decl(t, n) glue(TCGv_, dh_alias(t)) glue(arg, n)
118
119 #define DEF_HELPER_0(name, ret) \
120 DEF_HELPER_FLAGS_0(name, 0, ret)
121 #define DEF_HELPER_1(name, ret, t1) \
122 DEF_HELPER_FLAGS_1(name, 0, ret, t1)
123 #define DEF_HELPER_2(name, ret, t1, t2) \
124 DEF_HELPER_FLAGS_2(name, 0, ret, t1, t2)
125 #define DEF_HELPER_3(name, ret, t1, t2, t3) \
126 DEF_HELPER_FLAGS_3(name, 0, ret, t1, t2, t3)
127 #define DEF_HELPER_4(name, ret, t1, t2, t3, t4) \
128 DEF_HELPER_FLAGS_4(name, 0, ret, t1, t2, t3, t4)
129 #define DEF_HELPER_5(name, ret, t1, t2, t3, t4, t5) \
130 DEF_HELPER_FLAGS_5(name, 0, ret, t1, t2, t3, t4, t5)
131
132 /* MAX_OPC_PARAM_IARGS must be set to n if last entry is DEF_HELPER_FLAGS_n. */
133
134 #endif /* DEF_HELPER_H */