version 1.1.1.2, 2012/02/21 23:50:25
|
version 1.1.1.3, 2012/10/09 09:19:18
|
Line 515 static int emit_op_imm(struct sljit_compiler *compiler
|
Line 515 static int emit_op_imm(struct sljit_compiler *compiler
|
arg1 must be register, TMP_REG1, imm |
arg1 must be register, TMP_REG1, imm |
arg2 must be register, TMP_REG2, imm */ |
arg2 must be register, TMP_REG2, imm */ |
int reg; |
int reg; |
sljit_uw imm; | sljit_uw imm, negated_imm; |
|
|
if (SLJIT_UNLIKELY((flags & (ARG1_IMM | ARG2_IMM)) == (ARG1_IMM | ARG2_IMM))) { |
if (SLJIT_UNLIKELY((flags & (ARG1_IMM | ARG2_IMM)) == (ARG1_IMM | ARG2_IMM))) { |
/* Both are immediates. */ |
/* Both are immediates. */ |
Line 542 static int emit_op_imm(struct sljit_compiler *compiler
|
Line 542 static int emit_op_imm(struct sljit_compiler *compiler
|
/* No form with immediate operand. */ |
/* No form with immediate operand. */ |
break; |
break; |
case SLJIT_ADD: |
case SLJIT_ADD: |
|
negated_imm = (sljit_uw)-(sljit_w)imm; |
if (!(flags & KEEP_FLAGS) && IS_2_LO_REGS(reg, dst)) { |
if (!(flags & KEEP_FLAGS) && IS_2_LO_REGS(reg, dst)) { |
if (imm <= 0x7) |
if (imm <= 0x7) |
return push_inst16(compiler, ADDSI3 | IMM3(imm) | RD3(dst) | RN3(reg)); |
return push_inst16(compiler, ADDSI3 | IMM3(imm) | RD3(dst) | RN3(reg)); |
if (reg == dst && imm <= 0xff) | if (negated_imm <= 0x7) |
return push_inst16(compiler, ADDSI8 | IMM8(imm) | RDN3(dst)); | return push_inst16(compiler, SUBSI3 | IMM3(negated_imm) | RD3(dst) | RN3(reg)); |
| if (reg == dst) { |
| if (imm <= 0xff) |
| return push_inst16(compiler, ADDSI8 | IMM8(imm) | RDN3(dst)); |
| if (negated_imm <= 0xff) |
| return push_inst16(compiler, SUBSI8 | IMM8(negated_imm) | RDN3(dst)); |
| } |
} |
} |
if (imm <= 0xfff && !(flags & SET_FLAGS)) | if (!(flags & SET_FLAGS)) { |
return push_inst32(compiler, ADDWI | RD4(dst) | RN4(reg) | IMM12(imm)); | if (imm <= 0xfff) |
| return push_inst32(compiler, ADDWI | RD4(dst) | RN4(reg) | IMM12(imm)); |
| if (negated_imm <= 0xfff) |
| return push_inst32(compiler, SUBWI | RD4(dst) | RN4(reg) | IMM12(negated_imm)); |
| } |
imm = get_imm(imm); |
imm = get_imm(imm); |
if (imm != INVALID_IMM) |
if (imm != INVALID_IMM) |
return push_inst32(compiler, ADD_WI | (flags & SET_FLAGS) | RD4(dst) | RN4(reg) | imm); |
return push_inst32(compiler, ADD_WI | (flags & SET_FLAGS) | RD4(dst) | RN4(reg) | imm); |
Line 561 static int emit_op_imm(struct sljit_compiler *compiler
|
Line 572 static int emit_op_imm(struct sljit_compiler *compiler
|
break; |
break; |
case SLJIT_SUB: |
case SLJIT_SUB: |
if (flags & ARG2_IMM) { |
if (flags & ARG2_IMM) { |
|
negated_imm = (sljit_uw)-(sljit_w)imm; |
if (!(flags & KEEP_FLAGS) && IS_2_LO_REGS(reg, dst)) { |
if (!(flags & KEEP_FLAGS) && IS_2_LO_REGS(reg, dst)) { |
if (imm <= 0x7) |
if (imm <= 0x7) |
return push_inst16(compiler, SUBSI3 | IMM3(imm) | RD3(dst) | RN3(reg)); |
return push_inst16(compiler, SUBSI3 | IMM3(imm) | RD3(dst) | RN3(reg)); |
if (imm <= 0xff) { | if (negated_imm <= 0x7) |
if (reg == dst) | return push_inst16(compiler, ADDSI3 | IMM3(negated_imm) | RD3(dst) | RN3(reg)); |
| if (reg == dst) { |
| if (imm <= 0xff) |
return push_inst16(compiler, SUBSI8 | IMM8(imm) | RDN3(dst)); |
return push_inst16(compiler, SUBSI8 | IMM8(imm) | RDN3(dst)); |
if (flags & UNUSED_RETURN) | if (negated_imm <= 0xff) |
return push_inst16(compiler, CMPI | IMM8(imm) | RDN3(reg)); | return push_inst16(compiler, ADDSI8 | IMM8(negated_imm) | RDN3(dst)); |
} |
} |
|
if (imm <= 0xff && (flags & UNUSED_RETURN)) |
|
return push_inst16(compiler, CMPI | IMM8(imm) | RDN3(reg)); |
} |
} |
if (imm <= 0xfff && !(flags & SET_FLAGS)) | if (!(flags & SET_FLAGS)) { |
return push_inst32(compiler, SUBWI | RD4(dst) | RN4(reg) | IMM12(imm)); | if (imm <= 0xfff) |
| return push_inst32(compiler, SUBWI | RD4(dst) | RN4(reg) | IMM12(imm)); |
| if (negated_imm <= 0xfff) |
| return push_inst32(compiler, ADDWI | RD4(dst) | RN4(reg) | IMM12(negated_imm)); |
| } |
imm = get_imm(imm); |
imm = get_imm(imm); |
if (imm != INVALID_IMM) |
if (imm != INVALID_IMM) |
return push_inst32(compiler, SUB_WI | (flags & SET_FLAGS) | RD4(dst) | RN4(reg) | imm); |
return push_inst32(compiler, SUB_WI | (flags & SET_FLAGS) | RD4(dst) | RN4(reg) | imm); |
Line 1111 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_enter(struct s
|
Line 1131 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_enter(struct s
|
|
|
compiler->temporaries = temporaries; |
compiler->temporaries = temporaries; |
compiler->saveds = saveds; |
compiler->saveds = saveds; |
|
#if (defined SLJIT_DEBUG && SLJIT_DEBUG) |
|
compiler->logical_local_size = local_size; |
|
#endif |
|
|
push = (1 << 4); |
push = (1 << 4); |
if (saveds >= 5) |
if (saveds >= 5) |
Line 1161 SLJIT_API_FUNC_ATTRIBUTE void sljit_set_context(struct
|
Line 1184 SLJIT_API_FUNC_ATTRIBUTE void sljit_set_context(struct
|
|
|
compiler->temporaries = temporaries; |
compiler->temporaries = temporaries; |
compiler->saveds = saveds; |
compiler->saveds = saveds; |
|
#if (defined SLJIT_DEBUG && SLJIT_DEBUG) |
|
compiler->logical_local_size = local_size; |
|
#endif |
|
|
size = (3 + saveds) * sizeof(sljit_uw); |
size = (3 + saveds) * sizeof(sljit_uw); |
local_size += size; |
local_size += size; |
Line 1175 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_return(struct
|
Line 1201 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_return(struct
|
|
|
CHECK_ERROR(); |
CHECK_ERROR(); |
check_sljit_emit_return(compiler, op, src, srcw); |
check_sljit_emit_return(compiler, op, src, srcw); |
|
ADJUST_LOCAL_OFFSET(src, srcw); |
|
|
FAIL_IF(emit_mov_before_return(compiler, op, src, srcw)); |
FAIL_IF(emit_mov_before_return(compiler, op, src, srcw)); |
|
|
Line 1274 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op1(struct slj
|
Line 1301 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op1(struct slj
|
|
|
CHECK_ERROR(); |
CHECK_ERROR(); |
check_sljit_emit_op1(compiler, op, dst, dstw, src, srcw); |
check_sljit_emit_op1(compiler, op, dst, dstw, src, srcw); |
|
ADJUST_LOCAL_OFFSET(dst, dstw); |
|
ADJUST_LOCAL_OFFSET(src, srcw); |
|
|
compiler->cache_arg = 0; |
compiler->cache_arg = 0; |
compiler->cache_argw = 0; |
compiler->cache_argw = 0; |
Line 1402 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op2(struct slj
|
Line 1431 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op2(struct slj
|
|
|
CHECK_ERROR(); |
CHECK_ERROR(); |
check_sljit_emit_op2(compiler, op, dst, dstw, src1, src1w, src2, src2w); |
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); |
|
|
compiler->cache_arg = 0; |
compiler->cache_arg = 0; |
compiler->cache_argw = 0; |
compiler->cache_argw = 0; |
Line 1645 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fop2(struct sl
|
Line 1677 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fop2(struct sl
|
/* Other instructions */ |
/* Other instructions */ |
/* --------------------------------------------------------------------- */ |
/* --------------------------------------------------------------------- */ |
|
|
SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fast_enter(struct sljit_compiler *compiler, int dst, sljit_w dstw, int args, int temporaries, int saveds, int local_size) | SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fast_enter(struct sljit_compiler *compiler, int dst, sljit_w dstw) |
{ |
{ |
int size; |
|
|
|
CHECK_ERROR(); |
CHECK_ERROR(); |
check_sljit_emit_fast_enter(compiler, dst, dstw, args, temporaries, saveds, local_size); | check_sljit_emit_fast_enter(compiler, dst, dstw); |
| ADJUST_LOCAL_OFFSET(dst, dstw); |
|
|
compiler->temporaries = temporaries; |
|
compiler->saveds = saveds; |
|
|
|
size = (3 + saveds) * sizeof(sljit_uw); |
|
local_size += size; |
|
local_size = (local_size + 7) & ~7; |
|
local_size -= size; |
|
compiler->local_size = local_size; |
|
|
|
if (dst >= SLJIT_TEMPORARY_REG1 && dst <= SLJIT_NO_REGISTERS) |
if (dst >= SLJIT_TEMPORARY_REG1 && dst <= SLJIT_NO_REGISTERS) |
return push_inst16(compiler, MOV | SET_REGS44(dst, TMP_REG3)); |
return push_inst16(compiler, MOV | SET_REGS44(dst, TMP_REG3)); |
else if (dst & SLJIT_MEM) { |
else if (dst & SLJIT_MEM) { |
Line 1679 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fast_return(st
|
Line 1701 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fast_return(st
|
{ |
{ |
CHECK_ERROR(); |
CHECK_ERROR(); |
check_sljit_emit_fast_return(compiler, src, srcw); |
check_sljit_emit_fast_return(compiler, src, srcw); |
|
ADJUST_LOCAL_OFFSET(src, srcw); |
|
|
if (src >= SLJIT_TEMPORARY_REG1 && src <= SLJIT_NO_REGISTERS) |
if (src >= SLJIT_TEMPORARY_REG1 && src <= SLJIT_NO_REGISTERS) |
FAIL_IF(push_inst16(compiler, MOV | SET_REGS44(TMP_REG3, src))); |
FAIL_IF(push_inst16(compiler, MOV | SET_REGS44(TMP_REG3, src))); |
Line 1810 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_ijump(struct s
|
Line 1833 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_ijump(struct s
|
|
|
CHECK_ERROR(); |
CHECK_ERROR(); |
check_sljit_emit_ijump(compiler, type, src, srcw); |
check_sljit_emit_ijump(compiler, type, src, srcw); |
|
ADJUST_LOCAL_OFFSET(src, srcw); |
|
|
/* In ARM, we don't need to touch the arguments. */ |
/* In ARM, we don't need to touch the arguments. */ |
if (src & SLJIT_IMM) { |
if (src & SLJIT_IMM) { |
Line 1840 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_cond_value(str
|
Line 1864 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_cond_value(str
|
|
|
CHECK_ERROR(); |
CHECK_ERROR(); |
check_sljit_emit_cond_value(compiler, op, dst, dstw, type); |
check_sljit_emit_cond_value(compiler, op, dst, dstw, type); |
|
ADJUST_LOCAL_OFFSET(dst, dstw); |
|
|
if (dst == SLJIT_UNUSED) |
if (dst == SLJIT_UNUSED) |
return SLJIT_SUCCESS; |
return SLJIT_SUCCESS; |
Line 1887 SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emi
|
Line 1912 SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emi
|
|
|
CHECK_ERROR_PTR(); |
CHECK_ERROR_PTR(); |
check_sljit_emit_const(compiler, dst, dstw, init_value); |
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)); |
const_ = (struct sljit_const*)ensure_abuf(compiler, sizeof(struct sljit_const)); |
PTR_FAIL_IF(!const_); |
PTR_FAIL_IF(!const_); |