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