chiark / gitweb /
Record pcre3 (2:8.38-1) in archive suite sid
[pcre3.git] / sljit / sljitNativePPC_common.c
index 5e06f2fd8ee0e8ce8998b2b4bfe08ba1006dc46f..b6a043f4e48f24edf8d2495e29fb760d4623e96b 100644 (file)
@@ -87,22 +87,22 @@ static void ppc_cache_flush(sljit_ins *from, sljit_ins *to)
 #endif /* _AIX */
 }
 
-#define TMP_REG1       (SLJIT_NO_REGISTERS + 1)
-#define TMP_REG2       (SLJIT_NO_REGISTERS + 2)
-#define TMP_REG3       (SLJIT_NO_REGISTERS + 3)
-#define TMP_ZERO       (SLJIT_NO_REGISTERS + 4)
+#define TMP_REG1       (SLJIT_NUMBER_OF_REGISTERS + 2)
+#define TMP_REG2       (SLJIT_NUMBER_OF_REGISTERS + 3)
+#define TMP_REG3       (SLJIT_NUMBER_OF_REGISTERS + 4)
+#define TMP_ZERO       (SLJIT_NUMBER_OF_REGISTERS + 5)
 
 #if (defined SLJIT_PASS_ENTRY_ADDR_TO_CALL && SLJIT_PASS_ENTRY_ADDR_TO_CALL)
-#define TMP_CALL_REG   (SLJIT_NO_REGISTERS + 5)
+#define TMP_CALL_REG   (SLJIT_NUMBER_OF_REGISTERS + 6)
 #else
 #define TMP_CALL_REG   TMP_REG2
 #endif
 
 #define TMP_FREG1      (0)
-#define TMP_FREG2      (SLJIT_FLOAT_REG6 + 1)
+#define TMP_FREG2      (SLJIT_NUMBER_OF_FLOAT_REGISTERS + 1)
 
-static SLJIT_CONST sljit_ub reg_map[SLJIT_NO_REGISTERS + 6] = {
-       0, 3, 4, 5, 6, 7, 30, 29, 28, 27, 26, 1, 8, 9, 10, 31, 12
+static SLJIT_CONST sljit_ub reg_map[SLJIT_NUMBER_OF_REGISTERS + 7] = {
+       0, 3, 4, 5, 6, 7, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 1, 8, 9, 10, 31, 12
 };
 
 /* --------------------------------------------------------------------- */
@@ -114,6 +114,7 @@ static SLJIT_CONST sljit_ub reg_map[SLJIT_NO_REGISTERS + 6] = {
 #define B(b)           (reg_map[b] << 11)
 #define C(c)           (reg_map[c] << 6)
 #define FD(fd)         ((fd) << 21)
+#define FS(fs)         ((fs) << 21)
 #define FA(fa)         ((fa) << 16)
 #define FB(fb)         ((fb) << 11)
 #define FC(fc)         ((fc) << 6)
@@ -159,13 +160,17 @@ static SLJIT_CONST sljit_ub reg_map[SLJIT_NO_REGISTERS + 6] = {
 #define FABS           (HI(63) | LO(264))
 #define FADD           (HI(63) | LO(21))
 #define FADDS          (HI(59) | LO(21))
+#define FCFID          (HI(63) | LO(846))
 #define FCMPU          (HI(63) | LO(0))
+#define FCTIDZ         (HI(63) | LO(815))
+#define FCTIWZ         (HI(63) | LO(15))
 #define FDIV           (HI(63) | LO(18))
 #define FDIVS          (HI(59) | LO(18))
 #define FMR            (HI(63) | LO(72))
 #define FMUL           (HI(63) | LO(25))
 #define FMULS          (HI(59) | LO(25))
 #define FNEG           (HI(63) | LO(40))
+#define FRSP           (HI(63) | LO(12))
 #define FSUB           (HI(63) | LO(20))
 #define FSUBS          (HI(59) | LO(20))
 #define LD             (HI(58) | 0)
@@ -202,6 +207,7 @@ static SLJIT_CONST sljit_ub reg_map[SLJIT_NO_REGISTERS + 6] = {
 #define STD            (HI(62) | 0)
 #define STDU           (HI(62) | 1)
 #define STDUX          (HI(31) | LO(181))
+#define STFIWX         (HI(31) | LO(983))
 #define STW            (HI(36))
 #define STWU           (HI(37))
 #define STWUX          (HI(31) | LO(183))
@@ -323,7 +329,7 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil
        struct sljit_const *const_;
 
        CHECK_ERROR_PTR();
-       check_sljit_generate_code(compiler);
+       CHECK_PTR(check_sljit_generate_code(compiler));
        reverse_buf(compiler);
 
 #if (defined SLJIT_INDIRECT_CALL && SLJIT_INDIRECT_CALL)
@@ -565,118 +571,121 @@ ALT_FORM6               0x200000 */
 #define STACK_LOAD     LD
 #endif
 
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compiler, sljit_si args, sljit_si scratches, sljit_si saveds, sljit_si local_size)
+SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compiler,
+       sljit_si options, sljit_si args, sljit_si scratches, sljit_si saveds,
+       sljit_si fscratches, sljit_si fsaveds, sljit_si local_size)
 {
-       CHECK_ERROR();
-       check_sljit_emit_enter(compiler, args, scratches, saveds, local_size);
+       sljit_si i, tmp, offs;
 
-       compiler->scratches = scratches;
-       compiler->saveds = saveds;
-#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
-       compiler->logical_local_size = local_size;
-#endif
+       CHECK_ERROR();
+       CHECK(check_sljit_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size));
+       set_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
 
        FAIL_IF(push_inst(compiler, MFLR | D(0)));
-       FAIL_IF(push_inst(compiler, STACK_STORE | S(TMP_ZERO) | A(SLJIT_LOCALS_REG) | IMM(-(sljit_si)(sizeof(sljit_sw))) ));
-       if (saveds >= 1)
-               FAIL_IF(push_inst(compiler, STACK_STORE | S(SLJIT_SAVED_REG1) | A(SLJIT_LOCALS_REG) | IMM(-2 * (sljit_si)(sizeof(sljit_sw))) ));
-       if (saveds >= 2)
-               FAIL_IF(push_inst(compiler, STACK_STORE | S(SLJIT_SAVED_REG2) | A(SLJIT_LOCALS_REG) | IMM(-3 * (sljit_si)(sizeof(sljit_sw))) ));
-       if (saveds >= 3)
-               FAIL_IF(push_inst(compiler, STACK_STORE | S(SLJIT_SAVED_REG3) | A(SLJIT_LOCALS_REG) | IMM(-4 * (sljit_si)(sizeof(sljit_sw))) ));
-       if (saveds >= 4)
-               FAIL_IF(push_inst(compiler, STACK_STORE | S(SLJIT_SAVED_EREG1) | A(SLJIT_LOCALS_REG) | IMM(-5 * (sljit_si)(sizeof(sljit_sw))) ));
-       if (saveds >= 5)
-               FAIL_IF(push_inst(compiler, STACK_STORE | S(SLJIT_SAVED_EREG2) | A(SLJIT_LOCALS_REG) | IMM(-6 * (sljit_si)(sizeof(sljit_sw))) ));
+       offs = -(sljit_si)(sizeof(sljit_sw));
+       FAIL_IF(push_inst(compiler, STACK_STORE | S(TMP_ZERO) | A(SLJIT_SP) | IMM(offs)));
+
+       tmp = saveds < SLJIT_NUMBER_OF_SAVED_REGISTERS ? (SLJIT_S0 + 1 - saveds) : SLJIT_FIRST_SAVED_REG;
+       for (i = SLJIT_S0; i >= tmp; i--) {
+               offs -= (sljit_si)(sizeof(sljit_sw));
+               FAIL_IF(push_inst(compiler, STACK_STORE | S(i) | A(SLJIT_SP) | IMM(offs)));
+       }
+
+       for (i = scratches; i >= SLJIT_FIRST_SAVED_REG; i--) {
+               offs -= (sljit_si)(sizeof(sljit_sw));
+               FAIL_IF(push_inst(compiler, STACK_STORE | S(i) | A(SLJIT_SP) | IMM(offs)));
+       }
+
+       SLJIT_ASSERT(offs == -(sljit_si)GET_SAVED_REGISTERS_SIZE(compiler->scratches, compiler->saveds, 1));
+
 #if (defined SLJIT_PPC_STACK_FRAME_V2 && SLJIT_PPC_STACK_FRAME_V2)
-       FAIL_IF(push_inst(compiler, STACK_STORE | S(0) | A(SLJIT_LOCALS_REG) | IMM(2 * sizeof(sljit_sw)) ));
+       FAIL_IF(push_inst(compiler, STACK_STORE | S(0) | A(SLJIT_SP) | IMM(2 * sizeof(sljit_sw))));
 #else
-       FAIL_IF(push_inst(compiler, STACK_STORE | S(0) | A(SLJIT_LOCALS_REG) | IMM(sizeof(sljit_sw)) ));
+       FAIL_IF(push_inst(compiler, STACK_STORE | S(0) | A(SLJIT_SP) | IMM(sizeof(sljit_sw))));
 #endif
 
        FAIL_IF(push_inst(compiler, ADDI | D(TMP_ZERO) | A(0) | 0));
        if (args >= 1)
-               FAIL_IF(push_inst(compiler, OR | S(SLJIT_SCRATCH_REG1) | A(SLJIT_SAVED_REG1) | B(SLJIT_SCRATCH_REG1)));
+               FAIL_IF(push_inst(compiler, OR | S(SLJIT_R0) | A(SLJIT_S0) | B(SLJIT_R0)));
        if (args >= 2)
-               FAIL_IF(push_inst(compiler, OR | S(SLJIT_SCRATCH_REG2) | A(SLJIT_SAVED_REG2) | B(SLJIT_SCRATCH_REG2)));
+               FAIL_IF(push_inst(compiler, OR | S(SLJIT_R1) | A(SLJIT_S1) | B(SLJIT_R1)));
        if (args >= 3)
-               FAIL_IF(push_inst(compiler, OR | S(SLJIT_SCRATCH_REG3) | A(SLJIT_SAVED_REG3) | B(SLJIT_SCRATCH_REG3)));
+               FAIL_IF(push_inst(compiler, OR | S(SLJIT_R2) | A(SLJIT_S2) | B(SLJIT_R2)));
 
-#if (defined SLJIT_PPC_STACK_FRAME_V2 && SLJIT_PPC_STACK_FRAME_V2)
-       compiler->local_size = (1 + saveds + 6 + 8) * sizeof(sljit_sw) + local_size;
-#else
-       compiler->local_size = (1 + saveds + 2) * sizeof(sljit_sw) + local_size;
-#endif
-       compiler->local_size = (compiler->local_size + 15) & ~0xf;
+       local_size += GET_SAVED_REGISTERS_SIZE(scratches, saveds, 1) + SLJIT_LOCALS_OFFSET;
+       local_size = (local_size + 15) & ~0xf;
+       compiler->local_size = local_size;
 
 #if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32)
-       if (compiler->local_size <= SIMM_MAX)
-               FAIL_IF(push_inst(compiler, STWU | S(SLJIT_LOCALS_REG) | A(SLJIT_LOCALS_REG) | IMM(-compiler->local_size)));
+       if (local_size <= SIMM_MAX)
+               FAIL_IF(push_inst(compiler, STWU | S(SLJIT_SP) | A(SLJIT_SP) | IMM(-local_size)));
        else {
-               FAIL_IF(load_immediate(compiler, 0, -compiler->local_size));
-               FAIL_IF(push_inst(compiler, STWUX | S(SLJIT_LOCALS_REG) | A(SLJIT_LOCALS_REG) | B(0)));
+               FAIL_IF(load_immediate(compiler, 0, -local_size));
+               FAIL_IF(push_inst(compiler, STWUX | S(SLJIT_SP) | A(SLJIT_SP) | B(0)));
        }
 #else
-       if (compiler->local_size <= SIMM_MAX)
-               FAIL_IF(push_inst(compiler, STDU | S(SLJIT_LOCALS_REG) | A(SLJIT_LOCALS_REG) | IMM(-compiler->local_size)));
+       if (local_size <= SIMM_MAX)
+               FAIL_IF(push_inst(compiler, STDU | S(SLJIT_SP) | A(SLJIT_SP) | IMM(-local_size)));
        else {
-               FAIL_IF(load_immediate(compiler, 0, -compiler->local_size));
-               FAIL_IF(push_inst(compiler, STDUX | S(SLJIT_LOCALS_REG) | A(SLJIT_LOCALS_REG) | B(0)));
+               FAIL_IF(load_immediate(compiler, 0, -local_size));
+               FAIL_IF(push_inst(compiler, STDUX | S(SLJIT_SP) | A(SLJIT_SP) | B(0)));
        }
 #endif
 
        return SLJIT_SUCCESS;
 }
 
-SLJIT_API_FUNC_ATTRIBUTE void sljit_set_context(struct sljit_compiler *compiler, sljit_si args, sljit_si scratches, sljit_si saveds, sljit_si local_size)
+SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_set_context(struct sljit_compiler *compiler,
+       sljit_si options, sljit_si args, sljit_si scratches, sljit_si saveds,
+       sljit_si fscratches, sljit_si fsaveds, sljit_si local_size)
 {
-       CHECK_ERROR_VOID();
-       check_sljit_set_context(compiler, args, scratches, saveds, local_size);
-
-       compiler->scratches = scratches;
-       compiler->saveds = saveds;
-#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
-       compiler->logical_local_size = local_size;
-#endif
+       CHECK_ERROR();
+       CHECK(check_sljit_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size));
+       set_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
 
-#if (defined SLJIT_PPC_STACK_FRAME_V2 && SLJIT_PPC_STACK_FRAME_V2)
-       compiler->local_size = (1 + saveds + 6 + 8) * sizeof(sljit_sw) + local_size;
-#else
-       compiler->local_size = (1 + saveds + 2) * sizeof(sljit_sw) + local_size;
-#endif
-       compiler->local_size = (compiler->local_size + 15) & ~0xf;
+       local_size += GET_SAVED_REGISTERS_SIZE(scratches, saveds, 1) + SLJIT_LOCALS_OFFSET;
+       compiler->local_size = (local_size + 15) & ~0xf;
+       return SLJIT_SUCCESS;
 }
 
 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_return(struct sljit_compiler *compiler, sljit_si op, sljit_si src, sljit_sw srcw)
 {
+       sljit_si i, tmp, offs;
+
        CHECK_ERROR();
-       check_sljit_emit_return(compiler, op, src, srcw);
+       CHECK(check_sljit_emit_return(compiler, op, src, srcw));
 
        FAIL_IF(emit_mov_before_return(compiler, op, src, srcw));
 
        if (compiler->local_size <= SIMM_MAX)
-               FAIL_IF(push_inst(compiler, ADDI | D(SLJIT_LOCALS_REG) | A(SLJIT_LOCALS_REG) | IMM(compiler->local_size)));
+               FAIL_IF(push_inst(compiler, ADDI | D(SLJIT_SP) | A(SLJIT_SP) | IMM(compiler->local_size)));
        else {
                FAIL_IF(load_immediate(compiler, 0, compiler->local_size));
-               FAIL_IF(push_inst(compiler, ADD | D(SLJIT_LOCALS_REG) | A(SLJIT_LOCALS_REG) | B(0)));
+               FAIL_IF(push_inst(compiler, ADD | D(SLJIT_SP) | A(SLJIT_SP) | B(0)));
        }
 
 #if (defined SLJIT_PPC_STACK_FRAME_V2 && SLJIT_PPC_STACK_FRAME_V2)
-       FAIL_IF(push_inst(compiler, STACK_LOAD | D(0) | A(SLJIT_LOCALS_REG) | IMM(2 * sizeof(sljit_sw))));
+       FAIL_IF(push_inst(compiler, STACK_LOAD | D(0) | A(SLJIT_SP) | IMM(2 * sizeof(sljit_sw))));
 #else
-       FAIL_IF(push_inst(compiler, STACK_LOAD | D(0) | A(SLJIT_LOCALS_REG) | IMM(sizeof(sljit_sw))));
+       FAIL_IF(push_inst(compiler, STACK_LOAD | D(0) | A(SLJIT_SP) | IMM(sizeof(sljit_sw))));
 #endif
-       if (compiler->saveds >= 5)
-               FAIL_IF(push_inst(compiler, STACK_LOAD | D(SLJIT_SAVED_EREG2) | A(SLJIT_LOCALS_REG) | IMM(-6 * (sljit_si)(sizeof(sljit_sw))) ));
-       if (compiler->saveds >= 4)
-               FAIL_IF(push_inst(compiler, STACK_LOAD | D(SLJIT_SAVED_EREG1) | A(SLJIT_LOCALS_REG) | IMM(-5 * (sljit_si)(sizeof(sljit_sw))) ));
-       if (compiler->saveds >= 3)
-               FAIL_IF(push_inst(compiler, STACK_LOAD | D(SLJIT_SAVED_REG3) | A(SLJIT_LOCALS_REG) | IMM(-4 * (sljit_si)(sizeof(sljit_sw))) ));
-       if (compiler->saveds >= 2)
-               FAIL_IF(push_inst(compiler, STACK_LOAD | D(SLJIT_SAVED_REG2) | A(SLJIT_LOCALS_REG) | IMM(-3 * (sljit_si)(sizeof(sljit_sw))) ));
-       if (compiler->saveds >= 1)
-               FAIL_IF(push_inst(compiler, STACK_LOAD | D(SLJIT_SAVED_REG1) | A(SLJIT_LOCALS_REG) | IMM(-2 * (sljit_si)(sizeof(sljit_sw))) ));
-       FAIL_IF(push_inst(compiler, STACK_LOAD | D(TMP_ZERO) | A(SLJIT_LOCALS_REG) | IMM(-(sljit_si)(sizeof(sljit_sw))) ));
+
+       offs = -(sljit_si)GET_SAVED_REGISTERS_SIZE(compiler->scratches, compiler->saveds, 1);
+
+       tmp = compiler->scratches;
+       for (i = SLJIT_FIRST_SAVED_REG; i <= tmp; i++) {
+               FAIL_IF(push_inst(compiler, STACK_LOAD | D(i) | A(SLJIT_SP) | IMM(offs)));
+               offs += (sljit_si)(sizeof(sljit_sw));
+       }
+
+       tmp = compiler->saveds < SLJIT_NUMBER_OF_SAVED_REGISTERS ? (SLJIT_S0 + 1 - compiler->saveds) : SLJIT_FIRST_SAVED_REG;
+       for (i = tmp; i <= SLJIT_S0; i++) {
+               FAIL_IF(push_inst(compiler, STACK_LOAD | D(i) | A(SLJIT_SP) | IMM(offs)));
+               offs += (sljit_si)(sizeof(sljit_sw));
+       }
+
+       FAIL_IF(push_inst(compiler, STACK_LOAD | D(TMP_ZERO) | A(SLJIT_SP) | IMM(offs)));
+       SLJIT_ASSERT(offs == -(sljit_sw)(sizeof(sljit_sw)));
 
        FAIL_IF(push_inst(compiler, MTLR | S(0)));
        FAIL_IF(push_inst(compiler, BLR));
@@ -999,12 +1008,12 @@ static sljit_si getput_arg(struct sljit_compiler *compiler, sljit_si inp_flags,
                        tmp_r = arg;
                        FAIL_IF(push_inst(compiler, ADDIS | D(arg) | A(arg) | IMM(high_short >> 16)));
                }
-               else if (compiler->cache_arg != arg || high_short != compiler->cache_argw) {
+               else if (compiler->cache_arg != (SLJIT_MEM | arg) || high_short != compiler->cache_argw) {
                        if ((next_arg & SLJIT_MEM) && !(next_arg & OFFS_REG_MASK)) {
                                next_high_short = (sljit_si)(next_argw + ((next_argw & 0x8000) << 1)) & ~0xffff;
                                if (high_short == next_high_short) {
-                                       compiler->cache_arg = SLJIT_IMM | arg;
-                                       compiler->cache_argw = next_high_short;
+                                       compiler->cache_arg = SLJIT_MEM | arg;
+                                       compiler->cache_argw = high_short;
                                        tmp_r = TMP_REG3;
                                }
                        }
@@ -1241,39 +1250,40 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler
 #endif
 
        CHECK_ERROR();
-       check_sljit_emit_op0(compiler, op);
+       CHECK(check_sljit_emit_op0(compiler, op));
 
        op = GET_OPCODE(op);
        switch (op) {
        case SLJIT_BREAKPOINT:
        case SLJIT_NOP:
                return push_inst(compiler, NOP);
-       case SLJIT_UMUL:
-       case SLJIT_SMUL:
-               FAIL_IF(push_inst(compiler, OR | S(SLJIT_SCRATCH_REG1) | A(TMP_REG1) | B(SLJIT_SCRATCH_REG1)));
+       case SLJIT_LUMUL:
+       case SLJIT_LSMUL:
+               FAIL_IF(push_inst(compiler, OR | S(SLJIT_R0) | A(TMP_REG1) | B(SLJIT_R0)));
 #if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
-               FAIL_IF(push_inst(compiler, MULLD | D(SLJIT_SCRATCH_REG1) | A(TMP_REG1) | B(SLJIT_SCRATCH_REG2)));
-               return push_inst(compiler, (op == SLJIT_UMUL ? MULHDU : MULHD) | D(SLJIT_SCRATCH_REG2) | A(TMP_REG1) | B(SLJIT_SCRATCH_REG2));
+               FAIL_IF(push_inst(compiler, MULLD | D(SLJIT_R0) | A(TMP_REG1) | B(SLJIT_R1)));
+               return push_inst(compiler, (op == SLJIT_LUMUL ? MULHDU : MULHD) | D(SLJIT_R1) | A(TMP_REG1) | B(SLJIT_R1));
 #else
-               FAIL_IF(push_inst(compiler, MULLW | D(SLJIT_SCRATCH_REG1) | A(TMP_REG1) | B(SLJIT_SCRATCH_REG2)));
-               return push_inst(compiler, (op == SLJIT_UMUL ? MULHWU : MULHW) | D(SLJIT_SCRATCH_REG2) | A(TMP_REG1) | B(SLJIT_SCRATCH_REG2));
+               FAIL_IF(push_inst(compiler, MULLW | D(SLJIT_R0) | A(TMP_REG1) | B(SLJIT_R1)));
+               return push_inst(compiler, (op == SLJIT_LUMUL ? MULHWU : MULHW) | D(SLJIT_R1) | A(TMP_REG1) | B(SLJIT_R1));
 #endif
-       case SLJIT_UDIV:
-       case SLJIT_SDIV:
-               FAIL_IF(push_inst(compiler, OR | S(SLJIT_SCRATCH_REG1) | A(TMP_REG1) | B(SLJIT_SCRATCH_REG1)));
+       case SLJIT_UDIVMOD:
+       case SLJIT_SDIVMOD:
+               FAIL_IF(push_inst(compiler, OR | S(SLJIT_R0) | A(TMP_REG1) | B(SLJIT_R0)));
 #if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
-               if (int_op) {
-                       FAIL_IF(push_inst(compiler, (op == SLJIT_UDIV ? DIVWU : DIVW) | D(SLJIT_SCRATCH_REG1) | A(TMP_REG1) | B(SLJIT_SCRATCH_REG2)));
-                       FAIL_IF(push_inst(compiler, MULLW | D(SLJIT_SCRATCH_REG2) | A(SLJIT_SCRATCH_REG1) | B(SLJIT_SCRATCH_REG2)));
-               } else {
-                       FAIL_IF(push_inst(compiler, (op == SLJIT_UDIV ? DIVDU : DIVD) | D(SLJIT_SCRATCH_REG1) | A(TMP_REG1) | B(SLJIT_SCRATCH_REG2)));
-                       FAIL_IF(push_inst(compiler, MULLD | D(SLJIT_SCRATCH_REG2) | A(SLJIT_SCRATCH_REG1) | B(SLJIT_SCRATCH_REG2)));
-               }
-               return push_inst(compiler, SUBF | D(SLJIT_SCRATCH_REG2) | A(SLJIT_SCRATCH_REG2) | B(TMP_REG1));
+               FAIL_IF(push_inst(compiler, (int_op ? (op == SLJIT_UDIVMOD ? DIVWU : DIVW) : (op == SLJIT_UDIVMOD ? DIVDU : DIVD)) | D(SLJIT_R0) | A(SLJIT_R0) | B(SLJIT_R1)));
+               FAIL_IF(push_inst(compiler, (int_op ? MULLW : MULLD) | D(SLJIT_R1) | A(SLJIT_R0) | B(SLJIT_R1)));
 #else
-               FAIL_IF(push_inst(compiler, (op == SLJIT_UDIV ? DIVWU : DIVW) | D(SLJIT_SCRATCH_REG1) | A(TMP_REG1) | B(SLJIT_SCRATCH_REG2)));
-               FAIL_IF(push_inst(compiler, MULLW | D(SLJIT_SCRATCH_REG2) | A(SLJIT_SCRATCH_REG1) | B(SLJIT_SCRATCH_REG2)));
-               return push_inst(compiler, SUBF | D(SLJIT_SCRATCH_REG2) | A(SLJIT_SCRATCH_REG2) | B(TMP_REG1));
+               FAIL_IF(push_inst(compiler, (op == SLJIT_UDIVMOD ? DIVWU : DIVW) | D(SLJIT_R0) | A(SLJIT_R0) | B(SLJIT_R1)));
+               FAIL_IF(push_inst(compiler, MULLW | D(SLJIT_R1) | A(SLJIT_R0) | B(SLJIT_R1)));
+#endif
+               return push_inst(compiler, SUBF | D(SLJIT_R1) | A(SLJIT_R1) | B(TMP_REG1));
+       case SLJIT_UDIVI:
+       case SLJIT_SDIVI:
+#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
+               return push_inst(compiler, (int_op ? (op == SLJIT_UDIVI ? DIVWU : DIVW) : (op == SLJIT_UDIVI ? DIVDU : DIVD)) | D(SLJIT_R0) | A(SLJIT_R0) | B(SLJIT_R1));
+#else
+               return push_inst(compiler, (op == SLJIT_UDIVI ? DIVWU : DIVW) | D(SLJIT_R0) | A(SLJIT_R0) | B(SLJIT_R1));
 #endif
        }
 
@@ -1291,7 +1301,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op1(struct sljit_compiler *compiler
        sljit_si op_flags = GET_ALL_FLAGS(op);
 
        CHECK_ERROR();
-       check_sljit_emit_op1(compiler, op, dst, dstw, src, srcw);
+       CHECK(check_sljit_emit_op1(compiler, op, dst, dstw, src, srcw));
        ADJUST_LOCAL_OFFSET(dst, dstw);
        ADJUST_LOCAL_OFFSET(src, srcw);
 
@@ -1446,7 +1456,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op2(struct sljit_compiler *compiler
        sljit_si flags = GET_FLAGS(op) ? ALT_SET_FLAGS : 0;
 
        CHECK_ERROR();
-       check_sljit_emit_op2(compiler, op, dst, dstw, src1, src1w, src2, src2w);
+       CHECK(check_sljit_emit_op2(compiler, op, dst, dstw, src1, src1w, src2, src2w));
        ADJUST_LOCAL_OFFSET(dst, dstw);
        ADJUST_LOCAL_OFFSET(src1, src1w);
        ADJUST_LOCAL_OFFSET(src2, src2w);
@@ -1648,13 +1658,13 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op2(struct sljit_compiler *compiler
 
 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_get_register_index(sljit_si reg)
 {
-       check_sljit_get_register_index(reg);
+       CHECK_REG_INDEX(check_sljit_get_register_index(reg));
        return reg_map[reg];
 }
 
 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_get_float_register_index(sljit_si reg)
 {
-       check_sljit_get_float_register_index(reg);
+       CHECK_REG_INDEX(check_sljit_get_float_register_index(reg));
        return reg;
 }
 
@@ -1662,8 +1672,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_custom(struct sljit_compiler *co
        void *instruction, sljit_si size)
 {
        CHECK_ERROR();
-       check_sljit_emit_op_custom(compiler, instruction, size);
-       SLJIT_ASSERT(size == 4);
+       CHECK(check_sljit_emit_op_custom(compiler, instruction, size));
 
        return push_inst(compiler, *(sljit_ins*)instruction);
 }
@@ -1685,59 +1694,233 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_is_fpu_available(void)
 #define FLOAT_DATA(op) (DOUBLE_DATA | ((op & SLJIT_SINGLE_OP) >> 6))
 #define SELECT_FOP(op, single, double) ((op & SLJIT_SINGLE_OP) ? single : double)
 
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop1(struct sljit_compiler *compiler, sljit_si op,
+#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
+#define FLOAT_TMP_MEM_OFFSET (6 * sizeof(sljit_sw))
+#else
+#define FLOAT_TMP_MEM_OFFSET (2 * sizeof(sljit_sw))
+
+#if (defined SLJIT_LITTLE_ENDIAN && SLJIT_LITTLE_ENDIAN)
+#define FLOAT_TMP_MEM_OFFSET_LOW (2 * sizeof(sljit_sw))
+#define FLOAT_TMP_MEM_OFFSET_HI (3 * sizeof(sljit_sw))
+#else
+#define FLOAT_TMP_MEM_OFFSET_LOW (3 * sizeof(sljit_sw))
+#define FLOAT_TMP_MEM_OFFSET_HI (2 * sizeof(sljit_sw))
+#endif
+
+#endif /* SLJIT_CONFIG_PPC_64 */
+
+static SLJIT_INLINE sljit_si sljit_emit_fop1_convw_fromd(struct sljit_compiler *compiler, sljit_si op,
        sljit_si dst, sljit_sw dstw,
        sljit_si src, sljit_sw srcw)
 {
-       sljit_si dst_fr;
+       if (src & SLJIT_MEM) {
+               /* We can ignore the temporary data store on the stack from caching point of view. */
+               FAIL_IF(emit_op_mem2(compiler, FLOAT_DATA(op) | LOAD_DATA, TMP_FREG1, src, srcw, dst, dstw));
+               src = TMP_FREG1;
+       }
 
-       CHECK_ERROR();
-       check_sljit_emit_fop1(compiler, op, dst, dstw, src, srcw);
-       SLJIT_COMPILE_ASSERT((SLJIT_SINGLE_OP == 0x100) && !(DOUBLE_DATA & 0x4), float_transfer_bit_error);
+#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
+       op = GET_OPCODE(op);
+       FAIL_IF(push_inst(compiler, (op == SLJIT_CONVI_FROMD ? FCTIWZ : FCTIDZ) | FD(TMP_FREG1) | FB(src)));
 
-       compiler->cache_arg = 0;
-       compiler->cache_argw = 0;
+       if (dst == SLJIT_UNUSED)
+               return SLJIT_SUCCESS;
 
-       if (GET_OPCODE(op) == SLJIT_CMPD) {
-               if (dst & SLJIT_MEM) {
-                       FAIL_IF(emit_op_mem2(compiler, FLOAT_DATA(op) | LOAD_DATA, TMP_FREG1, dst, dstw, src, srcw));
-                       dst = TMP_FREG1;
+       if (op == SLJIT_CONVW_FROMD) {
+               if (FAST_IS_REG(dst)) {
+                       FAIL_IF(emit_op_mem2(compiler, DOUBLE_DATA, TMP_FREG1, SLJIT_MEM1(SLJIT_SP), FLOAT_TMP_MEM_OFFSET, 0, 0));
+                       return emit_op_mem2(compiler, WORD_DATA | LOAD_DATA, dst, SLJIT_MEM1(SLJIT_SP), FLOAT_TMP_MEM_OFFSET, 0, 0);
                }
+               return emit_op_mem2(compiler, DOUBLE_DATA, TMP_FREG1, dst, dstw, 0, 0);
+       }
 
-               if (src & SLJIT_MEM) {
-                       FAIL_IF(emit_op_mem2(compiler, FLOAT_DATA(op) | LOAD_DATA, TMP_FREG2, src, srcw, 0, 0));
-                       src = TMP_FREG2;
+#else
+       FAIL_IF(push_inst(compiler, FCTIWZ | FD(TMP_FREG1) | FB(src)));
+
+       if (dst == SLJIT_UNUSED)
+               return SLJIT_SUCCESS;
+#endif
+
+       if (FAST_IS_REG(dst)) {
+               FAIL_IF(load_immediate(compiler, TMP_REG1, FLOAT_TMP_MEM_OFFSET));
+               FAIL_IF(push_inst(compiler, STFIWX | FS(TMP_FREG1) | A(SLJIT_SP) | B(TMP_REG1)));
+               return emit_op_mem2(compiler, INT_DATA | LOAD_DATA, dst, SLJIT_MEM1(SLJIT_SP), FLOAT_TMP_MEM_OFFSET, 0, 0);
+       }
+
+       SLJIT_ASSERT(dst & SLJIT_MEM);
+
+       if (dst & OFFS_REG_MASK) {
+               dstw &= 0x3;
+               if (dstw) {
+#if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32)
+                       FAIL_IF(push_inst(compiler, RLWINM | S(OFFS_REG(dst)) | A(TMP_REG1) | (dstw << 11) | ((31 - dstw) << 1)));
+#else
+                       FAIL_IF(push_inst(compiler, RLDI(TMP_REG1, OFFS_REG(dst), dstw, 63 - dstw, 1)));
+#endif
+                       dstw = TMP_REG1;
+               }
+               else
+                       dstw = OFFS_REG(dst);
+       }
+       else {
+               if ((dst & REG_MASK) && !dstw) {
+                       dstw = dst & REG_MASK;
+                       dst = 0;
+               }
+               else {
+                       /* This works regardless we have SLJIT_MEM1 or SLJIT_MEM0. */
+                       FAIL_IF(load_immediate(compiler, TMP_REG1, dstw));
+                       dstw = TMP_REG1;
                }
+       }
+
+       return push_inst(compiler, STFIWX | FS(TMP_FREG1) | A(dst & REG_MASK) | B(dstw));
+}
 
-               return push_inst(compiler, FCMPU | CRD(4) | FA(dst) | FB(src));
+static SLJIT_INLINE sljit_si sljit_emit_fop1_convd_fromw(struct sljit_compiler *compiler, sljit_si op,
+       sljit_si dst, sljit_sw dstw,
+       sljit_si src, sljit_sw srcw)
+{
+#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
+
+       sljit_si dst_r = FAST_IS_REG(dst) ? dst : TMP_FREG1;
+
+       if (src & SLJIT_IMM) {
+               if (GET_OPCODE(op) == SLJIT_CONVD_FROMI)
+                       srcw = (sljit_si)srcw;
+               FAIL_IF(load_immediate(compiler, TMP_REG1, srcw));
+               src = TMP_REG1;
        }
+       else if (GET_OPCODE(op) == SLJIT_CONVD_FROMI) {
+               if (FAST_IS_REG(src))
+                       FAIL_IF(push_inst(compiler, EXTSW | S(src) | A(TMP_REG1)));
+               else
+                       FAIL_IF(emit_op_mem2(compiler, INT_DATA | SIGNED_DATA | LOAD_DATA, TMP_REG1, src, srcw, SLJIT_MEM1(SLJIT_SP), FLOAT_TMP_MEM_OFFSET));
+               src = TMP_REG1;
+       }
+
+       if (FAST_IS_REG(src)) {
+               FAIL_IF(emit_op_mem2(compiler, WORD_DATA, src, SLJIT_MEM1(SLJIT_SP), FLOAT_TMP_MEM_OFFSET, SLJIT_MEM1(SLJIT_SP), FLOAT_TMP_MEM_OFFSET));
+               FAIL_IF(emit_op_mem2(compiler, DOUBLE_DATA | LOAD_DATA, TMP_FREG1, SLJIT_MEM1(SLJIT_SP), FLOAT_TMP_MEM_OFFSET, dst, dstw));
+       }
+       else
+               FAIL_IF(emit_op_mem2(compiler, DOUBLE_DATA | LOAD_DATA, TMP_FREG1, src, srcw, dst, dstw));
+
+       FAIL_IF(push_inst(compiler, FCFID | FD(dst_r) | FB(TMP_FREG1)));
+
+       if (dst & SLJIT_MEM)
+               return emit_op_mem2(compiler, FLOAT_DATA(op), TMP_FREG1, dst, dstw, 0, 0);
+       if (op & SLJIT_SINGLE_OP)
+               return push_inst(compiler, FRSP | FD(dst_r) | FB(dst_r));
+       return SLJIT_SUCCESS;
+
+#else
 
-       dst_fr = FAST_IS_REG(dst) ? dst : TMP_FREG1;
+       sljit_si dst_r = FAST_IS_REG(dst) ? dst : TMP_FREG1;
+       sljit_si invert_sign = 1;
+
+       if (src & SLJIT_IMM) {
+               FAIL_IF(load_immediate(compiler, TMP_REG1, srcw ^ 0x80000000));
+               src = TMP_REG1;
+               invert_sign = 0;
+       }
+       else if (!FAST_IS_REG(src)) {
+               FAIL_IF(emit_op_mem2(compiler, WORD_DATA | SIGNED_DATA | LOAD_DATA, TMP_REG1, src, srcw, SLJIT_MEM1(SLJIT_SP), FLOAT_TMP_MEM_OFFSET_LOW));
+               src = TMP_REG1;
+       }
+
+       /* First, a special double floating point value is constructed: (2^53 + (input xor (2^31)))
+          The double precision format has exactly 53 bit precision, so the lower 32 bit represents
+          the lower 32 bit of such value. The result of xor 2^31 is the same as adding 0x80000000
+          to the input, which shifts it into the 0 - 0xffffffff range. To get the converted floating
+          point value, we need to substract 2^53 + 2^31 from the constructed value. */
+       FAIL_IF(push_inst(compiler, ADDIS | D(TMP_REG2) | A(0) | 0x4330));
+       if (invert_sign)
+               FAIL_IF(push_inst(compiler, XORIS | S(src) | A(TMP_REG1) | 0x8000));
+       FAIL_IF(emit_op_mem2(compiler, WORD_DATA, TMP_REG2, SLJIT_MEM1(SLJIT_SP), FLOAT_TMP_MEM_OFFSET_HI, SLJIT_MEM1(SLJIT_SP), FLOAT_TMP_MEM_OFFSET));
+       FAIL_IF(emit_op_mem2(compiler, WORD_DATA, TMP_REG1, SLJIT_MEM1(SLJIT_SP), FLOAT_TMP_MEM_OFFSET_LOW, SLJIT_MEM1(SLJIT_SP), FLOAT_TMP_MEM_OFFSET_HI));
+       FAIL_IF(push_inst(compiler, ADDIS | D(TMP_REG1) | A(0) | 0x8000));
+       FAIL_IF(emit_op_mem2(compiler, DOUBLE_DATA | LOAD_DATA, TMP_FREG1, SLJIT_MEM1(SLJIT_SP), FLOAT_TMP_MEM_OFFSET, SLJIT_MEM1(SLJIT_SP), FLOAT_TMP_MEM_OFFSET_LOW));
+       FAIL_IF(emit_op_mem2(compiler, WORD_DATA, TMP_REG1, SLJIT_MEM1(SLJIT_SP), FLOAT_TMP_MEM_OFFSET_LOW, SLJIT_MEM1(SLJIT_SP), FLOAT_TMP_MEM_OFFSET));
+       FAIL_IF(emit_op_mem2(compiler, DOUBLE_DATA | LOAD_DATA, TMP_FREG2, SLJIT_MEM1(SLJIT_SP), FLOAT_TMP_MEM_OFFSET, SLJIT_MEM1(SLJIT_SP), FLOAT_TMP_MEM_OFFSET_LOW));
+
+       FAIL_IF(push_inst(compiler, FSUB | FD(dst_r) | FA(TMP_FREG1) | FB(TMP_FREG2)));
+
+       if (dst & SLJIT_MEM)
+               return emit_op_mem2(compiler, FLOAT_DATA(op), TMP_FREG1, dst, dstw, 0, 0);
+       if (op & SLJIT_SINGLE_OP)
+               return push_inst(compiler, FRSP | FD(dst_r) | FB(dst_r));
+       return SLJIT_SUCCESS;
+
+#endif
+}
+
+static SLJIT_INLINE sljit_si sljit_emit_fop1_cmp(struct sljit_compiler *compiler, sljit_si op,
+       sljit_si src1, sljit_sw src1w,
+       sljit_si src2, sljit_sw src2w)
+{
+       if (src1 & SLJIT_MEM) {
+               FAIL_IF(emit_op_mem2(compiler, FLOAT_DATA(op) | LOAD_DATA, TMP_FREG1, src1, src1w, src2, src2w));
+               src1 = TMP_FREG1;
+       }
+
+       if (src2 & SLJIT_MEM) {
+               FAIL_IF(emit_op_mem2(compiler, FLOAT_DATA(op) | LOAD_DATA, TMP_FREG2, src2, src2w, 0, 0));
+               src2 = TMP_FREG2;
+       }
+
+       return push_inst(compiler, FCMPU | CRD(4) | FA(src1) | FB(src2));
+}
+
+SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop1(struct sljit_compiler *compiler, sljit_si op,
+       sljit_si dst, sljit_sw dstw,
+       sljit_si src, sljit_sw srcw)
+{
+       sljit_si dst_r;
+
+       CHECK_ERROR();
+       compiler->cache_arg = 0;
+       compiler->cache_argw = 0;
+
+       SLJIT_COMPILE_ASSERT((SLJIT_SINGLE_OP == 0x100) && !(DOUBLE_DATA & 0x4), float_transfer_bit_error);
+       SELECT_FOP1_OPERATION_WITH_CHECKS(compiler, op, dst, dstw, src, srcw);
+
+       if (GET_OPCODE(op) == SLJIT_CONVD_FROMS)
+               op ^= SLJIT_SINGLE_OP;
+
+       dst_r = FAST_IS_REG(dst) ? dst : TMP_FREG1;
 
        if (src & SLJIT_MEM) {
-               FAIL_IF(emit_op_mem2(compiler, FLOAT_DATA(op) | LOAD_DATA, dst_fr, src, srcw, dst, dstw));
-               src = dst_fr;
+               FAIL_IF(emit_op_mem2(compiler, FLOAT_DATA(op) | LOAD_DATA, dst_r, src, srcw, dst, dstw));
+               src = dst_r;
        }
 
        switch (GET_OPCODE(op)) {
-               case SLJIT_MOVD:
-                       if (src != dst_fr && dst_fr != TMP_FREG1)
-                               FAIL_IF(push_inst(compiler, FMR | FD(dst_fr) | FB(src)));
-                       break;
-               case SLJIT_NEGD:
-                       FAIL_IF(push_inst(compiler, FNEG | FD(dst_fr) | FB(src)));
-                       break;
-               case SLJIT_ABSD:
-                       FAIL_IF(push_inst(compiler, FABS | FD(dst_fr) | FB(src)));
+       case SLJIT_CONVD_FROMS:
+               op ^= SLJIT_SINGLE_OP;
+               if (op & SLJIT_SINGLE_OP) {
+                       FAIL_IF(push_inst(compiler, FRSP | FD(dst_r) | FB(src)));
                        break;
+               }
+               /* Fall through. */
+       case SLJIT_DMOV:
+               if (src != dst_r) {
+                       if (dst_r != TMP_FREG1)
+                               FAIL_IF(push_inst(compiler, FMR | FD(dst_r) | FB(src)));
+                       else
+                               dst_r = src;
+               }
+               break;
+       case SLJIT_DNEG:
+               FAIL_IF(push_inst(compiler, FNEG | FD(dst_r) | FB(src)));
+               break;
+       case SLJIT_DABS:
+               FAIL_IF(push_inst(compiler, FABS | FD(dst_r) | FB(src)));
+               break;
        }
 
-       if (dst_fr == TMP_FREG1) {
-               if (GET_OPCODE(op) == SLJIT_MOVD)
-                       dst_fr = src;
-               FAIL_IF(emit_op_mem2(compiler, FLOAT_DATA(op), dst_fr, dst, dstw, 0, 0));
-       }
-
+       if (dst & SLJIT_MEM)
+               FAIL_IF(emit_op_mem2(compiler, FLOAT_DATA(op), dst_r, dst, dstw, 0, 0));
        return SLJIT_SUCCESS;
 }
 
@@ -1746,15 +1929,18 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop2(struct sljit_compiler *compile
        sljit_si src1, sljit_sw src1w,
        sljit_si src2, sljit_sw src2w)
 {
-       sljit_si dst_fr, flags = 0;
+       sljit_si dst_r, flags = 0;
 
        CHECK_ERROR();
-       check_sljit_emit_fop2(compiler, op, dst, dstw, src1, src1w, src2, src2w);
+       CHECK(check_sljit_emit_fop2(compiler, op, dst, dstw, src1, src1w, src2, src2w));
+       ADJUST_LOCAL_OFFSET(dst, dstw);
+       ADJUST_LOCAL_OFFSET(src1, src1w);
+       ADJUST_LOCAL_OFFSET(src2, src2w);
 
        compiler->cache_arg = 0;
        compiler->cache_argw = 0;
 
-       dst_fr = FAST_IS_REG(dst) ? dst : TMP_FREG2;
+       dst_r = FAST_IS_REG(dst) ? dst : TMP_FREG2;
 
        if (src1 & SLJIT_MEM) {
                if (getput_arg_fast(compiler, FLOAT_DATA(op) | LOAD_DATA, TMP_FREG1, src1, src1w)) {
@@ -1793,24 +1979,24 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop2(struct sljit_compiler *compile
                src2 = TMP_FREG2;
 
        switch (GET_OPCODE(op)) {
-       case SLJIT_ADDD:
-               FAIL_IF(push_inst(compiler, SELECT_FOP(op, FADDS, FADD) | FD(dst_fr) | FA(src1) | FB(src2)));
+       case SLJIT_DADD:
+               FAIL_IF(push_inst(compiler, SELECT_FOP(op, FADDS, FADD) | FD(dst_r) | FA(src1) | FB(src2)));
                break;
 
-       case SLJIT_SUBD:
-               FAIL_IF(push_inst(compiler, SELECT_FOP(op, FSUBS, FSUB) | FD(dst_fr) | FA(src1) | FB(src2)));
+       case SLJIT_DSUB:
+               FAIL_IF(push_inst(compiler, SELECT_FOP(op, FSUBS, FSUB) | FD(dst_r) | FA(src1) | FB(src2)));
                break;
 
-       case SLJIT_MULD:
-               FAIL_IF(push_inst(compiler, SELECT_FOP(op, FMULS, FMUL) | FD(dst_fr) | FA(src1) | FC(src2) /* FMUL use FC as src2 */));
+       case SLJIT_DMUL:
+               FAIL_IF(push_inst(compiler, SELECT_FOP(op, FMULS, FMUL) | FD(dst_r) | FA(src1) | FC(src2) /* FMUL use FC as src2 */));
                break;
 
-       case SLJIT_DIVD:
-               FAIL_IF(push_inst(compiler, SELECT_FOP(op, FDIVS, FDIV) | FD(dst_fr) | FA(src1) | FB(src2)));
+       case SLJIT_DDIV:
+               FAIL_IF(push_inst(compiler, SELECT_FOP(op, FDIVS, FDIV) | FD(dst_r) | FA(src1) | FB(src2)));
                break;
        }
 
-       if (dst_fr == TMP_FREG2)
+       if (dst_r == TMP_FREG2)
                FAIL_IF(emit_op_mem2(compiler, FLOAT_DATA(op), TMP_FREG2, dst, dstw, 0, 0));
 
        return SLJIT_SUCCESS;
@@ -1826,7 +2012,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop2(struct sljit_compiler *compile
 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_enter(struct sljit_compiler *compiler, sljit_si dst, sljit_sw dstw)
 {
        CHECK_ERROR();
-       check_sljit_emit_fast_enter(compiler, dst, dstw);
+       CHECK(check_sljit_emit_fast_enter(compiler, dst, dstw));
        ADJUST_LOCAL_OFFSET(dst, dstw);
 
        /* For UNUSED dst. Uncommon, but possible. */
@@ -1844,7 +2030,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_enter(struct sljit_compiler *c
 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_return(struct sljit_compiler *compiler, sljit_si src, sljit_sw srcw)
 {
        CHECK_ERROR();
-       check_sljit_emit_fast_return(compiler, src, srcw);
+       CHECK(check_sljit_emit_fast_return(compiler, src, srcw));
        ADJUST_LOCAL_OFFSET(src, srcw);
 
        if (FAST_IS_REG(src))
@@ -1868,7 +2054,7 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_label* sljit_emit_label(struct sljit_compi
        struct sljit_label *label;
 
        CHECK_ERROR_PTR();
-       check_sljit_emit_label(compiler);
+       CHECK_PTR(check_sljit_emit_label(compiler));
 
        if (compiler->last_label && compiler->last_label->size == compiler->size)
                return compiler->last_label;
@@ -1882,58 +2068,58 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_label* sljit_emit_label(struct sljit_compi
 static sljit_ins get_bo_bi_flags(sljit_si type)
 {
        switch (type) {
-       case SLJIT_C_EQUAL:
+       case SLJIT_EQUAL:
                return (12 << 21) | (2 << 16);
 
-       case SLJIT_C_NOT_EQUAL:
+       case SLJIT_NOT_EQUAL:
                return (4 << 21) | (2 << 16);
 
-       case SLJIT_C_LESS:
-       case SLJIT_C_FLOAT_LESS:
+       case SLJIT_LESS:
+       case SLJIT_D_LESS:
                return (12 << 21) | ((4 + 0) << 16);
 
-       case SLJIT_C_GREATER_EQUAL:
-       case SLJIT_C_FLOAT_GREATER_EQUAL:
+       case SLJIT_GREATER_EQUAL:
+       case SLJIT_D_GREATER_EQUAL:
                return (4 << 21) | ((4 + 0) << 16);
 
-       case SLJIT_C_GREATER:
-       case SLJIT_C_FLOAT_GREATER:
+       case SLJIT_GREATER:
+       case SLJIT_D_GREATER:
                return (12 << 21) | ((4 + 1) << 16);
 
-       case SLJIT_C_LESS_EQUAL:
-       case SLJIT_C_FLOAT_LESS_EQUAL:
+       case SLJIT_LESS_EQUAL:
+       case SLJIT_D_LESS_EQUAL:
                return (4 << 21) | ((4 + 1) << 16);
 
-       case SLJIT_C_SIG_LESS:
+       case SLJIT_SIG_LESS:
                return (12 << 21) | (0 << 16);
 
-       case SLJIT_C_SIG_GREATER_EQUAL:
+       case SLJIT_SIG_GREATER_EQUAL:
                return (4 << 21) | (0 << 16);
 
-       case SLJIT_C_SIG_GREATER:
+       case SLJIT_SIG_GREATER:
                return (12 << 21) | (1 << 16);
 
-       case SLJIT_C_SIG_LESS_EQUAL:
+       case SLJIT_SIG_LESS_EQUAL:
                return (4 << 21) | (1 << 16);
 
-       case SLJIT_C_OVERFLOW:
-       case SLJIT_C_MUL_OVERFLOW:
+       case SLJIT_OVERFLOW:
+       case SLJIT_MUL_OVERFLOW:
                return (12 << 21) | (3 << 16);
 
-       case SLJIT_C_NOT_OVERFLOW:
-       case SLJIT_C_MUL_NOT_OVERFLOW:
+       case SLJIT_NOT_OVERFLOW:
+       case SLJIT_MUL_NOT_OVERFLOW:
                return (4 << 21) | (3 << 16);
 
-       case SLJIT_C_FLOAT_EQUAL:
+       case SLJIT_D_EQUAL:
                return (12 << 21) | ((4 + 2) << 16);
 
-       case SLJIT_C_FLOAT_NOT_EQUAL:
+       case SLJIT_D_NOT_EQUAL:
                return (4 << 21) | ((4 + 2) << 16);
 
-       case SLJIT_C_FLOAT_UNORDERED:
+       case SLJIT_D_UNORDERED:
                return (12 << 21) | ((4 + 3) << 16);
 
-       case SLJIT_C_FLOAT_ORDERED:
+       case SLJIT_D_ORDERED:
                return (4 << 21) | ((4 + 3) << 16);
 
        default:
@@ -1948,7 +2134,7 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_jump(struct sljit_compile
        sljit_ins bo_bi_flags;
 
        CHECK_ERROR_PTR();
-       check_sljit_emit_jump(compiler, type);
+       CHECK_PTR(check_sljit_emit_jump(compiler, type));
 
        bo_bi_flags = get_bo_bi_flags(type & 0xff);
        if (!bo_bi_flags)
@@ -1980,7 +2166,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_ijump(struct sljit_compiler *compil
        sljit_si src_r;
 
        CHECK_ERROR();
-       check_sljit_emit_ijump(compiler, type, src, srcw);
+       CHECK(check_sljit_emit_ijump(compiler, type, src, srcw));
        ADJUST_LOCAL_OFFSET(src, srcw);
 
        if (FAST_IS_REG(src)) {
@@ -2035,7 +2221,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_flags(struct sljit_compiler *com
        sljit_sw original_dstw = dstw;
 
        CHECK_ERROR();
-       check_sljit_emit_op_flags(compiler, op, dst, dstw, src, srcw, type);
+       CHECK(check_sljit_emit_op_flags(compiler, op, dst, dstw, src, srcw, type));
        ADJUST_LOCAL_OFFSET(dst, dstw);
 
        if (dst == SLJIT_UNUSED)
@@ -2058,81 +2244,81 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_flags(struct sljit_compiler *com
                srcw = 0;
        }
 
-       switch (type) {
-       case SLJIT_C_EQUAL:
+       switch (type & 0xff) {
+       case SLJIT_EQUAL:
                GET_CR_BIT(2, reg);
                break;
 
-       case SLJIT_C_NOT_EQUAL:
+       case SLJIT_NOT_EQUAL:
                GET_CR_BIT(2, reg);
                INVERT_BIT(reg);
                break;
 
-       case SLJIT_C_LESS:
-       case SLJIT_C_FLOAT_LESS:
+       case SLJIT_LESS:
+       case SLJIT_D_LESS:
                GET_CR_BIT(4 + 0, reg);
                break;
 
-       case SLJIT_C_GREATER_EQUAL:
-       case SLJIT_C_FLOAT_GREATER_EQUAL:
+       case SLJIT_GREATER_EQUAL:
+       case SLJIT_D_GREATER_EQUAL:
                GET_CR_BIT(4 + 0, reg);
                INVERT_BIT(reg);
                break;
 
-       case SLJIT_C_GREATER:
-       case SLJIT_C_FLOAT_GREATER:
+       case SLJIT_GREATER:
+       case SLJIT_D_GREATER:
                GET_CR_BIT(4 + 1, reg);
                break;
 
-       case SLJIT_C_LESS_EQUAL:
-       case SLJIT_C_FLOAT_LESS_EQUAL:
+       case SLJIT_LESS_EQUAL:
+       case SLJIT_D_LESS_EQUAL:
                GET_CR_BIT(4 + 1, reg);
                INVERT_BIT(reg);
                break;
 
-       case SLJIT_C_SIG_LESS:
+       case SLJIT_SIG_LESS:
                GET_CR_BIT(0, reg);
                break;
 
-       case SLJIT_C_SIG_GREATER_EQUAL:
+       case SLJIT_SIG_GREATER_EQUAL:
                GET_CR_BIT(0, reg);
                INVERT_BIT(reg);
                break;
 
-       case SLJIT_C_SIG_GREATER:
+       case SLJIT_SIG_GREATER:
                GET_CR_BIT(1, reg);
                break;
 
-       case SLJIT_C_SIG_LESS_EQUAL:
+       case SLJIT_SIG_LESS_EQUAL:
                GET_CR_BIT(1, reg);
                INVERT_BIT(reg);
                break;
 
-       case SLJIT_C_OVERFLOW:
-       case SLJIT_C_MUL_OVERFLOW:
+       case SLJIT_OVERFLOW:
+       case SLJIT_MUL_OVERFLOW:
                GET_CR_BIT(3, reg);
                break;
 
-       case SLJIT_C_NOT_OVERFLOW:
-       case SLJIT_C_MUL_NOT_OVERFLOW:
+       case SLJIT_NOT_OVERFLOW:
+       case SLJIT_MUL_NOT_OVERFLOW:
                GET_CR_BIT(3, reg);
                INVERT_BIT(reg);
                break;
 
-       case SLJIT_C_FLOAT_EQUAL:
+       case SLJIT_D_EQUAL:
                GET_CR_BIT(4 + 2, reg);
                break;
 
-       case SLJIT_C_FLOAT_NOT_EQUAL:
+       case SLJIT_D_NOT_EQUAL:
                GET_CR_BIT(4 + 2, reg);
                INVERT_BIT(reg);
                break;
 
-       case SLJIT_C_FLOAT_UNORDERED:
+       case SLJIT_D_UNORDERED:
                GET_CR_BIT(4 + 3, reg);
                break;
 
-       case SLJIT_C_FLOAT_ORDERED:
+       case SLJIT_D_ORDERED:
                GET_CR_BIT(4 + 3, reg);
                INVERT_BIT(reg);
                break;
@@ -2159,7 +2345,8 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_flags(struct sljit_compiler *com
                return emit_op(compiler, op, input_flags, dst, dstw, TMP_REG1, 0, TMP_REG2, 0);
        }
 
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG)
+#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) \
+               || (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
        compiler->skip_checks = 1;
 #endif
        return sljit_emit_op2(compiler, op | flags, dst, original_dstw, src, srcw, TMP_REG2, 0);
@@ -2171,7 +2358,7 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compi
        sljit_si reg;
 
        CHECK_ERROR_PTR();
-       check_sljit_emit_const(compiler, dst, dstw, init_value);
+       CHECK_PTR(check_sljit_emit_const(compiler, dst, dstw, init_value));
        ADJUST_LOCAL_OFFSET(dst, dstw);
 
        const_ = (struct sljit_const*)ensure_abuf(compiler, sizeof(struct sljit_const));