Modified: tomcat/jk/trunk/native/iis/pcre/sljit/sljitNativeMIPS_32.c
URL: 
http://svn.apache.org/viewvc/tomcat/jk/trunk/native/iis/pcre/sljit/sljitNativeMIPS_32.c?rev=1838867&r1=1838866&r2=1838867&view=diff
==============================================================================
--- tomcat/jk/trunk/native/iis/pcre/sljit/sljitNativeMIPS_32.c (original)
+++ tomcat/jk/trunk/native/iis/pcre/sljit/sljitNativeMIPS_32.c Fri Aug 24 
14:36:12 2018
@@ -435,3 +435,232 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_set_
        inst = (sljit_ins *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset);
        SLJIT_CACHE_FLUSH(inst, inst + 2);
 }
+
+static sljit_s32 call_with_args(struct sljit_compiler *compiler, sljit_s32 
arg_types, sljit_ins *ins_ptr)
+{
+       sljit_s32 stack_offset = 0;
+       sljit_s32 arg_count = 0;
+       sljit_s32 float_arg_count = 0;
+       sljit_s32 word_arg_count = 0;
+       sljit_s32 types = 0;
+       sljit_s32 arg_count_save, types_save;
+       sljit_ins prev_ins = NOP;
+       sljit_ins ins = NOP;
+       sljit_u8 offsets[4];
+
+       SLJIT_ASSERT(reg_map[TMP_REG1] == 4 && freg_map[TMP_FREG1] == 12);
+
+       arg_types >>= SLJIT_DEF_SHIFT;
+
+       while (arg_types) {
+               types = (types << SLJIT_DEF_SHIFT) | (arg_types & 
SLJIT_DEF_MASK);
+
+               switch (arg_types & SLJIT_DEF_MASK) {
+               case SLJIT_ARG_TYPE_F32:
+                       offsets[arg_count] = (sljit_u8)stack_offset;
+
+                       if (word_arg_count == 0 && arg_count <= 1)
+                               offsets[arg_count] = 254 + arg_count;
+
+                       stack_offset += sizeof(sljit_f32);
+                       arg_count++;
+                       float_arg_count++;
+                       break;
+               case SLJIT_ARG_TYPE_F64:
+                       if (stack_offset & 0x7)
+                               stack_offset += sizeof(sljit_sw);
+                       offsets[arg_count] = (sljit_u8)stack_offset;
+
+                       if (word_arg_count == 0 && arg_count <= 1)
+                               offsets[arg_count] = 254 + arg_count;
+
+                       stack_offset += sizeof(sljit_f64);
+                       arg_count++;
+                       float_arg_count++;
+                       break;
+               default:
+                       offsets[arg_count] = (sljit_u8)stack_offset;
+                       stack_offset += sizeof(sljit_sw);
+                       arg_count++;
+                       word_arg_count++;
+                       break;
+               }
+
+               arg_types >>= SLJIT_DEF_SHIFT;
+       }
+
+       /* Stack is aligned to 16 bytes, max two doubles can be placed on the 
stack. */
+       if (stack_offset > 16)
+               FAIL_IF(push_inst(compiler, ADDIU | S(SLJIT_SP) | T(SLJIT_SP) | 
IMM(-16), DR(SLJIT_SP)));
+
+       types_save = types;
+       arg_count_save = arg_count;
+
+       while (types) {
+               switch (types & SLJIT_DEF_MASK) {
+               case SLJIT_ARG_TYPE_F32:
+                       arg_count--;
+                       if (offsets[arg_count] < 254)
+                               ins = SWC1 | S(SLJIT_SP) | FT(float_arg_count) 
| IMM(offsets[arg_count]);
+                       float_arg_count--;
+                       break;
+               case SLJIT_ARG_TYPE_F64:
+                       arg_count--;
+                       if (offsets[arg_count] < 254)
+                               ins = SDC1 | S(SLJIT_SP) | FT(float_arg_count) 
| IMM(offsets[arg_count]);
+                       float_arg_count--;
+                       break;
+               default:
+                       if (offsets[arg_count - 1] >= 16)
+                               ins = SW | S(SLJIT_SP) | T(word_arg_count) | 
IMM(offsets[arg_count - 1]);
+                       else if (arg_count != word_arg_count)
+                               ins = ADDU | S(word_arg_count) | TA(0) | DA(4 + 
(offsets[arg_count - 1] >> 2));
+                       else if (arg_count == 1)
+                               ins = ADDU | S(SLJIT_R0) | TA(0) | DA(4);
+
+                       arg_count--;
+                       word_arg_count--;
+                       break;
+               }
+
+               if (ins != NOP) {
+                       if (prev_ins != NOP)
+                               FAIL_IF(push_inst(compiler, prev_ins, 
MOVABLE_INS));
+                       prev_ins = ins;
+                       ins = NOP;
+               }
+
+               types >>= SLJIT_DEF_SHIFT;
+       }
+
+       types = types_save;
+       arg_count = arg_count_save;
+
+       while (types) {
+               switch (types & SLJIT_DEF_MASK) {
+               case SLJIT_ARG_TYPE_F32:
+                       arg_count--;
+                       if (offsets[arg_count] == 254)
+                               ins = MOV_S | FMT_S | FS(SLJIT_FR0) | 
FD(TMP_FREG1);
+                       else if (offsets[arg_count] < 16)
+                               ins = LW | S(SLJIT_SP) | TA(4 + 
(offsets[arg_count] >> 2)) | IMM(offsets[arg_count]);
+                       break;
+               case SLJIT_ARG_TYPE_F64:
+                       arg_count--;
+                       if (offsets[arg_count] == 254)
+                               ins = MOV_S | FMT_D | FS(SLJIT_FR0) | 
FD(TMP_FREG1);
+                       else if (offsets[arg_count] < 16) {
+                               if (prev_ins != NOP)
+                                       FAIL_IF(push_inst(compiler, prev_ins, 
MOVABLE_INS));
+                               prev_ins = LW | S(SLJIT_SP) | TA(4 + 
(offsets[arg_count] >> 2)) | IMM(offsets[arg_count]);
+                               ins = LW | S(SLJIT_SP) | TA(5 + 
(offsets[arg_count] >> 2)) | IMM(offsets[arg_count] + sizeof(sljit_sw));
+                       }
+                       break;
+               default:
+                       arg_count--;
+                       break;
+               }
+
+               if (ins != NOP) {
+                       if (prev_ins != NOP)
+                               FAIL_IF(push_inst(compiler, prev_ins, 
MOVABLE_INS));
+                       prev_ins = ins;
+                       ins = NOP;
+               }
+
+               types >>= SLJIT_DEF_SHIFT;
+       }
+
+       *ins_ptr = prev_ins;
+
+       return SLJIT_SUCCESS;
+}
+
+static sljit_s32 post_call_with_args(struct sljit_compiler *compiler, 
sljit_s32 arg_types)
+{
+       sljit_s32 stack_offset = 0;
+
+       arg_types >>= SLJIT_DEF_SHIFT;
+
+       while (arg_types) {
+               switch (arg_types & SLJIT_DEF_MASK) {
+               case SLJIT_ARG_TYPE_F32:
+                       stack_offset += sizeof(sljit_f32);
+                       break;
+               case SLJIT_ARG_TYPE_F64:
+                       if (stack_offset & 0x7)
+                               stack_offset += sizeof(sljit_sw);
+                       stack_offset += sizeof(sljit_f64);
+                       break;
+               default:
+                       stack_offset += sizeof(sljit_sw);
+                       break;
+               }
+
+               arg_types >>= SLJIT_DEF_SHIFT;
+       }
+
+       /* Stack is aligned to 16 bytes, max two doubles can be placed on the 
stack. */
+       if (stack_offset > 16)
+               return push_inst(compiler, ADDIU | S(SLJIT_SP) | T(SLJIT_SP) | 
IMM(16), DR(SLJIT_SP));
+
+       return SLJIT_SUCCESS;
+}
+
+SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_call(struct 
sljit_compiler *compiler, sljit_s32 type,
+       sljit_s32 arg_types)
+{
+       struct sljit_jump *jump;
+       sljit_ins ins;
+
+       CHECK_ERROR_PTR();
+       CHECK_PTR(check_sljit_emit_call(compiler, type, arg_types));
+
+       jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct 
sljit_jump));
+       PTR_FAIL_IF(!jump);
+       set_jump(jump, compiler, type & SLJIT_REWRITABLE_JUMP);
+       type &= 0xff;
+
+       PTR_FAIL_IF(call_with_args(compiler, arg_types, &ins));
+
+       SLJIT_ASSERT(DR(PIC_ADDR_REG) == 25 && PIC_ADDR_REG == TMP_REG2);
+
+       PTR_FAIL_IF(emit_const(compiler, PIC_ADDR_REG, 0));
+
+       jump->flags |= IS_JAL | IS_CALL;
+       PTR_FAIL_IF(push_inst(compiler, JALR | S(PIC_ADDR_REG) | 
DA(RETURN_ADDR_REG), UNMOVABLE_INS));
+       jump->addr = compiler->size;
+       PTR_FAIL_IF(push_inst(compiler, ins, UNMOVABLE_INS));
+
+       PTR_FAIL_IF(post_call_with_args(compiler, arg_types));
+
+       return jump;
+}
+
+SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_icall(struct sljit_compiler 
*compiler, sljit_s32 type,
+       sljit_s32 arg_types,
+       sljit_s32 src, sljit_sw srcw)
+{
+       sljit_ins ins;
+
+       CHECK_ERROR();
+       CHECK(check_sljit_emit_icall(compiler, type, arg_types, src, srcw));
+
+       SLJIT_ASSERT(DR(PIC_ADDR_REG) == 25 && PIC_ADDR_REG == TMP_REG2);
+
+       if (src & SLJIT_IMM)
+               FAIL_IF(load_immediate(compiler, DR(PIC_ADDR_REG), srcw));
+       else if (FAST_IS_REG(src))
+               FAIL_IF(push_inst(compiler, ADDU | S(src) | TA(0) | 
D(PIC_ADDR_REG), DR(PIC_ADDR_REG)));
+       else if (src & SLJIT_MEM) {
+               ADJUST_LOCAL_OFFSET(src, srcw);
+               FAIL_IF(emit_op_mem(compiler, WORD_DATA | LOAD_DATA, 
DR(PIC_ADDR_REG), src, srcw));
+       }
+
+       FAIL_IF(call_with_args(compiler, arg_types, &ins));
+
+       /* Register input. */
+       FAIL_IF(push_inst(compiler, JALR | S(PIC_ADDR_REG) | 
DA(RETURN_ADDR_REG), UNMOVABLE_INS));
+       FAIL_IF(push_inst(compiler, ins, UNMOVABLE_INS));
+       return post_call_with_args(compiler, arg_types);
+}

Modified: tomcat/jk/trunk/native/iis/pcre/sljit/sljitNativeMIPS_64.c
URL: 
http://svn.apache.org/viewvc/tomcat/jk/trunk/native/iis/pcre/sljit/sljitNativeMIPS_64.c?rev=1838867&r1=1838866&r2=1838867&view=diff
==============================================================================
--- tomcat/jk/trunk/native/iis/pcre/sljit/sljitNativeMIPS_64.c (original)
+++ tomcat/jk/trunk/native/iis/pcre/sljit/sljitNativeMIPS_64.c Fri Aug 24 
14:36:12 2018
@@ -537,3 +537,132 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_set_
        inst = (sljit_ins *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset);
        SLJIT_CACHE_FLUSH(inst, inst + 6);
 }
+
+static sljit_s32 call_with_args(struct sljit_compiler *compiler, sljit_s32 
arg_types, sljit_ins *ins_ptr)
+{
+       sljit_s32 arg_count = 0;
+       sljit_s32 word_arg_count = 0;
+       sljit_s32 float_arg_count = 0;
+       sljit_s32 types = 0;
+       sljit_ins prev_ins = NOP;
+       sljit_ins ins = NOP;
+
+       SLJIT_ASSERT(reg_map[TMP_REG1] == 4 && freg_map[TMP_FREG1] == 12);
+
+       arg_types >>= SLJIT_DEF_SHIFT;
+
+       while (arg_types) {
+               types = (types << SLJIT_DEF_SHIFT) | (arg_types & 
SLJIT_DEF_MASK);
+
+               switch (arg_types & SLJIT_DEF_MASK) {
+               case SLJIT_ARG_TYPE_F32:
+               case SLJIT_ARG_TYPE_F64:
+                       arg_count++;
+                       float_arg_count++;
+                       break;
+               default:
+                       arg_count++;
+                       word_arg_count++;
+                       break;
+               }
+
+               arg_types >>= SLJIT_DEF_SHIFT;
+       }
+
+       while (types) {
+               switch (types & SLJIT_DEF_MASK) {
+               case SLJIT_ARG_TYPE_F32:
+                       if (arg_count != float_arg_count)
+                               ins = MOV_S | FMT_S | FS(float_arg_count) | 
FD(arg_count);
+                       else if (arg_count == 1)
+                               ins = MOV_S | FMT_S | FS(SLJIT_FR0) | 
FD(TMP_FREG1);
+                       arg_count--;
+                       float_arg_count--;
+                       break;
+               case SLJIT_ARG_TYPE_F64:
+                       if (arg_count != float_arg_count)
+                               ins = MOV_S | FMT_D | FS(float_arg_count) | 
FD(arg_count);
+                       else if (arg_count == 1)
+                               ins = MOV_S | FMT_D | FS(SLJIT_FR0) | 
FD(TMP_FREG1);
+                       arg_count--;
+                       float_arg_count--;
+                       break;
+               default:
+                       if (arg_count != word_arg_count)
+                               ins = DADDU | S(word_arg_count) | TA(0) | 
D(arg_count);
+                       else if (arg_count == 1)
+                               ins = DADDU | S(SLJIT_R0) | TA(0) | DA(4);
+                       arg_count--;
+                       word_arg_count--;
+                       break;
+               }
+
+               if (ins != NOP) {
+                       if (prev_ins != NOP)
+                               FAIL_IF(push_inst(compiler, prev_ins, 
MOVABLE_INS));
+                       prev_ins = ins;
+                       ins = NOP;
+               }
+
+               types >>= SLJIT_DEF_SHIFT;
+       }
+
+       *ins_ptr = prev_ins;
+
+       return SLJIT_SUCCESS;
+}
+
+SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_call(struct 
sljit_compiler *compiler, sljit_s32 type,
+       sljit_s32 arg_types)
+{
+       struct sljit_jump *jump;
+       sljit_ins ins;
+
+       CHECK_ERROR_PTR();
+       CHECK_PTR(check_sljit_emit_call(compiler, type, arg_types));
+
+       jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct 
sljit_jump));
+       PTR_FAIL_IF(!jump);
+       set_jump(jump, compiler, type & SLJIT_REWRITABLE_JUMP);
+       type &= 0xff;
+
+       PTR_FAIL_IF(call_with_args(compiler, arg_types, &ins));
+
+       SLJIT_ASSERT(DR(PIC_ADDR_REG) == 25 && PIC_ADDR_REG == TMP_REG2);
+
+       PTR_FAIL_IF(emit_const(compiler, PIC_ADDR_REG, 0));
+
+       jump->flags |= IS_JAL | IS_CALL;
+       PTR_FAIL_IF(push_inst(compiler, JALR | S(PIC_ADDR_REG) | 
DA(RETURN_ADDR_REG), UNMOVABLE_INS));
+       jump->addr = compiler->size;
+       PTR_FAIL_IF(push_inst(compiler, ins, UNMOVABLE_INS));
+
+       return jump;
+}
+
+SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_icall(struct sljit_compiler 
*compiler, sljit_s32 type,
+       sljit_s32 arg_types,
+       sljit_s32 src, sljit_sw srcw)
+{
+       sljit_ins ins;
+
+       CHECK_ERROR();
+       CHECK(check_sljit_emit_icall(compiler, type, arg_types, src, srcw));
+
+       SLJIT_ASSERT(DR(PIC_ADDR_REG) == 25 && PIC_ADDR_REG == TMP_REG2);
+
+       if (src & SLJIT_IMM)
+               FAIL_IF(load_immediate(compiler, DR(PIC_ADDR_REG), srcw));
+       else if (FAST_IS_REG(src))
+               FAIL_IF(push_inst(compiler, DADDU | S(src) | TA(0) | 
D(PIC_ADDR_REG), DR(PIC_ADDR_REG)));
+       else if (src & SLJIT_MEM) {
+               ADJUST_LOCAL_OFFSET(src, srcw);
+               FAIL_IF(emit_op_mem(compiler, WORD_DATA | LOAD_DATA, 
DR(PIC_ADDR_REG), src, srcw));
+       }
+
+       FAIL_IF(call_with_args(compiler, arg_types, &ins));
+
+       /* Register input. */
+       FAIL_IF(push_inst(compiler, JALR | S(PIC_ADDR_REG) | 
DA(RETURN_ADDR_REG), UNMOVABLE_INS));
+       return push_inst(compiler, ins, UNMOVABLE_INS);
+}

Modified: tomcat/jk/trunk/native/iis/pcre/sljit/sljitNativeMIPS_common.c
URL: 
http://svn.apache.org/viewvc/tomcat/jk/trunk/native/iis/pcre/sljit/sljitNativeMIPS_common.c?rev=1838867&r1=1838866&r2=1838867&view=diff
==============================================================================
--- tomcat/jk/trunk/native/iis/pcre/sljit/sljitNativeMIPS_common.c (original)
+++ tomcat/jk/trunk/native/iis/pcre/sljit/sljitNativeMIPS_common.c Fri Aug 24 
14:36:12 2018
@@ -57,16 +57,30 @@ typedef sljit_u32 sljit_ins;
 #define RETURN_ADDR_REG        31
 
 /* Flags are kept in volatile registers. */
-#define EQUAL_FLAG     31
+#define EQUAL_FLAG     3
 #define OTHER_FLAG     1
 
-#define TMP_FREG1      (0)
-#define TMP_FREG2      ((SLJIT_NUMBER_OF_FLOAT_REGISTERS + 1) << 1)
+#define TMP_FREG1      (SLJIT_NUMBER_OF_FLOAT_REGISTERS + 1)
+#define TMP_FREG2      (SLJIT_NUMBER_OF_FLOAT_REGISTERS + 2)
 
 static const sljit_u8 reg_map[SLJIT_NUMBER_OF_REGISTERS + 5] = {
-       0, 2, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 24, 23, 22, 21, 20, 19, 
18, 17, 16, 29, 3, 25, 4
+       0, 2, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 24, 23, 22, 21, 20, 19, 
18, 17, 16, 29, 4, 25, 31
 };
 
+#if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
+
+static const sljit_u8 freg_map[SLJIT_NUMBER_OF_FLOAT_REGISTERS + 3] = {
+       0, 0, 14, 2, 4, 6, 8, 12, 10
+};
+
+#else
+
+static const sljit_u8 freg_map[SLJIT_NUMBER_OF_FLOAT_REGISTERS + 3] = {
+       0, 0, 13, 14, 15, 16, 17, 12, 18
+};
+
+#endif
+
 /* --------------------------------------------------------------------- */
 /*  Instrucion forms                                                     */
 /* --------------------------------------------------------------------- */
@@ -74,21 +88,23 @@ static const sljit_u8 reg_map[SLJIT_NUMB
 #define S(s)           (reg_map[s] << 21)
 #define T(t)           (reg_map[t] << 16)
 #define D(d)           (reg_map[d] << 11)
+#define FT(t)          (freg_map[t] << 16)
+#define FS(s)          (freg_map[s] << 11)
+#define FD(d)          (freg_map[d] << 6)
 /* Absolute registers. */
 #define SA(s)          ((s) << 21)
 #define TA(t)          ((t) << 16)
 #define DA(d)          ((d) << 11)
-#define FT(t)          ((t) << 16)
-#define FS(s)          ((s) << 11)
-#define FD(d)          ((d) << 6)
 #define IMM(imm)       ((imm) & 0xffff)
 #define SH_IMM(imm)    ((imm) << 6)
 
 #define DR(dr)         (reg_map[dr])
+#define FR(dr)         (freg_map[dr])
 #define HI(opcode)     ((opcode) << 26)
 #define LO(opcode)     (opcode)
 /* S = (16 << 21) D = (17 << 21) */
 #define FMT_S          (16 << 21)
+#define FMT_D          (17 << 21)
 
 #define ABS_S          (HI(17) | FMT_S | LO(5))
 #define ADD_S          (HI(17) | FMT_S | LO(0))
@@ -153,6 +169,7 @@ static const sljit_u8 reg_map[SLJIT_NUMB
 #define OR             (HI(0) | LO(37))
 #define ORI            (HI(13))
 #define SD             (HI(63))
+#define SDC1           (HI(61))
 #define SLT            (HI(0) | LO(42))
 #define SLTI           (HI(10))
 #define SLTIU          (HI(11))
@@ -166,6 +183,7 @@ static const sljit_u8 reg_map[SLJIT_NUMB
 #define SUB_S          (HI(17) | FMT_S | LO(1))
 #define SUBU           (HI(0) | LO(35))
 #define SW             (HI(43))
+#define SWC1           (HI(57))
 #define TRUNC_W_S      (HI(17) | FMT_S | LO(13))
 #define XOR            (HI(0) | LO(38))
 #define XORI           (HI(14))
@@ -498,12 +516,13 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_gen
 
 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_has_cpu_feature(sljit_s32 
feature_type)
 {
+       sljit_sw fir = 0;
+
        switch (feature_type) {
        case SLJIT_HAS_FPU:
 #ifdef SLJIT_IS_FPU_AVAILABLE
                return SLJIT_IS_FPU_AVAILABLE;
 #elif defined(__GNUC__)
-               sljit_sw fir;
                asm ("cfc1 %0, $0" : "=r"(fir));
                return (fir >> 22) & 0x1;
 #else
@@ -517,7 +536,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit
 #endif
 
        default:
-               return 0;
+               return fir;
        }
 }
 
@@ -539,21 +558,20 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit
 
 #define MEM_MASK       0x1f
 
-#define WRITE_BACK     0x00020
-#define ARG_TEST       0x00040
-#define ALT_KEEP_CACHE 0x00080
-#define CUMULATIVE_OP  0x00100
-#define LOGICAL_OP     0x00200
-#define IMM_OP         0x00400
-#define SRC2_IMM       0x00800
-
-#define UNUSED_DEST    0x01000
-#define REG_DEST       0x02000
-#define REG1_SOURCE    0x04000
-#define REG2_SOURCE    0x08000
-#define SLOW_SRC1      0x10000
-#define SLOW_SRC2      0x20000
-#define SLOW_DEST      0x40000
+#define ARG_TEST       0x00020
+#define ALT_KEEP_CACHE 0x00040
+#define CUMULATIVE_OP  0x00080
+#define LOGICAL_OP     0x00100
+#define IMM_OP         0x00200
+#define SRC2_IMM       0x00400
+
+#define UNUSED_DEST    0x00800
+#define REG_DEST       0x01000
+#define REG1_SOURCE    0x02000
+#define REG2_SOURCE    0x04000
+#define SLOW_SRC1      0x08000
+#define SLOW_SRC2      0x10000
+#define SLOW_DEST      0x20000
 
 #if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
 #define STACK_STORE    SW
@@ -563,6 +581,8 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit
 #define STACK_LOAD     LD
 #endif
 
+static SLJIT_INLINE sljit_s32 emit_op_mem(struct sljit_compiler *compiler, 
sljit_s32 flags, sljit_s32 reg_ar, sljit_s32 arg, sljit_sw argw);
+
 #if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
 #include "sljitNativeMIPS_32.c"
 #else
@@ -570,15 +590,15 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit
 #endif
 
 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_enter(struct sljit_compiler 
*compiler,
-       sljit_s32 options, sljit_s32 args, sljit_s32 scratches, sljit_s32 
saveds,
+       sljit_s32 options, sljit_s32 arg_types, sljit_s32 scratches, sljit_s32 
saveds,
        sljit_s32 fscratches, sljit_s32 fsaveds, sljit_s32 local_size)
 {
        sljit_ins base;
-       sljit_s32 i, tmp, offs;
+       sljit_s32 args, i, tmp, offs;
 
        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);
+       CHECK(check_sljit_emit_enter(compiler, options, arg_types, scratches, 
saveds, fscratches, fsaveds, local_size));
+       set_emit_enter(compiler, options, arg_types, scratches, saveds, 
fscratches, fsaveds, local_size);
 
        local_size += GET_SAVED_REGISTERS_SIZE(scratches, saveds, 1) + 
SLJIT_LOCALS_OFFSET;
 #if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
@@ -592,16 +612,17 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit
                /* Frequent case. */
                FAIL_IF(push_inst(compiler, ADDIU_W | S(SLJIT_SP) | T(SLJIT_SP) 
| IMM(-local_size), DR(SLJIT_SP)));
                base = S(SLJIT_SP);
+               offs = local_size - (sljit_sw)sizeof(sljit_sw);
        }
        else {
-               FAIL_IF(load_immediate(compiler, DR(TMP_REG1), local_size));
+               FAIL_IF(load_immediate(compiler, DR(OTHER_FLAG), local_size));
                FAIL_IF(push_inst(compiler, ADDU_W | S(SLJIT_SP) | TA(0) | 
D(TMP_REG2), DR(TMP_REG2)));
-               FAIL_IF(push_inst(compiler, SUBU_W | S(SLJIT_SP) | T(TMP_REG1) 
| D(SLJIT_SP), DR(SLJIT_SP)));
+               FAIL_IF(push_inst(compiler, SUBU_W | S(SLJIT_SP) | 
T(OTHER_FLAG) | D(SLJIT_SP), DR(SLJIT_SP)));
                base = S(TMP_REG2);
                local_size = 0;
+               offs = -(sljit_sw)sizeof(sljit_sw);
        }
 
-       offs = local_size - (sljit_sw)(sizeof(sljit_sw));
        FAIL_IF(push_inst(compiler, STACK_STORE | base | TA(RETURN_ADDR_REG) | 
IMM(offs), MOVABLE_INS));
 
        tmp = saveds < SLJIT_NUMBER_OF_SAVED_REGISTERS ? (SLJIT_S0 + 1 - 
saveds) : SLJIT_FIRST_SAVED_REG;
@@ -615,6 +636,8 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit
                FAIL_IF(push_inst(compiler, STACK_STORE | base | T(i) | 
IMM(offs), MOVABLE_INS));
        }
 
+       args = get_arg_count(arg_types);
+
        if (args >= 1)
                FAIL_IF(push_inst(compiler, ADDU_W | SA(4) | TA(0) | 
D(SLJIT_S0), DR(SLJIT_S0)));
        if (args >= 2)
@@ -626,12 +649,12 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit
 }
 
 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_set_context(struct sljit_compiler 
*compiler,
-       sljit_s32 options, sljit_s32 args, sljit_s32 scratches, sljit_s32 
saveds,
+       sljit_s32 options, sljit_s32 arg_types, sljit_s32 scratches, sljit_s32 
saveds,
        sljit_s32 fscratches, sljit_s32 fsaveds, sljit_s32 local_size)
 {
        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);
+       CHECK(check_sljit_set_context(compiler, options, arg_types, scratches, 
saveds, fscratches, fsaveds, local_size));
+       set_set_context(compiler, options, arg_types, scratches, saveds, 
fscratches, fsaveds, local_size);
 
        local_size += GET_SAVED_REGISTERS_SIZE(scratches, saveds, 1) + 
SLJIT_LOCALS_OFFSET;
 #if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
@@ -733,7 +756,7 @@ static sljit_s32 getput_arg_fast(struct
 {
        SLJIT_ASSERT(arg & SLJIT_MEM);
 
-       if ((!(flags & WRITE_BACK) || !(arg & REG_MASK)) && !(arg & 
OFFS_REG_MASK) && argw <= SIMM_MAX && argw >= SIMM_MIN) {
+       if (!(arg & OFFS_REG_MASK) && argw <= SIMM_MAX && argw >= SIMM_MIN) {
                /* Works for both absoulte and relative addresses. */
                if (SLJIT_UNLIKELY(flags & ARG_TEST))
                        return 1;
@@ -783,19 +806,14 @@ static sljit_s32 getput_arg(struct sljit
        if ((flags & MEM_MASK) <= GPR_REG && (flags & LOAD_DATA)) {
                tmp_ar = reg_ar;
                delay_slot = reg_ar;
-       } else {
+       }
+       else {
                tmp_ar = DR(TMP_REG1);
                delay_slot = MOVABLE_INS;
        }
        base = arg & REG_MASK;
 
        if (SLJIT_UNLIKELY(arg & OFFS_REG_MASK)) {
-               if (SLJIT_UNLIKELY(flags & WRITE_BACK)) {
-                       SLJIT_ASSERT(argw == 0);
-                       FAIL_IF(push_inst(compiler, ADDU_W | S(base) | 
T(OFFS_REG(arg)) | D(base), DR(base)));
-                       return push_inst(compiler, data_transfer_insts[flags & 
MEM_MASK] | S(base) | TA(reg_ar), delay_slot);
-               }
-
                argw &= 0x3;
 
                /* Using the cache. */
@@ -832,29 +850,6 @@ static sljit_s32 getput_arg(struct sljit
                return push_inst(compiler, data_transfer_insts[flags & 
MEM_MASK] | SA(tmp_ar) | TA(reg_ar), delay_slot);
        }
 
-       if (SLJIT_UNLIKELY(flags & WRITE_BACK) && base) {
-               if (argw <= SIMM_MAX && argw >= SIMM_MIN) {
-                       if (argw)
-                               FAIL_IF(push_inst(compiler, ADDIU_W | S(base) | 
T(base) | IMM(argw), DR(base)));
-               }
-               else {
-                       if (compiler->cache_arg == SLJIT_MEM && argw - 
compiler->cache_argw <= SIMM_MAX && argw - compiler->cache_argw >= SIMM_MIN) {
-                               if (argw != compiler->cache_argw) {
-                                       FAIL_IF(push_inst(compiler, ADDIU_W | 
S(TMP_REG3) | T(TMP_REG3) | IMM(argw - compiler->cache_argw), DR(TMP_REG3)));
-                                       compiler->cache_argw = argw;
-                               }
-                               FAIL_IF(push_inst(compiler, ADDU_W | S(base) | 
T(TMP_REG3) | D(base), DR(base)));
-                       }
-                       else {
-                               compiler->cache_arg = SLJIT_MEM;
-                               compiler->cache_argw = argw;
-                               FAIL_IF(load_immediate(compiler, DR(TMP_REG3), 
argw));
-                               FAIL_IF(push_inst(compiler, ADDU_W | S(base) | 
T(TMP_REG3) | D(base), DR(base)));
-                       }
-               }
-               return push_inst(compiler, data_transfer_insts[flags & 
MEM_MASK] | S(base) | TA(reg_ar), delay_slot);
-       }
-
        if (compiler->cache_arg == arg && argw - compiler->cache_argw <= 
SIMM_MAX && argw - compiler->cache_argw >= SIMM_MIN) {
                if (argw != compiler->cache_argw) {
                        FAIL_IF(push_inst(compiler, ADDIU_W | S(TMP_REG3) | 
T(TMP_REG3) | IMM(argw - compiler->cache_argw), DR(TMP_REG3)));
@@ -888,11 +883,39 @@ static sljit_s32 getput_arg(struct sljit
 
 static SLJIT_INLINE sljit_s32 emit_op_mem(struct sljit_compiler *compiler, 
sljit_s32 flags, sljit_s32 reg_ar, sljit_s32 arg, sljit_sw argw)
 {
+       sljit_s32 tmp_ar, base, delay_slot;
+
        if (getput_arg_fast(compiler, flags, reg_ar, arg, argw))
                return compiler->error;
-       compiler->cache_arg = 0;
-       compiler->cache_argw = 0;
-       return getput_arg(compiler, flags, reg_ar, arg, argw, 0, 0);
+
+       if ((flags & MEM_MASK) <= GPR_REG && (flags & LOAD_DATA)) {
+               tmp_ar = reg_ar;
+               delay_slot = reg_ar;
+       }
+       else {
+               tmp_ar = DR(TMP_REG1);
+               delay_slot = MOVABLE_INS;
+       }
+       base = arg & REG_MASK;
+
+       if (SLJIT_UNLIKELY(arg & OFFS_REG_MASK)) {
+               argw &= 0x3;
+
+               if (SLJIT_UNLIKELY(argw)) {
+                       FAIL_IF(push_inst(compiler, SLL_W | T(OFFS_REG(arg)) | 
DA(tmp_ar) | SH_IMM(argw), tmp_ar));
+                       FAIL_IF(push_inst(compiler, ADDU_W | S(base) | 
TA(tmp_ar) | DA(tmp_ar), tmp_ar));
+               }
+               else
+                       FAIL_IF(push_inst(compiler, ADDU_W | S(base) | 
T(OFFS_REG(arg)) | DA(tmp_ar), tmp_ar));
+               return push_inst(compiler, data_transfer_insts[flags & 
MEM_MASK] | SA(tmp_ar) | TA(reg_ar), delay_slot);
+       }
+
+       FAIL_IF(load_immediate(compiler, tmp_ar, argw));
+
+       if (base != 0)
+               FAIL_IF(push_inst(compiler, ADDU_W | S(base) | TA(tmp_ar) | 
DA(tmp_ar), tmp_ar));
+
+       return push_inst(compiler, data_transfer_insts[flags & MEM_MASK] | 
SA(tmp_ar) | TA(reg_ar), delay_slot);
 }
 
 static SLJIT_INLINE sljit_s32 emit_op_mem2(struct sljit_compiler *compiler, 
sljit_s32 flags, sljit_s32 reg, sljit_s32 arg1, sljit_sw arg1w, sljit_s32 arg2, 
sljit_sw arg2w)
@@ -928,7 +951,7 @@ static sljit_s32 emit_op(struct sljit_co
        else if (FAST_IS_REG(dst)) {
                dst_r = dst;
                flags |= REG_DEST;
-               if (op >= SLJIT_MOV && op <= SLJIT_MOVU_S32)
+               if (op >= SLJIT_MOV && op <= SLJIT_MOV_P)
                        sugg_src2_r = dst_r;
        }
        else if ((dst & SLJIT_MEM) && !getput_arg_fast(compiler, flags | 
ARG_TEST, DR(TMP_REG1), dst, dstw))
@@ -982,7 +1005,7 @@ static sljit_s32 emit_op(struct sljit_co
        if (FAST_IS_REG(src2)) {
                src2_r = src2;
                flags |= REG2_SOURCE;
-               if (!(flags & REG_DEST) && op >= SLJIT_MOV && op <= 
SLJIT_MOVU_S32)
+               if (!(flags & REG_DEST) && op >= SLJIT_MOV && op <= SLJIT_MOV_P)
                        dst_r = src2_r;
        }
        else if (src2 & SLJIT_IMM) {
@@ -993,7 +1016,7 @@ static sljit_s32 emit_op(struct sljit_co
                        }
                        else {
                                src2_r = 0;
-                               if ((op >= SLJIT_MOV && op <= SLJIT_MOVU_S32) 
&& (dst & SLJIT_MEM))
+                               if ((op >= SLJIT_MOV && op <= SLJIT_MOV_P) && 
(dst & SLJIT_MEM))
                                        dst_r = 0;
                        }
                }
@@ -1132,11 +1155,8 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit
        }
 
 #if (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64)
-       if ((op & SLJIT_I32_OP) && GET_OPCODE(op) >= SLJIT_NOT) {
+       if ((op & SLJIT_I32_OP) && GET_OPCODE(op) >= SLJIT_NOT)
                flags |= INT_DATA | SIGNED_DATA;
-               if (src & SLJIT_IMM)
-                       srcw = (sljit_s32)srcw;
-       }
 #endif
 
        switch (GET_OPCODE(op)) {
@@ -1170,36 +1190,6 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit
        case SLJIT_MOV_S16:
                return emit_op(compiler, SLJIT_MOV_S16, HALF_DATA | 
SIGNED_DATA, dst, dstw, TMP_REG1, 0, src, (src & SLJIT_IMM) ? (sljit_s16)srcw : 
srcw);
 
-       case SLJIT_MOVU:
-       case SLJIT_MOVU_P:
-               return emit_op(compiler, SLJIT_MOV, WORD_DATA | WRITE_BACK, 
dst, dstw, TMP_REG1, 0, src, srcw);
-
-       case SLJIT_MOVU_U32:
-#if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
-               return emit_op(compiler, SLJIT_MOV_U32, INT_DATA | WRITE_BACK, 
dst, dstw, TMP_REG1, 0, src, srcw);
-#else
-               return emit_op(compiler, SLJIT_MOV_U32, INT_DATA | WRITE_BACK, 
dst, dstw, TMP_REG1, 0, src, (src & SLJIT_IMM) ? (sljit_u32)srcw : srcw);
-#endif
-
-       case SLJIT_MOVU_S32:
-#if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
-               return emit_op(compiler, SLJIT_MOV_S32, INT_DATA | SIGNED_DATA 
| WRITE_BACK, dst, dstw, TMP_REG1, 0, src, srcw);
-#else
-               return emit_op(compiler, SLJIT_MOV_S32, INT_DATA | SIGNED_DATA 
| WRITE_BACK, dst, dstw, TMP_REG1, 0, src, (src & SLJIT_IMM) ? (sljit_s32)srcw 
: srcw);
-#endif
-
-       case SLJIT_MOVU_U8:
-               return emit_op(compiler, SLJIT_MOV_U8, BYTE_DATA | WRITE_BACK, 
dst, dstw, TMP_REG1, 0, src, (src & SLJIT_IMM) ? (sljit_u8)srcw : srcw);
-
-       case SLJIT_MOVU_S8:
-               return emit_op(compiler, SLJIT_MOV_S8, BYTE_DATA | SIGNED_DATA 
| WRITE_BACK, dst, dstw, TMP_REG1, 0, src, (src & SLJIT_IMM) ? (sljit_s8)srcw : 
srcw);
-
-       case SLJIT_MOVU_U16:
-               return emit_op(compiler, SLJIT_MOV_U16, HALF_DATA | WRITE_BACK, 
dst, dstw, TMP_REG1, 0, src, (src & SLJIT_IMM) ? (sljit_u16)srcw : srcw);
-
-       case SLJIT_MOVU_S16:
-               return emit_op(compiler, SLJIT_MOV_S16, HALF_DATA | SIGNED_DATA 
| WRITE_BACK, dst, dstw, TMP_REG1, 0, src, (src & SLJIT_IMM) ? (sljit_s16)srcw 
: srcw);
-
        case SLJIT_NOT:
                return emit_op(compiler, op, flags, dst, dstw, TMP_REG1, 0, 
src, srcw);
 
@@ -1210,6 +1200,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit
                return emit_op(compiler, op, flags, dst, dstw, TMP_REG1, 0, 
src, srcw);
        }
 
+       SLJIT_UNREACHABLE();
        return SLJIT_SUCCESS;
 
 #if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
@@ -1281,6 +1272,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit
                return emit_op(compiler, op, flags | IMM_OP, dst, dstw, src1, 
src1w, src2, src2w);
        }
 
+       SLJIT_UNREACHABLE();
        return SLJIT_SUCCESS;
 
 #if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
@@ -1297,7 +1289,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit
 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_get_float_register_index(sljit_s32 
reg)
 {
        CHECK_REG_INDEX(check_sljit_get_float_register_index(reg));
-       return reg << 1;
+       return FR(reg);
 }
 
 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op_custom(struct sljit_compiler 
*compiler,
@@ -1327,11 +1319,9 @@ static SLJIT_INLINE sljit_s32 sljit_emit
 #endif
 
        if (src & SLJIT_MEM) {
-               FAIL_IF(emit_op_mem2(compiler, FLOAT_DATA(op) | LOAD_DATA, 
TMP_FREG1, src, srcw, dst, dstw));
+               FAIL_IF(emit_op_mem2(compiler, FLOAT_DATA(op) | LOAD_DATA, 
FR(TMP_FREG1), src, srcw, dst, dstw));
                src = TMP_FREG1;
        }
-       else
-               src <<= 1;
 
        FAIL_IF(push_inst(compiler, (TRUNC_W_S ^ (flags >> 19)) | FMT(op) | 
FS(src) | FD(TMP_FREG1), MOVABLE_INS));
 
@@ -1339,7 +1329,7 @@ static SLJIT_INLINE sljit_s32 sljit_emit
                return push_inst(compiler, MFC1 | flags | T(dst) | 
FS(TMP_FREG1), MOVABLE_INS);
 
        /* Store the integer value from a VFP register. */
-       return emit_op_mem2(compiler, flags ? DOUBLE_DATA : SINGLE_DATA, 
TMP_FREG1, dst, dstw, 0, 0);
+       return emit_op_mem2(compiler, flags ? DOUBLE_DATA : SINGLE_DATA, 
FR(TMP_FREG1), dst, dstw, 0, 0);
 
 #if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
 #      undef is_long
@@ -1356,13 +1346,13 @@ static SLJIT_INLINE sljit_s32 sljit_emit
        sljit_s32 flags = (GET_OPCODE(op) == SLJIT_CONV_F64_FROM_SW) << 21;
 #endif
 
-       sljit_s32 dst_r = FAST_IS_REG(dst) ? (dst << 1) : TMP_FREG1;
+       sljit_s32 dst_r = FAST_IS_REG(dst) ? dst : TMP_FREG1;
 
        if (FAST_IS_REG(src))
                FAIL_IF(push_inst(compiler, MTC1 | flags | T(src) | 
FS(TMP_FREG1), MOVABLE_INS));
        else if (src & SLJIT_MEM) {
                /* Load the integer value into a VFP register. */
-               FAIL_IF(emit_op_mem2(compiler, ((flags) ? DOUBLE_DATA : 
SINGLE_DATA) | LOAD_DATA, TMP_FREG1, src, srcw, dst, dstw));
+               FAIL_IF(emit_op_mem2(compiler, ((flags) ? DOUBLE_DATA : 
SINGLE_DATA) | LOAD_DATA, FR(TMP_FREG1), src, srcw, dst, dstw));
        }
        else {
 #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
@@ -1376,7 +1366,7 @@ static SLJIT_INLINE sljit_s32 sljit_emit
        FAIL_IF(push_inst(compiler, CVT_S_S | flags | (4 << 21) | (((op & 
SLJIT_F32_OP) ^ SLJIT_F32_OP) >> 8) | FS(TMP_FREG1) | FD(dst_r), MOVABLE_INS));
 
        if (dst & SLJIT_MEM)
-               return emit_op_mem2(compiler, FLOAT_DATA(op), TMP_FREG1, dst, 
dstw, 0, 0);
+               return emit_op_mem2(compiler, FLOAT_DATA(op), FR(TMP_FREG1), 
dst, dstw, 0, 0);
        return SLJIT_SUCCESS;
 
 #if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
@@ -1391,18 +1381,14 @@ static SLJIT_INLINE sljit_s32 sljit_emit
        sljit_ins inst;
 
        if (src1 & SLJIT_MEM) {
-               FAIL_IF(emit_op_mem2(compiler, FLOAT_DATA(op) | LOAD_DATA, 
TMP_FREG1, src1, src1w, src2, src2w));
+               FAIL_IF(emit_op_mem2(compiler, FLOAT_DATA(op) | LOAD_DATA, 
FR(TMP_FREG1), src1, src1w, src2, src2w));
                src1 = TMP_FREG1;
        }
-       else
-               src1 <<= 1;
 
        if (src2 & SLJIT_MEM) {
-               FAIL_IF(emit_op_mem2(compiler, FLOAT_DATA(op) | LOAD_DATA, 
TMP_FREG2, src2, src2w, 0, 0));
+               FAIL_IF(emit_op_mem2(compiler, FLOAT_DATA(op) | LOAD_DATA, 
FR(TMP_FREG2), src2, src2w, 0, 0));
                src2 = TMP_FREG2;
        }
-       else
-               src2 <<= 1;
 
        switch (GET_FLAG_TYPE(op)) {
        case SLJIT_EQUAL_F64:
@@ -1442,14 +1428,12 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit
        if (GET_OPCODE(op) == SLJIT_CONV_F64_FROM_F32)
                op ^= SLJIT_F32_OP;
 
-       dst_r = FAST_IS_REG(dst) ? (dst << 1) : TMP_FREG1;
+       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_r, src, srcw, dst, dstw));
+               FAIL_IF(emit_op_mem2(compiler, FLOAT_DATA(op) | LOAD_DATA, 
FR(dst_r), src, srcw, dst, dstw));
                src = dst_r;
        }
-       else
-               src <<= 1;
 
        switch (GET_OPCODE(op)) {
        case SLJIT_MOV_F64:
@@ -1473,7 +1457,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit
        }
 
        if (dst & SLJIT_MEM)
-               return emit_op_mem2(compiler, FLOAT_DATA(op), dst_r, dst, dstw, 
0, 0);
+               return emit_op_mem2(compiler, FLOAT_DATA(op), FR(dst_r), dst, 
dstw, 0, 0);
        return SLJIT_SUCCESS;
 }
 
@@ -1493,42 +1477,38 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit
        compiler->cache_arg = 0;
        compiler->cache_argw = 0;
 
-       dst_r = FAST_IS_REG(dst) ? (dst << 1) : 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)) {
+               if (getput_arg_fast(compiler, FLOAT_DATA(op) | LOAD_DATA, 
FR(TMP_FREG1), src1, src1w)) {
                        FAIL_IF(compiler->error);
                        src1 = TMP_FREG1;
                } else
                        flags |= SLOW_SRC1;
        }
-       else
-               src1 <<= 1;
 
        if (src2 & SLJIT_MEM) {
-               if (getput_arg_fast(compiler, FLOAT_DATA(op) | LOAD_DATA, 
TMP_FREG2, src2, src2w)) {
+               if (getput_arg_fast(compiler, FLOAT_DATA(op) | LOAD_DATA, 
FR(TMP_FREG2), src2, src2w)) {
                        FAIL_IF(compiler->error);
                        src2 = TMP_FREG2;
                } else
                        flags |= SLOW_SRC2;
        }
-       else
-               src2 <<= 1;
 
        if ((flags & (SLOW_SRC1 | SLOW_SRC2)) == (SLOW_SRC1 | SLOW_SRC2)) {
                if (!can_cache(src1, src1w, src2, src2w) && can_cache(src1, 
src1w, dst, dstw)) {
-                       FAIL_IF(getput_arg(compiler, FLOAT_DATA(op) | 
LOAD_DATA, TMP_FREG2, src2, src2w, src1, src1w));
-                       FAIL_IF(getput_arg(compiler, FLOAT_DATA(op) | 
LOAD_DATA, TMP_FREG1, src1, src1w, dst, dstw));
+                       FAIL_IF(getput_arg(compiler, FLOAT_DATA(op) | 
LOAD_DATA, FR(TMP_FREG2), src2, src2w, src1, src1w));
+                       FAIL_IF(getput_arg(compiler, FLOAT_DATA(op) | 
LOAD_DATA, FR(TMP_FREG1), src1, src1w, dst, dstw));
                }
                else {
-                       FAIL_IF(getput_arg(compiler, FLOAT_DATA(op) | 
LOAD_DATA, TMP_FREG1, src1, src1w, src2, src2w));
-                       FAIL_IF(getput_arg(compiler, FLOAT_DATA(op) | 
LOAD_DATA, TMP_FREG2, src2, src2w, dst, dstw));
+                       FAIL_IF(getput_arg(compiler, FLOAT_DATA(op) | 
LOAD_DATA, FR(TMP_FREG1), src1, src1w, src2, src2w));
+                       FAIL_IF(getput_arg(compiler, FLOAT_DATA(op) | 
LOAD_DATA, FR(TMP_FREG2), src2, src2w, dst, dstw));
                }
        }
        else if (flags & SLOW_SRC1)
-               FAIL_IF(getput_arg(compiler, FLOAT_DATA(op) | LOAD_DATA, 
TMP_FREG1, src1, src1w, dst, dstw));
+               FAIL_IF(getput_arg(compiler, FLOAT_DATA(op) | LOAD_DATA, 
FR(TMP_FREG1), src1, src1w, dst, dstw));
        else if (flags & SLOW_SRC2)
-               FAIL_IF(getput_arg(compiler, FLOAT_DATA(op) | LOAD_DATA, 
TMP_FREG2, src2, src2w, dst, dstw));
+               FAIL_IF(getput_arg(compiler, FLOAT_DATA(op) | LOAD_DATA, 
FR(TMP_FREG2), src2, src2w, dst, dstw));
 
        if (flags & SLOW_SRC1)
                src1 = TMP_FREG1;
@@ -1554,7 +1534,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit
        }
 
        if (dst_r == TMP_FREG2)
-               FAIL_IF(emit_op_mem2(compiler, FLOAT_DATA(op), TMP_FREG2, dst, 
dstw, 0, 0));
+               FAIL_IF(emit_op_mem2(compiler, FLOAT_DATA(op), FR(TMP_FREG2), 
dst, dstw, 0, 0));
 
        return SLJIT_SUCCESS;
 }
@@ -1584,10 +1564,8 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit
 
        if (FAST_IS_REG(src))
                FAIL_IF(push_inst(compiler, ADDU_W | S(src) | TA(0) | 
DA(RETURN_ADDR_REG), RETURN_ADDR_REG));
-       else if (src & SLJIT_MEM)
+       else
                FAIL_IF(emit_op_mem(compiler, WORD_DATA | LOAD_DATA, 
RETURN_ADDR_REG, src, srcw));
-       else if (src & SLJIT_IMM)
-               FAIL_IF(load_immediate(compiler, RETURN_ADDR_REG, srcw));
 
        FAIL_IF(push_inst(compiler, JR | SA(RETURN_ADDR_REG), UNMOVABLE_INS));
        return push_inst(compiler, NOP, UNMOVABLE_INS);
@@ -1704,19 +1682,16 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_ju
                PTR_FAIL_IF(push_inst(compiler, inst, UNMOVABLE_INS));
 
        PTR_FAIL_IF(emit_const(compiler, TMP_REG2, 0));
-       if (type <= SLJIT_JUMP) {
+
+       if (type <= SLJIT_JUMP)
                PTR_FAIL_IF(push_inst(compiler, JR | S(TMP_REG2), 
UNMOVABLE_INS));
-               jump->addr = compiler->size;
-               PTR_FAIL_IF(push_inst(compiler, NOP, UNMOVABLE_INS));
-       } else {
-               SLJIT_ASSERT(DR(PIC_ADDR_REG) == 25 && PIC_ADDR_REG == 
TMP_REG2);
-               /* Cannot be optimized out if type is >= CALL0. */
-               jump->flags |= IS_JAL | (type >= SLJIT_CALL0 ? IS_CALL : 0);
+       else {
+               jump->flags |= IS_JAL;
                PTR_FAIL_IF(push_inst(compiler, JALR | S(TMP_REG2) | 
DA(RETURN_ADDR_REG), UNMOVABLE_INS));
-               jump->addr = compiler->size;
-               /* A NOP if type < CALL1. */
-               PTR_FAIL_IF(push_inst(compiler, ADDU_W | S(SLJIT_R0) | TA(0) | 
DA(4), UNMOVABLE_INS));
        }
+
+       jump->addr = compiler->size;
+       PTR_FAIL_IF(push_inst(compiler, NOP, UNMOVABLE_INS));
        return jump;
 }
 
@@ -1872,41 +1847,12 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_ju
 
 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_ijump(struct sljit_compiler 
*compiler, sljit_s32 type, sljit_s32 src, sljit_sw srcw)
 {
-       sljit_s32 src_r = TMP_REG2;
        struct sljit_jump *jump = NULL;
 
        CHECK_ERROR();
        CHECK(check_sljit_emit_ijump(compiler, type, src, srcw));
        ADJUST_LOCAL_OFFSET(src, srcw);
 
-       if (FAST_IS_REG(src)) {
-               if (DR(src) != 4)
-                       src_r = src;
-               else
-                       FAIL_IF(push_inst(compiler, ADDU_W | S(src) | TA(0) | 
D(TMP_REG2), DR(TMP_REG2)));
-       }
-
-       if (type >= SLJIT_CALL0) {
-               SLJIT_ASSERT(DR(PIC_ADDR_REG) == 25 && PIC_ADDR_REG == 
TMP_REG2);
-               if (src & (SLJIT_IMM | SLJIT_MEM)) {
-                       if (src & SLJIT_IMM)
-                               FAIL_IF(load_immediate(compiler, 
DR(PIC_ADDR_REG), srcw));
-                       else {
-                               SLJIT_ASSERT(src_r == TMP_REG2 && (src & 
SLJIT_MEM));
-                               FAIL_IF(emit_op(compiler, SLJIT_MOV, WORD_DATA, 
TMP_REG2, 0, TMP_REG1, 0, src, srcw));
-                       }
-                       FAIL_IF(push_inst(compiler, JALR | S(PIC_ADDR_REG) | 
DA(RETURN_ADDR_REG), UNMOVABLE_INS));
-                       /* We need an extra instruction in any case. */
-                       return push_inst(compiler, ADDU_W | S(SLJIT_R0) | TA(0) 
| DA(4), UNMOVABLE_INS);
-               }
-
-               /* Register input. */
-               if (type >= SLJIT_CALL1)
-                       FAIL_IF(push_inst(compiler, ADDU_W | S(SLJIT_R0) | 
TA(0) | DA(4), 4));
-               FAIL_IF(push_inst(compiler, JALR | S(src_r) | 
DA(RETURN_ADDR_REG), UNMOVABLE_INS));
-               return push_inst(compiler, ADDU_W | S(src_r) | TA(0) | 
D(PIC_ADDR_REG), UNMOVABLE_INS);
-       }
-
        if (src & SLJIT_IMM) {
                jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct 
sljit_jump));
                FAIL_IF(!jump);
@@ -1917,11 +1863,14 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit
                        jump->flags |= IS_MOVABLE;
 
                FAIL_IF(emit_const(compiler, TMP_REG2, 0));
+               src = TMP_REG2;
+       }
+       else if (src & SLJIT_MEM) {
+               FAIL_IF(emit_op_mem(compiler, WORD_DATA | LOAD_DATA, 
DR(TMP_REG2), src, srcw));
+               src = TMP_REG2;
        }
-       else if (src & SLJIT_MEM)
-               FAIL_IF(emit_op(compiler, SLJIT_MOV, WORD_DATA, TMP_REG2, 0, 
TMP_REG1, 0, src, srcw));
 
-       FAIL_IF(push_inst(compiler, JR | S(src_r), UNMOVABLE_INS));
+       FAIL_IF(push_inst(compiler, JR | S(src), UNMOVABLE_INS));
        if (jump)
                jump->addr = compiler->size;
        FAIL_IF(push_inst(compiler, NOP, UNMOVABLE_INS));

Modified: tomcat/jk/trunk/native/iis/pcre/sljit/sljitNativePPC_64.c
URL: 
http://svn.apache.org/viewvc/tomcat/jk/trunk/native/iis/pcre/sljit/sljitNativePPC_64.c?rev=1838867&r1=1838866&r2=1838867&view=diff
==============================================================================
--- tomcat/jk/trunk/native/iis/pcre/sljit/sljitNativePPC_64.c (original)
+++ tomcat/jk/trunk/native/iis/pcre/sljit/sljitNativePPC_64.c Fri Aug 24 
14:36:12 2018
@@ -413,6 +413,61 @@ static SLJIT_INLINE sljit_s32 emit_singl
        return SLJIT_SUCCESS;
 }
 
+static sljit_s32 call_with_args(struct sljit_compiler *compiler, sljit_s32 
arg_types, sljit_s32 *src)
+{
+       sljit_s32 arg_count = 0;
+       sljit_s32 word_arg_count = 0;
+       sljit_s32 types = 0;
+       sljit_s32 reg = 0;
+
+       if (src)
+               reg = *src & REG_MASK;
+
+       arg_types >>= SLJIT_DEF_SHIFT;
+
+       while (arg_types) {
+               types = (types << SLJIT_DEF_SHIFT) | (arg_types & 
SLJIT_DEF_MASK);
+
+               switch (arg_types & SLJIT_DEF_MASK) {
+               case SLJIT_ARG_TYPE_F32:
+               case SLJIT_ARG_TYPE_F64:
+                       arg_count++;
+                       break;
+               default:
+                       arg_count++;
+                       word_arg_count++;
+
+                       if (arg_count != word_arg_count && arg_count == reg) {
+                               FAIL_IF(push_inst(compiler, OR | S(reg) | 
A(TMP_CALL_REG) | B(reg)));
+                               *src = TMP_CALL_REG;
+                       }
+                       break;
+               }
+
+               arg_types >>= SLJIT_DEF_SHIFT;
+       }
+
+       while (types) {
+               switch (types & SLJIT_DEF_MASK) {
+               case SLJIT_ARG_TYPE_F32:
+               case SLJIT_ARG_TYPE_F64:
+                       arg_count--;
+                       break;
+               default:
+                       if (arg_count != word_arg_count)
+                               FAIL_IF(push_inst(compiler, OR | 
S(word_arg_count) | A(arg_count) | B(word_arg_count)));
+
+                       arg_count--;
+                       word_arg_count--;
+                       break;
+               }
+
+               types >>= SLJIT_DEF_SHIFT;
+       }
+
+       return SLJIT_SUCCESS;
+}
+
 static SLJIT_INLINE sljit_s32 emit_const(struct sljit_compiler *compiler, 
sljit_s32 reg, sljit_sw init_value)
 {
        FAIL_IF(push_inst(compiler, ADDIS | D(reg) | A(0) | IMM(init_value >> 
48)));



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to