aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Pall <mike>2011-10-22 01:59:10 +0200
committerMike Pall <mike>2011-10-22 01:59:10 +0200
commitc805a49d304c344d69630a4282d21d753c70e1bd (patch)
treecb3aa44be781e82fcca3c9a82ccbe48176cba109 /src
parentff7f7a7180d25da9d425671a48867b50bb7e7ac2 (diff)
downloadluajit-c805a49d304c344d69630a4282d21d753c70e1bd.tar.gz
luajit-c805a49d304c344d69630a4282d21d753c70e1bd.tar.bz2
luajit-c805a49d304c344d69630a4282d21d753c70e1bd.zip
Separate/rename NUM/FLOAT <-> I64/U64 conversion functions.
Diffstat (limited to 'src')
-rw-r--r--src/lj_asm.c8
-rw-r--r--src/lj_ircall.h88
-rw-r--r--src/lj_opt_split.c8
3 files changed, 70 insertions, 34 deletions
diff --git a/src/lj_asm.c b/src/lj_asm.c
index 4187a1d9..3d9a213b 100644
--- a/src/lj_asm.c
+++ b/src/lj_asm.c
@@ -1516,6 +1516,14 @@ static void asm_setup_regsp(ASMState *as)
1516#endif 1516#endif
1517 break; 1517 break;
1518#endif 1518#endif
1519#if LJ_NEED_FP64
1520 case IR_CONV:
1521 if (irt_isfp((ir-1)->t)) {
1522 ir->prev = REGSP_HINT(RID_FPRET);
1523 continue;
1524 }
1525 /* fallthrough */
1526#endif
1519 case IR_CALLN: case IR_CALLXS: 1527 case IR_CALLN: case IR_CALLXS:
1520#if LJ_SOFTFP 1528#if LJ_SOFTFP
1521 case IR_MIN: case IR_MAX: 1529 case IR_MIN: case IR_MAX:
diff --git a/src/lj_ircall.h b/src/lj_ircall.h
index 00209d4c..b1e0e446 100644
--- a/src/lj_ircall.h
+++ b/src/lj_ircall.h
@@ -58,6 +58,14 @@ typedef struct CCallInfo {
58#define IRCALLCOND_SOFTFP_FFI(x) NULL 58#define IRCALLCOND_SOFTFP_FFI(x) NULL
59#endif 59#endif
60 60
61#define LJ_NEED_FP64 LJ_TARGET_PPC
62
63#if LJ_HASFFI && (LJ_SOFTFP || LJ_NEED_FP64)
64#define IRCALLCOND_FP64_FFI(x) x
65#else
66#define IRCALLCOND_FP64_FFI(x) NULL
67#endif
68
61#if LJ_HASFFI 69#if LJ_HASFFI
62#define IRCALLCOND_FFI(x) x 70#define IRCALLCOND_FFI(x) x
63#if LJ_32 71#if LJ_32
@@ -130,21 +138,21 @@ typedef struct CCallInfo {
130 _(SOFTFP, softfp_i2d, 1, N, NUM, 0) \ 138 _(SOFTFP, softfp_i2d, 1, N, NUM, 0) \
131 _(SOFTFP, softfp_d2i, 2, N, INT, 0) \ 139 _(SOFTFP, softfp_d2i, 2, N, INT, 0) \
132 _(SOFTFP_FFI, softfp_ui2d, 1, N, NUM, 0) \ 140 _(SOFTFP_FFI, softfp_ui2d, 1, N, NUM, 0) \
133 _(SOFTFP_FFI, softfp_l2d, 2, N, NUM, 0) \
134 _(SOFTFP_FFI, softfp_ul2d, 2, N, NUM, 0) \
135 _(SOFTFP_FFI, softfp_f2d, 1, N, NUM, 0) \ 141 _(SOFTFP_FFI, softfp_f2d, 1, N, NUM, 0) \
136 _(SOFTFP_FFI, softfp_d2ui, 2, N, INT, 0) \ 142 _(SOFTFP_FFI, softfp_d2ui, 2, N, INT, 0) \
137 _(SOFTFP_FFI, softfp_d2l, 2, N, I64, 0) \
138 _(SOFTFP_FFI, softfp_d2ul, 2, N, U64, 0) \
139 _(SOFTFP_FFI, softfp_d2f, 2, N, FLOAT, 0) \ 143 _(SOFTFP_FFI, softfp_d2f, 2, N, FLOAT, 0) \
140 _(SOFTFP_FFI, softfp_i2f, 1, N, FLOAT, 0) \ 144 _(SOFTFP_FFI, softfp_i2f, 1, N, FLOAT, 0) \
141 _(SOFTFP_FFI, softfp_ui2f, 1, N, FLOAT, 0) \ 145 _(SOFTFP_FFI, softfp_ui2f, 1, N, FLOAT, 0) \
142 _(SOFTFP_FFI, softfp_l2f, 2, N, FLOAT, 0) \
143 _(SOFTFP_FFI, softfp_ul2f, 2, N, FLOAT, 0) \
144 _(SOFTFP_FFI, softfp_f2i, 1, N, INT, 0) \ 146 _(SOFTFP_FFI, softfp_f2i, 1, N, INT, 0) \
145 _(SOFTFP_FFI, softfp_f2ui, 1, N, INT, 0) \ 147 _(SOFTFP_FFI, softfp_f2ui, 1, N, INT, 0) \
146 _(SOFTFP_FFI, softfp_f2l, 1, N, I64, 0) \ 148 _(FP64_FFI, fp64_l2d, 2, N, NUM, 0) \
147 _(SOFTFP_FFI, softfp_f2ul, 1, N, U64, 0) \ 149 _(FP64_FFI, fp64_ul2d, 2, N, NUM, 0) \
150 _(FP64_FFI, fp64_l2f, 2, N, FLOAT, 0) \
151 _(FP64_FFI, fp64_ul2f, 2, N, FLOAT, 0) \
152 _(FP64_FFI, fp64_d2l, 2, N, I64, 0) \
153 _(FP64_FFI, fp64_d2ul, 2, N, U64, 0) \
154 _(FP64_FFI, fp64_f2l, 1, N, I64, 0) \
155 _(FP64_FFI, fp64_f2ul, 1, N, U64, 0) \
148 _(FFI, lj_carith_divi64, ARG2_64, N, I64, CCI_NOFPRCLOBBER) \ 156 _(FFI, lj_carith_divi64, ARG2_64, N, I64, CCI_NOFPRCLOBBER) \
149 _(FFI, lj_carith_divu64, ARG2_64, N, U64, CCI_NOFPRCLOBBER) \ 157 _(FFI, lj_carith_divu64, ARG2_64, N, U64, CCI_NOFPRCLOBBER) \
150 _(FFI, lj_carith_modi64, ARG2_64, N, I64, CCI_NOFPRCLOBBER) \ 158 _(FFI, lj_carith_modi64, ARG2_64, N, I64, CCI_NOFPRCLOBBER) \
@@ -179,29 +187,29 @@ LJ_DATA const CCallInfo lj_ir_callinfo[IRCALL__MAX+1];
179#define softfp_div __aeabi_ddiv 187#define softfp_div __aeabi_ddiv
180#define softfp_cmp __aeabi_cdcmple 188#define softfp_cmp __aeabi_cdcmple
181#define softfp_i2d __aeabi_i2d 189#define softfp_i2d __aeabi_i2d
190#define softfp_d2i __aeabi_d2iz
182#define softfp_ui2d __aeabi_ui2d 191#define softfp_ui2d __aeabi_ui2d
183#define softfp_l2d __aeabi_l2d
184#define softfp_ul2d __aeabi_ul2d
185#define softfp_f2d __aeabi_f2d 192#define softfp_f2d __aeabi_f2d
186#define softfp_d2i __aeabi_d2iz
187#define softfp_d2ui __aeabi_d2uiz 193#define softfp_d2ui __aeabi_d2uiz
188#define softfp_d2f __aeabi_d2f 194#define softfp_d2f __aeabi_d2f
189#define softfp_i2f __aeabi_i2f 195#define softfp_i2f __aeabi_i2f
190#define softfp_ui2f __aeabi_ui2f 196#define softfp_ui2f __aeabi_ui2f
191#define softfp_l2f __aeabi_l2f
192#define softfp_ul2f __aeabi_ul2f
193#define softfp_f2i __aeabi_f2iz 197#define softfp_f2i __aeabi_f2iz
194#define softfp_f2ui __aeabi_f2uiz 198#define softfp_f2ui __aeabi_f2uiz
199#define fp64_l2d __aeabi_l2d
200#define fp64_ul2d __aeabi_ul2d
201#define fp64_l2f __aeabi_l2f
202#define fp64_ul2f __aeabi_ul2f
195#if LJ_TARGET_OSX 203#if LJ_TARGET_OSX
196#define softfp_d2l __fixdfdi 204#define fp64_d2l __fixdfdi
197#define softfp_d2ul __fixunsdfdi 205#define fp64_d2ul __fixunsdfdi
198#define softfp_f2l __fixsfdi 206#define fp64_f2l __fixsfdi
199#define softfp_f2ul __fixunssfdi 207#define fp64_f2ul __fixunssfdi
200#else 208#else
201#define softfp_d2l __aeabi_d2lz 209#define fp64_d2l __aeabi_d2lz
202#define softfp_d2ul __aeabi_d2ulz 210#define fp64_d2ul __aeabi_d2ulz
203#define softfp_f2l __aeabi_f2lz 211#define fp64_f2l __aeabi_f2lz
204#define softfp_f2ul __aeabi_f2ulz 212#define fp64_f2ul __aeabi_f2ulz
205#endif 213#endif
206#else 214#else
207#error "Missing soft-float definitions for target architecture" 215#error "Missing soft-float definitions for target architecture"
@@ -212,23 +220,43 @@ extern double softfp_mul(double a, double b);
212extern double softfp_div(double a, double b); 220extern double softfp_div(double a, double b);
213extern void softfp_cmp(double a, double b); 221extern void softfp_cmp(double a, double b);
214extern double softfp_i2d(int32_t a); 222extern double softfp_i2d(int32_t a);
223extern int32_t softfp_d2i(double a);
224#if LJ_HASFFI
215extern double softfp_ui2d(uint32_t a); 225extern double softfp_ui2d(uint32_t a);
216extern double softfp_l2d(int64_t a);
217extern double softfp_ul2d(uint64_t a);
218extern double softfp_f2d(float a); 226extern double softfp_f2d(float a);
219extern int32_t softfp_d2i(double a);
220extern uint32_t softfp_d2ui(double a); 227extern uint32_t softfp_d2ui(double a);
221extern int64_t softfp_d2l(double a);
222extern uint64_t softfp_d2ul(double a);
223extern float softfp_d2f(double a); 228extern float softfp_d2f(double a);
224extern float softfp_i2f(int32_t a); 229extern float softfp_i2f(int32_t a);
225extern float softfp_ui2f(uint32_t a); 230extern float softfp_ui2f(uint32_t a);
226extern float softfp_l2f(int64_t a);
227extern float softfp_ul2f(uint64_t a);
228extern int32_t softfp_f2i(float a); 231extern int32_t softfp_f2i(float a);
229extern uint32_t softfp_f2ui(float a); 232extern uint32_t softfp_f2ui(float a);
230extern int64_t softfp_f2l(float a); 233#endif
231extern uint64_t softfp_f2ul(float a); 234#endif
235
236#if LJ_HASFFI && LJ_NEED_FP64
237#ifdef __GNUC__
238#define fp64_l2d __floatdidf
239#define fp64_ul2d __floatundidf
240#define fp64_l2f __floatdisf
241#define fp64_ul2f __floatundisf
242#define fp64_d2l __fixdfdi
243#define fp64_d2ul __fixunsdfdi
244#define fp64_f2l __fixsfdi
245#define fp64_f2ul __fixunssfdi
246#else
247#error "Missing fp64 helper definitions for this compiler"
248#endif
249#endif
250
251#if LJ_HASFFI && (LJ_SOFTFP || LJ_NEED_FP64)
252extern double fp64_l2d(int64_t a);
253extern double fp64_ul2d(uint64_t a);
254extern float fp64_l2f(int64_t a);
255extern float fp64_ul2f(uint64_t a);
256extern int64_t fp64_d2l(double a);
257extern uint64_t fp64_d2ul(double a);
258extern int64_t fp64_f2l(float a);
259extern uint64_t fp64_f2ul(float a);
232#endif 260#endif
233 261
234#endif 262#endif
diff --git a/src/lj_opt_split.c b/src/lj_opt_split.c
index 61275b03..bd785d65 100644
--- a/src/lj_opt_split.c
+++ b/src/lj_opt_split.c
@@ -338,7 +338,7 @@ static void split_ir(jit_State *J)
338#if LJ_32 && LJ_HASFFI 338#if LJ_32 && LJ_HASFFI
339 if (st == IRT_I64 || st == IRT_U64) { 339 if (st == IRT_I64 || st == IRT_U64) {
340 hi = split_call_l(J, hisubst, oir, ir, 340 hi = split_call_l(J, hisubst, oir, ir,
341 st == IRT_I64 ? IRCALL_softfp_l2d : IRCALL_softfp_ul2d); 341 st == IRT_I64 ? IRCALL_fp64_l2d : IRCALL_fp64_ul2d);
342 break; 342 break;
343 } 343 }
344#endif 344#endif
@@ -435,10 +435,10 @@ static void split_ir(jit_State *J)
435#if LJ_SOFTFP 435#if LJ_SOFTFP
436 if (st == IRT_NUM) { /* NUM to 64 bit int conv. */ 436 if (st == IRT_NUM) { /* NUM to 64 bit int conv. */
437 hi = split_call_l(J, hisubst, oir, ir, 437 hi = split_call_l(J, hisubst, oir, ir,
438 irt_isi64(ir->t) ? IRCALL_softfp_d2l : IRCALL_softfp_d2ul); 438 irt_isi64(ir->t) ? IRCALL_fp64_d2l : IRCALL_fp64_d2ul);
439 } else if (st == IRT_FLOAT) { /* FLOAT to 64 bit int conv. */ 439 } else if (st == IRT_FLOAT) { /* FLOAT to 64 bit int conv. */
440 nir->o = IR_CALLN; 440 nir->o = IR_CALLN;
441 nir->op2 = irt_isi64(ir->t) ? IRCALL_softfp_f2l : IRCALL_softfp_f2ul; 441 nir->op2 = irt_isi64(ir->t) ? IRCALL_fp64_f2l : IRCALL_fp64_f2ul;
442 hi = split_emit(J, IRTI(IR_HIOP), nref, nref); 442 hi = split_emit(J, IRTI(IR_HIOP), nref, nref);
443 } 443 }
444#else 444#else
@@ -518,7 +518,7 @@ static void split_ir(jit_State *J)
518#if LJ_SOFTFP 518#if LJ_SOFTFP
519 if (irt_isfloat(ir->t)) { 519 if (irt_isfloat(ir->t)) {
520 split_call_l(J, hisubst, oir, ir, 520 split_call_l(J, hisubst, oir, ir,
521 st == IRT_I64 ? IRCALL_softfp_l2f : IRCALL_softfp_ul2f); 521 st == IRT_I64 ? IRCALL_fp64_l2f : IRCALL_fp64_ul2f);
522 J->cur.nins--; /* Drop unused HIOP. */ 522 J->cur.nins--; /* Drop unused HIOP. */
523 } 523 }
524#else 524#else