aboutsummaryrefslogtreecommitdiff
path: root/src/lj_crecord.c
diff options
context:
space:
mode:
authorMike Pall <mike>2011-02-02 02:29:37 +0100
committerMike Pall <mike>2011-02-02 02:29:37 +0100
commitb613216efc7447dae645d8834e4d6f3185cd1bcc (patch)
tree0859fed377f00ebeada70ba45d02496b7fb4a249 /src/lj_crecord.c
parentc539c0cac8f668e66a5ce9e5fd645cb45e3c5063 (diff)
downloadluajit-b613216efc7447dae645d8834e4d6f3185cd1bcc.tar.gz
luajit-b613216efc7447dae645d8834e4d6f3185cd1bcc.tar.bz2
luajit-b613216efc7447dae645d8834e4d6f3185cd1bcc.zip
Add SPLIT pass to split 64 bit IR instructions for 32 bit CPUs.
Add generic HIOP instruction for extra backend functionality. Add support for HIOP to x86 backend. Use POWI for 64 bit integer x^k, too. POWI is lowered to a call by SPLIT or the x64 backend.
Diffstat (limited to 'src/lj_crecord.c')
-rw-r--r--src/lj_crecord.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/lj_crecord.c b/src/lj_crecord.c
index 61210907..5eafa3a7 100644
--- a/src/lj_crecord.c
+++ b/src/lj_crecord.c
@@ -189,6 +189,7 @@ static void crec_ct_ct(jit_State *J, CType *d, CType *s, TRef dp, TRef sp,
189 sp = emitconv(sp, dsize < 4 ? IRT_INT : dt, st, 0); 189 sp = emitconv(sp, dsize < 4 ? IRT_INT : dt, st, 0);
190#endif 190#endif
191 xstore: 191 xstore:
192 if (dt == IRT_I64 || dt == IRT_U64) lj_needsplit(J);
192 emitir(IRT(IR_XSTORE, dt), dp, sp); 193 emitir(IRT(IR_XSTORE, dt), dp, sp);
193 break; 194 break;
194 case CCX(I, C): 195 case CCX(I, C):
@@ -311,6 +312,7 @@ static TRef crec_tv_ct(jit_State *J, CType *s, CTypeID sid, TRef sp)
311 TRef ptr = emitir(IRT(IR_ADD, IRT_PTR), dp, 312 TRef ptr = emitir(IRT(IR_ADD, IRT_PTR), dp,
312 lj_ir_kintp(J, sizeof(GCcdata))); 313 lj_ir_kintp(J, sizeof(GCcdata)));
313 emitir(IRT(IR_XSTORE, t), ptr, tr); 314 emitir(IRT(IR_XSTORE, t), ptr, tr);
315 lj_needsplit(J);
314 return dp; 316 return dp;
315 } else if ((sinfo & CTF_BOOL)) { 317 } else if ((sinfo & CTF_BOOL)) {
316 /* Assume not equal to zero. Fixup and emit pending guard later. */ 318 /* Assume not equal to zero. Fixup and emit pending guard later. */
@@ -406,7 +408,10 @@ static void crec_ct_tv(jit_State *J, CType *d, TRef dp, TRef sp, TValue *sval)
406 if (ctype_isenum(s->info)) s = ctype_child(cts, s); 408 if (ctype_isenum(s->info)) s = ctype_child(cts, s);
407 if (ctype_isnum(s->info)) { /* Load number value. */ 409 if (ctype_isnum(s->info)) { /* Load number value. */
408 IRType t = crec_ct2irt(s); 410 IRType t = crec_ct2irt(s);
409 if (t != IRT_CDATA) sp = emitir(IRT(IR_XLOAD, t), sp, 0); 411 if (t != IRT_CDATA) {
412 sp = emitir(IRT(IR_XLOAD, t), sp, 0);
413 if (t == IRT_I64 || t == IRT_U64) lj_needsplit(J);
414 }
410 } 415 }
411 goto doconv; 416 goto doconv;
412 } 417 }
@@ -499,8 +504,10 @@ void LJ_FASTCALL recff_cdata_index(jit_State *J, RecordFFData *rd)
499 if (ctype_isinteger(ctk->info) && (t = crec_ct2irt(ctk)) != IRT_CDATA) { 504 if (ctype_isinteger(ctk->info) && (t = crec_ct2irt(ctk)) != IRT_CDATA) {
500 idx = emitir(IRT(IR_ADD, IRT_PTR), idx, lj_ir_kintp(J, sizeof(GCcdata))); 505 idx = emitir(IRT(IR_ADD, IRT_PTR), idx, lj_ir_kintp(J, sizeof(GCcdata)));
501 idx = emitir(IRT(IR_XLOAD, t), idx, 0); 506 idx = emitir(IRT(IR_XLOAD, t), idx, 0);
502 if (!LJ_64 && (t == IRT_I64 || t == IRT_U64)) 507 if (!LJ_64 && (t == IRT_I64 || t == IRT_U64)) {
503 idx = emitconv(idx, IRT_INT, t, 0); 508 idx = emitconv(idx, IRT_INT, t, 0);
509 lj_needsplit(J);
510 }
504 goto integer_key; 511 goto integer_key;
505 } 512 }
506 } else if (tref_isstr(idx)) { 513 } else if (tref_isstr(idx)) {
@@ -664,6 +671,7 @@ static TRef crec_arith_int64(jit_State *J, TRef *sp, CType **s, MMS mm)
664 CTypeID id; 671 CTypeID id;
665 TRef tr, dp, ptr; 672 TRef tr, dp, ptr;
666 MSize i; 673 MSize i;
674 lj_needsplit(J);
667 if (((s[0]->info & CTF_UNSIGNED) && s[0]->size == 8) || 675 if (((s[0]->info & CTF_UNSIGNED) && s[0]->size == 8) ||
668 ((s[1]->info & CTF_UNSIGNED) && s[1]->size == 8)) { 676 ((s[1]->info & CTF_UNSIGNED) && s[1]->size == 8)) {
669 dt = IRT_U64; id = CTID_UINT64; 677 dt = IRT_U64; id = CTID_UINT64;
@@ -691,9 +699,6 @@ static TRef crec_arith_int64(jit_State *J, TRef *sp, CType **s, MMS mm)
691 lj_ir_set(J, IRTG(op, dt), sp[0], sp[1]); 699 lj_ir_set(J, IRTG(op, dt), sp[0], sp[1]);
692 J->postproc = LJ_POST_FIXGUARD; 700 J->postproc = LJ_POST_FIXGUARD;
693 return TREF_TRUE; 701 return TREF_TRUE;
694 } else if (mm == MM_pow) {
695 tr = lj_ir_call(J, dt == IRT_I64 ? IRCALL_lj_carith_powi64 :
696 IRCALL_lj_carith_powu64, sp[0], sp[1]);
697 } else { 702 } else {
698 if (mm == MM_div || mm == MM_mod) 703 if (mm == MM_div || mm == MM_mod)
699 return 0; /* NYI: integer div, mod. */ 704 return 0; /* NYI: integer div, mod. */
@@ -754,10 +759,11 @@ static TRef crec_arith_ptr(jit_State *J, TRef *sp, CType **s, MMS mm)
754 tr = emitconv(tr, IRT_INTP, IRT_INT, 759 tr = emitconv(tr, IRT_INTP, IRT_INT,
755 ((t - IRT_I8) & 1) ? 0 : IRCONV_SEXT); 760 ((t - IRT_I8) & 1) ? 0 : IRCONV_SEXT);
756#else 761#else
757 if (!tref_typerange(sp[1], IRT_I8, IRT_U32)) 762 if (!tref_typerange(sp[1], IRT_I8, IRT_U32)) {
758 tr = emitconv(tr, IRT_INTP, t, 763 tr = emitconv(tr, IRT_INTP, t,
759 (t == IRT_NUM || t == IRT_FLOAT) ? 764 (t == IRT_NUM || t == IRT_FLOAT) ?
760 IRCONV_TRUNC|IRCONV_ANY : 0); 765 IRCONV_TRUNC|IRCONV_ANY : 0);
766 }
761#endif 767#endif
762 tr = emitir(IRT(IR_MUL, IRT_INTP), tr, lj_ir_kintp(J, sz)); 768 tr = emitir(IRT(IR_MUL, IRT_INTP), tr, lj_ir_kintp(J, sz));
763 tr = emitir(IRT(IR_ADD, IRT_PTR), sp[0], tr); 769 tr = emitir(IRT(IR_ADD, IRT_PTR), sp[0], tr);
@@ -790,6 +796,7 @@ void LJ_FASTCALL recff_cdata_arith(jit_State *J, RecordFFData *rd)
790 if (ctype_isnum(ct->info)) { 796 if (ctype_isnum(ct->info)) {
791 IRType t = crec_ct2irt(ct); 797 IRType t = crec_ct2irt(ct);
792 if (t == IRT_CDATA) goto err_type; 798 if (t == IRT_CDATA) goto err_type;
799 if (t == IRT_I64 || t == IRT_U64) lj_needsplit(J);
793 tr = emitir(IRT(IR_XLOAD, t), tr, 0); 800 tr = emitir(IRT(IR_XLOAD, t), tr, 0);
794 } else if (!(ctype_isptr(ct->info) || ctype_isrefarray(ct->info))) { 801 } else if (!(ctype_isptr(ct->info) || ctype_isrefarray(ct->info))) {
795 goto err_type; 802 goto err_type;
@@ -842,6 +849,7 @@ void LJ_FASTCALL lj_crecord_tonumber(jit_State *J, RecordFFData *rd)
842 IRType t = crec_ct2irt(s); 849 IRType t = crec_ct2irt(s);
843 if (t != IRT_CDATA) { 850 if (t != IRT_CDATA) {
844 TRef tr = emitir(IRT(IR_XLOAD, t), sp, 0); /* Load number value. */ 851 TRef tr = emitir(IRT(IR_XLOAD, t), sp, 0); /* Load number value. */
852 if (t == IRT_I64 || t == IRT_U64) lj_needsplit(J);
845 if (t == IRT_FLOAT || t == IRT_U32 || t == IRT_I64 || t == IRT_U64) 853 if (t == IRT_FLOAT || t == IRT_U32 || t == IRT_I64 || t == IRT_U64)
846 tr = emitconv(tr, IRT_NUM, t, 0); 854 tr = emitconv(tr, IRT_NUM, t, 0);
847 J->base[0] = tr; 855 J->base[0] = tr;