Lines Matching refs:compiler

77 		if (p <= compiler->scratches) \
78 w = compiler->saveds_offset - ((p) - SLJIT_R2) * (sljit_sw)sizeof(sljit_sw); \
80 w = compiler->locals_offset + ((p) - SLJIT_S2) * (sljit_sw)sizeof(sljit_sw); \
264 #define INC_SIZE(s) (*inst++ = (s), compiler->size += (s))
477 SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compiler) in sljit_generate_code() argument
493 CHECK_PTR(check_sljit_generate_code(compiler)); in sljit_generate_code()
494 reverse_buf(compiler); in sljit_generate_code()
497 code = (sljit_u8*)SLJIT_MALLOC_EXEC(compiler->size); in sljit_generate_code()
499 buf = compiler->buf; in sljit_generate_code()
502 label = compiler->labels; in sljit_generate_code()
503 jump = compiler->jumps; in sljit_generate_code()
504 const_ = compiler->consts; in sljit_generate_code()
552 jump = compiler->jumps; in sljit_generate_code()
586 SLJIT_ASSERT(code_ptr <= code + compiler->size); in sljit_generate_code()
587 compiler->error = SLJIT_ERR_COMPILED; in sljit_generate_code()
588 compiler->executable_offset = executable_offset; in sljit_generate_code()
589 compiler->executable_size = code_ptr - code; in sljit_generate_code()
597 static sljit_s32 emit_cum_binary(struct sljit_compiler *compiler,
603 static sljit_s32 emit_non_cum_binary(struct sljit_compiler *compiler,
609 static sljit_s32 emit_mov(struct sljit_compiler *compiler,
613 #define EMIT_MOV(compiler, dst, dstw, src, srcw) \ argument
614 FAIL_IF(emit_mov(compiler, dst, dstw, src, srcw));
639 static sljit_s32 emit_mov(struct sljit_compiler *compiler, in emit_mov() argument
648 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src, srcw); in emit_mov()
655 inst = emit_x86_instruction(compiler, 1, src, 0, dst, dstw); in emit_mov()
663 return emit_do_imm(compiler, MOV_r_i32 + reg_map[dst], srcw); in emit_mov()
665 if (!compiler->mode32) { in emit_mov()
667 return emit_load_imm64(compiler, dst, srcw); in emit_mov()
670 … return emit_do_imm32(compiler, (reg_map[dst] >= 8) ? REX_B : 0, MOV_r_i32 + reg_lmap[dst], srcw); in emit_mov()
674 if (!compiler->mode32 && NOT_HALFWORD(srcw)) { in emit_mov()
675 FAIL_IF(emit_load_imm64(compiler, TMP_REG2, srcw)); in emit_mov()
676 inst = emit_x86_instruction(compiler, 1, TMP_REG2, 0, dst, dstw); in emit_mov()
682 inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, srcw, dst, dstw); in emit_mov()
688 inst = emit_x86_instruction(compiler, 1, dst, 0, src, srcw); in emit_mov()
695 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src, srcw); in emit_mov()
698 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, dst, dstw); in emit_mov()
704 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op0(struct sljit_compiler *compiler, sljit_s32 op) in sljit_emit_op0() argument
712 CHECK(check_sljit_emit_op0(compiler, op)); in sljit_emit_op0()
716 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1); in sljit_emit_op0()
722 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1); in sljit_emit_op0()
745 compiler->mode32 = op & SLJIT_I32_OP; in sljit_emit_op0()
752 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_R1, 0); in sljit_emit_op0()
753 inst = emit_x86_instruction(compiler, 1, SLJIT_R1, 0, SLJIT_R1, 0); in sljit_emit_op0()
755 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, TMP_REG1, 0); in sljit_emit_op0()
763 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_R1, 0); in sljit_emit_op0()
767 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1); in sljit_emit_op0()
772 if (compiler->mode32) { in sljit_emit_op0()
773 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1); in sljit_emit_op0()
778 inst = (sljit_u8*)ensure_buf(compiler, 1 + 2); in sljit_emit_op0()
788 inst = (sljit_u8*)ensure_buf(compiler, 1 + 2); in sljit_emit_op0()
795 size = (!compiler->mode32 || op >= SLJIT_DIVMOD_UW) ? 3 : 2; in sljit_emit_op0()
797 size = (!compiler->mode32) ? 3 : 2; in sljit_emit_op0()
799 inst = (sljit_u8*)ensure_buf(compiler, 1 + size); in sljit_emit_op0()
803 if (!compiler->mode32) in sljit_emit_op0()
810 if (!compiler->mode32) in sljit_emit_op0()
834 EMIT_MOV(compiler, SLJIT_R1, 0, TMP_REG1, 0); in sljit_emit_op0()
837 EMIT_MOV(compiler, SLJIT_R1, 0, TMP_REG1, 0); in sljit_emit_op0()
847 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1); \
853 static sljit_s32 emit_mov_byte(struct sljit_compiler *compiler, sljit_s32 sign, in emit_mov_byte() argument
864 compiler->mode32 = 0; in emit_mov_byte()
873 return emit_do_imm(compiler, MOV_r_i32 + reg_map[dst], srcw); in emit_mov_byte()
875 inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, srcw, dst, 0); in emit_mov_byte()
881 …inst = emit_x86_instruction(compiler, 1 | EX86_BYTE_ARG | EX86_NO_REXW, SLJIT_IMM, srcw, dst, dstw… in emit_mov_byte()
893 EMIT_MOV(compiler, TMP_REG1, 0, src, 0); in emit_mov_byte()
906 EMIT_MOV(compiler, dst, 0, src, 0); in emit_mov_byte()
907 inst = emit_x86_instruction(compiler, 2, dst, 0, dst, 0); in emit_mov_byte()
914 EMIT_MOV(compiler, dst, 0, src, 0); in emit_mov_byte()
917 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_IMM, 24, dst, 0); in emit_mov_byte()
921 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_IMM, 24, dst, 0); in emit_mov_byte()
926 inst = emit_x86_instruction(compiler, 1 | EX86_BIN_INS, SLJIT_IMM, 0xff, dst, 0); in emit_mov_byte()
936 inst = emit_x86_instruction(compiler, 2, dst_r, 0, src, srcw); in emit_mov_byte()
965 inst = emit_x86_instruction(compiler, 1, work_r, 0, dst_r, 0); in emit_mov_byte()
970 inst = emit_x86_instruction(compiler, 1, work_r, 0, dst, dstw); in emit_mov_byte()
978 inst = emit_x86_instruction(compiler, 1, work_r, 0, dst_r, 0); in emit_mov_byte()
984 inst = emit_x86_instruction(compiler, 1, dst_r, 0, dst, dstw); in emit_mov_byte()
989 inst = emit_x86_instruction(compiler, 1 | EX86_REX | EX86_NO_REXW, dst_r, 0, dst, dstw); in emit_mov_byte()
998 static sljit_s32 emit_mov_half(struct sljit_compiler *compiler, sljit_s32 sign, in emit_mov_half() argument
1006 compiler->mode32 = 0; in emit_mov_half()
1015 return emit_do_imm(compiler, MOV_r_i32 + reg_map[dst], srcw); in emit_mov_half()
1017 inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, srcw, dst, 0); in emit_mov_half()
1023 …inst = emit_x86_instruction(compiler, 1 | EX86_HALF_ARG | EX86_NO_REXW | EX86_PREF_66, SLJIT_IMM, … in emit_mov_half()
1034 inst = emit_x86_instruction(compiler, 2, dst_r, 0, src, srcw); in emit_mov_half()
1041 inst = emit_x86_instruction(compiler, 1 | EX86_NO_REXW | EX86_PREF_66, dst_r, 0, dst, dstw); in emit_mov_half()
1049 static sljit_s32 emit_unary(struct sljit_compiler *compiler, sljit_u8 opcode, in emit_unary() argument
1056 EMIT_MOV(compiler, TMP_REG1, 0, src, srcw); in emit_unary()
1057 inst = emit_x86_instruction(compiler, 1, 0, 0, TMP_REG1, 0); in emit_unary()
1065 inst = emit_x86_instruction(compiler, 1, 0, 0, dst, dstw); in emit_unary()
1072 EMIT_MOV(compiler, dst, 0, src, srcw); in emit_unary()
1073 inst = emit_x86_instruction(compiler, 1, 0, 0, dst, dstw); in emit_unary()
1079 EMIT_MOV(compiler, TMP_REG1, 0, src, srcw); in emit_unary()
1080 inst = emit_x86_instruction(compiler, 1, 0, 0, TMP_REG1, 0); in emit_unary()
1084 EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0); in emit_unary()
1088 static sljit_s32 emit_not_with_flags(struct sljit_compiler *compiler, in emit_not_with_flags() argument
1095 EMIT_MOV(compiler, TMP_REG1, 0, src, srcw); in emit_not_with_flags()
1096 inst = emit_x86_instruction(compiler, 1, 0, 0, TMP_REG1, 0); in emit_not_with_flags()
1100 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, TMP_REG1, 0); in emit_not_with_flags()
1106 EMIT_MOV(compiler, dst, 0, src, srcw); in emit_not_with_flags()
1107 inst = emit_x86_instruction(compiler, 1, 0, 0, dst, dstw); in emit_not_with_flags()
1111 inst = emit_x86_instruction(compiler, 1, dst, 0, dst, 0); in emit_not_with_flags()
1116 EMIT_MOV(compiler, TMP_REG1, 0, src, srcw); in emit_not_with_flags()
1117 inst = emit_x86_instruction(compiler, 1, 0, 0, TMP_REG1, 0); in emit_not_with_flags()
1121 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, TMP_REG1, 0); in emit_not_with_flags()
1124 EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0); in emit_not_with_flags()
1128 static sljit_s32 emit_clz(struct sljit_compiler *compiler, sljit_s32 op_flags, in emit_clz() argument
1138 EMIT_MOV(compiler, TMP_REG1, 0, src, srcw); in emit_clz()
1139 inst = emit_x86_instruction(compiler, 1, 0, 0, TMP_REG1, 0); in emit_clz()
1144 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_IMM, 31, TMP_REG1, 0); in emit_clz()
1146 …inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_IMM, !(op_flags & SLJIT_I32_OP) ? … in emit_clz()
1154 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_IMM, srcw); in emit_clz()
1159 inst = emit_x86_instruction(compiler, 2, TMP_REG1, 0, src, srcw); in emit_clz()
1175 EMIT_MOV(compiler, dst, dstw, dst_r, 0); in emit_clz()
1177 EMIT_MOV(compiler, dst_r, 0, SLJIT_IMM, 32 + 31); in emit_clz()
1180 compiler->mode32 = 0; in emit_clz()
1181 EMIT_MOV(compiler, dst_r, 0, SLJIT_IMM, !(op_flags & SLJIT_I32_OP) ? 64 + 63 : 32 + 31); in emit_clz()
1182 compiler->mode32 = op_flags & SLJIT_I32_OP; in emit_clz()
1189 inst = emit_x86_instruction(compiler, 2, dst_r, 0, TMP_REG1, 0); in emit_clz()
1195 inst = (sljit_u8*)ensure_buf(compiler, 1 + 4); in emit_clz()
1204 inst = (sljit_u8*)ensure_buf(compiler, 1 + 5); in emit_clz()
1217 inst = emit_x86_instruction(compiler, 1 | EX86_BIN_INS, SLJIT_IMM, 31, dst_r, 0); in emit_clz()
1219 …inst = emit_x86_instruction(compiler, 1 | EX86_BIN_INS, SLJIT_IMM, !(op_flags & SLJIT_I32_OP) ? 63… in emit_clz()
1226 inst = emit_x86_instruction(compiler, 1, dst_r, 0, dst, dstw); in emit_clz()
1232 EMIT_MOV(compiler, dst, dstw, TMP_REG2, 0); in emit_clz()
1237 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op1(struct sljit_compiler *compiler, sljit_s32 op, in sljit_emit_op1() argument
1251 CHECK(check_sljit_emit_op1(compiler, op, dst, dstw, src, srcw)); in sljit_emit_op1()
1258 compiler->mode32 = op_flags & SLJIT_I32_OP; in sljit_emit_op1()
1264 compiler->mode32 = 0; in sljit_emit_op1()
1315 return emit_mov(compiler, dst, dstw, src, srcw); in sljit_emit_op1()
1333 FAIL_IF(emit_mov(compiler, dst, dstw, src, srcw)); in sljit_emit_op1()
1336 FAIL_IF(emit_mov_byte(compiler, 0, dst, dstw, src, srcw)); in sljit_emit_op1()
1339 FAIL_IF(emit_mov_byte(compiler, 1, dst, dstw, src, srcw)); in sljit_emit_op1()
1342 FAIL_IF(emit_mov_half(compiler, 0, dst, dstw, src, srcw)); in sljit_emit_op1()
1345 FAIL_IF(emit_mov_half(compiler, 1, dst, dstw, src, srcw)); in sljit_emit_op1()
1349 FAIL_IF(emit_mov_int(compiler, 0, dst, dstw, src, srcw)); in sljit_emit_op1()
1352 FAIL_IF(emit_mov_int(compiler, 1, dst, dstw, src, srcw)); in sljit_emit_op1()
1359 return emit_mov(compiler, SLJIT_MEM1(SLJIT_SP), dstw, TMP_REG1, 0); in sljit_emit_op1()
1364 FAIL_IF(emit_cum_binary(compiler, ADD_r_rm, ADD_rm_r, ADD, ADD_EAX_i32, in sljit_emit_op1()
1368 FAIL_IF(emit_cum_binary(compiler, ADD_r_rm, ADD_rm_r, ADD, ADD_EAX_i32, in sljit_emit_op1()
1375 FAIL_IF(emit_cum_binary(compiler, ADD_r_rm, ADD_rm_r, ADD, ADD_EAX_i32, in sljit_emit_op1()
1379 FAIL_IF(emit_cum_binary(compiler, ADD_r_rm, ADD_rm_r, ADD, ADD_EAX_i32, in sljit_emit_op1()
1389 return emit_not_with_flags(compiler, dst, dstw, src, srcw); in sljit_emit_op1()
1390 return emit_unary(compiler, NOT_rm, dst, dstw, src, srcw); in sljit_emit_op1()
1393 return emit_unary(compiler, NEG_rm, dst, dstw, src, srcw); in sljit_emit_op1()
1396 return emit_clz(compiler, op_flags, dst, dstw, src, srcw); in sljit_emit_op1()
1409 if (IS_HALFWORD(immw) || compiler->mode32) { \
1410 inst = emit_x86_instruction(compiler, 1 | EX86_BIN_INS, SLJIT_IMM, immw, arg, argw); \
1415 FAIL_IF(emit_load_imm64(compiler, TMP_REG2, immw)); \
1416 inst = emit_x86_instruction(compiler, 1, TMP_REG2, 0, arg, argw); \
1422 FAIL_IF(emit_do_imm32(compiler, (!compiler->mode32) ? REX_W : 0, (op_eax_imm), immw))
1427 inst = emit_x86_instruction(compiler, 1 | EX86_BIN_INS, SLJIT_IMM, immw, arg, argw); \
1432 FAIL_IF(emit_do_imm(compiler, (op_eax_imm), immw))
1436 static sljit_s32 emit_cum_binary(struct sljit_compiler *compiler, argument
1445 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
1450 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src2, src2w);
1460 …if ((dst == SLJIT_R0) && (src2w > 127 || src2w < -128) && (compiler->mode32 || IS_HALFWORD(src2w))…
1471 inst = emit_x86_instruction(compiler, 1, dst, dstw, src2, src2w);
1477 inst = emit_x86_instruction(compiler, 1, src2, src2w, dst, dstw);
1482 EMIT_MOV(compiler, TMP_REG1, 0, src2, src2w);
1483 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, dst, dstw);
1494 …if ((dst == SLJIT_R0) && (src1w > 127 || src1w < -128) && (compiler->mode32 || IS_HALFWORD(src1w))…
1505 inst = emit_x86_instruction(compiler, 1, dst, dstw, src1, src1w);
1510 inst = emit_x86_instruction(compiler, 1, src1, src1w, dst, dstw);
1515 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
1516 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, dst, dstw);
1525 EMIT_MOV(compiler, dst, 0, src1, src1w);
1530 inst = emit_x86_instruction(compiler, 1, dst, 0, src2, src2w);
1537 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
1542 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src2, src2w);
1546 EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0);
1552 static sljit_s32 emit_non_cum_binary(struct sljit_compiler *compiler, argument
1561 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
1566 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src2, src2w);
1576 …if ((dst == SLJIT_R0) && (src2w > 127 || src2w < -128) && (compiler->mode32 || IS_HALFWORD(src2w))…
1587 inst = emit_x86_instruction(compiler, 1, dst, dstw, src2, src2w);
1592 inst = emit_x86_instruction(compiler, 1, src2, src2w, dst, dstw);
1597 EMIT_MOV(compiler, TMP_REG1, 0, src2, src2w);
1598 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, dst, dstw);
1607 EMIT_MOV(compiler, dst, 0, src1, src1w);
1612 inst = emit_x86_instruction(compiler, 1, dst, 0, src2, src2w);
1619 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
1624 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src2, src2w);
1628 EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0);
1634 static sljit_s32 emit_mul(struct sljit_compiler *compiler, argument
1646 inst = emit_x86_instruction(compiler, 2, dst_r, 0, src2, src2w);
1652 inst = emit_x86_instruction(compiler, 2, dst_r, 0, src1, src1w);
1659 EMIT_MOV(compiler, dst_r, 0, SLJIT_IMM, src2w);
1665 inst = emit_x86_instruction(compiler, 1, dst_r, 0, src2, src2w);
1668 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1);
1675 inst = emit_x86_instruction(compiler, 1, dst_r, 0, src2, src2w);
1678 inst = (sljit_u8*)ensure_buf(compiler, 1 + 4);
1685 inst = emit_x86_instruction(compiler, 1, dst_r, 0, src2, src2w);
1688 inst = (sljit_u8*)ensure_buf(compiler, 1 + 4);
1694 EMIT_MOV(compiler, TMP_REG2, 0, SLJIT_IMM, src1w);
1696 EMIT_MOV(compiler, dst_r, 0, src2, src2w);
1697 inst = emit_x86_instruction(compiler, 2, dst_r, 0, TMP_REG2, 0);
1708 inst = emit_x86_instruction(compiler, 1, dst_r, 0, src1, src1w);
1711 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1);
1718 inst = emit_x86_instruction(compiler, 1, dst_r, 0, src1, src1w);
1721 inst = (sljit_u8*)ensure_buf(compiler, 1 + 4);
1728 inst = emit_x86_instruction(compiler, 1, dst_r, 0, src1, src1w);
1731 inst = (sljit_u8*)ensure_buf(compiler, 1 + 4);
1737 EMIT_MOV(compiler, TMP_REG2, 0, SLJIT_IMM, src2w);
1739 EMIT_MOV(compiler, dst_r, 0, src1, src1w);
1740 inst = emit_x86_instruction(compiler, 2, dst_r, 0, TMP_REG2, 0);
1751 EMIT_MOV(compiler, dst_r, 0, src1, src1w);
1752 inst = emit_x86_instruction(compiler, 2, dst_r, 0, src2, src2w);
1759 EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0);
1764 static sljit_s32 emit_lea_binary(struct sljit_compiler *compiler, argument
1782 inst = emit_x86_instruction(compiler, 1, dst_r, 0, SLJIT_MEM2(src1, src2), 0);
1788 if ((src2 & SLJIT_IMM) && (compiler->mode32 || IS_HALFWORD(src2w))) {
1789 inst = emit_x86_instruction(compiler, 1, dst_r, 0, SLJIT_MEM1(src1), (sljit_s32)src2w);
1792 inst = emit_x86_instruction(compiler, 1, dst_r, 0, SLJIT_MEM1(src1), src2w);
1801 if ((src1 & SLJIT_IMM) && (compiler->mode32 || IS_HALFWORD(src1w))) {
1802 inst = emit_x86_instruction(compiler, 1, dst_r, 0, SLJIT_MEM1(src2), (sljit_s32)src1w);
1805 inst = emit_x86_instruction(compiler, 1, dst_r, 0, SLJIT_MEM1(src2), src1w);
1815 return emit_mov(compiler, dst, dstw, TMP_REG1, 0);
1821 static sljit_s32 emit_cmp_binary(struct sljit_compiler *compiler, argument
1828 …if (src1 == SLJIT_R0 && (src2 & SLJIT_IMM) && (src2w > 127 || src2w < -128) && (compiler->mode32 |…
1841 inst = emit_x86_instruction(compiler, 1, src1, 0, src2, src2w);
1849 inst = emit_x86_instruction(compiler, 1, src2, 0, src1, src1w);
1857 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
1864 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
1865 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src2, src2w);
1872 static sljit_s32 emit_test_binary(struct sljit_compiler *compiler, argument
1879 …if (src1 == SLJIT_R0 && (src2 & SLJIT_IMM) && (src2w > 127 || src2w < -128) && (compiler->mode32 |…
1888 …if (src2 == SLJIT_R0 && (src1 & SLJIT_IMM) && (src1w > 127 || src1w < -128) && (compiler->mode32 |…
1899 if (IS_HALFWORD(src2w) || compiler->mode32) {
1900 inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src2w, src1, src1w);
1905 FAIL_IF(emit_load_imm64(compiler, TMP_REG2, src2w));
1906 inst = emit_x86_instruction(compiler, 1, TMP_REG2, 0, src1, src1w);
1911 inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src2w, src1, src1w);
1918 inst = emit_x86_instruction(compiler, 1, src1, 0, src2, src2w);
1928 if (IS_HALFWORD(src1w) || compiler->mode32) {
1929 inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src1w, src2, src2w);
1934 FAIL_IF(emit_load_imm64(compiler, TMP_REG2, src1w));
1935 inst = emit_x86_instruction(compiler, 1, TMP_REG2, 0, src2, src2w);
1940 inst = emit_x86_instruction(compiler, 1, src1, src1w, src2, src2w);
1947 inst = emit_x86_instruction(compiler, 1, src2, 0, src1, src1w);
1954 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
1957 if (IS_HALFWORD(src2w) || compiler->mode32) {
1958 inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src2w, TMP_REG1, 0);
1963 FAIL_IF(emit_load_imm64(compiler, TMP_REG2, src2w));
1964 inst = emit_x86_instruction(compiler, 1, TMP_REG2, 0, TMP_REG1, 0);
1969 inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src2w, TMP_REG1, 0);
1975 inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src2, src2w);
1982 static sljit_s32 emit_shift(struct sljit_compiler *compiler, argument
1992 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, src2, src2w, dst, dstw);
1998 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
1999 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, src2, src2w, TMP_REG1, 0);
2005 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
2006 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
2009 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
2013 EMIT_MOV(compiler, dst, 0, src1, src1w);
2014 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, src2, src2w, dst, 0);
2020 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
2021 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, src2, src2w, TMP_REG1, 0);
2024 EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0);
2029 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
2030 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, src2, src2w);
2031 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
2034 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
2038 EMIT_MOV(compiler, dst, 0, src1, src1w);
2039 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_PREF_SHIFT_REG, 0);
2040 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, src2, src2w);
2041 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_PREF_SHIFT_REG, 0, dst, 0);
2044 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
2049 EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
2051 EMIT_MOV(compiler, TMP_REG2, 0, SLJIT_PREF_SHIFT_REG, 0);
2053 EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), 0, SLJIT_PREF_SHIFT_REG, 0);
2055 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, src2, src2w);
2056 inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
2060 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, TMP_REG2, 0);
2062 EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, SLJIT_MEM1(SLJIT_SP), 0);
2064 EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0);
2070 static sljit_s32 emit_shift_with_flags(struct sljit_compiler *compiler, argument
2079 if ((src2w & 0x3f) != 0 || (compiler->mode32 && (src2w & 0x1f) != 0))
2080 return emit_shift(compiler, mode, dst, dstw, src1, src1w, src2, src2w);
2083 return emit_shift(compiler, mode, dst, dstw, src1, src1w, src2, src2w);
2086 return emit_mov(compiler, dst, dstw, src1, src1w);
2088 return emit_cum_binary(compiler, OR_r_rm, OR_rm_r, OR, OR_EAX_i32,
2093 return emit_shift(compiler, mode, dst, dstw, src1, src1w, src2, src2w);
2096 FAIL_IF(emit_cmp_binary(compiler, src1, src1w, SLJIT_IMM, 0));
2098 FAIL_IF(emit_shift(compiler,mode, dst, dstw, src1, src1w, src2, src2w));
2101 return emit_cmp_binary(compiler, dst, dstw, SLJIT_IMM, 0);
2105 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op2(struct sljit_compiler *compiler, sljit_s32 op, argument
2111 CHECK(check_sljit_emit_op2(compiler, op, dst, dstw, src1, src1w, src2, src2w));
2120 compiler->mode32 = op & SLJIT_I32_OP;
2126 if (emit_lea_binary(compiler, dst, dstw, src1, src1w, src2, src2w) != SLJIT_ERR_UNSUPPORTED)
2127 return compiler->error;
2129 return emit_cum_binary(compiler, ADD_r_rm, ADD_rm_r, ADD, ADD_EAX_i32,
2132 return emit_cum_binary(compiler, ADC_r_rm, ADC_rm_r, ADC, ADC_EAX_i32,
2136 …if ((src2 & SLJIT_IMM) && emit_lea_binary(compiler, dst, dstw, src1, src1w, SLJIT_IMM, -src2w) != …
2137 return compiler->error;
2141 return emit_cmp_binary(compiler, src1, src1w, src2, src2w);
2142 return emit_non_cum_binary(compiler, SUB_r_rm, SUB_rm_r, SUB, SUB_EAX_i32,
2145 return emit_non_cum_binary(compiler, SBB_r_rm, SBB_rm_r, SBB, SBB_EAX_i32,
2148 return emit_mul(compiler, dst, dstw, src1, src1w, src2, src2w);
2151 return emit_test_binary(compiler, src1, src1w, src2, src2w);
2152 return emit_cum_binary(compiler, AND_r_rm, AND_rm_r, AND, AND_EAX_i32,
2155 return emit_cum_binary(compiler, OR_r_rm, OR_rm_r, OR, OR_EAX_i32,
2158 return emit_cum_binary(compiler, XOR_r_rm, XOR_rm_r, XOR, XOR_EAX_i32,
2161 return emit_shift_with_flags(compiler, SHL, HAS_FLAGS(op),
2164 return emit_shift_with_flags(compiler, SHR, HAS_FLAGS(op),
2167 return emit_shift_with_flags(compiler, SAR, HAS_FLAGS(op),
2190 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op_custom(struct sljit_compiler *compiler, argument
2196 CHECK(check_sljit_emit_op_custom(compiler, instruction, size));
2198 inst = (sljit_u8*)ensure_buf(compiler, 1 + size);
2239 static sljit_s32 emit_sse2(struct sljit_compiler *compiler, sljit_u8 opcode, argument
2244 …inst = emit_x86_instruction(compiler, 2 | (single ? EX86_PREF_F3 : EX86_PREF_F2) | EX86_SSE2, xmm1…
2251 static sljit_s32 emit_sse2_logic(struct sljit_compiler *compiler, sljit_u8 opcode, argument
2256 …inst = emit_x86_instruction(compiler, 2 | (pref66 ? EX86_PREF_66 : 0) | EX86_SSE2, xmm1, 0, xmm2, …
2263 static SLJIT_INLINE sljit_s32 emit_sse2_load(struct sljit_compiler *compiler, argument
2266 return emit_sse2(compiler, MOVSD_x_xm, single, dst, src, srcw);
2269 static SLJIT_INLINE sljit_s32 emit_sse2_store(struct sljit_compiler *compiler, argument
2272 return emit_sse2(compiler, MOVSD_xm_x, single, src, dst, dstw);
2275 static SLJIT_INLINE sljit_s32 sljit_emit_fop1_conv_sw_from_f64(struct sljit_compiler *compiler, slj… argument
2284 compiler->mode32 = 0;
2287 …inst = emit_x86_instruction(compiler, 2 | ((op & SLJIT_F32_OP) ? EX86_PREF_F3 : EX86_PREF_F2) | EX…
2293 return emit_mov(compiler, dst, dstw, TMP_REG1, 0);
2297 static SLJIT_INLINE sljit_s32 sljit_emit_fop1_conv_f64_from_sw(struct sljit_compiler *compiler, slj… argument
2306 compiler->mode32 = 0;
2314 EMIT_MOV(compiler, TMP_REG1, 0, src, srcw);
2319 …inst = emit_x86_instruction(compiler, 2 | ((op & SLJIT_F32_OP) ? EX86_PREF_F3 : EX86_PREF_F2) | EX…
2325 compiler->mode32 = 1;
2328 return emit_sse2_store(compiler, op & SLJIT_F32_OP, dst, dstw, TMP_FREG);
2332 static SLJIT_INLINE sljit_s32 sljit_emit_fop1_cmp(struct sljit_compiler *compiler, sljit_s32 op, argument
2337 FAIL_IF(emit_sse2_load(compiler, op & SLJIT_F32_OP, TMP_FREG, src1, src1w));
2340 return emit_sse2_logic(compiler, UCOMISD_x_xm, !(op & SLJIT_F32_OP), src1, src2, src2w);
2343 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_fop1(struct sljit_compiler *compiler, sljit_s32 op, argument
2350 compiler->mode32 = 1;
2354 SELECT_FOP1_OPERATION_WITH_CHECKS(compiler, op, dst, dstw, src, srcw);
2358 return emit_sse2_load(compiler, op & SLJIT_F32_OP, dst, src, srcw);
2360 return emit_sse2_store(compiler, op & SLJIT_F32_OP, dst, dstw, src);
2361 FAIL_IF(emit_sse2_load(compiler, op & SLJIT_F32_OP, TMP_FREG, src, srcw));
2362 return emit_sse2_store(compiler, op & SLJIT_F32_OP, dst, dstw, TMP_FREG);
2371 FAIL_IF(emit_sse2_logic(compiler, UNPCKLPD_x_xm, op & SLJIT_F32_OP, src, src, 0));
2374 FAIL_IF(emit_sse2_load(compiler, !(op & SLJIT_F32_OP), TMP_FREG, src, srcw));
2378 FAIL_IF(emit_sse2_logic(compiler, CVTPD2PS_x_xm, op & SLJIT_F32_OP, dst_r, src, 0));
2380 return emit_sse2_store(compiler, op & SLJIT_F32_OP, dst, dstw, TMP_FREG);
2387 FAIL_IF(emit_sse2_load(compiler, op & SLJIT_F32_OP, dst_r, src, srcw));
2391 FAIL_IF(emit_sse2_load(compiler, op & SLJIT_F32_OP, dst_r, src, srcw));
2396 …FAIL_IF(emit_sse2_logic(compiler, XORPD_x_xm, 1, dst_r, SLJIT_MEM0(), (sljit_sw)(op & SLJIT_F32_OP…
2400 …FAIL_IF(emit_sse2_logic(compiler, ANDPD_x_xm, 1, dst_r, SLJIT_MEM0(), (sljit_sw)(op & SLJIT_F32_OP…
2405 return emit_sse2_store(compiler, op & SLJIT_F32_OP, dst, dstw, TMP_FREG);
2409 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_fop2(struct sljit_compiler *compiler, sljit_s32 op, argument
2417 CHECK(check_sljit_emit_fop2(compiler, op, dst, dstw, src1, src1w, src2, src2w));
2423 compiler->mode32 = 1;
2436 FAIL_IF(emit_sse2_load(compiler, op & SLJIT_F32_OP, dst_r, src1, src1w));
2439 FAIL_IF(emit_sse2_load(compiler, op & SLJIT_F32_OP, TMP_FREG, src1, src1w));
2444 FAIL_IF(emit_sse2_load(compiler, op & SLJIT_F32_OP, TMP_FREG, src1, src1w));
2449 FAIL_IF(emit_sse2(compiler, ADDSD_x_xm, op & SLJIT_F32_OP, dst_r, src2, src2w));
2453 FAIL_IF(emit_sse2(compiler, SUBSD_x_xm, op & SLJIT_F32_OP, dst_r, src2, src2w));
2457 FAIL_IF(emit_sse2(compiler, MULSD_x_xm, op & SLJIT_F32_OP, dst_r, src2, src2w));
2461 FAIL_IF(emit_sse2(compiler, DIVSD_x_xm, op & SLJIT_F32_OP, dst_r, src2, src2w));
2466 return emit_sse2_store(compiler, op & SLJIT_F32_OP, dst, dstw, TMP_FREG);
2474 SLJIT_API_FUNC_ATTRIBUTE struct sljit_label* sljit_emit_label(struct sljit_compiler *compiler) argument
2480 CHECK_PTR(check_sljit_emit_label(compiler));
2482 if (compiler->last_label && compiler->last_label->size == compiler->size)
2483 return compiler->last_label;
2485 label = (struct sljit_label*)ensure_abuf(compiler, sizeof(struct sljit_label));
2487 set_label(label, compiler);
2489 inst = (sljit_u8*)ensure_buf(compiler, 2);
2498 SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_jump(struct sljit_compiler *compiler, sljit_… argument
2504 CHECK_PTR(check_sljit_emit_jump(compiler, type));
2506 jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sljit_jump));
2508 set_jump(jump, compiler, type & SLJIT_REWRITABLE_JUMP);
2512 PTR_FAIL_IF(call_with_args(compiler, type));
2516 compiler->size += (type >= SLJIT_JUMP) ? 5 : 6;
2518 compiler->size += (type >= SLJIT_JUMP) ? (10 + 3) : (2 + 10 + 3);
2521 inst = (sljit_u8*)ensure_buf(compiler, 2);
2529 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_ijump(struct sljit_compiler *compiler, sljit_s32 type… argument
2535 CHECK(check_sljit_emit_ijump(compiler, type, src, srcw));
2544 EMIT_MOV(compiler, TMP_REG1, 0, src, 0);
2553 EMIT_MOV(compiler, TMP_REG1, 0, src, 0);
2557 FAIL_IF(call_with_args(compiler, type));
2561 jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sljit_jump));
2563 set_jump(jump, compiler, JUMP_ADDR);
2568 compiler->size += 5;
2570 compiler->size += 10 + 3;
2573 inst = (sljit_u8*)ensure_buf(compiler, 2);
2582 compiler->mode32 = 1;
2584 inst = emit_x86_instruction(compiler, 1, 0, 0, src, srcw);
2592 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op_flags(struct sljit_compiler *compiler, sljit_s32 o… argument
2607 CHECK(check_sljit_emit_op_flags(compiler, op, dst, dstw, src, srcw, type));
2622 inst = (sljit_u8*)ensure_buf(compiler, 1 + 4 + 3);
2638 inst = (sljit_u8*)ensure_buf(compiler, 1 + 4 + 4);
2656 compiler->mode32 = GET_OPCODE(op) != SLJIT_MOV;
2657 return emit_mov(compiler, dst, dstw, TMP_REG1, 0);
2661 compiler->skip_checks = 1;
2663 return sljit_emit_op2(compiler, op, dst_save, dstw_save, dst_save, dstw_save, TMP_REG1, 0);
2670 inst = (sljit_u8*)ensure_buf(compiler, 1 + 3 + 3);
2689 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_IMM, 1);
2691 EMIT_MOV(compiler, dst, 0, SLJIT_IMM, 0);
2693 inst = (sljit_u8*)ensure_buf(compiler, 1 + 3);
2704 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1 + 3 + 3 + 1);
2724 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1 + 3 + 2 + 1);
2737 inst = (sljit_u8*)ensure_buf(compiler, 1 + 2 + 3 + 2 + 2);
2755 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1 + 3 + 3 + 1);
2771 return emit_mov(compiler, dst, dstw, TMP_REG1, 0);
2775 compiler->skip_checks = 1;
2777 return sljit_emit_op2(compiler, op, dst_save, dstw_save, dst_save, dstw_save, TMP_REG1, 0);
2781 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_get_local_base(struct sljit_compiler *compiler, sljit_s32 … argument
2784 CHECK(check_sljit_get_local_base(compiler, dst, dstw, offset));
2790 compiler->mode32 = 0;
2797 FAIL_IF(emit_load_imm64(compiler, TMP_REG1, offset));
2799 …SLJIT_ASSERT(emit_lea_binary(compiler, dst, dstw, SLJIT_SP, 0, TMP_REG1, 0) != SLJIT_ERR_UNSUPPORT…
2800 return compiler->error;
2802 return emit_lea_binary(compiler, dst, dstw, SLJIT_SP, 0, TMP_REG1, 0);
2808 return emit_lea_binary(compiler, dst, dstw, SLJIT_SP, 0, SLJIT_IMM, offset);
2809 return emit_mov(compiler, dst, dstw, SLJIT_SP, 0);
2812 SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compiler *compiler, slji… argument
2821 CHECK_PTR(check_sljit_emit_const(compiler, dst, dstw, init_value));
2826 const_ = (struct sljit_const*)ensure_abuf(compiler, sizeof(struct sljit_const));
2828 set_const(const_, compiler);
2831 compiler->mode32 = 0;
2834 if (emit_load_imm64(compiler, reg, init_value))
2840 if (emit_mov(compiler, dst, dstw, SLJIT_IMM, init_value))
2844 inst = (sljit_u8*)ensure_buf(compiler, 2);
2852 if (emit_mov(compiler, dst, dstw, TMP_REG1, 0))
2893 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_x86_emit_cmov(struct sljit_compiler *compiler, argument
2909 CHECK_ARGUMENT(compiler->last_flags & SLJIT_SET_Z);
2911 CHECK_ARGUMENT((type & 0xff) == (compiler->last_flags & 0xff));
2914 if (SLJIT_UNLIKELY(!!compiler->verbose)) {
2915 fprintf(compiler->verbose, " x86_cmov%s %s%s, ",
2918 sljit_verbose_reg(compiler, dst_reg & ~SLJIT_I32_OP);
2919 fprintf(compiler->verbose, ", ");
2920 sljit_verbose_param(compiler, src, srcw);
2921 fprintf(compiler->verbose, "\n");
2929 compiler->mode32 = dst_reg & SLJIT_I32_OP;
2934 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_IMM, srcw);
2939 inst = emit_x86_instruction(compiler, 2, dst_reg, 0, src, srcw);