• Home
  • Raw
  • Download

Lines Matching refs:compiler

258 #define INC_SIZE(s)			(*inst++ = (s), compiler->size += (s))
445 SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compiler) in sljit_generate_code() argument
459 check_sljit_generate_code(compiler); in sljit_generate_code()
460 reverse_buf(compiler); in sljit_generate_code()
463 code = (sljit_ub*)SLJIT_MALLOC_EXEC(compiler->size); in sljit_generate_code()
465 buf = compiler->buf; in sljit_generate_code()
468 label = compiler->labels; in sljit_generate_code()
469 jump = compiler->jumps; in sljit_generate_code()
470 const_ = compiler->consts; in sljit_generate_code()
523 jump = compiler->jumps; in sljit_generate_code()
555 SLJIT_ASSERT(code_ptr <= code + compiler->size); in sljit_generate_code()
556 compiler->error = SLJIT_ERR_COMPILED; in sljit_generate_code()
557 compiler->executable_size = code_ptr - code; in sljit_generate_code()
565 static sljit_si emit_cum_binary(struct sljit_compiler *compiler,
571 static sljit_si emit_non_cum_binary(struct sljit_compiler *compiler,
577 static sljit_si emit_mov(struct sljit_compiler *compiler,
581 static SLJIT_INLINE sljit_si emit_save_flags(struct sljit_compiler *compiler) in emit_save_flags() argument
586 inst = (sljit_ub*)ensure_buf(compiler, 1 + 5); in emit_save_flags()
590 inst = (sljit_ub*)ensure_buf(compiler, 1 + 6); in emit_save_flags()
600 compiler->flags_saved = 1; in emit_save_flags()
604 static SLJIT_INLINE sljit_si emit_restore_flags(struct sljit_compiler *compiler, sljit_si keep_flag… in emit_restore_flags() argument
609 inst = (sljit_ub*)ensure_buf(compiler, 1 + 5); in emit_restore_flags()
614 inst = (sljit_ub*)ensure_buf(compiler, 1 + 6); in emit_restore_flags()
624 compiler->flags_saved = keep_flags; in emit_restore_flags()
651 static sljit_si emit_mov(struct sljit_compiler *compiler, in emit_mov() argument
660 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src, srcw); in emit_mov()
667 inst = emit_x86_instruction(compiler, 1, src, 0, dst, dstw); in emit_mov()
675 return emit_do_imm(compiler, MOV_r_i32 + reg_map[dst], srcw); in emit_mov()
677 if (!compiler->mode32) { in emit_mov()
679 return emit_load_imm64(compiler, dst, srcw); in emit_mov()
682 … return emit_do_imm32(compiler, (reg_map[dst] >= 8) ? REX_B : 0, MOV_r_i32 + reg_lmap[dst], srcw); in emit_mov()
686 if (!compiler->mode32 && NOT_HALFWORD(srcw)) { in emit_mov()
687 FAIL_IF(emit_load_imm64(compiler, TMP_REG2, srcw)); in emit_mov()
688 inst = emit_x86_instruction(compiler, 1, TMP_REG2, 0, dst, dstw); in emit_mov()
694 inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, srcw, dst, dstw); in emit_mov()
700 inst = emit_x86_instruction(compiler, 1, dst, 0, src, srcw); in emit_mov()
707 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src, srcw); in emit_mov()
710 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, dst, dstw); in emit_mov()
716 #define EMIT_MOV(compiler, dst, dstw, src, srcw) \ argument
717 FAIL_IF(emit_mov(compiler, dst, dstw, src, srcw));
719 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler, sljit_si op) in sljit_emit_op0() argument
727 check_sljit_emit_op0(compiler, op); in sljit_emit_op0()
731 inst = (sljit_ub*)ensure_buf(compiler, 1 + 1); in sljit_emit_op0()
737 inst = (sljit_ub*)ensure_buf(compiler, 1 + 1); in sljit_emit_op0()
746 compiler->flags_saved = 0; in sljit_emit_op0()
761 compiler->mode32 = op & SLJIT_INT_OP; in sljit_emit_op0()
767 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_R1, 0); in sljit_emit_op0()
768 inst = emit_x86_instruction(compiler, 1, SLJIT_R1, 0, SLJIT_R1, 0); in sljit_emit_op0()
770 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, TMP_REG1, 0); in sljit_emit_op0()
778 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_R1, 0); in sljit_emit_op0()
782 inst = (sljit_ub*)ensure_buf(compiler, 1 + 1); in sljit_emit_op0()
787 if (compiler->mode32) { in sljit_emit_op0()
788 inst = (sljit_ub*)ensure_buf(compiler, 1 + 1); in sljit_emit_op0()
793 inst = (sljit_ub*)ensure_buf(compiler, 1 + 2); in sljit_emit_op0()
803 inst = (sljit_ub*)ensure_buf(compiler, 1 + 2); in sljit_emit_op0()
810 size = (!compiler->mode32 || op >= SLJIT_UDIV) ? 3 : 2; in sljit_emit_op0()
812 size = (!compiler->mode32) ? 3 : 2; in sljit_emit_op0()
814 inst = (sljit_ub*)ensure_buf(compiler, 1 + size); in sljit_emit_op0()
818 if (!compiler->mode32) in sljit_emit_op0()
825 if (!compiler->mode32) in sljit_emit_op0()
846 EMIT_MOV(compiler, SLJIT_R1, 0, TMP_REG1, 0); in sljit_emit_op0()
856 inst = (sljit_ub*)ensure_buf(compiler, 1 + 1); \
862 static sljit_si emit_mov_byte(struct sljit_compiler *compiler, sljit_si sign, in emit_mov_byte() argument
873 compiler->mode32 = 0; in emit_mov_byte()
882 return emit_do_imm(compiler, MOV_r_i32 + reg_map[dst], srcw); in emit_mov_byte()
884 inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, srcw, dst, 0); in emit_mov_byte()
890 …inst = emit_x86_instruction(compiler, 1 | EX86_BYTE_ARG | EX86_NO_REXW, SLJIT_IMM, srcw, dst, dstw… in emit_mov_byte()
902 EMIT_MOV(compiler, TMP_REG1, 0, src, 0); in emit_mov_byte()
915 EMIT_MOV(compiler, dst, 0, src, 0); in emit_mov_byte()
916 inst = emit_x86_instruction(compiler, 2, dst, 0, dst, 0); in emit_mov_byte()
923 EMIT_MOV(compiler, dst, 0, src, 0); in emit_mov_byte()
926 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_IMM, 24, dst, 0); in emit_mov_byte()
930 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_IMM, 24, dst, 0); in emit_mov_byte()
935 inst = emit_x86_instruction(compiler, 1 | EX86_BIN_INS, SLJIT_IMM, 0xff, dst, 0); in emit_mov_byte()
945 inst = emit_x86_instruction(compiler, 2, dst_r, 0, src, srcw); in emit_mov_byte()
974 inst = emit_x86_instruction(compiler, 1, work_r, 0, dst_r, 0); in emit_mov_byte()
979 inst = emit_x86_instruction(compiler, 1, work_r, 0, dst, dstw); in emit_mov_byte()
987 inst = emit_x86_instruction(compiler, 1, work_r, 0, dst_r, 0); in emit_mov_byte()
993 inst = emit_x86_instruction(compiler, 1, dst_r, 0, dst, dstw); in emit_mov_byte()
998 inst = emit_x86_instruction(compiler, 1 | EX86_REX | EX86_NO_REXW, dst_r, 0, dst, dstw); in emit_mov_byte()
1007 static sljit_si emit_mov_half(struct sljit_compiler *compiler, sljit_si sign, in emit_mov_half() argument
1015 compiler->mode32 = 0; in emit_mov_half()
1024 return emit_do_imm(compiler, MOV_r_i32 + reg_map[dst], srcw); in emit_mov_half()
1026 inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, srcw, dst, 0); in emit_mov_half()
1032 …inst = emit_x86_instruction(compiler, 1 | EX86_HALF_ARG | EX86_NO_REXW | EX86_PREF_66, SLJIT_IMM, … in emit_mov_half()
1043 inst = emit_x86_instruction(compiler, 2, dst_r, 0, src, srcw); in emit_mov_half()
1050 inst = emit_x86_instruction(compiler, 1 | EX86_NO_REXW | EX86_PREF_66, dst_r, 0, dst, dstw); in emit_mov_half()
1058 static sljit_si emit_unary(struct sljit_compiler *compiler, sljit_ub opcode, in emit_unary() argument
1065 EMIT_MOV(compiler, TMP_REG1, 0, src, srcw); in emit_unary()
1066 inst = emit_x86_instruction(compiler, 1, 0, 0, TMP_REG1, 0); in emit_unary()
1074 inst = emit_x86_instruction(compiler, 1, 0, 0, dst, dstw); in emit_unary()
1081 EMIT_MOV(compiler, dst, 0, src, srcw); in emit_unary()
1082 inst = emit_x86_instruction(compiler, 1, 0, 0, dst, dstw); in emit_unary()
1088 EMIT_MOV(compiler, TMP_REG1, 0, src, srcw); in emit_unary()
1089 inst = emit_x86_instruction(compiler, 1, 0, 0, TMP_REG1, 0); in emit_unary()
1093 EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0); in emit_unary()
1097 static sljit_si emit_not_with_flags(struct sljit_compiler *compiler, in emit_not_with_flags() argument
1104 EMIT_MOV(compiler, TMP_REG1, 0, src, srcw); in emit_not_with_flags()
1105 inst = emit_x86_instruction(compiler, 1, 0, 0, TMP_REG1, 0); in emit_not_with_flags()
1109 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, TMP_REG1, 0); in emit_not_with_flags()
1115 EMIT_MOV(compiler, dst, 0, src, srcw); in emit_not_with_flags()
1116 inst = emit_x86_instruction(compiler, 1, 0, 0, dst, dstw); in emit_not_with_flags()
1120 inst = emit_x86_instruction(compiler, 1, dst, 0, dst, 0); in emit_not_with_flags()
1125 EMIT_MOV(compiler, TMP_REG1, 0, src, srcw); in emit_not_with_flags()
1126 inst = emit_x86_instruction(compiler, 1, 0, 0, TMP_REG1, 0); in emit_not_with_flags()
1130 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, TMP_REG1, 0); in emit_not_with_flags()
1133 EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0); in emit_not_with_flags()
1137 static sljit_si emit_clz(struct sljit_compiler *compiler, sljit_si op_flags, in emit_clz() argument
1147 EMIT_MOV(compiler, TMP_REG1, 0, src, srcw); in emit_clz()
1148 inst = emit_x86_instruction(compiler, 1, 0, 0, TMP_REG1, 0); in emit_clz()
1153 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_IMM, 31, TMP_REG1, 0); in emit_clz()
1155 …inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_IMM, !(op_flags & SLJIT_INT_OP) ? … in emit_clz()
1163 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_IMM, srcw); in emit_clz()
1168 inst = emit_x86_instruction(compiler, 2, TMP_REG1, 0, src, srcw); in emit_clz()
1184 EMIT_MOV(compiler, dst, dstw, dst_r, 0); in emit_clz()
1186 EMIT_MOV(compiler, dst_r, 0, SLJIT_IMM, 32 + 31); in emit_clz()
1189 compiler->mode32 = 0; in emit_clz()
1190 EMIT_MOV(compiler, dst_r, 0, SLJIT_IMM, !(op_flags & SLJIT_INT_OP) ? 64 + 63 : 32 + 31); in emit_clz()
1191 compiler->mode32 = op_flags & SLJIT_INT_OP; in emit_clz()
1198 inst = emit_x86_instruction(compiler, 2, dst_r, 0, TMP_REG1, 0); in emit_clz()
1204 inst = (sljit_ub*)ensure_buf(compiler, 1 + 4); in emit_clz()
1213 inst = (sljit_ub*)ensure_buf(compiler, 1 + 5); in emit_clz()
1226 inst = emit_x86_instruction(compiler, 1 | EX86_BIN_INS, SLJIT_IMM, 31, dst_r, 0); in emit_clz()
1228 …inst = emit_x86_instruction(compiler, 1 | EX86_BIN_INS, SLJIT_IMM, !(op_flags & SLJIT_INT_OP) ? 63… in emit_clz()
1235 inst = emit_x86_instruction(compiler, 1, dst_r, 0, dst, dstw); in emit_clz()
1241 EMIT_MOV(compiler, dst, dstw, TMP_REG2, 0); in emit_clz()
1246 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op1(struct sljit_compiler *compiler, sljit_si op, in sljit_emit_op1() argument
1261 check_sljit_emit_op1(compiler, op, dst, dstw, src, srcw); in sljit_emit_op1()
1268 compiler->mode32 = op_flags & SLJIT_INT_OP; in sljit_emit_op1()
1274 compiler->mode32 = 0; in sljit_emit_op1()
1325 return emit_mov(compiler, dst, dstw, src, srcw); in sljit_emit_op1()
1330 inst = emit_x86_instruction(compiler, 1, src & REG_MASK, 0, src, srcw); in sljit_emit_op1()
1351 FAIL_IF(emit_mov(compiler, dst, dstw, src, srcw)); in sljit_emit_op1()
1354 FAIL_IF(emit_mov_byte(compiler, 0, dst, dstw, src, srcw)); in sljit_emit_op1()
1357 FAIL_IF(emit_mov_byte(compiler, 1, dst, dstw, src, srcw)); in sljit_emit_op1()
1360 FAIL_IF(emit_mov_half(compiler, 0, dst, dstw, src, srcw)); in sljit_emit_op1()
1363 FAIL_IF(emit_mov_half(compiler, 1, dst, dstw, src, srcw)); in sljit_emit_op1()
1367 FAIL_IF(emit_mov_int(compiler, 0, dst, dstw, src, srcw)); in sljit_emit_op1()
1370 FAIL_IF(emit_mov_int(compiler, 1, dst, dstw, src, srcw)); in sljit_emit_op1()
1377 return emit_mov(compiler, SLJIT_MEM1(SLJIT_SP), dstw, TMP_REG1, 0); in sljit_emit_op1()
1381 inst = emit_x86_instruction(compiler, 1, dst & REG_MASK, 0, dst, dstw); in sljit_emit_op1()
1389 compiler->flags_saved = 0; in sljit_emit_op1()
1394 return emit_not_with_flags(compiler, dst, dstw, src, srcw); in sljit_emit_op1()
1395 return emit_unary(compiler, NOT_rm, dst, dstw, src, srcw); in sljit_emit_op1()
1398 if (SLJIT_UNLIKELY(op_flags & SLJIT_KEEP_FLAGS) && !compiler->flags_saved) in sljit_emit_op1()
1399 FAIL_IF(emit_save_flags(compiler)); in sljit_emit_op1()
1400 return emit_unary(compiler, NEG_rm, dst, dstw, src, srcw); in sljit_emit_op1()
1403 if (SLJIT_UNLIKELY(op_flags & SLJIT_KEEP_FLAGS) && !compiler->flags_saved) in sljit_emit_op1()
1404 FAIL_IF(emit_save_flags(compiler)); in sljit_emit_op1()
1405 return emit_clz(compiler, op_flags, dst, dstw, src, srcw); in sljit_emit_op1()
1418 if (IS_HALFWORD(immw) || compiler->mode32) { \
1419 inst = emit_x86_instruction(compiler, 1 | EX86_BIN_INS, SLJIT_IMM, immw, arg, argw); \
1424 FAIL_IF(emit_load_imm64(compiler, TMP_REG2, immw)); \
1425 inst = emit_x86_instruction(compiler, 1, TMP_REG2, 0, arg, argw); \
1431 FAIL_IF(emit_do_imm32(compiler, (!compiler->mode32) ? REX_W : 0, (op_eax_imm), immw))
1436 inst = emit_x86_instruction(compiler, 1 | EX86_BIN_INS, SLJIT_IMM, immw, arg, argw); \
1441 FAIL_IF(emit_do_imm(compiler, (op_eax_imm), immw))
1445 static sljit_si emit_cum_binary(struct sljit_compiler *compiler, argument
1454 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
1459 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src2, src2w);
1469 …if ((dst == SLJIT_R0) && (src2w > 127 || src2w < -128) && (compiler->mode32 || IS_HALFWORD(src2w))…
1480 inst = emit_x86_instruction(compiler, 1, dst, dstw, src2, src2w);
1486 inst = emit_x86_instruction(compiler, 1, src2, src2w, dst, dstw);
1491 EMIT_MOV(compiler, TMP_REG1, 0, src2, src2w);
1492 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, dst, dstw);
1503 …if ((dst == SLJIT_R0) && (src1w > 127 || src1w < -128) && (compiler->mode32 || IS_HALFWORD(src1w))…
1514 inst = emit_x86_instruction(compiler, 1, dst, dstw, src1, src1w);
1519 inst = emit_x86_instruction(compiler, 1, src1, src1w, dst, dstw);
1524 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
1525 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, dst, dstw);
1534 EMIT_MOV(compiler, dst, 0, src1, src1w);
1539 inst = emit_x86_instruction(compiler, 1, dst, 0, src2, src2w);
1546 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
1551 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src2, src2w);
1555 EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0);
1561 static sljit_si emit_non_cum_binary(struct sljit_compiler *compiler, argument
1570 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
1575 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src2, src2w);
1585 …if ((dst == SLJIT_R0) && (src2w > 127 || src2w < -128) && (compiler->mode32 || IS_HALFWORD(src2w))…
1596 inst = emit_x86_instruction(compiler, 1, dst, dstw, src2, src2w);
1601 inst = emit_x86_instruction(compiler, 1, src2, src2w, dst, dstw);
1606 EMIT_MOV(compiler, TMP_REG1, 0, src2, src2w);
1607 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, dst, dstw);
1616 EMIT_MOV(compiler, dst, 0, src1, src1w);
1621 inst = emit_x86_instruction(compiler, 1, dst, 0, src2, src2w);
1628 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
1633 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src2, src2w);
1637 EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0);
1643 static sljit_si emit_mul(struct sljit_compiler *compiler, argument
1655 inst = emit_x86_instruction(compiler, 2, dst_r, 0, src2, src2w);
1661 inst = emit_x86_instruction(compiler, 2, dst_r, 0, src1, src1w);
1668 EMIT_MOV(compiler, dst_r, 0, SLJIT_IMM, src2w);
1674 inst = emit_x86_instruction(compiler, 1, dst_r, 0, src2, src2w);
1677 inst = (sljit_ub*)ensure_buf(compiler, 1 + 1);
1684 inst = emit_x86_instruction(compiler, 1, dst_r, 0, src2, src2w);
1687 inst = (sljit_ub*)ensure_buf(compiler, 1 + 4);
1694 inst = emit_x86_instruction(compiler, 1, dst_r, 0, src2, src2w);
1697 inst = (sljit_ub*)ensure_buf(compiler, 1 + 4);
1703 EMIT_MOV(compiler, TMP_REG2, 0, SLJIT_IMM, src1w);
1705 EMIT_MOV(compiler, dst_r, 0, src2, src2w);
1706 inst = emit_x86_instruction(compiler, 2, dst_r, 0, TMP_REG2, 0);
1717 inst = emit_x86_instruction(compiler, 1, dst_r, 0, src1, src1w);
1720 inst = (sljit_ub*)ensure_buf(compiler, 1 + 1);
1727 inst = emit_x86_instruction(compiler, 1, dst_r, 0, src1, src1w);
1730 inst = (sljit_ub*)ensure_buf(compiler, 1 + 4);
1737 inst = emit_x86_instruction(compiler, 1, dst_r, 0, src1, src1w);
1740 inst = (sljit_ub*)ensure_buf(compiler, 1 + 4);
1746 EMIT_MOV(compiler, TMP_REG2, 0, SLJIT_IMM, src1w);
1748 EMIT_MOV(compiler, dst_r, 0, src1, src1w);
1749 inst = emit_x86_instruction(compiler, 2, dst_r, 0, TMP_REG2, 0);
1760 EMIT_MOV(compiler, dst_r, 0, src1, src1w);
1761 inst = emit_x86_instruction(compiler, 2, dst_r, 0, src2, src2w);
1768 EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0);
1773 static sljit_si emit_lea_binary(struct sljit_compiler *compiler, sljit_si keep_flags, argument
1793 inst = emit_x86_instruction(compiler, 1, dst_r, 0, SLJIT_MEM2(src1, src2), 0);
1799 if ((src2 & SLJIT_IMM) && (compiler->mode32 || IS_HALFWORD(src2w))) {
1800 inst = emit_x86_instruction(compiler, 1, dst_r, 0, SLJIT_MEM1(src1), (sljit_si)src2w);
1803 inst = emit_x86_instruction(compiler, 1, dst_r, 0, SLJIT_MEM1(src1), src2w);
1812 if ((src1 & SLJIT_IMM) && (compiler->mode32 || IS_HALFWORD(src1w))) {
1813 inst = emit_x86_instruction(compiler, 1, dst_r, 0, SLJIT_MEM1(src2), (sljit_si)src1w);
1816 inst = emit_x86_instruction(compiler, 1, dst_r, 0, SLJIT_MEM1(src2), src1w);
1826 return emit_mov(compiler, dst, dstw, TMP_REG1, 0);
1832 static sljit_si emit_cmp_binary(struct sljit_compiler *compiler, argument
1839 …if (src1 == SLJIT_R0 && (src2 & SLJIT_IMM) && (src2w > 127 || src2w < -128) && (compiler->mode32 |…
1852 inst = emit_x86_instruction(compiler, 1, src1, 0, src2, src2w);
1860 inst = emit_x86_instruction(compiler, 1, src2, 0, src1, src1w);
1868 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
1875 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
1876 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src2, src2w);
1883 static sljit_si emit_test_binary(struct sljit_compiler *compiler, argument
1890 …if (src1 == SLJIT_R0 && (src2 & SLJIT_IMM) && (src2w > 127 || src2w < -128) && (compiler->mode32 |…
1899 …if (src2 == SLJIT_R0 && (src2 & SLJIT_IMM) && (src1w > 127 || src1w < -128) && (compiler->mode32 |…
1910 if (IS_HALFWORD(src2w) || compiler->mode32) {
1911 inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src2w, src1, 0);
1916 FAIL_IF(emit_load_imm64(compiler, TMP_REG2, src2w));
1917 inst = emit_x86_instruction(compiler, 1, TMP_REG2, 0, src1, 0);
1922 inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src2w, src1, 0);
1928 inst = emit_x86_instruction(compiler, 1, src1, 0, src2, src2w);
1938 if (IS_HALFWORD(src1w) || compiler->mode32) {
1939 inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src1w, src2, 0);
1944 FAIL_IF(emit_load_imm64(compiler, TMP_REG2, src1w));
1945 inst = emit_x86_instruction(compiler, 1, TMP_REG2, 0, src2, 0);
1950 inst = emit_x86_instruction(compiler, 1, src1, src1w, src2, 0);
1956 inst = emit_x86_instruction(compiler, 1, src2, 0, src1, src1w);
1963 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
1966 if (IS_HALFWORD(src2w) || compiler->mode32) {
1967 inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src2w, TMP_REG1, 0);
1972 FAIL_IF(emit_load_imm64(compiler, TMP_REG2, src2w));
1973 inst = emit_x86_instruction(compiler, 1, TMP_REG2, 0, TMP_REG1, 0);
1978 inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src2w, TMP_REG1, 0);
1984 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src2, src2w);
1991 static sljit_si emit_shift(struct sljit_compiler *compiler, argument
2001 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, src2, src2w, dst, dstw);
2007 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
2008 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, src2, src2w, TMP_REG1, 0);
2014 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
2015 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
2018 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
2022 EMIT_MOV(compiler, dst, 0, src1, src1w);
2023 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, src2, src2w, dst, 0);
2029 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
2030 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, src2, src2w, TMP_REG1, 0);
2033 EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0);
2038 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
2039 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, src2, src2w);
2040 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
2043 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
2047 EMIT_MOV(compiler, dst, 0, src1, src1w);
2048 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_PREF_SHIFT_REG, 0);
2049 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, src2, src2w);
2050 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_PREF_SHIFT_REG, 0, dst, 0);
2053 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
2058 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
2060 EMIT_MOV(compiler, TMP_REG2, 0, SLJIT_PREF_SHIFT_REG, 0);
2063 EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), sizeof(sljit_sw), SLJIT_PREF_SHIFT_REG, 0);
2065 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, src2, src2w);
2066 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
2070 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, TMP_REG2, 0);
2072 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, SLJIT_MEM1(SLJIT_SP), sizeof(sljit_sw));
2074 EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0);
2080 static sljit_si emit_shift_with_flags(struct sljit_compiler *compiler, argument
2089 if ((src2w & 0x3f) != 0 || (compiler->mode32 && (src2w & 0x1f) != 0))
2090 return emit_shift(compiler, mode, dst, dstw, src1, src1w, src2, src2w);
2093 return emit_shift(compiler, mode, dst, dstw, src1, src1w, src2, src2w);
2096 return emit_mov(compiler, dst, dstw, src1, src1w);
2098 return emit_cum_binary(compiler, OR_r_rm, OR_rm_r, OR, OR_EAX_i32,
2103 return emit_shift(compiler, mode, dst, dstw, src1, src1w, src2, src2w);
2106 FAIL_IF(emit_cmp_binary(compiler, src1, src1w, SLJIT_IMM, 0));
2108 FAIL_IF(emit_shift(compiler,mode, dst, dstw, src1, src1w, src2, src2w));
2111 return emit_cmp_binary(compiler, dst, dstw, SLJIT_IMM, 0);
2115 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op2(struct sljit_compiler *compiler, sljit_si op, argument
2121 check_sljit_emit_op2(compiler, op, dst, dstw, src1, src1w, src2, src2w);
2130 compiler->mode32 = op & SLJIT_INT_OP;
2135 compiler->flags_saved = 0;
2136 else if (SLJIT_UNLIKELY(op & SLJIT_KEEP_FLAGS) && !compiler->flags_saved)
2137 FAIL_IF(emit_save_flags(compiler));
2143 …if (emit_lea_binary(compiler, op & SLJIT_KEEP_FLAGS, dst, dstw, src1, src1w, src2, src2w) != SLJIT…
2144 return compiler->error;
2147 compiler->flags_saved = 0;
2148 if (SLJIT_UNLIKELY(op & SLJIT_KEEP_FLAGS) && !compiler->flags_saved)
2149 FAIL_IF(emit_save_flags(compiler));
2150 return emit_cum_binary(compiler, ADD_r_rm, ADD_rm_r, ADD, ADD_EAX_i32,
2153 if (SLJIT_UNLIKELY(compiler->flags_saved)) /* C flag must be restored. */
2154 FAIL_IF(emit_restore_flags(compiler, 1));
2156 FAIL_IF(emit_save_flags(compiler));
2158 compiler->flags_saved = 0;
2159 return emit_cum_binary(compiler, ADC_r_rm, ADC_rm_r, ADC, ADC_EAX_i32,
2163 …if ((src2 & SLJIT_IMM) && emit_lea_binary(compiler, op & SLJIT_KEEP_FLAGS, dst, dstw, src1, src1w,…
2164 return compiler->error;
2167 compiler->flags_saved = 0;
2168 if (SLJIT_UNLIKELY(op & SLJIT_KEEP_FLAGS) && !compiler->flags_saved)
2169 FAIL_IF(emit_save_flags(compiler));
2171 return emit_cmp_binary(compiler, src1, src1w, src2, src2w);
2172 return emit_non_cum_binary(compiler, SUB_r_rm, SUB_rm_r, SUB, SUB_EAX_i32,
2175 if (SLJIT_UNLIKELY(compiler->flags_saved)) /* C flag must be restored. */
2176 FAIL_IF(emit_restore_flags(compiler, 1));
2178 FAIL_IF(emit_save_flags(compiler));
2180 compiler->flags_saved = 0;
2181 return emit_non_cum_binary(compiler, SBB_r_rm, SBB_rm_r, SBB, SBB_EAX_i32,
2184 return emit_mul(compiler, dst, dstw, src1, src1w, src2, src2w);
2187 return emit_test_binary(compiler, src1, src1w, src2, src2w);
2188 return emit_cum_binary(compiler, AND_r_rm, AND_rm_r, AND, AND_EAX_i32,
2191 return emit_cum_binary(compiler, OR_r_rm, OR_rm_r, OR, OR_EAX_i32,
2194 return emit_cum_binary(compiler, XOR_r_rm, XOR_rm_r, XOR, XOR_EAX_i32,
2197 return emit_shift_with_flags(compiler, SHL, GET_FLAGS(op),
2200 return emit_shift_with_flags(compiler, SHR, GET_FLAGS(op),
2203 return emit_shift_with_flags(compiler, SAR, GET_FLAGS(op),
2226 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_custom(struct sljit_compiler *compiler, argument
2232 check_sljit_emit_op_custom(compiler, instruction, size);
2235 inst = (sljit_ub*)ensure_buf(compiler, 1 + size);
2276 static sljit_si emit_sse2(struct sljit_compiler *compiler, sljit_ub opcode, argument
2281 …inst = emit_x86_instruction(compiler, 2 | (single ? EX86_PREF_F3 : EX86_PREF_F2) | EX86_SSE2, xmm1…
2288 static sljit_si emit_sse2_logic(struct sljit_compiler *compiler, sljit_ub opcode, argument
2293 …inst = emit_x86_instruction(compiler, 2 | (pref66 ? EX86_PREF_66 : 0) | EX86_SSE2, xmm1, 0, xmm2, …
2300 static SLJIT_INLINE sljit_si emit_sse2_load(struct sljit_compiler *compiler, argument
2303 return emit_sse2(compiler, MOVSD_x_xm, single, dst, src, srcw);
2306 static SLJIT_INLINE sljit_si emit_sse2_store(struct sljit_compiler *compiler, argument
2309 return emit_sse2(compiler, MOVSD_xm_x, single, src, dst, dstw);
2312 static SLJIT_INLINE sljit_si sljit_emit_fop1_convw_fromd(struct sljit_compiler *compiler, sljit_si … argument
2321 compiler->mode32 = 0;
2324 …inst = emit_x86_instruction(compiler, 2 | ((op & SLJIT_SINGLE_OP) ? EX86_PREF_F3 : EX86_PREF_F2) |…
2330 return emit_mov(compiler, dst, dstw, TMP_REG1, 0);
2334 static SLJIT_INLINE sljit_si sljit_emit_fop1_convd_fromw(struct sljit_compiler *compiler, sljit_si … argument
2343 compiler->mode32 = 0;
2351 EMIT_MOV(compiler, TMP_REG1, 0, src, srcw);
2356 …inst = emit_x86_instruction(compiler, 2 | ((op & SLJIT_SINGLE_OP) ? EX86_PREF_F3 : EX86_PREF_F2) |…
2362 compiler->mode32 = 1;
2365 return emit_sse2_store(compiler, op & SLJIT_SINGLE_OP, dst, dstw, TMP_FREG);
2369 static SLJIT_INLINE sljit_si sljit_emit_fop1_cmp(struct sljit_compiler *compiler, sljit_si op, argument
2373 compiler->flags_saved = 0;
2375 FAIL_IF(emit_sse2_load(compiler, op & SLJIT_SINGLE_OP, TMP_FREG, src1, src1w));
2378 return emit_sse2_logic(compiler, UCOMISD_x_xm, !(op & SLJIT_SINGLE_OP), src1, src2, src2w);
2381 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop1(struct sljit_compiler *compiler, sljit_si op, argument
2388 compiler->mode32 = 1;
2392 SELECT_FOP1_OPERATION_WITH_CHECKS(compiler, op, dst, dstw, src, srcw);
2396 return emit_sse2_load(compiler, op & SLJIT_SINGLE_OP, dst, src, srcw);
2398 return emit_sse2_store(compiler, op & SLJIT_SINGLE_OP, dst, dstw, src);
2399 FAIL_IF(emit_sse2_load(compiler, op & SLJIT_SINGLE_OP, TMP_FREG, src, srcw));
2400 return emit_sse2_store(compiler, op & SLJIT_SINGLE_OP, dst, dstw, TMP_FREG);
2409 FAIL_IF(emit_sse2_logic(compiler, UNPCKLPD_x_xm, op & SLJIT_SINGLE_OP, src, src, 0));
2412 FAIL_IF(emit_sse2_load(compiler, !(op & SLJIT_SINGLE_OP), TMP_FREG, src, srcw));
2416 FAIL_IF(emit_sse2_logic(compiler, CVTPD2PS_x_xm, op & SLJIT_SINGLE_OP, dst_r, src, 0));
2418 return emit_sse2_store(compiler, op & SLJIT_SINGLE_OP, dst, dstw, TMP_FREG);
2425 FAIL_IF(emit_sse2_load(compiler, op & SLJIT_SINGLE_OP, dst_r, src, srcw));
2429 FAIL_IF(emit_sse2_load(compiler, op & SLJIT_SINGLE_OP, dst_r, src, srcw));
2434 …FAIL_IF(emit_sse2_logic(compiler, XORPD_x_xm, 1, dst_r, SLJIT_MEM0(), (sljit_sw)(op & SLJIT_SINGLE…
2438 …FAIL_IF(emit_sse2_logic(compiler, ANDPD_x_xm, 1, dst_r, SLJIT_MEM0(), (sljit_sw)(op & SLJIT_SINGLE…
2443 return emit_sse2_store(compiler, op & SLJIT_SINGLE_OP, dst, dstw, TMP_FREG);
2447 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop2(struct sljit_compiler *compiler, sljit_si op, argument
2455 check_sljit_emit_fop2(compiler, op, dst, dstw, src1, src1w, src2, src2w);
2461 compiler->mode32 = 1;
2474 FAIL_IF(emit_sse2_load(compiler, op & SLJIT_SINGLE_OP, dst_r, src1, src1w));
2477 FAIL_IF(emit_sse2_load(compiler, op & SLJIT_SINGLE_OP, TMP_FREG, src1, src1w));
2482 FAIL_IF(emit_sse2_load(compiler, op & SLJIT_SINGLE_OP, TMP_FREG, src1, src1w));
2487 FAIL_IF(emit_sse2(compiler, ADDSD_x_xm, op & SLJIT_SINGLE_OP, dst_r, src2, src2w));
2491 FAIL_IF(emit_sse2(compiler, SUBSD_x_xm, op & SLJIT_SINGLE_OP, dst_r, src2, src2w));
2495 FAIL_IF(emit_sse2(compiler, MULSD_x_xm, op & SLJIT_SINGLE_OP, dst_r, src2, src2w));
2499 FAIL_IF(emit_sse2(compiler, DIVSD_x_xm, op & SLJIT_SINGLE_OP, dst_r, src2, src2w));
2504 return emit_sse2_store(compiler, op & SLJIT_SINGLE_OP, dst, dstw, TMP_FREG);
2512 SLJIT_API_FUNC_ATTRIBUTE struct sljit_label* sljit_emit_label(struct sljit_compiler *compiler) argument
2518 check_sljit_emit_label(compiler);
2522 if (SLJIT_UNLIKELY(compiler->flags_saved))
2523 PTR_FAIL_IF(emit_restore_flags(compiler, 0));
2525 if (compiler->last_label && compiler->last_label->size == compiler->size)
2526 return compiler->last_label;
2528 label = (struct sljit_label*)ensure_abuf(compiler, sizeof(struct sljit_label));
2530 set_label(label, compiler);
2532 inst = (sljit_ub*)ensure_buf(compiler, 2);
2541 SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_jump(struct sljit_compiler *compiler, sljit_… argument
2547 check_sljit_emit_jump(compiler, type);
2549 if (SLJIT_UNLIKELY(compiler->flags_saved)) {
2551 PTR_FAIL_IF(emit_restore_flags(compiler, 0));
2552 compiler->flags_saved = 0;
2555 jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sljit_jump));
2557 set_jump(jump, compiler, type & SLJIT_REWRITABLE_JUMP);
2561 PTR_FAIL_IF(call_with_args(compiler, type));
2565 compiler->size += (type >= SLJIT_JUMP) ? 5 : 6;
2567 compiler->size += (type >= SLJIT_JUMP) ? (10 + 3) : (2 + 10 + 3);
2570 inst = (sljit_ub*)ensure_buf(compiler, 2);
2578 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_ijump(struct sljit_compiler *compiler, sljit_si type, … argument
2584 check_sljit_emit_ijump(compiler, type, src, srcw);
2589 if (SLJIT_UNLIKELY(compiler->flags_saved)) {
2591 FAIL_IF(emit_restore_flags(compiler, 0));
2592 compiler->flags_saved = 0;
2599 EMIT_MOV(compiler, TMP_REG1, 0, src, 0);
2608 EMIT_MOV(compiler, TMP_REG1, 0, src, 0);
2612 FAIL_IF(call_with_args(compiler, type));
2616 jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sljit_jump));
2618 set_jump(jump, compiler, JUMP_ADDR);
2623 compiler->size += 5;
2625 compiler->size += 10 + 3;
2628 inst = (sljit_ub*)ensure_buf(compiler, 2);
2637 compiler->mode32 = 1;
2639 inst = emit_x86_instruction(compiler, 1, 0, 0, src, srcw);
2647 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_flags(struct sljit_compiler *compiler, sljit_si op, argument
2663 check_sljit_emit_op_flags(compiler, op, dst, dstw, src, srcw, type);
2670 if (SLJIT_UNLIKELY(compiler->flags_saved))
2671 FAIL_IF(emit_restore_flags(compiler, op & SLJIT_KEEP_FLAGS));
2678 inst = (sljit_ub*)ensure_buf(compiler, 1 + 4 + 3);
2694 inst = (sljit_ub*)ensure_buf(compiler, 1 + 4 + 4);
2711 compiler->mode32 = GET_OPCODE(op) != SLJIT_MOV;
2712 return emit_mov(compiler, dst, dstw, TMP_REG1, 0);
2715 compiler->skip_checks = 1;
2717 return sljit_emit_op2(compiler, op, dst, dstw, dst, dstw, TMP_REG1, 0);
2722 inst = (sljit_ub*)ensure_buf(compiler, 1 + 3 + 3);
2741 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_IMM, 1);
2743 EMIT_MOV(compiler, dst, 0, SLJIT_IMM, 0);
2745 inst = (sljit_ub*)ensure_buf(compiler, 1 + 3);
2756 inst = (sljit_ub*)ensure_buf(compiler, 1 + 1 + 3 + 3 + 1);
2775 inst = (sljit_ub*)ensure_buf(compiler, 1 + 1 + 3 + 2 + 1);
2788 inst = (sljit_ub*)ensure_buf(compiler, 1 + 2 + 3 + 2 + 2);
2806 inst = (sljit_ub*)ensure_buf(compiler, 1 + 1 + 3 + 3 + 1);
2822 return emit_mov(compiler, dst, dstw, TMP_REG1, 0);
2825 compiler->skip_checks = 1;
2827 return sljit_emit_op2(compiler, op, dst_save, dstw_save, dst_save, dstw_save, TMP_REG1, 0);
2831 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_get_local_base(struct sljit_compiler *compiler, sljit_si ds… argument
2834 check_sljit_get_local_base(compiler, dst, dstw, offset);
2840 compiler->mode32 = 0;
2847 FAIL_IF(emit_load_imm64(compiler, TMP_REG1, offset));
2849 …SLJIT_ASSERT(emit_lea_binary(compiler, SLJIT_KEEP_FLAGS, dst, dstw, SLJIT_SP, 0, TMP_REG1, 0) != S…
2850 return compiler->error;
2852 return emit_lea_binary(compiler, SLJIT_KEEP_FLAGS, dst, dstw, SLJIT_SP, 0, TMP_REG1, 0);
2858 return emit_lea_binary(compiler, SLJIT_KEEP_FLAGS, dst, dstw, SLJIT_SP, 0, SLJIT_IMM, offset);
2859 return emit_mov(compiler, dst, dstw, SLJIT_SP, 0);
2862 SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compiler *compiler, slji… argument
2871 check_sljit_emit_const(compiler, dst, dstw, init_value);
2876 const_ = (struct sljit_const*)ensure_abuf(compiler, sizeof(struct sljit_const));
2878 set_const(const_, compiler);
2881 compiler->mode32 = 0;
2884 if (emit_load_imm64(compiler, reg, init_value))
2890 if (emit_mov(compiler, dst, dstw, SLJIT_IMM, init_value))
2894 inst = (sljit_ub*)ensure_buf(compiler, 2);
2902 if (emit_mov(compiler, dst, dstw, TMP_REG1, 0))