aboutsummaryrefslogtreecommitdiff
path: root/src/lj_asm_mips.h
diff options
context:
space:
mode:
authorMike Pall <mike>2013-04-22 17:34:36 +0200
committerMike Pall <mike>2013-04-22 17:34:36 +0200
commit988e1839658523e772de53f89df389b568883fde (patch)
tree2ba73f16385b3c8765a05580071308f2a4f11123 /src/lj_asm_mips.h
parent5f1781a1277508c2b7bec527f722da98d8556e26 (diff)
downloadluajit-988e1839658523e772de53f89df389b568883fde.tar.gz
luajit-988e1839658523e772de53f89df389b568883fde.tar.bz2
luajit-988e1839658523e772de53f89df389b568883fde.zip
Reorganize generic operations common to all assembler backends.
Diffstat (limited to 'src/lj_asm_mips.h')
-rw-r--r--src/lj_asm_mips.h97
1 files changed, 2 insertions, 95 deletions
diff --git a/src/lj_asm_mips.h b/src/lj_asm_mips.h
index 55fe10b8..44cb85e5 100644
--- a/src/lj_asm_mips.h
+++ b/src/lj_asm_mips.h
@@ -326,15 +326,6 @@ static void asm_setupresult(ASMState *as, IRIns *ir, const CCallInfo *ci)
326 } 326 }
327} 327}
328 328
329static void asm_call(ASMState *as, IRIns *ir)
330{
331 IRRef args[CCI_NARGS_MAX];
332 const CCallInfo *ci = &lj_ir_callinfo[ir->op2];
333 asm_collectargs(as, ir, ci, args);
334 asm_setupresult(as, ir, ci);
335 asm_gencall(as, ci, args);
336}
337
338static void asm_callx(ASMState *as, IRIns *ir) 329static void asm_callx(ASMState *as, IRIns *ir)
339{ 330{
340 IRRef args[CCI_NARGS_MAX]; 331 IRRef args[CCI_NARGS_MAX];
@@ -362,16 +353,6 @@ static void asm_callx(ASMState *as, IRIns *ir)
362 asm_gencall(as, &ci, args); 353 asm_gencall(as, &ci, args);
363} 354}
364 355
365static void asm_callid(ASMState *as, IRIns *ir, IRCallID id)
366{
367 const CCallInfo *ci = &lj_ir_callinfo[id];
368 IRRef args[2];
369 args[0] = ir->op1;
370 args[1] = ir->op2;
371 asm_setupresult(as, ir, ci);
372 asm_gencall(as, ci, args);
373}
374
375static void asm_callround(ASMState *as, IRIns *ir, IRCallID id) 356static void asm_callround(ASMState *as, IRIns *ir, IRCallID id)
376{ 357{
377 /* The modified regs must match with the *.dasc implementation. */ 358 /* The modified regs must match with the *.dasc implementation. */
@@ -519,28 +500,6 @@ static void asm_conv(ASMState *as, IRIns *ir)
519 } 500 }
520} 501}
521 502
522#if LJ_HASFFI
523static void asm_conv64(ASMState *as, IRIns *ir)
524{
525 IRType st = (IRType)((ir-1)->op2 & IRCONV_SRCMASK);
526 IRType dt = (((ir-1)->op2 & IRCONV_DSTMASK) >> IRCONV_DSH);
527 IRCallID id;
528 const CCallInfo *ci;
529 IRRef args[2];
530 args[LJ_BE?0:1] = ir->op1;
531 args[LJ_BE?1:0] = (ir-1)->op1;
532 if (st == IRT_NUM || st == IRT_FLOAT) {
533 id = IRCALL_fp64_d2l + ((st == IRT_FLOAT) ? 2 : 0) + (dt - IRT_I64);
534 ir--;
535 } else {
536 id = IRCALL_fp64_l2d + ((dt == IRT_FLOAT) ? 2 : 0) + (st - IRT_I64);
537 }
538 ci = &lj_ir_callinfo[id];
539 asm_setupresult(as, ir, ci);
540 asm_gencall(as, ci, args);
541}
542#endif
543
544static void asm_strto(ASMState *as, IRIns *ir) 503static void asm_strto(ASMState *as, IRIns *ir)
545{ 504{
546 const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_strscan_num]; 505 const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_strscan_num];
@@ -557,6 +516,8 @@ static void asm_strto(ASMState *as, IRIns *ir)
557 RID_SP, sps_scale(ir->s)); 516 RID_SP, sps_scale(ir->s));
558} 517}
559 518
519/* -- Memory references --------------------------------------------------- */
520
560/* Get pointer to TValue. */ 521/* Get pointer to TValue. */
561static void asm_tvptr(ASMState *as, Reg dest, IRRef ref) 522static void asm_tvptr(ASMState *as, Reg dest, IRRef ref)
562{ 523{
@@ -580,27 +541,6 @@ static void asm_tvptr(ASMState *as, Reg dest, IRRef ref)
580 } 541 }
581} 542}
582 543
583static void asm_tostr(ASMState *as, IRIns *ir)
584{
585 IRRef args[2];
586 args[0] = ASMREF_L;
587 as->gcsteps++;
588 if (irt_isnum(IR(ir->op1)->t) || (ir+1)->o == IR_HIOP) {
589 const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_str_fromnum];
590 args[1] = ASMREF_TMP1; /* const lua_Number * */
591 asm_setupresult(as, ir, ci); /* GCstr * */
592 asm_gencall(as, ci, args);
593 asm_tvptr(as, ra_releasetmp(as, ASMREF_TMP1), ir->op1);
594 } else {
595 const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_str_fromint];
596 args[1] = ir->op1; /* int32_t k */
597 asm_setupresult(as, ir, ci); /* GCstr * */
598 asm_gencall(as, ci, args);
599 }
600}
601
602/* -- Memory references --------------------------------------------------- */
603
604static void asm_aref(ASMState *as, IRIns *ir) 544static void asm_aref(ASMState *as, IRIns *ir)
605{ 545{
606 Reg dest = ra_dest(as, ir, RSET_GPR); 546 Reg dest = ra_dest(as, ir, RSET_GPR);
@@ -776,20 +716,6 @@ nolo:
776 emit_tsi(as, MIPSI_ADDU, dest, node, ra_allock(as, ofs, allow)); 716 emit_tsi(as, MIPSI_ADDU, dest, node, ra_allock(as, ofs, allow));
777} 717}
778 718
779static void asm_newref(ASMState *as, IRIns *ir)
780{
781 if (ir->r != RID_SINK) {
782 const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_tab_newkey];
783 IRRef args[3];
784 args[0] = ASMREF_L; /* lua_State *L */
785 args[1] = ir->op1; /* GCtab *t */
786 args[2] = ASMREF_TMP1; /* cTValue *key */
787 asm_setupresult(as, ir, ci); /* TValue * */
788 asm_gencall(as, ci, args);
789 asm_tvptr(as, ra_releasetmp(as, ASMREF_TMP1), ir->op2);
790 }
791}
792
793static void asm_uref(ASMState *as, IRIns *ir) 719static void asm_uref(ASMState *as, IRIns *ir)
794{ 720{
795 /* NYI: Check that UREFO is still open and not aliasing a slot. */ 721 /* NYI: Check that UREFO is still open and not aliasing a slot. */
@@ -1152,25 +1078,6 @@ static void asm_fpunary(ASMState *as, IRIns *ir, MIPSIns mi)
1152 emit_fg(as, mi, dest, left); 1078 emit_fg(as, mi, dest, left);
1153} 1079}
1154 1080
1155static int asm_fpjoin_pow(ASMState *as, IRIns *ir)
1156{
1157 IRIns *irp = IR(ir->op1);
1158 if (irp == ir-1 && irp->o == IR_MUL && !ra_used(irp)) {
1159 IRIns *irpp = IR(irp->op1);
1160 if (irpp == ir-2 && irpp->o == IR_FPMATH &&
1161 irpp->op2 == IRFPM_LOG2 && !ra_used(irpp)) {
1162 const CCallInfo *ci = &lj_ir_callinfo[IRCALL_pow];
1163 IRRef args[2];
1164 args[0] = irpp->op1;
1165 args[1] = irp->op2;
1166 asm_setupresult(as, ir, ci);
1167 asm_gencall(as, ci, args);
1168 return 1;
1169 }
1170 }
1171 return 0;
1172}
1173
1174static void asm_add(ASMState *as, IRIns *ir) 1081static void asm_add(ASMState *as, IRIns *ir)
1175{ 1082{
1176 if (irt_isnum(ir->t)) { 1083 if (irt_isnum(ir->t)) {