aboutsummaryrefslogtreecommitdiff
path: root/src/lj_asm.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lj_asm.c')
-rw-r--r--src/lj_asm.c118
1 files changed, 118 insertions, 0 deletions
diff --git a/src/lj_asm.c b/src/lj_asm.c
index 231e76fc..7ebde7b8 100644
--- a/src/lj_asm.c
+++ b/src/lj_asm.c
@@ -1515,6 +1515,124 @@ static void asm_loop(ASMState *as)
1515#error "Missing assembler for target CPU" 1515#error "Missing assembler for target CPU"
1516#endif 1516#endif
1517 1517
1518/* -- Instruction dispatch ------------------------------------------------ */
1519
1520/* Assemble a single instruction. */
1521static void asm_ir(ASMState *as, IRIns *ir)
1522{
1523 switch ((IROp)ir->o) {
1524 /* Miscellaneous ops. */
1525 case IR_LOOP: asm_loop(as); break;
1526 case IR_NOP: case IR_XBAR: lua_assert(!ra_used(ir)); break;
1527 case IR_USE:
1528 ra_alloc1(as, ir->op1, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR); break;
1529 case IR_PHI: asm_phi(as, ir); break;
1530 case IR_HIOP: asm_hiop(as, ir); break;
1531 case IR_GCSTEP: asm_gcstep(as, ir); break;
1532
1533 /* Guarded assertions. */
1534 case IR_LT: case IR_GE: case IR_LE: case IR_GT:
1535 case IR_ULT: case IR_UGE: case IR_ULE: case IR_UGT:
1536 case IR_ABC:
1537 asm_comp(as, ir);
1538 break;
1539 case IR_EQ: case IR_NE:
1540 if ((ir-1)->o == IR_HREF && ir->op1 == as->curins-1) {
1541 as->curins--;
1542 asm_href(as, ir-1, (IROp)ir->o);
1543 } else {
1544 asm_equal(as, ir);
1545 }
1546 break;
1547
1548 case IR_RETF: asm_retf(as, ir); break;
1549
1550 /* Bit ops. */
1551 case IR_BNOT: asm_bnot(as, ir); break;
1552 case IR_BSWAP: asm_bswap(as, ir); break;
1553 case IR_BAND: asm_band(as, ir); break;
1554 case IR_BOR: asm_bor(as, ir); break;
1555 case IR_BXOR: asm_bxor(as, ir); break;
1556 case IR_BSHL: asm_bshl(as, ir); break;
1557 case IR_BSHR: asm_bshr(as, ir); break;
1558 case IR_BSAR: asm_bsar(as, ir); break;
1559 case IR_BROL: asm_brol(as, ir); break;
1560 case IR_BROR: asm_bror(as, ir); break;
1561
1562 /* Arithmetic ops. */
1563 case IR_ADD: asm_add(as, ir); break;
1564 case IR_SUB: asm_sub(as, ir); break;
1565 case IR_MUL: asm_mul(as, ir); break;
1566 case IR_DIV: asm_div(as, ir); break;
1567 case IR_MOD: asm_mod(as, ir); break;
1568 case IR_POW: asm_pow(as, ir); break;
1569 case IR_NEG: asm_neg(as, ir); break;
1570 case IR_ABS: asm_abs(as, ir); break;
1571 case IR_ATAN2: asm_atan2(as, ir); break;
1572 case IR_LDEXP: asm_ldexp(as, ir); break;
1573 case IR_MIN: asm_min(as, ir); break;
1574 case IR_MAX: asm_max(as, ir); break;
1575 case IR_FPMATH: asm_fpmath(as, ir); break;
1576
1577 /* Overflow-checking arithmetic ops. */
1578 case IR_ADDOV: asm_addov(as, ir); break;
1579 case IR_SUBOV: asm_subov(as, ir); break;
1580 case IR_MULOV: asm_mulov(as, ir); break;
1581
1582 /* Memory references. */
1583 case IR_AREF: asm_aref(as, ir); break;
1584 case IR_HREF: asm_href(as, ir, 0); break;
1585 case IR_HREFK: asm_hrefk(as, ir); break;
1586 case IR_NEWREF: asm_newref(as, ir); break;
1587 case IR_UREFO: case IR_UREFC: asm_uref(as, ir); break;
1588 case IR_FREF: asm_fref(as, ir); break;
1589 case IR_STRREF: asm_strref(as, ir); break;
1590
1591 /* Loads and stores. */
1592 case IR_ALOAD: case IR_HLOAD: case IR_ULOAD: case IR_VLOAD:
1593 asm_ahuvload(as, ir);
1594 break;
1595 case IR_FLOAD: asm_fload(as, ir); break;
1596 case IR_XLOAD: asm_xload(as, ir); break;
1597 case IR_SLOAD: asm_sload(as, ir); break;
1598
1599 case IR_ASTORE: case IR_HSTORE: case IR_USTORE: asm_ahustore(as, ir); break;
1600 case IR_FSTORE: asm_fstore(as, ir); break;
1601 case IR_XSTORE: asm_xstore(as, ir); break;
1602
1603 /* Allocations. */
1604 case IR_SNEW: case IR_XSNEW: asm_snew(as, ir); break;
1605 case IR_TNEW: asm_tnew(as, ir); break;
1606 case IR_TDUP: asm_tdup(as, ir); break;
1607 case IR_CNEW: case IR_CNEWI: asm_cnew(as, ir); break;
1608
1609 /* Buffer operations. */
1610 case IR_BUFHDR: asm_bufhdr(as, ir); break;
1611 case IR_BUFPUT: asm_bufput(as, ir); break;
1612 case IR_BUFSTR: asm_bufstr(as, ir); break;
1613
1614 /* Write barriers. */
1615 case IR_TBAR: asm_tbar(as, ir); break;
1616 case IR_OBAR: asm_obar(as, ir); break;
1617
1618 /* Type conversions. */
1619 case IR_TOBIT: asm_tobit(as, ir); break;
1620 case IR_CONV: asm_conv(as, ir); break;
1621 case IR_TOSTR: asm_tostr(as, ir); break;
1622 case IR_STRTO: asm_strto(as, ir); break;
1623
1624 /* Calls. */
1625 case IR_CALLN: case IR_CALLL: case IR_CALLS: asm_call(as, ir); break;
1626 case IR_CALLXS: asm_callx(as, ir); break;
1627 case IR_CARG: break;
1628
1629 default:
1630 setintV(&as->J->errinfo, ir->o);
1631 lj_trace_err_info(as->J, LJ_TRERR_NYIIR);
1632 break;
1633 }
1634}
1635
1518/* -- Head of trace ------------------------------------------------------- */ 1636/* -- Head of trace ------------------------------------------------------- */
1519 1637
1520/* Head of a root trace. */ 1638/* Head of a root trace. */