• Home
  • Raw
  • Download

Lines Matching full:compiler

2  *    Stack-less Just-In-Time compiler
259 #define INC_SIZE(s) (*inst++ = (s), compiler->size += (s))
471 SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compiler) in sljit_generate_code() argument
485 CHECK_PTR(check_sljit_generate_code(compiler)); in sljit_generate_code()
486 reverse_buf(compiler); in sljit_generate_code()
489 code = (sljit_u8*)SLJIT_MALLOC_EXEC(compiler->size); in sljit_generate_code()
491 buf = compiler->buf; in sljit_generate_code()
494 label = compiler->labels; in sljit_generate_code()
495 jump = compiler->jumps; in sljit_generate_code()
496 const_ = compiler->consts; in sljit_generate_code()
549 jump = compiler->jumps; in sljit_generate_code()
581 SLJIT_ASSERT(code_ptr <= code + compiler->size); in sljit_generate_code()
582 compiler->error = SLJIT_ERR_COMPILED; in sljit_generate_code()
583 compiler->executable_size = code_ptr - code; in sljit_generate_code()
591 static sljit_s32 emit_cum_binary(struct sljit_compiler *compiler,
597 static sljit_s32 emit_non_cum_binary(struct sljit_compiler *compiler,
603 static sljit_s32 emit_mov(struct sljit_compiler *compiler,
607 static SLJIT_INLINE sljit_s32 emit_save_flags(struct sljit_compiler *compiler) in emit_save_flags() argument
612 inst = (sljit_u8*)ensure_buf(compiler, 1 + 5); in emit_save_flags()
616 inst = (sljit_u8*)ensure_buf(compiler, 1 + 6); in emit_save_flags()
626 compiler->flags_saved = 1; in emit_save_flags()
630 static SLJIT_INLINE sljit_s32 emit_restore_flags(struct sljit_compiler *compiler, sljit_s32 keep_fl… in emit_restore_flags() argument
635 inst = (sljit_u8*)ensure_buf(compiler, 1 + 5); in emit_restore_flags()
640 inst = (sljit_u8*)ensure_buf(compiler, 1 + 6); in emit_restore_flags()
650 compiler->flags_saved = keep_flags; in emit_restore_flags()
677 static sljit_s32 emit_mov(struct sljit_compiler *compiler, in emit_mov() argument
686 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src, srcw); in emit_mov()
693 inst = emit_x86_instruction(compiler, 1, src, 0, dst, dstw); in emit_mov()
701 return emit_do_imm(compiler, MOV_r_i32 + reg_map[dst], srcw); in emit_mov()
703 if (!compiler->mode32) { in emit_mov()
705 return emit_load_imm64(compiler, dst, srcw); in emit_mov()
708 … return emit_do_imm32(compiler, (reg_map[dst] >= 8) ? REX_B : 0, MOV_r_i32 + reg_lmap[dst], srcw); in emit_mov()
712 if (!compiler->mode32 && NOT_HALFWORD(srcw)) { in emit_mov()
713 FAIL_IF(emit_load_imm64(compiler, TMP_REG2, srcw)); in emit_mov()
714 inst = emit_x86_instruction(compiler, 1, TMP_REG2, 0, dst, dstw); in emit_mov()
720 inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, srcw, dst, dstw); in emit_mov()
726 inst = emit_x86_instruction(compiler, 1, dst, 0, src, srcw); in emit_mov()
733 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src, srcw); in emit_mov()
736 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, dst, dstw); in emit_mov()
742 #define EMIT_MOV(compiler, dst, dstw, src, srcw) \ argument
743 FAIL_IF(emit_mov(compiler, dst, dstw, src, srcw));
745 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op0(struct sljit_compiler *compiler, sljit_s32 op) in sljit_emit_op0() argument
753 CHECK(check_sljit_emit_op0(compiler, op)); in sljit_emit_op0()
757 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1); in sljit_emit_op0()
763 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1); in sljit_emit_op0()
774 compiler->flags_saved = 0; in sljit_emit_op0()
789 compiler->mode32 = op & SLJIT_I32_OP; in sljit_emit_op0()
796 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_R1, 0); in sljit_emit_op0()
797 inst = emit_x86_instruction(compiler, 1, SLJIT_R1, 0, SLJIT_R1, 0); in sljit_emit_op0()
799 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, TMP_REG1, 0); in sljit_emit_op0()
807 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_R1, 0); in sljit_emit_op0()
811 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1); in sljit_emit_op0()
816 if (compiler->mode32) { in sljit_emit_op0()
817 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1); in sljit_emit_op0()
822 inst = (sljit_u8*)ensure_buf(compiler, 1 + 2); in sljit_emit_op0()
832 inst = (sljit_u8*)ensure_buf(compiler, 1 + 2); in sljit_emit_op0()
839 size = (!compiler->mode32 || op >= SLJIT_DIVMOD_UW) ? 3 : 2; in sljit_emit_op0()
841 size = (!compiler->mode32) ? 3 : 2; in sljit_emit_op0()
843 inst = (sljit_u8*)ensure_buf(compiler, 1 + size); in sljit_emit_op0()
847 if (!compiler->mode32) in sljit_emit_op0()
854 if (!compiler->mode32) in sljit_emit_op0()
878 EMIT_MOV(compiler, SLJIT_R1, 0, TMP_REG1, 0); in sljit_emit_op0()
881 EMIT_MOV(compiler, SLJIT_R1, 0, TMP_REG1, 0); in sljit_emit_op0()
891 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1); \
897 static sljit_s32 emit_mov_byte(struct sljit_compiler *compiler, sljit_s32 sign, in emit_mov_byte() argument
908 compiler->mode32 = 0; in emit_mov_byte()
917 return emit_do_imm(compiler, MOV_r_i32 + reg_map[dst], srcw); in emit_mov_byte()
919 inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, srcw, dst, 0); in emit_mov_byte()
925 …inst = emit_x86_instruction(compiler, 1 | EX86_BYTE_ARG | EX86_NO_REXW, SLJIT_IMM, srcw, dst, dstw… in emit_mov_byte()
937 EMIT_MOV(compiler, TMP_REG1, 0, src, 0); in emit_mov_byte()
950 EMIT_MOV(compiler, dst, 0, src, 0); in emit_mov_byte()
951 inst = emit_x86_instruction(compiler, 2, dst, 0, dst, 0); in emit_mov_byte()
958 EMIT_MOV(compiler, dst, 0, src, 0); in emit_mov_byte()
961 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_IMM, 24, dst, 0); in emit_mov_byte()
965 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_IMM, 24, dst, 0); in emit_mov_byte()
970 inst = emit_x86_instruction(compiler, 1 | EX86_BIN_INS, SLJIT_IMM, 0xff, dst, 0); in emit_mov_byte()
980 inst = emit_x86_instruction(compiler, 2, dst_r, 0, src, srcw); in emit_mov_byte()
1009 inst = emit_x86_instruction(compiler, 1, work_r, 0, dst_r, 0); in emit_mov_byte()
1014 inst = emit_x86_instruction(compiler, 1, work_r, 0, dst, dstw); in emit_mov_byte()
1022 inst = emit_x86_instruction(compiler, 1, work_r, 0, dst_r, 0); in emit_mov_byte()
1028 inst = emit_x86_instruction(compiler, 1, dst_r, 0, dst, dstw); in emit_mov_byte()
1033 inst = emit_x86_instruction(compiler, 1 | EX86_REX | EX86_NO_REXW, dst_r, 0, dst, dstw); in emit_mov_byte()
1042 static sljit_s32 emit_mov_half(struct sljit_compiler *compiler, sljit_s32 sign, in emit_mov_half() argument
1050 compiler->mode32 = 0; in emit_mov_half()
1059 return emit_do_imm(compiler, MOV_r_i32 + reg_map[dst], srcw); in emit_mov_half()
1061 inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, srcw, dst, 0); in emit_mov_half()
1067 …inst = emit_x86_instruction(compiler, 1 | EX86_HALF_ARG | EX86_NO_REXW | EX86_PREF_66, SLJIT_IMM, … in emit_mov_half()
1078 inst = emit_x86_instruction(compiler, 2, dst_r, 0, src, srcw); in emit_mov_half()
1085 inst = emit_x86_instruction(compiler, 1 | EX86_NO_REXW | EX86_PREF_66, dst_r, 0, dst, dstw); in emit_mov_half()
1093 static sljit_s32 emit_unary(struct sljit_compiler *compiler, sljit_u8 opcode, in emit_unary() argument
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()
1109 inst = emit_x86_instruction(compiler, 1, 0, 0, dst, dstw); in emit_unary()
1116 EMIT_MOV(compiler, dst, 0, src, srcw); in emit_unary()
1117 inst = emit_x86_instruction(compiler, 1, 0, 0, dst, dstw); in emit_unary()
1123 EMIT_MOV(compiler, TMP_REG1, 0, src, srcw); in emit_unary()
1124 inst = emit_x86_instruction(compiler, 1, 0, 0, TMP_REG1, 0); in emit_unary()
1128 EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0); in emit_unary()
1132 static sljit_s32 emit_not_with_flags(struct sljit_compiler *compiler, in emit_not_with_flags() argument
1139 EMIT_MOV(compiler, TMP_REG1, 0, src, srcw); in emit_not_with_flags()
1140 inst = emit_x86_instruction(compiler, 1, 0, 0, TMP_REG1, 0); in emit_not_with_flags()
1144 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, TMP_REG1, 0); in emit_not_with_flags()
1150 EMIT_MOV(compiler, dst, 0, src, srcw); in emit_not_with_flags()
1151 inst = emit_x86_instruction(compiler, 1, 0, 0, dst, dstw); in emit_not_with_flags()
1155 inst = emit_x86_instruction(compiler, 1, dst, 0, dst, 0); in emit_not_with_flags()
1160 EMIT_MOV(compiler, TMP_REG1, 0, src, srcw); in emit_not_with_flags()
1161 inst = emit_x86_instruction(compiler, 1, 0, 0, TMP_REG1, 0); in emit_not_with_flags()
1165 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, TMP_REG1, 0); in emit_not_with_flags()
1168 EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0); in emit_not_with_flags()
1172 static sljit_s32 emit_clz(struct sljit_compiler *compiler, sljit_s32 op_flags, in emit_clz() argument
1182 EMIT_MOV(compiler, TMP_REG1, 0, src, srcw); in emit_clz()
1183 inst = emit_x86_instruction(compiler, 1, 0, 0, TMP_REG1, 0); in emit_clz()
1188 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_IMM, 31, TMP_REG1, 0); in emit_clz()
1190 …inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_IMM, !(op_flags & SLJIT_I32_OP) ? … in emit_clz()
1198 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_IMM, srcw); in emit_clz()
1203 inst = emit_x86_instruction(compiler, 2, TMP_REG1, 0, src, srcw); in emit_clz()
1219 EMIT_MOV(compiler, dst, dstw, dst_r, 0); in emit_clz()
1221 EMIT_MOV(compiler, dst_r, 0, SLJIT_IMM, 32 + 31); in emit_clz()
1224 compiler->mode32 = 0; in emit_clz()
1225 EMIT_MOV(compiler, dst_r, 0, SLJIT_IMM, !(op_flags & SLJIT_I32_OP) ? 64 + 63 : 32 + 31); in emit_clz()
1226 compiler->mode32 = op_flags & SLJIT_I32_OP; in emit_clz()
1233 inst = emit_x86_instruction(compiler, 2, dst_r, 0, TMP_REG1, 0); in emit_clz()
1239 inst = (sljit_u8*)ensure_buf(compiler, 1 + 4); in emit_clz()
1248 inst = (sljit_u8*)ensure_buf(compiler, 1 + 5); in emit_clz()
1261 inst = emit_x86_instruction(compiler, 1 | EX86_BIN_INS, SLJIT_IMM, 31, dst_r, 0); in emit_clz()
1263 …inst = emit_x86_instruction(compiler, 1 | EX86_BIN_INS, SLJIT_IMM, !(op_flags & SLJIT_I32_OP) ? 63… in emit_clz()
1270 inst = emit_x86_instruction(compiler, 1, dst_r, 0, dst, dstw); in emit_clz()
1276 EMIT_MOV(compiler, dst, dstw, TMP_REG2, 0); in emit_clz()
1281 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op1(struct sljit_compiler *compiler, sljit_s32 op, in sljit_emit_op1() argument
1296 CHECK(check_sljit_emit_op1(compiler, op, dst, dstw, src, srcw)); in sljit_emit_op1()
1303 compiler->mode32 = op_flags & SLJIT_I32_OP; in sljit_emit_op1()
1309 compiler->mode32 = 0; in sljit_emit_op1()
1360 return emit_mov(compiler, dst, dstw, src, srcw); in sljit_emit_op1()
1365 inst = emit_x86_instruction(compiler, 1, src & REG_MASK, 0, src, srcw); in sljit_emit_op1()
1386 FAIL_IF(emit_mov(compiler, dst, dstw, src, srcw)); in sljit_emit_op1()
1389 FAIL_IF(emit_mov_byte(compiler, 0, dst, dstw, src, srcw)); in sljit_emit_op1()
1392 FAIL_IF(emit_mov_byte(compiler, 1, dst, dstw, src, srcw)); in sljit_emit_op1()
1395 FAIL_IF(emit_mov_half(compiler, 0, dst, dstw, src, srcw)); in sljit_emit_op1()
1398 FAIL_IF(emit_mov_half(compiler, 1, dst, dstw, src, srcw)); in sljit_emit_op1()
1402 FAIL_IF(emit_mov_int(compiler, 0, dst, dstw, src, srcw)); in sljit_emit_op1()
1405 FAIL_IF(emit_mov_int(compiler, 1, dst, dstw, src, srcw)); in sljit_emit_op1()
1412 return emit_mov(compiler, SLJIT_MEM1(SLJIT_SP), dstw, TMP_REG1, 0); in sljit_emit_op1()
1416 inst = emit_x86_instruction(compiler, 1, dst & REG_MASK, 0, dst, dstw); in sljit_emit_op1()
1424 compiler->flags_saved = 0; in sljit_emit_op1()
1429 return emit_not_with_flags(compiler, dst, dstw, src, srcw); in sljit_emit_op1()
1430 return emit_unary(compiler, NOT_rm, dst, dstw, src, srcw); in sljit_emit_op1()
1433 if (SLJIT_UNLIKELY(op_flags & SLJIT_KEEP_FLAGS) && !compiler->flags_saved) in sljit_emit_op1()
1434 FAIL_IF(emit_save_flags(compiler)); in sljit_emit_op1()
1435 return emit_unary(compiler, NEG_rm, dst, dstw, src, srcw); in sljit_emit_op1()
1438 if (SLJIT_UNLIKELY(op_flags & SLJIT_KEEP_FLAGS) && !compiler->flags_saved) in sljit_emit_op1()
1439 FAIL_IF(emit_save_flags(compiler)); in sljit_emit_op1()
1440 return emit_clz(compiler, op_flags, dst, dstw, src, srcw); in sljit_emit_op1()
1453 if (IS_HALFWORD(immw) || compiler->mode32) { \
1454 inst = emit_x86_instruction(compiler, 1 | EX86_BIN_INS, SLJIT_IMM, immw, arg, argw); \
1459 FAIL_IF(emit_load_imm64(compiler, TMP_REG2, immw)); \
1460 inst = emit_x86_instruction(compiler, 1, TMP_REG2, 0, arg, argw); \
1466 FAIL_IF(emit_do_imm32(compiler, (!compiler->mode32) ? REX_W : 0, (op_eax_imm), immw))
1471 inst = emit_x86_instruction(compiler, 1 | EX86_BIN_INS, SLJIT_IMM, immw, arg, argw); \
1476 FAIL_IF(emit_do_imm(compiler, (op_eax_imm), immw))
1480 static sljit_s32 emit_cum_binary(struct sljit_compiler *compiler, argument
1489 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
1494 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src2, src2w);
1504 …if ((dst == SLJIT_R0) && (src2w > 127 || src2w < -128) && (compiler->mode32 || IS_HALFWORD(src2w))…
1515 inst = emit_x86_instruction(compiler, 1, dst, dstw, src2, src2w);
1521 inst = emit_x86_instruction(compiler, 1, src2, src2w, dst, dstw);
1526 EMIT_MOV(compiler, TMP_REG1, 0, src2, src2w);
1527 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, dst, dstw);
1538 …if ((dst == SLJIT_R0) && (src1w > 127 || src1w < -128) && (compiler->mode32 || IS_HALFWORD(src1w))…
1549 inst = emit_x86_instruction(compiler, 1, dst, dstw, src1, src1w);
1554 inst = emit_x86_instruction(compiler, 1, src1, src1w, dst, dstw);
1559 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
1560 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, dst, dstw);
1569 EMIT_MOV(compiler, dst, 0, src1, src1w);
1574 inst = emit_x86_instruction(compiler, 1, dst, 0, src2, src2w);
1581 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
1586 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src2, src2w);
1590 EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0);
1596 static sljit_s32 emit_non_cum_binary(struct sljit_compiler *compiler, argument
1605 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
1610 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src2, src2w);
1620 …if ((dst == SLJIT_R0) && (src2w > 127 || src2w < -128) && (compiler->mode32 || IS_HALFWORD(src2w))…
1631 inst = emit_x86_instruction(compiler, 1, dst, dstw, src2, src2w);
1636 inst = emit_x86_instruction(compiler, 1, src2, src2w, dst, dstw);
1641 EMIT_MOV(compiler, TMP_REG1, 0, src2, src2w);
1642 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, dst, dstw);
1651 EMIT_MOV(compiler, dst, 0, src1, src1w);
1656 inst = emit_x86_instruction(compiler, 1, dst, 0, src2, src2w);
1663 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
1668 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src2, src2w);
1672 EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0);
1678 static sljit_s32 emit_mul(struct sljit_compiler *compiler, argument
1690 inst = emit_x86_instruction(compiler, 2, dst_r, 0, src2, src2w);
1696 inst = emit_x86_instruction(compiler, 2, dst_r, 0, src1, src1w);
1703 EMIT_MOV(compiler, dst_r, 0, SLJIT_IMM, src2w);
1709 inst = emit_x86_instruction(compiler, 1, dst_r, 0, src2, src2w);
1712 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1);
1719 inst = emit_x86_instruction(compiler, 1, dst_r, 0, src2, src2w);
1722 inst = (sljit_u8*)ensure_buf(compiler, 1 + 4);
1729 inst = emit_x86_instruction(compiler, 1, dst_r, 0, src2, src2w);
1732 inst = (sljit_u8*)ensure_buf(compiler, 1 + 4);
1738 EMIT_MOV(compiler, TMP_REG2, 0, SLJIT_IMM, src1w);
1740 EMIT_MOV(compiler, dst_r, 0, src2, src2w);
1741 inst = emit_x86_instruction(compiler, 2, dst_r, 0, TMP_REG2, 0);
1752 inst = emit_x86_instruction(compiler, 1, dst_r, 0, src1, src1w);
1755 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1);
1762 inst = emit_x86_instruction(compiler, 1, dst_r, 0, src1, src1w);
1765 inst = (sljit_u8*)ensure_buf(compiler, 1 + 4);
1772 inst = emit_x86_instruction(compiler, 1, dst_r, 0, src1, src1w);
1775 inst = (sljit_u8*)ensure_buf(compiler, 1 + 4);
1781 EMIT_MOV(compiler, TMP_REG2, 0, SLJIT_IMM, src2w);
1783 EMIT_MOV(compiler, dst_r, 0, src1, src1w);
1784 inst = emit_x86_instruction(compiler, 2, dst_r, 0, TMP_REG2, 0);
1795 EMIT_MOV(compiler, dst_r, 0, src1, src1w);
1796 inst = emit_x86_instruction(compiler, 2, dst_r, 0, src2, src2w);
1803 EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0);
1808 static sljit_s32 emit_lea_binary(struct sljit_compiler *compiler, sljit_s32 keep_flags, argument
1828 inst = emit_x86_instruction(compiler, 1, dst_r, 0, SLJIT_MEM2(src1, src2), 0);
1834 if ((src2 & SLJIT_IMM) && (compiler->mode32 || IS_HALFWORD(src2w))) {
1835 inst = emit_x86_instruction(compiler, 1, dst_r, 0, SLJIT_MEM1(src1), (sljit_s32)src2w);
1838 inst = emit_x86_instruction(compiler, 1, dst_r, 0, SLJIT_MEM1(src1), src2w);
1847 if ((src1 & SLJIT_IMM) && (compiler->mode32 || IS_HALFWORD(src1w))) {
1848 inst = emit_x86_instruction(compiler, 1, dst_r, 0, SLJIT_MEM1(src2), (sljit_s32)src1w);
1851 inst = emit_x86_instruction(compiler, 1, dst_r, 0, SLJIT_MEM1(src2), src1w);
1861 return emit_mov(compiler, dst, dstw, TMP_REG1, 0);
1867 static sljit_s32 emit_cmp_binary(struct sljit_compiler *compiler, argument
1874 …if (src1 == SLJIT_R0 && (src2 & SLJIT_IMM) && (src2w > 127 || src2w < -128) && (compiler->mode32 |…
1887 inst = emit_x86_instruction(compiler, 1, src1, 0, src2, src2w);
1895 inst = emit_x86_instruction(compiler, 1, src2, 0, src1, src1w);
1903 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
1910 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
1911 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src2, src2w);
1918 static sljit_s32 emit_test_binary(struct sljit_compiler *compiler, argument
1925 …if (src1 == SLJIT_R0 && (src2 & SLJIT_IMM) && (src2w > 127 || src2w < -128) && (compiler->mode32 |…
1934 …if (src2 == SLJIT_R0 && (src2 & SLJIT_IMM) && (src1w > 127 || src1w < -128) && (compiler->mode32 |…
1945 if (IS_HALFWORD(src2w) || compiler->mode32) {
1946 inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src2w, src1, src1w);
1951 FAIL_IF(emit_load_imm64(compiler, TMP_REG2, src2w));
1952 inst = emit_x86_instruction(compiler, 1, TMP_REG2, 0, src1, src1w);
1957 inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src2w, src1, src1w);
1964 inst = emit_x86_instruction(compiler, 1, src1, 0, src2, src2w);
1974 if (IS_HALFWORD(src1w) || compiler->mode32) {
1975 inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src1w, src2, src2w);
1980 FAIL_IF(emit_load_imm64(compiler, TMP_REG2, src1w));
1981 inst = emit_x86_instruction(compiler, 1, TMP_REG2, 0, src2, src2w);
1986 inst = emit_x86_instruction(compiler, 1, src1, src1w, src2, src2w);
1993 inst = emit_x86_instruction(compiler, 1, src2, 0, src1, src1w);
2000 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
2003 if (IS_HALFWORD(src2w) || compiler->mode32) {
2004 inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src2w, TMP_REG1, 0);
2009 FAIL_IF(emit_load_imm64(compiler, TMP_REG2, src2w));
2010 inst = emit_x86_instruction(compiler, 1, TMP_REG2, 0, TMP_REG1, 0);
2015 inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src2w, TMP_REG1, 0);
2021 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src2, src2w);
2028 static sljit_s32 emit_shift(struct sljit_compiler *compiler, argument
2038 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, src2, src2w, dst, dstw);
2044 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
2045 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, src2, src2w, TMP_REG1, 0);
2051 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
2052 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
2055 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
2059 EMIT_MOV(compiler, dst, 0, src1, src1w);
2060 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, src2, src2w, dst, 0);
2066 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
2067 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, src2, src2w, TMP_REG1, 0);
2070 EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0);
2075 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
2076 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, src2, src2w);
2077 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
2080 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
2084 EMIT_MOV(compiler, dst, 0, src1, src1w);
2085 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_PREF_SHIFT_REG, 0);
2086 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, src2, src2w);
2087 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_PREF_SHIFT_REG, 0, dst, 0);
2090 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
2095 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
2097 EMIT_MOV(compiler, TMP_REG2, 0, SLJIT_PREF_SHIFT_REG, 0);
2100 EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), sizeof(sljit_sw), SLJIT_PREF_SHIFT_REG, 0);
2102 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, src2, src2w);
2103 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
2107 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, TMP_REG2, 0);
2109 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, SLJIT_MEM1(SLJIT_SP), sizeof(sljit_sw));
2111 EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0);
2117 static sljit_s32 emit_shift_with_flags(struct sljit_compiler *compiler, argument
2126 if ((src2w & 0x3f) != 0 || (compiler->mode32 && (src2w & 0x1f) != 0))
2127 return emit_shift(compiler, mode, dst, dstw, src1, src1w, src2, src2w);
2130 return emit_shift(compiler, mode, dst, dstw, src1, src1w, src2, src2w);
2133 return emit_mov(compiler, dst, dstw, src1, src1w);
2135 return emit_cum_binary(compiler, OR_r_rm, OR_rm_r, OR, OR_EAX_i32,
2140 return emit_shift(compiler, mode, dst, dstw, src1, src1w, src2, src2w);
2143 FAIL_IF(emit_cmp_binary(compiler, src1, src1w, SLJIT_IMM, 0));
2145 FAIL_IF(emit_shift(compiler,mode, dst, dstw, src1, src1w, src2, src2w));
2148 return emit_cmp_binary(compiler, dst, dstw, SLJIT_IMM, 0);
2152 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op2(struct sljit_compiler *compiler, sljit_s32 op, argument
2158 CHECK(check_sljit_emit_op2(compiler, op, dst, dstw, src1, src1w, src2, src2w));
2167 compiler->mode32 = op & SLJIT_I32_OP;
2172 compiler->flags_saved = 0;
2173 else if (SLJIT_UNLIKELY(op & SLJIT_KEEP_FLAGS) && !compiler->flags_saved)
2174 FAIL_IF(emit_save_flags(compiler));
2180 …if (emit_lea_binary(compiler, op & SLJIT_KEEP_FLAGS, dst, dstw, src1, src1w, src2, src2w) != SLJIT…
2181 return compiler->error;
2184 compiler->flags_saved = 0;
2185 if (SLJIT_UNLIKELY(op & SLJIT_KEEP_FLAGS) && !compiler->flags_saved)
2186 FAIL_IF(emit_save_flags(compiler));
2187 return emit_cum_binary(compiler, ADD_r_rm, ADD_rm_r, ADD, ADD_EAX_i32,
2190 if (SLJIT_UNLIKELY(compiler->flags_saved)) /* C flag must be restored. */
2191 FAIL_IF(emit_restore_flags(compiler, 1));
2193 FAIL_IF(emit_save_flags(compiler));
2195 compiler->flags_saved = 0;
2196 return emit_cum_binary(compiler, ADC_r_rm, ADC_rm_r, ADC, ADC_EAX_i32,
2200 …if ((src2 & SLJIT_IMM) && emit_lea_binary(compiler, op & SLJIT_KEEP_FLAGS, dst, dstw, src1, src1w,…
2201 return compiler->error;
2204 compiler->flags_saved = 0;
2205 if (SLJIT_UNLIKELY(op & SLJIT_KEEP_FLAGS) && !compiler->flags_saved)
2206 FAIL_IF(emit_save_flags(compiler));
2208 return emit_cmp_binary(compiler, src1, src1w, src2, src2w);
2209 return emit_non_cum_binary(compiler, SUB_r_rm, SUB_rm_r, SUB, SUB_EAX_i32,
2212 if (SLJIT_UNLIKELY(compiler->flags_saved)) /* C flag must be restored. */
2213 FAIL_IF(emit_restore_flags(compiler, 1));
2215 FAIL_IF(emit_save_flags(compiler));
2217 compiler->flags_saved = 0;
2218 return emit_non_cum_binary(compiler, SBB_r_rm, SBB_rm_r, SBB, SBB_EAX_i32,
2221 return emit_mul(compiler, dst, dstw, src1, src1w, src2, src2w);
2224 return emit_test_binary(compiler, src1, src1w, src2, src2w);
2225 return emit_cum_binary(compiler, AND_r_rm, AND_rm_r, AND, AND_EAX_i32,
2228 return emit_cum_binary(compiler, OR_r_rm, OR_rm_r, OR, OR_EAX_i32,
2231 return emit_cum_binary(compiler, XOR_r_rm, XOR_rm_r, XOR, XOR_EAX_i32,
2234 return emit_shift_with_flags(compiler, SHL, GET_FLAGS(op),
2237 return emit_shift_with_flags(compiler, SHR, GET_FLAGS(op),
2240 return emit_shift_with_flags(compiler, SAR, GET_FLAGS(op),
2263 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op_custom(struct sljit_compiler *compiler, argument
2269 CHECK(check_sljit_emit_op_custom(compiler, instruction, size));
2271 inst = (sljit_u8*)ensure_buf(compiler, 1 + size);
2312 static sljit_s32 emit_sse2(struct sljit_compiler *compiler, sljit_u8 opcode, argument
2317 …inst = emit_x86_instruction(compiler, 2 | (single ? EX86_PREF_F3 : EX86_PREF_F2) | EX86_SSE2, xmm1…
2324 static sljit_s32 emit_sse2_logic(struct sljit_compiler *compiler, sljit_u8 opcode, argument
2329 …inst = emit_x86_instruction(compiler, 2 | (pref66 ? EX86_PREF_66 : 0) | EX86_SSE2, xmm1, 0, xmm2, …
2336 static SLJIT_INLINE sljit_s32 emit_sse2_load(struct sljit_compiler *compiler, argument
2339 return emit_sse2(compiler, MOVSD_x_xm, single, dst, src, srcw);
2342 static SLJIT_INLINE sljit_s32 emit_sse2_store(struct sljit_compiler *compiler, argument
2345 return emit_sse2(compiler, MOVSD_xm_x, single, src, dst, dstw);
2348 static SLJIT_INLINE sljit_s32 sljit_emit_fop1_conv_sw_from_f64(struct sljit_compiler *compiler, slj… argument
2357 compiler->mode32 = 0;
2360 …inst = emit_x86_instruction(compiler, 2 | ((op & SLJIT_F32_OP) ? EX86_PREF_F3 : EX86_PREF_F2) | EX…
2366 return emit_mov(compiler, dst, dstw, TMP_REG1, 0);
2370 static SLJIT_INLINE sljit_s32 sljit_emit_fop1_conv_f64_from_sw(struct sljit_compiler *compiler, slj… argument
2379 compiler->mode32 = 0;
2387 EMIT_MOV(compiler, TMP_REG1, 0, src, srcw);
2392 …inst = emit_x86_instruction(compiler, 2 | ((op & SLJIT_F32_OP) ? EX86_PREF_F3 : EX86_PREF_F2) | EX…
2398 compiler->mode32 = 1;
2401 return emit_sse2_store(compiler, op & SLJIT_F32_OP, dst, dstw, TMP_FREG);
2405 static SLJIT_INLINE sljit_s32 sljit_emit_fop1_cmp(struct sljit_compiler *compiler, sljit_s32 op, argument
2409 compiler->flags_saved = 0;
2411 FAIL_IF(emit_sse2_load(compiler, op & SLJIT_F32_OP, TMP_FREG, src1, src1w));
2414 return emit_sse2_logic(compiler, UCOMISD_x_xm, !(op & SLJIT_F32_OP), src1, src2, src2w);
2417 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_fop1(struct sljit_compiler *compiler, sljit_s32 op, argument
2424 compiler->mode32 = 1;
2428 SELECT_FOP1_OPERATION_WITH_CHECKS(compiler, op, dst, dstw, src, srcw);
2432 return emit_sse2_load(compiler, op & SLJIT_F32_OP, dst, src, srcw);
2434 return emit_sse2_store(compiler, op & SLJIT_F32_OP, dst, dstw, src);
2435 FAIL_IF(emit_sse2_load(compiler, op & SLJIT_F32_OP, TMP_FREG, src, srcw));
2436 return emit_sse2_store(compiler, op & SLJIT_F32_OP, dst, dstw, TMP_FREG);
2445 FAIL_IF(emit_sse2_logic(compiler, UNPCKLPD_x_xm, op & SLJIT_F32_OP, src, src, 0));
2448 FAIL_IF(emit_sse2_load(compiler, !(op & SLJIT_F32_OP), TMP_FREG, src, srcw));
2452 FAIL_IF(emit_sse2_logic(compiler, CVTPD2PS_x_xm, op & SLJIT_F32_OP, dst_r, src, 0));
2454 return emit_sse2_store(compiler, op & SLJIT_F32_OP, dst, dstw, TMP_FREG);
2461 FAIL_IF(emit_sse2_load(compiler, op & SLJIT_F32_OP, dst_r, src, srcw));
2465 FAIL_IF(emit_sse2_load(compiler, op & SLJIT_F32_OP, dst_r, src, srcw));
2470 …FAIL_IF(emit_sse2_logic(compiler, XORPD_x_xm, 1, dst_r, SLJIT_MEM0(), (sljit_sw)(op & SLJIT_F32_OP…
2474 …FAIL_IF(emit_sse2_logic(compiler, ANDPD_x_xm, 1, dst_r, SLJIT_MEM0(), (sljit_sw)(op & SLJIT_F32_OP…
2479 return emit_sse2_store(compiler, op & SLJIT_F32_OP, dst, dstw, TMP_FREG);
2483 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_fop2(struct sljit_compiler *compiler, sljit_s32 op, argument
2491 CHECK(check_sljit_emit_fop2(compiler, op, dst, dstw, src1, src1w, src2, src2w));
2497 compiler->mode32 = 1;
2510 FAIL_IF(emit_sse2_load(compiler, op & SLJIT_F32_OP, dst_r, src1, src1w));
2513 FAIL_IF(emit_sse2_load(compiler, op & SLJIT_F32_OP, TMP_FREG, src1, src1w));
2518 FAIL_IF(emit_sse2_load(compiler, op & SLJIT_F32_OP, TMP_FREG, src1, src1w));
2523 FAIL_IF(emit_sse2(compiler, ADDSD_x_xm, op & SLJIT_F32_OP, dst_r, src2, src2w));
2527 FAIL_IF(emit_sse2(compiler, SUBSD_x_xm, op & SLJIT_F32_OP, dst_r, src2, src2w));
2531 FAIL_IF(emit_sse2(compiler, MULSD_x_xm, op & SLJIT_F32_OP, dst_r, src2, src2w));
2535 FAIL_IF(emit_sse2(compiler, DIVSD_x_xm, op & SLJIT_F32_OP, dst_r, src2, src2w));
2540 return emit_sse2_store(compiler, op & SLJIT_F32_OP, dst, dstw, TMP_FREG);
2548 SLJIT_API_FUNC_ATTRIBUTE struct sljit_label* sljit_emit_label(struct sljit_compiler *compiler) argument
2554 CHECK_PTR(check_sljit_emit_label(compiler));
2558 if (SLJIT_UNLIKELY(compiler->flags_saved))
2559 PTR_FAIL_IF(emit_restore_flags(compiler, 0));
2561 if (compiler->last_label && compiler->last_label->size == compiler->size)
2562 return compiler->last_label;
2564 label = (struct sljit_label*)ensure_abuf(compiler, sizeof(struct sljit_label));
2566 set_label(label, compiler);
2568 inst = (sljit_u8*)ensure_buf(compiler, 2);
2577 SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_jump(struct sljit_compiler *compiler, sljit_… argument
2583 CHECK_PTR(check_sljit_emit_jump(compiler, type));
2585 if (SLJIT_UNLIKELY(compiler->flags_saved)) {
2587 PTR_FAIL_IF(emit_restore_flags(compiler, 0));
2588 compiler->flags_saved = 0;
2591 jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sljit_jump));
2593 set_jump(jump, compiler, type & SLJIT_REWRITABLE_JUMP);
2597 PTR_FAIL_IF(call_with_args(compiler, type));
2601 compiler->size += (type >= SLJIT_JUMP) ? 5 : 6;
2603 compiler->size += (type >= SLJIT_JUMP) ? (10 + 3) : (2 + 10 + 3);
2606 inst = (sljit_u8*)ensure_buf(compiler, 2);
2614 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_ijump(struct sljit_compiler *compiler, sljit_s32 type… argument
2620 CHECK(check_sljit_emit_ijump(compiler, type, src, srcw));
2625 if (SLJIT_UNLIKELY(compiler->flags_saved)) {
2627 FAIL_IF(emit_restore_flags(compiler, 0));
2628 compiler->flags_saved = 0;
2635 EMIT_MOV(compiler, TMP_REG1, 0, src, 0);
2644 EMIT_MOV(compiler, TMP_REG1, 0, src, 0);
2648 FAIL_IF(call_with_args(compiler, type));
2652 jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sljit_jump));
2654 set_jump(jump, compiler, JUMP_ADDR);
2659 compiler->size += 5;
2661 compiler->size += 10 + 3;
2664 inst = (sljit_u8*)ensure_buf(compiler, 2);
2673 compiler->mode32 = 1;
2675 inst = emit_x86_instruction(compiler, 1, 0, 0, src, srcw);
2683 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op_flags(struct sljit_compiler *compiler, sljit_s32 o… argument
2699 CHECK(check_sljit_emit_op_flags(compiler, op, dst, dstw, src, srcw, type));
2707 if (SLJIT_UNLIKELY(compiler->flags_saved))
2708 FAIL_IF(emit_restore_flags(compiler, op & SLJIT_KEEP_FLAGS));
2716 inst = (sljit_u8*)ensure_buf(compiler, 1 + 4 + 3);
2732 inst = (sljit_u8*)ensure_buf(compiler, 1 + 4 + 4);
2749 compiler->mode32 = GET_OPCODE(op) != SLJIT_MOV;
2750 return emit_mov(compiler, dst, dstw, TMP_REG1, 0);
2754 compiler->skip_checks = 1;
2756 return sljit_emit_op2(compiler, op, dst, dstw, dst, dstw, TMP_REG1, 0);
2761 inst = (sljit_u8*)ensure_buf(compiler, 1 + 3 + 3);
2780 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_IMM, 1);
2782 EMIT_MOV(compiler, dst, 0, SLJIT_IMM, 0);
2784 inst = (sljit_u8*)ensure_buf(compiler, 1 + 3);
2795 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1 + 3 + 3 + 1);
2814 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1 + 3 + 2 + 1);
2827 inst = (sljit_u8*)ensure_buf(compiler, 1 + 2 + 3 + 2 + 2);
2845 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1 + 3 + 3 + 1);
2861 return emit_mov(compiler, dst, dstw, TMP_REG1, 0);
2865 compiler->skip_checks = 1;
2867 return sljit_emit_op2(compiler, op, dst_save, dstw_save, dst_save, dstw_save, TMP_REG1, 0);
2871 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_get_local_base(struct sljit_compiler *compiler, sljit_s32 … argument
2874 CHECK(check_sljit_get_local_base(compiler, dst, dstw, offset));
2880 compiler->mode32 = 0;
2887 FAIL_IF(emit_load_imm64(compiler, TMP_REG1, offset));
2889 …SLJIT_ASSERT(emit_lea_binary(compiler, SLJIT_KEEP_FLAGS, dst, dstw, SLJIT_SP, 0, TMP_REG1, 0) != S…
2890 return compiler->error;
2892 return emit_lea_binary(compiler, SLJIT_KEEP_FLAGS, dst, dstw, SLJIT_SP, 0, TMP_REG1, 0);
2898 return emit_lea_binary(compiler, SLJIT_KEEP_FLAGS, dst, dstw, SLJIT_SP, 0, SLJIT_IMM, offset);
2899 return emit_mov(compiler, dst, dstw, SLJIT_SP, 0);
2902 SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compiler *compiler, slji… argument
2911 CHECK_PTR(check_sljit_emit_const(compiler, dst, dstw, init_value));
2916 const_ = (struct sljit_const*)ensure_abuf(compiler, sizeof(struct sljit_const));
2918 set_const(const_, compiler);
2921 compiler->mode32 = 0;
2924 if (emit_load_imm64(compiler, reg, init_value))
2930 if (emit_mov(compiler, dst, dstw, SLJIT_IMM, init_value))
2934 inst = (sljit_u8*)ensure_buf(compiler, 2);
2942 if (emit_mov(compiler, dst, dstw, TMP_REG1, 0))
2981 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_x86_emit_cmov(struct sljit_compiler *compiler, argument
2997 if (SLJIT_UNLIKELY(!!compiler->verbose)) {
2998 fprintf(compiler->verbose, " x86_cmov%s %s%s, ",
3001 sljit_verbose_reg(compiler, dst_reg & ~SLJIT_I32_OP);
3002 fprintf(compiler->verbose, ", ");
3003 sljit_verbose_param(compiler, src, srcw);
3004 fprintf(compiler->verbose, "\n");
3012 compiler->mode32 = dst_reg & SLJIT_I32_OP;
3017 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_IMM, srcw);
3022 inst = emit_x86_instruction(compiler, 2, dst_reg, 0, src, srcw);