chiark / gitweb /
Merge from existing archive branch
[pcre3.git] / sljit / sljitNativeX86_64.c
index 1790d8a4d0a606639302d0d5f8c65da29f6d9bce..6ea27e5513114dfc9289f42540889fde0f5ca8fd 100644 (file)
 
 /* x86 64-bit arch dependent functions. */
 
-static sljit_si emit_load_imm64(struct sljit_compiler *compiler, sljit_si reg, sljit_sw imm)
+static sljit_s32 emit_load_imm64(struct sljit_compiler *compiler, sljit_s32 reg, sljit_sw imm)
 {
-       sljit_ub *inst;
+       sljit_u8 *inst;
 
-       inst = (sljit_ub*)ensure_buf(compiler, 1 + 2 + sizeof(sljit_sw));
+       inst = (sljit_u8*)ensure_buf(compiler, 1 + 2 + sizeof(sljit_sw));
        FAIL_IF(!inst);
        INC_SIZE(2 + sizeof(sljit_sw));
        *inst++ = REX_W | ((reg_map[reg] <= 7) ? 0 : REX_B);
@@ -39,7 +39,7 @@ static sljit_si emit_load_imm64(struct sljit_compiler *compiler, sljit_si reg, s
        return SLJIT_SUCCESS;
 }
 
-static sljit_ub* generate_far_jump_code(struct sljit_jump *jump, sljit_ub *code_ptr, sljit_si type)
+static sljit_u8* generate_far_jump_code(struct sljit_jump *jump, sljit_u8 *code_ptr, sljit_s32 type)
 {
        if (type < SLJIT_JUMP) {
                /* Invert type. */
@@ -65,9 +65,9 @@ static sljit_ub* generate_far_jump_code(struct sljit_jump *jump, sljit_ub *code_
        return code_ptr;
 }
 
-static sljit_ub* generate_fixed_jump(sljit_ub *code_ptr, sljit_sw addr, sljit_si type)
+static sljit_u8* generate_fixed_jump(sljit_u8 *code_ptr, sljit_sw addr, sljit_s32 type)
 {
-       sljit_sw delta = addr - ((sljit_sw)code_ptr + 1 + sizeof(sljit_si));
+       sljit_sw delta = addr - ((sljit_sw)code_ptr + 1 + sizeof(sljit_s32));
 
        if (delta <= HALFWORD_MAX && delta >= HALFWORD_MIN) {
                *code_ptr++ = (type == 2) ? CALL_i32 : JMP_i32;
@@ -87,12 +87,12 @@ static sljit_ub* generate_fixed_jump(sljit_ub *code_ptr, sljit_sw addr, sljit_si
        return code_ptr;
 }
 
-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)
+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 fscratches, sljit_s32 fsaveds, sljit_s32 local_size)
 {
-       sljit_si i, tmp, size, saved_register_size;
-       sljit_ub *inst;
+       sljit_s32 i, tmp, size, saved_register_size;
+       sljit_u8 *inst;
 
        CHECK_ERROR();
        CHECK(check_sljit_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size));
@@ -106,7 +106,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compil
        tmp = saveds < SLJIT_NUMBER_OF_SAVED_REGISTERS ? (SLJIT_S0 + 1 - saveds) : SLJIT_FIRST_SAVED_REG;
        for (i = SLJIT_S0; i >= tmp; i--) {
                size = reg_map[i] >= 8 ? 2 : 1;
-               inst = (sljit_ub*)ensure_buf(compiler, 1 + size);
+               inst = (sljit_u8*)ensure_buf(compiler, 1 + size);
                FAIL_IF(!inst);
                INC_SIZE(size);
                if (reg_map[i] >= 8)
@@ -116,7 +116,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compil
 
        for (i = scratches; i >= SLJIT_FIRST_SAVED_REG; i--) {
                size = reg_map[i] >= 8 ? 2 : 1;
-               inst = (sljit_ub*)ensure_buf(compiler, 1 + size);
+               inst = (sljit_u8*)ensure_buf(compiler, 1 + size);
                FAIL_IF(!inst);
                INC_SIZE(size);
                if (reg_map[i] >= 8)
@@ -126,7 +126,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compil
 
        if (args > 0) {
                size = args * 3;
-               inst = (sljit_ub*)ensure_buf(compiler, 1 + size);
+               inst = (sljit_u8*)ensure_buf(compiler, 1 + size);
                FAIL_IF(!inst);
 
                INC_SIZE(size);
@@ -172,9 +172,9 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compil
 #ifdef _WIN64
        if (local_size > 1024) {
                /* Allocate stack for the callback, which grows the stack. */
-               inst = (sljit_ub*)ensure_buf(compiler, 1 + 4 + (3 + sizeof(sljit_si)));
+               inst = (sljit_u8*)ensure_buf(compiler, 1 + 4 + (3 + sizeof(sljit_s32)));
                FAIL_IF(!inst);
-               INC_SIZE(4 + (3 + sizeof(sljit_si)));
+               INC_SIZE(4 + (3 + sizeof(sljit_s32)));
                *inst++ = REX_W;
                *inst++ = GROUP_BINARY_83;
                *inst++ = MOD_REG | SUB | 4;
@@ -193,7 +193,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compil
                *inst++ = REX_W;
                *inst++ = MOV_rm_i32;
                *inst++ = MOD_REG | reg_lmap[SLJIT_R0];
-               *(sljit_si*)inst = local_size;
+               *(sljit_s32*)inst = local_size;
 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) \
                        || (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
                compiler->skip_checks = 1;
@@ -204,7 +204,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compil
 
        SLJIT_ASSERT(local_size > 0);
        if (local_size <= 127) {
-               inst = (sljit_ub*)ensure_buf(compiler, 1 + 4);
+               inst = (sljit_u8*)ensure_buf(compiler, 1 + 4);
                FAIL_IF(!inst);
                INC_SIZE(4);
                *inst++ = REX_W;
@@ -213,35 +213,35 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compil
                *inst++ = local_size;
        }
        else {
-               inst = (sljit_ub*)ensure_buf(compiler, 1 + 7);
+               inst = (sljit_u8*)ensure_buf(compiler, 1 + 7);
                FAIL_IF(!inst);
                INC_SIZE(7);
                *inst++ = REX_W;
                *inst++ = GROUP_BINARY_81;
                *inst++ = MOD_REG | SUB | 4;
-               *(sljit_si*)inst = local_size;
-               inst += sizeof(sljit_si);
+               *(sljit_s32*)inst = local_size;
+               inst += sizeof(sljit_s32);
        }
 
 #ifdef _WIN64
        /* Save xmm6 register: movaps [rsp + 0x20], xmm6 */
        if (fscratches >= 6 || fsaveds >= 1) {
-               inst = (sljit_ub*)ensure_buf(compiler, 1 + 5);
+               inst = (sljit_u8*)ensure_buf(compiler, 1 + 5);
                FAIL_IF(!inst);
                INC_SIZE(5);
                *inst++ = GROUP_0F;
-               *(sljit_si*)inst = 0x20247429;
+               *(sljit_s32*)inst = 0x20247429;
        }
 #endif
 
        return SLJIT_SUCCESS;
 }
 
-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)
+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 fscratches, sljit_s32 fsaveds, sljit_s32 local_size)
 {
-       sljit_si saved_register_size;
+       sljit_s32 saved_register_size;
 
        CHECK_ERROR();
        CHECK(check_sljit_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size));
@@ -253,10 +253,10 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_set_context(struct sljit_compiler *compi
        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_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_return(struct sljit_compiler *compiler, sljit_s32 op, sljit_s32 src, sljit_sw srcw)
 {
-       sljit_si i, tmp, size;
-       sljit_ub *inst;
+       sljit_s32 i, tmp, size;
+       sljit_u8 *inst;
 
        CHECK_ERROR();
        CHECK(check_sljit_emit_return(compiler, op, src, srcw));
@@ -267,17 +267,17 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_return(struct sljit_compiler *compi
 #ifdef _WIN64
        /* Restore xmm6 register: movaps xmm6, [rsp + 0x20] */
        if (compiler->fscratches >= 6 || compiler->fsaveds >= 1) {
-               inst = (sljit_ub*)ensure_buf(compiler, 1 + 5);
+               inst = (sljit_u8*)ensure_buf(compiler, 1 + 5);
                FAIL_IF(!inst);
                INC_SIZE(5);
                *inst++ = GROUP_0F;
-               *(sljit_si*)inst = 0x20247428;
+               *(sljit_s32*)inst = 0x20247428;
        }
 #endif
 
        SLJIT_ASSERT(compiler->local_size > 0);
        if (compiler->local_size <= 127) {
-               inst = (sljit_ub*)ensure_buf(compiler, 1 + 4);
+               inst = (sljit_u8*)ensure_buf(compiler, 1 + 4);
                FAIL_IF(!inst);
                INC_SIZE(4);
                *inst++ = REX_W;
@@ -286,19 +286,19 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_return(struct sljit_compiler *compi
                *inst = compiler->local_size;
        }
        else {
-               inst = (sljit_ub*)ensure_buf(compiler, 1 + 7);
+               inst = (sljit_u8*)ensure_buf(compiler, 1 + 7);
                FAIL_IF(!inst);
                INC_SIZE(7);
                *inst++ = REX_W;
                *inst++ = GROUP_BINARY_81;
                *inst++ = MOD_REG | ADD | 4;
-               *(sljit_si*)inst = compiler->local_size;
+               *(sljit_s32*)inst = compiler->local_size;
        }
 
        tmp = compiler->scratches;
        for (i = SLJIT_FIRST_SAVED_REG; i <= tmp; i++) {
                size = reg_map[i] >= 8 ? 2 : 1;
-               inst = (sljit_ub*)ensure_buf(compiler, 1 + size);
+               inst = (sljit_u8*)ensure_buf(compiler, 1 + size);
                FAIL_IF(!inst);
                INC_SIZE(size);
                if (reg_map[i] >= 8)
@@ -309,7 +309,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_return(struct sljit_compiler *compi
        tmp = compiler->saveds < SLJIT_NUMBER_OF_SAVED_REGISTERS ? (SLJIT_S0 + 1 - compiler->saveds) : SLJIT_FIRST_SAVED_REG;
        for (i = tmp; i <= SLJIT_S0; i++) {
                size = reg_map[i] >= 8 ? 2 : 1;
-               inst = (sljit_ub*)ensure_buf(compiler, 1 + size);
+               inst = (sljit_u8*)ensure_buf(compiler, 1 + size);
                FAIL_IF(!inst);
                INC_SIZE(size);
                if (reg_map[i] >= 8)
@@ -317,7 +317,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_return(struct sljit_compiler *compi
                POP_REG(reg_lmap[i]);
        }
 
-       inst = (sljit_ub*)ensure_buf(compiler, 1 + 1);
+       inst = (sljit_u8*)ensure_buf(compiler, 1 + 1);
        FAIL_IF(!inst);
        INC_SIZE(1);
        RET();
@@ -328,32 +328,32 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_return(struct sljit_compiler *compi
 /*  Operators                                                            */
 /* --------------------------------------------------------------------- */
 
-static sljit_si emit_do_imm32(struct sljit_compiler *compiler, sljit_ub rex, sljit_ub opcode, sljit_sw imm)
+static sljit_s32 emit_do_imm32(struct sljit_compiler *compiler, sljit_u8 rex, sljit_u8 opcode, sljit_sw imm)
 {
-       sljit_ub *inst;
-       sljit_si length = 1 + (rex ? 1 : 0) + sizeof(sljit_si);
+       sljit_u8 *inst;
+       sljit_s32 length = 1 + (rex ? 1 : 0) + sizeof(sljit_s32);
 
-       inst = (sljit_ub*)ensure_buf(compiler, 1 + length);
+       inst = (sljit_u8*)ensure_buf(compiler, 1 + length);
        FAIL_IF(!inst);
        INC_SIZE(length);
        if (rex)
                *inst++ = rex;
        *inst++ = opcode;
-       *(sljit_si*)inst = imm;
+       *(sljit_s32*)inst = imm;
        return SLJIT_SUCCESS;
 }
 
-static sljit_ub* emit_x86_instruction(struct sljit_compiler *compiler, sljit_si size,
+static sljit_u8* emit_x86_instruction(struct sljit_compiler *compiler, sljit_s32 size,
        /* The register or immediate operand. */
-       sljit_si a, sljit_sw imma,
+       sljit_s32 a, sljit_sw imma,
        /* The general operand (not immediate). */
-       sljit_si b, sljit_sw immb)
+       sljit_s32 b, sljit_sw immb)
 {
-       sljit_ub *inst;
-       sljit_ub *buf_ptr;
-       sljit_ub rex = 0;
-       sljit_si flags = size & ~0xf;
-       sljit_si inst_size;
+       sljit_u8 *inst;
+       sljit_u8 *buf_ptr;
+       sljit_u8 rex = 0;
+       sljit_s32 flags = size & ~0xf;
+       sljit_s32 inst_size;
 
        /* The immediate operand must be 32 bit. */
        SLJIT_ASSERT(!(a & SLJIT_IMM) || compiler->mode32 || IS_HALFWORD(imma));
@@ -400,7 +400,7 @@ static sljit_ub* emit_x86_instruction(struct sljit_compiler *compiler, sljit_si
                }
 
                if ((b & REG_MASK) == SLJIT_UNUSED)
-                       inst_size += 1 + sizeof(sljit_si); /* SIB byte required to avoid RIP based addressing. */
+                       inst_size += 1 + sizeof(sljit_s32); /* SIB byte required to avoid RIP based addressing. */
                else {
                        if (reg_map[b & REG_MASK] >= 8)
                                rex |= REX_B;
@@ -408,12 +408,12 @@ static sljit_ub* emit_x86_instruction(struct sljit_compiler *compiler, sljit_si
                        if (immb != 0 && (!(b & OFFS_REG_MASK) || (b & OFFS_REG_MASK) == TO_OFFS_REG(SLJIT_SP))) {
                                /* Immediate operand. */
                                if (immb <= 127 && immb >= -128)
-                                       inst_size += sizeof(sljit_sb);
+                                       inst_size += sizeof(sljit_s8);
                                else
-                                       inst_size += sizeof(sljit_si);
+                                       inst_size += sizeof(sljit_s32);
                        }
                        else if (reg_lmap[b & REG_MASK] == 5)
-                               inst_size += sizeof(sljit_sb);
+                               inst_size += sizeof(sljit_s8);
 
                        if ((b & OFFS_REG_MASK) != SLJIT_UNUSED) {
                                inst_size += 1; /* SIB byte. */
@@ -444,7 +444,7 @@ static sljit_ub* emit_x86_instruction(struct sljit_compiler *compiler, sljit_si
                else if (flags & EX86_HALF_ARG)
                        inst_size += sizeof(short);
                else
-                       inst_size += sizeof(sljit_si);
+                       inst_size += sizeof(sljit_s32);
        }
        else {
                SLJIT_ASSERT(!(flags & EX86_SHIFT_INS) || a == SLJIT_PREF_SHIFT_REG);
@@ -456,7 +456,7 @@ static sljit_ub* emit_x86_instruction(struct sljit_compiler *compiler, sljit_si
        if (rex)
                inst_size++;
 
-       inst = (sljit_ub*)ensure_buf(compiler, 1 + inst_size);
+       inst = (sljit_u8*)ensure_buf(compiler, 1 + inst_size);
        PTR_FAIL_IF(!inst);
 
        /* Encoding the byte. */
@@ -516,8 +516,8 @@ static sljit_ub* emit_x86_instruction(struct sljit_compiler *compiler, sljit_si
                                if (immb <= 127 && immb >= -128)
                                        *buf_ptr++ = immb; /* 8 bit displacement. */
                                else {
-                                       *(sljit_si*)buf_ptr = immb; /* 32 bit displacement. */
-                                       buf_ptr += sizeof(sljit_si);
+                                       *(sljit_s32*)buf_ptr = immb; /* 32 bit displacement. */
+                                       buf_ptr += sizeof(sljit_s32);
                                }
                        }
                }
@@ -533,8 +533,8 @@ static sljit_ub* emit_x86_instruction(struct sljit_compiler *compiler, sljit_si
        else {
                *buf_ptr++ |= 0x04;
                *buf_ptr++ = 0x25;
-               *(sljit_si*)buf_ptr = immb; /* 32 bit displacement. */
-               buf_ptr += sizeof(sljit_si);
+               *(sljit_s32*)buf_ptr = immb; /* 32 bit displacement. */
+               buf_ptr += sizeof(sljit_s32);
        }
 
        if (a & SLJIT_IMM) {
@@ -543,7 +543,7 @@ static sljit_ub* emit_x86_instruction(struct sljit_compiler *compiler, sljit_si
                else if (flags & EX86_HALF_ARG)
                        *(short*)buf_ptr = imma;
                else if (!(flags & EX86_SHIFT_INS))
-                       *(sljit_si*)buf_ptr = imma;
+                       *(sljit_s32*)buf_ptr = imma;
        }
 
        return !(flags & EX86_SHIFT_INS) ? inst : (inst + 1);
@@ -553,14 +553,14 @@ static sljit_ub* emit_x86_instruction(struct sljit_compiler *compiler, sljit_si
 /*  Call / return instructions                                           */
 /* --------------------------------------------------------------------- */
 
-static SLJIT_INLINE sljit_si call_with_args(struct sljit_compiler *compiler, sljit_si type)
+static SLJIT_INLINE sljit_s32 call_with_args(struct sljit_compiler *compiler, sljit_s32 type)
 {
-       sljit_ub *inst;
+       sljit_u8 *inst;
 
 #ifndef _WIN64
        SLJIT_COMPILE_ASSERT(reg_map[SLJIT_R1] == 6 && reg_map[SLJIT_R0] < 8 && reg_map[SLJIT_R2] < 8, args_registers);
 
-       inst = (sljit_ub*)ensure_buf(compiler, 1 + ((type < SLJIT_CALL3) ? 3 : 6));
+       inst = (sljit_u8*)ensure_buf(compiler, 1 + ((type < SLJIT_CALL3) ? 3 : 6));
        FAIL_IF(!inst);
        INC_SIZE((type < SLJIT_CALL3) ? 3 : 6);
        if (type >= SLJIT_CALL3) {
@@ -574,7 +574,7 @@ static SLJIT_INLINE sljit_si call_with_args(struct sljit_compiler *compiler, slj
 #else
        SLJIT_COMPILE_ASSERT(reg_map[SLJIT_R1] == 2 && reg_map[SLJIT_R0] < 8 && reg_map[SLJIT_R2] < 8, args_registers);
 
-       inst = (sljit_ub*)ensure_buf(compiler, 1 + ((type < SLJIT_CALL3) ? 3 : 6));
+       inst = (sljit_u8*)ensure_buf(compiler, 1 + ((type < SLJIT_CALL3) ? 3 : 6));
        FAIL_IF(!inst);
        INC_SIZE((type < SLJIT_CALL3) ? 3 : 6);
        if (type >= SLJIT_CALL3) {
@@ -589,9 +589,9 @@ static SLJIT_INLINE sljit_si call_with_args(struct sljit_compiler *compiler, slj
        return SLJIT_SUCCESS;
 }
 
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_enter(struct sljit_compiler *compiler, sljit_si dst, sljit_sw dstw)
+SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_fast_enter(struct sljit_compiler *compiler, sljit_s32 dst, sljit_sw dstw)
 {
-       sljit_ub *inst;
+       sljit_u8 *inst;
 
        CHECK_ERROR();
        CHECK(check_sljit_emit_fast_enter(compiler, dst, dstw));
@@ -603,14 +603,14 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_enter(struct sljit_compiler *c
 
        if (FAST_IS_REG(dst)) {
                if (reg_map[dst] < 8) {
-                       inst = (sljit_ub*)ensure_buf(compiler, 1 + 1);
+                       inst = (sljit_u8*)ensure_buf(compiler, 1 + 1);
                        FAIL_IF(!inst);
                        INC_SIZE(1);
                        POP_REG(reg_lmap[dst]);
                        return SLJIT_SUCCESS;
                }
 
-               inst = (sljit_ub*)ensure_buf(compiler, 1 + 2);
+               inst = (sljit_u8*)ensure_buf(compiler, 1 + 2);
                FAIL_IF(!inst);
                INC_SIZE(2);
                *inst++ = REX_B;
@@ -626,9 +626,9 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_enter(struct sljit_compiler *c
        return SLJIT_SUCCESS;
 }
 
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_return(struct sljit_compiler *compiler, sljit_si src, sljit_sw srcw)
+SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_fast_return(struct sljit_compiler *compiler, sljit_s32 src, sljit_sw srcw)
 {
-       sljit_ub *inst;
+       sljit_u8 *inst;
 
        CHECK_ERROR();
        CHECK(check_sljit_emit_fast_return(compiler, src, srcw));
@@ -641,14 +641,14 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_return(struct sljit_compiler *
 
        if (FAST_IS_REG(src)) {
                if (reg_map[src] < 8) {
-                       inst = (sljit_ub*)ensure_buf(compiler, 1 + 1 + 1);
+                       inst = (sljit_u8*)ensure_buf(compiler, 1 + 1 + 1);
                        FAIL_IF(!inst);
 
                        INC_SIZE(1 + 1);
                        PUSH_REG(reg_lmap[src]);
                }
                else {
-                       inst = (sljit_ub*)ensure_buf(compiler, 1 + 2 + 1);
+                       inst = (sljit_u8*)ensure_buf(compiler, 1 + 2 + 1);
                        FAIL_IF(!inst);
 
                        INC_SIZE(2 + 1);
@@ -664,20 +664,20 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_return(struct sljit_compiler *
                *inst++ = GROUP_FF;
                *inst |= PUSH_rm;
 
-               inst = (sljit_ub*)ensure_buf(compiler, 1 + 1);
+               inst = (sljit_u8*)ensure_buf(compiler, 1 + 1);
                FAIL_IF(!inst);
                INC_SIZE(1);
        }
        else {
                SLJIT_ASSERT(IS_HALFWORD(srcw));
                /* SLJIT_IMM. */
-               inst = (sljit_ub*)ensure_buf(compiler, 1 + 5 + 1);
+               inst = (sljit_u8*)ensure_buf(compiler, 1 + 5 + 1);
                FAIL_IF(!inst);
 
                INC_SIZE(5 + 1);
                *inst++ = PUSH_i32;
-               *(sljit_si*)inst = srcw;
-               inst += sizeof(sljit_si);
+               *(sljit_s32*)inst = srcw;
+               inst += sizeof(sljit_s32);
        }
 
        RET();
@@ -689,12 +689,12 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_return(struct sljit_compiler *
 /*  Extend input                                                         */
 /* --------------------------------------------------------------------- */
 
-static sljit_si emit_mov_int(struct sljit_compiler *compiler, sljit_si sign,
-       sljit_si dst, sljit_sw dstw,
-       sljit_si src, sljit_sw srcw)
+static sljit_s32 emit_mov_int(struct sljit_compiler *compiler, sljit_s32 sign,
+       sljit_s32 dst, sljit_sw dstw,
+       sljit_s32 src, sljit_sw srcw)
 {
-       sljit_ub* inst;
-       sljit_si dst_r;
+       sljit_u8* inst;
+       sljit_s32 dst_r;
 
        compiler->mode32 = 0;
 
@@ -704,7 +704,7 @@ static sljit_si emit_mov_int(struct sljit_compiler *compiler, sljit_si sign,
        if (src & SLJIT_IMM) {
                if (FAST_IS_REG(dst)) {
                        if (sign || ((sljit_uw)srcw <= 0x7fffffff)) {
-                               inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, (sljit_sw)(sljit_si)srcw, dst, dstw);
+                               inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, (sljit_sw)(sljit_s32)srcw, dst, dstw);
                                FAIL_IF(!inst);
                                *inst = MOV_rm_i32;
                                return SLJIT_SUCCESS;
@@ -712,7 +712,7 @@ static sljit_si emit_mov_int(struct sljit_compiler *compiler, sljit_si sign,
                        return emit_load_imm64(compiler, dst, srcw);
                }
                compiler->mode32 = 1;
-               inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, (sljit_sw)(sljit_si)srcw, dst, dstw);
+               inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, (sljit_sw)(sljit_s32)srcw, dst, dstw);
                FAIL_IF(!inst);
                *inst = MOV_rm_i32;
                compiler->mode32 = 0;