2 * Stack-less Just-In-Time compiler
4 * Copyright Zoltan Herczeg (hzmester@freemail.hu). All rights reserved.
6 * Redistribution and use in source and binary forms, with or without modification, are
7 * permitted provided that the following conditions are met:
9 * 1. Redistributions of source code must retain the above copyright notice, this list of
10 * conditions and the following disclaimer.
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.
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.
35 #if !(defined SLJIT_STD_MACROS_DEFINED && SLJIT_STD_MACROS_DEFINED)
37 /* These libraries are needed for the macros below. */
41 #endif /* SLJIT_STD_MACROS_DEFINED */
43 #define CHECK_ERROR() \
45 if (SLJIT_UNLIKELY(compiler->error)) \
46 return compiler->error; \
49 #define CHECK_ERROR_PTR() \
51 if (SLJIT_UNLIKELY(compiler->error)) \
55 #define FAIL_IF(expr) \
57 if (SLJIT_UNLIKELY(expr)) \
58 return compiler->error; \
61 #define PTR_FAIL_IF(expr) \
63 if (SLJIT_UNLIKELY(expr)) \
67 #define FAIL_IF_NULL(ptr) \
69 if (SLJIT_UNLIKELY(!(ptr))) { \
70 compiler->error = SLJIT_ERR_ALLOC_FAILED; \
71 return SLJIT_ERR_ALLOC_FAILED; \
75 #define PTR_FAIL_IF_NULL(ptr) \
77 if (SLJIT_UNLIKELY(!(ptr))) { \
78 compiler->error = SLJIT_ERR_ALLOC_FAILED; \
83 #define PTR_FAIL_WITH_EXEC_IF(ptr) \
85 if (SLJIT_UNLIKELY(!(ptr))) { \
86 compiler->error = SLJIT_ERR_EX_ALLOC_FAILED; \
91 #if !(defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
93 #define VARIABLE_FLAG_SHIFT (10)
94 #define VARIABLE_FLAG_MASK (0x3f << VARIABLE_FLAG_SHIFT)
95 #define GET_FLAG_TYPE(op) ((op) >> VARIABLE_FLAG_SHIFT)
97 #define GET_OPCODE(op) \
98 ((op) & ~(SLJIT_I32_OP | SLJIT_SET_Z | VARIABLE_FLAG_MASK))
100 #define HAS_FLAGS(op) \
101 ((op) & (SLJIT_SET_Z | VARIABLE_FLAG_MASK))
103 #define GET_ALL_FLAGS(op) \
104 ((op) & (SLJIT_I32_OP | SLJIT_SET_Z | VARIABLE_FLAG_MASK))
106 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
107 #define TYPE_CAST_NEEDED(op) \
108 ((op) >= SLJIT_MOV_U8 && (op) <= SLJIT_MOV_S32)
110 #define TYPE_CAST_NEEDED(op) \
111 ((op) >= SLJIT_MOV_U8 && (op) <= SLJIT_MOV_S16)
114 #define BUF_SIZE 4096
116 #if (defined SLJIT_32BIT_ARCHITECTURE && SLJIT_32BIT_ARCHITECTURE)
117 #define ABUF_SIZE 2048
119 #define ABUF_SIZE 4096
122 /* Parameter parsing. */
123 #define REG_MASK 0x3f
124 #define OFFS_REG(reg) (((reg) >> 8) & REG_MASK)
125 #define OFFS_REG_MASK (REG_MASK << 8)
126 #define TO_OFFS_REG(reg) ((reg) << 8)
127 /* When reg cannot be unused. */
128 #define FAST_IS_REG(reg) ((reg) <= REG_MASK)
129 /* When reg can be unused. */
130 #define SLOW_IS_REG(reg) ((reg) > 0 && (reg) <= REG_MASK)
132 /* Mask for argument types. */
133 #define SLJIT_DEF_MASK ((1 << SLJIT_DEF_SHIFT) - 1)
136 #define JUMP_LABEL 0x1
137 #define JUMP_ADDR 0x2
138 /* SLJIT_REWRITABLE_JUMP is 0x1000. */
140 #if (defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86)
141 # define PATCH_MB 0x4
142 # define PATCH_MW 0x8
143 #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
144 # define PATCH_MD 0x10
146 # define TYPE_SHIFT 13
149 #if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) || (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7)
154 #if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5)
155 # define CPOOL_SIZE 512
158 #if (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
159 # define IS_COND 0x04
161 /* conditional + imm8 */
162 # define PATCH_TYPE1 0x10
163 /* conditional + imm20 */
164 # define PATCH_TYPE2 0x20
166 # define PATCH_TYPE3 0x30
168 # define PATCH_TYPE4 0x40
170 # define PATCH_TYPE5 0x50
172 # define PATCH_BL 0x60
173 /* 0xf00 cc code for branches */
176 #if (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64)
177 # define IS_COND 0x004
178 # define IS_CBZ 0x008
180 # define PATCH_B 0x020
181 # define PATCH_COND 0x040
182 # define PATCH_ABS48 0x080
183 # define PATCH_ABS64 0x100
186 #if (defined SLJIT_CONFIG_PPC && SLJIT_CONFIG_PPC)
187 # define IS_COND 0x004
188 # define IS_CALL 0x008
189 # define PATCH_B 0x010
190 # define PATCH_ABS_B 0x020
191 #if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
192 # define PATCH_ABS32 0x040
193 # define PATCH_ABS48 0x080
195 # define REMOVE_COND 0x100
198 #if (defined SLJIT_CONFIG_MIPS && SLJIT_CONFIG_MIPS)
199 # define IS_MOVABLE 0x004
200 # define IS_JAL 0x008
201 # define IS_CALL 0x010
202 # define IS_BIT26_COND 0x020
203 # define IS_BIT16_COND 0x040
204 # define IS_BIT23_COND 0x080
206 # define IS_COND (IS_BIT26_COND | IS_BIT16_COND | IS_BIT23_COND)
208 # define PATCH_B 0x100
209 # define PATCH_J 0x200
211 #if (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64)
212 # define PATCH_ABS32 0x400
213 # define PATCH_ABS48 0x800
216 /* instruction types */
217 # define MOVABLE_INS 0
218 /* 1 - 31 last destination register */
219 /* no destination (i.e: store) */
220 # define UNMOVABLE_INS 32
221 /* FPU status register */
225 #if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
226 # define IS_MOVABLE 0x04
227 # define IS_COND 0x08
228 # define IS_CALL 0x10
230 # define PATCH_B 0x20
231 # define PATCH_CALL 0x40
233 /* instruction types */
234 # define MOVABLE_INS 0
235 /* 1 - 31 last destination register */
236 /* no destination (i.e: store) */
237 # define UNMOVABLE_INS 32
239 # define DST_INS_MASK 0xff
241 /* ICC_SET is the same as SET_FLAGS. */
242 # define ICC_IS_SET (1 << 23)
243 # define FCC_IS_SET (1 << 24)
246 /* Stack management. */
248 #define GET_SAVED_REGISTERS_SIZE(scratches, saveds, extra) \
249 (((scratches < SLJIT_NUMBER_OF_SCRATCH_REGISTERS ? 0 : (scratches - SLJIT_NUMBER_OF_SCRATCH_REGISTERS)) + \
250 (saveds < SLJIT_NUMBER_OF_SAVED_REGISTERS ? saveds : SLJIT_NUMBER_OF_SAVED_REGISTERS) + \
251 extra) * sizeof(sljit_sw))
253 #define ADJUST_LOCAL_OFFSET(p, i) \
254 if ((p) == (SLJIT_MEM1(SLJIT_SP))) \
255 (i) += SLJIT_LOCALS_OFFSET;
257 #endif /* !(defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED) */
259 /* Utils can still be used even if SLJIT_CONFIG_UNSUPPORTED is set. */
260 #include "sljitUtils.c"
262 #if !(defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
264 #if (defined SLJIT_EXECUTABLE_ALLOCATOR && SLJIT_EXECUTABLE_ALLOCATOR)
266 #if (defined SLJIT_PROT_EXECUTABLE_ALLOCATOR && SLJIT_PROT_EXECUTABLE_ALLOCATOR)
267 #include "sljitProtExecAllocator.c"
268 #elif (defined SLJIT_WX_EXECUTABLE_ALLOCATOR && SLJIT_WX_EXECUTABLE_ALLOCATOR)
269 #include "sljitWXExecAllocator.c"
271 #include "sljitExecAllocator.c"
276 #if (defined SLJIT_PROT_EXECUTABLE_ALLOCATOR && SLJIT_PROT_EXECUTABLE_ALLOCATOR)
277 #define SLJIT_ADD_EXEC_OFFSET(ptr, exec_offset) ((sljit_u8 *)(ptr) + (exec_offset))
279 #define SLJIT_ADD_EXEC_OFFSET(ptr, exec_offset) ((sljit_u8 *)(ptr))
282 #ifndef SLJIT_UPDATE_WX_FLAGS
283 #define SLJIT_UPDATE_WX_FLAGS(from, to, enable_exec)
286 /* Argument checking features. */
288 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
290 /* Returns with error when an invalid argument is passed. */
292 #define CHECK_ARGUMENT(x) \
294 if (SLJIT_UNLIKELY(!(x))) \
298 #define CHECK_RETURN_TYPE sljit_s32
299 #define CHECK_RETURN_OK return 0
303 if (SLJIT_UNLIKELY(x)) { \
304 compiler->error = SLJIT_ERR_BAD_ARGUMENT; \
305 return SLJIT_ERR_BAD_ARGUMENT; \
309 #define CHECK_PTR(x) \
311 if (SLJIT_UNLIKELY(x)) { \
312 compiler->error = SLJIT_ERR_BAD_ARGUMENT; \
317 #define CHECK_REG_INDEX(x) \
319 if (SLJIT_UNLIKELY(x)) { \
324 #elif (defined SLJIT_DEBUG && SLJIT_DEBUG)
326 /* Assertion failure occures if an invalid argument is passed. */
327 #undef SLJIT_ARGUMENT_CHECKS
328 #define SLJIT_ARGUMENT_CHECKS 1
330 #define CHECK_ARGUMENT(x) SLJIT_ASSERT(x)
331 #define CHECK_RETURN_TYPE void
332 #define CHECK_RETURN_OK return
334 #define CHECK_PTR(x) x
335 #define CHECK_REG_INDEX(x) x
337 #elif (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
339 /* Arguments are not checked. */
340 #define CHECK_RETURN_TYPE void
341 #define CHECK_RETURN_OK return
343 #define CHECK_PTR(x) x
344 #define CHECK_REG_INDEX(x) x
348 /* Arguments are not checked. */
351 #define CHECK_REG_INDEX(x)
353 #endif /* SLJIT_ARGUMENT_CHECKS */
355 /* --------------------------------------------------------------------- */
356 /* Public functions */
357 /* --------------------------------------------------------------------- */
359 #if (defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86)
360 #define SLJIT_NEEDS_COMPILER_INIT 1
361 static sljit_s32 compiler_initialized
= 0;
362 /* A thread safe initialization. */
363 static void init_compiler(void);
366 SLJIT_API_FUNC_ATTRIBUTE
struct sljit_compiler
* sljit_create_compiler(void *allocator_data
, void *exec_allocator_data
)
368 struct sljit_compiler
*compiler
= (struct sljit_compiler
*)SLJIT_MALLOC(sizeof(struct sljit_compiler
), allocator_data
);
371 SLJIT_ZEROMEM(compiler
, sizeof(struct sljit_compiler
));
373 SLJIT_COMPILE_ASSERT(
374 sizeof(sljit_s8
) == 1 && sizeof(sljit_u8
) == 1
375 && sizeof(sljit_s16
) == 2 && sizeof(sljit_u16
) == 2
376 && sizeof(sljit_s32
) == 4 && sizeof(sljit_u32
) == 4
377 && (sizeof(sljit_p
) == 4 || sizeof(sljit_p
) == 8)
378 && sizeof(sljit_p
) <= sizeof(sljit_sw
)
379 && (sizeof(sljit_sw
) == 4 || sizeof(sljit_sw
) == 8)
380 && (sizeof(sljit_uw
) == 4 || sizeof(sljit_uw
) == 8),
381 invalid_integer_types
);
382 SLJIT_COMPILE_ASSERT(SLJIT_I32_OP
== SLJIT_F32_OP
,
383 int_op_and_single_op_must_be_the_same
);
384 SLJIT_COMPILE_ASSERT(SLJIT_REWRITABLE_JUMP
!= SLJIT_F32_OP
,
385 rewritable_jump_and_single_op_must_not_be_the_same
);
386 SLJIT_COMPILE_ASSERT(!(SLJIT_EQUAL
& 0x1) && !(SLJIT_LESS
& 0x1) && !(SLJIT_EQUAL_F64
& 0x1) && !(SLJIT_JUMP
& 0x1),
387 conditional_flags_must_be_even_numbers
);
389 /* Only the non-zero members must be set. */
390 compiler
->error
= SLJIT_SUCCESS
;
392 compiler
->allocator_data
= allocator_data
;
393 compiler
->exec_allocator_data
= exec_allocator_data
;
394 compiler
->buf
= (struct sljit_memory_fragment
*)SLJIT_MALLOC(BUF_SIZE
, allocator_data
);
395 compiler
->abuf
= (struct sljit_memory_fragment
*)SLJIT_MALLOC(ABUF_SIZE
, allocator_data
);
397 if (!compiler
->buf
|| !compiler
->abuf
) {
399 SLJIT_FREE(compiler
->buf
, allocator_data
);
401 SLJIT_FREE(compiler
->abuf
, allocator_data
);
402 SLJIT_FREE(compiler
, allocator_data
);
406 compiler
->buf
->next
= NULL
;
407 compiler
->buf
->used_size
= 0;
408 compiler
->abuf
->next
= NULL
;
409 compiler
->abuf
->used_size
= 0;
411 compiler
->scratches
= -1;
412 compiler
->saveds
= -1;
413 compiler
->fscratches
= -1;
414 compiler
->fsaveds
= -1;
415 compiler
->local_size
= -1;
417 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
421 #if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5)
422 compiler
->cpool
= (sljit_uw
*)SLJIT_MALLOC(CPOOL_SIZE
* sizeof(sljit_uw
)
423 + CPOOL_SIZE
* sizeof(sljit_u8
), allocator_data
);
424 if (!compiler
->cpool
) {
425 SLJIT_FREE(compiler
->buf
, allocator_data
);
426 SLJIT_FREE(compiler
->abuf
, allocator_data
);
427 SLJIT_FREE(compiler
, allocator_data
);
430 compiler
->cpool_unique
= (sljit_u8
*)(compiler
->cpool
+ CPOOL_SIZE
);
431 compiler
->cpool_diff
= 0xffffffff;
434 #if (defined SLJIT_CONFIG_MIPS && SLJIT_CONFIG_MIPS)
435 compiler
->delay_slot
= UNMOVABLE_INS
;
438 #if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
439 compiler
->delay_slot
= UNMOVABLE_INS
;
442 #if (defined SLJIT_NEEDS_COMPILER_INIT && SLJIT_NEEDS_COMPILER_INIT)
443 if (!compiler_initialized
) {
445 compiler_initialized
= 1;
452 SLJIT_API_FUNC_ATTRIBUTE
void sljit_free_compiler(struct sljit_compiler
*compiler
)
454 struct sljit_memory_fragment
*buf
;
455 struct sljit_memory_fragment
*curr
;
456 void *allocator_data
= compiler
->allocator_data
;
457 SLJIT_UNUSED_ARG(allocator_data
);
463 SLJIT_FREE(curr
, allocator_data
);
466 buf
= compiler
->abuf
;
470 SLJIT_FREE(curr
, allocator_data
);
473 #if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5)
474 SLJIT_FREE(compiler
->cpool
, allocator_data
);
476 SLJIT_FREE(compiler
, allocator_data
);
479 SLJIT_API_FUNC_ATTRIBUTE
void sljit_set_compiler_memory_error(struct sljit_compiler
*compiler
)
481 if (compiler
->error
== SLJIT_SUCCESS
)
482 compiler
->error
= SLJIT_ERR_ALLOC_FAILED
;
485 #if (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
486 SLJIT_API_FUNC_ATTRIBUTE
void sljit_free_code(void* code
, void *exec_allocator_data
)
488 SLJIT_UNUSED_ARG(exec_allocator_data
);
490 /* Remove thumb mode flag. */
491 SLJIT_FREE_EXEC((void*)((sljit_uw
)code
& ~0x1), exec_allocator_data
);
493 #elif (defined SLJIT_INDIRECT_CALL && SLJIT_INDIRECT_CALL)
494 SLJIT_API_FUNC_ATTRIBUTE
void sljit_free_code(void* code
, void *exec_allocator_data
)
496 SLJIT_UNUSED_ARG(exec_allocator_data
);
498 /* Resolve indirection. */
499 code
= (void*)(*(sljit_uw
*)code
);
500 SLJIT_FREE_EXEC(code
, exec_allocator_data
);
503 SLJIT_API_FUNC_ATTRIBUTE
void sljit_free_code(void* code
, void *exec_allocator_data
)
505 SLJIT_UNUSED_ARG(exec_allocator_data
);
507 SLJIT_FREE_EXEC(code
, exec_allocator_data
);
511 SLJIT_API_FUNC_ATTRIBUTE
void sljit_set_label(struct sljit_jump
*jump
, struct sljit_label
* label
)
513 if (SLJIT_LIKELY(!!jump
) && SLJIT_LIKELY(!!label
)) {
514 jump
->flags
&= ~JUMP_ADDR
;
515 jump
->flags
|= JUMP_LABEL
;
516 jump
->u
.label
= label
;
520 SLJIT_API_FUNC_ATTRIBUTE
void sljit_set_target(struct sljit_jump
*jump
, sljit_uw target
)
522 if (SLJIT_LIKELY(!!jump
)) {
523 jump
->flags
&= ~JUMP_LABEL
;
524 jump
->flags
|= JUMP_ADDR
;
525 jump
->u
.target
= target
;
529 SLJIT_API_FUNC_ATTRIBUTE
void sljit_set_put_label(struct sljit_put_label
*put_label
, struct sljit_label
*label
)
531 if (SLJIT_LIKELY(!!put_label
))
532 put_label
->label
= label
;
535 #define SLJIT_CURRENT_FLAGS_ALL \
536 (SLJIT_CURRENT_FLAGS_I32_OP | SLJIT_CURRENT_FLAGS_ADD_SUB | SLJIT_CURRENT_FLAGS_COMPARE)
538 SLJIT_API_FUNC_ATTRIBUTE
void sljit_set_current_flags(struct sljit_compiler
*compiler
, sljit_s32 current_flags
)
540 SLJIT_UNUSED_ARG(compiler
);
541 SLJIT_UNUSED_ARG(current_flags
);
543 #if (defined SLJIT_HAS_STATUS_FLAGS_STATE && SLJIT_HAS_STATUS_FLAGS_STATE)
544 compiler
->status_flags_state
= current_flags
;
547 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
548 compiler
->last_flags
= 0;
549 if ((current_flags
& ~(VARIABLE_FLAG_MASK
| SLJIT_SET_Z
| SLJIT_CURRENT_FLAGS_ALL
)) == 0) {
550 compiler
->last_flags
= GET_FLAG_TYPE(current_flags
) | (current_flags
& (SLJIT_I32_OP
| SLJIT_SET_Z
));
555 /* --------------------------------------------------------------------- */
556 /* Private functions */
557 /* --------------------------------------------------------------------- */
559 static void* ensure_buf(struct sljit_compiler
*compiler
, sljit_uw size
)
562 struct sljit_memory_fragment
*new_frag
;
564 SLJIT_ASSERT(size
<= 256);
565 if (compiler
->buf
->used_size
+ size
<= (BUF_SIZE
- (sljit_uw
)SLJIT_OFFSETOF(struct sljit_memory_fragment
, memory
))) {
566 ret
= compiler
->buf
->memory
+ compiler
->buf
->used_size
;
567 compiler
->buf
->used_size
+= size
;
570 new_frag
= (struct sljit_memory_fragment
*)SLJIT_MALLOC(BUF_SIZE
, compiler
->allocator_data
);
571 PTR_FAIL_IF_NULL(new_frag
);
572 new_frag
->next
= compiler
->buf
;
573 compiler
->buf
= new_frag
;
574 new_frag
->used_size
= size
;
575 return new_frag
->memory
;
578 static void* ensure_abuf(struct sljit_compiler
*compiler
, sljit_uw size
)
581 struct sljit_memory_fragment
*new_frag
;
583 SLJIT_ASSERT(size
<= 256);
584 if (compiler
->abuf
->used_size
+ size
<= (ABUF_SIZE
- (sljit_uw
)SLJIT_OFFSETOF(struct sljit_memory_fragment
, memory
))) {
585 ret
= compiler
->abuf
->memory
+ compiler
->abuf
->used_size
;
586 compiler
->abuf
->used_size
+= size
;
589 new_frag
= (struct sljit_memory_fragment
*)SLJIT_MALLOC(ABUF_SIZE
, compiler
->allocator_data
);
590 PTR_FAIL_IF_NULL(new_frag
);
591 new_frag
->next
= compiler
->abuf
;
592 compiler
->abuf
= new_frag
;
593 new_frag
->used_size
= size
;
594 return new_frag
->memory
;
597 SLJIT_API_FUNC_ATTRIBUTE
void* sljit_alloc_memory(struct sljit_compiler
*compiler
, sljit_s32 size
)
601 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
602 if (size
<= 0 || size
> 128)
604 size
= (size
+ 7) & ~7;
606 if (size
<= 0 || size
> 64)
608 size
= (size
+ 3) & ~3;
610 return ensure_abuf(compiler
, size
);
613 static SLJIT_INLINE
void reverse_buf(struct sljit_compiler
*compiler
)
615 struct sljit_memory_fragment
*buf
= compiler
->buf
;
616 struct sljit_memory_fragment
*prev
= NULL
;
617 struct sljit_memory_fragment
*tmp
;
624 } while (buf
!= NULL
);
626 compiler
->buf
= prev
;
629 static SLJIT_INLINE sljit_s32
get_arg_count(sljit_s32 arg_types
)
631 sljit_s32 arg_count
= 0;
633 arg_types
>>= SLJIT_DEF_SHIFT
;
636 arg_types
>>= SLJIT_DEF_SHIFT
;
643 /* Only used in RISC architectures where the instruction size is constant */
644 #if !(defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86) \
645 && !(defined SLJIT_CONFIG_S390X && SLJIT_CONFIG_S390X)
647 static SLJIT_INLINE sljit_uw
compute_next_addr(struct sljit_label
*label
, struct sljit_jump
*jump
,
648 struct sljit_const
*const_
, struct sljit_put_label
*put_label
)
650 sljit_uw result
= ~(sljit_uw
)0;
653 result
= label
->size
;
655 if (jump
&& jump
->addr
< result
)
658 if (const_
&& const_
->addr
< result
)
659 result
= const_
->addr
;
661 if (put_label
&& put_label
->addr
< result
)
662 result
= put_label
->addr
;
667 #endif /* !SLJIT_CONFIG_X86 && !SLJIT_CONFIG_S390X */
669 static SLJIT_INLINE
void set_emit_enter(struct sljit_compiler
*compiler
,
670 sljit_s32 options
, sljit_s32 args
, sljit_s32 scratches
, sljit_s32 saveds
,
671 sljit_s32 fscratches
, sljit_s32 fsaveds
, sljit_s32 local_size
)
673 SLJIT_UNUSED_ARG(args
);
674 SLJIT_UNUSED_ARG(local_size
);
676 compiler
->options
= options
;
677 compiler
->scratches
= scratches
;
678 compiler
->saveds
= saveds
;
679 compiler
->fscratches
= fscratches
;
680 compiler
->fsaveds
= fsaveds
;
681 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
682 compiler
->logical_local_size
= local_size
;
686 static SLJIT_INLINE
void set_set_context(struct sljit_compiler
*compiler
,
687 sljit_s32 options
, sljit_s32 args
, sljit_s32 scratches
, sljit_s32 saveds
,
688 sljit_s32 fscratches
, sljit_s32 fsaveds
, sljit_s32 local_size
)
690 SLJIT_UNUSED_ARG(args
);
691 SLJIT_UNUSED_ARG(local_size
);
693 compiler
->options
= options
;
694 compiler
->scratches
= scratches
;
695 compiler
->saveds
= saveds
;
696 compiler
->fscratches
= fscratches
;
697 compiler
->fsaveds
= fsaveds
;
698 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
699 compiler
->logical_local_size
= local_size
;
703 static SLJIT_INLINE
void set_label(struct sljit_label
*label
, struct sljit_compiler
*compiler
)
706 label
->size
= compiler
->size
;
707 if (compiler
->last_label
)
708 compiler
->last_label
->next
= label
;
710 compiler
->labels
= label
;
711 compiler
->last_label
= label
;
714 static SLJIT_INLINE
void set_jump(struct sljit_jump
*jump
, struct sljit_compiler
*compiler
, sljit_s32 flags
)
718 if (compiler
->last_jump
)
719 compiler
->last_jump
->next
= jump
;
721 compiler
->jumps
= jump
;
722 compiler
->last_jump
= jump
;
725 static SLJIT_INLINE
void set_const(struct sljit_const
*const_
, struct sljit_compiler
*compiler
)
728 const_
->addr
= compiler
->size
;
729 if (compiler
->last_const
)
730 compiler
->last_const
->next
= const_
;
732 compiler
->consts
= const_
;
733 compiler
->last_const
= const_
;
736 static SLJIT_INLINE
void set_put_label(struct sljit_put_label
*put_label
, struct sljit_compiler
*compiler
, sljit_uw offset
)
738 put_label
->next
= NULL
;
739 put_label
->label
= NULL
;
740 put_label
->addr
= compiler
->size
- offset
;
741 put_label
->flags
= 0;
742 if (compiler
->last_put_label
)
743 compiler
->last_put_label
->next
= put_label
;
745 compiler
->put_labels
= put_label
;
746 compiler
->last_put_label
= put_label
;
749 #define ADDRESSING_DEPENDS_ON(exp, reg) \
750 (((exp) & SLJIT_MEM) && (((exp) & REG_MASK) == reg || OFFS_REG(exp) == reg))
752 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
754 #define FUNCTION_CHECK_IS_REG(r) \
755 (((r) >= SLJIT_R0 && (r) < (SLJIT_R0 + compiler->scratches)) \
756 || ((r) > (SLJIT_S0 - compiler->saveds) && (r) <= SLJIT_S0))
758 #define FUNCTION_CHECK_IS_FREG(fr) \
759 (((fr) >= SLJIT_FR0 && (fr) < (SLJIT_FR0 + compiler->fscratches)) \
760 || ((fr) > (SLJIT_FS0 - compiler->fsaveds) && (fr) <= SLJIT_FS0))
762 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
763 #define CHECK_IF_VIRTUAL_REGISTER(p) ((p) <= SLJIT_S3 && (p) >= SLJIT_S8)
765 #define CHECK_IF_VIRTUAL_REGISTER(p) 0
768 static sljit_s32
function_check_src_mem(struct sljit_compiler
*compiler
, sljit_s32 p
, sljit_sw i
)
770 if (compiler
->scratches
== -1 || compiler
->saveds
== -1)
773 if (!(p
& SLJIT_MEM
))
776 if (!((p
& REG_MASK
) == SLJIT_UNUSED
|| FUNCTION_CHECK_IS_REG(p
& REG_MASK
)))
779 if (CHECK_IF_VIRTUAL_REGISTER(p
& REG_MASK
))
782 if (p
& OFFS_REG_MASK
) {
783 if ((p
& REG_MASK
) == SLJIT_UNUSED
)
786 if (!(FUNCTION_CHECK_IS_REG(OFFS_REG(p
))))
789 if (CHECK_IF_VIRTUAL_REGISTER(OFFS_REG(p
)))
796 return (p
& ~(SLJIT_MEM
| REG_MASK
| OFFS_REG_MASK
)) == 0;
799 #define FUNCTION_CHECK_SRC_MEM(p, i) \
800 CHECK_ARGUMENT(function_check_src_mem(compiler, p, i));
802 static sljit_s32
function_check_src(struct sljit_compiler
*compiler
, sljit_s32 p
, sljit_sw i
)
804 if (compiler
->scratches
== -1 || compiler
->saveds
== -1)
807 if (FUNCTION_CHECK_IS_REG(p
))
813 if (p
== SLJIT_MEM1(SLJIT_SP
))
814 return (i
>= 0 && i
< compiler
->logical_local_size
);
816 return function_check_src_mem(compiler
, p
, i
);
819 #define FUNCTION_CHECK_SRC(p, i) \
820 CHECK_ARGUMENT(function_check_src(compiler, p, i));
822 static sljit_s32
function_check_dst(struct sljit_compiler
*compiler
, sljit_s32 p
, sljit_sw i
, sljit_s32 unused
)
824 if (compiler
->scratches
== -1 || compiler
->saveds
== -1)
827 if (FUNCTION_CHECK_IS_REG(p
) || ((unused
) && (p
) == SLJIT_UNUSED
))
830 if (p
== SLJIT_MEM1(SLJIT_SP
))
831 return (i
>= 0 && i
< compiler
->logical_local_size
);
833 return function_check_src_mem(compiler
, p
, i
);
836 #define FUNCTION_CHECK_DST(p, i, unused) \
837 CHECK_ARGUMENT(function_check_dst(compiler, p, i, unused));
839 static sljit_s32
function_fcheck(struct sljit_compiler
*compiler
, sljit_s32 p
, sljit_sw i
)
841 if (compiler
->scratches
== -1 || compiler
->saveds
== -1)
844 if (FUNCTION_CHECK_IS_FREG(p
))
847 if (p
== SLJIT_MEM1(SLJIT_SP
))
848 return (i
>= 0 && i
< compiler
->logical_local_size
);
850 return function_check_src_mem(compiler
, p
, i
);
853 #define FUNCTION_FCHECK(p, i) \
854 CHECK_ARGUMENT(function_fcheck(compiler, p, i));
856 #endif /* SLJIT_ARGUMENT_CHECKS */
858 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
860 SLJIT_API_FUNC_ATTRIBUTE
void sljit_compiler_verbose(struct sljit_compiler
*compiler
, FILE* verbose
)
862 compiler
->verbose
= verbose
;
865 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
867 # define SLJIT_PRINT_D "I64"
869 # define SLJIT_PRINT_D "l"
872 # define SLJIT_PRINT_D ""
875 static void sljit_verbose_reg(struct sljit_compiler
*compiler
, sljit_s32 r
)
877 if (r
< (SLJIT_R0
+ compiler
->scratches
))
878 fprintf(compiler
->verbose
, "r%d", r
- SLJIT_R0
);
879 else if (r
!= SLJIT_SP
)
880 fprintf(compiler
->verbose
, "s%d", SLJIT_NUMBER_OF_REGISTERS
- r
);
882 fprintf(compiler
->verbose
, "sp");
885 static void sljit_verbose_freg(struct sljit_compiler
*compiler
, sljit_s32 r
)
887 if (r
< (SLJIT_FR0
+ compiler
->fscratches
))
888 fprintf(compiler
->verbose
, "fr%d", r
- SLJIT_FR0
);
890 fprintf(compiler
->verbose
, "fs%d", SLJIT_NUMBER_OF_FLOAT_REGISTERS
- r
);
893 static void sljit_verbose_param(struct sljit_compiler
*compiler
, sljit_s32 p
, sljit_sw i
)
896 fprintf(compiler
->verbose
, "#%" SLJIT_PRINT_D
"d", (i
));
897 else if ((p
) & SLJIT_MEM
) {
898 if ((p
) & REG_MASK
) {
899 fputc('[', compiler
->verbose
);
900 sljit_verbose_reg(compiler
, (p
) & REG_MASK
);
901 if ((p
) & OFFS_REG_MASK
) {
902 fprintf(compiler
->verbose
, " + ");
903 sljit_verbose_reg(compiler
, OFFS_REG(p
));
905 fprintf(compiler
->verbose
, " * %d", 1 << (i
));
908 fprintf(compiler
->verbose
, " + %" SLJIT_PRINT_D
"d", (i
));
909 fputc(']', compiler
->verbose
);
912 fprintf(compiler
->verbose
, "[#%" SLJIT_PRINT_D
"d]", (i
));
914 sljit_verbose_reg(compiler
, p
);
916 fprintf(compiler
->verbose
, "unused");
919 static void sljit_verbose_fparam(struct sljit_compiler
*compiler
, sljit_s32 p
, sljit_sw i
)
921 if ((p
) & SLJIT_MEM
) {
922 if ((p
) & REG_MASK
) {
923 fputc('[', compiler
->verbose
);
924 sljit_verbose_reg(compiler
, (p
) & REG_MASK
);
925 if ((p
) & OFFS_REG_MASK
) {
926 fprintf(compiler
->verbose
, " + ");
927 sljit_verbose_reg(compiler
, OFFS_REG(p
));
929 fprintf(compiler
->verbose
, "%d", 1 << (i
));
932 fprintf(compiler
->verbose
, " + %" SLJIT_PRINT_D
"d", (i
));
933 fputc(']', compiler
->verbose
);
936 fprintf(compiler
->verbose
, "[#%" SLJIT_PRINT_D
"d]", (i
));
939 sljit_verbose_freg(compiler
, p
);
942 static const char* op0_names
[] = {
943 (char*)"breakpoint", (char*)"nop", (char*)"lmul.uw", (char*)"lmul.sw",
944 (char*)"divmod.u", (char*)"divmod.s", (char*)"div.u", (char*)"div.s",
945 (char*)"endbr", (char*)"skip_frames_before_return"
948 static const char* op1_names
[] = {
949 (char*)"", (char*)".u8", (char*)".s8", (char*)".u16",
950 (char*)".s16", (char*)".u32", (char*)".s32", (char*)".p",
951 (char*)"", (char*)".u8", (char*)".s8", (char*)".u16",
952 (char*)".s16", (char*)".u32", (char*)".s32", (char*)".p",
953 (char*)"not", (char*)"neg", (char*)"clz",
956 static const char* op2_names
[] = {
957 (char*)"add", (char*)"addc", (char*)"sub", (char*)"subc",
958 (char*)"mul", (char*)"and", (char*)"or", (char*)"xor",
959 (char*)"shl", (char*)"lshr", (char*)"ashr",
962 static const char* op_src_names
[] = {
963 (char*)"fast_return", (char*)"skip_frames_before_fast_return",
964 (char*)"prefetch_l1", (char*)"prefetch_l2",
965 (char*)"prefetch_l3", (char*)"prefetch_once",
968 static const char* fop1_names
[] = {
969 (char*)"mov", (char*)"conv", (char*)"conv", (char*)"conv",
970 (char*)"conv", (char*)"conv", (char*)"cmp", (char*)"neg",
974 static const char* fop2_names
[] = {
975 (char*)"add", (char*)"sub", (char*)"mul", (char*)"div"
978 #define JUMP_POSTFIX(type) \
979 ((type & 0xff) <= SLJIT_NOT_OVERFLOW ? ((type & SLJIT_I32_OP) ? "32" : "") \
980 : ((type & 0xff) <= SLJIT_ORDERED_F64 ? ((type & SLJIT_F32_OP) ? ".f32" : ".f64") : ""))
982 static char* jump_names
[] = {
983 (char*)"equal", (char*)"not_equal",
984 (char*)"less", (char*)"greater_equal",
985 (char*)"greater", (char*)"less_equal",
986 (char*)"sig_less", (char*)"sig_greater_equal",
987 (char*)"sig_greater", (char*)"sig_less_equal",
988 (char*)"overflow", (char*)"not_overflow",
989 (char*)"carry", (char*)"",
990 (char*)"equal", (char*)"not_equal",
991 (char*)"less", (char*)"greater_equal",
992 (char*)"greater", (char*)"less_equal",
993 (char*)"unordered", (char*)"ordered",
994 (char*)"jump", (char*)"fast_call",
995 (char*)"call", (char*)"call.cdecl"
998 static char* call_arg_names
[] = {
999 (char*)"void", (char*)"sw", (char*)"uw", (char*)"s32", (char*)"u32", (char*)"f32", (char*)"f64"
1002 #endif /* SLJIT_VERBOSE */
1004 /* --------------------------------------------------------------------- */
1005 /* Arch dependent */
1006 /* --------------------------------------------------------------------- */
1008 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS) \
1009 || (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1011 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_generate_code(struct sljit_compiler
*compiler
)
1013 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1014 struct sljit_jump
*jump
;
1017 SLJIT_UNUSED_ARG(compiler
);
1019 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1020 CHECK_ARGUMENT(compiler
->size
> 0);
1021 jump
= compiler
->jumps
;
1023 /* All jumps have target. */
1024 CHECK_ARGUMENT(jump
->flags
& (JUMP_LABEL
| JUMP_ADDR
));
1031 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_enter(struct sljit_compiler
*compiler
,
1032 sljit_s32 options
, sljit_s32 arg_types
, sljit_s32 scratches
, sljit_s32 saveds
,
1033 sljit_s32 fscratches
, sljit_s32 fsaveds
, sljit_s32 local_size
)
1035 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1036 sljit_s32 types
, arg_count
, curr_type
;
1039 SLJIT_UNUSED_ARG(compiler
);
1041 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1042 CHECK_ARGUMENT(!(options
& ~SLJIT_F64_ALIGNMENT
));
1043 CHECK_ARGUMENT(scratches
>= 0 && scratches
<= SLJIT_NUMBER_OF_REGISTERS
);
1044 CHECK_ARGUMENT(saveds
>= 0 && saveds
<= SLJIT_NUMBER_OF_REGISTERS
);
1045 CHECK_ARGUMENT(scratches
+ saveds
<= SLJIT_NUMBER_OF_REGISTERS
);
1046 CHECK_ARGUMENT(fscratches
>= 0 && fscratches
<= SLJIT_NUMBER_OF_FLOAT_REGISTERS
);
1047 CHECK_ARGUMENT(fsaveds
>= 0 && fsaveds
<= SLJIT_NUMBER_OF_FLOAT_REGISTERS
);
1048 CHECK_ARGUMENT(fscratches
+ fsaveds
<= SLJIT_NUMBER_OF_FLOAT_REGISTERS
);
1049 CHECK_ARGUMENT(local_size
>= 0 && local_size
<= SLJIT_MAX_LOCAL_SIZE
);
1050 CHECK_ARGUMENT((arg_types
& SLJIT_DEF_MASK
) == 0);
1052 types
= (arg_types
>> SLJIT_DEF_SHIFT
);
1054 while (types
!= 0 && arg_count
< 3) {
1055 curr_type
= (types
& SLJIT_DEF_MASK
);
1056 CHECK_ARGUMENT(curr_type
== SLJIT_ARG_TYPE_SW
|| curr_type
== SLJIT_ARG_TYPE_UW
);
1058 types
>>= SLJIT_DEF_SHIFT
;
1060 CHECK_ARGUMENT(arg_count
<= saveds
&& types
== 0);
1062 compiler
->last_flags
= 0;
1064 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1065 if (SLJIT_UNLIKELY(!!compiler
->verbose
)) {
1066 fprintf(compiler
->verbose
, " enter options:%s args[", (options
& SLJIT_F64_ALIGNMENT
) ? "f64_align" : "");
1068 arg_types
>>= SLJIT_DEF_SHIFT
;
1070 fprintf(compiler
->verbose
, "%s", call_arg_names
[arg_types
& SLJIT_DEF_MASK
]);
1071 arg_types
>>= SLJIT_DEF_SHIFT
;
1073 fprintf(compiler
->verbose
, ",");
1076 fprintf(compiler
->verbose
, "] scratches:%d saveds:%d fscratches:%d fsaveds:%d local_size:%d\n",
1077 scratches
, saveds
, fscratches
, fsaveds
, local_size
);
1083 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_set_context(struct sljit_compiler
*compiler
,
1084 sljit_s32 options
, sljit_s32 arg_types
, sljit_s32 scratches
, sljit_s32 saveds
,
1085 sljit_s32 fscratches
, sljit_s32 fsaveds
, sljit_s32 local_size
)
1087 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1088 sljit_s32 types
, arg_count
, curr_type
;
1091 SLJIT_UNUSED_ARG(compiler
);
1093 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1094 CHECK_ARGUMENT(!(options
& ~SLJIT_F64_ALIGNMENT
));
1095 CHECK_ARGUMENT(scratches
>= 0 && scratches
<= SLJIT_NUMBER_OF_REGISTERS
);
1096 CHECK_ARGUMENT(saveds
>= 0 && saveds
<= SLJIT_NUMBER_OF_REGISTERS
);
1097 CHECK_ARGUMENT(scratches
+ saveds
<= SLJIT_NUMBER_OF_REGISTERS
);
1098 CHECK_ARGUMENT(fscratches
>= 0 && fscratches
<= SLJIT_NUMBER_OF_FLOAT_REGISTERS
);
1099 CHECK_ARGUMENT(fsaveds
>= 0 && fsaveds
<= SLJIT_NUMBER_OF_FLOAT_REGISTERS
);
1100 CHECK_ARGUMENT(fscratches
+ fsaveds
<= SLJIT_NUMBER_OF_FLOAT_REGISTERS
);
1101 CHECK_ARGUMENT(local_size
>= 0 && local_size
<= SLJIT_MAX_LOCAL_SIZE
);
1103 types
= (arg_types
>> SLJIT_DEF_SHIFT
);
1105 while (types
!= 0 && arg_count
< 3) {
1106 curr_type
= (types
& SLJIT_DEF_MASK
);
1107 CHECK_ARGUMENT(curr_type
== SLJIT_ARG_TYPE_SW
|| curr_type
== SLJIT_ARG_TYPE_UW
);
1109 types
>>= SLJIT_DEF_SHIFT
;
1111 CHECK_ARGUMENT(arg_count
<= saveds
&& types
== 0);
1113 compiler
->last_flags
= 0;
1115 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1116 if (SLJIT_UNLIKELY(!!compiler
->verbose
)) {
1117 fprintf(compiler
->verbose
, " set_context options:%s args[", (options
& SLJIT_F64_ALIGNMENT
) ? "f64_align" : "");
1119 arg_types
>>= SLJIT_DEF_SHIFT
;
1121 fprintf(compiler
->verbose
, "%s", call_arg_names
[arg_types
& SLJIT_DEF_MASK
]);
1122 arg_types
>>= SLJIT_DEF_SHIFT
;
1124 fprintf(compiler
->verbose
, ",");
1127 fprintf(compiler
->verbose
, "] scratches:%d saveds:%d fscratches:%d fsaveds:%d local_size:%d\n",
1128 scratches
, saveds
, fscratches
, fsaveds
, local_size
);
1134 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_return(struct sljit_compiler
*compiler
, sljit_s32 op
, sljit_s32 src
, sljit_sw srcw
)
1136 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1137 CHECK_ARGUMENT(compiler
->scratches
>= 0);
1138 if (op
!= SLJIT_UNUSED
) {
1139 CHECK_ARGUMENT(op
>= SLJIT_MOV
&& op
<= SLJIT_MOV_P
);
1140 FUNCTION_CHECK_SRC(src
, srcw
);
1143 CHECK_ARGUMENT(src
== 0 && srcw
== 0);
1144 compiler
->last_flags
= 0;
1146 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1147 if (SLJIT_UNLIKELY(!!compiler
->verbose
)) {
1148 if (op
== SLJIT_UNUSED
)
1149 fprintf(compiler
->verbose
, " return\n");
1151 fprintf(compiler
->verbose
, " return%s ", op1_names
[op
- SLJIT_OP1_BASE
]);
1152 sljit_verbose_param(compiler
, src
, srcw
);
1153 fprintf(compiler
->verbose
, "\n");
1160 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_fast_enter(struct sljit_compiler
*compiler
, sljit_s32 dst
, sljit_sw dstw
)
1162 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1163 FUNCTION_CHECK_DST(dst
, dstw
, 0);
1164 compiler
->last_flags
= 0;
1166 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1167 if (SLJIT_UNLIKELY(!!compiler
->verbose
)) {
1168 fprintf(compiler
->verbose
, " fast_enter ");
1169 sljit_verbose_param(compiler
, dst
, dstw
);
1170 fprintf(compiler
->verbose
, "\n");
1176 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_op0(struct sljit_compiler
*compiler
, sljit_s32 op
)
1178 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1179 CHECK_ARGUMENT((op
>= SLJIT_BREAKPOINT
&& op
<= SLJIT_LMUL_SW
)
1180 || ((op
& ~SLJIT_I32_OP
) >= SLJIT_DIVMOD_UW
&& (op
& ~SLJIT_I32_OP
) <= SLJIT_DIV_SW
)
1181 || (op
>= SLJIT_ENDBR
&& op
<= SLJIT_SKIP_FRAMES_BEFORE_RETURN
));
1182 CHECK_ARGUMENT(GET_OPCODE(op
) < SLJIT_LMUL_UW
|| GET_OPCODE(op
) >= SLJIT_ENDBR
|| compiler
->scratches
>= 2);
1183 if ((GET_OPCODE(op
) >= SLJIT_LMUL_UW
&& GET_OPCODE(op
) <= SLJIT_DIV_SW
) || op
== SLJIT_SKIP_FRAMES_BEFORE_RETURN
)
1184 compiler
->last_flags
= 0;
1186 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1187 if (SLJIT_UNLIKELY(!!compiler
->verbose
))
1189 fprintf(compiler
->verbose
, " %s", op0_names
[GET_OPCODE(op
) - SLJIT_OP0_BASE
]);
1190 if (GET_OPCODE(op
) >= SLJIT_DIVMOD_UW
&& GET_OPCODE(op
) <= SLJIT_DIV_SW
) {
1191 fprintf(compiler
->verbose
, (op
& SLJIT_I32_OP
) ? "32" : "w");
1193 fprintf(compiler
->verbose
, "\n");
1199 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_op1(struct sljit_compiler
*compiler
, sljit_s32 op
,
1200 sljit_s32 dst
, sljit_sw dstw
,
1201 sljit_s32 src
, sljit_sw srcw
)
1203 if (SLJIT_UNLIKELY(compiler
->skip_checks
)) {
1204 compiler
->skip_checks
= 0;
1208 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1209 CHECK_ARGUMENT(GET_OPCODE(op
) >= SLJIT_MOV
&& GET_OPCODE(op
) <= SLJIT_CLZ
);
1211 switch (GET_OPCODE(op
)) {
1213 /* Only SLJIT_I32_OP and SLJIT_SET_Z are allowed. */
1214 CHECK_ARGUMENT(!(op
& VARIABLE_FLAG_MASK
));
1217 CHECK_ARGUMENT(!(op
& VARIABLE_FLAG_MASK
)
1218 || GET_FLAG_TYPE(op
) == SLJIT_OVERFLOW
);
1223 /* Nothing allowed */
1224 CHECK_ARGUMENT(!(op
& (SLJIT_I32_OP
| SLJIT_SET_Z
| VARIABLE_FLAG_MASK
)));
1227 /* Only SLJIT_I32_OP is allowed. */
1228 CHECK_ARGUMENT(!(op
& (SLJIT_SET_Z
| VARIABLE_FLAG_MASK
)));
1232 FUNCTION_CHECK_DST(dst
, dstw
, HAS_FLAGS(op
));
1233 FUNCTION_CHECK_SRC(src
, srcw
);
1235 if (GET_OPCODE(op
) >= SLJIT_NOT
) {
1236 CHECK_ARGUMENT(src
!= SLJIT_IMM
);
1237 compiler
->last_flags
= GET_FLAG_TYPE(op
) | (op
& (SLJIT_I32_OP
| SLJIT_SET_Z
));
1240 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1241 if (SLJIT_UNLIKELY(!!compiler
->verbose
)) {
1242 if (GET_OPCODE(op
) <= SLJIT_MOV_P
)
1244 fprintf(compiler
->verbose
, " mov%s%s ", !(op
& SLJIT_I32_OP
) ? "" : "32",
1245 (op
!= SLJIT_MOV32
) ? op1_names
[GET_OPCODE(op
) - SLJIT_OP1_BASE
] : "");
1249 fprintf(compiler
->verbose
, " %s%s%s%s%s ", op1_names
[GET_OPCODE(op
) - SLJIT_OP1_BASE
], !(op
& SLJIT_I32_OP
) ? "" : "32",
1250 !(op
& SLJIT_SET_Z
) ? "" : ".z", !(op
& VARIABLE_FLAG_MASK
) ? "" : ".",
1251 !(op
& VARIABLE_FLAG_MASK
) ? "" : jump_names
[GET_FLAG_TYPE(op
)]);
1254 sljit_verbose_param(compiler
, dst
, dstw
);
1255 fprintf(compiler
->verbose
, ", ");
1256 sljit_verbose_param(compiler
, src
, srcw
);
1257 fprintf(compiler
->verbose
, "\n");
1263 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_op2(struct sljit_compiler
*compiler
, sljit_s32 op
,
1264 sljit_s32 dst
, sljit_sw dstw
,
1265 sljit_s32 src1
, sljit_sw src1w
,
1266 sljit_s32 src2
, sljit_sw src2w
)
1268 if (SLJIT_UNLIKELY(compiler
->skip_checks
)) {
1269 compiler
->skip_checks
= 0;
1273 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1274 CHECK_ARGUMENT(GET_OPCODE(op
) >= SLJIT_ADD
&& GET_OPCODE(op
) <= SLJIT_ASHR
);
1276 switch (GET_OPCODE(op
)) {
1283 CHECK_ARGUMENT(!(op
& VARIABLE_FLAG_MASK
));
1286 CHECK_ARGUMENT(!(op
& SLJIT_SET_Z
));
1287 CHECK_ARGUMENT(!(op
& VARIABLE_FLAG_MASK
)
1288 || GET_FLAG_TYPE(op
) == SLJIT_OVERFLOW
);
1291 CHECK_ARGUMENT(!(op
& VARIABLE_FLAG_MASK
)
1292 || GET_FLAG_TYPE(op
) == GET_FLAG_TYPE(SLJIT_SET_CARRY
)
1293 || GET_FLAG_TYPE(op
) == SLJIT_OVERFLOW
);
1296 CHECK_ARGUMENT(!(op
& VARIABLE_FLAG_MASK
)
1297 || (GET_FLAG_TYPE(op
) >= SLJIT_LESS
&& GET_FLAG_TYPE(op
) <= SLJIT_OVERFLOW
)
1298 || GET_FLAG_TYPE(op
) == GET_FLAG_TYPE(SLJIT_SET_CARRY
));
1302 CHECK_ARGUMENT(!(op
& VARIABLE_FLAG_MASK
)
1303 || GET_FLAG_TYPE(op
) == GET_FLAG_TYPE(SLJIT_SET_CARRY
));
1304 CHECK_ARGUMENT((compiler
->last_flags
& 0xff) == GET_FLAG_TYPE(SLJIT_SET_CARRY
));
1305 CHECK_ARGUMENT((op
& SLJIT_I32_OP
) == (compiler
->last_flags
& SLJIT_I32_OP
));
1308 SLJIT_UNREACHABLE();
1312 FUNCTION_CHECK_DST(dst
, dstw
, HAS_FLAGS(op
));
1313 FUNCTION_CHECK_SRC(src1
, src1w
);
1314 FUNCTION_CHECK_SRC(src2
, src2w
);
1315 compiler
->last_flags
= GET_FLAG_TYPE(op
) | (op
& (SLJIT_I32_OP
| SLJIT_SET_Z
));
1317 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1318 if (SLJIT_UNLIKELY(!!compiler
->verbose
)) {
1319 fprintf(compiler
->verbose
, " %s%s%s%s%s ", op2_names
[GET_OPCODE(op
) - SLJIT_OP2_BASE
], !(op
& SLJIT_I32_OP
) ? "" : "32",
1320 !(op
& SLJIT_SET_Z
) ? "" : ".z", !(op
& VARIABLE_FLAG_MASK
) ? "" : ".",
1321 !(op
& VARIABLE_FLAG_MASK
) ? "" : jump_names
[GET_FLAG_TYPE(op
)]);
1322 sljit_verbose_param(compiler
, dst
, dstw
);
1323 fprintf(compiler
->verbose
, ", ");
1324 sljit_verbose_param(compiler
, src1
, src1w
);
1325 fprintf(compiler
->verbose
, ", ");
1326 sljit_verbose_param(compiler
, src2
, src2w
);
1327 fprintf(compiler
->verbose
, "\n");
1333 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_op_src(struct sljit_compiler
*compiler
, sljit_s32 op
,
1334 sljit_s32 src
, sljit_sw srcw
)
1336 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1337 CHECK_ARGUMENT(op
>= SLJIT_FAST_RETURN
&& op
<= SLJIT_PREFETCH_ONCE
);
1338 FUNCTION_CHECK_SRC(src
, srcw
);
1340 if (op
== SLJIT_FAST_RETURN
|| op
== SLJIT_SKIP_FRAMES_BEFORE_FAST_RETURN
)
1342 CHECK_ARGUMENT(src
!= SLJIT_IMM
);
1343 compiler
->last_flags
= 0;
1345 else if (op
>= SLJIT_PREFETCH_L1
&& op
<= SLJIT_PREFETCH_ONCE
)
1347 CHECK_ARGUMENT(src
& SLJIT_MEM
);
1350 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1351 if (SLJIT_UNLIKELY(!!compiler
->verbose
)) {
1352 fprintf(compiler
->verbose
, " %s ", op_src_names
[op
- SLJIT_OP_SRC_BASE
]);
1353 sljit_verbose_param(compiler
, src
, srcw
);
1354 fprintf(compiler
->verbose
, "\n");
1360 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_get_register_index(sljit_s32 reg
)
1362 SLJIT_UNUSED_ARG(reg
);
1363 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1364 CHECK_ARGUMENT(reg
> 0 && reg
<= SLJIT_NUMBER_OF_REGISTERS
);
1369 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_get_float_register_index(sljit_s32 reg
)
1371 SLJIT_UNUSED_ARG(reg
);
1372 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1373 CHECK_ARGUMENT(reg
> 0 && reg
<= SLJIT_NUMBER_OF_FLOAT_REGISTERS
);
1378 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_op_custom(struct sljit_compiler
*compiler
,
1379 void *instruction
, sljit_s32 size
)
1381 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1385 SLJIT_UNUSED_ARG(compiler
);
1387 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1388 CHECK_ARGUMENT(instruction
);
1390 #if (defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86)
1391 CHECK_ARGUMENT(size
> 0 && size
< 16);
1392 #elif (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
1393 CHECK_ARGUMENT((size
== 2 && (((sljit_sw
)instruction
) & 0x1) == 0)
1394 || (size
== 4 && (((sljit_sw
)instruction
) & 0x3) == 0));
1395 #elif (defined SLJIT_CONFIG_S390X && SLJIT_CONFIG_S390X)
1396 CHECK_ARGUMENT(size
== 2 || size
== 4 || size
== 6);
1398 CHECK_ARGUMENT(size
== 4 && (((sljit_sw
)instruction
) & 0x3) == 0);
1401 compiler
->last_flags
= 0;
1403 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1404 if (SLJIT_UNLIKELY(!!compiler
->verbose
)) {
1405 fprintf(compiler
->verbose
, " op_custom");
1406 for (i
= 0; i
< size
; i
++)
1407 fprintf(compiler
->verbose
, " 0x%x", ((sljit_u8
*)instruction
)[i
]);
1408 fprintf(compiler
->verbose
, "\n");
1414 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_fop1(struct sljit_compiler
*compiler
, sljit_s32 op
,
1415 sljit_s32 dst
, sljit_sw dstw
,
1416 sljit_s32 src
, sljit_sw srcw
)
1418 if (SLJIT_UNLIKELY(compiler
->skip_checks
)) {
1419 compiler
->skip_checks
= 0;
1423 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1424 CHECK_ARGUMENT(sljit_has_cpu_feature(SLJIT_HAS_FPU
));
1425 CHECK_ARGUMENT(GET_OPCODE(op
) >= SLJIT_MOV_F64
&& GET_OPCODE(op
) <= SLJIT_ABS_F64
);
1426 CHECK_ARGUMENT(!(op
& (SLJIT_SET_Z
| VARIABLE_FLAG_MASK
)));
1427 FUNCTION_FCHECK(src
, srcw
);
1428 FUNCTION_FCHECK(dst
, dstw
);
1430 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1431 if (SLJIT_UNLIKELY(!!compiler
->verbose
)) {
1432 if (GET_OPCODE(op
) == SLJIT_CONV_F64_FROM_F32
)
1433 fprintf(compiler
->verbose
, " %s%s ", fop1_names
[SLJIT_CONV_F64_FROM_F32
- SLJIT_FOP1_BASE
],
1434 (op
& SLJIT_F32_OP
) ? ".f32.from.f64" : ".f64.from.f32");
1436 fprintf(compiler
->verbose
, " %s%s ", fop1_names
[GET_OPCODE(op
) - SLJIT_FOP1_BASE
],
1437 (op
& SLJIT_F32_OP
) ? ".f32" : ".f64");
1439 sljit_verbose_fparam(compiler
, dst
, dstw
);
1440 fprintf(compiler
->verbose
, ", ");
1441 sljit_verbose_fparam(compiler
, src
, srcw
);
1442 fprintf(compiler
->verbose
, "\n");
1448 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_fop1_cmp(struct sljit_compiler
*compiler
, sljit_s32 op
,
1449 sljit_s32 src1
, sljit_sw src1w
,
1450 sljit_s32 src2
, sljit_sw src2w
)
1452 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1453 compiler
->last_flags
= GET_FLAG_TYPE(op
) | (op
& (SLJIT_I32_OP
| SLJIT_SET_Z
));
1456 if (SLJIT_UNLIKELY(compiler
->skip_checks
)) {
1457 compiler
->skip_checks
= 0;
1461 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1462 CHECK_ARGUMENT(sljit_has_cpu_feature(SLJIT_HAS_FPU
));
1463 CHECK_ARGUMENT(GET_OPCODE(op
) == SLJIT_CMP_F64
);
1464 CHECK_ARGUMENT(!(op
& SLJIT_SET_Z
));
1465 CHECK_ARGUMENT((op
& VARIABLE_FLAG_MASK
)
1466 || (GET_FLAG_TYPE(op
) >= SLJIT_EQUAL_F64
&& GET_FLAG_TYPE(op
) <= SLJIT_ORDERED_F64
));
1467 FUNCTION_FCHECK(src1
, src1w
);
1468 FUNCTION_FCHECK(src2
, src2w
);
1470 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1471 if (SLJIT_UNLIKELY(!!compiler
->verbose
)) {
1472 fprintf(compiler
->verbose
, " %s%s", fop1_names
[SLJIT_CMP_F64
- SLJIT_FOP1_BASE
], (op
& SLJIT_F32_OP
) ? ".f32" : ".f64");
1473 if (op
& VARIABLE_FLAG_MASK
) {
1474 fprintf(compiler
->verbose
, ".%s_f", jump_names
[GET_FLAG_TYPE(op
)]);
1476 fprintf(compiler
->verbose
, " ");
1477 sljit_verbose_fparam(compiler
, src1
, src1w
);
1478 fprintf(compiler
->verbose
, ", ");
1479 sljit_verbose_fparam(compiler
, src2
, src2w
);
1480 fprintf(compiler
->verbose
, "\n");
1486 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_fop1_conv_sw_from_f64(struct sljit_compiler
*compiler
, sljit_s32 op
,
1487 sljit_s32 dst
, sljit_sw dstw
,
1488 sljit_s32 src
, sljit_sw srcw
)
1490 if (SLJIT_UNLIKELY(compiler
->skip_checks
)) {
1491 compiler
->skip_checks
= 0;
1495 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1496 CHECK_ARGUMENT(sljit_has_cpu_feature(SLJIT_HAS_FPU
));
1497 CHECK_ARGUMENT(GET_OPCODE(op
) >= SLJIT_CONV_SW_FROM_F64
&& GET_OPCODE(op
) <= SLJIT_CONV_S32_FROM_F64
);
1498 CHECK_ARGUMENT(!(op
& (SLJIT_SET_Z
| VARIABLE_FLAG_MASK
)));
1499 FUNCTION_FCHECK(src
, srcw
);
1500 FUNCTION_CHECK_DST(dst
, dstw
, 0);
1502 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1503 if (SLJIT_UNLIKELY(!!compiler
->verbose
)) {
1504 fprintf(compiler
->verbose
, " %s%s.from%s ", fop1_names
[GET_OPCODE(op
) - SLJIT_FOP1_BASE
],
1505 (GET_OPCODE(op
) == SLJIT_CONV_S32_FROM_F64
) ? ".s32" : ".sw",
1506 (op
& SLJIT_F32_OP
) ? ".f32" : ".f64");
1507 sljit_verbose_param(compiler
, dst
, dstw
);
1508 fprintf(compiler
->verbose
, ", ");
1509 sljit_verbose_fparam(compiler
, src
, srcw
);
1510 fprintf(compiler
->verbose
, "\n");
1516 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_fop1_conv_f64_from_sw(struct sljit_compiler
*compiler
, sljit_s32 op
,
1517 sljit_s32 dst
, sljit_sw dstw
,
1518 sljit_s32 src
, sljit_sw srcw
)
1520 if (SLJIT_UNLIKELY(compiler
->skip_checks
)) {
1521 compiler
->skip_checks
= 0;
1525 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1526 CHECK_ARGUMENT(sljit_has_cpu_feature(SLJIT_HAS_FPU
));
1527 CHECK_ARGUMENT(GET_OPCODE(op
) >= SLJIT_CONV_F64_FROM_SW
&& GET_OPCODE(op
) <= SLJIT_CONV_F64_FROM_S32
);
1528 CHECK_ARGUMENT(!(op
& (SLJIT_SET_Z
| VARIABLE_FLAG_MASK
)));
1529 FUNCTION_CHECK_SRC(src
, srcw
);
1530 FUNCTION_FCHECK(dst
, dstw
);
1532 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1533 if (SLJIT_UNLIKELY(!!compiler
->verbose
)) {
1534 fprintf(compiler
->verbose
, " %s%s.from%s ", fop1_names
[GET_OPCODE(op
) - SLJIT_FOP1_BASE
],
1535 (op
& SLJIT_F32_OP
) ? ".f32" : ".f64",
1536 (GET_OPCODE(op
) == SLJIT_CONV_F64_FROM_S32
) ? ".s32" : ".sw");
1537 sljit_verbose_fparam(compiler
, dst
, dstw
);
1538 fprintf(compiler
->verbose
, ", ");
1539 sljit_verbose_param(compiler
, src
, srcw
);
1540 fprintf(compiler
->verbose
, "\n");
1546 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_fop2(struct sljit_compiler
*compiler
, sljit_s32 op
,
1547 sljit_s32 dst
, sljit_sw dstw
,
1548 sljit_s32 src1
, sljit_sw src1w
,
1549 sljit_s32 src2
, sljit_sw src2w
)
1551 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1552 CHECK_ARGUMENT(sljit_has_cpu_feature(SLJIT_HAS_FPU
));
1553 CHECK_ARGUMENT(GET_OPCODE(op
) >= SLJIT_ADD_F64
&& GET_OPCODE(op
) <= SLJIT_DIV_F64
);
1554 CHECK_ARGUMENT(!(op
& (SLJIT_SET_Z
| VARIABLE_FLAG_MASK
)));
1555 FUNCTION_FCHECK(src1
, src1w
);
1556 FUNCTION_FCHECK(src2
, src2w
);
1557 FUNCTION_FCHECK(dst
, dstw
);
1559 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1560 if (SLJIT_UNLIKELY(!!compiler
->verbose
)) {
1561 fprintf(compiler
->verbose
, " %s%s ", fop2_names
[GET_OPCODE(op
) - SLJIT_FOP2_BASE
], (op
& SLJIT_F32_OP
) ? ".f32" : ".f64");
1562 sljit_verbose_fparam(compiler
, dst
, dstw
);
1563 fprintf(compiler
->verbose
, ", ");
1564 sljit_verbose_fparam(compiler
, src1
, src1w
);
1565 fprintf(compiler
->verbose
, ", ");
1566 sljit_verbose_fparam(compiler
, src2
, src2w
);
1567 fprintf(compiler
->verbose
, "\n");
1573 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_label(struct sljit_compiler
*compiler
)
1575 SLJIT_UNUSED_ARG(compiler
);
1577 if (SLJIT_UNLIKELY(compiler
->skip_checks
)) {
1578 compiler
->skip_checks
= 0;
1582 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1583 compiler
->last_flags
= 0;
1586 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1587 if (SLJIT_UNLIKELY(!!compiler
->verbose
))
1588 fprintf(compiler
->verbose
, "label:\n");
1593 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_jump(struct sljit_compiler
*compiler
, sljit_s32 type
)
1595 if (SLJIT_UNLIKELY(compiler
->skip_checks
)) {
1596 compiler
->skip_checks
= 0;
1600 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1601 CHECK_ARGUMENT(!(type
& ~(0xff | SLJIT_REWRITABLE_JUMP
| SLJIT_I32_OP
)));
1602 CHECK_ARGUMENT((type
& 0xff) != GET_FLAG_TYPE(SLJIT_SET_CARRY
) && (type
& 0xff) != (GET_FLAG_TYPE(SLJIT_SET_CARRY
) + 1));
1603 CHECK_ARGUMENT((type
& 0xff) >= SLJIT_EQUAL
&& (type
& 0xff) <= SLJIT_FAST_CALL
);
1604 CHECK_ARGUMENT((type
& 0xff) < SLJIT_JUMP
|| !(type
& SLJIT_I32_OP
));
1606 if ((type
& 0xff) < SLJIT_JUMP
) {
1607 if ((type
& 0xff) <= SLJIT_NOT_ZERO
)
1608 CHECK_ARGUMENT(compiler
->last_flags
& SLJIT_SET_Z
);
1610 CHECK_ARGUMENT((type
& 0xff) == (compiler
->last_flags
& 0xff)
1611 || ((type
& 0xff) == SLJIT_NOT_OVERFLOW
&& (compiler
->last_flags
& 0xff) == SLJIT_OVERFLOW
));
1614 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1615 if (SLJIT_UNLIKELY(!!compiler
->verbose
))
1616 fprintf(compiler
->verbose
, " jump%s %s%s\n", !(type
& SLJIT_REWRITABLE_JUMP
) ? "" : ".r",
1617 jump_names
[type
& 0xff], JUMP_POSTFIX(type
));
1622 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_call(struct sljit_compiler
*compiler
, sljit_s32 type
,
1623 sljit_s32 arg_types
)
1625 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1626 sljit_s32 i
, types
, curr_type
, scratches
, fscratches
;
1628 CHECK_ARGUMENT(!(type
& ~(0xff | SLJIT_REWRITABLE_JUMP
)));
1629 CHECK_ARGUMENT((type
& 0xff) == SLJIT_CALL
|| (type
& 0xff) == SLJIT_CALL_CDECL
);
1634 for (i
= 0; i
< 5; i
++) {
1635 curr_type
= (types
& SLJIT_DEF_MASK
);
1636 CHECK_ARGUMENT(curr_type
<= SLJIT_ARG_TYPE_F64
);
1638 if (curr_type
== 0) {
1641 if (curr_type
>= SLJIT_ARG_TYPE_F32
)
1646 if (curr_type
>= SLJIT_ARG_TYPE_F32
) {
1647 CHECK_ARGUMENT(compiler
->fscratches
> 0);
1648 } else if (curr_type
>= SLJIT_ARG_TYPE_SW
) {
1649 CHECK_ARGUMENT(compiler
->scratches
> 0);
1652 types
>>= SLJIT_DEF_SHIFT
;
1654 CHECK_ARGUMENT(compiler
->scratches
>= scratches
);
1655 CHECK_ARGUMENT(compiler
->fscratches
>= fscratches
);
1656 CHECK_ARGUMENT(types
== 0);
1658 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1659 if (SLJIT_UNLIKELY(!!compiler
->verbose
)) {
1660 fprintf(compiler
->verbose
, " %s%s ret[%s", jump_names
[type
& 0xff],
1661 !(type
& SLJIT_REWRITABLE_JUMP
) ? "" : ".r", call_arg_names
[arg_types
& SLJIT_DEF_MASK
]);
1663 arg_types
>>= SLJIT_DEF_SHIFT
;
1665 fprintf(compiler
->verbose
, "], args[");
1667 fprintf(compiler
->verbose
, "%s", call_arg_names
[arg_types
& SLJIT_DEF_MASK
]);
1668 arg_types
>>= SLJIT_DEF_SHIFT
;
1670 fprintf(compiler
->verbose
, ",");
1671 } while (arg_types
);
1673 fprintf(compiler
->verbose
, "]\n");
1679 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_cmp(struct sljit_compiler
*compiler
, sljit_s32 type
,
1680 sljit_s32 src1
, sljit_sw src1w
,
1681 sljit_s32 src2
, sljit_sw src2w
)
1683 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1684 CHECK_ARGUMENT(!(type
& ~(0xff | SLJIT_REWRITABLE_JUMP
| SLJIT_I32_OP
)));
1685 CHECK_ARGUMENT((type
& 0xff) >= SLJIT_EQUAL
&& (type
& 0xff) <= SLJIT_SIG_LESS_EQUAL
);
1686 FUNCTION_CHECK_SRC(src1
, src1w
);
1687 FUNCTION_CHECK_SRC(src2
, src2w
);
1688 compiler
->last_flags
= 0;
1690 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1691 if (SLJIT_UNLIKELY(!!compiler
->verbose
)) {
1692 fprintf(compiler
->verbose
, " cmp%s %s%s, ", !(type
& SLJIT_REWRITABLE_JUMP
) ? "" : ".r",
1693 jump_names
[type
& 0xff], (type
& SLJIT_I32_OP
) ? "32" : "");
1694 sljit_verbose_param(compiler
, src1
, src1w
);
1695 fprintf(compiler
->verbose
, ", ");
1696 sljit_verbose_param(compiler
, src2
, src2w
);
1697 fprintf(compiler
->verbose
, "\n");
1703 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_fcmp(struct sljit_compiler
*compiler
, sljit_s32 type
,
1704 sljit_s32 src1
, sljit_sw src1w
,
1705 sljit_s32 src2
, sljit_sw src2w
)
1707 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1708 CHECK_ARGUMENT(sljit_has_cpu_feature(SLJIT_HAS_FPU
));
1709 CHECK_ARGUMENT(!(type
& ~(0xff | SLJIT_REWRITABLE_JUMP
| SLJIT_F32_OP
)));
1710 CHECK_ARGUMENT((type
& 0xff) >= SLJIT_EQUAL_F64
&& (type
& 0xff) <= SLJIT_ORDERED_F64
);
1711 FUNCTION_FCHECK(src1
, src1w
);
1712 FUNCTION_FCHECK(src2
, src2w
);
1713 compiler
->last_flags
= 0;
1715 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1716 if (SLJIT_UNLIKELY(!!compiler
->verbose
)) {
1717 fprintf(compiler
->verbose
, " fcmp%s %s%s, ", !(type
& SLJIT_REWRITABLE_JUMP
) ? "" : ".r",
1718 jump_names
[type
& 0xff], (type
& SLJIT_F32_OP
) ? ".f32" : ".f64");
1719 sljit_verbose_fparam(compiler
, src1
, src1w
);
1720 fprintf(compiler
->verbose
, ", ");
1721 sljit_verbose_fparam(compiler
, src2
, src2w
);
1722 fprintf(compiler
->verbose
, "\n");
1728 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_ijump(struct sljit_compiler
*compiler
, sljit_s32 type
,
1729 sljit_s32 src
, sljit_sw srcw
)
1731 if (SLJIT_UNLIKELY(compiler
->skip_checks
)) {
1732 compiler
->skip_checks
= 0;
1736 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1737 CHECK_ARGUMENT(type
>= SLJIT_JUMP
&& type
<= SLJIT_FAST_CALL
);
1738 FUNCTION_CHECK_SRC(src
, srcw
);
1740 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1741 if (SLJIT_UNLIKELY(!!compiler
->verbose
)) {
1742 fprintf(compiler
->verbose
, " ijump.%s ", jump_names
[type
]);
1743 sljit_verbose_param(compiler
, src
, srcw
);
1744 fprintf(compiler
->verbose
, "\n");
1750 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_icall(struct sljit_compiler
*compiler
, sljit_s32 type
,
1751 sljit_s32 arg_types
,
1752 sljit_s32 src
, sljit_sw srcw
)
1754 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1755 sljit_s32 i
, types
, curr_type
, scratches
, fscratches
;
1757 CHECK_ARGUMENT(type
== SLJIT_CALL
|| type
== SLJIT_CALL_CDECL
);
1758 FUNCTION_CHECK_SRC(src
, srcw
);
1763 for (i
= 0; i
< 5; i
++) {
1764 curr_type
= (types
& SLJIT_DEF_MASK
);
1765 CHECK_ARGUMENT(curr_type
<= SLJIT_ARG_TYPE_F64
);
1767 if (curr_type
== 0) {
1770 if (curr_type
>= SLJIT_ARG_TYPE_F32
)
1775 if (curr_type
>= SLJIT_ARG_TYPE_F32
) {
1776 CHECK_ARGUMENT(compiler
->fscratches
> 0);
1777 } else if (curr_type
>= SLJIT_ARG_TYPE_SW
) {
1778 CHECK_ARGUMENT(compiler
->scratches
> 0);
1781 types
>>= SLJIT_DEF_SHIFT
;
1783 CHECK_ARGUMENT(compiler
->scratches
>= scratches
);
1784 CHECK_ARGUMENT(compiler
->fscratches
>= fscratches
);
1785 CHECK_ARGUMENT(types
== 0);
1787 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1788 if (SLJIT_UNLIKELY(!!compiler
->verbose
)) {
1789 fprintf(compiler
->verbose
, " i%s%s ret[%s", jump_names
[type
& 0xff],
1790 !(type
& SLJIT_REWRITABLE_JUMP
) ? "" : ".r", call_arg_names
[arg_types
& SLJIT_DEF_MASK
]);
1792 arg_types
>>= SLJIT_DEF_SHIFT
;
1794 fprintf(compiler
->verbose
, "], args[");
1796 fprintf(compiler
->verbose
, "%s", call_arg_names
[arg_types
& SLJIT_DEF_MASK
]);
1797 arg_types
>>= SLJIT_DEF_SHIFT
;
1799 fprintf(compiler
->verbose
, ",");
1800 } while (arg_types
);
1802 fprintf(compiler
->verbose
, "], ");
1803 sljit_verbose_param(compiler
, src
, srcw
);
1804 fprintf(compiler
->verbose
, "\n");
1810 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_op_flags(struct sljit_compiler
*compiler
, sljit_s32 op
,
1811 sljit_s32 dst
, sljit_sw dstw
,
1814 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1815 CHECK_ARGUMENT(!(type
& ~(0xff | SLJIT_I32_OP
)));
1816 CHECK_ARGUMENT((type
& 0xff) >= SLJIT_EQUAL
&& (type
& 0xff) <= SLJIT_ORDERED_F64
);
1817 CHECK_ARGUMENT((type
& 0xff) != GET_FLAG_TYPE(SLJIT_SET_CARRY
) && (type
& 0xff) != (GET_FLAG_TYPE(SLJIT_SET_CARRY
) + 1));
1818 CHECK_ARGUMENT(op
== SLJIT_MOV
|| op
== SLJIT_MOV32
1819 || (GET_OPCODE(op
) >= SLJIT_AND
&& GET_OPCODE(op
) <= SLJIT_XOR
));
1820 CHECK_ARGUMENT(!(op
& VARIABLE_FLAG_MASK
));
1822 if ((type
& 0xff) <= SLJIT_NOT_ZERO
)
1823 CHECK_ARGUMENT(compiler
->last_flags
& SLJIT_SET_Z
);
1825 CHECK_ARGUMENT((type
& 0xff) == (compiler
->last_flags
& 0xff)
1826 || ((type
& 0xff) == SLJIT_NOT_OVERFLOW
&& (compiler
->last_flags
& 0xff) == SLJIT_OVERFLOW
));
1828 FUNCTION_CHECK_DST(dst
, dstw
, 0);
1830 if (GET_OPCODE(op
) >= SLJIT_ADD
)
1831 compiler
->last_flags
= GET_FLAG_TYPE(op
) | (op
& (SLJIT_I32_OP
| SLJIT_SET_Z
));
1833 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1834 if (SLJIT_UNLIKELY(!!compiler
->verbose
)) {
1835 fprintf(compiler
->verbose
, " flags%s %s%s, ",
1836 !(op
& SLJIT_SET_Z
) ? "" : ".z",
1837 GET_OPCODE(op
) < SLJIT_OP2_BASE
? "mov" : op2_names
[GET_OPCODE(op
) - SLJIT_OP2_BASE
],
1838 GET_OPCODE(op
) < SLJIT_OP2_BASE
? op1_names
[GET_OPCODE(op
) - SLJIT_OP1_BASE
] : ((op
& SLJIT_I32_OP
) ? "32" : ""));
1839 sljit_verbose_param(compiler
, dst
, dstw
);
1840 fprintf(compiler
->verbose
, ", %s%s\n", jump_names
[type
& 0xff], JUMP_POSTFIX(type
));
1846 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_cmov(struct sljit_compiler
*compiler
, sljit_s32 type
,
1848 sljit_s32 src
, sljit_sw srcw
)
1850 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1851 CHECK_ARGUMENT(!(type
& ~(0xff | SLJIT_I32_OP
)));
1852 CHECK_ARGUMENT((type
& 0xff) >= SLJIT_EQUAL
&& (type
& 0xff) <= SLJIT_ORDERED_F64
);
1854 CHECK_ARGUMENT(compiler
->scratches
!= -1 && compiler
->saveds
!= -1);
1855 CHECK_ARGUMENT(FUNCTION_CHECK_IS_REG(dst_reg
& ~SLJIT_I32_OP
));
1856 if (src
!= SLJIT_IMM
) {
1857 CHECK_ARGUMENT(FUNCTION_CHECK_IS_REG(src
));
1858 CHECK_ARGUMENT(srcw
== 0);
1861 if ((type
& 0xff) <= SLJIT_NOT_ZERO
)
1862 CHECK_ARGUMENT(compiler
->last_flags
& SLJIT_SET_Z
);
1864 CHECK_ARGUMENT((type
& 0xff) == (compiler
->last_flags
& 0xff)
1865 || ((type
& 0xff) == SLJIT_NOT_OVERFLOW
&& (compiler
->last_flags
& 0xff) == SLJIT_OVERFLOW
));
1867 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1868 if (SLJIT_UNLIKELY(!!compiler
->verbose
)) {
1869 fprintf(compiler
->verbose
, " cmov%s %s%s, ",
1870 !(dst_reg
& SLJIT_I32_OP
) ? "" : "32",
1871 jump_names
[type
& 0xff], JUMP_POSTFIX(type
));
1872 sljit_verbose_reg(compiler
, dst_reg
& ~SLJIT_I32_OP
);
1873 fprintf(compiler
->verbose
, ", ");
1874 sljit_verbose_param(compiler
, src
, srcw
);
1875 fprintf(compiler
->verbose
, "\n");
1881 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_mem(struct sljit_compiler
*compiler
, sljit_s32 type
,
1883 sljit_s32 mem
, sljit_sw memw
)
1885 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1886 CHECK_ARGUMENT((type
& 0xff) >= SLJIT_MOV
&& (type
& 0xff) <= SLJIT_MOV_P
);
1887 CHECK_ARGUMENT(!(type
& SLJIT_I32_OP
) || ((type
& 0xff) != SLJIT_MOV
&& (type
& 0xff) != SLJIT_MOV_U32
&& (type
& 0xff) != SLJIT_MOV_P
));
1888 CHECK_ARGUMENT((type
& SLJIT_MEM_PRE
) || (type
& SLJIT_MEM_POST
));
1889 CHECK_ARGUMENT((type
& (SLJIT_MEM_PRE
| SLJIT_MEM_POST
)) != (SLJIT_MEM_PRE
| SLJIT_MEM_POST
));
1890 CHECK_ARGUMENT((type
& ~(0xff | SLJIT_I32_OP
| SLJIT_MEM_STORE
| SLJIT_MEM_SUPP
| SLJIT_MEM_PRE
| SLJIT_MEM_POST
)) == 0);
1892 FUNCTION_CHECK_SRC_MEM(mem
, memw
);
1893 CHECK_ARGUMENT(FUNCTION_CHECK_IS_REG(reg
));
1895 CHECK_ARGUMENT((mem
& REG_MASK
) != SLJIT_UNUSED
&& (mem
& REG_MASK
) != reg
);
1897 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1898 if (!(type
& SLJIT_MEM_SUPP
) && SLJIT_UNLIKELY(!!compiler
->verbose
)) {
1899 if (sljit_emit_mem(compiler
, type
| SLJIT_MEM_SUPP
, reg
, mem
, memw
) == SLJIT_ERR_UNSUPPORTED
)
1900 fprintf(compiler
->verbose
, " //");
1902 fprintf(compiler
->verbose
, " mem%s.%s%s%s ",
1903 !(type
& SLJIT_I32_OP
) ? "" : "32",
1904 (type
& SLJIT_MEM_STORE
) ? "st" : "ld",
1905 op1_names
[(type
& 0xff) - SLJIT_OP1_BASE
],
1906 (type
& SLJIT_MEM_PRE
) ? ".pre" : ".post");
1907 sljit_verbose_reg(compiler
, reg
);
1908 fprintf(compiler
->verbose
, ", ");
1909 sljit_verbose_param(compiler
, mem
, memw
);
1910 fprintf(compiler
->verbose
, "\n");
1916 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_fmem(struct sljit_compiler
*compiler
, sljit_s32 type
,
1918 sljit_s32 mem
, sljit_sw memw
)
1920 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1921 CHECK_ARGUMENT((type
& 0xff) == SLJIT_MOV_F64
);
1922 CHECK_ARGUMENT((type
& SLJIT_MEM_PRE
) || (type
& SLJIT_MEM_POST
));
1923 CHECK_ARGUMENT((type
& (SLJIT_MEM_PRE
| SLJIT_MEM_POST
)) != (SLJIT_MEM_PRE
| SLJIT_MEM_POST
));
1924 CHECK_ARGUMENT((type
& ~(0xff | SLJIT_I32_OP
| SLJIT_MEM_STORE
| SLJIT_MEM_SUPP
| SLJIT_MEM_PRE
| SLJIT_MEM_POST
)) == 0);
1926 FUNCTION_CHECK_SRC_MEM(mem
, memw
);
1927 CHECK_ARGUMENT(FUNCTION_CHECK_IS_FREG(freg
));
1929 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1930 if (!(type
& SLJIT_MEM_SUPP
) && SLJIT_UNLIKELY(!!compiler
->verbose
)) {
1931 if (sljit_emit_fmem(compiler
, type
| SLJIT_MEM_SUPP
, freg
, mem
, memw
) == SLJIT_ERR_UNSUPPORTED
)
1932 fprintf(compiler
->verbose
, " //");
1934 fprintf(compiler
->verbose
, " fmem.%s%s%s ",
1935 (type
& SLJIT_MEM_STORE
) ? "st" : "ld",
1936 !(type
& SLJIT_I32_OP
) ? ".f64" : ".f32",
1937 (type
& SLJIT_MEM_PRE
) ? ".pre" : ".post");
1938 sljit_verbose_freg(compiler
, freg
);
1939 fprintf(compiler
->verbose
, ", ");
1940 sljit_verbose_param(compiler
, mem
, memw
);
1941 fprintf(compiler
->verbose
, "\n");
1947 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_get_local_base(struct sljit_compiler
*compiler
, sljit_s32 dst
, sljit_sw dstw
, sljit_sw offset
)
1949 /* Any offset is allowed. */
1950 SLJIT_UNUSED_ARG(offset
);
1952 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1953 FUNCTION_CHECK_DST(dst
, dstw
, 0);
1955 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1956 if (SLJIT_UNLIKELY(!!compiler
->verbose
)) {
1957 fprintf(compiler
->verbose
, " local_base ");
1958 sljit_verbose_param(compiler
, dst
, dstw
);
1959 fprintf(compiler
->verbose
, ", #%" SLJIT_PRINT_D
"d\n", offset
);
1965 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_const(struct sljit_compiler
*compiler
, sljit_s32 dst
, sljit_sw dstw
, sljit_sw init_value
)
1967 SLJIT_UNUSED_ARG(init_value
);
1969 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1970 FUNCTION_CHECK_DST(dst
, dstw
, 0);
1972 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1973 if (SLJIT_UNLIKELY(!!compiler
->verbose
)) {
1974 fprintf(compiler
->verbose
, " const ");
1975 sljit_verbose_param(compiler
, dst
, dstw
);
1976 fprintf(compiler
->verbose
, ", #%" SLJIT_PRINT_D
"d\n", init_value
);
1982 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_put_label(struct sljit_compiler
*compiler
, sljit_s32 dst
, sljit_sw dstw
)
1984 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1985 FUNCTION_CHECK_DST(dst
, dstw
, 0);
1987 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1988 if (SLJIT_UNLIKELY(!!compiler
->verbose
)) {
1989 fprintf(compiler
->verbose
, " put_label ");
1990 sljit_verbose_param(compiler
, dst
, dstw
);
1991 fprintf(compiler
->verbose
, "\n");
1997 #endif /* SLJIT_ARGUMENT_CHECKS || SLJIT_VERBOSE */
1999 #define SELECT_FOP1_OPERATION_WITH_CHECKS(compiler, op, dst, dstw, src, srcw) \
2000 SLJIT_COMPILE_ASSERT(!(SLJIT_CONV_SW_FROM_F64 & 0x1) && !(SLJIT_CONV_F64_FROM_SW & 0x1), \
2001 invalid_float_opcodes); \
2002 if (GET_OPCODE(op) >= SLJIT_CONV_SW_FROM_F64 && GET_OPCODE(op) <= SLJIT_CMP_F64) { \
2003 if (GET_OPCODE(op) == SLJIT_CMP_F64) { \
2004 CHECK(check_sljit_emit_fop1_cmp(compiler, op, dst, dstw, src, srcw)); \
2005 ADJUST_LOCAL_OFFSET(dst, dstw); \
2006 ADJUST_LOCAL_OFFSET(src, srcw); \
2007 return sljit_emit_fop1_cmp(compiler, op, dst, dstw, src, srcw); \
2009 if ((GET_OPCODE(op) | 0x1) == SLJIT_CONV_S32_FROM_F64) { \
2010 CHECK(check_sljit_emit_fop1_conv_sw_from_f64(compiler, op, dst, dstw, src, srcw)); \
2011 ADJUST_LOCAL_OFFSET(dst, dstw); \
2012 ADJUST_LOCAL_OFFSET(src, srcw); \
2013 return sljit_emit_fop1_conv_sw_from_f64(compiler, op, dst, dstw, src, srcw); \
2015 CHECK(check_sljit_emit_fop1_conv_f64_from_sw(compiler, op, dst, dstw, src, srcw)); \
2016 ADJUST_LOCAL_OFFSET(dst, dstw); \
2017 ADJUST_LOCAL_OFFSET(src, srcw); \
2018 return sljit_emit_fop1_conv_f64_from_sw(compiler, op, dst, dstw, src, srcw); \
2020 CHECK(check_sljit_emit_fop1(compiler, op, dst, dstw, src, srcw)); \
2021 ADJUST_LOCAL_OFFSET(dst, dstw); \
2022 ADJUST_LOCAL_OFFSET(src, srcw);
2024 static SLJIT_INLINE sljit_s32
emit_mov_before_return(struct sljit_compiler
*compiler
, sljit_s32 op
, sljit_s32 src
, sljit_sw srcw
)
2026 /* Return if don't need to do anything. */
2027 if (op
== SLJIT_UNUSED
)
2028 return SLJIT_SUCCESS
;
2030 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
2031 /* At the moment the pointer size is always equal to sljit_sw. May be changed in the future. */
2032 if (src
== SLJIT_RETURN_REG
&& (op
== SLJIT_MOV
|| op
== SLJIT_MOV_P
))
2033 return SLJIT_SUCCESS
;
2035 if (src
== SLJIT_RETURN_REG
&& (op
== SLJIT_MOV
|| op
== SLJIT_MOV_U32
|| op
== SLJIT_MOV_S32
|| op
== SLJIT_MOV_P
))
2036 return SLJIT_SUCCESS
;
2039 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS) \
2040 || (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
2041 compiler
->skip_checks
= 1;
2043 return sljit_emit_op1(compiler
, op
, SLJIT_RETURN_REG
, 0, src
, srcw
);
2046 #if (defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86) \
2047 || (defined SLJIT_CONFIG_PPC && SLJIT_CONFIG_PPC) \
2048 || (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32) \
2049 || ((defined SLJIT_CONFIG_MIPS && SLJIT_CONFIG_MIPS) && !(defined SLJIT_MIPS_REV && SLJIT_MIPS_REV >= 1 && SLJIT_MIPS_REV < 6))
2051 static SLJIT_INLINE sljit_s32
sljit_emit_cmov_generic(struct sljit_compiler
*compiler
, sljit_s32 type
,
2053 sljit_s32 src
, sljit_sw srcw
)
2055 struct sljit_label
*label
;
2056 struct sljit_jump
*jump
;
2057 sljit_s32 op
= (dst_reg
& SLJIT_I32_OP
) ? SLJIT_MOV32
: SLJIT_MOV
;
2059 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) \
2060 || (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
2061 compiler
->skip_checks
= 1;
2063 jump
= sljit_emit_jump(compiler
, type
^ 0x1);
2066 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) \
2067 || (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
2068 compiler
->skip_checks
= 1;
2070 FAIL_IF(sljit_emit_op1(compiler
, op
, dst_reg
& ~SLJIT_I32_OP
, 0, src
, srcw
));
2072 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) \
2073 || (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
2074 compiler
->skip_checks
= 1;
2076 label
= sljit_emit_label(compiler
);
2078 sljit_set_label(jump
, label
);
2079 return SLJIT_SUCCESS
;
2084 /* CPU description section */
2086 #if (defined SLJIT_32BIT_ARCHITECTURE && SLJIT_32BIT_ARCHITECTURE)
2087 #define SLJIT_CPUINFO_PART1 " 32bit ("
2088 #elif (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
2089 #define SLJIT_CPUINFO_PART1 " 64bit ("
2091 #error "Internal error: CPU type info missing"
2094 #if (defined SLJIT_LITTLE_ENDIAN && SLJIT_LITTLE_ENDIAN)
2095 #define SLJIT_CPUINFO_PART2 "little endian + "
2096 #elif (defined SLJIT_BIG_ENDIAN && SLJIT_BIG_ENDIAN)
2097 #define SLJIT_CPUINFO_PART2 "big endian + "
2099 #error "Internal error: CPU type info missing"
2102 #if (defined SLJIT_UNALIGNED && SLJIT_UNALIGNED)
2103 #define SLJIT_CPUINFO_PART3 "unaligned)"
2105 #define SLJIT_CPUINFO_PART3 "aligned)"
2108 #define SLJIT_CPUINFO SLJIT_CPUINFO_PART1 SLJIT_CPUINFO_PART2 SLJIT_CPUINFO_PART3
2110 #if (defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86)
2111 # include "sljitNativeX86_common.c"
2112 #elif (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5)
2113 # include "sljitNativeARM_32.c"
2114 #elif (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7)
2115 # include "sljitNativeARM_32.c"
2116 #elif (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
2117 # include "sljitNativeARM_T2_32.c"
2118 #elif (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64)
2119 # include "sljitNativeARM_64.c"
2120 #elif (defined SLJIT_CONFIG_PPC && SLJIT_CONFIG_PPC)
2121 # include "sljitNativePPC_common.c"
2122 #elif (defined SLJIT_CONFIG_MIPS && SLJIT_CONFIG_MIPS)
2123 # include "sljitNativeMIPS_common.c"
2124 #elif (defined SLJIT_CONFIG_SPARC && SLJIT_CONFIG_SPARC)
2125 # include "sljitNativeSPARC_common.c"
2126 #elif (defined SLJIT_CONFIG_S390X && SLJIT_CONFIG_S390X)
2127 # include "sljitNativeS390X.c"
2130 #if !(defined SLJIT_CONFIG_MIPS && SLJIT_CONFIG_MIPS)
2132 SLJIT_API_FUNC_ATTRIBUTE
struct sljit_jump
* sljit_emit_cmp(struct sljit_compiler
*compiler
, sljit_s32 type
,
2133 sljit_s32 src1
, sljit_sw src1w
,
2134 sljit_s32 src2
, sljit_sw src2w
)
2136 /* Default compare for most architectures. */
2137 sljit_s32 flags
, tmp_src
, condition
;
2141 CHECK_PTR(check_sljit_emit_cmp(compiler
, type
, src1
, src1w
, src2
, src2w
));
2143 condition
= type
& 0xff;
2144 #if (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64)
2145 if ((condition
== SLJIT_EQUAL
|| condition
== SLJIT_NOT_EQUAL
)) {
2146 if ((src1
& SLJIT_IMM
) && !src1w
) {
2152 if ((src2
& SLJIT_IMM
) && !src2w
)
2153 return emit_cmp_to0(compiler
, type
, src1
, src1w
);
2157 if (SLJIT_UNLIKELY((src1
& SLJIT_IMM
) && !(src2
& SLJIT_IMM
))) {
2158 /* Immediate is preferred as second argument by most architectures. */
2159 switch (condition
) {
2161 condition
= SLJIT_GREATER
;
2163 case SLJIT_GREATER_EQUAL
:
2164 condition
= SLJIT_LESS_EQUAL
;
2167 condition
= SLJIT_LESS
;
2169 case SLJIT_LESS_EQUAL
:
2170 condition
= SLJIT_GREATER_EQUAL
;
2172 case SLJIT_SIG_LESS
:
2173 condition
= SLJIT_SIG_GREATER
;
2175 case SLJIT_SIG_GREATER_EQUAL
:
2176 condition
= SLJIT_SIG_LESS_EQUAL
;
2178 case SLJIT_SIG_GREATER
:
2179 condition
= SLJIT_SIG_LESS
;
2181 case SLJIT_SIG_LESS_EQUAL
:
2182 condition
= SLJIT_SIG_GREATER_EQUAL
;
2186 type
= condition
| (type
& (SLJIT_I32_OP
| SLJIT_REWRITABLE_JUMP
));
2195 if (condition
<= SLJIT_NOT_ZERO
)
2196 flags
= SLJIT_SET_Z
;
2198 flags
= condition
<< VARIABLE_FLAG_SHIFT
;
2200 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) \
2201 || (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
2202 compiler
->skip_checks
= 1;
2204 PTR_FAIL_IF(sljit_emit_op2(compiler
, SLJIT_SUB
| flags
| (type
& SLJIT_I32_OP
),
2205 SLJIT_UNUSED
, 0, src1
, src1w
, src2
, src2w
));
2206 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) \
2207 || (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
2208 compiler
->skip_checks
= 1;
2210 return sljit_emit_jump(compiler
, condition
| (type
& (SLJIT_REWRITABLE_JUMP
| SLJIT_I32_OP
)));
2215 SLJIT_API_FUNC_ATTRIBUTE
struct sljit_jump
* sljit_emit_fcmp(struct sljit_compiler
*compiler
, sljit_s32 type
,
2216 sljit_s32 src1
, sljit_sw src1w
,
2217 sljit_s32 src2
, sljit_sw src2w
)
2220 CHECK_PTR(check_sljit_emit_fcmp(compiler
, type
, src1
, src1w
, src2
, src2w
));
2222 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) \
2223 || (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
2224 compiler
->skip_checks
= 1;
2226 sljit_emit_fop1(compiler
, SLJIT_CMP_F64
| ((type
& 0xff) << VARIABLE_FLAG_SHIFT
) | (type
& SLJIT_I32_OP
), src1
, src1w
, src2
, src2w
);
2228 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) \
2229 || (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
2230 compiler
->skip_checks
= 1;
2232 return sljit_emit_jump(compiler
, type
);
2235 #if !(defined SLJIT_CONFIG_ARM_32 && SLJIT_CONFIG_ARM_32) \
2236 && !(defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) \
2237 && !(defined SLJIT_CONFIG_PPC && SLJIT_CONFIG_PPC)
2239 SLJIT_API_FUNC_ATTRIBUTE sljit_s32
sljit_emit_mem(struct sljit_compiler
*compiler
, sljit_s32 type
,
2241 sljit_s32 mem
, sljit_sw memw
)
2243 SLJIT_UNUSED_ARG(compiler
);
2244 SLJIT_UNUSED_ARG(type
);
2245 SLJIT_UNUSED_ARG(reg
);
2246 SLJIT_UNUSED_ARG(mem
);
2247 SLJIT_UNUSED_ARG(memw
);
2250 CHECK(check_sljit_emit_mem(compiler
, type
, reg
, mem
, memw
));
2252 return SLJIT_ERR_UNSUPPORTED
;
2257 #if !(defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) \
2258 && !(defined SLJIT_CONFIG_PPC && SLJIT_CONFIG_PPC)
2260 SLJIT_API_FUNC_ATTRIBUTE sljit_s32
sljit_emit_fmem(struct sljit_compiler
*compiler
, sljit_s32 type
,
2262 sljit_s32 mem
, sljit_sw memw
)
2264 SLJIT_UNUSED_ARG(compiler
);
2265 SLJIT_UNUSED_ARG(type
);
2266 SLJIT_UNUSED_ARG(freg
);
2267 SLJIT_UNUSED_ARG(mem
);
2268 SLJIT_UNUSED_ARG(memw
);
2271 CHECK(check_sljit_emit_fmem(compiler
, type
, freg
, mem
, memw
));
2273 return SLJIT_ERR_UNSUPPORTED
;
2278 #if !(defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86) \
2279 && !(defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64)
2281 SLJIT_API_FUNC_ATTRIBUTE sljit_s32
sljit_get_local_base(struct sljit_compiler
*compiler
, sljit_s32 dst
, sljit_sw dstw
, sljit_sw offset
)
2284 CHECK(check_sljit_get_local_base(compiler
, dst
, dstw
, offset
));
2286 ADJUST_LOCAL_OFFSET(SLJIT_MEM1(SLJIT_SP
), offset
);
2287 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) \
2288 || (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
2289 compiler
->skip_checks
= 1;
2292 return sljit_emit_op2(compiler
, SLJIT_ADD
, dst
, dstw
, SLJIT_SP
, 0, SLJIT_IMM
, offset
);
2293 return sljit_emit_op1(compiler
, SLJIT_MOV
, dst
, dstw
, SLJIT_SP
, 0);
2298 #else /* SLJIT_CONFIG_UNSUPPORTED */
2300 /* Empty function bodies for those machines, which are not (yet) supported. */
2302 SLJIT_API_FUNC_ATTRIBUTE
const char* sljit_get_platform_name(void)
2304 return "unsupported";
2307 SLJIT_API_FUNC_ATTRIBUTE
struct sljit_compiler
* sljit_create_compiler(void *allocator_data
, void *exec_allocator_data
)
2309 SLJIT_UNUSED_ARG(allocator_data
);
2310 SLJIT_UNUSED_ARG(exec_allocator_data
);
2311 SLJIT_UNREACHABLE();
2315 SLJIT_API_FUNC_ATTRIBUTE
void sljit_free_compiler(struct sljit_compiler
*compiler
)
2317 SLJIT_UNUSED_ARG(compiler
);
2318 SLJIT_UNREACHABLE();
2321 SLJIT_API_FUNC_ATTRIBUTE
void sljit_set_compiler_memory_error(struct sljit_compiler
*compiler
)
2323 SLJIT_UNUSED_ARG(compiler
);
2324 SLJIT_UNREACHABLE();
2327 SLJIT_API_FUNC_ATTRIBUTE
void* sljit_alloc_memory(struct sljit_compiler
*compiler
, sljit_s32 size
)
2329 SLJIT_UNUSED_ARG(compiler
);
2330 SLJIT_UNUSED_ARG(size
);
2331 SLJIT_UNREACHABLE();
2335 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
2336 SLJIT_API_FUNC_ATTRIBUTE
void sljit_compiler_verbose(struct sljit_compiler
*compiler
, FILE* verbose
)
2338 SLJIT_UNUSED_ARG(compiler
);
2339 SLJIT_UNUSED_ARG(verbose
);
2340 SLJIT_UNREACHABLE();
2344 SLJIT_API_FUNC_ATTRIBUTE
void* sljit_generate_code(struct sljit_compiler
*compiler
)
2346 SLJIT_UNUSED_ARG(compiler
);
2347 SLJIT_UNREACHABLE();
2351 SLJIT_API_FUNC_ATTRIBUTE sljit_s32
sljit_has_cpu_feature(sljit_s32 feature_type
)
2353 SLJIT_UNUSED_ARG(feature_type
);
2354 SLJIT_UNREACHABLE();
2358 SLJIT_API_FUNC_ATTRIBUTE
void sljit_free_code(void* code
, void *exec_allocator_data
)
2360 SLJIT_UNUSED_ARG(code
);
2361 SLJIT_UNUSED_ARG(exec_allocator_data
);
2362 SLJIT_UNREACHABLE();
2365 SLJIT_API_FUNC_ATTRIBUTE sljit_s32
sljit_emit_enter(struct sljit_compiler
*compiler
,
2366 sljit_s32 options
, sljit_s32 arg_types
, sljit_s32 scratches
, sljit_s32 saveds
,
2367 sljit_s32 fscratches
, sljit_s32 fsaveds
, sljit_s32 local_size
)
2369 SLJIT_UNUSED_ARG(compiler
);
2370 SLJIT_UNUSED_ARG(options
);
2371 SLJIT_UNUSED_ARG(arg_types
);
2372 SLJIT_UNUSED_ARG(scratches
);
2373 SLJIT_UNUSED_ARG(saveds
);
2374 SLJIT_UNUSED_ARG(fscratches
);
2375 SLJIT_UNUSED_ARG(fsaveds
);
2376 SLJIT_UNUSED_ARG(local_size
);
2377 SLJIT_UNREACHABLE();
2378 return SLJIT_ERR_UNSUPPORTED
;
2381 SLJIT_API_FUNC_ATTRIBUTE sljit_s32
sljit_set_context(struct sljit_compiler
*compiler
,
2382 sljit_s32 options
, sljit_s32 arg_types
, sljit_s32 scratches
, sljit_s32 saveds
,
2383 sljit_s32 fscratches
, sljit_s32 fsaveds
, sljit_s32 local_size
)
2385 SLJIT_UNUSED_ARG(compiler
);
2386 SLJIT_UNUSED_ARG(options
);
2387 SLJIT_UNUSED_ARG(arg_types
);
2388 SLJIT_UNUSED_ARG(scratches
);
2389 SLJIT_UNUSED_ARG(saveds
);
2390 SLJIT_UNUSED_ARG(fscratches
);
2391 SLJIT_UNUSED_ARG(fsaveds
);
2392 SLJIT_UNUSED_ARG(local_size
);
2393 SLJIT_UNREACHABLE();
2394 return SLJIT_ERR_UNSUPPORTED
;
2397 SLJIT_API_FUNC_ATTRIBUTE sljit_s32
sljit_emit_return(struct sljit_compiler
*compiler
, sljit_s32 op
, sljit_s32 src
, sljit_sw srcw
)
2399 SLJIT_UNUSED_ARG(compiler
);
2400 SLJIT_UNUSED_ARG(op
);
2401 SLJIT_UNUSED_ARG(src
);
2402 SLJIT_UNUSED_ARG(srcw
);
2403 SLJIT_UNREACHABLE();
2404 return SLJIT_ERR_UNSUPPORTED
;
2407 SLJIT_API_FUNC_ATTRIBUTE sljit_s32
sljit_emit_fast_enter(struct sljit_compiler
*compiler
, sljit_s32 dst
, sljit_sw dstw
)
2409 SLJIT_UNUSED_ARG(compiler
);
2410 SLJIT_UNUSED_ARG(dst
);
2411 SLJIT_UNUSED_ARG(dstw
);
2412 SLJIT_UNREACHABLE();
2413 return SLJIT_ERR_UNSUPPORTED
;
2416 SLJIT_API_FUNC_ATTRIBUTE sljit_s32
sljit_emit_op0(struct sljit_compiler
*compiler
, sljit_s32 op
)
2418 SLJIT_UNUSED_ARG(compiler
);
2419 SLJIT_UNUSED_ARG(op
);
2420 SLJIT_UNREACHABLE();
2421 return SLJIT_ERR_UNSUPPORTED
;
2424 SLJIT_API_FUNC_ATTRIBUTE sljit_s32
sljit_emit_op1(struct sljit_compiler
*compiler
, sljit_s32 op
,
2425 sljit_s32 dst
, sljit_sw dstw
,
2426 sljit_s32 src
, sljit_sw srcw
)
2428 SLJIT_UNUSED_ARG(compiler
);
2429 SLJIT_UNUSED_ARG(op
);
2430 SLJIT_UNUSED_ARG(dst
);
2431 SLJIT_UNUSED_ARG(dstw
);
2432 SLJIT_UNUSED_ARG(src
);
2433 SLJIT_UNUSED_ARG(srcw
);
2434 SLJIT_UNREACHABLE();
2435 return SLJIT_ERR_UNSUPPORTED
;
2438 SLJIT_API_FUNC_ATTRIBUTE sljit_s32
sljit_emit_op2(struct sljit_compiler
*compiler
, sljit_s32 op
,
2439 sljit_s32 dst
, sljit_sw dstw
,
2440 sljit_s32 src1
, sljit_sw src1w
,
2441 sljit_s32 src2
, sljit_sw src2w
)
2443 SLJIT_UNUSED_ARG(compiler
);
2444 SLJIT_UNUSED_ARG(op
);
2445 SLJIT_UNUSED_ARG(dst
);
2446 SLJIT_UNUSED_ARG(dstw
);
2447 SLJIT_UNUSED_ARG(src1
);
2448 SLJIT_UNUSED_ARG(src1w
);
2449 SLJIT_UNUSED_ARG(src2
);
2450 SLJIT_UNUSED_ARG(src2w
);
2451 SLJIT_UNREACHABLE();
2452 return SLJIT_ERR_UNSUPPORTED
;
2455 SLJIT_API_FUNC_ATTRIBUTE sljit_s32
sljit_emit_op_src(struct sljit_compiler
*compiler
, sljit_s32 op
,
2456 sljit_s32 src
, sljit_sw srcw
)
2458 SLJIT_UNUSED_ARG(compiler
);
2459 SLJIT_UNUSED_ARG(op
);
2460 SLJIT_UNUSED_ARG(src
);
2461 SLJIT_UNUSED_ARG(srcw
);
2462 SLJIT_UNREACHABLE();
2463 return SLJIT_ERR_UNSUPPORTED
;
2466 SLJIT_API_FUNC_ATTRIBUTE sljit_s32
sljit_get_register_index(sljit_s32 reg
)
2468 SLJIT_UNREACHABLE();
2472 SLJIT_API_FUNC_ATTRIBUTE sljit_s32
sljit_emit_op_custom(struct sljit_compiler
*compiler
,
2473 void *instruction
, sljit_s32 size
)
2475 SLJIT_UNUSED_ARG(compiler
);
2476 SLJIT_UNUSED_ARG(instruction
);
2477 SLJIT_UNUSED_ARG(size
);
2478 SLJIT_UNREACHABLE();
2479 return SLJIT_ERR_UNSUPPORTED
;
2482 SLJIT_API_FUNC_ATTRIBUTE
void sljit_set_current_flags(struct sljit_compiler
*compiler
, sljit_s32 current_flags
)
2484 SLJIT_UNUSED_ARG(compiler
);
2485 SLJIT_UNUSED_ARG(current_flags
);
2488 SLJIT_API_FUNC_ATTRIBUTE sljit_s32
sljit_emit_fop1(struct sljit_compiler
*compiler
, sljit_s32 op
,
2489 sljit_s32 dst
, sljit_sw dstw
,
2490 sljit_s32 src
, sljit_sw srcw
)
2492 SLJIT_UNUSED_ARG(compiler
);
2493 SLJIT_UNUSED_ARG(op
);
2494 SLJIT_UNUSED_ARG(dst
);
2495 SLJIT_UNUSED_ARG(dstw
);
2496 SLJIT_UNUSED_ARG(src
);
2497 SLJIT_UNUSED_ARG(srcw
);
2498 SLJIT_UNREACHABLE();
2499 return SLJIT_ERR_UNSUPPORTED
;
2502 SLJIT_API_FUNC_ATTRIBUTE sljit_s32
sljit_emit_fop2(struct sljit_compiler
*compiler
, sljit_s32 op
,
2503 sljit_s32 dst
, sljit_sw dstw
,
2504 sljit_s32 src1
, sljit_sw src1w
,
2505 sljit_s32 src2
, sljit_sw src2w
)
2507 SLJIT_UNUSED_ARG(compiler
);
2508 SLJIT_UNUSED_ARG(op
);
2509 SLJIT_UNUSED_ARG(dst
);
2510 SLJIT_UNUSED_ARG(dstw
);
2511 SLJIT_UNUSED_ARG(src1
);
2512 SLJIT_UNUSED_ARG(src1w
);
2513 SLJIT_UNUSED_ARG(src2
);
2514 SLJIT_UNUSED_ARG(src2w
);
2515 SLJIT_UNREACHABLE();
2516 return SLJIT_ERR_UNSUPPORTED
;
2519 SLJIT_API_FUNC_ATTRIBUTE
struct sljit_label
* sljit_emit_label(struct sljit_compiler
*compiler
)
2521 SLJIT_UNUSED_ARG(compiler
);
2522 SLJIT_UNREACHABLE();
2526 SLJIT_API_FUNC_ATTRIBUTE
struct sljit_jump
* sljit_emit_jump(struct sljit_compiler
*compiler
, sljit_s32 type
)
2528 SLJIT_UNUSED_ARG(compiler
);
2529 SLJIT_UNUSED_ARG(type
);
2530 SLJIT_UNREACHABLE();
2534 SLJIT_API_FUNC_ATTRIBUTE
struct sljit_jump
* sljit_emit_call(struct sljit_compiler
*compiler
, sljit_s32 type
,
2535 sljit_s32 arg_types
)
2537 SLJIT_UNUSED_ARG(compiler
);
2538 SLJIT_UNUSED_ARG(type
);
2539 SLJIT_UNUSED_ARG(arg_types
);
2540 SLJIT_UNREACHABLE();
2544 SLJIT_API_FUNC_ATTRIBUTE
struct sljit_jump
* sljit_emit_cmp(struct sljit_compiler
*compiler
, sljit_s32 type
,
2545 sljit_s32 src1
, sljit_sw src1w
,
2546 sljit_s32 src2
, sljit_sw src2w
)
2548 SLJIT_UNUSED_ARG(compiler
);
2549 SLJIT_UNUSED_ARG(type
);
2550 SLJIT_UNUSED_ARG(src1
);
2551 SLJIT_UNUSED_ARG(src1w
);
2552 SLJIT_UNUSED_ARG(src2
);
2553 SLJIT_UNUSED_ARG(src2w
);
2554 SLJIT_UNREACHABLE();
2558 SLJIT_API_FUNC_ATTRIBUTE
struct sljit_jump
* sljit_emit_fcmp(struct sljit_compiler
*compiler
, sljit_s32 type
,
2559 sljit_s32 src1
, sljit_sw src1w
,
2560 sljit_s32 src2
, sljit_sw src2w
)
2562 SLJIT_UNUSED_ARG(compiler
);
2563 SLJIT_UNUSED_ARG(type
);
2564 SLJIT_UNUSED_ARG(src1
);
2565 SLJIT_UNUSED_ARG(src1w
);
2566 SLJIT_UNUSED_ARG(src2
);
2567 SLJIT_UNUSED_ARG(src2w
);
2568 SLJIT_UNREACHABLE();
2572 SLJIT_API_FUNC_ATTRIBUTE
void sljit_set_label(struct sljit_jump
*jump
, struct sljit_label
* label
)
2574 SLJIT_UNUSED_ARG(jump
);
2575 SLJIT_UNUSED_ARG(label
);
2576 SLJIT_UNREACHABLE();
2579 SLJIT_API_FUNC_ATTRIBUTE
void sljit_set_target(struct sljit_jump
*jump
, sljit_uw target
)
2581 SLJIT_UNUSED_ARG(jump
);
2582 SLJIT_UNUSED_ARG(target
);
2583 SLJIT_UNREACHABLE();
2586 SLJIT_API_FUNC_ATTRIBUTE
void sljit_set_put_label(struct sljit_put_label
*put_label
, struct sljit_label
*label
)
2588 SLJIT_UNUSED_ARG(put_label
);
2589 SLJIT_UNUSED_ARG(label
);
2590 SLJIT_UNREACHABLE();
2593 SLJIT_API_FUNC_ATTRIBUTE sljit_s32
sljit_emit_ijump(struct sljit_compiler
*compiler
, sljit_s32 type
, sljit_s32 src
, sljit_sw srcw
)
2595 SLJIT_UNUSED_ARG(compiler
);
2596 SLJIT_UNUSED_ARG(type
);
2597 SLJIT_UNUSED_ARG(src
);
2598 SLJIT_UNUSED_ARG(srcw
);
2599 SLJIT_UNREACHABLE();
2600 return SLJIT_ERR_UNSUPPORTED
;
2603 SLJIT_API_FUNC_ATTRIBUTE sljit_s32
sljit_emit_icall(struct sljit_compiler
*compiler
, sljit_s32 type
,
2604 sljit_s32 arg_types
,
2605 sljit_s32 src
, sljit_sw srcw
)
2607 SLJIT_UNUSED_ARG(compiler
);
2608 SLJIT_UNUSED_ARG(type
);
2609 SLJIT_UNUSED_ARG(arg_types
);
2610 SLJIT_UNUSED_ARG(src
);
2611 SLJIT_UNUSED_ARG(srcw
);
2612 SLJIT_UNREACHABLE();
2613 return SLJIT_ERR_UNSUPPORTED
;
2616 SLJIT_API_FUNC_ATTRIBUTE sljit_s32
sljit_emit_op_flags(struct sljit_compiler
*compiler
, sljit_s32 op
,
2617 sljit_s32 dst
, sljit_sw dstw
,
2620 SLJIT_UNUSED_ARG(compiler
);
2621 SLJIT_UNUSED_ARG(op
);
2622 SLJIT_UNUSED_ARG(dst
);
2623 SLJIT_UNUSED_ARG(dstw
);
2624 SLJIT_UNUSED_ARG(type
);
2625 SLJIT_UNREACHABLE();
2626 return SLJIT_ERR_UNSUPPORTED
;
2629 SLJIT_API_FUNC_ATTRIBUTE sljit_s32
sljit_emit_cmov(struct sljit_compiler
*compiler
, sljit_s32 type
,
2631 sljit_s32 src
, sljit_sw srcw
)
2633 SLJIT_UNUSED_ARG(compiler
);
2634 SLJIT_UNUSED_ARG(type
);
2635 SLJIT_UNUSED_ARG(dst_reg
);
2636 SLJIT_UNUSED_ARG(src
);
2637 SLJIT_UNUSED_ARG(srcw
);
2638 SLJIT_UNREACHABLE();
2639 return SLJIT_ERR_UNSUPPORTED
;
2642 SLJIT_API_FUNC_ATTRIBUTE sljit_s32
sljit_emit_mem(struct sljit_compiler
*compiler
, sljit_s32 type
, sljit_s32 reg
, sljit_s32 mem
, sljit_sw memw
)
2644 SLJIT_UNUSED_ARG(compiler
);
2645 SLJIT_UNUSED_ARG(type
);
2646 SLJIT_UNUSED_ARG(reg
);
2647 SLJIT_UNUSED_ARG(mem
);
2648 SLJIT_UNUSED_ARG(memw
);
2649 SLJIT_UNREACHABLE();
2650 return SLJIT_ERR_UNSUPPORTED
;
2653 SLJIT_API_FUNC_ATTRIBUTE sljit_s32
sljit_emit_fmem(struct sljit_compiler
*compiler
, sljit_s32 type
, sljit_s32 freg
, sljit_s32 mem
, sljit_sw memw
)
2655 SLJIT_UNUSED_ARG(compiler
);
2656 SLJIT_UNUSED_ARG(type
);
2657 SLJIT_UNUSED_ARG(freg
);
2658 SLJIT_UNUSED_ARG(mem
);
2659 SLJIT_UNUSED_ARG(memw
);
2660 SLJIT_UNREACHABLE();
2661 return SLJIT_ERR_UNSUPPORTED
;
2664 SLJIT_API_FUNC_ATTRIBUTE sljit_s32
sljit_get_local_base(struct sljit_compiler
*compiler
, sljit_s32 dst
, sljit_sw dstw
, sljit_sw offset
)
2666 SLJIT_UNUSED_ARG(compiler
);
2667 SLJIT_UNUSED_ARG(dst
);
2668 SLJIT_UNUSED_ARG(dstw
);
2669 SLJIT_UNUSED_ARG(offset
);
2670 SLJIT_UNREACHABLE();
2671 return SLJIT_ERR_UNSUPPORTED
;
2674 SLJIT_API_FUNC_ATTRIBUTE
struct sljit_const
* sljit_emit_const(struct sljit_compiler
*compiler
, sljit_s32 dst
, sljit_sw dstw
, sljit_sw initval
)
2676 SLJIT_UNUSED_ARG(compiler
);
2677 SLJIT_UNUSED_ARG(dst
);
2678 SLJIT_UNUSED_ARG(dstw
);
2679 SLJIT_UNUSED_ARG(initval
);
2680 SLJIT_UNREACHABLE();
2684 SLJIT_API_FUNC_ATTRIBUTE
struct sljit_put_label
* sljit_emit_put_label(struct sljit_compiler
*compiler
, sljit_s32 dst
, sljit_sw dstw
)
2686 SLJIT_UNUSED_ARG(compiler
);
2687 SLJIT_UNUSED_ARG(dst
);
2688 SLJIT_UNUSED_ARG(dstw
);
2692 SLJIT_API_FUNC_ATTRIBUTE
void sljit_set_jump_addr(sljit_uw addr
, sljit_uw new_target
, sljit_sw executable_offset
)
2694 SLJIT_UNUSED_ARG(addr
);
2695 SLJIT_UNUSED_ARG(new_target
);
2696 SLJIT_UNUSED_ARG(executable_offset
);
2697 SLJIT_UNREACHABLE();
2700 SLJIT_API_FUNC_ATTRIBUTE
void sljit_set_const(sljit_uw addr
, sljit_sw new_constant
, sljit_sw executable_offset
)
2702 SLJIT_UNUSED_ARG(addr
);
2703 SLJIT_UNUSED_ARG(new_constant
);
2704 SLJIT_UNUSED_ARG(executable_offset
);
2705 SLJIT_UNREACHABLE();
2708 #endif /* !SLJIT_CONFIG_UNSUPPORTED */