Lines Matching refs:compiler
79 if (p <= compiler->scratches) \
80 w = compiler->saveds_offset - ((p) - SLJIT_R2) * (sljit_sw)sizeof(sljit_sw); \
82 w = compiler->locals_offset + ((p) - SLJIT_S2) * (sljit_sw)sizeof(sljit_sw); \
277 #define INC_SIZE(s) (*inst++ = (s), compiler->size += (s))
486 SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compiler) in sljit_generate_code() argument
502 CHECK_PTR(check_sljit_generate_code(compiler)); in sljit_generate_code()
503 reverse_buf(compiler); in sljit_generate_code()
506 code = (sljit_u8*)SLJIT_MALLOC_EXEC(compiler->size); in sljit_generate_code()
508 buf = compiler->buf; in sljit_generate_code()
511 label = compiler->labels; in sljit_generate_code()
512 jump = compiler->jumps; in sljit_generate_code()
513 const_ = compiler->consts; in sljit_generate_code()
561 jump = compiler->jumps; in sljit_generate_code()
595 SLJIT_ASSERT(code_ptr <= code + compiler->size); in sljit_generate_code()
596 compiler->error = SLJIT_ERR_COMPILED; in sljit_generate_code()
597 compiler->executable_offset = executable_offset; in sljit_generate_code()
598 compiler->executable_size = code_ptr - code; in sljit_generate_code()
647 static sljit_s32 emit_cum_binary(struct sljit_compiler *compiler,
653 static sljit_s32 emit_non_cum_binary(struct sljit_compiler *compiler,
659 static sljit_s32 emit_mov(struct sljit_compiler *compiler,
663 #define EMIT_MOV(compiler, dst, dstw, src, srcw) \ argument
664 FAIL_IF(emit_mov(compiler, dst, dstw, src, srcw));
666 static SLJIT_INLINE sljit_s32 emit_sse2_store(struct sljit_compiler *compiler,
669 static SLJIT_INLINE sljit_s32 emit_sse2_load(struct sljit_compiler *compiler,
678 static sljit_s32 emit_mov(struct sljit_compiler *compiler, in emit_mov() argument
687 inst = emit_x86_instruction(compiler, 1, src, 0, dst, dstw); in emit_mov()
695 return emit_do_imm(compiler, MOV_r_i32 + reg_map[dst], srcw); in emit_mov()
697 if (!compiler->mode32) { in emit_mov()
699 return emit_load_imm64(compiler, dst, srcw); in emit_mov()
702 … return emit_do_imm32(compiler, (reg_map[dst] >= 8) ? REX_B : 0, MOV_r_i32 + reg_lmap[dst], srcw); in emit_mov()
706 if (!compiler->mode32 && NOT_HALFWORD(srcw)) { in emit_mov()
709 FAIL_IF(emit_load_imm64(compiler, TMP_REG1, srcw)); in emit_mov()
710 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, dst, dstw); in emit_mov()
716 inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, srcw, dst, dstw); in emit_mov()
722 inst = emit_x86_instruction(compiler, 1, dst, 0, src, srcw); in emit_mov()
730 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src, srcw); in emit_mov()
733 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, dst, dstw); in emit_mov()
739 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op0(struct sljit_compiler *compiler, sljit_s32 op) in sljit_emit_op0() argument
747 CHECK(check_sljit_emit_op0(compiler, op)); in sljit_emit_op0()
751 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1); in sljit_emit_op0()
757 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1); in sljit_emit_op0()
780 compiler->mode32 = op & SLJIT_I32_OP; in sljit_emit_op0()
787 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_R1, 0); in sljit_emit_op0()
788 inst = emit_x86_instruction(compiler, 1, SLJIT_R1, 0, SLJIT_R1, 0); in sljit_emit_op0()
790 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, TMP_REG1, 0); in sljit_emit_op0()
798 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_R1, 0); in sljit_emit_op0()
802 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1); in sljit_emit_op0()
807 if (compiler->mode32) { in sljit_emit_op0()
808 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1); in sljit_emit_op0()
813 inst = (sljit_u8*)ensure_buf(compiler, 1 + 2); in sljit_emit_op0()
823 inst = (sljit_u8*)ensure_buf(compiler, 1 + 2); in sljit_emit_op0()
830 size = (!compiler->mode32 || op >= SLJIT_DIVMOD_UW) ? 3 : 2; in sljit_emit_op0()
832 size = (!compiler->mode32) ? 3 : 2; in sljit_emit_op0()
834 inst = (sljit_u8*)ensure_buf(compiler, 1 + size); in sljit_emit_op0()
838 if (!compiler->mode32) in sljit_emit_op0()
845 if (!compiler->mode32) in sljit_emit_op0()
869 EMIT_MOV(compiler, SLJIT_R1, 0, TMP_REG1, 0); in sljit_emit_op0()
872 EMIT_MOV(compiler, SLJIT_R1, 0, TMP_REG1, 0); in sljit_emit_op0()
882 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1); \
888 static sljit_s32 emit_mov_byte(struct sljit_compiler *compiler, sljit_s32 sign, in emit_mov_byte() argument
899 compiler->mode32 = 0; in emit_mov_byte()
905 return emit_do_imm(compiler, MOV_r_i32 + reg_map[dst], srcw); in emit_mov_byte()
907 inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, srcw, dst, 0); in emit_mov_byte()
913 …inst = emit_x86_instruction(compiler, 1 | EX86_BYTE_ARG | EX86_NO_REXW, SLJIT_IMM, srcw, dst, dstw… in emit_mov_byte()
925 EMIT_MOV(compiler, TMP_REG1, 0, src, 0); in emit_mov_byte()
938 EMIT_MOV(compiler, dst, 0, src, 0); in emit_mov_byte()
939 inst = emit_x86_instruction(compiler, 2, dst, 0, dst, 0); in emit_mov_byte()
946 EMIT_MOV(compiler, dst, 0, src, 0); in emit_mov_byte()
949 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_IMM, 24, dst, 0); in emit_mov_byte()
953 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_IMM, 24, dst, 0); in emit_mov_byte()
958 inst = emit_x86_instruction(compiler, 1 | EX86_BIN_INS, SLJIT_IMM, 0xff, dst, 0); in emit_mov_byte()
968 inst = emit_x86_instruction(compiler, 2, dst_r, 0, src, srcw); in emit_mov_byte()
997 inst = emit_x86_instruction(compiler, 1, work_r, 0, dst_r, 0); in emit_mov_byte()
1002 inst = emit_x86_instruction(compiler, 1, work_r, 0, dst, dstw); in emit_mov_byte()
1010 inst = emit_x86_instruction(compiler, 1, work_r, 0, dst_r, 0); in emit_mov_byte()
1016 inst = emit_x86_instruction(compiler, 1, dst_r, 0, dst, dstw); in emit_mov_byte()
1021 inst = emit_x86_instruction(compiler, 1 | EX86_REX | EX86_NO_REXW, dst_r, 0, dst, dstw); in emit_mov_byte()
1030 static sljit_s32 emit_prefetch(struct sljit_compiler *compiler, sljit_s32 op, in emit_prefetch() argument
1036 compiler->mode32 = 1; in emit_prefetch()
1039 inst = emit_x86_instruction(compiler, 2, 0, 0, src, srcw); in emit_prefetch()
1054 static sljit_s32 emit_mov_half(struct sljit_compiler *compiler, sljit_s32 sign, in emit_mov_half() argument
1062 compiler->mode32 = 0; in emit_mov_half()
1068 return emit_do_imm(compiler, MOV_r_i32 + reg_map[dst], srcw); in emit_mov_half()
1070 inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, srcw, dst, 0); in emit_mov_half()
1076 …inst = emit_x86_instruction(compiler, 1 | EX86_HALF_ARG | EX86_NO_REXW | EX86_PREF_66, SLJIT_IMM, … in emit_mov_half()
1087 inst = emit_x86_instruction(compiler, 2, dst_r, 0, src, srcw); in emit_mov_half()
1094 inst = emit_x86_instruction(compiler, 1 | EX86_NO_REXW | EX86_PREF_66, dst_r, 0, dst, dstw); in emit_mov_half()
1102 static sljit_s32 emit_unary(struct sljit_compiler *compiler, sljit_u8 opcode, in emit_unary() argument
1110 inst = emit_x86_instruction(compiler, 1, 0, 0, dst, dstw); in emit_unary()
1121 EMIT_MOV(compiler, dst, 0, src, srcw); in emit_unary()
1122 inst = emit_x86_instruction(compiler, 1, 0, 0, dst, 0); in emit_unary()
1129 EMIT_MOV(compiler, TMP_REG1, 0, src, srcw); in emit_unary()
1130 inst = emit_x86_instruction(compiler, 1, 0, 0, TMP_REG1, 0); in emit_unary()
1134 EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0); in emit_unary()
1138 static sljit_s32 emit_not_with_flags(struct sljit_compiler *compiler, in emit_not_with_flags() argument
1148 EMIT_MOV(compiler, dst, 0, src, srcw); in emit_not_with_flags()
1149 inst = emit_x86_instruction(compiler, 1, 0, 0, dst, 0); in emit_not_with_flags()
1153 inst = emit_x86_instruction(compiler, 1, dst, 0, dst, 0); in emit_not_with_flags()
1159 EMIT_MOV(compiler, TMP_REG1, 0, src, srcw); in emit_not_with_flags()
1160 inst = emit_x86_instruction(compiler, 1, 0, 0, TMP_REG1, 0); in emit_not_with_flags()
1164 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, TMP_REG1, 0); in emit_not_with_flags()
1167 EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0); in emit_not_with_flags()
1175 static sljit_s32 emit_clz(struct sljit_compiler *compiler, sljit_s32 op_flags, in emit_clz() argument
1189 inst = emit_x86_instruction(compiler, 2, dst_r, 0, src, srcw); in emit_clz()
1197 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_IMM, 32 + 31); in emit_clz()
1198 inst = emit_x86_instruction(compiler, 2, dst_r, 0, TMP_REG1, 0); in emit_clz()
1201 inst = emit_x86_instruction(compiler, 2, dst_r, 0, SLJIT_MEM0(), (sljit_sw)&emit_clz_arg); in emit_clz()
1208 FAIL_IF(sljit_emit_cmov_generic(compiler, SLJIT_EQUAL, dst_r, SLJIT_IMM, 32 + 31)); in emit_clz()
1210 inst = emit_x86_instruction(compiler, 1 | EX86_BIN_INS, SLJIT_IMM, 31, dst_r, 0); in emit_clz()
1213 EMIT_MOV(compiler, TMP_REG2, 0, SLJIT_IMM, !(op_flags & SLJIT_I32_OP) ? (64 + 63) : (32 + 31)); in emit_clz()
1215 inst = emit_x86_instruction(compiler, 2, dst_r, 0, TMP_REG2, 0); in emit_clz()
1221 …FAIL_IF(sljit_emit_cmov_generic(compiler, SLJIT_EQUAL, dst_r, SLJIT_IMM, !(op_flags & SLJIT_I32_OP… in emit_clz()
1223 …inst = emit_x86_instruction(compiler, 1 | EX86_BIN_INS, SLJIT_IMM, !(op_flags & SLJIT_I32_OP) ? 63… in emit_clz()
1230 EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0); in emit_clz()
1234 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op1(struct sljit_compiler *compiler, sljit_s32 op, in sljit_emit_op1() argument
1244 CHECK(check_sljit_emit_op1(compiler, op, dst, dstw, src, srcw)); in sljit_emit_op1()
1251 compiler->mode32 = op_flags & SLJIT_I32_OP; in sljit_emit_op1()
1256 return emit_prefetch(compiler, op, src, srcw); in sljit_emit_op1()
1264 compiler->mode32 = 0; in sljit_emit_op1()
1310 return emit_mov(compiler, dst, dstw, src, srcw); in sljit_emit_op1()
1328 FAIL_IF(emit_mov(compiler, dst, dstw, src, srcw)); in sljit_emit_op1()
1331 FAIL_IF(emit_mov_byte(compiler, 0, dst, dstw, src, srcw)); in sljit_emit_op1()
1334 FAIL_IF(emit_mov_byte(compiler, 1, dst, dstw, src, srcw)); in sljit_emit_op1()
1337 FAIL_IF(emit_mov_half(compiler, 0, dst, dstw, src, srcw)); in sljit_emit_op1()
1340 FAIL_IF(emit_mov_half(compiler, 1, dst, dstw, src, srcw)); in sljit_emit_op1()
1344 FAIL_IF(emit_mov_int(compiler, 0, dst, dstw, src, srcw)); in sljit_emit_op1()
1347 FAIL_IF(emit_mov_int(compiler, 1, dst, dstw, src, srcw)); in sljit_emit_op1()
1354 return emit_mov(compiler, SLJIT_MEM1(SLJIT_SP), dstw, TMP_REG1, 0); in sljit_emit_op1()
1362 return emit_not_with_flags(compiler, dst, dstw, src, srcw); in sljit_emit_op1()
1363 return emit_unary(compiler, NOT_rm, dst, dstw, src, srcw); in sljit_emit_op1()
1366 return emit_unary(compiler, NEG_rm, dst, dstw, src, srcw); in sljit_emit_op1()
1369 return emit_clz(compiler, op_flags, dst, dstw, src, srcw); in sljit_emit_op1()
1378 if (IS_HALFWORD(immw) || compiler->mode32) { \
1379 inst = emit_x86_instruction(compiler, 1 | EX86_BIN_INS, SLJIT_IMM, immw, arg, argw); \
1384 FAIL_IF(emit_load_imm64(compiler, (arg == TMP_REG1) ? TMP_REG2 : TMP_REG1, immw)); \
1385 inst = emit_x86_instruction(compiler, 1, (arg == TMP_REG1) ? TMP_REG2 : TMP_REG1, 0, arg, argw); \
1391 FAIL_IF(emit_do_imm32(compiler, (!compiler->mode32) ? REX_W : 0, (op_eax_imm), immw))
1396 inst = emit_x86_instruction(compiler, 1 | EX86_BIN_INS, SLJIT_IMM, immw, arg, argw); \
1401 FAIL_IF(emit_do_imm(compiler, (op_eax_imm), immw))
1405 static sljit_s32 emit_cum_binary(struct sljit_compiler *compiler, argument
1418 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
1423 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src2, src2w);
1433 …if ((dst == SLJIT_R0) && (src2w > 127 || src2w < -128) && (compiler->mode32 || IS_HALFWORD(src2w))…
1444 inst = emit_x86_instruction(compiler, 1, dst, dstw, src2, src2w);
1450 inst = emit_x86_instruction(compiler, 1, src2, src2w, dst, dstw);
1455 EMIT_MOV(compiler, TMP_REG1, 0, src2, src2w);
1456 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, dst, dstw);
1467 …if ((dst == SLJIT_R0) && (src1w > 127 || src1w < -128) && (compiler->mode32 || IS_HALFWORD(src1w))…
1478 inst = emit_x86_instruction(compiler, 1, dst, dstw, src1, src1w);
1483 inst = emit_x86_instruction(compiler, 1, src1, src1w, dst, dstw);
1488 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
1489 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, dst, dstw);
1498 EMIT_MOV(compiler, dst, 0, src1, src1w);
1503 inst = emit_x86_instruction(compiler, 1, dst, 0, src2, src2w);
1510 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
1515 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src2, src2w);
1519 EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0);
1525 static sljit_s32 emit_non_cum_binary(struct sljit_compiler *compiler, argument
1538 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
1543 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src2, src2w);
1553 …if ((dst == SLJIT_R0) && (src2w > 127 || src2w < -128) && (compiler->mode32 || IS_HALFWORD(src2w))…
1564 inst = emit_x86_instruction(compiler, 1, dst, dstw, src2, src2w);
1569 inst = emit_x86_instruction(compiler, 1, src2, src2w, dst, dstw);
1574 EMIT_MOV(compiler, TMP_REG1, 0, src2, src2w);
1575 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, dst, dstw);
1584 EMIT_MOV(compiler, dst, 0, src1, src1w);
1589 inst = emit_x86_instruction(compiler, 1, dst, 0, src2, src2w);
1596 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
1601 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src2, src2w);
1605 EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0);
1611 static sljit_s32 emit_mul(struct sljit_compiler *compiler, argument
1623 inst = emit_x86_instruction(compiler, 2, dst_r, 0, src2, src2w);
1629 inst = emit_x86_instruction(compiler, 2, dst_r, 0, src1, src1w);
1636 EMIT_MOV(compiler, dst_r, 0, SLJIT_IMM, src2w);
1642 inst = emit_x86_instruction(compiler, 1, dst_r, 0, src2, src2w);
1645 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1);
1652 inst = emit_x86_instruction(compiler, 1, dst_r, 0, src2, src2w);
1655 inst = (sljit_u8*)ensure_buf(compiler, 1 + 4);
1662 inst = emit_x86_instruction(compiler, 1, dst_r, 0, src2, src2w);
1665 inst = (sljit_u8*)ensure_buf(compiler, 1 + 4);
1672 EMIT_MOV(compiler, dst_r, 0, src2, src2w);
1673 FAIL_IF(emit_load_imm64(compiler, TMP_REG2, src1w));
1674 inst = emit_x86_instruction(compiler, 2, dst_r, 0, TMP_REG2, 0);
1685 inst = emit_x86_instruction(compiler, 1, dst_r, 0, src1, src1w);
1688 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1);
1695 inst = emit_x86_instruction(compiler, 1, dst_r, 0, src1, src1w);
1698 inst = (sljit_u8*)ensure_buf(compiler, 1 + 4);
1705 inst = emit_x86_instruction(compiler, 1, dst_r, 0, src1, src1w);
1708 inst = (sljit_u8*)ensure_buf(compiler, 1 + 4);
1715 EMIT_MOV(compiler, dst_r, 0, src1, src1w);
1716 FAIL_IF(emit_load_imm64(compiler, TMP_REG2, src2w));
1717 inst = emit_x86_instruction(compiler, 2, dst_r, 0, TMP_REG2, 0);
1728 EMIT_MOV(compiler, dst_r, 0, src1, src1w);
1729 inst = emit_x86_instruction(compiler, 2, dst_r, 0, src2, src2w);
1736 EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0);
1741 static sljit_s32 emit_lea_binary(struct sljit_compiler *compiler, argument
1759 inst = emit_x86_instruction(compiler, 1, dst_r, 0, SLJIT_MEM2(src1, src2), 0);
1765 if ((src2 & SLJIT_IMM) && (compiler->mode32 || IS_HALFWORD(src2w))) {
1766 inst = emit_x86_instruction(compiler, 1, dst_r, 0, SLJIT_MEM1(src1), (sljit_s32)src2w);
1769 inst = emit_x86_instruction(compiler, 1, dst_r, 0, SLJIT_MEM1(src1), src2w);
1778 if ((src1 & SLJIT_IMM) && (compiler->mode32 || IS_HALFWORD(src1w))) {
1779 inst = emit_x86_instruction(compiler, 1, dst_r, 0, SLJIT_MEM1(src2), (sljit_s32)src1w);
1782 inst = emit_x86_instruction(compiler, 1, dst_r, 0, SLJIT_MEM1(src2), src1w);
1792 return emit_mov(compiler, dst, dstw, TMP_REG1, 0);
1798 static sljit_s32 emit_cmp_binary(struct sljit_compiler *compiler, argument
1805 …if (src1 == SLJIT_R0 && (src2 & SLJIT_IMM) && (src2w > 127 || src2w < -128) && (compiler->mode32 |…
1818 inst = emit_x86_instruction(compiler, 1, src1, 0, src2, src2w);
1826 inst = emit_x86_instruction(compiler, 1, src2, 0, src1, src1w);
1834 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
1841 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
1842 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src2, src2w);
1849 static sljit_s32 emit_test_binary(struct sljit_compiler *compiler, argument
1856 …if (src1 == SLJIT_R0 && (src2 & SLJIT_IMM) && (src2w > 127 || src2w < -128) && (compiler->mode32 |…
1865 …if (src2 == SLJIT_R0 && (src1 & SLJIT_IMM) && (src1w > 127 || src1w < -128) && (compiler->mode32 |…
1876 if (IS_HALFWORD(src2w) || compiler->mode32) {
1877 inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src2w, src1, src1w);
1882 FAIL_IF(emit_load_imm64(compiler, TMP_REG1, src2w));
1883 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src1, src1w);
1888 inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src2w, src1, src1w);
1895 inst = emit_x86_instruction(compiler, 1, src1, 0, src2, src2w);
1905 if (IS_HALFWORD(src1w) || compiler->mode32) {
1906 inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src1w, src2, src2w);
1911 FAIL_IF(emit_load_imm64(compiler, TMP_REG1, src1w));
1912 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src2, src2w);
1917 inst = emit_x86_instruction(compiler, 1, src1, src1w, src2, src2w);
1924 inst = emit_x86_instruction(compiler, 1, src2, 0, src1, src1w);
1931 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
1934 if (IS_HALFWORD(src2w) || compiler->mode32) {
1935 inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src2w, TMP_REG1, 0);
1940 FAIL_IF(emit_load_imm64(compiler, TMP_REG2, src2w));
1941 inst = emit_x86_instruction(compiler, 1, TMP_REG2, 0, TMP_REG1, 0);
1946 inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src2w, TMP_REG1, 0);
1952 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src2, src2w);
1959 static sljit_s32 emit_shift(struct sljit_compiler *compiler, argument
1969 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, src2, src2w, dst, dstw);
1975 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
1976 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, src2, src2w, TMP_REG1, 0);
1982 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
1983 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
1986 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
1990 EMIT_MOV(compiler, dst, 0, src1, src1w);
1991 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, src2, src2w, dst, 0);
1997 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
1998 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, src2, src2w, TMP_REG1, 0);
2001 EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0);
2006 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
2007 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, src2, src2w);
2008 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
2011 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
2015 EMIT_MOV(compiler, dst, 0, src1, src1w);
2016 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_PREF_SHIFT_REG, 0);
2017 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, src2, src2w);
2018 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_PREF_SHIFT_REG, 0, dst, 0);
2021 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
2026 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
2028 EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), 0, SLJIT_PREF_SHIFT_REG, 0);
2029 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, src2, src2w);
2030 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
2033 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, SLJIT_MEM1(SLJIT_SP), 0);
2035 EMIT_MOV(compiler, TMP_REG2, 0, SLJIT_PREF_SHIFT_REG, 0);
2036 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, src2, src2w);
2037 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
2040 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, TMP_REG2, 0);
2043 return emit_mov(compiler, dst, dstw, TMP_REG1, 0);
2049 static sljit_s32 emit_shift_with_flags(struct sljit_compiler *compiler, argument
2058 if ((src2w & 0x3f) != 0 || (compiler->mode32 && (src2w & 0x1f) != 0))
2059 return emit_shift(compiler, mode, dst, dstw, src1, src1w, src2, src2w);
2062 return emit_shift(compiler, mode, dst, dstw, src1, src1w, src2, src2w);
2065 return emit_mov(compiler, dst, dstw, src1, src1w);
2067 return emit_cum_binary(compiler, BINARY_OPCODE(OR),
2072 return emit_shift(compiler, mode, dst, dstw, src1, src1w, src2, src2w);
2075 FAIL_IF(emit_cmp_binary(compiler, src1, src1w, SLJIT_IMM, 0));
2077 FAIL_IF(emit_shift(compiler, mode, dst, dstw, src1, src1w, src2, src2w));
2080 return emit_cmp_binary(compiler, (dst == SLJIT_UNUSED) ? TMP_REG1 : dst, dstw, SLJIT_IMM, 0);
2084 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op2(struct sljit_compiler *compiler, sljit_s32 op, argument
2090 CHECK(check_sljit_emit_op2(compiler, op, dst, dstw, src1, src1w, src2, src2w));
2099 compiler->mode32 = op & SLJIT_I32_OP;
2108 if (emit_lea_binary(compiler, dst, dstw, src1, src1w, src2, src2w) != SLJIT_ERR_UNSUPPORTED)
2109 return compiler->error;
2111 return emit_cum_binary(compiler, BINARY_OPCODE(ADD),
2114 return emit_cum_binary(compiler, BINARY_OPCODE(ADC),
2118 …if ((src2 & SLJIT_IMM) && emit_lea_binary(compiler, dst, dstw, src1, src1w, SLJIT_IMM, -src2w) != …
2119 return compiler->error;
2123 return emit_cmp_binary(compiler, src1, src1w, src2, src2w);
2124 return emit_non_cum_binary(compiler, BINARY_OPCODE(SUB),
2127 return emit_non_cum_binary(compiler, BINARY_OPCODE(SBB),
2130 return emit_mul(compiler, dst, dstw, src1, src1w, src2, src2w);
2133 return emit_test_binary(compiler, src1, src1w, src2, src2w);
2134 return emit_cum_binary(compiler, BINARY_OPCODE(AND),
2137 return emit_cum_binary(compiler, BINARY_OPCODE(OR),
2140 return emit_cum_binary(compiler, BINARY_OPCODE(XOR),
2143 return emit_shift_with_flags(compiler, SHL, HAS_FLAGS(op),
2146 return emit_shift_with_flags(compiler, SHR, HAS_FLAGS(op),
2149 return emit_shift_with_flags(compiler, SAR, HAS_FLAGS(op),
2176 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op_custom(struct sljit_compiler *compiler, argument
2182 CHECK(check_sljit_emit_op_custom(compiler, instruction, size));
2184 inst = (sljit_u8*)ensure_buf(compiler, 1 + size);
2214 static sljit_s32 emit_sse2(struct sljit_compiler *compiler, sljit_u8 opcode, argument
2219 …inst = emit_x86_instruction(compiler, 2 | (single ? EX86_PREF_F3 : EX86_PREF_F2) | EX86_SSE2, xmm1…
2226 static sljit_s32 emit_sse2_logic(struct sljit_compiler *compiler, sljit_u8 opcode, argument
2231 …inst = emit_x86_instruction(compiler, 2 | (pref66 ? EX86_PREF_66 : 0) | EX86_SSE2, xmm1, 0, xmm2, …
2238 static SLJIT_INLINE sljit_s32 emit_sse2_load(struct sljit_compiler *compiler, argument
2241 return emit_sse2(compiler, MOVSD_x_xm, single, dst, src, srcw);
2244 static SLJIT_INLINE sljit_s32 emit_sse2_store(struct sljit_compiler *compiler, argument
2247 return emit_sse2(compiler, MOVSD_xm_x, single, src, dst, dstw);
2250 static SLJIT_INLINE sljit_s32 sljit_emit_fop1_conv_sw_from_f64(struct sljit_compiler *compiler, slj… argument
2259 compiler->mode32 = 0;
2262 …inst = emit_x86_instruction(compiler, 2 | ((op & SLJIT_F32_OP) ? EX86_PREF_F3 : EX86_PREF_F2) | EX…
2268 return emit_mov(compiler, dst, dstw, TMP_REG1, 0);
2272 static SLJIT_INLINE sljit_s32 sljit_emit_fop1_conv_f64_from_sw(struct sljit_compiler *compiler, slj… argument
2281 compiler->mode32 = 0;
2289 EMIT_MOV(compiler, TMP_REG1, 0, src, srcw);
2294 …inst = emit_x86_instruction(compiler, 2 | ((op & SLJIT_F32_OP) ? EX86_PREF_F3 : EX86_PREF_F2) | EX…
2300 compiler->mode32 = 1;
2303 return emit_sse2_store(compiler, op & SLJIT_F32_OP, dst, dstw, TMP_FREG);
2307 static SLJIT_INLINE sljit_s32 sljit_emit_fop1_cmp(struct sljit_compiler *compiler, sljit_s32 op, argument
2312 FAIL_IF(emit_sse2_load(compiler, op & SLJIT_F32_OP, TMP_FREG, src1, src1w));
2316 return emit_sse2_logic(compiler, UCOMISD_x_xm, !(op & SLJIT_F32_OP), src1, src2, src2w);
2319 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_fop1(struct sljit_compiler *compiler, sljit_s32 op, argument
2326 compiler->mode32 = 1;
2330 SELECT_FOP1_OPERATION_WITH_CHECKS(compiler, op, dst, dstw, src, srcw);
2334 return emit_sse2_load(compiler, op & SLJIT_F32_OP, dst, src, srcw);
2336 return emit_sse2_store(compiler, op & SLJIT_F32_OP, dst, dstw, src);
2337 FAIL_IF(emit_sse2_load(compiler, op & SLJIT_F32_OP, TMP_FREG, src, srcw));
2338 return emit_sse2_store(compiler, op & SLJIT_F32_OP, dst, dstw, TMP_FREG);
2347 FAIL_IF(emit_sse2_logic(compiler, UNPCKLPD_x_xm, op & SLJIT_F32_OP, src, src, 0));
2350 FAIL_IF(emit_sse2_load(compiler, !(op & SLJIT_F32_OP), TMP_FREG, src, srcw));
2354 FAIL_IF(emit_sse2_logic(compiler, CVTPD2PS_x_xm, op & SLJIT_F32_OP, dst_r, src, 0));
2356 return emit_sse2_store(compiler, op & SLJIT_F32_OP, dst, dstw, TMP_FREG);
2363 FAIL_IF(emit_sse2_load(compiler, op & SLJIT_F32_OP, dst_r, src, srcw));
2367 FAIL_IF(emit_sse2_load(compiler, op & SLJIT_F32_OP, dst_r, src, srcw));
2372 …FAIL_IF(emit_sse2_logic(compiler, XORPD_x_xm, 1, dst_r, SLJIT_MEM0(), (sljit_sw)(op & SLJIT_F32_OP…
2376 …FAIL_IF(emit_sse2_logic(compiler, ANDPD_x_xm, 1, dst_r, SLJIT_MEM0(), (sljit_sw)(op & SLJIT_F32_OP…
2381 return emit_sse2_store(compiler, op & SLJIT_F32_OP, dst, dstw, TMP_FREG);
2385 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_fop2(struct sljit_compiler *compiler, sljit_s32 op, argument
2393 CHECK(check_sljit_emit_fop2(compiler, op, dst, dstw, src1, src1w, src2, src2w));
2399 compiler->mode32 = 1;
2412 FAIL_IF(emit_sse2_load(compiler, op & SLJIT_F32_OP, dst_r, src1, src1w));
2415 FAIL_IF(emit_sse2_load(compiler, op & SLJIT_F32_OP, TMP_FREG, src1, src1w));
2420 FAIL_IF(emit_sse2_load(compiler, op & SLJIT_F32_OP, TMP_FREG, src1, src1w));
2425 FAIL_IF(emit_sse2(compiler, ADDSD_x_xm, op & SLJIT_F32_OP, dst_r, src2, src2w));
2429 FAIL_IF(emit_sse2(compiler, SUBSD_x_xm, op & SLJIT_F32_OP, dst_r, src2, src2w));
2433 FAIL_IF(emit_sse2(compiler, MULSD_x_xm, op & SLJIT_F32_OP, dst_r, src2, src2w));
2437 FAIL_IF(emit_sse2(compiler, DIVSD_x_xm, op & SLJIT_F32_OP, dst_r, src2, src2w));
2442 return emit_sse2_store(compiler, op & SLJIT_F32_OP, dst, dstw, TMP_FREG);
2450 SLJIT_API_FUNC_ATTRIBUTE struct sljit_label* sljit_emit_label(struct sljit_compiler *compiler) argument
2456 CHECK_PTR(check_sljit_emit_label(compiler));
2458 if (compiler->last_label && compiler->last_label->size == compiler->size)
2459 return compiler->last_label;
2461 label = (struct sljit_label*)ensure_abuf(compiler, sizeof(struct sljit_label));
2463 set_label(label, compiler);
2465 inst = (sljit_u8*)ensure_buf(compiler, 2);
2474 SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_jump(struct sljit_compiler *compiler, sljit_… argument
2480 CHECK_PTR(check_sljit_emit_jump(compiler, type));
2482 jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sljit_jump));
2484 set_jump(jump, compiler, type & SLJIT_REWRITABLE_JUMP);
2489 compiler->size += (type >= SLJIT_JUMP) ? 5 : 6;
2491 compiler->size += (type >= SLJIT_JUMP) ? (10 + 3) : (2 + 10 + 3);
2494 inst = (sljit_u8*)ensure_buf(compiler, 2);
2502 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_ijump(struct sljit_compiler *compiler, sljit_s32 type… argument
2508 CHECK(check_sljit_emit_ijump(compiler, type, src, srcw));
2514 jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sljit_jump));
2516 set_jump(jump, compiler, JUMP_ADDR);
2521 compiler->size += 5;
2523 compiler->size += 10 + 3;
2526 inst = (sljit_u8*)ensure_buf(compiler, 2);
2535 compiler->mode32 = 1;
2537 inst = emit_x86_instruction(compiler, 1, 0, 0, src, srcw);
2545 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op_flags(struct sljit_compiler *compiler, sljit_s32 o… argument
2559 CHECK(check_sljit_emit_op_flags(compiler, op, dst, dstw, type));
2570 inst = (sljit_u8*)ensure_buf(compiler, 1 + 4 + 3);
2586 inst = (sljit_u8*)ensure_buf(compiler, 1 + 4 + 4);
2604 compiler->mode32 = GET_OPCODE(op) != SLJIT_MOV;
2605 return emit_mov(compiler, dst, dstw, TMP_REG1, 0);
2610 compiler->skip_checks = 1;
2612 return sljit_emit_op2(compiler, op, dst_save, dstw_save, dst_save, dstw_save, TMP_REG1, 0);
2619 inst = (sljit_u8*)ensure_buf(compiler, 1 + 3 + 3);
2638 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_IMM, 1);
2640 EMIT_MOV(compiler, dst, 0, SLJIT_IMM, 0);
2642 inst = (sljit_u8*)ensure_buf(compiler, 1 + 3);
2653 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1 + 3 + 3 + 1);
2673 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1 + 3 + 2 + 1);
2686 inst = (sljit_u8*)ensure_buf(compiler, 1 + 2 + 3 + 2 + 2);
2704 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1 + 3 + 3 + 1);
2720 return emit_mov(compiler, dst, dstw, TMP_REG1, 0);
2724 compiler->skip_checks = 1;
2726 return sljit_emit_op2(compiler, op, dst_save, dstw_save, dst_save, dstw_save, TMP_REG1, 0);
2730 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_cmov(struct sljit_compiler *compiler, sljit_s32 type, argument
2737 CHECK(check_sljit_emit_cmov(compiler, type, dst_reg, src, srcw));
2743 return sljit_emit_cmov_generic(compiler, type, dst_reg, src, srcw);
2746 return sljit_emit_cmov_generic(compiler, type, dst_reg, src, srcw);
2753 compiler->mode32 = dst_reg & SLJIT_I32_OP;
2758 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_IMM, srcw);
2763 inst = emit_x86_instruction(compiler, 2, dst_reg, 0, src, srcw);
2770 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_get_local_base(struct sljit_compiler *compiler, sljit_s32 … argument
2773 CHECK(check_sljit_get_local_base(compiler, dst, dstw, offset));
2779 compiler->mode32 = 0;
2786 FAIL_IF(emit_load_imm64(compiler, TMP_REG1, offset));
2788 …SLJIT_ASSERT(emit_lea_binary(compiler, dst, dstw, SLJIT_SP, 0, TMP_REG1, 0) != SLJIT_ERR_UNSUPPORT…
2789 return compiler->error;
2791 return emit_lea_binary(compiler, dst, dstw, SLJIT_SP, 0, TMP_REG1, 0);
2797 return emit_lea_binary(compiler, dst, dstw, SLJIT_SP, 0, SLJIT_IMM, offset);
2798 return emit_mov(compiler, dst, dstw, SLJIT_SP, 0);
2801 SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compiler *compiler, slji… argument
2810 CHECK_PTR(check_sljit_emit_const(compiler, dst, dstw, init_value));
2815 const_ = (struct sljit_const*)ensure_abuf(compiler, sizeof(struct sljit_const));
2817 set_const(const_, compiler);
2820 compiler->mode32 = 0;
2823 if (emit_load_imm64(compiler, reg, init_value))
2826 if (emit_mov(compiler, dst, dstw, SLJIT_IMM, init_value))
2830 inst = (sljit_u8*)ensure_buf(compiler, 2);
2838 if (emit_mov(compiler, dst, dstw, TMP_REG1, 0))