diff options
Diffstat (limited to 'src/lj_ircall.h')
-rw-r--r-- | src/lj_ircall.h | 123 |
1 files changed, 123 insertions, 0 deletions
diff --git a/src/lj_ircall.h b/src/lj_ircall.h index 3131b15d..b83a0a81 100644 --- a/src/lj_ircall.h +++ b/src/lj_ircall.h | |||
@@ -38,6 +38,72 @@ typedef struct CCallInfo { | |||
38 | #define CCI_FASTCALL 0x0800 /* Fastcall convention. */ | 38 | #define CCI_FASTCALL 0x0800 /* Fastcall convention. */ |
39 | 39 | ||
40 | /* Function definitions for CALL* instructions. */ | 40 | /* Function definitions for CALL* instructions. */ |
41 | #if LJ_SOFTFP | ||
42 | #if LJ_HASFFI | ||
43 | #define IRCALLDEF_SOFTFP_FFI(_) \ | ||
44 | _(softfp_ui2d, 1, N, NUM, 0) \ | ||
45 | _(softfp_l2d, 2, N, NUM, 0) \ | ||
46 | _(softfp_ul2d, 2, N, NUM, 0) \ | ||
47 | _(softfp_f2d, 1, N, NUM, 0) \ | ||
48 | _(softfp_d2ui, 2, N, INT, 0) \ | ||
49 | _(softfp_d2l, 2, N, I64, 0) \ | ||
50 | _(softfp_d2ul, 2, N, U64, 0) \ | ||
51 | _(softfp_d2f, 2, N, FLOAT, 0) \ | ||
52 | _(softfp_i2f, 1, N, FLOAT, 0) \ | ||
53 | _(softfp_ui2f, 1, N, FLOAT, 0) \ | ||
54 | _(softfp_l2f, 2, N, FLOAT, 0) \ | ||
55 | _(softfp_ul2f, 2, N, FLOAT, 0) \ | ||
56 | _(softfp_f2i, 1, N, INT, 0) \ | ||
57 | _(softfp_f2ui, 1, N, INT, 0) \ | ||
58 | _(softfp_f2l, 1, N, I64, 0) \ | ||
59 | _(softfp_f2ul, 1, N, U64, 0) | ||
60 | #else | ||
61 | #define IRCALLDEF_SOFTFP_FFI(_) | ||
62 | #endif | ||
63 | #define IRCALLDEF_SOFTFP(_) \ | ||
64 | _(lj_vm_tobit, 2, N, INT, 0) \ | ||
65 | _(softfp_add, 4, N, NUM, 0) \ | ||
66 | _(softfp_sub, 4, N, NUM, 0) \ | ||
67 | _(softfp_mul, 4, N, NUM, 0) \ | ||
68 | _(softfp_div, 4, N, NUM, 0) \ | ||
69 | _(softfp_cmp, 4, N, NIL, 0) \ | ||
70 | _(softfp_i2d, 1, N, NUM, 0) \ | ||
71 | _(softfp_d2i, 2, N, INT, 0) \ | ||
72 | IRCALLDEF_SOFTFP_FFI(_) | ||
73 | #else | ||
74 | #define IRCALLDEF_SOFTFP(_) | ||
75 | #endif | ||
76 | |||
77 | #if LJ_TARGET_X86ORX64 | ||
78 | /* Use lj_vm_* helpers and x87 ops. */ | ||
79 | #define IRCALLDEF_FPMATH(_) | ||
80 | #else | ||
81 | /* Use standard math library calls. */ | ||
82 | #if LJ_SOFTFP | ||
83 | #define ARG1_FP 2 /* Treat as 2 32 bit arguments. */ | ||
84 | #else | ||
85 | #define ARG1_FP 1 | ||
86 | #endif | ||
87 | /* ORDER FPM */ | ||
88 | #define IRCALLDEF_FPMATH(_) \ | ||
89 | _(lj_vm_floor, ARG1_FP, N, NUM, 0) \ | ||
90 | _(lj_vm_ceil, ARG1_FP, N, NUM, 0) \ | ||
91 | _(lj_vm_trunc, ARG1_FP, N, NUM, 0) \ | ||
92 | _(sqrt, ARG1_FP, N, NUM, 0) \ | ||
93 | _(exp, ARG1_FP, N, NUM, 0) \ | ||
94 | _(exp2, ARG1_FP, N, NUM, 0) \ | ||
95 | _(log, ARG1_FP, N, NUM, 0) \ | ||
96 | _(log2, ARG1_FP, N, NUM, 0) \ | ||
97 | _(log10, ARG1_FP, N, NUM, 0) \ | ||
98 | _(sin, ARG1_FP, N, NUM, 0) \ | ||
99 | _(cos, ARG1_FP, N, NUM, 0) \ | ||
100 | _(tan, ARG1_FP, N, NUM, 0) \ | ||
101 | _(lj_vm_powi, ARG1_FP+1, N, NUM, 0) \ | ||
102 | _(pow, ARG1_FP*2, N, NUM, 0) \ | ||
103 | _(atan2, ARG1_FP*2, N, NUM, 0) \ | ||
104 | _(ldexp, ARG1_FP+1, N, NUM, 0) | ||
105 | #endif | ||
106 | |||
41 | #if LJ_HASFFI | 107 | #if LJ_HASFFI |
42 | #if LJ_32 | 108 | #if LJ_32 |
43 | #define ARG2_64 4 /* Treat as 4 32 bit arguments. */ | 109 | #define ARG2_64 4 /* Treat as 4 32 bit arguments. */ |
@@ -62,6 +128,7 @@ typedef struct CCallInfo { | |||
62 | #else | 128 | #else |
63 | #define IRCALLDEF_FFI(_) | 129 | #define IRCALLDEF_FFI(_) |
64 | #endif | 130 | #endif |
131 | |||
65 | #define IRCALLDEF(_) \ | 132 | #define IRCALLDEF(_) \ |
66 | _(lj_str_cmp, 2, FN, INT, CCI_NOFPRCLOBBER) \ | 133 | _(lj_str_cmp, 2, FN, INT, CCI_NOFPRCLOBBER) \ |
67 | _(lj_str_new, 3, S, STR, CCI_L) \ | 134 | _(lj_str_new, 3, S, STR, CCI_L) \ |
@@ -76,6 +143,8 @@ typedef struct CCallInfo { | |||
76 | _(lj_gc_barrieruv, 2, FS, NIL, 0) \ | 143 | _(lj_gc_barrieruv, 2, FS, NIL, 0) \ |
77 | _(lj_mem_newgco, 2, FS, P32, CCI_L) \ | 144 | _(lj_mem_newgco, 2, FS, P32, CCI_L) \ |
78 | _(lj_math_random_step, 1, FS, NUM, CCI_CASTU64|CCI_NOFPRCLOBBER) \ | 145 | _(lj_math_random_step, 1, FS, NUM, CCI_CASTU64|CCI_NOFPRCLOBBER) \ |
146 | IRCALLDEF_SOFTFP(_) \ | ||
147 | IRCALLDEF_FPMATH(_) \ | ||
79 | IRCALLDEF_FFI(_) \ | 148 | IRCALLDEF_FFI(_) \ |
80 | _(sinh, 1, N, NUM, 0) \ | 149 | _(sinh, 1, N, NUM, 0) \ |
81 | _(cosh, 1, N, NUM, 0) \ | 150 | _(cosh, 1, N, NUM, 0) \ |
@@ -97,4 +166,58 @@ LJ_FUNC TRef lj_ir_call(jit_State *J, IRCallID id, ...); | |||
97 | 166 | ||
98 | LJ_DATA const CCallInfo lj_ir_callinfo[IRCALL__MAX+1]; | 167 | LJ_DATA const CCallInfo lj_ir_callinfo[IRCALL__MAX+1]; |
99 | 168 | ||
169 | /* Soft-float declarations. */ | ||
170 | #if LJ_SOFTFP | ||
171 | #if LJ_TARGET_ARM | ||
172 | #define softfp_add __aeabi_dadd | ||
173 | #define softfp_sub __aeabi_dsub | ||
174 | #define softfp_mul __aeabi_dmul | ||
175 | #define softfp_div __aeabi_ddiv | ||
176 | #define softfp_cmp __aeabi_cdcmple | ||
177 | #define softfp_i2d __aeabi_i2d | ||
178 | #define softfp_ui2d __aeabi_ui2d | ||
179 | #define softfp_l2d __aeabi_l2d | ||
180 | #define softfp_ul2d __aeabi_ul2d | ||
181 | #define softfp_f2d __aeabi_f2d | ||
182 | #define softfp_d2i __aeabi_d2iz | ||
183 | #define softfp_d2ui __aeabi_d2uiz | ||
184 | #define softfp_d2l __aeabi_d2lz | ||
185 | #define softfp_d2ul __aeabi_d2ulz | ||
186 | #define softfp_d2f __aeabi_d2f | ||
187 | #define softfp_i2f __aeabi_i2f | ||
188 | #define softfp_ui2f __aeabi_ui2f | ||
189 | #define softfp_l2f __aeabi_l2f | ||
190 | #define softfp_ul2f __aeabi_ul2f | ||
191 | #define softfp_f2i __aeabi_f2iz | ||
192 | #define softfp_f2ui __aeabi_f2uiz | ||
193 | #define softfp_f2l __aeabi_f2lz | ||
194 | #define softfp_f2ul __aeabi_f2ulz | ||
195 | #else | ||
196 | #error "Missing soft-float definitions for target architecture" | ||
197 | #endif | ||
198 | extern double softfp_add(double a, double b); | ||
199 | extern double softfp_sub(double a, double b); | ||
200 | extern double softfp_mul(double a, double b); | ||
201 | extern double softfp_div(double a, double b); | ||
202 | extern void softfp_cmp(double a, double b); | ||
203 | extern double softfp_i2d(int32_t a); | ||
204 | extern double softfp_ui2d(uint32_t a); | ||
205 | extern double softfp_l2d(int64_t a); | ||
206 | extern double softfp_ul2d(uint64_t a); | ||
207 | extern double softfp_f2d(float a); | ||
208 | extern int32_t softfp_d2i(double a); | ||
209 | extern uint32_t softfp_d2ui(double a); | ||
210 | extern int64_t softfp_d2l(double a); | ||
211 | extern uint64_t softfp_d2ul(double a); | ||
212 | extern float softfp_d2f(double a); | ||
213 | extern float softfp_i2f(int32_t a); | ||
214 | extern float softfp_ui2f(uint32_t a); | ||
215 | extern float softfp_l2f(int64_t a); | ||
216 | extern float softfp_ul2f(uint64_t a); | ||
217 | extern int32_t softfp_f2i(float a); | ||
218 | extern uint32_t softfp_f2ui(float a); | ||
219 | extern int64_t softfp_f2l(float a); | ||
220 | extern uint64_t softfp_f2ul(float a); | ||
221 | #endif | ||
222 | |||
100 | #endif | 223 | #endif |