Lines Matching refs:compiler

81 		if (p <= compiler->scratches) \
82 w = compiler->scratches_offset + ((p) - SLJIT_R3) * SSIZE_OF(sw); \
84 w = compiler->locals_offset + ((p) - SLJIT_S2) * SSIZE_OF(sw); \
283 #define INC_SIZE(s) (*inst++ = U8(s), compiler->size += (s))
492 SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compiler) in sljit_generate_code() argument
509 CHECK_PTR(check_sljit_generate_code(compiler)); in sljit_generate_code()
510 reverse_buf(compiler); in sljit_generate_code()
513 code = (sljit_u8*)SLJIT_MALLOC_EXEC(compiler->size, compiler->exec_allocator_data); in sljit_generate_code()
515 buf = compiler->buf; in sljit_generate_code()
518 label = compiler->labels; in sljit_generate_code()
519 jump = compiler->jumps; in sljit_generate_code()
520 const_ = compiler->consts; in sljit_generate_code()
521 put_label = compiler->put_labels; in sljit_generate_code()
580 SLJIT_ASSERT(code_ptr <= code + compiler->size); in sljit_generate_code()
582 jump = compiler->jumps; in sljit_generate_code()
615 put_label = compiler->put_labels; in sljit_generate_code()
633 compiler->error = SLJIT_ERR_COMPILED; in sljit_generate_code()
634 compiler->executable_offset = executable_offset; in sljit_generate_code()
635 compiler->executable_size = (sljit_uw)(code_ptr - code); in sljit_generate_code()
693 inst = emit_x86_instruction(compiler, 1 | EX86_BIN_INS, SLJIT_IMM, immw, arg, argw); \
702 if (IS_HALFWORD(immw) || compiler->mode32) { \
706 FAIL_IF(emit_load_imm64(compiler, (arg == TMP_REG1) ? TMP_REG2 : TMP_REG1, immw)); \
707 … inst = emit_x86_instruction(compiler, 1, (arg == TMP_REG1) ? TMP_REG2 : TMP_REG1, 0, arg, argw); \
714 FAIL_IF(emit_do_imm32(compiler, (!compiler->mode32) ? REX_W : 0, (op_eax_imm), immw))
722 FAIL_IF(emit_do_imm(compiler, (op_eax_imm), immw))
726 static sljit_s32 emit_mov(struct sljit_compiler *compiler,
730 #define EMIT_MOV(compiler, dst, dstw, src, srcw) \ argument
731 FAIL_IF(emit_mov(compiler, dst, dstw, src, srcw));
733 static SLJIT_INLINE sljit_s32 emit_sse2_store(struct sljit_compiler *compiler,
736 static SLJIT_INLINE sljit_s32 emit_sse2_load(struct sljit_compiler *compiler,
739 static sljit_s32 emit_cmp_binary(struct sljit_compiler *compiler,
743 static SLJIT_INLINE sljit_s32 emit_endbranch(struct sljit_compiler *compiler) in emit_endbranch() argument
748 inst = (sljit_u8*)ensure_buf(compiler, 1 + 4); in emit_endbranch()
760 SLJIT_UNUSED_ARG(compiler); in emit_endbranch()
767 static SLJIT_INLINE sljit_s32 emit_rdssp(struct sljit_compiler *compiler, sljit_s32 reg) in emit_rdssp() argument
778 inst = (sljit_u8*)ensure_buf(compiler, 1 + size); in emit_rdssp()
791 static SLJIT_INLINE sljit_s32 emit_incssp(struct sljit_compiler *compiler, sljit_s32 reg) in emit_incssp() argument
802 inst = (sljit_u8*)ensure_buf(compiler, 1 + size); in emit_incssp()
826 static SLJIT_INLINE sljit_s32 adjust_shadow_stack(struct sljit_compiler *compiler, in adjust_shadow_stack() argument
833 sljit_uw size_before_rdssp_inst = compiler->size; in adjust_shadow_stack()
836 FAIL_IF(emit_rdssp(compiler, TMP_REG1)); in adjust_shadow_stack()
843 inst = (sljit_u8*)ensure_buf(compiler, 1 + 3); in adjust_shadow_stack()
850 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_MEM1(TMP_REG1), 0); in adjust_shadow_stack()
854 FAIL_IF(emit_cmp_binary (compiler, TMP_REG1, 0, src, srcw)); in adjust_shadow_stack()
858 inst = (sljit_u8*)ensure_buf(compiler, 1 + 2); in adjust_shadow_stack()
862 size_jz_after_cmp_inst = compiler->size; in adjust_shadow_stack()
867 compiler->mode32 = 1; in adjust_shadow_stack()
870 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_IMM, 1); in adjust_shadow_stack()
873 FAIL_IF(emit_incssp(compiler, TMP_REG1)); in adjust_shadow_stack()
876 inst = (sljit_u8*)ensure_buf(compiler, 1 + 2); in adjust_shadow_stack()
880 *inst = size_before_rdssp_inst - compiler->size; in adjust_shadow_stack()
882 *jz_after_cmp_inst = compiler->size - size_jz_after_cmp_inst; in adjust_shadow_stack()
884 SLJIT_UNUSED_ARG(compiler); in adjust_shadow_stack()
897 static sljit_s32 emit_mov(struct sljit_compiler *compiler, in emit_mov() argument
904 inst = emit_x86_instruction(compiler, 1, src, 0, dst, dstw); in emit_mov()
912 return emit_do_imm(compiler, MOV_r_i32 | reg_map[dst], srcw); in emit_mov()
914 if (!compiler->mode32) { in emit_mov()
916 return emit_load_imm64(compiler, dst, srcw); in emit_mov()
919 …return emit_do_imm32(compiler, (reg_map[dst] >= 8) ? REX_B : 0, U8(MOV_r_i32 | reg_lmap[dst]), src… in emit_mov()
923 if (!compiler->mode32 && NOT_HALFWORD(srcw)) { in emit_mov()
926 FAIL_IF(emit_load_imm64(compiler, TMP_REG1, srcw)); in emit_mov()
927 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, dst, dstw); in emit_mov()
933 inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, srcw, dst, dstw); in emit_mov()
939 inst = emit_x86_instruction(compiler, 1, dst, 0, src, srcw); in emit_mov()
947 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src, srcw); in emit_mov()
950 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, dst, dstw); in emit_mov()
956 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op0(struct sljit_compiler *compiler, sljit_s32 op) in sljit_emit_op0() argument
964 CHECK(check_sljit_emit_op0(compiler, op)); in sljit_emit_op0()
968 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1); in sljit_emit_op0()
974 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1); in sljit_emit_op0()
997 compiler->mode32 = op & SLJIT_32; in sljit_emit_op0()
1004 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_R1, 0); in sljit_emit_op0()
1005 inst = emit_x86_instruction(compiler, 1, SLJIT_R1, 0, SLJIT_R1, 0); in sljit_emit_op0()
1007 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, TMP_REG1, 0); in sljit_emit_op0()
1015 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_R1, 0); in sljit_emit_op0()
1019 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1); in sljit_emit_op0()
1024 if (compiler->mode32) { in sljit_emit_op0()
1025 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1); in sljit_emit_op0()
1030 inst = (sljit_u8*)ensure_buf(compiler, 1 + 2); in sljit_emit_op0()
1040 inst = (sljit_u8*)ensure_buf(compiler, 1 + 2); in sljit_emit_op0()
1047 size = (!compiler->mode32 || op >= SLJIT_DIVMOD_UW) ? 3 : 2; in sljit_emit_op0()
1049 size = (!compiler->mode32) ? 3 : 2; in sljit_emit_op0()
1051 inst = (sljit_u8*)ensure_buf(compiler, 1 + size); in sljit_emit_op0()
1055 if (!compiler->mode32) in sljit_emit_op0()
1062 if (!compiler->mode32) in sljit_emit_op0()
1086 EMIT_MOV(compiler, SLJIT_R1, 0, TMP_REG1, 0); in sljit_emit_op0()
1089 EMIT_MOV(compiler, SLJIT_R1, 0, TMP_REG1, 0); in sljit_emit_op0()
1093 return emit_endbranch(compiler); in sljit_emit_op0()
1095 return skip_frames_before_return(compiler); in sljit_emit_op0()
1103 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1); \
1109 static sljit_s32 emit_mov_byte(struct sljit_compiler *compiler, sljit_s32 sign, in emit_mov_byte() argument
1120 compiler->mode32 = 0; in emit_mov_byte()
1126 return emit_do_imm(compiler, MOV_r_i32 | reg_map[dst], srcw); in emit_mov_byte()
1128 inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, srcw, dst, 0); in emit_mov_byte()
1134 …inst = emit_x86_instruction(compiler, 1 | EX86_BYTE_ARG | EX86_NO_REXW, SLJIT_IMM, srcw, dst, dstw… in emit_mov_byte()
1146 EMIT_MOV(compiler, TMP_REG1, 0, src, 0); in emit_mov_byte()
1159 EMIT_MOV(compiler, dst, 0, src, 0); in emit_mov_byte()
1160 inst = emit_x86_instruction(compiler, 2, dst, 0, dst, 0); in emit_mov_byte()
1167 EMIT_MOV(compiler, dst, 0, src, 0); in emit_mov_byte()
1170 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_IMM, 24, dst, 0); in emit_mov_byte()
1174 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_IMM, 24, dst, 0); in emit_mov_byte()
1179 inst = emit_x86_instruction(compiler, 1 | EX86_BIN_INS, SLJIT_IMM, 0xff, dst, 0); in emit_mov_byte()
1189 inst = emit_x86_instruction(compiler, 2, dst_r, 0, src, srcw); in emit_mov_byte()
1218 inst = emit_x86_instruction(compiler, 1, work_r, 0, dst_r, 0); in emit_mov_byte()
1223 inst = emit_x86_instruction(compiler, 1, work_r, 0, dst, dstw); in emit_mov_byte()
1231 inst = emit_x86_instruction(compiler, 1, work_r, 0, dst_r, 0); in emit_mov_byte()
1237 inst = emit_x86_instruction(compiler, 1, dst_r, 0, dst, dstw); in emit_mov_byte()
1242 inst = emit_x86_instruction(compiler, 1 | EX86_REX | EX86_NO_REXW, dst_r, 0, dst, dstw); in emit_mov_byte()
1251 static sljit_s32 emit_prefetch(struct sljit_compiler *compiler, sljit_s32 op, in emit_prefetch() argument
1257 compiler->mode32 = 1; in emit_prefetch()
1260 inst = emit_x86_instruction(compiler, 2, 0, 0, src, srcw); in emit_prefetch()
1275 static sljit_s32 emit_mov_half(struct sljit_compiler *compiler, sljit_s32 sign, in emit_mov_half() argument
1283 compiler->mode32 = 0; in emit_mov_half()
1289 return emit_do_imm(compiler, MOV_r_i32 | reg_map[dst], srcw); in emit_mov_half()
1291 inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, srcw, dst, 0); in emit_mov_half()
1297 …inst = emit_x86_instruction(compiler, 1 | EX86_HALF_ARG | EX86_NO_REXW | EX86_PREF_66, SLJIT_IMM, … in emit_mov_half()
1308 inst = emit_x86_instruction(compiler, 2, dst_r, 0, src, srcw); in emit_mov_half()
1315 inst = emit_x86_instruction(compiler, 1 | EX86_NO_REXW | EX86_PREF_66, dst_r, 0, dst, dstw); in emit_mov_half()
1323 static sljit_s32 emit_unary(struct sljit_compiler *compiler, sljit_u8 opcode, in emit_unary() argument
1331 inst = emit_x86_instruction(compiler, 1, 0, 0, dst, dstw); in emit_unary()
1339 EMIT_MOV(compiler, dst, 0, src, srcw); in emit_unary()
1340 inst = emit_x86_instruction(compiler, 1, 0, 0, dst, 0); in emit_unary()
1347 EMIT_MOV(compiler, TMP_REG1, 0, src, srcw); in emit_unary()
1348 inst = emit_x86_instruction(compiler, 1, 0, 0, TMP_REG1, 0); in emit_unary()
1352 EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0); in emit_unary()
1356 static sljit_s32 emit_not_with_flags(struct sljit_compiler *compiler, in emit_not_with_flags() argument
1363 EMIT_MOV(compiler, dst, 0, src, srcw); in emit_not_with_flags()
1364 inst = emit_x86_instruction(compiler, 1, 0, 0, dst, 0); in emit_not_with_flags()
1368 inst = emit_x86_instruction(compiler, 1, dst, 0, dst, 0); in emit_not_with_flags()
1374 EMIT_MOV(compiler, TMP_REG1, 0, src, srcw); in emit_not_with_flags()
1375 inst = emit_x86_instruction(compiler, 1, 0, 0, TMP_REG1, 0); in emit_not_with_flags()
1379 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, TMP_REG1, 0); in emit_not_with_flags()
1382 EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0); in emit_not_with_flags()
1390 static sljit_s32 emit_clz(struct sljit_compiler *compiler, sljit_s32 op_flags, in emit_clz() argument
1404 inst = emit_x86_instruction(compiler, 2, dst_r, 0, src, srcw); in emit_clz()
1412 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_IMM, 32 + 31); in emit_clz()
1413 inst = emit_x86_instruction(compiler, 2, dst_r, 0, TMP_REG1, 0); in emit_clz()
1416 inst = emit_x86_instruction(compiler, 2, dst_r, 0, SLJIT_MEM0(), (sljit_sw)&emit_clz_arg); in emit_clz()
1423 FAIL_IF(sljit_emit_cmov_generic(compiler, SLJIT_EQUAL, dst_r, SLJIT_IMM, 32 + 31)); in emit_clz()
1425 inst = emit_x86_instruction(compiler, 1 | EX86_BIN_INS, SLJIT_IMM, 31, dst_r, 0); in emit_clz()
1428 EMIT_MOV(compiler, TMP_REG2, 0, SLJIT_IMM, !(op_flags & SLJIT_32) ? (64 + 63) : (32 + 31)); in emit_clz()
1430 inst = emit_x86_instruction(compiler, 2, dst_r, 0, TMP_REG2, 0); in emit_clz()
1436 …FAIL_IF(sljit_emit_cmov_generic(compiler, SLJIT_EQUAL, dst_r, SLJIT_IMM, !(op_flags & SLJIT_32) ? … in emit_clz()
1438 …inst = emit_x86_instruction(compiler, 1 | EX86_BIN_INS, SLJIT_IMM, !(op_flags & SLJIT_32) ? 63 : 3… in emit_clz()
1445 EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0); in emit_clz()
1449 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op1(struct sljit_compiler *compiler, sljit_s32 op, in sljit_emit_op1() argument
1459 CHECK(check_sljit_emit_op1(compiler, op, dst, dstw, src, srcw)); in sljit_emit_op1()
1466 compiler->mode32 = op_flags & SLJIT_32; in sljit_emit_op1()
1473 compiler->mode32 = 0; in sljit_emit_op1()
1519 return emit_mov(compiler, dst, dstw, src, srcw); in sljit_emit_op1()
1538 EMIT_MOV(compiler, dst, dstw, src, srcw); in sljit_emit_op1()
1541 FAIL_IF(emit_mov_byte(compiler, 0, dst, dstw, src, srcw)); in sljit_emit_op1()
1544 FAIL_IF(emit_mov_byte(compiler, 1, dst, dstw, src, srcw)); in sljit_emit_op1()
1547 FAIL_IF(emit_mov_half(compiler, 0, dst, dstw, src, srcw)); in sljit_emit_op1()
1550 FAIL_IF(emit_mov_half(compiler, 1, dst, dstw, src, srcw)); in sljit_emit_op1()
1554 FAIL_IF(emit_mov_int(compiler, 0, dst, dstw, src, srcw)); in sljit_emit_op1()
1557 FAIL_IF(emit_mov_int(compiler, 1, dst, dstw, src, srcw)); in sljit_emit_op1()
1560 compiler->mode32 = 1; in sljit_emit_op1()
1561 EMIT_MOV(compiler, dst, dstw, src, srcw); in sljit_emit_op1()
1562 compiler->mode32 = 0; in sljit_emit_op1()
1569 return emit_mov(compiler, SLJIT_MEM1(SLJIT_SP), dstw, TMP_REG1, 0); in sljit_emit_op1()
1577 return emit_not_with_flags(compiler, dst, dstw, src, srcw); in sljit_emit_op1()
1578 return emit_unary(compiler, NOT_rm, dst, dstw, src, srcw); in sljit_emit_op1()
1581 return emit_clz(compiler, op_flags, dst, dstw, src, srcw); in sljit_emit_op1()
1587 static sljit_s32 emit_cum_binary(struct sljit_compiler *compiler, argument
1602 …if ((dst == SLJIT_R0) && (src2w > 127 || src2w < -128) && (compiler->mode32 || IS_HALFWORD(src2w))…
1613 inst = emit_x86_instruction(compiler, 1, dst, dstw, src2, src2w);
1619 inst = emit_x86_instruction(compiler, 1, src2, src2w, dst, dstw);
1624 EMIT_MOV(compiler, TMP_REG1, 0, src2, src2w);
1625 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, dst, dstw);
1636 …if ((dst == SLJIT_R0) && (src1w > 127 || src1w < -128) && (compiler->mode32 || IS_HALFWORD(src1w))…
1647 inst = emit_x86_instruction(compiler, 1, dst, dstw, src1, src1w);
1652 inst = emit_x86_instruction(compiler, 1, src1, src1w, dst, dstw);
1657 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
1658 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, dst, dstw);
1667 EMIT_MOV(compiler, dst, 0, src1, src1w);
1672 inst = emit_x86_instruction(compiler, 1, dst, 0, src2, src2w);
1679 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
1684 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src2, src2w);
1688 EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0);
1694 static sljit_s32 emit_non_cum_binary(struct sljit_compiler *compiler, argument
1709 …if ((dst == SLJIT_R0) && (src2w > 127 || src2w < -128) && (compiler->mode32 || IS_HALFWORD(src2w))…
1720 inst = emit_x86_instruction(compiler, 1, dst, dstw, src2, src2w);
1725 inst = emit_x86_instruction(compiler, 1, src2, src2w, dst, dstw);
1730 EMIT_MOV(compiler, TMP_REG1, 0, src2, src2w);
1731 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, dst, dstw);
1740 EMIT_MOV(compiler, dst, 0, src1, src1w);
1745 inst = emit_x86_instruction(compiler, 1, dst, 0, src2, src2w);
1752 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
1757 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src2, src2w);
1761 EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0);
1767 static sljit_s32 emit_mul(struct sljit_compiler *compiler, argument
1777 inst = emit_x86_instruction(compiler, 2, dst_r, 0, src2, src2w);
1783 inst = emit_x86_instruction(compiler, 2, dst_r, 0, src1, src1w);
1790 EMIT_MOV(compiler, dst_r, 0, SLJIT_IMM, src2w);
1796 inst = emit_x86_instruction(compiler, 1, dst_r, 0, src2, src2w);
1799 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1);
1806 inst = emit_x86_instruction(compiler, 1, dst_r, 0, src2, src2w);
1809 inst = (sljit_u8*)ensure_buf(compiler, 1 + 4);
1816 inst = emit_x86_instruction(compiler, 1, dst_r, 0, src2, src2w);
1819 inst = (sljit_u8*)ensure_buf(compiler, 1 + 4);
1826 EMIT_MOV(compiler, dst_r, 0, src2, src2w);
1827 FAIL_IF(emit_load_imm64(compiler, TMP_REG2, src1w));
1828 inst = emit_x86_instruction(compiler, 2, dst_r, 0, TMP_REG2, 0);
1839 inst = emit_x86_instruction(compiler, 1, dst_r, 0, src1, src1w);
1842 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1);
1849 inst = emit_x86_instruction(compiler, 1, dst_r, 0, src1, src1w);
1852 inst = (sljit_u8*)ensure_buf(compiler, 1 + 4);
1859 inst = emit_x86_instruction(compiler, 1, dst_r, 0, src1, src1w);
1862 inst = (sljit_u8*)ensure_buf(compiler, 1 + 4);
1869 EMIT_MOV(compiler, dst_r, 0, src1, src1w);
1870 FAIL_IF(emit_load_imm64(compiler, TMP_REG2, src2w));
1871 inst = emit_x86_instruction(compiler, 2, dst_r, 0, TMP_REG2, 0);
1882 EMIT_MOV(compiler, dst_r, 0, src1, src1w);
1883 inst = emit_x86_instruction(compiler, 2, dst_r, 0, src2, src2w);
1890 EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0);
1895 static sljit_s32 emit_lea_binary(struct sljit_compiler *compiler, argument
1913 inst = emit_x86_instruction(compiler, 1, dst_r, 0, SLJIT_MEM2(src1, src2), 0);
1919 if ((src2 & SLJIT_IMM) && (compiler->mode32 || IS_HALFWORD(src2w))) {
1920 inst = emit_x86_instruction(compiler, 1, dst_r, 0, SLJIT_MEM1(src1), (sljit_s32)src2w);
1923 inst = emit_x86_instruction(compiler, 1, dst_r, 0, SLJIT_MEM1(src1), src2w);
1932 if ((src1 & SLJIT_IMM) && (compiler->mode32 || IS_HALFWORD(src1w))) {
1933 inst = emit_x86_instruction(compiler, 1, dst_r, 0, SLJIT_MEM1(src2), (sljit_s32)src1w);
1936 inst = emit_x86_instruction(compiler, 1, dst_r, 0, SLJIT_MEM1(src2), src1w);
1946 return emit_mov(compiler, dst, dstw, TMP_REG1, 0);
1952 static sljit_s32 emit_cmp_binary(struct sljit_compiler *compiler, argument
1959 …if (src1 == SLJIT_R0 && (src2 & SLJIT_IMM) && (src2w > 127 || src2w < -128) && (compiler->mode32 |…
1972 inst = emit_x86_instruction(compiler, 1, src1, 0, src2, src2w);
1980 inst = emit_x86_instruction(compiler, 1, src2, 0, src1, src1w);
1988 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
1995 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
1996 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src2, src2w);
2003 static sljit_s32 emit_test_binary(struct sljit_compiler *compiler, argument
2010 …if (src1 == SLJIT_R0 && (src2 & SLJIT_IMM) && (src2w > 127 || src2w < -128) && (compiler->mode32 |…
2019 …if (src2 == SLJIT_R0 && (src1 & SLJIT_IMM) && (src1w > 127 || src1w < -128) && (compiler->mode32 |…
2030 if (IS_HALFWORD(src2w) || compiler->mode32) {
2031 inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src2w, src1, src1w);
2036 FAIL_IF(emit_load_imm64(compiler, TMP_REG1, src2w));
2037 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src1, src1w);
2042 inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src2w, src1, src1w);
2049 inst = emit_x86_instruction(compiler, 1, src1, 0, src2, src2w);
2059 if (IS_HALFWORD(src1w) || compiler->mode32) {
2060 inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src1w, src2, src2w);
2065 FAIL_IF(emit_load_imm64(compiler, TMP_REG1, src1w));
2066 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src2, src2w);
2071 inst = emit_x86_instruction(compiler, 1, src1, src1w, src2, src2w);
2078 inst = emit_x86_instruction(compiler, 1, src2, 0, src1, src1w);
2085 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
2088 if (IS_HALFWORD(src2w) || compiler->mode32) {
2089 inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src2w, TMP_REG1, 0);
2094 FAIL_IF(emit_load_imm64(compiler, TMP_REG2, src2w));
2095 inst = emit_x86_instruction(compiler, 1, TMP_REG2, 0, TMP_REG1, 0);
2100 inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src2w, TMP_REG1, 0);
2106 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src2, src2w);
2113 static sljit_s32 emit_shift(struct sljit_compiler *compiler, argument
2123 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, src2, src2w, dst, dstw);
2129 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
2130 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
2133 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
2137 EMIT_MOV(compiler, dst, 0, src1, src1w);
2138 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, src2, src2w, dst, 0);
2144 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
2145 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, src2, src2w, TMP_REG1, 0);
2148 EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0);
2153 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
2154 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, src2, src2w);
2155 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
2158 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
2162 EMIT_MOV(compiler, dst, 0, src1, src1w);
2163 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_PREF_SHIFT_REG, 0);
2164 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, src2, src2w);
2165 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_PREF_SHIFT_REG, 0, dst, 0);
2168 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
2173 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
2175 EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), 0, SLJIT_PREF_SHIFT_REG, 0);
2176 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, src2, src2w);
2177 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
2180 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, SLJIT_MEM1(SLJIT_SP), 0);
2182 EMIT_MOV(compiler, TMP_REG2, 0, SLJIT_PREF_SHIFT_REG, 0);
2183 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, src2, src2w);
2184 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
2187 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, TMP_REG2, 0);
2190 return emit_mov(compiler, dst, dstw, TMP_REG1, 0);
2196 static sljit_s32 emit_shift_with_flags(struct sljit_compiler *compiler, argument
2205 if ((src2w & 0x3f) != 0 || (compiler->mode32 && (src2w & 0x1f) != 0))
2206 return emit_shift(compiler, mode, dst, dstw, src1, src1w, src2, src2w);
2209 return emit_shift(compiler, mode, dst, dstw, src1, src1w, src2, src2w);
2212 return emit_mov(compiler, dst, dstw, src1, src1w);
2214 return emit_cum_binary(compiler, BINARY_OPCODE(OR),
2219 return emit_shift(compiler, mode, dst, dstw, src1, src1w, src2, src2w);
2222 FAIL_IF(emit_cmp_binary(compiler, src1, src1w, SLJIT_IMM, 0));
2224 FAIL_IF(emit_shift(compiler, mode, dst, dstw, src1, src1w, src2, src2w));
2227 return emit_cmp_binary(compiler, dst, dstw, SLJIT_IMM, 0);
2231 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op2(struct sljit_compiler *compiler, sljit_s32 op, argument
2237 CHECK(check_sljit_emit_op2(compiler, op, 0, dst, dstw, src1, src1w, src2, src2w));
2246 compiler->mode32 = op & SLJIT_32;
2254 if (emit_lea_binary(compiler, dst, dstw, src1, src1w, src2, src2w) != SLJIT_ERR_UNSUPPORTED)
2255 return compiler->error;
2257 return emit_cum_binary(compiler, BINARY_OPCODE(ADD),
2260 return emit_cum_binary(compiler, BINARY_OPCODE(ADC),
2264 return emit_unary(compiler, NEG_rm, dst, dstw, src2, src2w);
2267 …if ((src2 & SLJIT_IMM) && emit_lea_binary(compiler, dst, dstw, src1, src1w, SLJIT_IMM, -src2w) != …
2268 return compiler->error;
2270 FAIL_IF(emit_non_cum_binary(compiler, BINARY_OPCODE(SUB), dst, 0, dst, 0, src1, src1w));
2271 return emit_unary(compiler, NEG_rm, dst, 0, dst, 0);
2275 return emit_non_cum_binary(compiler, BINARY_OPCODE(SUB),
2278 return emit_non_cum_binary(compiler, BINARY_OPCODE(SBB),
2281 return emit_mul(compiler, dst, dstw, src1, src1w, src2, src2w);
2283 return emit_cum_binary(compiler, BINARY_OPCODE(AND),
2286 return emit_cum_binary(compiler, BINARY_OPCODE(OR),
2289 return emit_cum_binary(compiler, BINARY_OPCODE(XOR),
2292 return emit_shift_with_flags(compiler, SHL, HAS_FLAGS(op),
2295 return emit_shift_with_flags(compiler, SHR, HAS_FLAGS(op),
2298 return emit_shift_with_flags(compiler, SAR, HAS_FLAGS(op),
2305 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op2u(struct sljit_compiler *compiler, sljit_s32 op, argument
2312 CHECK(check_sljit_emit_op2(compiler, op, 1, 0, 0, src1, src1w, src2, src2w));
2317 compiler->skip_checks = 1;
2319 return sljit_emit_op2(compiler, op, TMP_REG1, 0, src1, src1w, src2, src2w);
2328 compiler->mode32 = op & SLJIT_32;
2332 return emit_cmp_binary(compiler, src1, src1w, src2, src2w);
2334 return emit_test_binary(compiler, src1, src1w, src2, src2w);
2337 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op_src(struct sljit_compiler *compiler, sljit_s32 op, argument
2341 CHECK(check_sljit_emit_op_src(compiler, op, src, srcw));
2348 return emit_fast_return(compiler, src, srcw);
2353 return adjust_shadow_stack(compiler, src, srcw);
2358 return emit_prefetch(compiler, op, src, srcw);
2384 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op_custom(struct sljit_compiler *compiler, argument
2390 CHECK(check_sljit_emit_op_custom(compiler, instruction, size));
2392 inst = (sljit_u8*)ensure_buf(compiler, 1 + size);
2422 static sljit_s32 emit_sse2(struct sljit_compiler *compiler, sljit_u8 opcode, argument
2427 …inst = emit_x86_instruction(compiler, 2 | (single ? EX86_PREF_F3 : EX86_PREF_F2) | EX86_SSE2, xmm1…
2434 static sljit_s32 emit_sse2_logic(struct sljit_compiler *compiler, sljit_u8 opcode, argument
2439 …inst = emit_x86_instruction(compiler, 2 | (pref66 ? EX86_PREF_66 : 0) | EX86_SSE2, xmm1, 0, xmm2, …
2446 static SLJIT_INLINE sljit_s32 emit_sse2_load(struct sljit_compiler *compiler, argument
2449 return emit_sse2(compiler, MOVSD_x_xm, single, dst, src, srcw);
2452 static SLJIT_INLINE sljit_s32 emit_sse2_store(struct sljit_compiler *compiler, argument
2455 return emit_sse2(compiler, MOVSD_xm_x, single, src, dst, dstw);
2458 static SLJIT_INLINE sljit_s32 sljit_emit_fop1_conv_sw_from_f64(struct sljit_compiler *compiler, slj… argument
2467 compiler->mode32 = 0;
2470 …inst = emit_x86_instruction(compiler, 2 | ((op & SLJIT_32) ? EX86_PREF_F3 : EX86_PREF_F2) | EX86_S…
2476 return emit_mov(compiler, dst, dstw, TMP_REG1, 0);
2480 static SLJIT_INLINE sljit_s32 sljit_emit_fop1_conv_f64_from_sw(struct sljit_compiler *compiler, slj… argument
2489 compiler->mode32 = 0;
2497 EMIT_MOV(compiler, TMP_REG1, 0, src, srcw);
2502 …inst = emit_x86_instruction(compiler, 2 | ((op & SLJIT_32) ? EX86_PREF_F3 : EX86_PREF_F2) | EX86_S…
2508 compiler->mode32 = 1;
2511 return emit_sse2_store(compiler, op & SLJIT_32, dst, dstw, TMP_FREG);
2515 static SLJIT_INLINE sljit_s32 sljit_emit_fop1_cmp(struct sljit_compiler *compiler, sljit_s32 op, argument
2520 FAIL_IF(emit_sse2_load(compiler, op & SLJIT_32, TMP_FREG, src1, src1w));
2524 return emit_sse2_logic(compiler, UCOMISD_x_xm, !(op & SLJIT_32), src1, src2, src2w);
2527 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_fop1(struct sljit_compiler *compiler, sljit_s32 op, argument
2534 compiler->mode32 = 1;
2538 SELECT_FOP1_OPERATION_WITH_CHECKS(compiler, op, dst, dstw, src, srcw);
2542 return emit_sse2_load(compiler, op & SLJIT_32, dst, src, srcw);
2544 return emit_sse2_store(compiler, op & SLJIT_32, dst, dstw, src);
2545 FAIL_IF(emit_sse2_load(compiler, op & SLJIT_32, TMP_FREG, src, srcw));
2546 return emit_sse2_store(compiler, op & SLJIT_32, dst, dstw, TMP_FREG);
2555 FAIL_IF(emit_sse2_logic(compiler, UNPCKLPD_x_xm, op & SLJIT_32, src, src, 0));
2558 FAIL_IF(emit_sse2_load(compiler, !(op & SLJIT_32), TMP_FREG, src, srcw));
2562 FAIL_IF(emit_sse2_logic(compiler, CVTPD2PS_x_xm, op & SLJIT_32, dst_r, src, 0));
2564 return emit_sse2_store(compiler, op & SLJIT_32, dst, dstw, TMP_FREG);
2571 FAIL_IF(emit_sse2_load(compiler, op & SLJIT_32, dst_r, src, srcw));
2575 FAIL_IF(emit_sse2_load(compiler, op & SLJIT_32, dst_r, src, srcw));
2580 …FAIL_IF(emit_sse2_logic(compiler, XORPD_x_xm, 1, dst_r, SLJIT_MEM0(), (sljit_sw)(op & SLJIT_32 ? s…
2584 …FAIL_IF(emit_sse2_logic(compiler, ANDPD_x_xm, 1, dst_r, SLJIT_MEM0(), (sljit_sw)(op & SLJIT_32 ? s…
2589 return emit_sse2_store(compiler, op & SLJIT_32, dst, dstw, TMP_FREG);
2593 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_fop2(struct sljit_compiler *compiler, sljit_s32 op, argument
2601 CHECK(check_sljit_emit_fop2(compiler, op, dst, dstw, src1, src1w, src2, src2w));
2607 compiler->mode32 = 1;
2620 FAIL_IF(emit_sse2_load(compiler, op & SLJIT_32, dst_r, src1, src1w));
2623 FAIL_IF(emit_sse2_load(compiler, op & SLJIT_32, TMP_FREG, src1, src1w));
2628 FAIL_IF(emit_sse2_load(compiler, op & SLJIT_32, TMP_FREG, src1, src1w));
2633 FAIL_IF(emit_sse2(compiler, ADDSD_x_xm, op & SLJIT_32, dst_r, src2, src2w));
2637 FAIL_IF(emit_sse2(compiler, SUBSD_x_xm, op & SLJIT_32, dst_r, src2, src2w));
2641 FAIL_IF(emit_sse2(compiler, MULSD_x_xm, op & SLJIT_32, dst_r, src2, src2w));
2645 FAIL_IF(emit_sse2(compiler, DIVSD_x_xm, op & SLJIT_32, dst_r, src2, src2w));
2650 return emit_sse2_store(compiler, op & SLJIT_32, dst, dstw, TMP_FREG);
2658 SLJIT_API_FUNC_ATTRIBUTE struct sljit_label* sljit_emit_label(struct sljit_compiler *compiler) argument
2664 CHECK_PTR(check_sljit_emit_label(compiler));
2666 if (compiler->last_label && compiler->last_label->size == compiler->size)
2667 return compiler->last_label;
2669 label = (struct sljit_label*)ensure_abuf(compiler, sizeof(struct sljit_label));
2671 set_label(label, compiler);
2673 inst = (sljit_u8*)ensure_buf(compiler, 2);
2682 SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_jump(struct sljit_compiler *compiler, sljit_… argument
2688 CHECK_PTR(check_sljit_emit_jump(compiler, type));
2690 jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sljit_jump));
2692 …set_jump(jump, compiler, (sljit_u32)((type & SLJIT_REWRITABLE_JUMP) | ((type & 0xff) << TYPE_SHIFT…
2697 compiler->size += (type >= SLJIT_JUMP) ? 5 : 6;
2699 compiler->size += (type >= SLJIT_JUMP) ? (10 + 3) : (2 + 10 + 3);
2702 inst = (sljit_u8*)ensure_buf(compiler, 2);
2710 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_ijump(struct sljit_compiler *compiler, sljit_s32 type… argument
2716 CHECK(check_sljit_emit_ijump(compiler, type, src, srcw));
2722 jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sljit_jump));
2724 set_jump(jump, compiler, (sljit_u32)(JUMP_ADDR | (type << TYPE_SHIFT)));
2729 compiler->size += 5;
2731 compiler->size += 10 + 3;
2734 inst = (sljit_u8*)ensure_buf(compiler, 2);
2743 compiler->mode32 = 1;
2745 inst = emit_x86_instruction(compiler, 1, 0, 0, src, srcw);
2753 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op_flags(struct sljit_compiler *compiler, sljit_s32 o… argument
2767 CHECK(check_sljit_emit_op_flags(compiler, op, dst, dstw, type));
2778 inst = (sljit_u8*)ensure_buf(compiler, 1 + 4 + 3);
2794 inst = (sljit_u8*)ensure_buf(compiler, 1 + 4 + 4);
2812 compiler->mode32 = GET_OPCODE(op) != SLJIT_MOV;
2813 return emit_mov(compiler, dst, dstw, TMP_REG1, 0);
2818 compiler->skip_checks = 1;
2820 return sljit_emit_op2(compiler, op, dst_save, dstw_save, dst_save, dstw_save, TMP_REG1, 0);
2827 inst = (sljit_u8*)ensure_buf(compiler, 1 + 3 + 3);
2846 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_IMM, 1);
2848 EMIT_MOV(compiler, dst, 0, SLJIT_IMM, 0);
2850 inst = (sljit_u8*)ensure_buf(compiler, 1 + 3);
2861 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1 + 3 + 3 + 1);
2881 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1 + 3 + 2 + 1);
2894 inst = (sljit_u8*)ensure_buf(compiler, 1 + 2 + 3 + 2 + 2);
2912 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1 + 3 + 3 + 1);
2928 return emit_mov(compiler, dst, dstw, TMP_REG1, 0);
2932 compiler->skip_checks = 1;
2934 return sljit_emit_op2(compiler, op, dst_save, dstw_save, dst_save, dstw_save, TMP_REG1, 0);
2938 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_cmov(struct sljit_compiler *compiler, sljit_s32 type, argument
2945 CHECK(check_sljit_emit_cmov(compiler, type, dst_reg, src, srcw));
2951 return sljit_emit_cmov_generic(compiler, type, dst_reg, src, srcw);
2954 return sljit_emit_cmov_generic(compiler, type, dst_reg, src, srcw);
2961 compiler->mode32 = dst_reg & SLJIT_32;
2966 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_IMM, srcw);
2971 inst = emit_x86_instruction(compiler, 2, dst_reg, 0, src, srcw);
2978 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_get_local_base(struct sljit_compiler *compiler, sljit_s32 … argument
2981 CHECK(check_sljit_get_local_base(compiler, dst, dstw, offset));
2987 compiler->mode32 = 0;
2994 FAIL_IF(emit_load_imm64(compiler, TMP_REG1, offset));
2996 …SLJIT_ASSERT(emit_lea_binary(compiler, dst, dstw, SLJIT_SP, 0, TMP_REG1, 0) != SLJIT_ERR_UNSUPPORT…
2997 return compiler->error;
2999 return emit_lea_binary(compiler, dst, dstw, SLJIT_SP, 0, TMP_REG1, 0);
3005 return emit_lea_binary(compiler, dst, dstw, SLJIT_SP, 0, SLJIT_IMM, offset);
3006 return emit_mov(compiler, dst, dstw, SLJIT_SP, 0);
3009 SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compiler *compiler, slji… argument
3018 CHECK_PTR(check_sljit_emit_const(compiler, dst, dstw, init_value));
3023 const_ = (struct sljit_const*)ensure_abuf(compiler, sizeof(struct sljit_const));
3025 set_const(const_, compiler);
3028 compiler->mode32 = 0;
3031 if (emit_load_imm64(compiler, reg, init_value))
3034 if (emit_mov(compiler, dst, dstw, SLJIT_IMM, init_value))
3038 inst = (sljit_u8*)ensure_buf(compiler, 2);
3046 if (emit_mov(compiler, dst, dstw, TMP_REG1, 0))
3053 …UTE struct sljit_put_label* sljit_emit_put_label(struct sljit_compiler *compiler, sljit_s32 dst, s… argument
3063 CHECK_PTR(check_sljit_emit_put_label(compiler, dst, dstw));
3068 put_label = (struct sljit_put_label*)ensure_abuf(compiler, sizeof(struct sljit_put_label));
3070 set_put_label(put_label, compiler, 0);
3073 compiler->mode32 = 0;
3076 if (emit_load_imm64(compiler, reg, 0))
3079 if (emit_mov(compiler, dst, dstw, SLJIT_IMM, 0))
3085 start_size = compiler->size;
3086 if (emit_mov(compiler, dst, dstw, TMP_REG1, 0))
3088 put_label->flags = compiler->size - start_size;
3092 inst = (sljit_u8*)ensure_buf(compiler, 2);