version 1.1.1.2, 2012/02/21 23:50:25
|
version 1.1.1.3, 2012/10/09 09:19:18
|
Line 166
|
Line 166
|
#define MOVABLE_INS 33 |
#define MOVABLE_INS 33 |
#endif |
#endif |
|
|
|
#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) |
|
#define SLJIT_HAS_VARIABLE_LOCALS_OFFSET 1 |
|
#endif |
|
|
|
#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) |
|
#define SLJIT_HAS_FIXED_LOCALS_OFFSET 1 |
|
#ifdef _WIN64 |
|
#define FIXED_LOCALS_OFFSET (4 * sizeof(sljit_w)) |
|
#else |
|
#define FIXED_LOCALS_OFFSET (sizeof(sljit_w)) |
|
#endif |
|
#endif |
|
|
|
#if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) |
|
#define SLJIT_HAS_FIXED_LOCALS_OFFSET 1 |
|
#define FIXED_LOCALS_OFFSET (4 * sizeof(sljit_w)) |
|
#endif |
|
|
|
#if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) |
|
#define SLJIT_HAS_FIXED_LOCALS_OFFSET 1 |
|
#define FIXED_LOCALS_OFFSET (2 * sizeof(sljit_w)) |
|
#endif |
|
|
|
#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) |
|
#define SLJIT_HAS_FIXED_LOCALS_OFFSET 1 |
|
#define FIXED_LOCALS_OFFSET ((7 + 8) * sizeof(sljit_w)) |
|
#endif |
|
|
|
#if (defined SLJIT_HAS_VARIABLE_LOCALS_OFFSET && SLJIT_HAS_VARIABLE_LOCALS_OFFSET) |
|
|
|
#define ADJUST_LOCAL_OFFSET(p, i) \ |
|
if ((p) == (SLJIT_MEM1(SLJIT_LOCALS_REG))) \ |
|
(i) += compiler->locals_offset; |
|
|
|
#elif (defined SLJIT_HAS_FIXED_LOCALS_OFFSET && SLJIT_HAS_FIXED_LOCALS_OFFSET) |
|
|
|
#define ADJUST_LOCAL_OFFSET(p, i) \ |
|
if ((p) == (SLJIT_MEM1(SLJIT_LOCALS_REG))) \ |
|
(i) += FIXED_LOCALS_OFFSET; |
|
|
|
#else |
|
|
|
#define ADJUST_LOCAL_OFFSET(p, i) |
|
|
|
#endif |
|
|
#endif /* !(defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED) */ |
#endif /* !(defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED) */ |
|
|
/* Utils can still be used even if SLJIT_CONFIG_UNSUPPORTED is set. */ |
/* Utils can still be used even if SLJIT_CONFIG_UNSUPPORTED is set. */ |
Line 192 static int compiler_initialized = 0;
|
Line 238 static int compiler_initialized = 0;
|
static void init_compiler(void); |
static void init_compiler(void); |
#endif |
#endif |
|
|
|
|
SLJIT_API_FUNC_ATTRIBUTE struct sljit_compiler* sljit_create_compiler(void) |
SLJIT_API_FUNC_ATTRIBUTE struct sljit_compiler* sljit_create_compiler(void) |
{ |
{ |
struct sljit_compiler *compiler = (struct sljit_compiler*)SLJIT_MALLOC(sizeof(struct sljit_compiler)); |
struct sljit_compiler *compiler = (struct sljit_compiler*)SLJIT_MALLOC(sizeof(struct sljit_compiler)); |
Line 473 static SLJIT_INLINE void set_const(struct sljit_const
|
Line 518 static SLJIT_INLINE void set_const(struct sljit_const
|
} |
} |
|
|
#define FUNCTION_CHECK_IS_REG(r) \ |
#define FUNCTION_CHECK_IS_REG(r) \ |
((r) == SLJIT_UNUSED || (r) == SLJIT_LOCALS_REG || \ | ((r) == SLJIT_UNUSED || \ |
((r) >= SLJIT_TEMPORARY_REG1 && (r) <= SLJIT_TEMPORARY_REG3 && (r) <= SLJIT_TEMPORARY_REG1 - 1 + compiler->temporaries) || \ | ((r) >= SLJIT_TEMPORARY_REG1 && (r) <= SLJIT_TEMPORARY_REG1 - 1 + compiler->temporaries) || \ |
((r) >= SLJIT_SAVED_REG1 && (r) <= SLJIT_SAVED_REG3 && (r) <= SLJIT_SAVED_REG1 - 1 + compiler->saveds)) \ | ((r) >= SLJIT_SAVED_REG1 && (r) <= SLJIT_SAVED_REG1 - 1 + compiler->saveds)) |
|
|
#define FUNCTION_CHECK_SRC(p, i) \ |
#define FUNCTION_CHECK_SRC(p, i) \ |
SLJIT_ASSERT(compiler->temporaries != -1 && compiler->saveds != -1); \ |
SLJIT_ASSERT(compiler->temporaries != -1 && compiler->saveds != -1); \ |
if (((p) >= SLJIT_TEMPORARY_REG1 && (p) <= SLJIT_TEMPORARY_REG1 - 1 + compiler->temporaries) || \ | if (FUNCTION_CHECK_IS_REG(p)) \ |
((p) >= SLJIT_SAVED_REG1 && (p) <= SLJIT_SAVED_REG1 - 1 + compiler->saveds) || \ | SLJIT_ASSERT((i) == 0 && (p) != SLJIT_UNUSED); \ |
(p) == SLJIT_LOCALS_REG) \ | |
SLJIT_ASSERT(i == 0); \ | |
else if ((p) == SLJIT_IMM) \ |
else if ((p) == SLJIT_IMM) \ |
; \ |
; \ |
|
else if ((p) == (SLJIT_MEM1(SLJIT_LOCALS_REG))) \ |
|
SLJIT_ASSERT((i) >= 0 && (i) < compiler->logical_local_size); \ |
else if ((p) & SLJIT_MEM) { \ |
else if ((p) & SLJIT_MEM) { \ |
SLJIT_ASSERT(FUNCTION_CHECK_IS_REG((p) & 0xf)); \ |
SLJIT_ASSERT(FUNCTION_CHECK_IS_REG((p) & 0xf)); \ |
if ((p) & 0xf0) { \ |
if ((p) & 0xf0) { \ |
SLJIT_ASSERT(FUNCTION_CHECK_IS_REG(((p) >> 4) & 0xf)); \ |
SLJIT_ASSERT(FUNCTION_CHECK_IS_REG(((p) >> 4) & 0xf)); \ |
SLJIT_ASSERT(((p) & 0xf0) != (SLJIT_LOCALS_REG << 4) && !(i & ~0x3)); \ | SLJIT_ASSERT(!((i) & ~0x3)); \ |
} else \ | } \ |
SLJIT_ASSERT((((p) >> 4) & 0xf) == 0); \ | |
SLJIT_ASSERT(((p) >> 9) == 0); \ |
SLJIT_ASSERT(((p) >> 9) == 0); \ |
} \ |
} \ |
else \ |
else \ |
Line 499 static SLJIT_INLINE void set_const(struct sljit_const
|
Line 543 static SLJIT_INLINE void set_const(struct sljit_const
|
|
|
#define FUNCTION_CHECK_DST(p, i) \ |
#define FUNCTION_CHECK_DST(p, i) \ |
SLJIT_ASSERT(compiler->temporaries != -1 && compiler->saveds != -1); \ |
SLJIT_ASSERT(compiler->temporaries != -1 && compiler->saveds != -1); \ |
if (((p) >= SLJIT_TEMPORARY_REG1 && (p) <= SLJIT_TEMPORARY_REG1 - 1 + compiler->temporaries) || \ | if (FUNCTION_CHECK_IS_REG(p)) \ |
((p) >= SLJIT_SAVED_REG1 && (p) <= SLJIT_SAVED_REG1 - 1 + compiler->saveds) || \ | SLJIT_ASSERT((i) == 0); \ |
(p) == SLJIT_UNUSED) \ | else if ((p) == (SLJIT_MEM1(SLJIT_LOCALS_REG))) \ |
SLJIT_ASSERT(i == 0); \ | SLJIT_ASSERT((i) >= 0 && (i) < compiler->logical_local_size); \ |
else if ((p) & SLJIT_MEM) { \ |
else if ((p) & SLJIT_MEM) { \ |
SLJIT_ASSERT(FUNCTION_CHECK_IS_REG((p) & 0xf)); \ |
SLJIT_ASSERT(FUNCTION_CHECK_IS_REG((p) & 0xf)); \ |
if ((p) & 0xf0) { \ |
if ((p) & 0xf0) { \ |
SLJIT_ASSERT(FUNCTION_CHECK_IS_REG(((p) >> 4) & 0xf)); \ |
SLJIT_ASSERT(FUNCTION_CHECK_IS_REG(((p) >> 4) & 0xf)); \ |
SLJIT_ASSERT(((p) & 0xf0) != (SLJIT_LOCALS_REG << 4) && !(i & ~0x3)); \ | SLJIT_ASSERT(!((i) & ~0x3)); \ |
} else \ | } \ |
SLJIT_ASSERT((((p) >> 4) & 0xf) == 0); \ | |
SLJIT_ASSERT(((p) >> 9) == 0); \ |
SLJIT_ASSERT(((p) >> 9) == 0); \ |
} \ |
} \ |
else \ |
else \ |
Line 572 static char* freg_names[] = {
|
Line 615 static char* freg_names[] = {
|
|
|
#define sljit_verbose_param(p, i) \ |
#define sljit_verbose_param(p, i) \ |
if ((p) & SLJIT_IMM) \ |
if ((p) & SLJIT_IMM) \ |
fprintf(compiler->verbose, "#%"SLJIT_PRINT_D"d", (i)); \ | fprintf(compiler->verbose, "#%" SLJIT_PRINT_D "d", (i)); \ |
else if ((p) & SLJIT_MEM) { \ |
else if ((p) & SLJIT_MEM) { \ |
if ((p) & 0xf) { \ |
if ((p) & 0xf) { \ |
if (i) { \ |
if (i) { \ |
if (((p) >> 4) & 0xf) \ |
if (((p) >> 4) & 0xf) \ |
fprintf(compiler->verbose, "[%s + %s * %d]", reg_names[(p) & 0xF], reg_names[((p) >> 4)& 0xF], 1 << (i)); \ |
fprintf(compiler->verbose, "[%s + %s * %d]", reg_names[(p) & 0xF], reg_names[((p) >> 4)& 0xF], 1 << (i)); \ |
else \ |
else \ |
fprintf(compiler->verbose, "[%s + #%"SLJIT_PRINT_D"d]", reg_names[(p) & 0xF], (i)); \ | fprintf(compiler->verbose, "[%s + #%" SLJIT_PRINT_D "d]", reg_names[(p) & 0xF], (i)); \ |
} \ |
} \ |
else { \ |
else { \ |
if (((p) >> 4) & 0xf) \ |
if (((p) >> 4) & 0xf) \ |
Line 589 static char* freg_names[] = {
|
Line 632 static char* freg_names[] = {
|
} \ |
} \ |
} \ |
} \ |
else \ |
else \ |
fprintf(compiler->verbose, "[#%"SLJIT_PRINT_D"d]", (i)); \ | fprintf(compiler->verbose, "[#%" SLJIT_PRINT_D "d]", (i)); \ |
} else \ |
} else \ |
fprintf(compiler->verbose, "%s", reg_names[p]); |
fprintf(compiler->verbose, "%s", reg_names[p]); |
#define sljit_verbose_fparam(p, i) \ |
#define sljit_verbose_fparam(p, i) \ |
Line 599 static char* freg_names[] = {
|
Line 642 static char* freg_names[] = {
|
if (((p) >> 4) & 0xf) \ |
if (((p) >> 4) & 0xf) \ |
fprintf(compiler->verbose, "[%s + %s * %d]", reg_names[(p) & 0xF], reg_names[((p) >> 4)& 0xF], 1 << (i)); \ |
fprintf(compiler->verbose, "[%s + %s * %d]", reg_names[(p) & 0xF], reg_names[((p) >> 4)& 0xF], 1 << (i)); \ |
else \ |
else \ |
fprintf(compiler->verbose, "[%s + #%"SLJIT_PRINT_D"d]", reg_names[(p) & 0xF], (i)); \ | fprintf(compiler->verbose, "[%s + #%" SLJIT_PRINT_D "d]", reg_names[(p) & 0xF], (i)); \ |
} \ |
} \ |
else { \ |
else { \ |
if (((p) >> 4) & 0xF) \ |
if (((p) >> 4) & 0xF) \ |
Line 609 static char* freg_names[] = {
|
Line 652 static char* freg_names[] = {
|
} \ |
} \ |
} \ |
} \ |
else \ |
else \ |
fprintf(compiler->verbose, "[#%"SLJIT_PRINT_D"d]", (i)); \ | fprintf(compiler->verbose, "[#%" SLJIT_PRINT_D "d]", (i)); \ |
} else \ |
} else \ |
fprintf(compiler->verbose, "%s", freg_names[p]); |
fprintf(compiler->verbose, "%s", freg_names[p]); |
|
|
Line 703 static SLJIT_INLINE void check_sljit_set_context(struc
|
Line 746 static SLJIT_INLINE void check_sljit_set_context(struc
|
SLJIT_UNUSED_ARG(saveds); |
SLJIT_UNUSED_ARG(saveds); |
SLJIT_UNUSED_ARG(local_size); |
SLJIT_UNUSED_ARG(local_size); |
|
|
|
#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG) |
|
if (SLJIT_UNLIKELY(compiler->skip_checks)) { |
|
compiler->skip_checks = 0; |
|
return; |
|
} |
|
#endif |
|
|
SLJIT_ASSERT(args >= 0 && args <= 3); |
SLJIT_ASSERT(args >= 0 && args <= 3); |
SLJIT_ASSERT(temporaries >= 0 && temporaries <= SLJIT_NO_TMP_REGISTERS); |
SLJIT_ASSERT(temporaries >= 0 && temporaries <= SLJIT_NO_TMP_REGISTERS); |
SLJIT_ASSERT(saveds >= 0 && saveds <= SLJIT_NO_GEN_REGISTERS); |
SLJIT_ASSERT(saveds >= 0 && saveds <= SLJIT_NO_GEN_REGISTERS); |
Line 710 static SLJIT_INLINE void check_sljit_set_context(struc
|
Line 760 static SLJIT_INLINE void check_sljit_set_context(struc
|
SLJIT_ASSERT(local_size >= 0 && local_size <= SLJIT_MAX_LOCAL_SIZE); |
SLJIT_ASSERT(local_size >= 0 && local_size <= SLJIT_MAX_LOCAL_SIZE); |
#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) |
#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) |
if (SLJIT_UNLIKELY(!!compiler->verbose)) |
if (SLJIT_UNLIKELY(!!compiler->verbose)) |
fprintf(compiler->verbose, " fake_enter args=%d temporaries=%d saveds=%d local_size=%d\n", args, temporaries, saveds, local_size); | fprintf(compiler->verbose, " set_context args=%d temporaries=%d saveds=%d local_size=%d\n", args, temporaries, saveds, local_size); |
#endif |
#endif |
} |
} |
|
|
Line 743 static SLJIT_INLINE void check_sljit_emit_return(struc
|
Line 793 static SLJIT_INLINE void check_sljit_emit_return(struc
|
#endif |
#endif |
} |
} |
|
|
static SLJIT_INLINE void check_sljit_emit_fast_enter(struct sljit_compiler *compiler, int dst, sljit_w dstw, int args, int temporaries, int saveds, int local_size) | static SLJIT_INLINE void check_sljit_emit_fast_enter(struct sljit_compiler *compiler, int dst, sljit_w dstw) |
{ |
{ |
/* If debug and verbose are disabled, all arguments are unused. */ |
/* If debug and verbose are disabled, all arguments are unused. */ |
SLJIT_UNUSED_ARG(compiler); |
SLJIT_UNUSED_ARG(compiler); |
SLJIT_UNUSED_ARG(dst); |
SLJIT_UNUSED_ARG(dst); |
SLJIT_UNUSED_ARG(dstw); |
SLJIT_UNUSED_ARG(dstw); |
SLJIT_UNUSED_ARG(args); |
|
SLJIT_UNUSED_ARG(temporaries); |
|
SLJIT_UNUSED_ARG(saveds); |
|
SLJIT_UNUSED_ARG(local_size); |
|
|
|
SLJIT_ASSERT(args >= 0 && args <= 3); |
|
SLJIT_ASSERT(temporaries >= 0 && temporaries <= SLJIT_NO_TMP_REGISTERS); |
|
SLJIT_ASSERT(saveds >= 0 && saveds <= SLJIT_NO_GEN_REGISTERS); |
|
SLJIT_ASSERT(args <= saveds); |
|
SLJIT_ASSERT(local_size >= 0 && local_size <= SLJIT_MAX_LOCAL_SIZE); |
|
#if (defined SLJIT_DEBUG && SLJIT_DEBUG) |
#if (defined SLJIT_DEBUG && SLJIT_DEBUG) |
compiler->temporaries = temporaries; |
|
compiler->saveds = saveds; |
|
FUNCTION_CHECK_DST(dst, dstw); |
FUNCTION_CHECK_DST(dst, dstw); |
compiler->temporaries = -1; |
|
compiler->saveds = -1; |
|
#endif |
#endif |
#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) |
#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) |
if (SLJIT_UNLIKELY(!!compiler->verbose)) { |
if (SLJIT_UNLIKELY(!!compiler->verbose)) { |
fprintf(compiler->verbose, " fast_enter "); |
fprintf(compiler->verbose, " fast_enter "); |
sljit_verbose_param(dst, dstw); |
sljit_verbose_param(dst, dstw); |
fprintf(compiler->verbose, " args=%d temporaries=%d saveds=%d local_size=%d\n", args, temporaries, saveds, local_size); | fprintf(compiler->verbose, "\n"); |
} |
} |
#endif |
#endif |
} |
} |
Line 1113 static SLJIT_INLINE void check_sljit_emit_cond_value(s
|
Line 1150 static SLJIT_INLINE void check_sljit_emit_cond_value(s
|
#endif |
#endif |
} |
} |
|
|
|
static SLJIT_INLINE void check_sljit_get_local_base(struct sljit_compiler *compiler, int dst, sljit_w dstw, sljit_w offset) |
|
{ |
|
SLJIT_UNUSED_ARG(compiler); |
|
SLJIT_UNUSED_ARG(dst); |
|
SLJIT_UNUSED_ARG(dstw); |
|
SLJIT_UNUSED_ARG(offset); |
|
|
|
#if (defined SLJIT_DEBUG && SLJIT_DEBUG) |
|
FUNCTION_CHECK_DST(dst, dstw); |
|
#endif |
|
#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) |
|
if (SLJIT_UNLIKELY(!!compiler->verbose)) { |
|
fprintf(compiler->verbose, " local_base "); |
|
sljit_verbose_param(dst, dstw); |
|
fprintf(compiler->verbose, ", #%" SLJIT_PRINT_D "d\n", offset); |
|
} |
|
#endif |
|
} |
|
|
static SLJIT_INLINE void check_sljit_emit_const(struct sljit_compiler *compiler, int dst, sljit_w dstw, sljit_w init_value) |
static SLJIT_INLINE void check_sljit_emit_const(struct sljit_compiler *compiler, int dst, sljit_w dstw, sljit_w init_value) |
{ |
{ |
/* If debug and verbose are disabled, all arguments are unused. */ |
/* If debug and verbose are disabled, all arguments are unused. */ |
Line 1128 static SLJIT_INLINE void check_sljit_emit_const(struct
|
Line 1184 static SLJIT_INLINE void check_sljit_emit_const(struct
|
if (SLJIT_UNLIKELY(!!compiler->verbose)) { |
if (SLJIT_UNLIKELY(!!compiler->verbose)) { |
fprintf(compiler->verbose, " const "); |
fprintf(compiler->verbose, " const "); |
sljit_verbose_param(dst, dstw); |
sljit_verbose_param(dst, dstw); |
fprintf(compiler->verbose, ", #%"SLJIT_PRINT_D"d\n", init_value); | fprintf(compiler->verbose, ", #%" SLJIT_PRINT_D "d\n", init_value); |
} |
} |
#endif |
#endif |
} |
} |
Line 1293 SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit
|
Line 1349 SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit
|
|
|
#endif |
#endif |
|
|
|
#if !(defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) && !(defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) |
|
|
|
SLJIT_API_FUNC_ATTRIBUTE int sljit_get_local_base(struct sljit_compiler *compiler, int dst, sljit_w dstw, sljit_w offset) |
|
{ |
|
CHECK_ERROR(); |
|
check_sljit_get_local_base(compiler, dst, dstw, offset); |
|
|
|
ADJUST_LOCAL_OFFSET(SLJIT_MEM1(SLJIT_LOCALS_REG), offset); |
|
#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG) |
|
compiler->skip_checks = 1; |
|
#endif |
|
if (offset != 0) |
|
return sljit_emit_op2(compiler, SLJIT_ADD | SLJIT_KEEP_FLAGS, dst, dstw, SLJIT_LOCALS_REG, 0, SLJIT_IMM, offset); |
|
return sljit_emit_op1(compiler, SLJIT_MOV, dst, dstw, SLJIT_LOCALS_REG, 0); |
|
} |
|
|
|
#endif |
|
|
#else /* SLJIT_CONFIG_UNSUPPORTED */ |
#else /* SLJIT_CONFIG_UNSUPPORTED */ |
|
|
/* Empty function bodies for those machines, which are not (yet) supported. */ |
/* Empty function bodies for those machines, which are not (yet) supported. */ |
Line 1563 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_cond_value(str
|
Line 1637 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_cond_value(str
|
SLJIT_UNUSED_ARG(dst); |
SLJIT_UNUSED_ARG(dst); |
SLJIT_UNUSED_ARG(dstw); |
SLJIT_UNUSED_ARG(dstw); |
SLJIT_UNUSED_ARG(type); |
SLJIT_UNUSED_ARG(type); |
|
SLJIT_ASSERT_STOP(); |
|
return SLJIT_ERR_UNSUPPORTED; |
|
} |
|
|
|
SLJIT_API_FUNC_ATTRIBUTE int sljit_get_local_base(struct sljit_compiler *compiler, int dst, sljit_w dstw, sljit_w offset) |
|
{ |
|
SLJIT_UNUSED_ARG(compiler); |
|
SLJIT_UNUSED_ARG(dst); |
|
SLJIT_UNUSED_ARG(dstw); |
|
SLJIT_UNUSED_ARG(offset); |
SLJIT_ASSERT_STOP(); |
SLJIT_ASSERT_STOP(); |
return SLJIT_ERR_UNSUPPORTED; |
return SLJIT_ERR_UNSUPPORTED; |
} |
} |