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 SSIZE_OF(type) ((sljit_s32)sizeof(sljit_ ## type))
95 #define VARIABLE_FLAG_SHIFT (10)
96 #define VARIABLE_FLAG_MASK (0x3f << VARIABLE_FLAG_SHIFT)
97 #define GET_FLAG_TYPE(op) ((op) >> VARIABLE_FLAG_SHIFT)
99 #define GET_OPCODE(op) \
100 ((op) & ~(SLJIT_32 | SLJIT_SET_Z | VARIABLE_FLAG_MASK))
102 #define HAS_FLAGS(op) \
103 ((op) & (SLJIT_SET_Z | VARIABLE_FLAG_MASK))
105 #define GET_ALL_FLAGS(op) \
106 ((op) & (SLJIT_32 | SLJIT_SET_Z | VARIABLE_FLAG_MASK))
108 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
109 #define TYPE_CAST_NEEDED(op) \
110 ((op) >= SLJIT_MOV_U8 && (op) <= SLJIT_MOV_S32)
111 #else /* !SLJIT_64BIT_ARCHITECTURE */
112 #define TYPE_CAST_NEEDED(op) \
113 ((op) >= SLJIT_MOV_U8 && (op) <= SLJIT_MOV_S16)
114 #endif /* SLJIT_64BIT_ARCHITECTURE */
116 #define BUF_SIZE 4096
118 #if (defined SLJIT_32BIT_ARCHITECTURE && SLJIT_32BIT_ARCHITECTURE)
119 #define ABUF_SIZE 2048
121 #define ABUF_SIZE 4096
124 /* Parameter parsing. */
125 #define REG_MASK 0x3f
126 #define OFFS_REG(reg) (((reg) >> 8) & REG_MASK)
127 #define OFFS_REG_MASK (REG_MASK << 8)
128 #define TO_OFFS_REG(reg) ((reg) << 8)
129 /* When reg cannot be unused. */
130 #define FAST_IS_REG(reg) ((reg) <= REG_MASK)
132 /* Mask for argument types. */
133 #define SLJIT_ARG_MASK 0x7
134 #define SLJIT_ARG_FULL_MASK (SLJIT_ARG_MASK | SLJIT_ARG_TYPE_SCRATCH_REG)
137 #define JUMP_LABEL 0x1
138 #define JUMP_ADDR 0x2
139 /* SLJIT_REWRITABLE_JUMP is 0x1000. */
141 #if (defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86)
142 # define PATCH_MB 0x4
143 # define PATCH_MW 0x8
144 #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
145 # define PATCH_MD 0x10
147 # define TYPE_SHIFT 13
150 #if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) || (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7)
155 #if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5)
156 # define CPOOL_SIZE 512
159 #if (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
160 # define IS_COND 0x04
162 /* conditional + imm8 */
163 # define PATCH_TYPE1 0x10
164 /* conditional + imm20 */
165 # define PATCH_TYPE2 0x20
167 # define PATCH_TYPE3 0x30
169 # define PATCH_TYPE4 0x40
171 # define PATCH_TYPE5 0x50
173 # define PATCH_BL 0x60
174 /* 0xf00 cc code for branches */
177 #if (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64)
178 # define IS_COND 0x004
179 # define IS_CBZ 0x008
181 # define PATCH_B 0x020
182 # define PATCH_COND 0x040
183 # define PATCH_ABS48 0x080
184 # define PATCH_ABS64 0x100
187 #if (defined SLJIT_CONFIG_PPC && SLJIT_CONFIG_PPC)
188 # define IS_COND 0x004
189 # define IS_CALL 0x008
190 # define PATCH_B 0x010
191 # define PATCH_ABS_B 0x020
192 #if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
193 # define PATCH_ABS32 0x040
194 # define PATCH_ABS48 0x080
196 # define REMOVE_COND 0x100
199 #if (defined SLJIT_CONFIG_MIPS && SLJIT_CONFIG_MIPS)
200 # define IS_MOVABLE 0x004
201 # define IS_JAL 0x008
202 # define IS_CALL 0x010
203 # define IS_BIT26_COND 0x020
204 # define IS_BIT16_COND 0x040
205 # define IS_BIT23_COND 0x080
207 # define IS_COND (IS_BIT26_COND | IS_BIT16_COND | IS_BIT23_COND)
209 # define PATCH_B 0x100
210 # define PATCH_J 0x200
212 #if (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64)
213 # define PATCH_ABS32 0x400
214 # define PATCH_ABS48 0x800
217 /* instruction types */
218 # define MOVABLE_INS 0
219 /* 1 - 31 last destination register */
220 /* no destination (i.e: store) */
221 # define UNMOVABLE_INS 32
222 /* FPU status register */
226 #if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
227 # define IS_MOVABLE 0x04
228 # define IS_COND 0x08
229 # define IS_CALL 0x10
231 # define PATCH_B 0x20
232 # define PATCH_CALL 0x40
234 /* instruction types */
235 # define MOVABLE_INS 0
236 /* 1 - 31 last destination register */
237 /* no destination (i.e: store) */
238 # define UNMOVABLE_INS 32
240 # define DST_INS_MASK 0xff
242 /* ICC_SET is the same as SET_FLAGS. */
243 # define ICC_IS_SET (1 << 23)
244 # define FCC_IS_SET (1 << 24)
247 /* Stack management. */
249 #define GET_SAVED_REGISTERS_SIZE(scratches, saveds, extra) \
250 (((scratches < SLJIT_NUMBER_OF_SCRATCH_REGISTERS ? 0 : (scratches - SLJIT_NUMBER_OF_SCRATCH_REGISTERS)) + \
251 (saveds) + (sljit_s32)(extra)) * (sljit_s32)sizeof(sljit_sw))
253 #define GET_SAVED_FLOAT_REGISTERS_SIZE(fscratches, fsaveds, size) \
254 (((fscratches < SLJIT_NUMBER_OF_SCRATCH_FLOAT_REGISTERS ? 0 : (fscratches - SLJIT_NUMBER_OF_SCRATCH_FLOAT_REGISTERS)) + \
255 (fsaveds)) * (sljit_s32)(size))
257 #define ADJUST_LOCAL_OFFSET(p, i) \
258 if ((p) == (SLJIT_MEM1(SLJIT_SP))) \
259 (i) += SLJIT_LOCALS_OFFSET;
261 #endif /* !(defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED) */
263 /* Utils can still be used even if SLJIT_CONFIG_UNSUPPORTED is set. */
264 #include "sljitUtils.c"
266 #if !(defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
268 #if (defined SLJIT_EXECUTABLE_ALLOCATOR && SLJIT_EXECUTABLE_ALLOCATOR)
270 #if (defined SLJIT_PROT_EXECUTABLE_ALLOCATOR && SLJIT_PROT_EXECUTABLE_ALLOCATOR)
271 #include "sljitProtExecAllocator.c"
272 #elif (defined SLJIT_WX_EXECUTABLE_ALLOCATOR && SLJIT_WX_EXECUTABLE_ALLOCATOR)
273 #include "sljitWXExecAllocator.c"
275 #include "sljitExecAllocator.c"
280 #if (defined SLJIT_PROT_EXECUTABLE_ALLOCATOR && SLJIT_PROT_EXECUTABLE_ALLOCATOR)
281 #define SLJIT_ADD_EXEC_OFFSET(ptr, exec_offset) ((sljit_u8 *)(ptr) + (exec_offset))
283 #define SLJIT_ADD_EXEC_OFFSET(ptr, exec_offset) ((sljit_u8 *)(ptr))
286 #ifndef SLJIT_UPDATE_WX_FLAGS
287 #define SLJIT_UPDATE_WX_FLAGS(from, to, enable_exec)
290 /* Argument checking features. */
292 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
294 /* Returns with error when an invalid argument is passed. */
296 #define CHECK_ARGUMENT(x) \
298 if (SLJIT_UNLIKELY(!(x))) \
302 #define CHECK_RETURN_TYPE sljit_s32
303 #define CHECK_RETURN_OK return 0
307 if (SLJIT_UNLIKELY(x)) { \
308 compiler->error = SLJIT_ERR_BAD_ARGUMENT; \
309 return SLJIT_ERR_BAD_ARGUMENT; \
313 #define CHECK_PTR(x) \
315 if (SLJIT_UNLIKELY(x)) { \
316 compiler->error = SLJIT_ERR_BAD_ARGUMENT; \
321 #define CHECK_REG_INDEX(x) \
323 if (SLJIT_UNLIKELY(x)) { \
328 #elif (defined SLJIT_DEBUG && SLJIT_DEBUG)
330 /* Assertion failure occures if an invalid argument is passed. */
331 #undef SLJIT_ARGUMENT_CHECKS
332 #define SLJIT_ARGUMENT_CHECKS 1
334 #define CHECK_ARGUMENT(x) SLJIT_ASSERT(x)
335 #define CHECK_RETURN_TYPE void
336 #define CHECK_RETURN_OK return
338 #define CHECK_PTR(x) x
339 #define CHECK_REG_INDEX(x) x
341 #elif (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
343 /* Arguments are not checked. */
344 #define CHECK_RETURN_TYPE void
345 #define CHECK_RETURN_OK return
347 #define CHECK_PTR(x) x
348 #define CHECK_REG_INDEX(x) x
352 /* Arguments are not checked. */
355 #define CHECK_REG_INDEX(x)
357 #endif /* SLJIT_ARGUMENT_CHECKS */
359 /* --------------------------------------------------------------------- */
360 /* Public functions */
361 /* --------------------------------------------------------------------- */
363 #if (defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86)
364 #define SLJIT_NEEDS_COMPILER_INIT 1
365 static sljit_s32 compiler_initialized
= 0;
366 /* A thread safe initialization. */
367 static void init_compiler(void);
370 SLJIT_API_FUNC_ATTRIBUTE
struct sljit_compiler
* sljit_create_compiler(void *allocator_data
, void *exec_allocator_data
)
372 struct sljit_compiler
*compiler
= (struct sljit_compiler
*)SLJIT_MALLOC(sizeof(struct sljit_compiler
), allocator_data
);
375 SLJIT_ZEROMEM(compiler
, sizeof(struct sljit_compiler
));
377 SLJIT_COMPILE_ASSERT(
378 sizeof(sljit_s8
) == 1 && sizeof(sljit_u8
) == 1
379 && sizeof(sljit_s16
) == 2 && sizeof(sljit_u16
) == 2
380 && sizeof(sljit_s32
) == 4 && sizeof(sljit_u32
) == 4
381 && (sizeof(sljit_p
) == 4 || sizeof(sljit_p
) == 8)
382 && sizeof(sljit_p
) <= sizeof(sljit_sw
)
383 && (sizeof(sljit_sw
) == 4 || sizeof(sljit_sw
) == 8)
384 && (sizeof(sljit_uw
) == 4 || sizeof(sljit_uw
) == 8),
385 invalid_integer_types
);
386 SLJIT_COMPILE_ASSERT(SLJIT_REWRITABLE_JUMP
!= SLJIT_32
,
387 rewritable_jump_and_single_op_must_not_be_the_same
);
388 SLJIT_COMPILE_ASSERT(!(SLJIT_EQUAL
& 0x1) && !(SLJIT_LESS
& 0x1) && !(SLJIT_F_EQUAL
& 0x1) && !(SLJIT_JUMP
& 0x1),
389 conditional_flags_must_be_even_numbers
);
391 /* Only the non-zero members must be set. */
392 compiler
->error
= SLJIT_SUCCESS
;
394 compiler
->allocator_data
= allocator_data
;
395 compiler
->exec_allocator_data
= exec_allocator_data
;
396 compiler
->buf
= (struct sljit_memory_fragment
*)SLJIT_MALLOC(BUF_SIZE
, allocator_data
);
397 compiler
->abuf
= (struct sljit_memory_fragment
*)SLJIT_MALLOC(ABUF_SIZE
, allocator_data
);
399 if (!compiler
->buf
|| !compiler
->abuf
) {
401 SLJIT_FREE(compiler
->buf
, allocator_data
);
403 SLJIT_FREE(compiler
->abuf
, allocator_data
);
404 SLJIT_FREE(compiler
, allocator_data
);
408 compiler
->buf
->next
= NULL
;
409 compiler
->buf
->used_size
= 0;
410 compiler
->abuf
->next
= NULL
;
411 compiler
->abuf
->used_size
= 0;
413 compiler
->scratches
= -1;
414 compiler
->saveds
= -1;
415 compiler
->fscratches
= -1;
416 compiler
->fsaveds
= -1;
417 compiler
->local_size
= -1;
419 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
420 compiler
->args_size
= -1;
423 #if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5)
424 compiler
->cpool
= (sljit_uw
*)SLJIT_MALLOC(CPOOL_SIZE
* sizeof(sljit_uw
)
425 + CPOOL_SIZE
* sizeof(sljit_u8
), allocator_data
);
426 if (!compiler
->cpool
) {
427 SLJIT_FREE(compiler
->buf
, allocator_data
);
428 SLJIT_FREE(compiler
->abuf
, allocator_data
);
429 SLJIT_FREE(compiler
, allocator_data
);
432 compiler
->cpool_unique
= (sljit_u8
*)(compiler
->cpool
+ CPOOL_SIZE
);
433 compiler
->cpool_diff
= 0xffffffff;
436 #if (defined SLJIT_CONFIG_MIPS && SLJIT_CONFIG_MIPS)
437 compiler
->delay_slot
= UNMOVABLE_INS
;
440 #if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
441 compiler
->delay_slot
= UNMOVABLE_INS
;
444 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS) \
445 || (defined SLJIT_DEBUG && SLJIT_DEBUG)
446 compiler
->last_flags
= 0;
447 compiler
->last_return
= -1;
448 compiler
->logical_local_size
= 0;
451 #if (defined SLJIT_NEEDS_COMPILER_INIT && SLJIT_NEEDS_COMPILER_INIT)
452 if (!compiler_initialized
) {
454 compiler_initialized
= 1;
461 SLJIT_API_FUNC_ATTRIBUTE
void sljit_free_compiler(struct sljit_compiler
*compiler
)
463 struct sljit_memory_fragment
*buf
;
464 struct sljit_memory_fragment
*curr
;
465 void *allocator_data
= compiler
->allocator_data
;
466 SLJIT_UNUSED_ARG(allocator_data
);
472 SLJIT_FREE(curr
, allocator_data
);
475 buf
= compiler
->abuf
;
479 SLJIT_FREE(curr
, allocator_data
);
482 #if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5)
483 SLJIT_FREE(compiler
->cpool
, allocator_data
);
485 SLJIT_FREE(compiler
, allocator_data
);
488 SLJIT_API_FUNC_ATTRIBUTE
void sljit_set_compiler_memory_error(struct sljit_compiler
*compiler
)
490 if (compiler
->error
== SLJIT_SUCCESS
)
491 compiler
->error
= SLJIT_ERR_ALLOC_FAILED
;
494 #if (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
495 SLJIT_API_FUNC_ATTRIBUTE
void sljit_free_code(void* code
, void *exec_allocator_data
)
497 SLJIT_UNUSED_ARG(exec_allocator_data
);
499 /* Remove thumb mode flag. */
500 SLJIT_FREE_EXEC((void*)((sljit_uw
)code
& ~(sljit_uw
)0x1), exec_allocator_data
);
502 #elif (defined SLJIT_INDIRECT_CALL && SLJIT_INDIRECT_CALL)
503 SLJIT_API_FUNC_ATTRIBUTE
void sljit_free_code(void* code
, void *exec_allocator_data
)
505 SLJIT_UNUSED_ARG(exec_allocator_data
);
507 /* Resolve indirection. */
508 code
= (void*)(*(sljit_uw
*)code
);
509 SLJIT_FREE_EXEC(code
, exec_allocator_data
);
512 SLJIT_API_FUNC_ATTRIBUTE
void sljit_free_code(void* code
, void *exec_allocator_data
)
514 SLJIT_UNUSED_ARG(exec_allocator_data
);
516 SLJIT_FREE_EXEC(code
, exec_allocator_data
);
520 SLJIT_API_FUNC_ATTRIBUTE
void sljit_set_label(struct sljit_jump
*jump
, struct sljit_label
* label
)
522 if (SLJIT_LIKELY(!!jump
) && SLJIT_LIKELY(!!label
)) {
523 jump
->flags
&= (sljit_uw
)~JUMP_ADDR
;
524 jump
->flags
|= JUMP_LABEL
;
525 jump
->u
.label
= label
;
529 SLJIT_API_FUNC_ATTRIBUTE
void sljit_set_target(struct sljit_jump
*jump
, sljit_uw target
)
531 if (SLJIT_LIKELY(!!jump
)) {
532 jump
->flags
&= (sljit_uw
)~JUMP_LABEL
;
533 jump
->flags
|= JUMP_ADDR
;
534 jump
->u
.target
= target
;
538 SLJIT_API_FUNC_ATTRIBUTE
void sljit_set_put_label(struct sljit_put_label
*put_label
, struct sljit_label
*label
)
540 if (SLJIT_LIKELY(!!put_label
))
541 put_label
->label
= label
;
544 #define SLJIT_CURRENT_FLAGS_ALL \
545 (SLJIT_CURRENT_FLAGS_32 | SLJIT_CURRENT_FLAGS_ADD | SLJIT_CURRENT_FLAGS_SUB | SLJIT_CURRENT_FLAGS_COMPARE)
547 SLJIT_API_FUNC_ATTRIBUTE
void sljit_set_current_flags(struct sljit_compiler
*compiler
, sljit_s32 current_flags
)
549 SLJIT_UNUSED_ARG(compiler
);
550 SLJIT_UNUSED_ARG(current_flags
);
552 #if (defined SLJIT_HAS_STATUS_FLAGS_STATE && SLJIT_HAS_STATUS_FLAGS_STATE)
553 compiler
->status_flags_state
= current_flags
;
556 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
557 compiler
->last_flags
= 0;
558 if ((current_flags
& ~(VARIABLE_FLAG_MASK
| SLJIT_SET_Z
| SLJIT_CURRENT_FLAGS_ALL
)) == 0) {
559 compiler
->last_flags
= GET_FLAG_TYPE(current_flags
) | (current_flags
& (SLJIT_32
| SLJIT_SET_Z
));
564 /* --------------------------------------------------------------------- */
565 /* Private functions */
566 /* --------------------------------------------------------------------- */
568 static void* ensure_buf(struct sljit_compiler
*compiler
, sljit_uw size
)
571 struct sljit_memory_fragment
*new_frag
;
573 SLJIT_ASSERT(size
<= 256);
574 if (compiler
->buf
->used_size
+ size
<= (BUF_SIZE
- (sljit_uw
)SLJIT_OFFSETOF(struct sljit_memory_fragment
, memory
))) {
575 ret
= compiler
->buf
->memory
+ compiler
->buf
->used_size
;
576 compiler
->buf
->used_size
+= size
;
579 new_frag
= (struct sljit_memory_fragment
*)SLJIT_MALLOC(BUF_SIZE
, compiler
->allocator_data
);
580 PTR_FAIL_IF_NULL(new_frag
);
581 new_frag
->next
= compiler
->buf
;
582 compiler
->buf
= new_frag
;
583 new_frag
->used_size
= size
;
584 return new_frag
->memory
;
587 static void* ensure_abuf(struct sljit_compiler
*compiler
, sljit_uw size
)
590 struct sljit_memory_fragment
*new_frag
;
592 SLJIT_ASSERT(size
<= 256);
593 if (compiler
->abuf
->used_size
+ size
<= (ABUF_SIZE
- (sljit_uw
)SLJIT_OFFSETOF(struct sljit_memory_fragment
, memory
))) {
594 ret
= compiler
->abuf
->memory
+ compiler
->abuf
->used_size
;
595 compiler
->abuf
->used_size
+= size
;
598 new_frag
= (struct sljit_memory_fragment
*)SLJIT_MALLOC(ABUF_SIZE
, compiler
->allocator_data
);
599 PTR_FAIL_IF_NULL(new_frag
);
600 new_frag
->next
= compiler
->abuf
;
601 compiler
->abuf
= new_frag
;
602 new_frag
->used_size
= size
;
603 return new_frag
->memory
;
606 SLJIT_API_FUNC_ATTRIBUTE
void* sljit_alloc_memory(struct sljit_compiler
*compiler
, sljit_s32 size
)
610 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
611 if (size
<= 0 || size
> 128)
613 size
= (size
+ 7) & ~7;
615 if (size
<= 0 || size
> 64)
617 size
= (size
+ 3) & ~3;
619 return ensure_abuf(compiler
, (sljit_uw
)size
);
622 static SLJIT_INLINE
void reverse_buf(struct sljit_compiler
*compiler
)
624 struct sljit_memory_fragment
*buf
= compiler
->buf
;
625 struct sljit_memory_fragment
*prev
= NULL
;
626 struct sljit_memory_fragment
*tmp
;
633 } while (buf
!= NULL
);
635 compiler
->buf
= prev
;
638 /* Only used in RISC architectures where the instruction size is constant */
639 #if !(defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86) \
640 && !(defined SLJIT_CONFIG_S390X && SLJIT_CONFIG_S390X)
642 static SLJIT_INLINE sljit_uw
compute_next_addr(struct sljit_label
*label
, struct sljit_jump
*jump
,
643 struct sljit_const
*const_
, struct sljit_put_label
*put_label
)
645 sljit_uw result
= ~(sljit_uw
)0;
648 result
= label
->size
;
650 if (jump
&& jump
->addr
< result
)
653 if (const_
&& const_
->addr
< result
)
654 result
= const_
->addr
;
656 if (put_label
&& put_label
->addr
< result
)
657 result
= put_label
->addr
;
662 #endif /* !SLJIT_CONFIG_X86 && !SLJIT_CONFIG_S390X */
664 static SLJIT_INLINE
void set_emit_enter(struct sljit_compiler
*compiler
,
665 sljit_s32 options
, sljit_s32 args
, sljit_s32 scratches
, sljit_s32 saveds
,
666 sljit_s32 fscratches
, sljit_s32 fsaveds
, sljit_s32 local_size
)
668 SLJIT_UNUSED_ARG(args
);
669 SLJIT_UNUSED_ARG(local_size
);
671 compiler
->options
= options
;
672 compiler
->scratches
= scratches
;
673 compiler
->saveds
= saveds
;
674 compiler
->fscratches
= fscratches
;
675 compiler
->fsaveds
= fsaveds
;
676 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
677 compiler
->last_return
= args
& SLJIT_ARG_MASK
;
678 compiler
->logical_local_size
= local_size
;
682 static SLJIT_INLINE
void set_set_context(struct sljit_compiler
*compiler
,
683 sljit_s32 options
, sljit_s32 args
, sljit_s32 scratches
, sljit_s32 saveds
,
684 sljit_s32 fscratches
, sljit_s32 fsaveds
, sljit_s32 local_size
)
686 SLJIT_UNUSED_ARG(args
);
687 SLJIT_UNUSED_ARG(local_size
);
689 compiler
->options
= options
;
690 compiler
->scratches
= scratches
;
691 compiler
->saveds
= saveds
;
692 compiler
->fscratches
= fscratches
;
693 compiler
->fsaveds
= fsaveds
;
694 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
695 compiler
->last_return
= args
& SLJIT_ARG_MASK
;
696 compiler
->logical_local_size
= local_size
;
700 static SLJIT_INLINE
void set_label(struct sljit_label
*label
, struct sljit_compiler
*compiler
)
703 label
->size
= compiler
->size
;
704 if (compiler
->last_label
)
705 compiler
->last_label
->next
= label
;
707 compiler
->labels
= label
;
708 compiler
->last_label
= label
;
711 static SLJIT_INLINE
void set_jump(struct sljit_jump
*jump
, struct sljit_compiler
*compiler
, sljit_u32 flags
)
715 if (compiler
->last_jump
)
716 compiler
->last_jump
->next
= jump
;
718 compiler
->jumps
= jump
;
719 compiler
->last_jump
= jump
;
722 static SLJIT_INLINE
void set_const(struct sljit_const
*const_
, struct sljit_compiler
*compiler
)
725 const_
->addr
= compiler
->size
;
726 if (compiler
->last_const
)
727 compiler
->last_const
->next
= const_
;
729 compiler
->consts
= const_
;
730 compiler
->last_const
= const_
;
733 static SLJIT_INLINE
void set_put_label(struct sljit_put_label
*put_label
, struct sljit_compiler
*compiler
, sljit_uw offset
)
735 put_label
->next
= NULL
;
736 put_label
->label
= NULL
;
737 put_label
->addr
= compiler
->size
- offset
;
738 put_label
->flags
= 0;
739 if (compiler
->last_put_label
)
740 compiler
->last_put_label
->next
= put_label
;
742 compiler
->put_labels
= put_label
;
743 compiler
->last_put_label
= put_label
;
746 #define ADDRESSING_DEPENDS_ON(exp, reg) \
747 (((exp) & SLJIT_MEM) && (((exp) & REG_MASK) == reg || OFFS_REG(exp) == reg))
749 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
751 static sljit_s32
function_check_arguments(sljit_s32 arg_types
, sljit_s32 scratches
, sljit_s32 saveds
, sljit_s32 fscratches
)
753 sljit_s32 word_arg_count
, scratch_arg_end
, saved_arg_count
, float_arg_count
, curr_type
;
755 curr_type
= (arg_types
& SLJIT_ARG_FULL_MASK
);
757 if (curr_type
>= SLJIT_ARG_TYPE_F64
) {
758 if (curr_type
> SLJIT_ARG_TYPE_F32
|| fscratches
== 0)
760 } else if (curr_type
>= SLJIT_ARG_TYPE_W
) {
765 arg_types
>>= SLJIT_ARG_SHIFT
;
771 while (arg_types
!= 0) {
772 if (word_arg_count
+ float_arg_count
>= 4)
775 curr_type
= (arg_types
& SLJIT_ARG_MASK
);
777 if (arg_types
& SLJIT_ARG_TYPE_SCRATCH_REG
) {
778 if (saveds
== -1 || curr_type
< SLJIT_ARG_TYPE_W
|| curr_type
> SLJIT_ARG_TYPE_P
)
782 scratch_arg_end
= word_arg_count
;
784 if (curr_type
< SLJIT_ARG_TYPE_W
|| curr_type
> SLJIT_ARG_TYPE_F32
)
787 if (curr_type
< SLJIT_ARG_TYPE_F64
) {
794 arg_types
>>= SLJIT_ARG_SHIFT
;
798 return (word_arg_count
<= scratches
&& float_arg_count
<= fscratches
);
800 return (saved_arg_count
<= saveds
&& scratch_arg_end
<= scratches
&& float_arg_count
<= fscratches
);
803 #define FUNCTION_CHECK_IS_REG(r) \
804 (((r) >= SLJIT_R0 && (r) < (SLJIT_R0 + compiler->scratches)) \
805 || ((r) > (SLJIT_S0 - compiler->saveds) && (r) <= SLJIT_S0))
807 #define FUNCTION_CHECK_IS_FREG(fr) \
808 (((fr) >= SLJIT_FR0 && (fr) < (SLJIT_FR0 + compiler->fscratches)) \
809 || ((fr) > (SLJIT_FS0 - compiler->fsaveds) && (fr) <= SLJIT_FS0))
811 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
812 #define CHECK_IF_VIRTUAL_REGISTER(p) ((p) <= SLJIT_S3 && (p) >= SLJIT_S8)
814 #define CHECK_IF_VIRTUAL_REGISTER(p) 0
817 static sljit_s32
function_check_src_mem(struct sljit_compiler
*compiler
, sljit_s32 p
, sljit_sw i
)
819 if (compiler
->scratches
== -1 || compiler
->saveds
== -1)
822 if (!(p
& SLJIT_MEM
))
825 if (!(!(p
& REG_MASK
) || FUNCTION_CHECK_IS_REG(p
& REG_MASK
)))
828 if (CHECK_IF_VIRTUAL_REGISTER(p
& REG_MASK
))
831 if (p
& OFFS_REG_MASK
) {
835 if (!(FUNCTION_CHECK_IS_REG(OFFS_REG(p
))))
838 if (CHECK_IF_VIRTUAL_REGISTER(OFFS_REG(p
)))
845 return (p
& ~(SLJIT_MEM
| REG_MASK
| OFFS_REG_MASK
)) == 0;
848 #define FUNCTION_CHECK_SRC_MEM(p, i) \
849 CHECK_ARGUMENT(function_check_src_mem(compiler, p, i));
851 static sljit_s32
function_check_src(struct sljit_compiler
*compiler
, sljit_s32 p
, sljit_sw i
)
853 if (compiler
->scratches
== -1 || compiler
->saveds
== -1)
856 if (FUNCTION_CHECK_IS_REG(p
))
862 if (p
== SLJIT_MEM1(SLJIT_SP
))
863 return (i
>= 0 && i
< compiler
->logical_local_size
);
865 return function_check_src_mem(compiler
, p
, i
);
868 #define FUNCTION_CHECK_SRC(p, i) \
869 CHECK_ARGUMENT(function_check_src(compiler, p, i));
871 static sljit_s32
function_check_dst(struct sljit_compiler
*compiler
, sljit_s32 p
, sljit_sw i
)
873 if (compiler
->scratches
== -1 || compiler
->saveds
== -1)
876 if (FUNCTION_CHECK_IS_REG(p
))
879 if (p
== SLJIT_MEM1(SLJIT_SP
))
880 return (i
>= 0 && i
< compiler
->logical_local_size
);
882 return function_check_src_mem(compiler
, p
, i
);
885 #define FUNCTION_CHECK_DST(p, i) \
886 CHECK_ARGUMENT(function_check_dst(compiler, p, i));
888 static sljit_s32
function_fcheck(struct sljit_compiler
*compiler
, sljit_s32 p
, sljit_sw i
)
890 if (compiler
->scratches
== -1 || compiler
->saveds
== -1)
893 if (FUNCTION_CHECK_IS_FREG(p
))
896 if (p
== SLJIT_MEM1(SLJIT_SP
))
897 return (i
>= 0 && i
< compiler
->logical_local_size
);
899 return function_check_src_mem(compiler
, p
, i
);
902 #define FUNCTION_FCHECK(p, i) \
903 CHECK_ARGUMENT(function_fcheck(compiler, p, i));
905 #endif /* SLJIT_ARGUMENT_CHECKS */
907 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
909 SLJIT_API_FUNC_ATTRIBUTE
void sljit_compiler_verbose(struct sljit_compiler
*compiler
, FILE* verbose
)
911 compiler
->verbose
= verbose
;
914 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
917 # define SLJIT_PRINT_D "ll"
919 # define SLJIT_PRINT_D "I64"
922 # define SLJIT_PRINT_D "l"
925 # define SLJIT_PRINT_D ""
928 static void sljit_verbose_reg(struct sljit_compiler
*compiler
, sljit_s32 r
)
930 if (r
< (SLJIT_R0
+ compiler
->scratches
))
931 fprintf(compiler
->verbose
, "r%d", r
- SLJIT_R0
);
932 else if (r
!= SLJIT_SP
)
933 fprintf(compiler
->verbose
, "s%d", SLJIT_NUMBER_OF_REGISTERS
- r
);
935 fprintf(compiler
->verbose
, "sp");
938 static void sljit_verbose_freg(struct sljit_compiler
*compiler
, sljit_s32 r
)
940 if (r
< (SLJIT_FR0
+ compiler
->fscratches
))
941 fprintf(compiler
->verbose
, "fr%d", r
- SLJIT_FR0
);
943 fprintf(compiler
->verbose
, "fs%d", SLJIT_NUMBER_OF_FLOAT_REGISTERS
- r
);
946 static void sljit_verbose_param(struct sljit_compiler
*compiler
, sljit_s32 p
, sljit_sw i
)
949 fprintf(compiler
->verbose
, "#%" SLJIT_PRINT_D
"d", (i
));
950 else if ((p
) & SLJIT_MEM
) {
951 if ((p
) & REG_MASK
) {
952 fputc('[', compiler
->verbose
);
953 sljit_verbose_reg(compiler
, (p
) & REG_MASK
);
954 if ((p
) & OFFS_REG_MASK
) {
955 fprintf(compiler
->verbose
, " + ");
956 sljit_verbose_reg(compiler
, OFFS_REG(p
));
958 fprintf(compiler
->verbose
, " * %d", 1 << (i
));
961 fprintf(compiler
->verbose
, " + %" SLJIT_PRINT_D
"d", (i
));
962 fputc(']', compiler
->verbose
);
965 fprintf(compiler
->verbose
, "[#%" SLJIT_PRINT_D
"d]", (i
));
967 sljit_verbose_reg(compiler
, p
);
970 static void sljit_verbose_fparam(struct sljit_compiler
*compiler
, sljit_s32 p
, sljit_sw i
)
972 if ((p
) & SLJIT_MEM
) {
973 if ((p
) & REG_MASK
) {
974 fputc('[', compiler
->verbose
);
975 sljit_verbose_reg(compiler
, (p
) & REG_MASK
);
976 if ((p
) & OFFS_REG_MASK
) {
977 fprintf(compiler
->verbose
, " + ");
978 sljit_verbose_reg(compiler
, OFFS_REG(p
));
980 fprintf(compiler
->verbose
, "%d", 1 << (i
));
983 fprintf(compiler
->verbose
, " + %" SLJIT_PRINT_D
"d", (i
));
984 fputc(']', compiler
->verbose
);
987 fprintf(compiler
->verbose
, "[#%" SLJIT_PRINT_D
"d]", (i
));
990 sljit_verbose_freg(compiler
, p
);
993 static const char* op0_names
[] = {
994 "breakpoint", "nop", "lmul.uw", "lmul.sw",
995 "divmod.u", "divmod.s", "div.u", "div.s",
996 "endbr", "skip_frames_before_return"
999 static const char* op1_names
[] = {
1000 "", ".u8", ".s8", ".u16",
1001 ".s16", ".u32", ".s32", "32",
1005 static const char* op2_names
[] = {
1006 "add", "addc", "sub", "subc",
1007 "mul", "and", "or", "xor",
1008 "shl", "lshr", "ashr",
1011 static const char* op_src_names
[] = {
1012 "fast_return", "skip_frames_before_fast_return",
1013 "prefetch_l1", "prefetch_l2",
1014 "prefetch_l3", "prefetch_once",
1017 static const char* fop1_names
[] = {
1018 "mov", "conv", "conv", "conv",
1019 "conv", "conv", "cmp", "neg",
1023 static const char* fop2_names
[] = {
1024 "add", "sub", "mul", "div"
1027 static const char* jump_names
[] = {
1028 "equal", "not_equal",
1029 "less", "greater_equal",
1030 "greater", "less_equal",
1031 "sig_less", "sig_greater_equal",
1032 "sig_greater", "sig_less_equal",
1033 "overflow", "not_overflow",
1035 "f_equal", "f_not_equal",
1036 "f_less", "f_greater_equal",
1037 "f_greater", "f_less_equal",
1038 "unordered", "ordered",
1039 "ordered_equal", "unordered_or_not_equal",
1040 "ordered_less", "unordered_or_greater_equal",
1041 "ordered_greater", "unordered_or_less_equal",
1042 "unordered_or_equal", "ordered_not_equal",
1043 "unordered_or_less", "ordered_greater_equal",
1044 "unordered_or_greater", "ordered_less_equal",
1045 "jump", "fast_call",
1046 "call", "call.cdecl"
1049 static const char* call_arg_names
[] = {
1050 "void", "w", "32", "p", "f64", "f32"
1053 #endif /* SLJIT_VERBOSE */
1055 /* --------------------------------------------------------------------- */
1056 /* Arch dependent */
1057 /* --------------------------------------------------------------------- */
1059 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS) \
1060 || (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1062 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_generate_code(struct sljit_compiler
*compiler
)
1064 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1065 struct sljit_jump
*jump
;
1068 SLJIT_UNUSED_ARG(compiler
);
1070 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1071 CHECK_ARGUMENT(compiler
->size
> 0);
1072 jump
= compiler
->jumps
;
1074 /* All jumps have target. */
1075 CHECK_ARGUMENT(jump
->flags
& (JUMP_LABEL
| JUMP_ADDR
));
1082 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_enter(struct sljit_compiler
*compiler
,
1083 sljit_s32 options
, sljit_s32 arg_types
, sljit_s32 scratches
, sljit_s32 saveds
,
1084 sljit_s32 fscratches
, sljit_s32 fsaveds
, sljit_s32 local_size
)
1086 SLJIT_UNUSED_ARG(compiler
);
1088 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1089 CHECK_ARGUMENT(!(options
& ~SLJIT_ENTER_CDECL
));
1090 CHECK_ARGUMENT(scratches
>= 0 && scratches
<= SLJIT_NUMBER_OF_REGISTERS
);
1091 CHECK_ARGUMENT(saveds
>= 0 && saveds
<= SLJIT_NUMBER_OF_SAVED_REGISTERS
);
1092 CHECK_ARGUMENT(scratches
+ saveds
<= SLJIT_NUMBER_OF_REGISTERS
);
1093 CHECK_ARGUMENT(fscratches
>= 0 && fscratches
<= SLJIT_NUMBER_OF_FLOAT_REGISTERS
);
1094 CHECK_ARGUMENT(fsaveds
>= 0 && fsaveds
<= SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS
);
1095 CHECK_ARGUMENT(fscratches
+ fsaveds
<= SLJIT_NUMBER_OF_FLOAT_REGISTERS
);
1096 CHECK_ARGUMENT(local_size
>= 0 && local_size
<= SLJIT_MAX_LOCAL_SIZE
);
1097 CHECK_ARGUMENT((arg_types
& SLJIT_ARG_FULL_MASK
) < SLJIT_ARG_TYPE_F64
);
1098 CHECK_ARGUMENT(function_check_arguments(arg_types
, scratches
, saveds
, fscratches
));
1100 compiler
->last_flags
= 0;
1102 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1103 if (SLJIT_UNLIKELY(!!compiler
->verbose
)) {
1104 fprintf(compiler
->verbose
, " enter ret[%s", call_arg_names
[arg_types
& SLJIT_ARG_MASK
]);
1106 arg_types
>>= SLJIT_ARG_SHIFT
;
1108 fprintf(compiler
->verbose
, "], args[");
1110 fprintf(compiler
->verbose
, "%s%s", call_arg_names
[arg_types
& SLJIT_ARG_MASK
],
1111 (arg_types
& SLJIT_ARG_TYPE_SCRATCH_REG
) ? "_r" : "");
1112 arg_types
>>= SLJIT_ARG_SHIFT
;
1114 fprintf(compiler
->verbose
, ",");
1115 } while (arg_types
);
1118 fprintf(compiler
->verbose
, "],%s scratches:%d, saveds:%d, fscratches:%d, fsaveds:%d, local_size:%d\n",
1119 (options
& SLJIT_ENTER_CDECL
) ? " enter:cdecl," : "",
1120 scratches
, saveds
, fscratches
, fsaveds
, local_size
);
1126 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_set_context(struct sljit_compiler
*compiler
,
1127 sljit_s32 options
, sljit_s32 arg_types
, sljit_s32 scratches
, sljit_s32 saveds
,
1128 sljit_s32 fscratches
, sljit_s32 fsaveds
, sljit_s32 local_size
)
1130 SLJIT_UNUSED_ARG(compiler
);
1132 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1133 CHECK_ARGUMENT(!(options
& ~SLJIT_ENTER_CDECL
));
1134 CHECK_ARGUMENT(scratches
>= 0 && scratches
<= SLJIT_NUMBER_OF_REGISTERS
);
1135 CHECK_ARGUMENT(saveds
>= 0 && saveds
<= SLJIT_NUMBER_OF_SAVED_REGISTERS
);
1136 CHECK_ARGUMENT(scratches
+ saveds
<= SLJIT_NUMBER_OF_REGISTERS
);
1137 CHECK_ARGUMENT(fscratches
>= 0 && fscratches
<= SLJIT_NUMBER_OF_FLOAT_REGISTERS
);
1138 CHECK_ARGUMENT(fsaveds
>= 0 && fsaveds
<= SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS
);
1139 CHECK_ARGUMENT(fscratches
+ fsaveds
<= SLJIT_NUMBER_OF_FLOAT_REGISTERS
);
1140 CHECK_ARGUMENT(local_size
>= 0 && local_size
<= SLJIT_MAX_LOCAL_SIZE
);
1141 CHECK_ARGUMENT((arg_types
& SLJIT_ARG_FULL_MASK
) < SLJIT_ARG_TYPE_F64
);
1142 CHECK_ARGUMENT(function_check_arguments(arg_types
, scratches
, saveds
, fscratches
));
1144 compiler
->last_flags
= 0;
1146 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1147 if (SLJIT_UNLIKELY(!!compiler
->verbose
)) {
1148 fprintf(compiler
->verbose
, " set_context ret[%s", call_arg_names
[arg_types
& SLJIT_ARG_MASK
]);
1150 arg_types
>>= SLJIT_ARG_SHIFT
;
1152 fprintf(compiler
->verbose
, "], args[");
1154 fprintf(compiler
->verbose
, "%s%s", call_arg_names
[arg_types
& SLJIT_ARG_MASK
],
1155 (arg_types
& SLJIT_ARG_TYPE_SCRATCH_REG
) ? "_r" : "");
1156 arg_types
>>= SLJIT_ARG_SHIFT
;
1158 fprintf(compiler
->verbose
, ",");
1159 } while (arg_types
);
1162 fprintf(compiler
->verbose
, "],%s scratches:%d, saveds:%d, fscratches:%d, fsaveds:%d, local_size:%d\n",
1163 (options
& SLJIT_ENTER_CDECL
) ? " enter:cdecl," : "",
1164 scratches
, saveds
, fscratches
, fsaveds
, local_size
);
1170 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_return_void(struct sljit_compiler
*compiler
)
1172 if (SLJIT_UNLIKELY(compiler
->skip_checks
)) {
1173 compiler
->skip_checks
= 0;
1177 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1178 CHECK_ARGUMENT(compiler
->last_return
== SLJIT_ARG_TYPE_VOID
);
1181 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1182 if (SLJIT_UNLIKELY(!!compiler
->verbose
)) {
1183 fprintf(compiler
->verbose
, " return_void\n");
1189 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_return(struct sljit_compiler
*compiler
, sljit_s32 op
, sljit_s32 src
, sljit_sw srcw
)
1191 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1192 CHECK_ARGUMENT(compiler
->scratches
>= 0);
1194 switch (compiler
->last_return
) {
1195 case SLJIT_ARG_TYPE_W
:
1196 CHECK_ARGUMENT(op
>= SLJIT_MOV
&& op
<= SLJIT_MOV_S32
);
1198 case SLJIT_ARG_TYPE_32
:
1199 CHECK_ARGUMENT(op
== SLJIT_MOV32
|| (op
>= SLJIT_MOV32_U8
&& op
<= SLJIT_MOV32_S16
));
1201 case SLJIT_ARG_TYPE_P
:
1202 CHECK_ARGUMENT(op
== SLJIT_MOV_P
);
1205 /* Context not initialized, void, etc. */
1209 FUNCTION_CHECK_SRC(src
, srcw
);
1210 compiler
->last_flags
= 0;
1212 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1213 if (SLJIT_UNLIKELY(!!compiler
->verbose
)) {
1214 fprintf(compiler
->verbose
, " return%s%s ", !(op
& SLJIT_32
) ? "" : "32",
1215 op1_names
[GET_OPCODE(op
) - SLJIT_OP1_BASE
]);
1216 sljit_verbose_param(compiler
, src
, srcw
);
1217 fprintf(compiler
->verbose
, "\n");
1223 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_fast_enter(struct sljit_compiler
*compiler
, sljit_s32 dst
, sljit_sw dstw
)
1225 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1226 FUNCTION_CHECK_DST(dst
, dstw
);
1227 compiler
->last_flags
= 0;
1229 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1230 if (SLJIT_UNLIKELY(!!compiler
->verbose
)) {
1231 fprintf(compiler
->verbose
, " fast_enter ");
1232 sljit_verbose_param(compiler
, dst
, dstw
);
1233 fprintf(compiler
->verbose
, "\n");
1239 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_op0(struct sljit_compiler
*compiler
, sljit_s32 op
)
1241 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1242 CHECK_ARGUMENT((op
>= SLJIT_BREAKPOINT
&& op
<= SLJIT_LMUL_SW
)
1243 || ((op
& ~SLJIT_32
) >= SLJIT_DIVMOD_UW
&& (op
& ~SLJIT_32
) <= SLJIT_DIV_SW
)
1244 || (op
>= SLJIT_ENDBR
&& op
<= SLJIT_SKIP_FRAMES_BEFORE_RETURN
));
1245 CHECK_ARGUMENT(GET_OPCODE(op
) < SLJIT_LMUL_UW
|| GET_OPCODE(op
) >= SLJIT_ENDBR
|| compiler
->scratches
>= 2);
1246 if ((GET_OPCODE(op
) >= SLJIT_LMUL_UW
&& GET_OPCODE(op
) <= SLJIT_DIV_SW
) || op
== SLJIT_SKIP_FRAMES_BEFORE_RETURN
)
1247 compiler
->last_flags
= 0;
1249 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1250 if (SLJIT_UNLIKELY(!!compiler
->verbose
))
1252 fprintf(compiler
->verbose
, " %s", op0_names
[GET_OPCODE(op
) - SLJIT_OP0_BASE
]);
1253 if (GET_OPCODE(op
) >= SLJIT_DIVMOD_UW
&& GET_OPCODE(op
) <= SLJIT_DIV_SW
) {
1254 fprintf(compiler
->verbose
, (op
& SLJIT_32
) ? "32" : "w");
1256 fprintf(compiler
->verbose
, "\n");
1262 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_op1(struct sljit_compiler
*compiler
, sljit_s32 op
,
1263 sljit_s32 dst
, sljit_sw dstw
,
1264 sljit_s32 src
, sljit_sw srcw
)
1266 if (SLJIT_UNLIKELY(compiler
->skip_checks
)) {
1267 compiler
->skip_checks
= 0;
1271 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1272 CHECK_ARGUMENT(GET_OPCODE(op
) >= SLJIT_MOV
&& GET_OPCODE(op
) <= SLJIT_CLZ
);
1274 switch (GET_OPCODE(op
)) {
1276 /* Only SLJIT_32 and SLJIT_SET_Z are allowed. */
1277 CHECK_ARGUMENT(!(op
& VARIABLE_FLAG_MASK
));
1282 /* Nothing allowed */
1283 CHECK_ARGUMENT(!(op
& (SLJIT_32
| SLJIT_SET_Z
| VARIABLE_FLAG_MASK
)));
1286 /* Only SLJIT_32 is allowed. */
1287 CHECK_ARGUMENT(!(op
& (SLJIT_SET_Z
| VARIABLE_FLAG_MASK
)));
1291 FUNCTION_CHECK_DST(dst
, dstw
);
1292 FUNCTION_CHECK_SRC(src
, srcw
);
1294 if (GET_OPCODE(op
) >= SLJIT_NOT
) {
1295 CHECK_ARGUMENT(src
!= SLJIT_IMM
);
1296 compiler
->last_flags
= GET_FLAG_TYPE(op
) | (op
& (SLJIT_32
| SLJIT_SET_Z
));
1299 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1300 if (SLJIT_UNLIKELY(!!compiler
->verbose
)) {
1301 if (GET_OPCODE(op
) <= SLJIT_MOV_P
)
1303 fprintf(compiler
->verbose
, " mov%s%s ", !(op
& SLJIT_32
) ? "" : "32",
1304 op1_names
[GET_OPCODE(op
) - SLJIT_OP1_BASE
]);
1308 fprintf(compiler
->verbose
, " %s%s%s%s%s ", op1_names
[GET_OPCODE(op
) - SLJIT_OP1_BASE
], !(op
& SLJIT_32
) ? "" : "32",
1309 !(op
& SLJIT_SET_Z
) ? "" : ".z", !(op
& VARIABLE_FLAG_MASK
) ? "" : ".",
1310 !(op
& VARIABLE_FLAG_MASK
) ? "" : jump_names
[GET_FLAG_TYPE(op
)]);
1313 sljit_verbose_param(compiler
, dst
, dstw
);
1314 fprintf(compiler
->verbose
, ", ");
1315 sljit_verbose_param(compiler
, src
, srcw
);
1316 fprintf(compiler
->verbose
, "\n");
1322 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_op2(struct sljit_compiler
*compiler
, sljit_s32 op
, sljit_s32 unset
,
1323 sljit_s32 dst
, sljit_sw dstw
,
1324 sljit_s32 src1
, sljit_sw src1w
,
1325 sljit_s32 src2
, sljit_sw src2w
)
1327 if (SLJIT_UNLIKELY(compiler
->skip_checks
)) {
1328 compiler
->skip_checks
= 0;
1332 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1333 CHECK_ARGUMENT(GET_OPCODE(op
) >= SLJIT_ADD
&& GET_OPCODE(op
) <= SLJIT_ASHR
);
1335 switch (GET_OPCODE(op
)) {
1342 CHECK_ARGUMENT(!(op
& VARIABLE_FLAG_MASK
));
1345 CHECK_ARGUMENT(!(op
& SLJIT_SET_Z
));
1346 CHECK_ARGUMENT(!(op
& VARIABLE_FLAG_MASK
)
1347 || GET_FLAG_TYPE(op
) == SLJIT_OVERFLOW
);
1350 CHECK_ARGUMENT(!(op
& VARIABLE_FLAG_MASK
)
1351 || GET_FLAG_TYPE(op
) == GET_FLAG_TYPE(SLJIT_SET_CARRY
)
1352 || GET_FLAG_TYPE(op
) == SLJIT_OVERFLOW
);
1355 CHECK_ARGUMENT(!(op
& VARIABLE_FLAG_MASK
)
1356 || (GET_FLAG_TYPE(op
) >= SLJIT_LESS
&& GET_FLAG_TYPE(op
) <= SLJIT_OVERFLOW
)
1357 || GET_FLAG_TYPE(op
) == GET_FLAG_TYPE(SLJIT_SET_CARRY
));
1361 CHECK_ARGUMENT(!(op
& VARIABLE_FLAG_MASK
)
1362 || GET_FLAG_TYPE(op
) == GET_FLAG_TYPE(SLJIT_SET_CARRY
));
1363 CHECK_ARGUMENT((compiler
->last_flags
& 0xff) == GET_FLAG_TYPE(SLJIT_SET_CARRY
));
1364 CHECK_ARGUMENT((op
& SLJIT_32
) == (compiler
->last_flags
& SLJIT_32
));
1367 SLJIT_UNREACHABLE();
1372 CHECK_ARGUMENT(HAS_FLAGS(op
));
1374 FUNCTION_CHECK_DST(dst
, dstw
);
1376 FUNCTION_CHECK_SRC(src1
, src1w
);
1377 FUNCTION_CHECK_SRC(src2
, src2w
);
1378 compiler
->last_flags
= GET_FLAG_TYPE(op
) | (op
& (SLJIT_32
| SLJIT_SET_Z
));
1380 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1381 if (SLJIT_UNLIKELY(!!compiler
->verbose
)) {
1382 fprintf(compiler
->verbose
, " %s%s%s%s%s ", op2_names
[GET_OPCODE(op
) - SLJIT_OP2_BASE
], !(op
& SLJIT_32
) ? "" : "32",
1383 !(op
& SLJIT_SET_Z
) ? "" : ".z", !(op
& VARIABLE_FLAG_MASK
) ? "" : ".",
1384 !(op
& VARIABLE_FLAG_MASK
) ? "" : jump_names
[GET_FLAG_TYPE(op
)]);
1386 fprintf(compiler
->verbose
, "unset");
1388 sljit_verbose_param(compiler
, dst
, dstw
);
1389 fprintf(compiler
->verbose
, ", ");
1390 sljit_verbose_param(compiler
, src1
, src1w
);
1391 fprintf(compiler
->verbose
, ", ");
1392 sljit_verbose_param(compiler
, src2
, src2w
);
1393 fprintf(compiler
->verbose
, "\n");
1399 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_op_src(struct sljit_compiler
*compiler
, sljit_s32 op
,
1400 sljit_s32 src
, sljit_sw srcw
)
1402 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1403 CHECK_ARGUMENT(op
>= SLJIT_FAST_RETURN
&& op
<= SLJIT_PREFETCH_ONCE
);
1404 FUNCTION_CHECK_SRC(src
, srcw
);
1406 if (op
== SLJIT_FAST_RETURN
|| op
== SLJIT_SKIP_FRAMES_BEFORE_FAST_RETURN
)
1408 CHECK_ARGUMENT(src
!= SLJIT_IMM
);
1409 compiler
->last_flags
= 0;
1411 else if (op
>= SLJIT_PREFETCH_L1
&& op
<= SLJIT_PREFETCH_ONCE
)
1413 CHECK_ARGUMENT(src
& SLJIT_MEM
);
1416 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1417 if (SLJIT_UNLIKELY(!!compiler
->verbose
)) {
1418 fprintf(compiler
->verbose
, " %s ", op_src_names
[op
- SLJIT_OP_SRC_BASE
]);
1419 sljit_verbose_param(compiler
, src
, srcw
);
1420 fprintf(compiler
->verbose
, "\n");
1426 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_get_register_index(sljit_s32 reg
)
1428 SLJIT_UNUSED_ARG(reg
);
1429 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1430 CHECK_ARGUMENT(reg
> 0 && reg
<= SLJIT_NUMBER_OF_REGISTERS
);
1435 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_get_float_register_index(sljit_s32 reg
)
1437 SLJIT_UNUSED_ARG(reg
);
1438 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1439 CHECK_ARGUMENT(reg
> 0 && reg
<= SLJIT_NUMBER_OF_FLOAT_REGISTERS
);
1444 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_op_custom(struct sljit_compiler
*compiler
,
1445 void *instruction
, sljit_u32 size
)
1447 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1451 SLJIT_UNUSED_ARG(compiler
);
1453 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1454 CHECK_ARGUMENT(instruction
);
1456 #if (defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86)
1457 CHECK_ARGUMENT(size
> 0 && size
< 16);
1458 #elif (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
1459 CHECK_ARGUMENT((size
== 2 && (((sljit_sw
)instruction
) & 0x1) == 0)
1460 || (size
== 4 && (((sljit_sw
)instruction
) & 0x3) == 0));
1461 #elif (defined SLJIT_CONFIG_S390X && SLJIT_CONFIG_S390X)
1462 CHECK_ARGUMENT(size
== 2 || size
== 4 || size
== 6);
1464 CHECK_ARGUMENT(size
== 4 && (((sljit_sw
)instruction
) & 0x3) == 0);
1467 compiler
->last_flags
= 0;
1469 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1470 if (SLJIT_UNLIKELY(!!compiler
->verbose
)) {
1471 fprintf(compiler
->verbose
, " op_custom");
1472 for (i
= 0; i
< size
; i
++)
1473 fprintf(compiler
->verbose
, " 0x%x", ((sljit_u8
*)instruction
)[i
]);
1474 fprintf(compiler
->verbose
, "\n");
1480 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_fop1(struct sljit_compiler
*compiler
, sljit_s32 op
,
1481 sljit_s32 dst
, sljit_sw dstw
,
1482 sljit_s32 src
, sljit_sw srcw
)
1484 if (SLJIT_UNLIKELY(compiler
->skip_checks
)) {
1485 compiler
->skip_checks
= 0;
1489 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1490 CHECK_ARGUMENT(sljit_has_cpu_feature(SLJIT_HAS_FPU
));
1491 CHECK_ARGUMENT(GET_OPCODE(op
) >= SLJIT_MOV_F64
&& GET_OPCODE(op
) <= SLJIT_ABS_F64
);
1492 CHECK_ARGUMENT(!(op
& (SLJIT_SET_Z
| VARIABLE_FLAG_MASK
)));
1493 FUNCTION_FCHECK(src
, srcw
);
1494 FUNCTION_FCHECK(dst
, dstw
);
1496 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1497 if (SLJIT_UNLIKELY(!!compiler
->verbose
)) {
1498 if (GET_OPCODE(op
) == SLJIT_CONV_F64_FROM_F32
)
1499 fprintf(compiler
->verbose
, " %s%s ", fop1_names
[SLJIT_CONV_F64_FROM_F32
- SLJIT_FOP1_BASE
],
1500 (op
& SLJIT_32
) ? ".f32.from.f64" : ".f64.from.f32");
1502 fprintf(compiler
->verbose
, " %s%s ", fop1_names
[GET_OPCODE(op
) - SLJIT_FOP1_BASE
],
1503 (op
& SLJIT_32
) ? ".f32" : ".f64");
1505 sljit_verbose_fparam(compiler
, dst
, dstw
);
1506 fprintf(compiler
->verbose
, ", ");
1507 sljit_verbose_fparam(compiler
, src
, srcw
);
1508 fprintf(compiler
->verbose
, "\n");
1514 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_fop1_cmp(struct sljit_compiler
*compiler
, sljit_s32 op
,
1515 sljit_s32 src1
, sljit_sw src1w
,
1516 sljit_s32 src2
, sljit_sw src2w
)
1518 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1519 compiler
->last_flags
= GET_FLAG_TYPE(op
) | (op
& (SLJIT_32
| SLJIT_SET_Z
));
1522 if (SLJIT_UNLIKELY(compiler
->skip_checks
)) {
1523 compiler
->skip_checks
= 0;
1527 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1528 CHECK_ARGUMENT(sljit_has_cpu_feature(SLJIT_HAS_FPU
));
1529 CHECK_ARGUMENT(GET_OPCODE(op
) == SLJIT_CMP_F64
);
1530 CHECK_ARGUMENT(!(op
& SLJIT_SET_Z
));
1531 CHECK_ARGUMENT((op
& VARIABLE_FLAG_MASK
)
1532 || (GET_FLAG_TYPE(op
) >= SLJIT_F_EQUAL
&& GET_FLAG_TYPE(op
) <= SLJIT_ORDERED_LESS_EQUAL
));
1533 FUNCTION_FCHECK(src1
, src1w
);
1534 FUNCTION_FCHECK(src2
, src2w
);
1536 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1537 if (SLJIT_UNLIKELY(!!compiler
->verbose
)) {
1538 fprintf(compiler
->verbose
, " %s%s", fop1_names
[SLJIT_CMP_F64
- SLJIT_FOP1_BASE
], (op
& SLJIT_32
) ? ".f32" : ".f64");
1539 if (op
& VARIABLE_FLAG_MASK
) {
1540 fprintf(compiler
->verbose
, ".%s", jump_names
[GET_FLAG_TYPE(op
)]);
1542 fprintf(compiler
->verbose
, " ");
1543 sljit_verbose_fparam(compiler
, src1
, src1w
);
1544 fprintf(compiler
->verbose
, ", ");
1545 sljit_verbose_fparam(compiler
, src2
, src2w
);
1546 fprintf(compiler
->verbose
, "\n");
1552 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_fop1_conv_sw_from_f64(struct sljit_compiler
*compiler
, sljit_s32 op
,
1553 sljit_s32 dst
, sljit_sw dstw
,
1554 sljit_s32 src
, sljit_sw srcw
)
1556 if (SLJIT_UNLIKELY(compiler
->skip_checks
)) {
1557 compiler
->skip_checks
= 0;
1561 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1562 CHECK_ARGUMENT(sljit_has_cpu_feature(SLJIT_HAS_FPU
));
1563 CHECK_ARGUMENT(GET_OPCODE(op
) >= SLJIT_CONV_SW_FROM_F64
&& GET_OPCODE(op
) <= SLJIT_CONV_S32_FROM_F64
);
1564 CHECK_ARGUMENT(!(op
& (SLJIT_SET_Z
| VARIABLE_FLAG_MASK
)));
1565 FUNCTION_FCHECK(src
, srcw
);
1566 FUNCTION_CHECK_DST(dst
, dstw
);
1568 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1569 if (SLJIT_UNLIKELY(!!compiler
->verbose
)) {
1570 fprintf(compiler
->verbose
, " %s%s.from%s ", fop1_names
[GET_OPCODE(op
) - SLJIT_FOP1_BASE
],
1571 (GET_OPCODE(op
) == SLJIT_CONV_S32_FROM_F64
) ? ".s32" : ".sw",
1572 (op
& SLJIT_32
) ? ".f32" : ".f64");
1573 sljit_verbose_param(compiler
, dst
, dstw
);
1574 fprintf(compiler
->verbose
, ", ");
1575 sljit_verbose_fparam(compiler
, src
, srcw
);
1576 fprintf(compiler
->verbose
, "\n");
1582 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_fop1_conv_f64_from_sw(struct sljit_compiler
*compiler
, sljit_s32 op
,
1583 sljit_s32 dst
, sljit_sw dstw
,
1584 sljit_s32 src
, sljit_sw srcw
)
1586 if (SLJIT_UNLIKELY(compiler
->skip_checks
)) {
1587 compiler
->skip_checks
= 0;
1591 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1592 CHECK_ARGUMENT(sljit_has_cpu_feature(SLJIT_HAS_FPU
));
1593 CHECK_ARGUMENT(GET_OPCODE(op
) >= SLJIT_CONV_F64_FROM_SW
&& GET_OPCODE(op
) <= SLJIT_CONV_F64_FROM_S32
);
1594 CHECK_ARGUMENT(!(op
& (SLJIT_SET_Z
| VARIABLE_FLAG_MASK
)));
1595 FUNCTION_CHECK_SRC(src
, srcw
);
1596 FUNCTION_FCHECK(dst
, dstw
);
1598 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1599 if (SLJIT_UNLIKELY(!!compiler
->verbose
)) {
1600 fprintf(compiler
->verbose
, " %s%s.from%s ", fop1_names
[GET_OPCODE(op
) - SLJIT_FOP1_BASE
],
1601 (op
& SLJIT_32
) ? ".f32" : ".f64",
1602 (GET_OPCODE(op
) == SLJIT_CONV_F64_FROM_S32
) ? ".s32" : ".sw");
1603 sljit_verbose_fparam(compiler
, dst
, dstw
);
1604 fprintf(compiler
->verbose
, ", ");
1605 sljit_verbose_param(compiler
, src
, srcw
);
1606 fprintf(compiler
->verbose
, "\n");
1612 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_fop2(struct sljit_compiler
*compiler
, sljit_s32 op
,
1613 sljit_s32 dst
, sljit_sw dstw
,
1614 sljit_s32 src1
, sljit_sw src1w
,
1615 sljit_s32 src2
, sljit_sw src2w
)
1617 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1618 CHECK_ARGUMENT(sljit_has_cpu_feature(SLJIT_HAS_FPU
));
1619 CHECK_ARGUMENT(GET_OPCODE(op
) >= SLJIT_ADD_F64
&& GET_OPCODE(op
) <= SLJIT_DIV_F64
);
1620 CHECK_ARGUMENT(!(op
& (SLJIT_SET_Z
| VARIABLE_FLAG_MASK
)));
1621 FUNCTION_FCHECK(src1
, src1w
);
1622 FUNCTION_FCHECK(src2
, src2w
);
1623 FUNCTION_FCHECK(dst
, dstw
);
1625 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1626 if (SLJIT_UNLIKELY(!!compiler
->verbose
)) {
1627 fprintf(compiler
->verbose
, " %s%s ", fop2_names
[GET_OPCODE(op
) - SLJIT_FOP2_BASE
], (op
& SLJIT_32
) ? ".f32" : ".f64");
1628 sljit_verbose_fparam(compiler
, dst
, dstw
);
1629 fprintf(compiler
->verbose
, ", ");
1630 sljit_verbose_fparam(compiler
, src1
, src1w
);
1631 fprintf(compiler
->verbose
, ", ");
1632 sljit_verbose_fparam(compiler
, src2
, src2w
);
1633 fprintf(compiler
->verbose
, "\n");
1639 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_label(struct sljit_compiler
*compiler
)
1641 SLJIT_UNUSED_ARG(compiler
);
1643 if (SLJIT_UNLIKELY(compiler
->skip_checks
)) {
1644 compiler
->skip_checks
= 0;
1648 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1649 compiler
->last_flags
= 0;
1652 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1653 if (SLJIT_UNLIKELY(!!compiler
->verbose
))
1654 fprintf(compiler
->verbose
, "label:\n");
1659 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1660 #if (defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86) \
1661 || (defined SLJIT_CONFIG_ARM && SLJIT_CONFIG_ARM)
1662 #define CHECK_UNORDERED(type, last_flags) \
1663 ((((type) & 0xff) == SLJIT_UNORDERED || ((type) & 0xff) == SLJIT_ORDERED) && \
1664 ((last_flags) & 0xff) >= SLJIT_UNORDERED && ((last_flags) & 0xff) <= SLJIT_ORDERED_LESS_EQUAL)
1666 #define CHECK_UNORDERED(type, last_flags) 0
1668 #endif /* SLJIT_ARGUMENT_CHECKS */
1670 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_jump(struct sljit_compiler
*compiler
, sljit_s32 type
)
1672 if (SLJIT_UNLIKELY(compiler
->skip_checks
)) {
1673 compiler
->skip_checks
= 0;
1677 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1678 CHECK_ARGUMENT(!(type
& ~(0xff | SLJIT_REWRITABLE_JUMP
| SLJIT_32
)));
1679 CHECK_ARGUMENT((type
& 0xff) >= SLJIT_EQUAL
&& (type
& 0xff) <= SLJIT_FAST_CALL
);
1680 CHECK_ARGUMENT((type
& 0xff) < SLJIT_JUMP
|| !(type
& SLJIT_32
));
1682 if ((type
& 0xff) < SLJIT_JUMP
) {
1683 if ((type
& 0xff) <= SLJIT_NOT_ZERO
)
1684 CHECK_ARGUMENT(compiler
->last_flags
& SLJIT_SET_Z
);
1685 else if ((compiler
->last_flags
& 0xff) == SLJIT_CARRY
) {
1686 CHECK_ARGUMENT((type
& 0xff) == SLJIT_CARRY
|| (type
& 0xff) == SLJIT_NOT_CARRY
);
1687 compiler
->last_flags
= 0;
1689 CHECK_ARGUMENT((type
& 0xff) == (compiler
->last_flags
& 0xff)
1690 || ((type
& 0xff) == SLJIT_NOT_OVERFLOW
&& (compiler
->last_flags
& 0xff) == SLJIT_OVERFLOW
)
1691 || CHECK_UNORDERED(type
, compiler
->last_flags
));
1694 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1695 if (SLJIT_UNLIKELY(!!compiler
->verbose
))
1696 fprintf(compiler
->verbose
, " jump%s %s\n", !(type
& SLJIT_REWRITABLE_JUMP
) ? "" : ".r",
1697 jump_names
[type
& 0xff]);
1702 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_call(struct sljit_compiler
*compiler
, sljit_s32 type
,
1703 sljit_s32 arg_types
)
1705 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1706 CHECK_ARGUMENT(!(type
& ~(0xff | SLJIT_REWRITABLE_JUMP
| SLJIT_CALL_RETURN
)));
1707 CHECK_ARGUMENT((type
& 0xff) == SLJIT_CALL
|| (type
& 0xff) == SLJIT_CALL_CDECL
);
1708 CHECK_ARGUMENT(function_check_arguments(arg_types
, compiler
->scratches
, -1, compiler
->fscratches
));
1710 if (type
& SLJIT_CALL_RETURN
) {
1711 CHECK_ARGUMENT((arg_types
& SLJIT_ARG_MASK
) == compiler
->last_return
);
1714 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1715 if (SLJIT_UNLIKELY(!!compiler
->verbose
)) {
1716 fprintf(compiler
->verbose
, " %s%s%s ret[%s", jump_names
[type
& 0xff],
1717 !(type
& SLJIT_REWRITABLE_JUMP
) ? "" : ".r",
1718 !(type
& SLJIT_CALL_RETURN
) ? "" : ".ret",
1719 call_arg_names
[arg_types
& SLJIT_ARG_MASK
]);
1721 arg_types
>>= SLJIT_ARG_SHIFT
;
1723 fprintf(compiler
->verbose
, "], args[");
1725 fprintf(compiler
->verbose
, "%s", call_arg_names
[arg_types
& SLJIT_ARG_MASK
]);
1726 arg_types
>>= SLJIT_ARG_SHIFT
;
1728 fprintf(compiler
->verbose
, ",");
1729 } while (arg_types
);
1731 fprintf(compiler
->verbose
, "]\n");
1737 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_cmp(struct sljit_compiler
*compiler
, sljit_s32 type
,
1738 sljit_s32 src1
, sljit_sw src1w
,
1739 sljit_s32 src2
, sljit_sw src2w
)
1741 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1742 CHECK_ARGUMENT(!(type
& ~(0xff | SLJIT_REWRITABLE_JUMP
| SLJIT_32
)));
1743 CHECK_ARGUMENT((type
& 0xff) >= SLJIT_EQUAL
&& (type
& 0xff) <= SLJIT_SIG_LESS_EQUAL
);
1744 FUNCTION_CHECK_SRC(src1
, src1w
);
1745 FUNCTION_CHECK_SRC(src2
, src2w
);
1746 compiler
->last_flags
= 0;
1748 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1749 if (SLJIT_UNLIKELY(!!compiler
->verbose
)) {
1750 fprintf(compiler
->verbose
, " cmp%s%s %s, ", (type
& SLJIT_32
) ? "32" : "",
1751 !(type
& SLJIT_REWRITABLE_JUMP
) ? "" : ".r", jump_names
[type
& 0xff]);
1752 sljit_verbose_param(compiler
, src1
, src1w
);
1753 fprintf(compiler
->verbose
, ", ");
1754 sljit_verbose_param(compiler
, src2
, src2w
);
1755 fprintf(compiler
->verbose
, "\n");
1761 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_fcmp(struct sljit_compiler
*compiler
, sljit_s32 type
,
1762 sljit_s32 src1
, sljit_sw src1w
,
1763 sljit_s32 src2
, sljit_sw src2w
)
1765 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1766 CHECK_ARGUMENT(sljit_has_cpu_feature(SLJIT_HAS_FPU
));
1767 CHECK_ARGUMENT(!(type
& ~(0xff | SLJIT_REWRITABLE_JUMP
| SLJIT_32
)));
1768 CHECK_ARGUMENT((type
& 0xff) >= SLJIT_F_EQUAL
&& (type
& 0xff) <= SLJIT_ORDERED_LESS_EQUAL
1769 && ((type
& 0xff) <= SLJIT_ORDERED
|| sljit_cmp_info(type
& 0xff)));
1770 FUNCTION_FCHECK(src1
, src1w
);
1771 FUNCTION_FCHECK(src2
, src2w
);
1772 compiler
->last_flags
= 0;
1774 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1775 if (SLJIT_UNLIKELY(!!compiler
->verbose
)) {
1776 fprintf(compiler
->verbose
, " fcmp%s%s %s, ", (type
& SLJIT_32
) ? ".f32" : ".f64",
1777 !(type
& SLJIT_REWRITABLE_JUMP
) ? "" : ".r", jump_names
[type
& 0xff]);
1778 sljit_verbose_fparam(compiler
, src1
, src1w
);
1779 fprintf(compiler
->verbose
, ", ");
1780 sljit_verbose_fparam(compiler
, src2
, src2w
);
1781 fprintf(compiler
->verbose
, "\n");
1787 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_ijump(struct sljit_compiler
*compiler
, sljit_s32 type
,
1788 sljit_s32 src
, sljit_sw srcw
)
1790 if (SLJIT_UNLIKELY(compiler
->skip_checks
)) {
1791 compiler
->skip_checks
= 0;
1795 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1796 CHECK_ARGUMENT(type
>= SLJIT_JUMP
&& type
<= SLJIT_FAST_CALL
);
1797 FUNCTION_CHECK_SRC(src
, srcw
);
1799 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1800 if (SLJIT_UNLIKELY(!!compiler
->verbose
)) {
1801 fprintf(compiler
->verbose
, " ijump.%s ", jump_names
[type
]);
1802 sljit_verbose_param(compiler
, src
, srcw
);
1803 fprintf(compiler
->verbose
, "\n");
1809 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_icall(struct sljit_compiler
*compiler
, sljit_s32 type
,
1810 sljit_s32 arg_types
,
1811 sljit_s32 src
, sljit_sw srcw
)
1813 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1814 CHECK_ARGUMENT(!(type
& ~(0xff | SLJIT_CALL_RETURN
)));
1815 CHECK_ARGUMENT((type
& 0xff) == SLJIT_CALL
|| (type
& 0xff) == SLJIT_CALL_CDECL
);
1816 CHECK_ARGUMENT(function_check_arguments(arg_types
, compiler
->scratches
, -1, compiler
->fscratches
));
1817 FUNCTION_CHECK_SRC(src
, srcw
);
1819 if (type
& SLJIT_CALL_RETURN
) {
1820 CHECK_ARGUMENT((arg_types
& SLJIT_ARG_MASK
) == compiler
->last_return
);
1823 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1824 if (SLJIT_UNLIKELY(!!compiler
->verbose
)) {
1825 fprintf(compiler
->verbose
, " i%s%s ret[%s", jump_names
[type
& 0xff],
1826 !(type
& SLJIT_CALL_RETURN
) ? "" : ".ret",
1827 call_arg_names
[arg_types
& SLJIT_ARG_MASK
]);
1829 arg_types
>>= SLJIT_ARG_SHIFT
;
1831 fprintf(compiler
->verbose
, "], args[");
1833 fprintf(compiler
->verbose
, "%s", call_arg_names
[arg_types
& SLJIT_ARG_MASK
]);
1834 arg_types
>>= SLJIT_ARG_SHIFT
;
1836 fprintf(compiler
->verbose
, ",");
1837 } while (arg_types
);
1839 fprintf(compiler
->verbose
, "], ");
1840 sljit_verbose_param(compiler
, src
, srcw
);
1841 fprintf(compiler
->verbose
, "\n");
1847 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_op_flags(struct sljit_compiler
*compiler
, sljit_s32 op
,
1848 sljit_s32 dst
, sljit_sw dstw
,
1851 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1852 CHECK_ARGUMENT(!(type
& ~(0xff | SLJIT_32
)));
1853 CHECK_ARGUMENT((type
& 0xff) >= SLJIT_EQUAL
&& (type
& 0xff) <= SLJIT_ORDERED_LESS_EQUAL
);
1854 CHECK_ARGUMENT(op
== SLJIT_MOV
|| op
== SLJIT_MOV32
1855 || (GET_OPCODE(op
) >= SLJIT_AND
&& GET_OPCODE(op
) <= SLJIT_XOR
));
1856 CHECK_ARGUMENT(!(op
& VARIABLE_FLAG_MASK
));
1858 if ((type
& 0xff) <= SLJIT_NOT_ZERO
)
1859 CHECK_ARGUMENT(compiler
->last_flags
& SLJIT_SET_Z
);
1861 CHECK_ARGUMENT((type
& 0xff) == (compiler
->last_flags
& 0xff)
1862 || ((type
& 0xff) == SLJIT_NOT_CARRY
&& (compiler
->last_flags
& 0xff) == SLJIT_CARRY
)
1863 || ((type
& 0xff) == SLJIT_NOT_OVERFLOW
&& (compiler
->last_flags
& 0xff) == SLJIT_OVERFLOW
)
1864 || CHECK_UNORDERED(type
, compiler
->last_flags
));
1866 FUNCTION_CHECK_DST(dst
, dstw
);
1868 if (GET_OPCODE(op
) >= SLJIT_ADD
)
1869 compiler
->last_flags
= GET_FLAG_TYPE(op
) | (op
& (SLJIT_32
| SLJIT_SET_Z
));
1871 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1872 if (SLJIT_UNLIKELY(!!compiler
->verbose
)) {
1873 fprintf(compiler
->verbose
, " flags.%s%s%s ",
1874 GET_OPCODE(op
) < SLJIT_OP2_BASE
? "mov" : op2_names
[GET_OPCODE(op
) - SLJIT_OP2_BASE
],
1875 GET_OPCODE(op
) < SLJIT_OP2_BASE
? op1_names
[GET_OPCODE(op
) - SLJIT_OP1_BASE
] : ((op
& SLJIT_32
) ? "32" : ""),
1876 !(op
& SLJIT_SET_Z
) ? "" : ".z");
1877 sljit_verbose_param(compiler
, dst
, dstw
);
1878 fprintf(compiler
->verbose
, ", %s\n", jump_names
[type
& 0xff]);
1884 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_cmov(struct sljit_compiler
*compiler
, sljit_s32 type
,
1886 sljit_s32 src
, sljit_sw srcw
)
1888 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1889 CHECK_ARGUMENT(!(type
& ~(0xff | SLJIT_32
)));
1890 CHECK_ARGUMENT((type
& 0xff) >= SLJIT_EQUAL
&& (type
& 0xff) <= SLJIT_ORDERED_LESS_EQUAL
);
1892 CHECK_ARGUMENT(compiler
->scratches
!= -1 && compiler
->saveds
!= -1);
1893 CHECK_ARGUMENT(FUNCTION_CHECK_IS_REG(dst_reg
& ~SLJIT_32
));
1894 if (src
!= SLJIT_IMM
) {
1895 CHECK_ARGUMENT(FUNCTION_CHECK_IS_REG(src
));
1896 CHECK_ARGUMENT(srcw
== 0);
1899 if ((type
& 0xff) <= SLJIT_NOT_ZERO
)
1900 CHECK_ARGUMENT(compiler
->last_flags
& SLJIT_SET_Z
);
1902 CHECK_ARGUMENT((type
& 0xff) == (compiler
->last_flags
& 0xff)
1903 || ((type
& 0xff) == SLJIT_NOT_CARRY
&& (compiler
->last_flags
& 0xff) == SLJIT_CARRY
)
1904 || ((type
& 0xff) == SLJIT_NOT_OVERFLOW
&& (compiler
->last_flags
& 0xff) == SLJIT_OVERFLOW
)
1905 || CHECK_UNORDERED(type
, compiler
->last_flags
));
1907 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1908 if (SLJIT_UNLIKELY(!!compiler
->verbose
)) {
1909 fprintf(compiler
->verbose
, " cmov%s %s, ",
1910 !(dst_reg
& SLJIT_32
) ? "" : "32",
1911 jump_names
[type
& 0xff]);
1912 sljit_verbose_reg(compiler
, dst_reg
& ~SLJIT_32
);
1913 fprintf(compiler
->verbose
, ", ");
1914 sljit_verbose_param(compiler
, src
, srcw
);
1915 fprintf(compiler
->verbose
, "\n");
1921 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_mem(struct sljit_compiler
*compiler
, sljit_s32 type
,
1923 sljit_s32 mem
, sljit_sw memw
)
1925 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1926 CHECK_ARGUMENT((type
& 0xff) >= SLJIT_MOV
&& (type
& 0xff) <= SLJIT_MOV_P
);
1927 CHECK_ARGUMENT(!(type
& SLJIT_32
) || ((type
& 0xff) != SLJIT_MOV
&& (type
& 0xff) != SLJIT_MOV_U32
&& (type
& 0xff) != SLJIT_MOV_P
));
1928 CHECK_ARGUMENT((type
& SLJIT_MEM_PRE
) || (type
& SLJIT_MEM_POST
));
1929 CHECK_ARGUMENT((type
& (SLJIT_MEM_PRE
| SLJIT_MEM_POST
)) != (SLJIT_MEM_PRE
| SLJIT_MEM_POST
));
1930 CHECK_ARGUMENT((type
& ~(0xff | SLJIT_32
| SLJIT_MEM_STORE
| SLJIT_MEM_SUPP
| SLJIT_MEM_PRE
| SLJIT_MEM_POST
)) == 0);
1932 FUNCTION_CHECK_SRC_MEM(mem
, memw
);
1933 CHECK_ARGUMENT(FUNCTION_CHECK_IS_REG(reg
));
1935 CHECK_ARGUMENT((mem
& REG_MASK
) != 0 && (mem
& REG_MASK
) != reg
);
1937 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1938 if (!(type
& SLJIT_MEM_SUPP
) && SLJIT_UNLIKELY(!!compiler
->verbose
)) {
1939 if (sljit_emit_mem(compiler
, type
| SLJIT_MEM_SUPP
, reg
, mem
, memw
) == SLJIT_ERR_UNSUPPORTED
)
1940 fprintf(compiler
->verbose
, " //");
1942 fprintf(compiler
->verbose
, " mem%s.%s%s%s ",
1943 !(type
& SLJIT_32
) ? "" : "32",
1944 (type
& SLJIT_MEM_STORE
) ? "st" : "ld",
1945 op1_names
[(type
& 0xff) - SLJIT_OP1_BASE
],
1946 (type
& SLJIT_MEM_PRE
) ? ".pre" : ".post");
1947 sljit_verbose_reg(compiler
, reg
);
1948 fprintf(compiler
->verbose
, ", ");
1949 sljit_verbose_param(compiler
, mem
, memw
);
1950 fprintf(compiler
->verbose
, "\n");
1956 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_fmem(struct sljit_compiler
*compiler
, sljit_s32 type
,
1958 sljit_s32 mem
, sljit_sw memw
)
1960 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1961 CHECK_ARGUMENT((type
& 0xff) == SLJIT_MOV_F64
);
1962 CHECK_ARGUMENT((type
& SLJIT_MEM_PRE
) || (type
& SLJIT_MEM_POST
));
1963 CHECK_ARGUMENT((type
& (SLJIT_MEM_PRE
| SLJIT_MEM_POST
)) != (SLJIT_MEM_PRE
| SLJIT_MEM_POST
));
1964 CHECK_ARGUMENT((type
& ~(0xff | SLJIT_32
| SLJIT_MEM_STORE
| SLJIT_MEM_SUPP
| SLJIT_MEM_PRE
| SLJIT_MEM_POST
)) == 0);
1966 FUNCTION_CHECK_SRC_MEM(mem
, memw
);
1967 CHECK_ARGUMENT(FUNCTION_CHECK_IS_FREG(freg
));
1969 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1970 if (!(type
& SLJIT_MEM_SUPP
) && SLJIT_UNLIKELY(!!compiler
->verbose
)) {
1971 if (sljit_emit_fmem(compiler
, type
| SLJIT_MEM_SUPP
, freg
, mem
, memw
) == SLJIT_ERR_UNSUPPORTED
)
1972 fprintf(compiler
->verbose
, " //");
1974 fprintf(compiler
->verbose
, " fmem.%s%s%s ",
1975 (type
& SLJIT_MEM_STORE
) ? "st" : "ld",
1976 !(type
& SLJIT_32
) ? ".f64" : ".f32",
1977 (type
& SLJIT_MEM_PRE
) ? ".pre" : ".post");
1978 sljit_verbose_freg(compiler
, freg
);
1979 fprintf(compiler
->verbose
, ", ");
1980 sljit_verbose_param(compiler
, mem
, memw
);
1981 fprintf(compiler
->verbose
, "\n");
1987 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_get_local_base(struct sljit_compiler
*compiler
, sljit_s32 dst
, sljit_sw dstw
, sljit_sw offset
)
1989 /* Any offset is allowed. */
1990 SLJIT_UNUSED_ARG(offset
);
1992 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1993 FUNCTION_CHECK_DST(dst
, dstw
);
1995 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1996 if (SLJIT_UNLIKELY(!!compiler
->verbose
)) {
1997 fprintf(compiler
->verbose
, " local_base ");
1998 sljit_verbose_param(compiler
, dst
, dstw
);
1999 fprintf(compiler
->verbose
, ", #%" SLJIT_PRINT_D
"d\n", offset
);
2005 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_const(struct sljit_compiler
*compiler
, sljit_s32 dst
, sljit_sw dstw
, sljit_sw init_value
)
2007 SLJIT_UNUSED_ARG(init_value
);
2009 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
2010 FUNCTION_CHECK_DST(dst
, dstw
);
2012 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
2013 if (SLJIT_UNLIKELY(!!compiler
->verbose
)) {
2014 fprintf(compiler
->verbose
, " const ");
2015 sljit_verbose_param(compiler
, dst
, dstw
);
2016 fprintf(compiler
->verbose
, ", #%" SLJIT_PRINT_D
"d\n", init_value
);
2022 static SLJIT_INLINE CHECK_RETURN_TYPE
check_sljit_emit_put_label(struct sljit_compiler
*compiler
, sljit_s32 dst
, sljit_sw dstw
)
2024 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
2025 FUNCTION_CHECK_DST(dst
, dstw
);
2027 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
2028 if (SLJIT_UNLIKELY(!!compiler
->verbose
)) {
2029 fprintf(compiler
->verbose
, " put_label ");
2030 sljit_verbose_param(compiler
, dst
, dstw
);
2031 fprintf(compiler
->verbose
, "\n");
2037 #endif /* SLJIT_ARGUMENT_CHECKS || SLJIT_VERBOSE */
2039 #define SELECT_FOP1_OPERATION_WITH_CHECKS(compiler, op, dst, dstw, src, srcw) \
2040 SLJIT_COMPILE_ASSERT(!(SLJIT_CONV_SW_FROM_F64 & 0x1) && !(SLJIT_CONV_F64_FROM_SW & 0x1), \
2041 invalid_float_opcodes); \
2042 if (GET_OPCODE(op) >= SLJIT_CONV_SW_FROM_F64 && GET_OPCODE(op) <= SLJIT_CMP_F64) { \
2043 if (GET_OPCODE(op) == SLJIT_CMP_F64) { \
2044 CHECK(check_sljit_emit_fop1_cmp(compiler, op, dst, dstw, src, srcw)); \
2045 ADJUST_LOCAL_OFFSET(dst, dstw); \
2046 ADJUST_LOCAL_OFFSET(src, srcw); \
2047 return sljit_emit_fop1_cmp(compiler, op, dst, dstw, src, srcw); \
2049 if ((GET_OPCODE(op) | 0x1) == SLJIT_CONV_S32_FROM_F64) { \
2050 CHECK(check_sljit_emit_fop1_conv_sw_from_f64(compiler, op, dst, dstw, src, srcw)); \
2051 ADJUST_LOCAL_OFFSET(dst, dstw); \
2052 ADJUST_LOCAL_OFFSET(src, srcw); \
2053 return sljit_emit_fop1_conv_sw_from_f64(compiler, op, dst, dstw, src, srcw); \
2055 CHECK(check_sljit_emit_fop1_conv_f64_from_sw(compiler, op, dst, dstw, src, srcw)); \
2056 ADJUST_LOCAL_OFFSET(dst, dstw); \
2057 ADJUST_LOCAL_OFFSET(src, srcw); \
2058 return sljit_emit_fop1_conv_f64_from_sw(compiler, op, dst, dstw, src, srcw); \
2060 CHECK(check_sljit_emit_fop1(compiler, op, dst, dstw, src, srcw)); \
2061 ADJUST_LOCAL_OFFSET(dst, dstw); \
2062 ADJUST_LOCAL_OFFSET(src, srcw);
2064 static SLJIT_INLINE sljit_s32
emit_mov_before_return(struct sljit_compiler
*compiler
, sljit_s32 op
, sljit_s32 src
, sljit_sw srcw
)
2066 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
2067 /* At the moment the pointer size is always equal to sljit_sw. May be changed in the future. */
2068 if (src
== SLJIT_RETURN_REG
&& (op
== SLJIT_MOV
|| op
== SLJIT_MOV_P
))
2069 return SLJIT_SUCCESS
;
2071 if (src
== SLJIT_RETURN_REG
&& (op
== SLJIT_MOV
|| op
== SLJIT_MOV_U32
|| op
== SLJIT_MOV_S32
|| op
== SLJIT_MOV_P
))
2072 return SLJIT_SUCCESS
;
2075 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS) \
2076 || (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
2077 compiler
->skip_checks
= 1;
2079 return sljit_emit_op1(compiler
, op
, SLJIT_RETURN_REG
, 0, src
, srcw
);
2082 #if !(defined SLJIT_CONFIG_SPARC && SLJIT_CONFIG_SPARC)
2084 SLJIT_API_FUNC_ATTRIBUTE sljit_s32
sljit_emit_return(struct sljit_compiler
*compiler
, sljit_s32 op
, sljit_s32 src
, sljit_sw srcw
)
2087 CHECK(check_sljit_emit_return(compiler
, op
, src
, srcw
));
2089 FAIL_IF(emit_mov_before_return(compiler
, op
, src
, srcw
));
2091 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS) \
2092 || (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
2093 compiler
->skip_checks
= 1;
2095 return sljit_emit_return_void(compiler
);
2100 #if (defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86) \
2101 || (defined SLJIT_CONFIG_PPC && SLJIT_CONFIG_PPC) \
2102 || (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32) \
2103 || ((defined SLJIT_CONFIG_MIPS && SLJIT_CONFIG_MIPS) && !(defined SLJIT_MIPS_REV && SLJIT_MIPS_REV >= 1 && SLJIT_MIPS_REV < 6))
2105 static SLJIT_INLINE sljit_s32
sljit_emit_cmov_generic(struct sljit_compiler
*compiler
, sljit_s32 type
,
2107 sljit_s32 src
, sljit_sw srcw
)
2109 struct sljit_label
*label
;
2110 struct sljit_jump
*jump
;
2111 sljit_s32 op
= (dst_reg
& SLJIT_32
) ? SLJIT_MOV32
: SLJIT_MOV
;
2113 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) \
2114 || (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
2115 compiler
->skip_checks
= 1;
2117 jump
= sljit_emit_jump(compiler
, type
^ 0x1);
2120 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) \
2121 || (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
2122 compiler
->skip_checks
= 1;
2124 FAIL_IF(sljit_emit_op1(compiler
, op
, dst_reg
& ~SLJIT_32
, 0, src
, srcw
));
2126 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) \
2127 || (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
2128 compiler
->skip_checks
= 1;
2130 label
= sljit_emit_label(compiler
);
2132 sljit_set_label(jump
, label
);
2133 return SLJIT_SUCCESS
;
2138 /* CPU description section */
2140 #if (defined SLJIT_32BIT_ARCHITECTURE && SLJIT_32BIT_ARCHITECTURE)
2141 #define SLJIT_CPUINFO_PART1 " 32bit ("
2142 #elif (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
2143 #define SLJIT_CPUINFO_PART1 " 64bit ("
2145 #error "Internal error: CPU type info missing"
2148 #if (defined SLJIT_LITTLE_ENDIAN && SLJIT_LITTLE_ENDIAN)
2149 #define SLJIT_CPUINFO_PART2 "little endian + "
2150 #elif (defined SLJIT_BIG_ENDIAN && SLJIT_BIG_ENDIAN)
2151 #define SLJIT_CPUINFO_PART2 "big endian + "
2153 #error "Internal error: CPU type info missing"
2156 #if (defined SLJIT_UNALIGNED && SLJIT_UNALIGNED)
2157 #define SLJIT_CPUINFO_PART3 "unaligned)"
2159 #define SLJIT_CPUINFO_PART3 "aligned)"
2162 #define SLJIT_CPUINFO SLJIT_CPUINFO_PART1 SLJIT_CPUINFO_PART2 SLJIT_CPUINFO_PART3
2164 #if (defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86)
2165 # include "sljitNativeX86_common.c"
2166 #elif (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5)
2167 # include "sljitNativeARM_32.c"
2168 #elif (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7)
2169 # include "sljitNativeARM_32.c"
2170 #elif (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
2171 # include "sljitNativeARM_T2_32.c"
2172 #elif (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64)
2173 # include "sljitNativeARM_64.c"
2174 #elif (defined SLJIT_CONFIG_PPC && SLJIT_CONFIG_PPC)
2175 # include "sljitNativePPC_common.c"
2176 #elif (defined SLJIT_CONFIG_MIPS && SLJIT_CONFIG_MIPS)
2177 # include "sljitNativeMIPS_common.c"
2178 #elif (defined SLJIT_CONFIG_SPARC && SLJIT_CONFIG_SPARC)
2179 # include "sljitNativeSPARC_common.c"
2180 #elif (defined SLJIT_CONFIG_S390X && SLJIT_CONFIG_S390X)
2181 # include "sljitNativeS390X.c"
2184 #if !(defined SLJIT_CONFIG_MIPS && SLJIT_CONFIG_MIPS)
2186 SLJIT_API_FUNC_ATTRIBUTE
struct sljit_jump
* sljit_emit_cmp(struct sljit_compiler
*compiler
, sljit_s32 type
,
2187 sljit_s32 src1
, sljit_sw src1w
,
2188 sljit_s32 src2
, sljit_sw src2w
)
2190 /* Default compare for most architectures. */
2191 sljit_s32 flags
, tmp_src
, condition
;
2195 CHECK_PTR(check_sljit_emit_cmp(compiler
, type
, src1
, src1w
, src2
, src2w
));
2197 condition
= type
& 0xff;
2198 #if (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64)
2199 if ((condition
== SLJIT_EQUAL
|| condition
== SLJIT_NOT_EQUAL
)) {
2200 if ((src1
& SLJIT_IMM
) && !src1w
) {
2206 if ((src2
& SLJIT_IMM
) && !src2w
)
2207 return emit_cmp_to0(compiler
, type
, src1
, src1w
);
2211 if (SLJIT_UNLIKELY((src1
& SLJIT_IMM
) && !(src2
& SLJIT_IMM
))) {
2212 /* Immediate is preferred as second argument by most architectures. */
2213 switch (condition
) {
2215 condition
= SLJIT_GREATER
;
2217 case SLJIT_GREATER_EQUAL
:
2218 condition
= SLJIT_LESS_EQUAL
;
2221 condition
= SLJIT_LESS
;
2223 case SLJIT_LESS_EQUAL
:
2224 condition
= SLJIT_GREATER_EQUAL
;
2226 case SLJIT_SIG_LESS
:
2227 condition
= SLJIT_SIG_GREATER
;
2229 case SLJIT_SIG_GREATER_EQUAL
:
2230 condition
= SLJIT_SIG_LESS_EQUAL
;
2232 case SLJIT_SIG_GREATER
:
2233 condition
= SLJIT_SIG_LESS
;
2235 case SLJIT_SIG_LESS_EQUAL
:
2236 condition
= SLJIT_SIG_GREATER_EQUAL
;
2240 type
= condition
| (type
& (SLJIT_32
| SLJIT_REWRITABLE_JUMP
));
2249 if (condition
<= SLJIT_NOT_ZERO
)
2250 flags
= SLJIT_SET_Z
;
2252 flags
= condition
<< VARIABLE_FLAG_SHIFT
;
2254 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) \
2255 || (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
2256 compiler
->skip_checks
= 1;
2258 PTR_FAIL_IF(sljit_emit_op2u(compiler
,
2259 SLJIT_SUB
| flags
| (type
& SLJIT_32
), src1
, src1w
, src2
, src2w
));
2260 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) \
2261 || (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
2262 compiler
->skip_checks
= 1;
2264 return sljit_emit_jump(compiler
, condition
| (type
& (SLJIT_REWRITABLE_JUMP
| SLJIT_32
)));
2267 #endif /* !SLJIT_CONFIG_MIPS */
2269 #if (defined SLJIT_CONFIG_ARM && SLJIT_CONFIG_ARM)
2271 SLJIT_API_FUNC_ATTRIBUTE sljit_s32
sljit_cmp_info(sljit_s32 type
)
2273 if (type
< SLJIT_UNORDERED
|| type
> SLJIT_ORDERED_LESS_EQUAL
)
2277 case SLJIT_UNORDERED_OR_EQUAL
:
2278 case SLJIT_ORDERED_NOT_EQUAL
:
2285 #endif /* SLJIT_CONFIG_ARM */
2287 SLJIT_API_FUNC_ATTRIBUTE
struct sljit_jump
* sljit_emit_fcmp(struct sljit_compiler
*compiler
, sljit_s32 type
,
2288 sljit_s32 src1
, sljit_sw src1w
,
2289 sljit_s32 src2
, sljit_sw src2w
)
2292 CHECK_PTR(check_sljit_emit_fcmp(compiler
, type
, src1
, src1w
, src2
, src2w
));
2294 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) \
2295 || (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
2296 compiler
->skip_checks
= 1;
2298 sljit_emit_fop1(compiler
, SLJIT_CMP_F64
| ((type
& 0xff) << VARIABLE_FLAG_SHIFT
) | (type
& SLJIT_32
), src1
, src1w
, src2
, src2w
);
2300 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) \
2301 || (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
2302 compiler
->skip_checks
= 1;
2304 return sljit_emit_jump(compiler
, type
);
2307 #if !(defined SLJIT_CONFIG_ARM_32 && SLJIT_CONFIG_ARM_32) \
2308 && !(defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) \
2309 && !(defined SLJIT_CONFIG_PPC && SLJIT_CONFIG_PPC)
2311 SLJIT_API_FUNC_ATTRIBUTE sljit_s32
sljit_emit_mem(struct sljit_compiler
*compiler
, sljit_s32 type
,
2313 sljit_s32 mem
, sljit_sw memw
)
2315 SLJIT_UNUSED_ARG(compiler
);
2316 SLJIT_UNUSED_ARG(type
);
2317 SLJIT_UNUSED_ARG(reg
);
2318 SLJIT_UNUSED_ARG(mem
);
2319 SLJIT_UNUSED_ARG(memw
);
2322 CHECK(check_sljit_emit_mem(compiler
, type
, reg
, mem
, memw
));
2324 return SLJIT_ERR_UNSUPPORTED
;
2329 #if !(defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) \
2330 && !(defined SLJIT_CONFIG_PPC && SLJIT_CONFIG_PPC)
2332 SLJIT_API_FUNC_ATTRIBUTE sljit_s32
sljit_emit_fmem(struct sljit_compiler
*compiler
, sljit_s32 type
,
2334 sljit_s32 mem
, sljit_sw memw
)
2336 SLJIT_UNUSED_ARG(compiler
);
2337 SLJIT_UNUSED_ARG(type
);
2338 SLJIT_UNUSED_ARG(freg
);
2339 SLJIT_UNUSED_ARG(mem
);
2340 SLJIT_UNUSED_ARG(memw
);
2343 CHECK(check_sljit_emit_fmem(compiler
, type
, freg
, mem
, memw
));
2345 return SLJIT_ERR_UNSUPPORTED
;
2350 #if !(defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86) \
2351 && !(defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64)
2353 SLJIT_API_FUNC_ATTRIBUTE sljit_s32
sljit_get_local_base(struct sljit_compiler
*compiler
, sljit_s32 dst
, sljit_sw dstw
, sljit_sw offset
)
2356 CHECK(check_sljit_get_local_base(compiler
, dst
, dstw
, offset
));
2358 ADJUST_LOCAL_OFFSET(SLJIT_MEM1(SLJIT_SP
), offset
);
2359 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) \
2360 || (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
2361 compiler
->skip_checks
= 1;
2364 return sljit_emit_op2(compiler
, SLJIT_ADD
, dst
, dstw
, SLJIT_SP
, 0, SLJIT_IMM
, offset
);
2365 return sljit_emit_op1(compiler
, SLJIT_MOV
, dst
, dstw
, SLJIT_SP
, 0);
2370 #else /* SLJIT_CONFIG_UNSUPPORTED */
2372 /* Empty function bodies for those machines, which are not (yet) supported. */
2374 SLJIT_API_FUNC_ATTRIBUTE
const char* sljit_get_platform_name(void)
2376 return "unsupported";
2379 SLJIT_API_FUNC_ATTRIBUTE
struct sljit_compiler
* sljit_create_compiler(void *allocator_data
, void *exec_allocator_data
)
2381 SLJIT_UNUSED_ARG(allocator_data
);
2382 SLJIT_UNUSED_ARG(exec_allocator_data
);
2383 SLJIT_UNREACHABLE();
2387 SLJIT_API_FUNC_ATTRIBUTE
void sljit_free_compiler(struct sljit_compiler
*compiler
)
2389 SLJIT_UNUSED_ARG(compiler
);
2390 SLJIT_UNREACHABLE();
2393 SLJIT_API_FUNC_ATTRIBUTE
void sljit_set_compiler_memory_error(struct sljit_compiler
*compiler
)
2395 SLJIT_UNUSED_ARG(compiler
);
2396 SLJIT_UNREACHABLE();
2399 SLJIT_API_FUNC_ATTRIBUTE
void* sljit_alloc_memory(struct sljit_compiler
*compiler
, sljit_s32 size
)
2401 SLJIT_UNUSED_ARG(compiler
);
2402 SLJIT_UNUSED_ARG(size
);
2403 SLJIT_UNREACHABLE();
2407 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
2408 SLJIT_API_FUNC_ATTRIBUTE
void sljit_compiler_verbose(struct sljit_compiler
*compiler
, FILE* verbose
)
2410 SLJIT_UNUSED_ARG(compiler
);
2411 SLJIT_UNUSED_ARG(verbose
);
2412 SLJIT_UNREACHABLE();
2416 SLJIT_API_FUNC_ATTRIBUTE
void* sljit_generate_code(struct sljit_compiler
*compiler
)
2418 SLJIT_UNUSED_ARG(compiler
);
2419 SLJIT_UNREACHABLE();
2423 SLJIT_API_FUNC_ATTRIBUTE sljit_s32
sljit_has_cpu_feature(sljit_s32 feature_type
)
2425 SLJIT_UNUSED_ARG(feature_type
);
2426 SLJIT_UNREACHABLE();
2430 SLJIT_API_FUNC_ATTRIBUTE sljit_s32
sljit_cmp_info(sljit_s32 type
)
2432 SLJIT_UNUSED_ARG(type
);
2433 SLJIT_UNREACHABLE();
2437 SLJIT_API_FUNC_ATTRIBUTE
void sljit_free_code(void* code
, void *exec_allocator_data
)
2439 SLJIT_UNUSED_ARG(code
);
2440 SLJIT_UNUSED_ARG(exec_allocator_data
);
2441 SLJIT_UNREACHABLE();
2444 SLJIT_API_FUNC_ATTRIBUTE sljit_s32
sljit_emit_enter(struct sljit_compiler
*compiler
,
2445 sljit_s32 options
, sljit_s32 arg_types
, sljit_s32 scratches
, sljit_s32 saveds
,
2446 sljit_s32 fscratches
, sljit_s32 fsaveds
, sljit_s32 local_size
)
2448 SLJIT_UNUSED_ARG(compiler
);
2449 SLJIT_UNUSED_ARG(options
);
2450 SLJIT_UNUSED_ARG(arg_types
);
2451 SLJIT_UNUSED_ARG(scratches
);
2452 SLJIT_UNUSED_ARG(saveds
);
2453 SLJIT_UNUSED_ARG(fscratches
);
2454 SLJIT_UNUSED_ARG(fsaveds
);
2455 SLJIT_UNUSED_ARG(local_size
);
2456 SLJIT_UNREACHABLE();
2457 return SLJIT_ERR_UNSUPPORTED
;
2460 SLJIT_API_FUNC_ATTRIBUTE sljit_s32
sljit_set_context(struct sljit_compiler
*compiler
,
2461 sljit_s32 options
, sljit_s32 arg_types
, sljit_s32 scratches
, sljit_s32 saveds
,
2462 sljit_s32 fscratches
, sljit_s32 fsaveds
, sljit_s32 local_size
)
2464 SLJIT_UNUSED_ARG(compiler
);
2465 SLJIT_UNUSED_ARG(options
);
2466 SLJIT_UNUSED_ARG(arg_types
);
2467 SLJIT_UNUSED_ARG(scratches
);
2468 SLJIT_UNUSED_ARG(saveds
);
2469 SLJIT_UNUSED_ARG(fscratches
);
2470 SLJIT_UNUSED_ARG(fsaveds
);
2471 SLJIT_UNUSED_ARG(local_size
);
2472 SLJIT_UNREACHABLE();
2473 return SLJIT_ERR_UNSUPPORTED
;
2476 SLJIT_API_FUNC_ATTRIBUTE sljit_s32
sljit_emit_return(struct sljit_compiler
*compiler
, sljit_s32 op
, sljit_s32 src
, sljit_sw srcw
)
2478 SLJIT_UNUSED_ARG(compiler
);
2479 SLJIT_UNUSED_ARG(op
);
2480 SLJIT_UNUSED_ARG(src
);
2481 SLJIT_UNUSED_ARG(srcw
);
2482 SLJIT_UNREACHABLE();
2483 return SLJIT_ERR_UNSUPPORTED
;
2486 SLJIT_API_FUNC_ATTRIBUTE sljit_s32
sljit_emit_return_void(struct sljit_compiler
*compiler
)
2488 SLJIT_UNUSED_ARG(compiler
);
2489 SLJIT_UNREACHABLE();
2490 return SLJIT_ERR_UNSUPPORTED
;
2493 SLJIT_API_FUNC_ATTRIBUTE sljit_s32
sljit_emit_fast_enter(struct sljit_compiler
*compiler
, sljit_s32 dst
, sljit_sw dstw
)
2495 SLJIT_UNUSED_ARG(compiler
);
2496 SLJIT_UNUSED_ARG(dst
);
2497 SLJIT_UNUSED_ARG(dstw
);
2498 SLJIT_UNREACHABLE();
2499 return SLJIT_ERR_UNSUPPORTED
;
2502 SLJIT_API_FUNC_ATTRIBUTE sljit_s32
sljit_emit_op0(struct sljit_compiler
*compiler
, sljit_s32 op
)
2504 SLJIT_UNUSED_ARG(compiler
);
2505 SLJIT_UNUSED_ARG(op
);
2506 SLJIT_UNREACHABLE();
2507 return SLJIT_ERR_UNSUPPORTED
;
2510 SLJIT_API_FUNC_ATTRIBUTE sljit_s32
sljit_emit_op1(struct sljit_compiler
*compiler
, sljit_s32 op
,
2511 sljit_s32 dst
, sljit_sw dstw
,
2512 sljit_s32 src
, sljit_sw srcw
)
2514 SLJIT_UNUSED_ARG(compiler
);
2515 SLJIT_UNUSED_ARG(op
);
2516 SLJIT_UNUSED_ARG(dst
);
2517 SLJIT_UNUSED_ARG(dstw
);
2518 SLJIT_UNUSED_ARG(src
);
2519 SLJIT_UNUSED_ARG(srcw
);
2520 SLJIT_UNREACHABLE();
2521 return SLJIT_ERR_UNSUPPORTED
;
2524 SLJIT_API_FUNC_ATTRIBUTE sljit_s32
sljit_emit_op2(struct sljit_compiler
*compiler
, sljit_s32 op
,
2525 sljit_s32 dst
, sljit_sw dstw
,
2526 sljit_s32 src1
, sljit_sw src1w
,
2527 sljit_s32 src2
, sljit_sw src2w
)
2529 SLJIT_UNUSED_ARG(compiler
);
2530 SLJIT_UNUSED_ARG(op
);
2531 SLJIT_UNUSED_ARG(dst
);
2532 SLJIT_UNUSED_ARG(dstw
);
2533 SLJIT_UNUSED_ARG(src1
);
2534 SLJIT_UNUSED_ARG(src1w
);
2535 SLJIT_UNUSED_ARG(src2
);
2536 SLJIT_UNUSED_ARG(src2w
);
2537 SLJIT_UNREACHABLE();
2538 return SLJIT_ERR_UNSUPPORTED
;
2541 SLJIT_API_FUNC_ATTRIBUTE sljit_s32
sljit_emit_op2u(struct sljit_compiler
*compiler
, sljit_s32 op
,
2542 sljit_s32 src1
, sljit_sw src1w
,
2543 sljit_s32 src2
, sljit_sw src2w
)
2545 SLJIT_UNUSED_ARG(compiler
);
2546 SLJIT_UNUSED_ARG(op
);
2547 SLJIT_UNUSED_ARG(src1
);
2548 SLJIT_UNUSED_ARG(src1w
);
2549 SLJIT_UNUSED_ARG(src2
);
2550 SLJIT_UNUSED_ARG(src2w
);
2551 SLJIT_UNREACHABLE();
2552 return SLJIT_ERR_UNSUPPORTED
;
2555 SLJIT_API_FUNC_ATTRIBUTE sljit_s32
sljit_emit_op_src(struct sljit_compiler
*compiler
, sljit_s32 op
,
2556 sljit_s32 src
, sljit_sw srcw
)
2558 SLJIT_UNUSED_ARG(compiler
);
2559 SLJIT_UNUSED_ARG(op
);
2560 SLJIT_UNUSED_ARG(src
);
2561 SLJIT_UNUSED_ARG(srcw
);
2562 SLJIT_UNREACHABLE();
2563 return SLJIT_ERR_UNSUPPORTED
;
2566 SLJIT_API_FUNC_ATTRIBUTE sljit_s32
sljit_get_register_index(sljit_s32 reg
)
2568 SLJIT_UNREACHABLE();
2572 SLJIT_API_FUNC_ATTRIBUTE sljit_s32
sljit_emit_op_custom(struct sljit_compiler
*compiler
,
2573 void *instruction
, sljit_u32 size
)
2575 SLJIT_UNUSED_ARG(compiler
);
2576 SLJIT_UNUSED_ARG(instruction
);
2577 SLJIT_UNUSED_ARG(size
);
2578 SLJIT_UNREACHABLE();
2579 return SLJIT_ERR_UNSUPPORTED
;
2582 SLJIT_API_FUNC_ATTRIBUTE
void sljit_set_current_flags(struct sljit_compiler
*compiler
, sljit_s32 current_flags
)
2584 SLJIT_UNUSED_ARG(compiler
);
2585 SLJIT_UNUSED_ARG(current_flags
);
2588 SLJIT_API_FUNC_ATTRIBUTE sljit_s32
sljit_emit_fop1(struct sljit_compiler
*compiler
, sljit_s32 op
,
2589 sljit_s32 dst
, sljit_sw dstw
,
2590 sljit_s32 src
, sljit_sw srcw
)
2592 SLJIT_UNUSED_ARG(compiler
);
2593 SLJIT_UNUSED_ARG(op
);
2594 SLJIT_UNUSED_ARG(dst
);
2595 SLJIT_UNUSED_ARG(dstw
);
2596 SLJIT_UNUSED_ARG(src
);
2597 SLJIT_UNUSED_ARG(srcw
);
2598 SLJIT_UNREACHABLE();
2599 return SLJIT_ERR_UNSUPPORTED
;
2602 SLJIT_API_FUNC_ATTRIBUTE sljit_s32
sljit_emit_fop2(struct sljit_compiler
*compiler
, sljit_s32 op
,
2603 sljit_s32 dst
, sljit_sw dstw
,
2604 sljit_s32 src1
, sljit_sw src1w
,
2605 sljit_s32 src2
, sljit_sw src2w
)
2607 SLJIT_UNUSED_ARG(compiler
);
2608 SLJIT_UNUSED_ARG(op
);
2609 SLJIT_UNUSED_ARG(dst
);
2610 SLJIT_UNUSED_ARG(dstw
);
2611 SLJIT_UNUSED_ARG(src1
);
2612 SLJIT_UNUSED_ARG(src1w
);
2613 SLJIT_UNUSED_ARG(src2
);
2614 SLJIT_UNUSED_ARG(src2w
);
2615 SLJIT_UNREACHABLE();
2616 return SLJIT_ERR_UNSUPPORTED
;
2619 SLJIT_API_FUNC_ATTRIBUTE
struct sljit_label
* sljit_emit_label(struct sljit_compiler
*compiler
)
2621 SLJIT_UNUSED_ARG(compiler
);
2622 SLJIT_UNREACHABLE();
2626 SLJIT_API_FUNC_ATTRIBUTE
struct sljit_jump
* sljit_emit_jump(struct sljit_compiler
*compiler
, sljit_s32 type
)
2628 SLJIT_UNUSED_ARG(compiler
);
2629 SLJIT_UNUSED_ARG(type
);
2630 SLJIT_UNREACHABLE();
2634 SLJIT_API_FUNC_ATTRIBUTE
struct sljit_jump
* sljit_emit_call(struct sljit_compiler
*compiler
, sljit_s32 type
,
2635 sljit_s32 arg_types
)
2637 SLJIT_UNUSED_ARG(compiler
);
2638 SLJIT_UNUSED_ARG(type
);
2639 SLJIT_UNUSED_ARG(arg_types
);
2640 SLJIT_UNREACHABLE();
2644 SLJIT_API_FUNC_ATTRIBUTE
struct sljit_jump
* sljit_emit_cmp(struct sljit_compiler
*compiler
, sljit_s32 type
,
2645 sljit_s32 src1
, sljit_sw src1w
,
2646 sljit_s32 src2
, sljit_sw src2w
)
2648 SLJIT_UNUSED_ARG(compiler
);
2649 SLJIT_UNUSED_ARG(type
);
2650 SLJIT_UNUSED_ARG(src1
);
2651 SLJIT_UNUSED_ARG(src1w
);
2652 SLJIT_UNUSED_ARG(src2
);
2653 SLJIT_UNUSED_ARG(src2w
);
2654 SLJIT_UNREACHABLE();
2658 SLJIT_API_FUNC_ATTRIBUTE
struct sljit_jump
* sljit_emit_fcmp(struct sljit_compiler
*compiler
, sljit_s32 type
,
2659 sljit_s32 src1
, sljit_sw src1w
,
2660 sljit_s32 src2
, sljit_sw src2w
)
2662 SLJIT_UNUSED_ARG(compiler
);
2663 SLJIT_UNUSED_ARG(type
);
2664 SLJIT_UNUSED_ARG(src1
);
2665 SLJIT_UNUSED_ARG(src1w
);
2666 SLJIT_UNUSED_ARG(src2
);
2667 SLJIT_UNUSED_ARG(src2w
);
2668 SLJIT_UNREACHABLE();
2672 SLJIT_API_FUNC_ATTRIBUTE
void sljit_set_label(struct sljit_jump
*jump
, struct sljit_label
* label
)
2674 SLJIT_UNUSED_ARG(jump
);
2675 SLJIT_UNUSED_ARG(label
);
2676 SLJIT_UNREACHABLE();
2679 SLJIT_API_FUNC_ATTRIBUTE
void sljit_set_target(struct sljit_jump
*jump
, sljit_uw target
)
2681 SLJIT_UNUSED_ARG(jump
);
2682 SLJIT_UNUSED_ARG(target
);
2683 SLJIT_UNREACHABLE();
2686 SLJIT_API_FUNC_ATTRIBUTE
void sljit_set_put_label(struct sljit_put_label
*put_label
, struct sljit_label
*label
)
2688 SLJIT_UNUSED_ARG(put_label
);
2689 SLJIT_UNUSED_ARG(label
);
2690 SLJIT_UNREACHABLE();
2693 SLJIT_API_FUNC_ATTRIBUTE sljit_s32
sljit_emit_ijump(struct sljit_compiler
*compiler
, sljit_s32 type
, sljit_s32 src
, sljit_sw srcw
)
2695 SLJIT_UNUSED_ARG(compiler
);
2696 SLJIT_UNUSED_ARG(type
);
2697 SLJIT_UNUSED_ARG(src
);
2698 SLJIT_UNUSED_ARG(srcw
);
2699 SLJIT_UNREACHABLE();
2700 return SLJIT_ERR_UNSUPPORTED
;
2703 SLJIT_API_FUNC_ATTRIBUTE sljit_s32
sljit_emit_icall(struct sljit_compiler
*compiler
, sljit_s32 type
,
2704 sljit_s32 arg_types
,
2705 sljit_s32 src
, sljit_sw srcw
)
2707 SLJIT_UNUSED_ARG(compiler
);
2708 SLJIT_UNUSED_ARG(type
);
2709 SLJIT_UNUSED_ARG(arg_types
);
2710 SLJIT_UNUSED_ARG(src
);
2711 SLJIT_UNUSED_ARG(srcw
);
2712 SLJIT_UNREACHABLE();
2713 return SLJIT_ERR_UNSUPPORTED
;
2716 SLJIT_API_FUNC_ATTRIBUTE sljit_s32
sljit_emit_op_flags(struct sljit_compiler
*compiler
, sljit_s32 op
,
2717 sljit_s32 dst
, sljit_sw dstw
,
2720 SLJIT_UNUSED_ARG(compiler
);
2721 SLJIT_UNUSED_ARG(op
);
2722 SLJIT_UNUSED_ARG(dst
);
2723 SLJIT_UNUSED_ARG(dstw
);
2724 SLJIT_UNUSED_ARG(type
);
2725 SLJIT_UNREACHABLE();
2726 return SLJIT_ERR_UNSUPPORTED
;
2729 SLJIT_API_FUNC_ATTRIBUTE sljit_s32
sljit_emit_cmov(struct sljit_compiler
*compiler
, sljit_s32 type
,
2731 sljit_s32 src
, sljit_sw srcw
)
2733 SLJIT_UNUSED_ARG(compiler
);
2734 SLJIT_UNUSED_ARG(type
);
2735 SLJIT_UNUSED_ARG(dst_reg
);
2736 SLJIT_UNUSED_ARG(src
);
2737 SLJIT_UNUSED_ARG(srcw
);
2738 SLJIT_UNREACHABLE();
2739 return SLJIT_ERR_UNSUPPORTED
;
2742 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
)
2744 SLJIT_UNUSED_ARG(compiler
);
2745 SLJIT_UNUSED_ARG(type
);
2746 SLJIT_UNUSED_ARG(reg
);
2747 SLJIT_UNUSED_ARG(mem
);
2748 SLJIT_UNUSED_ARG(memw
);
2749 SLJIT_UNREACHABLE();
2750 return SLJIT_ERR_UNSUPPORTED
;
2753 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
)
2755 SLJIT_UNUSED_ARG(compiler
);
2756 SLJIT_UNUSED_ARG(type
);
2757 SLJIT_UNUSED_ARG(freg
);
2758 SLJIT_UNUSED_ARG(mem
);
2759 SLJIT_UNUSED_ARG(memw
);
2760 SLJIT_UNREACHABLE();
2761 return SLJIT_ERR_UNSUPPORTED
;
2764 SLJIT_API_FUNC_ATTRIBUTE sljit_s32
sljit_get_local_base(struct sljit_compiler
*compiler
, sljit_s32 dst
, sljit_sw dstw
, sljit_sw offset
)
2766 SLJIT_UNUSED_ARG(compiler
);
2767 SLJIT_UNUSED_ARG(dst
);
2768 SLJIT_UNUSED_ARG(dstw
);
2769 SLJIT_UNUSED_ARG(offset
);
2770 SLJIT_UNREACHABLE();
2771 return SLJIT_ERR_UNSUPPORTED
;
2774 SLJIT_API_FUNC_ATTRIBUTE
struct sljit_const
* sljit_emit_const(struct sljit_compiler
*compiler
, sljit_s32 dst
, sljit_sw dstw
, sljit_sw initval
)
2776 SLJIT_UNUSED_ARG(compiler
);
2777 SLJIT_UNUSED_ARG(dst
);
2778 SLJIT_UNUSED_ARG(dstw
);
2779 SLJIT_UNUSED_ARG(initval
);
2780 SLJIT_UNREACHABLE();
2784 SLJIT_API_FUNC_ATTRIBUTE
struct sljit_put_label
* sljit_emit_put_label(struct sljit_compiler
*compiler
, sljit_s32 dst
, sljit_sw dstw
)
2786 SLJIT_UNUSED_ARG(compiler
);
2787 SLJIT_UNUSED_ARG(dst
);
2788 SLJIT_UNUSED_ARG(dstw
);
2792 SLJIT_API_FUNC_ATTRIBUTE
void sljit_set_jump_addr(sljit_uw addr
, sljit_uw new_target
, sljit_sw executable_offset
)
2794 SLJIT_UNUSED_ARG(addr
);
2795 SLJIT_UNUSED_ARG(new_target
);
2796 SLJIT_UNUSED_ARG(executable_offset
);
2797 SLJIT_UNREACHABLE();
2800 SLJIT_API_FUNC_ATTRIBUTE
void sljit_set_const(sljit_uw addr
, sljit_sw new_constant
, sljit_sw executable_offset
)
2802 SLJIT_UNUSED_ARG(addr
);
2803 SLJIT_UNUSED_ARG(new_constant
);
2804 SLJIT_UNUSED_ARG(executable_offset
);
2805 SLJIT_UNREACHABLE();
2808 #endif /* !SLJIT_CONFIG_UNSUPPORTED */