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