Home | History | Annotate | Line # | Download | only in sljit_src
sljitLir.c revision 1.1.1.3.2.2
      1 /*
      2  *    Stack-less Just-In-Time compiler
      3  *
      4  *    Copyright 2009-2012 Zoltan Herczeg (hzmester (at) freemail.hu). All rights reserved.
      5  *
      6  * Redistribution and use in source and binary forms, with or without modification, are
      7  * permitted provided that the following conditions are met:
      8  *
      9  *   1. Redistributions of source code must retain the above copyright notice, this list of
     10  *      conditions and the following disclaimer.
     11  *
     12  *   2. Redistributions in binary form must reproduce the above copyright notice, this list
     13  *      of conditions and the following disclaimer in the documentation and/or other materials
     14  *      provided with the distribution.
     15  *
     16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND CONTRIBUTORS ``AS IS'' AND ANY
     17  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     18  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
     19  * SHALL THE COPYRIGHT HOLDER(S) OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
     20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
     21  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
     22  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     23  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
     24  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     25  */
     26 
     27 #include "sljitLir.h"
     28 
     29 #define CHECK_ERROR() \
     30 	do { \
     31 		if (SLJIT_UNLIKELY(compiler->error)) \
     32 			return compiler->error; \
     33 	} while (0)
     34 
     35 #define CHECK_ERROR_PTR() \
     36 	do { \
     37 		if (SLJIT_UNLIKELY(compiler->error)) \
     38 			return NULL; \
     39 	} while (0)
     40 
     41 #define CHECK_ERROR_VOID() \
     42 	do { \
     43 		if (SLJIT_UNLIKELY(compiler->error)) \
     44 			return; \
     45 	} while (0)
     46 
     47 #define FAIL_IF(expr) \
     48 	do { \
     49 		if (SLJIT_UNLIKELY(expr)) \
     50 			return compiler->error; \
     51 	} while (0)
     52 
     53 #define PTR_FAIL_IF(expr) \
     54 	do { \
     55 		if (SLJIT_UNLIKELY(expr)) \
     56 			return NULL; \
     57 	} while (0)
     58 
     59 #define FAIL_IF_NULL(ptr) \
     60 	do { \
     61 		if (SLJIT_UNLIKELY(!(ptr))) { \
     62 			compiler->error = SLJIT_ERR_ALLOC_FAILED; \
     63 			return SLJIT_ERR_ALLOC_FAILED; \
     64 		} \
     65 	} while (0)
     66 
     67 #define PTR_FAIL_IF_NULL(ptr) \
     68 	do { \
     69 		if (SLJIT_UNLIKELY(!(ptr))) { \
     70 			compiler->error = SLJIT_ERR_ALLOC_FAILED; \
     71 			return NULL; \
     72 		} \
     73 	} while (0)
     74 
     75 #define PTR_FAIL_WITH_EXEC_IF(ptr) \
     76 	do { \
     77 		if (SLJIT_UNLIKELY(!(ptr))) { \
     78 			compiler->error = SLJIT_ERR_EX_ALLOC_FAILED; \
     79 			return NULL; \
     80 		} \
     81 	} while (0)
     82 
     83 #if !(defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
     84 
     85 #define GET_OPCODE(op) \
     86 	((op) & ~(SLJIT_INT_OP | SLJIT_SET_E | SLJIT_SET_S | SLJIT_SET_U | SLJIT_SET_O | SLJIT_SET_C | SLJIT_KEEP_FLAGS))
     87 
     88 #define GET_FLAGS(op) \
     89 	((op) & (SLJIT_SET_E | SLJIT_SET_S | SLJIT_SET_U | SLJIT_SET_O | SLJIT_SET_C))
     90 
     91 #define GET_ALL_FLAGS(op) \
     92 	((op) & (SLJIT_SET_E | SLJIT_SET_S | SLJIT_SET_U | SLJIT_SET_O | SLJIT_SET_C | SLJIT_KEEP_FLAGS))
     93 
     94 #define BUF_SIZE	4096
     95 
     96 #if (defined SLJIT_32BIT_ARCHITECTURE && SLJIT_32BIT_ARCHITECTURE)
     97 #define ABUF_SIZE	2048
     98 #else
     99 #define ABUF_SIZE	4096
    100 #endif
    101 
    102 /* Jump flags. */
    103 #define JUMP_LABEL	0x1
    104 #define JUMP_ADDR	0x2
    105 /* SLJIT_REWRITABLE_JUMP is 0x1000. */
    106 
    107 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) || (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
    108 	#define PATCH_MB	0x4
    109 	#define PATCH_MW	0x8
    110 #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
    111 	#define PATCH_MD	0x10
    112 #endif
    113 #endif
    114 
    115 #if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) || (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7)
    116 	#define IS_BL		0x4
    117 	#define PATCH_B		0x8
    118 #endif
    119 
    120 #if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5)
    121 	#define CPOOL_SIZE	512
    122 #endif
    123 
    124 #if (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
    125 	#define IS_COND		0x04
    126 	#define IS_BL		0x08
    127 	/* cannot be encoded as branch */
    128 	#define B_TYPE0		0x00
    129 	/* conditional + imm8 */
    130 	#define B_TYPE1		0x10
    131 	/* conditional + imm20 */
    132 	#define B_TYPE2		0x20
    133 	/* IT + imm24 */
    134 	#define B_TYPE3		0x30
    135 	/* imm11 */
    136 	#define B_TYPE4		0x40
    137 	/* imm24 */
    138 	#define B_TYPE5		0x50
    139 	/* BL + imm24 */
    140 	#define BL_TYPE6	0x60
    141 	/* 0xf00 cc code for branches */
    142 #endif
    143 
    144 #if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) || (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
    145 	#define UNCOND_B	0x04
    146 	#define PATCH_B		0x08
    147 	#define ABSOLUTE_B	0x10
    148 #endif
    149 
    150 #if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
    151 	#define IS_MOVABLE	0x04
    152 	#define IS_JAL		0x08
    153 	#define IS_BIT26_COND	0x10
    154 	#define IS_BIT16_COND	0x20
    155 
    156 	#define IS_COND		(IS_BIT26_COND | IS_BIT16_COND)
    157 
    158 	#define PATCH_B		0x40
    159 	#define PATCH_J		0x80
    160 
    161 	/* instruction types */
    162 	#define MOVABLE_INS	0
    163 	/* 1 - 31 last destination register */
    164 	/* no destination (i.e: store) */
    165 	#define UNMOVABLE_INS	32
    166 	/* FPU status register */
    167 	#define FCSR_FCC	33
    168 #endif
    169 
    170 #if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
    171 	#define IS_MOVABLE	0x04
    172 	#define IS_COND		0x08
    173 	#define IS_CALL		0x10
    174 
    175 	#define PATCH_B		0x20
    176 	#define PATCH_CALL	0x40
    177 
    178 	/* instruction types */
    179 	#define MOVABLE_INS	0
    180 	/* 1 - 31 last destination register */
    181 	/* no destination (i.e: store) */
    182 	#define UNMOVABLE_INS	32
    183 
    184 	#define DST_INS_MASK	0xff
    185 
    186 	/* ICC_SET is the same as SET_FLAGS. */
    187 	#define ICC_IS_SET	(1 << 23)
    188 	#define FCC_IS_SET	(1 << 24)
    189 #endif
    190 
    191 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
    192 #define SLJIT_HAS_VARIABLE_LOCALS_OFFSET 1
    193 #endif
    194 
    195 #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
    196 #define SLJIT_HAS_FIXED_LOCALS_OFFSET 1
    197 #ifdef _WIN64
    198 #define FIXED_LOCALS_OFFSET (4 * sizeof(sljit_w))
    199 #else
    200 #define FIXED_LOCALS_OFFSET (sizeof(sljit_w))
    201 #endif
    202 #endif
    203 
    204 #if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32)
    205 #define SLJIT_HAS_FIXED_LOCALS_OFFSET 1
    206 #if (defined SLJIT_INDIRECT_CALL && SLJIT_INDIRECT_CALL)
    207 #define FIXED_LOCALS_OFFSET ((6 + 8) * sizeof(sljit_w))
    208 #else
    209 #define FIXED_LOCALS_OFFSET (2 * sizeof(sljit_w))
    210 #endif
    211 #endif
    212 
    213 #if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
    214 #define SLJIT_HAS_FIXED_LOCALS_OFFSET 1
    215 #define FIXED_LOCALS_OFFSET ((6 + 8) * sizeof(sljit_w))
    216 #endif
    217 
    218 #if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
    219 #define SLJIT_HAS_FIXED_LOCALS_OFFSET 1
    220 #define FIXED_LOCALS_OFFSET (4 * sizeof(sljit_w))
    221 #endif
    222 
    223 #if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
    224 #define SLJIT_HAS_FIXED_LOCALS_OFFSET 1
    225 #define FIXED_LOCALS_OFFSET (23 * sizeof(sljit_w))
    226 #endif
    227 
    228 #if (defined SLJIT_HAS_VARIABLE_LOCALS_OFFSET && SLJIT_HAS_VARIABLE_LOCALS_OFFSET)
    229 
    230 #define ADJUST_LOCAL_OFFSET(p, i) \
    231 	if ((p) == (SLJIT_MEM1(SLJIT_LOCALS_REG))) \
    232 		(i) += compiler->locals_offset;
    233 
    234 #elif (defined SLJIT_HAS_FIXED_LOCALS_OFFSET && SLJIT_HAS_FIXED_LOCALS_OFFSET)
    235 
    236 #define ADJUST_LOCAL_OFFSET(p, i) \
    237 	if ((p) == (SLJIT_MEM1(SLJIT_LOCALS_REG))) \
    238 		(i) += FIXED_LOCALS_OFFSET;
    239 
    240 #else
    241 
    242 #define ADJUST_LOCAL_OFFSET(p, i)
    243 
    244 #endif
    245 
    246 #endif /* !(defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED) */
    247 
    248 /* Utils can still be used even if SLJIT_CONFIG_UNSUPPORTED is set. */
    249 #include "sljitUtils.c"
    250 
    251 #if !(defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
    252 
    253 #if (defined SLJIT_EXECUTABLE_ALLOCATOR && SLJIT_EXECUTABLE_ALLOCATOR)
    254 #include "sljitExecAllocator.c"
    255 #endif
    256 
    257 #if (defined SLJIT_SSE2_AUTO && SLJIT_SSE2_AUTO) && !(defined SLJIT_SSE2 && SLJIT_SSE2)
    258 #error SLJIT_SSE2_AUTO cannot be enabled without SLJIT_SSE2
    259 #endif
    260 
    261 /* --------------------------------------------------------------------- */
    262 /*  Public functions                                                     */
    263 /* --------------------------------------------------------------------- */
    264 
    265 #if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) || ((defined SLJIT_SSE2 && SLJIT_SSE2) && ((defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) || (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)))
    266 #define SLJIT_NEEDS_COMPILER_INIT 1
    267 static int compiler_initialized = 0;
    268 /* A thread safe initialization. */
    269 static void init_compiler(void);
    270 #endif
    271 
    272 SLJIT_API_FUNC_ATTRIBUTE struct sljit_compiler* sljit_create_compiler(void)
    273 {
    274 	struct sljit_compiler *compiler = (struct sljit_compiler*)SLJIT_MALLOC(sizeof(struct sljit_compiler));
    275 	if (!compiler)
    276 		return NULL;
    277 	SLJIT_ZEROMEM(compiler, sizeof(struct sljit_compiler));
    278 
    279 	SLJIT_COMPILE_ASSERT(
    280 		sizeof(sljit_b) == 1 && sizeof(sljit_ub) == 1
    281 		&& sizeof(sljit_h) == 2 && sizeof(sljit_uh) == 2
    282 		&& sizeof(sljit_i) == 4 && sizeof(sljit_ui) == 4
    283 		&& ((sizeof(sljit_w) == 4 && sizeof(sljit_uw) == 4) || (sizeof(sljit_w) == 8 && sizeof(sljit_uw) == 8)),
    284 		invalid_integer_types);
    285 
    286 	/* Only the non-zero members must be set. */
    287 	compiler->error = SLJIT_SUCCESS;
    288 
    289 	compiler->buf = (struct sljit_memory_fragment*)SLJIT_MALLOC(BUF_SIZE);
    290 	compiler->abuf = (struct sljit_memory_fragment*)SLJIT_MALLOC(ABUF_SIZE);
    291 
    292 	if (!compiler->buf || !compiler->abuf) {
    293 		if (compiler->buf)
    294 			SLJIT_FREE(compiler->buf);
    295 		if (compiler->abuf)
    296 			SLJIT_FREE(compiler->abuf);
    297 		SLJIT_FREE(compiler);
    298 		return NULL;
    299 	}
    300 
    301 	compiler->buf->next = NULL;
    302 	compiler->buf->used_size = 0;
    303 	compiler->abuf->next = NULL;
    304 	compiler->abuf->used_size = 0;
    305 
    306 	compiler->temporaries = -1;
    307 	compiler->saveds = -1;
    308 
    309 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
    310 	compiler->args = -1;
    311 #endif
    312 
    313 #if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5)
    314 	compiler->cpool = (sljit_uw*)SLJIT_MALLOC(CPOOL_SIZE * sizeof(sljit_uw) + CPOOL_SIZE * sizeof(sljit_ub));
    315 	if (!compiler->cpool) {
    316 		SLJIT_FREE(compiler->buf);
    317 		SLJIT_FREE(compiler->abuf);
    318 		SLJIT_FREE(compiler);
    319 		return NULL;
    320 	}
    321 	compiler->cpool_unique = (sljit_ub*)(compiler->cpool + CPOOL_SIZE);
    322 	compiler->cpool_diff = 0xffffffff;
    323 #endif
    324 
    325 #if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
    326 	compiler->delay_slot = UNMOVABLE_INS;
    327 #endif
    328 
    329 #if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
    330 	compiler->delay_slot = UNMOVABLE_INS;
    331 #endif
    332 
    333 #if (defined SLJIT_NEEDS_COMPILER_INIT && SLJIT_NEEDS_COMPILER_INIT)
    334 	if (!compiler_initialized) {
    335 		init_compiler();
    336 		compiler_initialized = 1;
    337 	}
    338 #endif
    339 
    340 	return compiler;
    341 }
    342 
    343 SLJIT_API_FUNC_ATTRIBUTE void sljit_free_compiler(struct sljit_compiler *compiler)
    344 {
    345 	struct sljit_memory_fragment *buf;
    346 	struct sljit_memory_fragment *curr;
    347 
    348 	buf = compiler->buf;
    349 	while (buf) {
    350 		curr = buf;
    351 		buf = buf->next;
    352 		SLJIT_FREE(curr);
    353 	}
    354 
    355 	buf = compiler->abuf;
    356 	while (buf) {
    357 		curr = buf;
    358 		buf = buf->next;
    359 		SLJIT_FREE(curr);
    360 	}
    361 
    362 #if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5)
    363 	SLJIT_FREE(compiler->cpool);
    364 #endif
    365 	SLJIT_FREE(compiler);
    366 }
    367 
    368 #if (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
    369 SLJIT_API_FUNC_ATTRIBUTE void sljit_free_code(void* code)
    370 {
    371 	/* Remove thumb mode flag. */
    372 	SLJIT_FREE_EXEC((void*)((sljit_uw)code & ~0x1));
    373 }
    374 #elif (defined SLJIT_INDIRECT_CALL && SLJIT_INDIRECT_CALL)
    375 SLJIT_API_FUNC_ATTRIBUTE void sljit_free_code(void* code)
    376 {
    377 	/* Resolve indirection. */
    378 	code = (void*)(*(sljit_uw*)code);
    379 	SLJIT_FREE_EXEC(code);
    380 }
    381 #else
    382 SLJIT_API_FUNC_ATTRIBUTE void sljit_free_code(void* code)
    383 {
    384 	SLJIT_FREE_EXEC(code);
    385 }
    386 #endif
    387 
    388 SLJIT_API_FUNC_ATTRIBUTE void sljit_set_label(struct sljit_jump *jump, struct sljit_label* label)
    389 {
    390 	if (SLJIT_LIKELY(!!jump) && SLJIT_LIKELY(!!label)) {
    391 		jump->flags &= ~JUMP_ADDR;
    392 		jump->flags |= JUMP_LABEL;
    393 		jump->u.label = label;
    394 	}
    395 }
    396 
    397 SLJIT_API_FUNC_ATTRIBUTE void sljit_set_target(struct sljit_jump *jump, sljit_uw target)
    398 {
    399 	if (SLJIT_LIKELY(!!jump)) {
    400 		SLJIT_ASSERT(jump->flags & SLJIT_REWRITABLE_JUMP);
    401 
    402 		jump->flags &= ~JUMP_LABEL;
    403 		jump->flags |= JUMP_ADDR;
    404 		jump->u.target = target;
    405 	}
    406 }
    407 
    408 /* --------------------------------------------------------------------- */
    409 /*  Private functions                                                    */
    410 /* --------------------------------------------------------------------- */
    411 
    412 static void* ensure_buf(struct sljit_compiler *compiler, int size)
    413 {
    414 	sljit_ub *ret;
    415 	struct sljit_memory_fragment *new_frag;
    416 
    417 	if (compiler->buf->used_size + size <= (int)(BUF_SIZE - sizeof(sljit_uw) - sizeof(void*))) {
    418 		ret = compiler->buf->memory + compiler->buf->used_size;
    419 		compiler->buf->used_size += size;
    420 		return ret;
    421 	}
    422 	new_frag = (struct sljit_memory_fragment*)SLJIT_MALLOC(BUF_SIZE);
    423 	PTR_FAIL_IF_NULL(new_frag);
    424 	new_frag->next = compiler->buf;
    425 	compiler->buf = new_frag;
    426 	new_frag->used_size = size;
    427 	return new_frag->memory;
    428 }
    429 
    430 static void* ensure_abuf(struct sljit_compiler *compiler, int size)
    431 {
    432 	sljit_ub *ret;
    433 	struct sljit_memory_fragment *new_frag;
    434 
    435 	if (compiler->abuf->used_size + size <= (int)(ABUF_SIZE - sizeof(sljit_uw) - sizeof(void*))) {
    436 		ret = compiler->abuf->memory + compiler->abuf->used_size;
    437 		compiler->abuf->used_size += size;
    438 		return ret;
    439 	}
    440 	new_frag = (struct sljit_memory_fragment*)SLJIT_MALLOC(ABUF_SIZE);
    441 	PTR_FAIL_IF_NULL(new_frag);
    442 	new_frag->next = compiler->abuf;
    443 	compiler->abuf = new_frag;
    444 	new_frag->used_size = size;
    445 	return new_frag->memory;
    446 }
    447 
    448 SLJIT_API_FUNC_ATTRIBUTE void* sljit_alloc_memory(struct sljit_compiler *compiler, int size)
    449 {
    450 	CHECK_ERROR_PTR();
    451 
    452 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
    453 	if (size <= 0 || size > 128)
    454 		return NULL;
    455 	size = (size + 7) & ~7;
    456 #else
    457 	if (size <= 0 || size > 64)
    458 		return NULL;
    459 	size = (size + 3) & ~3;
    460 #endif
    461 	return ensure_abuf(compiler, size);
    462 }
    463 
    464 static SLJIT_INLINE void reverse_buf(struct sljit_compiler *compiler)
    465 {
    466 	struct sljit_memory_fragment *buf = compiler->buf;
    467 	struct sljit_memory_fragment *prev = NULL;
    468 	struct sljit_memory_fragment *tmp;
    469 
    470 	do {
    471 		tmp = buf->next;
    472 		buf->next = prev;
    473 		prev = buf;
    474 		buf = tmp;
    475 	} while (buf != NULL);
    476 
    477 	compiler->buf = prev;
    478 }
    479 
    480 static SLJIT_INLINE void set_label(struct sljit_label *label, struct sljit_compiler *compiler)
    481 {
    482 	label->next = NULL;
    483 	label->size = compiler->size;
    484 	if (compiler->last_label)
    485 		compiler->last_label->next = label;
    486 	else
    487 		compiler->labels = label;
    488 	compiler->last_label = label;
    489 }
    490 
    491 static SLJIT_INLINE void set_jump(struct sljit_jump *jump, struct sljit_compiler *compiler, int flags)
    492 {
    493 	jump->next = NULL;
    494 	jump->flags = flags;
    495 	if (compiler->last_jump)
    496 		compiler->last_jump->next = jump;
    497 	else
    498 		compiler->jumps = jump;
    499 	compiler->last_jump = jump;
    500 }
    501 
    502 static SLJIT_INLINE void set_const(struct sljit_const *const_, struct sljit_compiler *compiler)
    503 {
    504 	const_->next = NULL;
    505 	const_->addr = compiler->size;
    506 	if (compiler->last_const)
    507 		compiler->last_const->next = const_;
    508 	else
    509 		compiler->consts = const_;
    510 	compiler->last_const = const_;
    511 }
    512 
    513 #define ADDRESSING_DEPENDS_ON(exp, reg) \
    514 	(((exp) & SLJIT_MEM) && (((exp) & 0xf) == reg || (((exp) >> 4) & 0xf) == reg))
    515 
    516 #if (defined SLJIT_DEBUG && SLJIT_DEBUG)
    517 #define FUNCTION_CHECK_OP() \
    518 	SLJIT_ASSERT(!GET_FLAGS(op) || !(op & SLJIT_KEEP_FLAGS)); \
    519 	switch (GET_OPCODE(op)) { \
    520 	case SLJIT_NOT: \
    521 	case SLJIT_CLZ: \
    522 	case SLJIT_AND: \
    523 	case SLJIT_OR: \
    524 	case SLJIT_XOR: \
    525 	case SLJIT_SHL: \
    526 	case SLJIT_LSHR: \
    527 	case SLJIT_ASHR: \
    528 		SLJIT_ASSERT(!(op & (SLJIT_SET_S | SLJIT_SET_U | SLJIT_SET_O | SLJIT_SET_C))); \
    529 		break; \
    530 	case SLJIT_NEG: \
    531 		SLJIT_ASSERT(!(op & (SLJIT_SET_S | SLJIT_SET_U | SLJIT_SET_C))); \
    532 		break; \
    533 	case SLJIT_MUL: \
    534 		SLJIT_ASSERT(!(op & (SLJIT_SET_E | SLJIT_SET_S | SLJIT_SET_U | SLJIT_SET_C))); \
    535 		break; \
    536 	case SLJIT_FCMP: \
    537 		SLJIT_ASSERT(!(op & (SLJIT_INT_OP | SLJIT_SET_U | SLJIT_SET_O | SLJIT_SET_C | SLJIT_KEEP_FLAGS))); \
    538 		SLJIT_ASSERT((op & (SLJIT_SET_E | SLJIT_SET_S))); \
    539 		break; \
    540 	case SLJIT_ADD: \
    541 		SLJIT_ASSERT(!(op & (SLJIT_SET_S | SLJIT_SET_U))); \
    542 		break; \
    543 	case SLJIT_SUB: \
    544 		break; \
    545 	case SLJIT_ADDC: \
    546 	case SLJIT_SUBC: \
    547 		SLJIT_ASSERT(!(op & (SLJIT_SET_E | SLJIT_SET_S | SLJIT_SET_U | SLJIT_SET_O))); \
    548 		break; \
    549 	default: \
    550 		/* Nothing allowed */ \
    551 		SLJIT_ASSERT(!(op & (SLJIT_INT_OP | SLJIT_SET_E | SLJIT_SET_S | SLJIT_SET_U | SLJIT_SET_O | SLJIT_SET_C | SLJIT_KEEP_FLAGS))); \
    552 		break; \
    553 	}
    554 
    555 #define FUNCTION_CHECK_IS_REG(r) \
    556 	((r) == SLJIT_UNUSED || \
    557 	((r) >= SLJIT_TEMPORARY_REG1 && (r) <= SLJIT_TEMPORARY_REG1 - 1 + compiler->temporaries) || \
    558 	((r) >= SLJIT_SAVED_REG1 && (r) <= SLJIT_SAVED_REG1 - 1 + compiler->saveds))
    559 
    560 #define FUNCTION_CHECK_SRC(p, i) \
    561 	SLJIT_ASSERT(compiler->temporaries != -1 && compiler->saveds != -1); \
    562 	if (FUNCTION_CHECK_IS_REG(p)) \
    563 		SLJIT_ASSERT((i) == 0 && (p) != SLJIT_UNUSED); \
    564 	else if ((p) == SLJIT_IMM) \
    565 		; \
    566 	else if ((p) == (SLJIT_MEM1(SLJIT_LOCALS_REG))) \
    567 		SLJIT_ASSERT((i) >= 0 && (i) < compiler->logical_local_size); \
    568 	else if ((p) & SLJIT_MEM) { \
    569 		SLJIT_ASSERT(FUNCTION_CHECK_IS_REG((p) & 0xf)); \
    570 		if ((p) & 0xf0) { \
    571 			SLJIT_ASSERT(FUNCTION_CHECK_IS_REG(((p) >> 4) & 0xf)); \
    572 			SLJIT_ASSERT(!((i) & ~0x3)); \
    573 		} \
    574 		SLJIT_ASSERT(((p) >> 9) == 0); \
    575 	} \
    576 	else \
    577 		SLJIT_ASSERT_STOP();
    578 
    579 #define FUNCTION_CHECK_DST(p, i) \
    580 	SLJIT_ASSERT(compiler->temporaries != -1 && compiler->saveds != -1); \
    581 	if (FUNCTION_CHECK_IS_REG(p)) \
    582 		SLJIT_ASSERT((i) == 0); \
    583 	else if ((p) == (SLJIT_MEM1(SLJIT_LOCALS_REG))) \
    584 		SLJIT_ASSERT((i) >= 0 && (i) < compiler->logical_local_size); \
    585 	else if ((p) & SLJIT_MEM) { \
    586 		SLJIT_ASSERT(FUNCTION_CHECK_IS_REG((p) & 0xf)); \
    587 		if ((p) & 0xf0) { \
    588 			SLJIT_ASSERT(FUNCTION_CHECK_IS_REG(((p) >> 4) & 0xf)); \
    589 			SLJIT_ASSERT(!((i) & ~0x3)); \
    590 		} \
    591 		SLJIT_ASSERT(((p) >> 9) == 0); \
    592 	} \
    593 	else \
    594 		SLJIT_ASSERT_STOP();
    595 
    596 #define FUNCTION_FCHECK(p, i) \
    597 	if ((p) >= SLJIT_FLOAT_REG1 && (p) <= SLJIT_FLOAT_REG4) \
    598 		SLJIT_ASSERT(i == 0); \
    599 	else if ((p) & SLJIT_MEM) { \
    600 		SLJIT_ASSERT(FUNCTION_CHECK_IS_REG((p) & 0xf)); \
    601 		if ((p) & 0xf0) { \
    602 			SLJIT_ASSERT(FUNCTION_CHECK_IS_REG(((p) >> 4) & 0xf)); \
    603 			SLJIT_ASSERT(((p) & 0xf0) != (SLJIT_LOCALS_REG << 4) && !(i & ~0x3)); \
    604 		} else \
    605 			SLJIT_ASSERT((((p) >> 4) & 0xf) == 0); \
    606 		SLJIT_ASSERT(((p) >> 9) == 0); \
    607 	} \
    608 	else \
    609 		SLJIT_ASSERT_STOP();
    610 
    611 #define FUNCTION_CHECK_OP1() \
    612 	if (GET_OPCODE(op) >= SLJIT_MOV && GET_OPCODE(op) <= SLJIT_MOVU_SI) { \
    613 		SLJIT_ASSERT(!GET_ALL_FLAGS(op)); \
    614 	} \
    615         if (GET_OPCODE(op) >= SLJIT_MOVU && GET_OPCODE(op) <= SLJIT_MOVU_SI) { \
    616 		SLJIT_ASSERT(!(src & SLJIT_MEM) || (src & 0xf) != SLJIT_LOCALS_REG); \
    617 		SLJIT_ASSERT(!(dst & SLJIT_MEM) || (dst & 0xf) != SLJIT_LOCALS_REG); \
    618 		if ((src & SLJIT_MEM) && (src & 0xf)) \
    619 			SLJIT_ASSERT((dst & 0xf) != (src & 0xf) && ((dst >> 4) & 0xf) != (src & 0xf)); \
    620 	}
    621 
    622 #endif
    623 
    624 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
    625 
    626 SLJIT_API_FUNC_ATTRIBUTE void sljit_compiler_verbose(struct sljit_compiler *compiler, FILE* verbose)
    627 {
    628 	compiler->verbose = verbose;
    629 }
    630 
    631 static char* reg_names[] = {
    632 	(char*)"<noreg>", (char*)"t1", (char*)"t2", (char*)"t3",
    633 	(char*)"te1", (char*)"te2", (char*)"s1", (char*)"s2",
    634 	(char*)"s3", (char*)"se1", (char*)"se2", (char*)"lcr"
    635 };
    636 
    637 static char* freg_names[] = {
    638 	(char*)"<noreg>", (char*)"float_r1", (char*)"float_r2", (char*)"float_r3", (char*)"float_r4"
    639 };
    640 
    641 #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) || (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
    642 #ifdef _WIN64
    643 	#define SLJIT_PRINT_D	"I64"
    644 #else
    645 	#define SLJIT_PRINT_D	"l"
    646 #endif
    647 #else
    648 	#define SLJIT_PRINT_D	""
    649 #endif
    650 
    651 #define sljit_verbose_param(p, i) \
    652 	if ((p) & SLJIT_IMM) \
    653 		fprintf(compiler->verbose, "#%" SLJIT_PRINT_D "d", (i)); \
    654 	else if ((p) & SLJIT_MEM) { \
    655 		if ((p) & 0xf) { \
    656 			if (i) { \
    657 				if (((p) >> 4) & 0xf) \
    658 					fprintf(compiler->verbose, "[%s + %s * %d]", reg_names[(p) & 0xF], reg_names[((p) >> 4)& 0xF], 1 << (i)); \
    659 				else \
    660 					fprintf(compiler->verbose, "[%s + #%" SLJIT_PRINT_D "d]", reg_names[(p) & 0xF], (i)); \
    661 			} \
    662 			else { \
    663 				if (((p) >> 4) & 0xf) \
    664 					fprintf(compiler->verbose, "[%s + %s]", reg_names[(p) & 0xF], reg_names[((p) >> 4)& 0xF]); \
    665 				else \
    666 					fprintf(compiler->verbose, "[%s]", reg_names[(p) & 0xF]); \
    667 			} \
    668 		} \
    669 		else \
    670 			fprintf(compiler->verbose, "[#%" SLJIT_PRINT_D "d]", (i)); \
    671 	} else \
    672 		fprintf(compiler->verbose, "%s", reg_names[p]);
    673 #define sljit_verbose_fparam(p, i) \
    674 	if ((p) & SLJIT_MEM) { \
    675 		if ((p) & 0xf) { \
    676 			if (i) { \
    677 				if (((p) >> 4) & 0xf) \
    678 					fprintf(compiler->verbose, "[%s + %s * %d]", reg_names[(p) & 0xF], reg_names[((p) >> 4)& 0xF], 1 << (i)); \
    679 				else \
    680 					fprintf(compiler->verbose, "[%s + #%" SLJIT_PRINT_D "d]", reg_names[(p) & 0xF], (i)); \
    681 			} \
    682 			else { \
    683 				if (((p) >> 4) & 0xF) \
    684 					fprintf(compiler->verbose, "[%s + %s]", reg_names[(p) & 0xF], reg_names[((p) >> 4)& 0xF]); \
    685 				else \
    686 					fprintf(compiler->verbose, "[%s]", reg_names[(p) & 0xF]); \
    687 			} \
    688 		} \
    689 		else \
    690 			fprintf(compiler->verbose, "[#%" SLJIT_PRINT_D "d]", (i)); \
    691 	} else \
    692 		fprintf(compiler->verbose, "%s", freg_names[p]);
    693 
    694 static SLJIT_CONST char* op_names[] = {
    695 	/* op0 */
    696 	(char*)"breakpoint", (char*)"nop",
    697 	(char*)"umul", (char*)"smul", (char*)"udiv", (char*)"sdiv",
    698 	/* op1 */
    699 	(char*)"mov", (char*)"mov.ub", (char*)"mov.sb", (char*)"mov.uh",
    700 	(char*)"mov.sh", (char*)"mov.ui", (char*)"mov.si", (char*)"movu",
    701 	(char*)"movu.ub", (char*)"movu.sb", (char*)"movu.uh", (char*)"movu.sh",
    702 	(char*)"movu.ui", (char*)"movu.si", (char*)"not", (char*)"neg",
    703 	(char*)"clz",
    704 	/* op2 */
    705 	(char*)"add", (char*)"addc", (char*)"sub", (char*)"subc",
    706 	(char*)"mul", (char*)"and", (char*)"or", (char*)"xor",
    707 	(char*)"shl", (char*)"lshr", (char*)"ashr",
    708 	/* fop1 */
    709 	(char*)"fcmp", (char*)"fmov", (char*)"fneg", (char*)"fabs",
    710 	/* fop2 */
    711 	(char*)"fadd", (char*)"fsub", (char*)"fmul", (char*)"fdiv"
    712 };
    713 
    714 static char* jump_names[] = {
    715 	(char*)"c_equal", (char*)"c_not_equal",
    716 	(char*)"c_less", (char*)"c_greater_equal",
    717 	(char*)"c_greater", (char*)"c_less_equal",
    718 	(char*)"c_sig_less", (char*)"c_sig_greater_equal",
    719 	(char*)"c_sig_greater", (char*)"c_sig_less_equal",
    720 	(char*)"c_overflow", (char*)"c_not_overflow",
    721 	(char*)"c_mul_overflow", (char*)"c_mul_not_overflow",
    722 	(char*)"c_float_equal", (char*)"c_float_not_equal",
    723 	(char*)"c_float_less", (char*)"c_float_greater_equal",
    724 	(char*)"c_float_greater", (char*)"c_float_less_equal",
    725 	(char*)"c_float_nan", (char*)"c_float_not_nan",
    726 	(char*)"jump", (char*)"fast_call",
    727 	(char*)"call0", (char*)"call1", (char*)"call2", (char*)"call3"
    728 };
    729 
    730 #endif
    731 
    732 /* --------------------------------------------------------------------- */
    733 /*  Arch dependent                                                       */
    734 /* --------------------------------------------------------------------- */
    735 
    736 static SLJIT_INLINE void check_sljit_generate_code(struct sljit_compiler *compiler)
    737 {
    738 #if (defined SLJIT_DEBUG && SLJIT_DEBUG)
    739 	struct sljit_jump *jump;
    740 #endif
    741 	/* If debug and verbose are disabled, all arguments are unused. */
    742 	SLJIT_UNUSED_ARG(compiler);
    743 
    744 	SLJIT_ASSERT(compiler->size > 0);
    745 #if (defined SLJIT_DEBUG && SLJIT_DEBUG)
    746 	jump = compiler->jumps;
    747 	while (jump) {
    748 		/* All jumps have target. */
    749 		SLJIT_ASSERT(jump->flags & (JUMP_LABEL | JUMP_ADDR));
    750 		jump = jump->next;
    751 	}
    752 #endif
    753 }
    754 
    755 static SLJIT_INLINE void check_sljit_emit_enter(struct sljit_compiler *compiler, int args, int temporaries, int saveds, int local_size)
    756 {
    757 	/* If debug and verbose are disabled, all arguments are unused. */
    758 	SLJIT_UNUSED_ARG(compiler);
    759 	SLJIT_UNUSED_ARG(args);
    760 	SLJIT_UNUSED_ARG(temporaries);
    761 	SLJIT_UNUSED_ARG(saveds);
    762 	SLJIT_UNUSED_ARG(local_size);
    763 
    764 	SLJIT_ASSERT(args >= 0 && args <= 3);
    765 	SLJIT_ASSERT(temporaries >= 0 && temporaries <= SLJIT_NO_TMP_REGISTERS);
    766 	SLJIT_ASSERT(saveds >= 0 && saveds <= SLJIT_NO_GEN_REGISTERS);
    767 	SLJIT_ASSERT(args <= saveds);
    768 	SLJIT_ASSERT(local_size >= 0 && local_size <= SLJIT_MAX_LOCAL_SIZE);
    769 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
    770 	if (SLJIT_UNLIKELY(!!compiler->verbose))
    771 		fprintf(compiler->verbose, "  enter args=%d temporaries=%d saveds=%d local_size=%d\n", args, temporaries, saveds, local_size);
    772 #endif
    773 }
    774 
    775 static SLJIT_INLINE void check_sljit_set_context(struct sljit_compiler *compiler, int args, int temporaries, int saveds, int local_size)
    776 {
    777 	/* If debug and verbose are disabled, all arguments are unused. */
    778 	SLJIT_UNUSED_ARG(compiler);
    779 	SLJIT_UNUSED_ARG(args);
    780 	SLJIT_UNUSED_ARG(temporaries);
    781 	SLJIT_UNUSED_ARG(saveds);
    782 	SLJIT_UNUSED_ARG(local_size);
    783 
    784 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG)
    785 	if (SLJIT_UNLIKELY(compiler->skip_checks)) {
    786 		compiler->skip_checks = 0;
    787 		return;
    788 	}
    789 #endif
    790 
    791 	SLJIT_ASSERT(args >= 0 && args <= 3);
    792 	SLJIT_ASSERT(temporaries >= 0 && temporaries <= SLJIT_NO_TMP_REGISTERS);
    793 	SLJIT_ASSERT(saveds >= 0 && saveds <= SLJIT_NO_GEN_REGISTERS);
    794 	SLJIT_ASSERT(args <= saveds);
    795 	SLJIT_ASSERT(local_size >= 0 && local_size <= SLJIT_MAX_LOCAL_SIZE);
    796 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
    797 	if (SLJIT_UNLIKELY(!!compiler->verbose))
    798 		fprintf(compiler->verbose, "  set_context args=%d temporaries=%d saveds=%d local_size=%d\n", args, temporaries, saveds, local_size);
    799 #endif
    800 }
    801 
    802 static SLJIT_INLINE void check_sljit_emit_return(struct sljit_compiler *compiler, int op, int src, sljit_w srcw)
    803 {
    804 	/* If debug and verbose are disabled, all arguments are unused. */
    805 	SLJIT_UNUSED_ARG(compiler);
    806 	SLJIT_UNUSED_ARG(op);
    807 	SLJIT_UNUSED_ARG(src);
    808 	SLJIT_UNUSED_ARG(srcw);
    809 
    810 #if (defined SLJIT_DEBUG && SLJIT_DEBUG)
    811 	if (op != SLJIT_UNUSED) {
    812 		SLJIT_ASSERT(op >= SLJIT_MOV && op <= SLJIT_MOV_SI);
    813 		FUNCTION_CHECK_SRC(src, srcw);
    814 	}
    815 	else
    816 		SLJIT_ASSERT(src == 0 && srcw == 0);
    817 #endif
    818 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
    819 	if (SLJIT_UNLIKELY(!!compiler->verbose)) {
    820 		if (op == SLJIT_UNUSED)
    821 			fprintf(compiler->verbose, "  return\n");
    822 		else {
    823 			fprintf(compiler->verbose, "  return %s ", op_names[op]);
    824 			sljit_verbose_param(src, srcw);
    825 			fprintf(compiler->verbose, "\n");
    826 		}
    827 	}
    828 #endif
    829 }
    830 
    831 static SLJIT_INLINE void check_sljit_emit_fast_enter(struct sljit_compiler *compiler, int dst, sljit_w dstw)
    832 {
    833 	/* If debug and verbose are disabled, all arguments are unused. */
    834 	SLJIT_UNUSED_ARG(compiler);
    835 	SLJIT_UNUSED_ARG(dst);
    836 	SLJIT_UNUSED_ARG(dstw);
    837 
    838 #if (defined SLJIT_DEBUG && SLJIT_DEBUG)
    839 	FUNCTION_CHECK_DST(dst, dstw);
    840 #endif
    841 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
    842 	if (SLJIT_UNLIKELY(!!compiler->verbose)) {
    843 		fprintf(compiler->verbose, "  fast_enter ");
    844 		sljit_verbose_param(dst, dstw);
    845 		fprintf(compiler->verbose, "\n");
    846 	}
    847 #endif
    848 }
    849 
    850 static SLJIT_INLINE void check_sljit_emit_fast_return(struct sljit_compiler *compiler, int src, sljit_w srcw)
    851 {
    852 	/* If debug and verbose are disabled, all arguments are unused. */
    853 	SLJIT_UNUSED_ARG(compiler);
    854 	SLJIT_UNUSED_ARG(src);
    855 	SLJIT_UNUSED_ARG(srcw);
    856 
    857 #if (defined SLJIT_DEBUG && SLJIT_DEBUG)
    858 	FUNCTION_CHECK_SRC(src, srcw);
    859 #endif
    860 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
    861 	if (SLJIT_UNLIKELY(!!compiler->verbose)) {
    862 		fprintf(compiler->verbose, "  fast_return ");
    863 		sljit_verbose_param(src, srcw);
    864 		fprintf(compiler->verbose, "\n");
    865 	}
    866 #endif
    867 }
    868 
    869 static SLJIT_INLINE void check_sljit_emit_op0(struct sljit_compiler *compiler, int op)
    870 {
    871 	/* If debug and verbose are disabled, all arguments are unused. */
    872 	SLJIT_UNUSED_ARG(compiler);
    873 	SLJIT_UNUSED_ARG(op);
    874 
    875 	SLJIT_ASSERT((op >= SLJIT_BREAKPOINT && op <= SLJIT_SMUL)
    876 		|| ((op & ~SLJIT_INT_OP) >= SLJIT_UDIV && (op & ~SLJIT_INT_OP) <= SLJIT_SDIV));
    877 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
    878 	if (SLJIT_UNLIKELY(!!compiler->verbose))
    879 		fprintf(compiler->verbose, "  %s%s\n", !(op & SLJIT_INT_OP) ? "" : "i", op_names[GET_OPCODE(op)]);
    880 #endif
    881 }
    882 
    883 static SLJIT_INLINE void check_sljit_emit_op1(struct sljit_compiler *compiler, int op,
    884 	int dst, sljit_w dstw,
    885 	int src, sljit_w srcw)
    886 {
    887 	/* If debug and verbose are disabled, all arguments are unused. */
    888 	SLJIT_UNUSED_ARG(compiler);
    889 	SLJIT_UNUSED_ARG(op);
    890 	SLJIT_UNUSED_ARG(dst);
    891 	SLJIT_UNUSED_ARG(dstw);
    892 	SLJIT_UNUSED_ARG(src);
    893 	SLJIT_UNUSED_ARG(srcw);
    894 
    895 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG)
    896 	if (SLJIT_UNLIKELY(compiler->skip_checks)) {
    897 		compiler->skip_checks = 0;
    898 		return;
    899 	}
    900 #endif
    901 
    902 	SLJIT_ASSERT(GET_OPCODE(op) >= SLJIT_MOV && GET_OPCODE(op) <= SLJIT_CLZ);
    903 #if (defined SLJIT_DEBUG && SLJIT_DEBUG)
    904 	FUNCTION_CHECK_OP();
    905 	FUNCTION_CHECK_SRC(src, srcw);
    906 	FUNCTION_CHECK_DST(dst, dstw);
    907 	FUNCTION_CHECK_OP1();
    908 #endif
    909 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
    910 	if (SLJIT_UNLIKELY(!!compiler->verbose)) {
    911 		fprintf(compiler->verbose, "  %s%s%s%s%s%s%s%s ", !(op & SLJIT_INT_OP) ? "" : "i", op_names[GET_OPCODE(op)],
    912 			!(op & SLJIT_SET_E) ? "" : "E", !(op & SLJIT_SET_S) ? "" : "S", !(op & SLJIT_SET_U) ? "" : "U", !(op & SLJIT_SET_O) ? "" : "O", !(op & SLJIT_SET_C) ? "" : "C", !(op & SLJIT_KEEP_FLAGS) ? "" : "K");
    913 		sljit_verbose_param(dst, dstw);
    914 		fprintf(compiler->verbose, ", ");
    915 		sljit_verbose_param(src, srcw);
    916 		fprintf(compiler->verbose, "\n");
    917 	}
    918 #endif
    919 }
    920 
    921 static SLJIT_INLINE void check_sljit_emit_op2(struct sljit_compiler *compiler, int op,
    922 	int dst, sljit_w dstw,
    923 	int src1, sljit_w src1w,
    924 	int src2, sljit_w src2w)
    925 {
    926 	/* If debug and verbose are disabled, all arguments are unused. */
    927 	SLJIT_UNUSED_ARG(compiler);
    928 	SLJIT_UNUSED_ARG(op);
    929 	SLJIT_UNUSED_ARG(dst);
    930 	SLJIT_UNUSED_ARG(dstw);
    931 	SLJIT_UNUSED_ARG(src1);
    932 	SLJIT_UNUSED_ARG(src1w);
    933 	SLJIT_UNUSED_ARG(src2);
    934 	SLJIT_UNUSED_ARG(src2w);
    935 
    936 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG)
    937 	if (SLJIT_UNLIKELY(compiler->skip_checks)) {
    938 		compiler->skip_checks = 0;
    939 		return;
    940 	}
    941 #endif
    942 
    943 	SLJIT_ASSERT(GET_OPCODE(op) >= SLJIT_ADD && GET_OPCODE(op) <= SLJIT_ASHR);
    944 #if (defined SLJIT_DEBUG && SLJIT_DEBUG)
    945 	FUNCTION_CHECK_OP();
    946 	FUNCTION_CHECK_SRC(src1, src1w);
    947 	FUNCTION_CHECK_SRC(src2, src2w);
    948 	FUNCTION_CHECK_DST(dst, dstw);
    949 #endif
    950 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
    951 	if (SLJIT_UNLIKELY(!!compiler->verbose)) {
    952 		fprintf(compiler->verbose, "  %s%s%s%s%s%s%s%s ", !(op & SLJIT_INT_OP) ? "" : "i", op_names[GET_OPCODE(op)],
    953 			!(op & SLJIT_SET_E) ? "" : "E", !(op & SLJIT_SET_S) ? "" : "S", !(op & SLJIT_SET_U) ? "" : "U", !(op & SLJIT_SET_O) ? "" : "O", !(op & SLJIT_SET_C) ? "" : "C", !(op & SLJIT_KEEP_FLAGS) ? "" : "K");
    954 		sljit_verbose_param(dst, dstw);
    955 		fprintf(compiler->verbose, ", ");
    956 		sljit_verbose_param(src1, src1w);
    957 		fprintf(compiler->verbose, ", ");
    958 		sljit_verbose_param(src2, src2w);
    959 		fprintf(compiler->verbose, "\n");
    960 	}
    961 #endif
    962 }
    963 
    964 static SLJIT_INLINE void check_sljit_get_register_index(int reg)
    965 {
    966 	SLJIT_UNUSED_ARG(reg);
    967 	SLJIT_ASSERT(reg > 0 && reg <= SLJIT_NO_REGISTERS);
    968 }
    969 
    970 static SLJIT_INLINE void check_sljit_emit_op_custom(struct sljit_compiler *compiler,
    971 	void *instruction, int size)
    972 {
    973 	SLJIT_UNUSED_ARG(compiler);
    974 	SLJIT_UNUSED_ARG(instruction);
    975 	SLJIT_UNUSED_ARG(size);
    976 	SLJIT_ASSERT(instruction);
    977 }
    978 
    979 static SLJIT_INLINE void check_sljit_emit_fop1(struct sljit_compiler *compiler, int op,
    980 	int dst, sljit_w dstw,
    981 	int src, sljit_w srcw)
    982 {
    983 	/* If debug and verbose are disabled, all arguments are unused. */
    984 	SLJIT_UNUSED_ARG(compiler);
    985 	SLJIT_UNUSED_ARG(op);
    986 	SLJIT_UNUSED_ARG(dst);
    987 	SLJIT_UNUSED_ARG(dstw);
    988 	SLJIT_UNUSED_ARG(src);
    989 	SLJIT_UNUSED_ARG(srcw);
    990 
    991 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG)
    992 	if (SLJIT_UNLIKELY(compiler->skip_checks)) {
    993 		compiler->skip_checks = 0;
    994 		return;
    995 	}
    996 #endif
    997 
    998 	SLJIT_ASSERT(sljit_is_fpu_available());
    999 	SLJIT_ASSERT(GET_OPCODE(op) >= SLJIT_FCMP && GET_OPCODE(op) <= SLJIT_FABS);
   1000 #if (defined SLJIT_DEBUG && SLJIT_DEBUG)
   1001 	FUNCTION_CHECK_OP();
   1002 	FUNCTION_FCHECK(src, srcw);
   1003 	FUNCTION_FCHECK(dst, dstw);
   1004 #endif
   1005 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
   1006 	if (SLJIT_UNLIKELY(!!compiler->verbose)) {
   1007 		fprintf(compiler->verbose, "  %s%s%s ", op_names[GET_OPCODE(op)],
   1008 			!(op & SLJIT_SET_E) ? "" : "E", !(op & SLJIT_SET_S) ? "" : "S");
   1009 		sljit_verbose_fparam(dst, dstw);
   1010 		fprintf(compiler->verbose, ", ");
   1011 		sljit_verbose_fparam(src, srcw);
   1012 		fprintf(compiler->verbose, "\n");
   1013 	}
   1014 #endif
   1015 }
   1016 
   1017 static SLJIT_INLINE void check_sljit_emit_fop2(struct sljit_compiler *compiler, int op,
   1018 	int dst, sljit_w dstw,
   1019 	int src1, sljit_w src1w,
   1020 	int src2, sljit_w src2w)
   1021 {
   1022 	/* If debug and verbose are disabled, all arguments are unused. */
   1023 	SLJIT_UNUSED_ARG(compiler);
   1024 	SLJIT_UNUSED_ARG(op);
   1025 	SLJIT_UNUSED_ARG(dst);
   1026 	SLJIT_UNUSED_ARG(dstw);
   1027 	SLJIT_UNUSED_ARG(src1);
   1028 	SLJIT_UNUSED_ARG(src1w);
   1029 	SLJIT_UNUSED_ARG(src2);
   1030 	SLJIT_UNUSED_ARG(src2w);
   1031 
   1032 	SLJIT_ASSERT(sljit_is_fpu_available());
   1033 	SLJIT_ASSERT(GET_OPCODE(op) >= SLJIT_FADD && GET_OPCODE(op) <= SLJIT_FDIV);
   1034 #if (defined SLJIT_DEBUG && SLJIT_DEBUG)
   1035 	FUNCTION_CHECK_OP();
   1036 	FUNCTION_FCHECK(src1, src1w);
   1037 	FUNCTION_FCHECK(src2, src2w);
   1038 	FUNCTION_FCHECK(dst, dstw);
   1039 #endif
   1040 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
   1041 	if (SLJIT_UNLIKELY(!!compiler->verbose)) {
   1042 		fprintf(compiler->verbose, "  %s ", op_names[GET_OPCODE(op)]);
   1043 		sljit_verbose_fparam(dst, dstw);
   1044 		fprintf(compiler->verbose, ", ");
   1045 		sljit_verbose_fparam(src1, src1w);
   1046 		fprintf(compiler->verbose, ", ");
   1047 		sljit_verbose_fparam(src2, src2w);
   1048 		fprintf(compiler->verbose, "\n");
   1049 	}
   1050 #endif
   1051 }
   1052 
   1053 static SLJIT_INLINE void check_sljit_emit_label(struct sljit_compiler *compiler)
   1054 {
   1055 	/* If debug and verbose are disabled, all arguments are unused. */
   1056 	SLJIT_UNUSED_ARG(compiler);
   1057 
   1058 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
   1059 	if (SLJIT_UNLIKELY(!!compiler->verbose))
   1060 		fprintf(compiler->verbose, "label:\n");
   1061 #endif
   1062 }
   1063 
   1064 static SLJIT_INLINE void check_sljit_emit_jump(struct sljit_compiler *compiler, int type)
   1065 {
   1066 	/* If debug and verbose are disabled, all arguments are unused. */
   1067 	SLJIT_UNUSED_ARG(compiler);
   1068 	SLJIT_UNUSED_ARG(type);
   1069 
   1070 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG)
   1071 	if (SLJIT_UNLIKELY(compiler->skip_checks)) {
   1072 		compiler->skip_checks = 0;
   1073 		return;
   1074 	}
   1075 #endif
   1076 
   1077 	SLJIT_ASSERT(!(type & ~(0xff | SLJIT_REWRITABLE_JUMP)));
   1078 	SLJIT_ASSERT((type & 0xff) >= SLJIT_C_EQUAL && (type & 0xff) <= SLJIT_CALL3);
   1079 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
   1080 	if (SLJIT_UNLIKELY(!!compiler->verbose))
   1081 		fprintf(compiler->verbose, "  jump%s <%s>\n", !(type & SLJIT_REWRITABLE_JUMP) ? "" : "R", jump_names[type & 0xff]);
   1082 #endif
   1083 }
   1084 
   1085 static SLJIT_INLINE void check_sljit_emit_cmp(struct sljit_compiler *compiler, int type,
   1086 	int src1, sljit_w src1w,
   1087 	int src2, sljit_w src2w)
   1088 {
   1089 	SLJIT_UNUSED_ARG(compiler);
   1090 	SLJIT_UNUSED_ARG(type);
   1091 	SLJIT_UNUSED_ARG(src1);
   1092 	SLJIT_UNUSED_ARG(src1w);
   1093 	SLJIT_UNUSED_ARG(src2);
   1094 	SLJIT_UNUSED_ARG(src2w);
   1095 
   1096 	SLJIT_ASSERT(!(type & ~(0xff | SLJIT_INT_OP | SLJIT_REWRITABLE_JUMP)));
   1097 	SLJIT_ASSERT((type & 0xff) >= SLJIT_C_EQUAL && (type & 0xff) <= SLJIT_C_SIG_LESS_EQUAL);
   1098 #if (defined SLJIT_DEBUG && SLJIT_DEBUG)
   1099 	FUNCTION_CHECK_SRC(src1, src1w);
   1100 	FUNCTION_CHECK_SRC(src2, src2w);
   1101 #endif
   1102 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
   1103 	if (SLJIT_UNLIKELY(!!compiler->verbose)) {
   1104 		fprintf(compiler->verbose, "  %scmp%s <%s> ", !(type & SLJIT_INT_OP) ? "" : "i", !(type & SLJIT_REWRITABLE_JUMP) ? "" : "R", jump_names[type & 0xff]);
   1105 		sljit_verbose_param(src1, src1w);
   1106 		fprintf(compiler->verbose, ", ");
   1107 		sljit_verbose_param(src2, src2w);
   1108 		fprintf(compiler->verbose, "\n");
   1109 	}
   1110 #endif
   1111 }
   1112 
   1113 static SLJIT_INLINE void check_sljit_emit_fcmp(struct sljit_compiler *compiler, int type,
   1114 	int src1, sljit_w src1w,
   1115 	int src2, sljit_w src2w)
   1116 {
   1117 	SLJIT_UNUSED_ARG(compiler);
   1118 	SLJIT_UNUSED_ARG(type);
   1119 	SLJIT_UNUSED_ARG(src1);
   1120 	SLJIT_UNUSED_ARG(src1w);
   1121 	SLJIT_UNUSED_ARG(src2);
   1122 	SLJIT_UNUSED_ARG(src2w);
   1123 
   1124 	SLJIT_ASSERT(sljit_is_fpu_available());
   1125 	SLJIT_ASSERT(!(type & ~(0xff | SLJIT_REWRITABLE_JUMP)));
   1126 	SLJIT_ASSERT((type & 0xff) >= SLJIT_C_FLOAT_EQUAL && (type & 0xff) <= SLJIT_C_FLOAT_ORDERED);
   1127 #if (defined SLJIT_DEBUG && SLJIT_DEBUG)
   1128 	FUNCTION_FCHECK(src1, src1w);
   1129 	FUNCTION_FCHECK(src2, src2w);
   1130 #endif
   1131 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
   1132 	if (SLJIT_UNLIKELY(!!compiler->verbose)) {
   1133 		fprintf(compiler->verbose, "  fcmp%s <%s> ", !(type & SLJIT_REWRITABLE_JUMP) ? "" : "R", jump_names[type & 0xff]);
   1134 		sljit_verbose_fparam(src1, src1w);
   1135 		fprintf(compiler->verbose, ", ");
   1136 		sljit_verbose_fparam(src2, src2w);
   1137 		fprintf(compiler->verbose, "\n");
   1138 	}
   1139 #endif
   1140 }
   1141 
   1142 static SLJIT_INLINE void check_sljit_emit_ijump(struct sljit_compiler *compiler, int type, int src, sljit_w srcw)
   1143 {
   1144 	/* If debug and verbose are disabled, all arguments are unused. */
   1145 	SLJIT_UNUSED_ARG(compiler);
   1146 	SLJIT_UNUSED_ARG(type);
   1147 	SLJIT_UNUSED_ARG(src);
   1148 	SLJIT_UNUSED_ARG(srcw);
   1149 
   1150 	SLJIT_ASSERT(type >= SLJIT_JUMP && type <= SLJIT_CALL3);
   1151 #if (defined SLJIT_DEBUG && SLJIT_DEBUG)
   1152 	FUNCTION_CHECK_SRC(src, srcw);
   1153 #endif
   1154 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
   1155 	if (SLJIT_UNLIKELY(!!compiler->verbose)) {
   1156 		fprintf(compiler->verbose, "  ijump <%s> ", jump_names[type]);
   1157 		sljit_verbose_param(src, srcw);
   1158 		fprintf(compiler->verbose, "\n");
   1159 	}
   1160 #endif
   1161 }
   1162 
   1163 static SLJIT_INLINE void check_sljit_emit_cond_value(struct sljit_compiler *compiler, int op, int dst, sljit_w dstw, int type)
   1164 {
   1165 	/* If debug and verbose are disabled, all arguments are unused. */
   1166 	SLJIT_UNUSED_ARG(compiler);
   1167 	SLJIT_UNUSED_ARG(op);
   1168 	SLJIT_UNUSED_ARG(dst);
   1169 	SLJIT_UNUSED_ARG(dstw);
   1170 	SLJIT_UNUSED_ARG(type);
   1171 
   1172 	SLJIT_ASSERT(type >= SLJIT_C_EQUAL && type < SLJIT_JUMP);
   1173 	SLJIT_ASSERT(op == SLJIT_MOV || GET_OPCODE(op) == SLJIT_OR);
   1174 	SLJIT_ASSERT(GET_ALL_FLAGS(op) == 0 || GET_ALL_FLAGS(op) == SLJIT_SET_E || GET_ALL_FLAGS(op) == SLJIT_KEEP_FLAGS);
   1175 #if (defined SLJIT_DEBUG && SLJIT_DEBUG)
   1176 	FUNCTION_CHECK_DST(dst, dstw);
   1177 #endif
   1178 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
   1179 	if (SLJIT_UNLIKELY(!!compiler->verbose)) {
   1180 		fprintf(compiler->verbose, "  cond_set%s%s <%s> ", !(op & SLJIT_SET_E) ? "" : "E",
   1181 			!(op & SLJIT_KEEP_FLAGS) ? "" : "K", op_names[GET_OPCODE(op)]);
   1182 		sljit_verbose_param(dst, dstw);
   1183 		fprintf(compiler->verbose, ", <%s>\n", jump_names[type]);
   1184 	}
   1185 #endif
   1186 }
   1187 
   1188 static SLJIT_INLINE void check_sljit_get_local_base(struct sljit_compiler *compiler, int dst, sljit_w dstw, sljit_w offset)
   1189 {
   1190 	SLJIT_UNUSED_ARG(compiler);
   1191 	SLJIT_UNUSED_ARG(dst);
   1192 	SLJIT_UNUSED_ARG(dstw);
   1193 	SLJIT_UNUSED_ARG(offset);
   1194 
   1195 #if (defined SLJIT_DEBUG && SLJIT_DEBUG)
   1196 	FUNCTION_CHECK_DST(dst, dstw);
   1197 #endif
   1198 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
   1199 	if (SLJIT_UNLIKELY(!!compiler->verbose)) {
   1200 		fprintf(compiler->verbose, "  local_base ");
   1201 		sljit_verbose_param(dst, dstw);
   1202 		fprintf(compiler->verbose, ", #%" SLJIT_PRINT_D "d\n", offset);
   1203 	}
   1204 #endif
   1205 }
   1206 
   1207 static SLJIT_INLINE void check_sljit_emit_const(struct sljit_compiler *compiler, int dst, sljit_w dstw, sljit_w init_value)
   1208 {
   1209 	/* If debug and verbose are disabled, all arguments are unused. */
   1210 	SLJIT_UNUSED_ARG(compiler);
   1211 	SLJIT_UNUSED_ARG(dst);
   1212 	SLJIT_UNUSED_ARG(dstw);
   1213 	SLJIT_UNUSED_ARG(init_value);
   1214 
   1215 #if (defined SLJIT_DEBUG && SLJIT_DEBUG)
   1216 	FUNCTION_CHECK_DST(dst, dstw);
   1217 #endif
   1218 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
   1219 	if (SLJIT_UNLIKELY(!!compiler->verbose)) {
   1220 		fprintf(compiler->verbose, "  const ");
   1221 		sljit_verbose_param(dst, dstw);
   1222 		fprintf(compiler->verbose, ", #%" SLJIT_PRINT_D "d\n", init_value);
   1223 	}
   1224 #endif
   1225 }
   1226 
   1227 static SLJIT_INLINE int emit_mov_before_return(struct sljit_compiler *compiler, int op, int src, sljit_w srcw)
   1228 {
   1229 	/* Return if don't need to do anything. */
   1230 	if (op == SLJIT_UNUSED)
   1231 		return SLJIT_SUCCESS;
   1232 
   1233 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
   1234 	if (src == SLJIT_RETURN_REG && op == SLJIT_MOV)
   1235 		return SLJIT_SUCCESS;
   1236 #else
   1237 	if (src == SLJIT_RETURN_REG && (op == SLJIT_MOV || op == SLJIT_MOV_UI || op == SLJIT_MOV_SI))
   1238 		return SLJIT_SUCCESS;
   1239 #endif
   1240 
   1241 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG)
   1242 	compiler->skip_checks = 1;
   1243 #endif
   1244 	return sljit_emit_op1(compiler, op, SLJIT_RETURN_REG, 0, src, srcw);
   1245 }
   1246 
   1247 /* CPU description section */
   1248 
   1249 #if (defined SLJIT_32BIT_ARCHITECTURE && SLJIT_32BIT_ARCHITECTURE)
   1250 #define SLJIT_CPUINFO_PART1 " 32bit ("
   1251 #elif (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
   1252 #define SLJIT_CPUINFO_PART1 " 64bit ("
   1253 #else
   1254 #error "Internal error: CPU type info missing"
   1255 #endif
   1256 
   1257 #if (defined SLJIT_LITTLE_ENDIAN && SLJIT_LITTLE_ENDIAN)
   1258 #define SLJIT_CPUINFO_PART2 "little endian + "
   1259 #elif (defined SLJIT_BIG_ENDIAN && SLJIT_BIG_ENDIAN)
   1260 #define SLJIT_CPUINFO_PART2 "big endian + "
   1261 #else
   1262 #error "Internal error: CPU type info missing"
   1263 #endif
   1264 
   1265 #if (defined SLJIT_UNALIGNED && SLJIT_UNALIGNED)
   1266 #define SLJIT_CPUINFO_PART3 "unaligned)"
   1267 #else
   1268 #define SLJIT_CPUINFO_PART3 "aligned)"
   1269 #endif
   1270 
   1271 #define SLJIT_CPUINFO SLJIT_CPUINFO_PART1 SLJIT_CPUINFO_PART2 SLJIT_CPUINFO_PART3
   1272 
   1273 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
   1274 	#include "sljitNativeX86_common.c"
   1275 #elif (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
   1276 	#include "sljitNativeX86_common.c"
   1277 #elif (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5)
   1278 	#include "sljitNativeARM_v5.c"
   1279 #elif (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7)
   1280 	#include "sljitNativeARM_v5.c"
   1281 #elif (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
   1282 	#include "sljitNativeARM_Thumb2.c"
   1283 #elif (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32)
   1284 	#include "sljitNativePPC_common.c"
   1285 #elif (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
   1286 	#include "sljitNativePPC_common.c"
   1287 #elif (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
   1288 	#include "sljitNativeMIPS_common.c"
   1289 #elif (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
   1290 	#include "sljitNativeSPARC_common.c"
   1291 #endif
   1292 
   1293 #if !(defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
   1294 
   1295 SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_cmp(struct sljit_compiler *compiler, int type,
   1296 	int src1, sljit_w src1w,
   1297 	int src2, sljit_w src2w)
   1298 {
   1299 	/* Default compare for most architectures. */
   1300 	int flags, tmp_src, condition;
   1301 	sljit_w tmp_srcw;
   1302 
   1303 	CHECK_ERROR_PTR();
   1304 	check_sljit_emit_cmp(compiler, type, src1, src1w, src2, src2w);
   1305 
   1306 	condition = type & 0xff;
   1307 	if (SLJIT_UNLIKELY((src1 & SLJIT_IMM) && !(src2 & SLJIT_IMM))) {
   1308 		/* Immediate is prefered as second argument by most architectures. */
   1309 		switch (condition) {
   1310 		case SLJIT_C_LESS:
   1311 			condition = SLJIT_C_GREATER;
   1312 			break;
   1313 		case SLJIT_C_GREATER_EQUAL:
   1314 			condition = SLJIT_C_LESS_EQUAL;
   1315 			break;
   1316 		case SLJIT_C_GREATER:
   1317 			condition = SLJIT_C_LESS;
   1318 			break;
   1319 		case SLJIT_C_LESS_EQUAL:
   1320 			condition = SLJIT_C_GREATER_EQUAL;
   1321 			break;
   1322 		case SLJIT_C_SIG_LESS:
   1323 			condition = SLJIT_C_SIG_GREATER;
   1324 			break;
   1325 		case SLJIT_C_SIG_GREATER_EQUAL:
   1326 			condition = SLJIT_C_SIG_LESS_EQUAL;
   1327 			break;
   1328 		case SLJIT_C_SIG_GREATER:
   1329 			condition = SLJIT_C_SIG_LESS;
   1330 			break;
   1331 		case SLJIT_C_SIG_LESS_EQUAL:
   1332 			condition = SLJIT_C_SIG_GREATER_EQUAL;
   1333 			break;
   1334 		}
   1335 		type = condition | (type & (SLJIT_INT_OP | SLJIT_REWRITABLE_JUMP));
   1336 		tmp_src = src1;
   1337 		src1 = src2;
   1338 		src2 = tmp_src;
   1339 		tmp_srcw = src1w;
   1340 		src1w = src2w;
   1341 		src2w = tmp_srcw;
   1342 	}
   1343 
   1344 	if (condition <= SLJIT_C_NOT_ZERO)
   1345 		flags = SLJIT_SET_E;
   1346 	else if (condition <= SLJIT_C_LESS_EQUAL)
   1347 		flags = SLJIT_SET_U;
   1348 	else
   1349 		flags = SLJIT_SET_S;
   1350 
   1351 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG)
   1352 	compiler->skip_checks = 1;
   1353 #endif
   1354 	PTR_FAIL_IF(sljit_emit_op2(compiler, SLJIT_SUB | flags | (type & SLJIT_INT_OP),
   1355 		SLJIT_UNUSED, 0, src1, src1w, src2, src2w));
   1356 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG)
   1357 	compiler->skip_checks = 1;
   1358 #endif
   1359 	return sljit_emit_jump(compiler, condition | (type & SLJIT_REWRITABLE_JUMP));
   1360 }
   1361 
   1362 SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_fcmp(struct sljit_compiler *compiler, int type,
   1363 	int src1, sljit_w src1w,
   1364 	int src2, sljit_w src2w)
   1365 {
   1366 	int flags, condition;
   1367 
   1368 	check_sljit_emit_fcmp(compiler, type, src1, src1w, src2, src2w);
   1369 
   1370 	condition = type & 0xff;
   1371 	if (condition <= SLJIT_C_FLOAT_NOT_EQUAL)
   1372 		flags = SLJIT_SET_E;
   1373 	else
   1374 		flags = SLJIT_SET_S;
   1375 
   1376 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG)
   1377 	compiler->skip_checks = 1;
   1378 #endif
   1379 	sljit_emit_fop1(compiler, SLJIT_FCMP | flags, src1, src1w, src2, src2w);
   1380 
   1381 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG)
   1382 	compiler->skip_checks = 1;
   1383 #endif
   1384 	return sljit_emit_jump(compiler, condition | (type & SLJIT_REWRITABLE_JUMP));
   1385 }
   1386 
   1387 #endif
   1388 
   1389 #if !(defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) && !(defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
   1390 
   1391 SLJIT_API_FUNC_ATTRIBUTE int sljit_get_local_base(struct sljit_compiler *compiler, int dst, sljit_w dstw, sljit_w offset)
   1392 {
   1393 	CHECK_ERROR();
   1394 	check_sljit_get_local_base(compiler, dst, dstw, offset);
   1395 
   1396 	ADJUST_LOCAL_OFFSET(SLJIT_MEM1(SLJIT_LOCALS_REG), offset);
   1397 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG)
   1398 	compiler->skip_checks = 1;
   1399 #endif
   1400 	if (offset != 0)
   1401 		return sljit_emit_op2(compiler, SLJIT_ADD | SLJIT_KEEP_FLAGS, dst, dstw, SLJIT_LOCALS_REG, 0, SLJIT_IMM, offset);
   1402 	return sljit_emit_op1(compiler, SLJIT_MOV, dst, dstw, SLJIT_LOCALS_REG, 0);
   1403 }
   1404 
   1405 #endif
   1406 
   1407 #else /* SLJIT_CONFIG_UNSUPPORTED */
   1408 
   1409 /* Empty function bodies for those machines, which are not (yet) supported. */
   1410 
   1411 SLJIT_API_FUNC_ATTRIBUTE SLJIT_CONST char* sljit_get_platform_name(void)
   1412 {
   1413 	return "unsupported";
   1414 }
   1415 
   1416 SLJIT_API_FUNC_ATTRIBUTE struct sljit_compiler* sljit_create_compiler(void)
   1417 {
   1418 	SLJIT_ASSERT_STOP();
   1419 	return NULL;
   1420 }
   1421 
   1422 SLJIT_API_FUNC_ATTRIBUTE void sljit_free_compiler(struct sljit_compiler *compiler)
   1423 {
   1424 	SLJIT_UNUSED_ARG(compiler);
   1425 	SLJIT_ASSERT_STOP();
   1426 }
   1427 
   1428 SLJIT_API_FUNC_ATTRIBUTE void* sljit_alloc_memory(struct sljit_compiler *compiler, int size)
   1429 {
   1430 	SLJIT_UNUSED_ARG(compiler);
   1431 	SLJIT_UNUSED_ARG(size);
   1432 	SLJIT_ASSERT_STOP();
   1433 	return NULL;
   1434 }
   1435 
   1436 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
   1437 SLJIT_API_FUNC_ATTRIBUTE void sljit_compiler_verbose(struct sljit_compiler *compiler, FILE* verbose)
   1438 {
   1439 	SLJIT_UNUSED_ARG(compiler);
   1440 	SLJIT_UNUSED_ARG(verbose);
   1441 	SLJIT_ASSERT_STOP();
   1442 }
   1443 #endif
   1444 
   1445 SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compiler)
   1446 {
   1447 	SLJIT_UNUSED_ARG(compiler);
   1448 	SLJIT_ASSERT_STOP();
   1449 	return NULL;
   1450 }
   1451 
   1452 SLJIT_API_FUNC_ATTRIBUTE void sljit_free_code(void* code)
   1453 {
   1454 	SLJIT_UNUSED_ARG(code);
   1455 	SLJIT_ASSERT_STOP();
   1456 }
   1457 
   1458 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_enter(struct sljit_compiler *compiler, int args, int temporaries, int saveds, int local_size)
   1459 {
   1460 	SLJIT_UNUSED_ARG(compiler);
   1461 	SLJIT_UNUSED_ARG(args);
   1462 	SLJIT_UNUSED_ARG(temporaries);
   1463 	SLJIT_UNUSED_ARG(saveds);
   1464 	SLJIT_UNUSED_ARG(local_size);
   1465 	SLJIT_ASSERT_STOP();
   1466 	return SLJIT_ERR_UNSUPPORTED;
   1467 }
   1468 
   1469 SLJIT_API_FUNC_ATTRIBUTE void sljit_set_context(struct sljit_compiler *compiler, int args, int temporaries, int saveds, int local_size)
   1470 {
   1471 	SLJIT_UNUSED_ARG(compiler);
   1472 	SLJIT_UNUSED_ARG(args);
   1473 	SLJIT_UNUSED_ARG(temporaries);
   1474 	SLJIT_UNUSED_ARG(saveds);
   1475 	SLJIT_UNUSED_ARG(local_size);
   1476 	SLJIT_ASSERT_STOP();
   1477 }
   1478 
   1479 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_return(struct sljit_compiler *compiler, int op, int src, sljit_w srcw)
   1480 {
   1481 	SLJIT_UNUSED_ARG(compiler);
   1482 	SLJIT_UNUSED_ARG(op);
   1483 	SLJIT_UNUSED_ARG(src);
   1484 	SLJIT_UNUSED_ARG(srcw);
   1485 	SLJIT_ASSERT_STOP();
   1486 	return SLJIT_ERR_UNSUPPORTED;
   1487 }
   1488 
   1489 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)
   1490 {
   1491 	SLJIT_UNUSED_ARG(compiler);
   1492 	SLJIT_UNUSED_ARG(dst);
   1493 	SLJIT_UNUSED_ARG(dstw);
   1494 	SLJIT_UNUSED_ARG(args);
   1495 	SLJIT_UNUSED_ARG(temporaries);
   1496 	SLJIT_UNUSED_ARG(saveds);
   1497 	SLJIT_UNUSED_ARG(local_size);
   1498 	SLJIT_ASSERT_STOP();
   1499 	return SLJIT_ERR_UNSUPPORTED;
   1500 }
   1501 
   1502 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fast_return(struct sljit_compiler *compiler, int src, sljit_w srcw)
   1503 {
   1504 	SLJIT_UNUSED_ARG(compiler);
   1505 	SLJIT_UNUSED_ARG(src);
   1506 	SLJIT_UNUSED_ARG(srcw);
   1507 	SLJIT_ASSERT_STOP();
   1508 	return SLJIT_ERR_UNSUPPORTED;
   1509 }
   1510 
   1511 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op0(struct sljit_compiler *compiler, int op)
   1512 {
   1513 	SLJIT_UNUSED_ARG(compiler);
   1514 	SLJIT_UNUSED_ARG(op);
   1515 	SLJIT_ASSERT_STOP();
   1516 	return SLJIT_ERR_UNSUPPORTED;
   1517 }
   1518 
   1519 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op1(struct sljit_compiler *compiler, int op,
   1520 	int dst, sljit_w dstw,
   1521 	int src, sljit_w srcw)
   1522 {
   1523 	SLJIT_UNUSED_ARG(compiler);
   1524 	SLJIT_UNUSED_ARG(op);
   1525 	SLJIT_UNUSED_ARG(dst);
   1526 	SLJIT_UNUSED_ARG(dstw);
   1527 	SLJIT_UNUSED_ARG(src);
   1528 	SLJIT_UNUSED_ARG(srcw);
   1529 	SLJIT_ASSERT_STOP();
   1530 	return SLJIT_ERR_UNSUPPORTED;
   1531 }
   1532 
   1533 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op2(struct sljit_compiler *compiler, int op,
   1534 	int dst, sljit_w dstw,
   1535 	int src1, sljit_w src1w,
   1536 	int src2, sljit_w src2w)
   1537 {
   1538 	SLJIT_UNUSED_ARG(compiler);
   1539 	SLJIT_UNUSED_ARG(op);
   1540 	SLJIT_UNUSED_ARG(dst);
   1541 	SLJIT_UNUSED_ARG(dstw);
   1542 	SLJIT_UNUSED_ARG(src1);
   1543 	SLJIT_UNUSED_ARG(src1w);
   1544 	SLJIT_UNUSED_ARG(src2);
   1545 	SLJIT_UNUSED_ARG(src2w);
   1546 	SLJIT_ASSERT_STOP();
   1547 	return SLJIT_ERR_UNSUPPORTED;
   1548 }
   1549 
   1550 SLJIT_API_FUNC_ATTRIBUTE int sljit_get_register_index(int reg)
   1551 {
   1552 	SLJIT_ASSERT_STOP();
   1553 	return reg;
   1554 }
   1555 
   1556 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op_custom(struct sljit_compiler *compiler,
   1557 	void *instruction, int size)
   1558 {
   1559 	SLJIT_UNUSED_ARG(compiler);
   1560 	SLJIT_UNUSED_ARG(instruction);
   1561 	SLJIT_UNUSED_ARG(size);
   1562 	SLJIT_ASSERT_STOP();
   1563 	return SLJIT_ERR_UNSUPPORTED;
   1564 }
   1565 
   1566 SLJIT_API_FUNC_ATTRIBUTE int sljit_is_fpu_available(void)
   1567 {
   1568 	SLJIT_ASSERT_STOP();
   1569 	return 0;
   1570 }
   1571 
   1572 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fop1(struct sljit_compiler *compiler, int op,
   1573 	int dst, sljit_w dstw,
   1574 	int src, sljit_w srcw)
   1575 {
   1576 	SLJIT_UNUSED_ARG(compiler);
   1577 	SLJIT_UNUSED_ARG(op);
   1578 	SLJIT_UNUSED_ARG(dst);
   1579 	SLJIT_UNUSED_ARG(dstw);
   1580 	SLJIT_UNUSED_ARG(src);
   1581 	SLJIT_UNUSED_ARG(srcw);
   1582 	SLJIT_ASSERT_STOP();
   1583 	return SLJIT_ERR_UNSUPPORTED;
   1584 }
   1585 
   1586 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fop2(struct sljit_compiler *compiler, int op,
   1587 	int dst, sljit_w dstw,
   1588 	int src1, sljit_w src1w,
   1589 	int src2, sljit_w src2w)
   1590 {
   1591 	SLJIT_UNUSED_ARG(compiler);
   1592 	SLJIT_UNUSED_ARG(op);
   1593 	SLJIT_UNUSED_ARG(dst);
   1594 	SLJIT_UNUSED_ARG(dstw);
   1595 	SLJIT_UNUSED_ARG(src1);
   1596 	SLJIT_UNUSED_ARG(src1w);
   1597 	SLJIT_UNUSED_ARG(src2);
   1598 	SLJIT_UNUSED_ARG(src2w);
   1599 	SLJIT_ASSERT_STOP();
   1600 	return SLJIT_ERR_UNSUPPORTED;
   1601 }
   1602 
   1603 SLJIT_API_FUNC_ATTRIBUTE struct sljit_label* sljit_emit_label(struct sljit_compiler *compiler)
   1604 {
   1605 	SLJIT_UNUSED_ARG(compiler);
   1606 	SLJIT_ASSERT_STOP();
   1607 	return NULL;
   1608 }
   1609 
   1610 SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_jump(struct sljit_compiler *compiler, int type)
   1611 {
   1612 	SLJIT_UNUSED_ARG(compiler);
   1613 	SLJIT_UNUSED_ARG(type);
   1614 	SLJIT_ASSERT_STOP();
   1615 	return NULL;
   1616 }
   1617 
   1618 SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_cmp(struct sljit_compiler *compiler, int type,
   1619 	int src1, sljit_w src1w,
   1620 	int src2, sljit_w src2w)
   1621 {
   1622 	SLJIT_UNUSED_ARG(compiler);
   1623 	SLJIT_UNUSED_ARG(type);
   1624 	SLJIT_UNUSED_ARG(src1);
   1625 	SLJIT_UNUSED_ARG(src1w);
   1626 	SLJIT_UNUSED_ARG(src2);
   1627 	SLJIT_UNUSED_ARG(src2w);
   1628 	SLJIT_ASSERT_STOP();
   1629 	return NULL;
   1630 }
   1631 
   1632 SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_fcmp(struct sljit_compiler *compiler, int type,
   1633 	int src1, sljit_w src1w,
   1634 	int src2, sljit_w src2w)
   1635 {
   1636 	SLJIT_UNUSED_ARG(compiler);
   1637 	SLJIT_UNUSED_ARG(type);
   1638 	SLJIT_UNUSED_ARG(src1);
   1639 	SLJIT_UNUSED_ARG(src1w);
   1640 	SLJIT_UNUSED_ARG(src2);
   1641 	SLJIT_UNUSED_ARG(src2w);
   1642 	SLJIT_ASSERT_STOP();
   1643 	return NULL;
   1644 }
   1645 
   1646 SLJIT_API_FUNC_ATTRIBUTE void sljit_set_label(struct sljit_jump *jump, struct sljit_label* label)
   1647 {
   1648 	SLJIT_UNUSED_ARG(jump);
   1649 	SLJIT_UNUSED_ARG(label);
   1650 	SLJIT_ASSERT_STOP();
   1651 }
   1652 
   1653 SLJIT_API_FUNC_ATTRIBUTE void sljit_set_target(struct sljit_jump *jump, sljit_uw target)
   1654 {
   1655 	SLJIT_UNUSED_ARG(jump);
   1656 	SLJIT_UNUSED_ARG(target);
   1657 	SLJIT_ASSERT_STOP();
   1658 }
   1659 
   1660 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_ijump(struct sljit_compiler *compiler, int type, int src, sljit_w srcw)
   1661 {
   1662 	SLJIT_UNUSED_ARG(compiler);
   1663 	SLJIT_UNUSED_ARG(type);
   1664 	SLJIT_UNUSED_ARG(src);
   1665 	SLJIT_UNUSED_ARG(srcw);
   1666 	SLJIT_ASSERT_STOP();
   1667 	return SLJIT_ERR_UNSUPPORTED;
   1668 }
   1669 
   1670 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_cond_value(struct sljit_compiler *compiler, int op, int dst, sljit_w dstw, int type)
   1671 {
   1672 	SLJIT_UNUSED_ARG(compiler);
   1673 	SLJIT_UNUSED_ARG(op);
   1674 	SLJIT_UNUSED_ARG(dst);
   1675 	SLJIT_UNUSED_ARG(dstw);
   1676 	SLJIT_UNUSED_ARG(type);
   1677 	SLJIT_ASSERT_STOP();
   1678 	return SLJIT_ERR_UNSUPPORTED;
   1679 }
   1680 
   1681 SLJIT_API_FUNC_ATTRIBUTE int sljit_get_local_base(struct sljit_compiler *compiler, int dst, sljit_w dstw, sljit_w offset)
   1682 {
   1683 	SLJIT_UNUSED_ARG(compiler);
   1684 	SLJIT_UNUSED_ARG(dst);
   1685 	SLJIT_UNUSED_ARG(dstw);
   1686 	SLJIT_UNUSED_ARG(offset);
   1687 	SLJIT_ASSERT_STOP();
   1688 	return SLJIT_ERR_UNSUPPORTED;
   1689 }
   1690 
   1691 SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compiler *compiler, int dst, sljit_w dstw, sljit_w initval)
   1692 {
   1693 	SLJIT_UNUSED_ARG(compiler);
   1694 	SLJIT_UNUSED_ARG(dst);
   1695 	SLJIT_UNUSED_ARG(dstw);
   1696 	SLJIT_UNUSED_ARG(initval);
   1697 	SLJIT_ASSERT_STOP();
   1698 	return NULL;
   1699 }
   1700 
   1701 SLJIT_API_FUNC_ATTRIBUTE void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_addr)
   1702 {
   1703 	SLJIT_UNUSED_ARG(addr);
   1704 	SLJIT_UNUSED_ARG(new_addr);
   1705 	SLJIT_ASSERT_STOP();
   1706 }
   1707 
   1708 SLJIT_API_FUNC_ATTRIBUTE void sljit_set_const(sljit_uw addr, sljit_w new_constant)
   1709 {
   1710 	SLJIT_UNUSED_ARG(addr);
   1711 	SLJIT_UNUSED_ARG(new_constant);
   1712 	SLJIT_ASSERT_STOP();
   1713 }
   1714 
   1715 #endif
   1716