Lines Matching refs:compiler

259 #define INC_SIZE(s)			(*inst++ = (s), compiler->size += (s))
448 SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compiler) in sljit_generate_code() argument
462 CHECK_PTR(check_sljit_generate_code(compiler)); in sljit_generate_code()
463 reverse_buf(compiler); in sljit_generate_code()
466 code = (sljit_ub*)SLJIT_MALLOC_EXEC(compiler->size); in sljit_generate_code()
468 buf = compiler->buf; in sljit_generate_code()
471 label = compiler->labels; in sljit_generate_code()
472 jump = compiler->jumps; in sljit_generate_code()
473 const_ = compiler->consts; in sljit_generate_code()
526 jump = compiler->jumps; in sljit_generate_code()
558 SLJIT_ASSERT(code_ptr <= code + compiler->size); in sljit_generate_code()
559 compiler->error = SLJIT_ERR_COMPILED; in sljit_generate_code()
560 compiler->executable_size = code_ptr - code; in sljit_generate_code()
568 static sljit_si emit_cum_binary(struct sljit_compiler *compiler,
574 static sljit_si emit_non_cum_binary(struct sljit_compiler *compiler,
580 static sljit_si emit_mov(struct sljit_compiler *compiler,
584 static SLJIT_INLINE sljit_si emit_save_flags(struct sljit_compiler *compiler) in emit_save_flags() argument
589 inst = (sljit_ub*)ensure_buf(compiler, 1 + 5); in emit_save_flags()
593 inst = (sljit_ub*)ensure_buf(compiler, 1 + 6); in emit_save_flags()
603 compiler->flags_saved = 1; in emit_save_flags()
607 static SLJIT_INLINE sljit_si emit_restore_flags(struct sljit_compiler *compiler, sljit_si keep_flag… in emit_restore_flags() argument
612 inst = (sljit_ub*)ensure_buf(compiler, 1 + 5); in emit_restore_flags()
617 inst = (sljit_ub*)ensure_buf(compiler, 1 + 6); in emit_restore_flags()
627 compiler->flags_saved = keep_flags; in emit_restore_flags()
654 static sljit_si emit_mov(struct sljit_compiler *compiler, in emit_mov() argument
663 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src, srcw); in emit_mov()
670 inst = emit_x86_instruction(compiler, 1, src, 0, dst, dstw); in emit_mov()
678 return emit_do_imm(compiler, MOV_r_i32 + reg_map[dst], srcw); in emit_mov()
680 if (!compiler->mode32) { in emit_mov()
682 return emit_load_imm64(compiler, dst, srcw); in emit_mov()
685 … return emit_do_imm32(compiler, (reg_map[dst] >= 8) ? REX_B : 0, MOV_r_i32 + reg_lmap[dst], srcw); in emit_mov()
689 if (!compiler->mode32 && NOT_HALFWORD(srcw)) { in emit_mov()
690 FAIL_IF(emit_load_imm64(compiler, TMP_REG2, srcw)); in emit_mov()
691 inst = emit_x86_instruction(compiler, 1, TMP_REG2, 0, dst, dstw); in emit_mov()
697 inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, srcw, dst, dstw); in emit_mov()
703 inst = emit_x86_instruction(compiler, 1, dst, 0, src, srcw); in emit_mov()
710 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src, srcw); in emit_mov()
713 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, dst, dstw); in emit_mov()
719 #define EMIT_MOV(compiler, dst, dstw, src, srcw) \ argument
720 FAIL_IF(emit_mov(compiler, dst, dstw, src, srcw));
722 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler, sljit_si op) in sljit_emit_op0() argument
730 CHECK(check_sljit_emit_op0(compiler, op)); in sljit_emit_op0()
734 inst = (sljit_ub*)ensure_buf(compiler, 1 + 1); in sljit_emit_op0()
740 inst = (sljit_ub*)ensure_buf(compiler, 1 + 1); in sljit_emit_op0()
751 compiler->flags_saved = 0; in sljit_emit_op0()
766 compiler->mode32 = op & SLJIT_INT_OP; in sljit_emit_op0()
773 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_R1, 0); in sljit_emit_op0()
774 inst = emit_x86_instruction(compiler, 1, SLJIT_R1, 0, SLJIT_R1, 0); in sljit_emit_op0()
776 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, TMP_REG1, 0); in sljit_emit_op0()
784 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_R1, 0); in sljit_emit_op0()
788 inst = (sljit_ub*)ensure_buf(compiler, 1 + 1); in sljit_emit_op0()
793 if (compiler->mode32) { in sljit_emit_op0()
794 inst = (sljit_ub*)ensure_buf(compiler, 1 + 1); in sljit_emit_op0()
799 inst = (sljit_ub*)ensure_buf(compiler, 1 + 2); in sljit_emit_op0()
809 inst = (sljit_ub*)ensure_buf(compiler, 1 + 2); in sljit_emit_op0()
816 size = (!compiler->mode32 || op >= SLJIT_UDIVMOD) ? 3 : 2; in sljit_emit_op0()
818 size = (!compiler->mode32) ? 3 : 2; in sljit_emit_op0()
820 inst = (sljit_ub*)ensure_buf(compiler, 1 + size); in sljit_emit_op0()
824 if (!compiler->mode32) in sljit_emit_op0()
831 if (!compiler->mode32) in sljit_emit_op0()
855 EMIT_MOV(compiler, SLJIT_R1, 0, TMP_REG1, 0); in sljit_emit_op0()
858 EMIT_MOV(compiler, SLJIT_R1, 0, TMP_REG1, 0); in sljit_emit_op0()
868 inst = (sljit_ub*)ensure_buf(compiler, 1 + 1); \
874 static sljit_si emit_mov_byte(struct sljit_compiler *compiler, sljit_si sign, in emit_mov_byte() argument
885 compiler->mode32 = 0; in emit_mov_byte()
894 return emit_do_imm(compiler, MOV_r_i32 + reg_map[dst], srcw); in emit_mov_byte()
896 inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, srcw, dst, 0); in emit_mov_byte()
902 …inst = emit_x86_instruction(compiler, 1 | EX86_BYTE_ARG | EX86_NO_REXW, SLJIT_IMM, srcw, dst, dstw… in emit_mov_byte()
914 EMIT_MOV(compiler, TMP_REG1, 0, src, 0); in emit_mov_byte()
927 EMIT_MOV(compiler, dst, 0, src, 0); in emit_mov_byte()
928 inst = emit_x86_instruction(compiler, 2, dst, 0, dst, 0); in emit_mov_byte()
935 EMIT_MOV(compiler, dst, 0, src, 0); in emit_mov_byte()
938 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_IMM, 24, dst, 0); in emit_mov_byte()
942 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_IMM, 24, dst, 0); in emit_mov_byte()
947 inst = emit_x86_instruction(compiler, 1 | EX86_BIN_INS, SLJIT_IMM, 0xff, dst, 0); in emit_mov_byte()
957 inst = emit_x86_instruction(compiler, 2, dst_r, 0, src, srcw); in emit_mov_byte()
986 inst = emit_x86_instruction(compiler, 1, work_r, 0, dst_r, 0); in emit_mov_byte()
991 inst = emit_x86_instruction(compiler, 1, work_r, 0, dst, dstw); in emit_mov_byte()
999 inst = emit_x86_instruction(compiler, 1, work_r, 0, dst_r, 0); in emit_mov_byte()
1005 inst = emit_x86_instruction(compiler, 1, dst_r, 0, dst, dstw); in emit_mov_byte()
1010 inst = emit_x86_instruction(compiler, 1 | EX86_REX | EX86_NO_REXW, dst_r, 0, dst, dstw); in emit_mov_byte()
1019 static sljit_si emit_mov_half(struct sljit_compiler *compiler, sljit_si sign, in emit_mov_half() argument
1027 compiler->mode32 = 0; in emit_mov_half()
1036 return emit_do_imm(compiler, MOV_r_i32 + reg_map[dst], srcw); in emit_mov_half()
1038 inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, srcw, dst, 0); in emit_mov_half()
1044 …inst = emit_x86_instruction(compiler, 1 | EX86_HALF_ARG | EX86_NO_REXW | EX86_PREF_66, SLJIT_IMM, … in emit_mov_half()
1055 inst = emit_x86_instruction(compiler, 2, dst_r, 0, src, srcw); in emit_mov_half()
1062 inst = emit_x86_instruction(compiler, 1 | EX86_NO_REXW | EX86_PREF_66, dst_r, 0, dst, dstw); in emit_mov_half()
1070 static sljit_si emit_unary(struct sljit_compiler *compiler, sljit_ub opcode, in emit_unary() argument
1077 EMIT_MOV(compiler, TMP_REG1, 0, src, srcw); in emit_unary()
1078 inst = emit_x86_instruction(compiler, 1, 0, 0, TMP_REG1, 0); in emit_unary()
1086 inst = emit_x86_instruction(compiler, 1, 0, 0, dst, dstw); in emit_unary()
1093 EMIT_MOV(compiler, dst, 0, src, srcw); in emit_unary()
1094 inst = emit_x86_instruction(compiler, 1, 0, 0, dst, dstw); in emit_unary()
1100 EMIT_MOV(compiler, TMP_REG1, 0, src, srcw); in emit_unary()
1101 inst = emit_x86_instruction(compiler, 1, 0, 0, TMP_REG1, 0); in emit_unary()
1105 EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0); in emit_unary()
1109 static sljit_si emit_not_with_flags(struct sljit_compiler *compiler, in emit_not_with_flags() argument
1116 EMIT_MOV(compiler, TMP_REG1, 0, src, srcw); in emit_not_with_flags()
1117 inst = emit_x86_instruction(compiler, 1, 0, 0, TMP_REG1, 0); in emit_not_with_flags()
1121 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, TMP_REG1, 0); in emit_not_with_flags()
1127 EMIT_MOV(compiler, dst, 0, src, srcw); in emit_not_with_flags()
1128 inst = emit_x86_instruction(compiler, 1, 0, 0, dst, dstw); in emit_not_with_flags()
1132 inst = emit_x86_instruction(compiler, 1, dst, 0, dst, 0); in emit_not_with_flags()
1137 EMIT_MOV(compiler, TMP_REG1, 0, src, srcw); in emit_not_with_flags()
1138 inst = emit_x86_instruction(compiler, 1, 0, 0, TMP_REG1, 0); in emit_not_with_flags()
1142 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, TMP_REG1, 0); in emit_not_with_flags()
1145 EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0); in emit_not_with_flags()
1149 static sljit_si emit_clz(struct sljit_compiler *compiler, sljit_si op_flags, in emit_clz() argument
1159 EMIT_MOV(compiler, TMP_REG1, 0, src, srcw); in emit_clz()
1160 inst = emit_x86_instruction(compiler, 1, 0, 0, TMP_REG1, 0); in emit_clz()
1165 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_IMM, 31, TMP_REG1, 0); in emit_clz()
1167 …inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_IMM, !(op_flags & SLJIT_INT_OP) ? … in emit_clz()
1175 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_IMM, srcw); in emit_clz()
1180 inst = emit_x86_instruction(compiler, 2, TMP_REG1, 0, src, srcw); in emit_clz()
1196 EMIT_MOV(compiler, dst, dstw, dst_r, 0); in emit_clz()
1198 EMIT_MOV(compiler, dst_r, 0, SLJIT_IMM, 32 + 31); in emit_clz()
1201 compiler->mode32 = 0; in emit_clz()
1202 EMIT_MOV(compiler, dst_r, 0, SLJIT_IMM, !(op_flags & SLJIT_INT_OP) ? 64 + 63 : 32 + 31); in emit_clz()
1203 compiler->mode32 = op_flags & SLJIT_INT_OP; in emit_clz()
1210 inst = emit_x86_instruction(compiler, 2, dst_r, 0, TMP_REG1, 0); in emit_clz()
1216 inst = (sljit_ub*)ensure_buf(compiler, 1 + 4); in emit_clz()
1225 inst = (sljit_ub*)ensure_buf(compiler, 1 + 5); in emit_clz()
1238 inst = emit_x86_instruction(compiler, 1 | EX86_BIN_INS, SLJIT_IMM, 31, dst_r, 0); in emit_clz()
1240 …inst = emit_x86_instruction(compiler, 1 | EX86_BIN_INS, SLJIT_IMM, !(op_flags & SLJIT_INT_OP) ? 63… in emit_clz()
1247 inst = emit_x86_instruction(compiler, 1, dst_r, 0, dst, dstw); in emit_clz()
1253 EMIT_MOV(compiler, dst, dstw, TMP_REG2, 0); in emit_clz()
1258 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op1(struct sljit_compiler *compiler, sljit_si op, in sljit_emit_op1() argument
1273 CHECK(check_sljit_emit_op1(compiler, op, dst, dstw, src, srcw)); in sljit_emit_op1()
1280 compiler->mode32 = op_flags & SLJIT_INT_OP; in sljit_emit_op1()
1286 compiler->mode32 = 0; in sljit_emit_op1()
1337 return emit_mov(compiler, dst, dstw, src, srcw); in sljit_emit_op1()
1342 inst = emit_x86_instruction(compiler, 1, src & REG_MASK, 0, src, srcw); in sljit_emit_op1()
1363 FAIL_IF(emit_mov(compiler, dst, dstw, src, srcw)); in sljit_emit_op1()
1366 FAIL_IF(emit_mov_byte(compiler, 0, dst, dstw, src, srcw)); in sljit_emit_op1()
1369 FAIL_IF(emit_mov_byte(compiler, 1, dst, dstw, src, srcw)); in sljit_emit_op1()
1372 FAIL_IF(emit_mov_half(compiler, 0, dst, dstw, src, srcw)); in sljit_emit_op1()
1375 FAIL_IF(emit_mov_half(compiler, 1, dst, dstw, src, srcw)); in sljit_emit_op1()
1379 FAIL_IF(emit_mov_int(compiler, 0, dst, dstw, src, srcw)); in sljit_emit_op1()
1382 FAIL_IF(emit_mov_int(compiler, 1, dst, dstw, src, srcw)); in sljit_emit_op1()
1389 return emit_mov(compiler, SLJIT_MEM1(SLJIT_SP), dstw, TMP_REG1, 0); in sljit_emit_op1()
1393 inst = emit_x86_instruction(compiler, 1, dst & REG_MASK, 0, dst, dstw); in sljit_emit_op1()
1401 compiler->flags_saved = 0; in sljit_emit_op1()
1406 return emit_not_with_flags(compiler, dst, dstw, src, srcw); in sljit_emit_op1()
1407 return emit_unary(compiler, NOT_rm, dst, dstw, src, srcw); in sljit_emit_op1()
1410 if (SLJIT_UNLIKELY(op_flags & SLJIT_KEEP_FLAGS) && !compiler->flags_saved) in sljit_emit_op1()
1411 FAIL_IF(emit_save_flags(compiler)); in sljit_emit_op1()
1412 return emit_unary(compiler, NEG_rm, dst, dstw, src, srcw); in sljit_emit_op1()
1415 if (SLJIT_UNLIKELY(op_flags & SLJIT_KEEP_FLAGS) && !compiler->flags_saved) in sljit_emit_op1()
1416 FAIL_IF(emit_save_flags(compiler)); in sljit_emit_op1()
1417 return emit_clz(compiler, op_flags, dst, dstw, src, srcw); in sljit_emit_op1()
1430 if (IS_HALFWORD(immw) || compiler->mode32) { \
1431 inst = emit_x86_instruction(compiler, 1 | EX86_BIN_INS, SLJIT_IMM, immw, arg, argw); \
1436 FAIL_IF(emit_load_imm64(compiler, TMP_REG2, immw)); \
1437 inst = emit_x86_instruction(compiler, 1, TMP_REG2, 0, arg, argw); \
1443 FAIL_IF(emit_do_imm32(compiler, (!compiler->mode32) ? REX_W : 0, (op_eax_imm), immw))
1448 inst = emit_x86_instruction(compiler, 1 | EX86_BIN_INS, SLJIT_IMM, immw, arg, argw); \
1453 FAIL_IF(emit_do_imm(compiler, (op_eax_imm), immw))
1457 static sljit_si emit_cum_binary(struct sljit_compiler *compiler, argument
1466 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
1471 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src2, src2w);
1481 …if ((dst == SLJIT_R0) && (src2w > 127 || src2w < -128) && (compiler->mode32 || IS_HALFWORD(src2w))…
1492 inst = emit_x86_instruction(compiler, 1, dst, dstw, src2, src2w);
1498 inst = emit_x86_instruction(compiler, 1, src2, src2w, dst, dstw);
1503 EMIT_MOV(compiler, TMP_REG1, 0, src2, src2w);
1504 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, dst, dstw);
1515 …if ((dst == SLJIT_R0) && (src1w > 127 || src1w < -128) && (compiler->mode32 || IS_HALFWORD(src1w))…
1526 inst = emit_x86_instruction(compiler, 1, dst, dstw, src1, src1w);
1531 inst = emit_x86_instruction(compiler, 1, src1, src1w, dst, dstw);
1536 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
1537 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, dst, dstw);
1546 EMIT_MOV(compiler, dst, 0, src1, src1w);
1551 inst = emit_x86_instruction(compiler, 1, dst, 0, src2, src2w);
1558 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
1563 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src2, src2w);
1567 EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0);
1573 static sljit_si emit_non_cum_binary(struct sljit_compiler *compiler, argument
1582 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
1587 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src2, src2w);
1597 …if ((dst == SLJIT_R0) && (src2w > 127 || src2w < -128) && (compiler->mode32 || IS_HALFWORD(src2w))…
1608 inst = emit_x86_instruction(compiler, 1, dst, dstw, src2, src2w);
1613 inst = emit_x86_instruction(compiler, 1, src2, src2w, dst, dstw);
1618 EMIT_MOV(compiler, TMP_REG1, 0, src2, src2w);
1619 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, dst, dstw);
1628 EMIT_MOV(compiler, dst, 0, src1, src1w);
1633 inst = emit_x86_instruction(compiler, 1, dst, 0, src2, src2w);
1640 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
1645 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src2, src2w);
1649 EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0);
1655 static sljit_si emit_mul(struct sljit_compiler *compiler, argument
1667 inst = emit_x86_instruction(compiler, 2, dst_r, 0, src2, src2w);
1673 inst = emit_x86_instruction(compiler, 2, dst_r, 0, src1, src1w);
1680 EMIT_MOV(compiler, dst_r, 0, SLJIT_IMM, src2w);
1686 inst = emit_x86_instruction(compiler, 1, dst_r, 0, src2, src2w);
1689 inst = (sljit_ub*)ensure_buf(compiler, 1 + 1);
1696 inst = emit_x86_instruction(compiler, 1, dst_r, 0, src2, src2w);
1699 inst = (sljit_ub*)ensure_buf(compiler, 1 + 4);
1706 inst = emit_x86_instruction(compiler, 1, dst_r, 0, src2, src2w);
1709 inst = (sljit_ub*)ensure_buf(compiler, 1 + 4);
1715 EMIT_MOV(compiler, TMP_REG2, 0, SLJIT_IMM, src1w);
1717 EMIT_MOV(compiler, dst_r, 0, src2, src2w);
1718 inst = emit_x86_instruction(compiler, 2, dst_r, 0, TMP_REG2, 0);
1729 inst = emit_x86_instruction(compiler, 1, dst_r, 0, src1, src1w);
1732 inst = (sljit_ub*)ensure_buf(compiler, 1 + 1);
1739 inst = emit_x86_instruction(compiler, 1, dst_r, 0, src1, src1w);
1742 inst = (sljit_ub*)ensure_buf(compiler, 1 + 4);
1749 inst = emit_x86_instruction(compiler, 1, dst_r, 0, src1, src1w);
1752 inst = (sljit_ub*)ensure_buf(compiler, 1 + 4);
1758 EMIT_MOV(compiler, TMP_REG2, 0, SLJIT_IMM, src2w);
1760 EMIT_MOV(compiler, dst_r, 0, src1, src1w);
1761 inst = emit_x86_instruction(compiler, 2, dst_r, 0, TMP_REG2, 0);
1772 EMIT_MOV(compiler, dst_r, 0, src1, src1w);
1773 inst = emit_x86_instruction(compiler, 2, dst_r, 0, src2, src2w);
1780 EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0);
1785 static sljit_si emit_lea_binary(struct sljit_compiler *compiler, sljit_si keep_flags, argument
1805 inst = emit_x86_instruction(compiler, 1, dst_r, 0, SLJIT_MEM2(src1, src2), 0);
1811 if ((src2 & SLJIT_IMM) && (compiler->mode32 || IS_HALFWORD(src2w))) {
1812 inst = emit_x86_instruction(compiler, 1, dst_r, 0, SLJIT_MEM1(src1), (sljit_si)src2w);
1815 inst = emit_x86_instruction(compiler, 1, dst_r, 0, SLJIT_MEM1(src1), src2w);
1824 if ((src1 & SLJIT_IMM) && (compiler->mode32 || IS_HALFWORD(src1w))) {
1825 inst = emit_x86_instruction(compiler, 1, dst_r, 0, SLJIT_MEM1(src2), (sljit_si)src1w);
1828 inst = emit_x86_instruction(compiler, 1, dst_r, 0, SLJIT_MEM1(src2), src1w);
1838 return emit_mov(compiler, dst, dstw, TMP_REG1, 0);
1844 static sljit_si emit_cmp_binary(struct sljit_compiler *compiler, argument
1851 …if (src1 == SLJIT_R0 && (src2 & SLJIT_IMM) && (src2w > 127 || src2w < -128) && (compiler->mode32 |…
1864 inst = emit_x86_instruction(compiler, 1, src1, 0, src2, src2w);
1872 inst = emit_x86_instruction(compiler, 1, src2, 0, src1, src1w);
1880 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
1887 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
1888 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src2, src2w);
1895 static sljit_si emit_test_binary(struct sljit_compiler *compiler, argument
1902 …if (src1 == SLJIT_R0 && (src2 & SLJIT_IMM) && (src2w > 127 || src2w < -128) && (compiler->mode32 |…
1911 …if (src2 == SLJIT_R0 && (src2 & SLJIT_IMM) && (src1w > 127 || src1w < -128) && (compiler->mode32 |…
1922 if (IS_HALFWORD(src2w) || compiler->mode32) {
1923 inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src2w, src1, src1w);
1928 FAIL_IF(emit_load_imm64(compiler, TMP_REG2, src2w));
1929 inst = emit_x86_instruction(compiler, 1, TMP_REG2, 0, src1, src1w);
1934 inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src2w, src1, src1w);
1941 inst = emit_x86_instruction(compiler, 1, src1, 0, src2, src2w);
1951 if (IS_HALFWORD(src1w) || compiler->mode32) {
1952 inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src1w, src2, src2w);
1957 FAIL_IF(emit_load_imm64(compiler, TMP_REG2, src1w));
1958 inst = emit_x86_instruction(compiler, 1, TMP_REG2, 0, src2, src2w);
1963 inst = emit_x86_instruction(compiler, 1, src1, src1w, src2, src2w);
1970 inst = emit_x86_instruction(compiler, 1, src2, 0, src1, src1w);
1977 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
1980 if (IS_HALFWORD(src2w) || compiler->mode32) {
1981 inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src2w, TMP_REG1, 0);
1986 FAIL_IF(emit_load_imm64(compiler, TMP_REG2, src2w));
1987 inst = emit_x86_instruction(compiler, 1, TMP_REG2, 0, TMP_REG1, 0);
1992 inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src2w, TMP_REG1, 0);
1998 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src2, src2w);
2005 static sljit_si emit_shift(struct sljit_compiler *compiler, argument
2015 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, src2, src2w, dst, dstw);
2021 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
2022 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, src2, src2w, TMP_REG1, 0);
2028 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
2029 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
2032 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
2036 EMIT_MOV(compiler, dst, 0, src1, src1w);
2037 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, src2, src2w, dst, 0);
2043 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
2044 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, src2, src2w, TMP_REG1, 0);
2047 EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0);
2052 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
2053 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, src2, src2w);
2054 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
2057 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
2061 EMIT_MOV(compiler, dst, 0, src1, src1w);
2062 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_PREF_SHIFT_REG, 0);
2063 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, src2, src2w);
2064 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_PREF_SHIFT_REG, 0, dst, 0);
2067 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
2072 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
2074 EMIT_MOV(compiler, TMP_REG2, 0, SLJIT_PREF_SHIFT_REG, 0);
2077 EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), sizeof(sljit_sw), SLJIT_PREF_SHIFT_REG, 0);
2079 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, src2, src2w);
2080 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
2084 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, TMP_REG2, 0);
2086 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, SLJIT_MEM1(SLJIT_SP), sizeof(sljit_sw));
2088 EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0);
2094 static sljit_si emit_shift_with_flags(struct sljit_compiler *compiler, argument
2103 if ((src2w & 0x3f) != 0 || (compiler->mode32 && (src2w & 0x1f) != 0))
2104 return emit_shift(compiler, mode, dst, dstw, src1, src1w, src2, src2w);
2107 return emit_shift(compiler, mode, dst, dstw, src1, src1w, src2, src2w);
2110 return emit_mov(compiler, dst, dstw, src1, src1w);
2112 return emit_cum_binary(compiler, OR_r_rm, OR_rm_r, OR, OR_EAX_i32,
2117 return emit_shift(compiler, mode, dst, dstw, src1, src1w, src2, src2w);
2120 FAIL_IF(emit_cmp_binary(compiler, src1, src1w, SLJIT_IMM, 0));
2122 FAIL_IF(emit_shift(compiler,mode, dst, dstw, src1, src1w, src2, src2w));
2125 return emit_cmp_binary(compiler, dst, dstw, SLJIT_IMM, 0);
2129 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op2(struct sljit_compiler *compiler, sljit_si op, argument
2135 CHECK(check_sljit_emit_op2(compiler, op, dst, dstw, src1, src1w, src2, src2w));
2144 compiler->mode32 = op & SLJIT_INT_OP;
2149 compiler->flags_saved = 0;
2150 else if (SLJIT_UNLIKELY(op & SLJIT_KEEP_FLAGS) && !compiler->flags_saved)
2151 FAIL_IF(emit_save_flags(compiler));
2157 …if (emit_lea_binary(compiler, op & SLJIT_KEEP_FLAGS, dst, dstw, src1, src1w, src2, src2w) != SLJIT…
2158 return compiler->error;
2161 compiler->flags_saved = 0;
2162 if (SLJIT_UNLIKELY(op & SLJIT_KEEP_FLAGS) && !compiler->flags_saved)
2163 FAIL_IF(emit_save_flags(compiler));
2164 return emit_cum_binary(compiler, ADD_r_rm, ADD_rm_r, ADD, ADD_EAX_i32,
2167 if (SLJIT_UNLIKELY(compiler->flags_saved)) /* C flag must be restored. */
2168 FAIL_IF(emit_restore_flags(compiler, 1));
2170 FAIL_IF(emit_save_flags(compiler));
2172 compiler->flags_saved = 0;
2173 return emit_cum_binary(compiler, ADC_r_rm, ADC_rm_r, ADC, ADC_EAX_i32,
2177 …if ((src2 & SLJIT_IMM) && emit_lea_binary(compiler, op & SLJIT_KEEP_FLAGS, dst, dstw, src1, src1w,…
2178 return compiler->error;
2181 compiler->flags_saved = 0;
2182 if (SLJIT_UNLIKELY(op & SLJIT_KEEP_FLAGS) && !compiler->flags_saved)
2183 FAIL_IF(emit_save_flags(compiler));
2185 return emit_cmp_binary(compiler, src1, src1w, src2, src2w);
2186 return emit_non_cum_binary(compiler, SUB_r_rm, SUB_rm_r, SUB, SUB_EAX_i32,
2189 if (SLJIT_UNLIKELY(compiler->flags_saved)) /* C flag must be restored. */
2190 FAIL_IF(emit_restore_flags(compiler, 1));
2192 FAIL_IF(emit_save_flags(compiler));
2194 compiler->flags_saved = 0;
2195 return emit_non_cum_binary(compiler, SBB_r_rm, SBB_rm_r, SBB, SBB_EAX_i32,
2198 return emit_mul(compiler, dst, dstw, src1, src1w, src2, src2w);
2201 return emit_test_binary(compiler, src1, src1w, src2, src2w);
2202 return emit_cum_binary(compiler, AND_r_rm, AND_rm_r, AND, AND_EAX_i32,
2205 return emit_cum_binary(compiler, OR_r_rm, OR_rm_r, OR, OR_EAX_i32,
2208 return emit_cum_binary(compiler, XOR_r_rm, XOR_rm_r, XOR, XOR_EAX_i32,
2211 return emit_shift_with_flags(compiler, SHL, GET_FLAGS(op),
2214 return emit_shift_with_flags(compiler, SHR, GET_FLAGS(op),
2217 return emit_shift_with_flags(compiler, SAR, GET_FLAGS(op),
2240 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_custom(struct sljit_compiler *compiler, argument
2246 CHECK(check_sljit_emit_op_custom(compiler, instruction, size));
2248 inst = (sljit_ub*)ensure_buf(compiler, 1 + size);
2289 static sljit_si emit_sse2(struct sljit_compiler *compiler, sljit_ub opcode, argument
2294 …inst = emit_x86_instruction(compiler, 2 | (single ? EX86_PREF_F3 : EX86_PREF_F2) | EX86_SSE2, xmm1…
2301 static sljit_si emit_sse2_logic(struct sljit_compiler *compiler, sljit_ub opcode, argument
2306 …inst = emit_x86_instruction(compiler, 2 | (pref66 ? EX86_PREF_66 : 0) | EX86_SSE2, xmm1, 0, xmm2, …
2313 static SLJIT_INLINE sljit_si emit_sse2_load(struct sljit_compiler *compiler, argument
2316 return emit_sse2(compiler, MOVSD_x_xm, single, dst, src, srcw);
2319 static SLJIT_INLINE sljit_si emit_sse2_store(struct sljit_compiler *compiler, argument
2322 return emit_sse2(compiler, MOVSD_xm_x, single, src, dst, dstw);
2325 static SLJIT_INLINE sljit_si sljit_emit_fop1_convw_fromd(struct sljit_compiler *compiler, sljit_si … argument
2334 compiler->mode32 = 0;
2337 …inst = emit_x86_instruction(compiler, 2 | ((op & SLJIT_SINGLE_OP) ? EX86_PREF_F3 : EX86_PREF_F2) |…
2343 return emit_mov(compiler, dst, dstw, TMP_REG1, 0);
2347 static SLJIT_INLINE sljit_si sljit_emit_fop1_convd_fromw(struct sljit_compiler *compiler, sljit_si … argument
2356 compiler->mode32 = 0;
2364 EMIT_MOV(compiler, TMP_REG1, 0, src, srcw);
2369 …inst = emit_x86_instruction(compiler, 2 | ((op & SLJIT_SINGLE_OP) ? EX86_PREF_F3 : EX86_PREF_F2) |…
2375 compiler->mode32 = 1;
2378 return emit_sse2_store(compiler, op & SLJIT_SINGLE_OP, dst, dstw, TMP_FREG);
2382 static SLJIT_INLINE sljit_si sljit_emit_fop1_cmp(struct sljit_compiler *compiler, sljit_si op, argument
2386 compiler->flags_saved = 0;
2388 FAIL_IF(emit_sse2_load(compiler, op & SLJIT_SINGLE_OP, TMP_FREG, src1, src1w));
2391 return emit_sse2_logic(compiler, UCOMISD_x_xm, !(op & SLJIT_SINGLE_OP), src1, src2, src2w);
2394 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop1(struct sljit_compiler *compiler, sljit_si op, argument
2401 compiler->mode32 = 1;
2405 SELECT_FOP1_OPERATION_WITH_CHECKS(compiler, op, dst, dstw, src, srcw);
2409 return emit_sse2_load(compiler, op & SLJIT_SINGLE_OP, dst, src, srcw);
2411 return emit_sse2_store(compiler, op & SLJIT_SINGLE_OP, dst, dstw, src);
2412 FAIL_IF(emit_sse2_load(compiler, op & SLJIT_SINGLE_OP, TMP_FREG, src, srcw));
2413 return emit_sse2_store(compiler, op & SLJIT_SINGLE_OP, dst, dstw, TMP_FREG);
2422 FAIL_IF(emit_sse2_logic(compiler, UNPCKLPD_x_xm, op & SLJIT_SINGLE_OP, src, src, 0));
2425 FAIL_IF(emit_sse2_load(compiler, !(op & SLJIT_SINGLE_OP), TMP_FREG, src, srcw));
2429 FAIL_IF(emit_sse2_logic(compiler, CVTPD2PS_x_xm, op & SLJIT_SINGLE_OP, dst_r, src, 0));
2431 return emit_sse2_store(compiler, op & SLJIT_SINGLE_OP, dst, dstw, TMP_FREG);
2438 FAIL_IF(emit_sse2_load(compiler, op & SLJIT_SINGLE_OP, dst_r, src, srcw));
2442 FAIL_IF(emit_sse2_load(compiler, op & SLJIT_SINGLE_OP, dst_r, src, srcw));
2447 …FAIL_IF(emit_sse2_logic(compiler, XORPD_x_xm, 1, dst_r, SLJIT_MEM0(), (sljit_sw)(op & SLJIT_SINGLE…
2451 …FAIL_IF(emit_sse2_logic(compiler, ANDPD_x_xm, 1, dst_r, SLJIT_MEM0(), (sljit_sw)(op & SLJIT_SINGLE…
2456 return emit_sse2_store(compiler, op & SLJIT_SINGLE_OP, dst, dstw, TMP_FREG);
2460 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop2(struct sljit_compiler *compiler, sljit_si op, argument
2468 CHECK(check_sljit_emit_fop2(compiler, op, dst, dstw, src1, src1w, src2, src2w));
2474 compiler->mode32 = 1;
2487 FAIL_IF(emit_sse2_load(compiler, op & SLJIT_SINGLE_OP, dst_r, src1, src1w));
2490 FAIL_IF(emit_sse2_load(compiler, op & SLJIT_SINGLE_OP, TMP_FREG, src1, src1w));
2495 FAIL_IF(emit_sse2_load(compiler, op & SLJIT_SINGLE_OP, TMP_FREG, src1, src1w));
2500 FAIL_IF(emit_sse2(compiler, ADDSD_x_xm, op & SLJIT_SINGLE_OP, dst_r, src2, src2w));
2504 FAIL_IF(emit_sse2(compiler, SUBSD_x_xm, op & SLJIT_SINGLE_OP, dst_r, src2, src2w));
2508 FAIL_IF(emit_sse2(compiler, MULSD_x_xm, op & SLJIT_SINGLE_OP, dst_r, src2, src2w));
2512 FAIL_IF(emit_sse2(compiler, DIVSD_x_xm, op & SLJIT_SINGLE_OP, dst_r, src2, src2w));
2517 return emit_sse2_store(compiler, op & SLJIT_SINGLE_OP, dst, dstw, TMP_FREG);
2525 SLJIT_API_FUNC_ATTRIBUTE struct sljit_label* sljit_emit_label(struct sljit_compiler *compiler) argument
2531 CHECK_PTR(check_sljit_emit_label(compiler));
2535 if (SLJIT_UNLIKELY(compiler->flags_saved))
2536 PTR_FAIL_IF(emit_restore_flags(compiler, 0));
2538 if (compiler->last_label && compiler->last_label->size == compiler->size)
2539 return compiler->last_label;
2541 label = (struct sljit_label*)ensure_abuf(compiler, sizeof(struct sljit_label));
2543 set_label(label, compiler);
2545 inst = (sljit_ub*)ensure_buf(compiler, 2);
2554 SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_jump(struct sljit_compiler *compiler, sljit_… argument
2560 CHECK_PTR(check_sljit_emit_jump(compiler, type));
2562 if (SLJIT_UNLIKELY(compiler->flags_saved)) {
2564 PTR_FAIL_IF(emit_restore_flags(compiler, 0));
2565 compiler->flags_saved = 0;
2568 jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sljit_jump));
2570 set_jump(jump, compiler, type & SLJIT_REWRITABLE_JUMP);
2574 PTR_FAIL_IF(call_with_args(compiler, type));
2578 compiler->size += (type >= SLJIT_JUMP) ? 5 : 6;
2580 compiler->size += (type >= SLJIT_JUMP) ? (10 + 3) : (2 + 10 + 3);
2583 inst = (sljit_ub*)ensure_buf(compiler, 2);
2591 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_ijump(struct sljit_compiler *compiler, sljit_si type, … argument
2597 CHECK(check_sljit_emit_ijump(compiler, type, src, srcw));
2602 if (SLJIT_UNLIKELY(compiler->flags_saved)) {
2604 FAIL_IF(emit_restore_flags(compiler, 0));
2605 compiler->flags_saved = 0;
2612 EMIT_MOV(compiler, TMP_REG1, 0, src, 0);
2621 EMIT_MOV(compiler, TMP_REG1, 0, src, 0);
2625 FAIL_IF(call_with_args(compiler, type));
2629 jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sljit_jump));
2631 set_jump(jump, compiler, JUMP_ADDR);
2636 compiler->size += 5;
2638 compiler->size += 10 + 3;
2641 inst = (sljit_ub*)ensure_buf(compiler, 2);
2650 compiler->mode32 = 1;
2652 inst = emit_x86_instruction(compiler, 1, 0, 0, src, srcw);
2660 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_flags(struct sljit_compiler *compiler, sljit_si op, argument
2676 CHECK(check_sljit_emit_op_flags(compiler, op, dst, dstw, src, srcw, type));
2684 if (SLJIT_UNLIKELY(compiler->flags_saved))
2685 FAIL_IF(emit_restore_flags(compiler, op & SLJIT_KEEP_FLAGS));
2693 inst = (sljit_ub*)ensure_buf(compiler, 1 + 4 + 3);
2709 inst = (sljit_ub*)ensure_buf(compiler, 1 + 4 + 4);
2726 compiler->mode32 = GET_OPCODE(op) != SLJIT_MOV;
2727 return emit_mov(compiler, dst, dstw, TMP_REG1, 0);
2731 compiler->skip_checks = 1;
2733 return sljit_emit_op2(compiler, op, dst, dstw, dst, dstw, TMP_REG1, 0);
2738 inst = (sljit_ub*)ensure_buf(compiler, 1 + 3 + 3);
2757 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_IMM, 1);
2759 EMIT_MOV(compiler, dst, 0, SLJIT_IMM, 0);
2761 inst = (sljit_ub*)ensure_buf(compiler, 1 + 3);
2772 inst = (sljit_ub*)ensure_buf(compiler, 1 + 1 + 3 + 3 + 1);
2791 inst = (sljit_ub*)ensure_buf(compiler, 1 + 1 + 3 + 2 + 1);
2804 inst = (sljit_ub*)ensure_buf(compiler, 1 + 2 + 3 + 2 + 2);
2822 inst = (sljit_ub*)ensure_buf(compiler, 1 + 1 + 3 + 3 + 1);
2838 return emit_mov(compiler, dst, dstw, TMP_REG1, 0);
2842 compiler->skip_checks = 1;
2844 return sljit_emit_op2(compiler, op, dst_save, dstw_save, dst_save, dstw_save, TMP_REG1, 0);
2848 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_get_local_base(struct sljit_compiler *compiler, sljit_si ds… argument
2851 CHECK(check_sljit_get_local_base(compiler, dst, dstw, offset));
2857 compiler->mode32 = 0;
2864 FAIL_IF(emit_load_imm64(compiler, TMP_REG1, offset));
2866 …SLJIT_ASSERT(emit_lea_binary(compiler, SLJIT_KEEP_FLAGS, dst, dstw, SLJIT_SP, 0, TMP_REG1, 0) != S…
2867 return compiler->error;
2869 return emit_lea_binary(compiler, SLJIT_KEEP_FLAGS, dst, dstw, SLJIT_SP, 0, TMP_REG1, 0);
2875 return emit_lea_binary(compiler, SLJIT_KEEP_FLAGS, dst, dstw, SLJIT_SP, 0, SLJIT_IMM, offset);
2876 return emit_mov(compiler, dst, dstw, SLJIT_SP, 0);
2879 SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compiler *compiler, slji… argument
2888 CHECK_PTR(check_sljit_emit_const(compiler, dst, dstw, init_value));
2893 const_ = (struct sljit_const*)ensure_abuf(compiler, sizeof(struct sljit_const));
2895 set_const(const_, compiler);
2898 compiler->mode32 = 0;
2901 if (emit_load_imm64(compiler, reg, init_value))
2907 if (emit_mov(compiler, dst, dstw, SLJIT_IMM, init_value))
2911 inst = (sljit_ub*)ensure_buf(compiler, 2);
2919 if (emit_mov(compiler, dst, dstw, TMP_REG1, 0))
2958 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_x86_emit_cmov(struct sljit_compiler *compiler, argument
2974 if (SLJIT_UNLIKELY(!!compiler->verbose)) {
2975 fprintf(compiler->verbose, " x86_cmov%s %s%s, ",
2978 sljit_verbose_reg(compiler, dst_reg & ~SLJIT_INT_OP);
2979 fprintf(compiler->verbose, ", ");
2980 sljit_verbose_param(compiler, src, srcw);
2981 fprintf(compiler->verbose, "\n");
2989 compiler->mode32 = dst_reg & SLJIT_INT_OP;
2994 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_IMM, srcw);
2999 inst = emit_x86_instruction(compiler, 2, dst_reg, 0, src, srcw);