/[pcre2]/code/trunk/src/sljit/sljitLir.c
ViewVC logotype

Contents of /code/trunk/src/sljit/sljitLir.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 652 - (show annotations)
Thu Jan 12 09:32:15 2017 UTC (4 days, 5 hours ago) by zherczeg
File MIME type: text/plain
File size: 65941 byte(s)
JIT compiler update. Patch insipred by Christian Persch.
1 /*
2 * Stack-less Just-In-Time compiler
3 *
4 * Copyright 2009-2012 Zoltan Herczeg (hzmester@freemail.hu). All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without modification, are
7 * permitted provided that the following conditions are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright notice, this list of
10 * conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
13 * of conditions and the following disclaimer in the documentation and/or other materials
14 * provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND CONTRIBUTORS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19 * SHALL THE COPYRIGHT HOLDER(S) OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
21 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
22 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
24 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27 #include "sljitLir.h"
28
29 #if !(defined SLJIT_STD_MACROS_DEFINED && SLJIT_STD_MACROS_DEFINED)
30
31 /* These libraries are needed for the macros below. */
32 #include <stdlib.h>
33 #include <string.h>
34
35 #endif /* SLJIT_STD_MACROS_DEFINED */
36
37 #define CHECK_ERROR() \
38 do { \
39 if (SLJIT_UNLIKELY(compiler->error)) \
40 return compiler->error; \
41 } while (0)
42
43 #define CHECK_ERROR_PTR() \
44 do { \
45 if (SLJIT_UNLIKELY(compiler->error)) \
46 return NULL; \
47 } while (0)
48
49 #define FAIL_IF(expr) \
50 do { \
51 if (SLJIT_UNLIKELY(expr)) \
52 return compiler->error; \
53 } while (0)
54
55 #define PTR_FAIL_IF(expr) \
56 do { \
57 if (SLJIT_UNLIKELY(expr)) \
58 return NULL; \
59 } while (0)
60
61 #define FAIL_IF_NULL(ptr) \
62 do { \
63 if (SLJIT_UNLIKELY(!(ptr))) { \
64 compiler->error = SLJIT_ERR_ALLOC_FAILED; \
65 return SLJIT_ERR_ALLOC_FAILED; \
66 } \
67 } while (0)
68
69 #define PTR_FAIL_IF_NULL(ptr) \
70 do { \
71 if (SLJIT_UNLIKELY(!(ptr))) { \
72 compiler->error = SLJIT_ERR_ALLOC_FAILED; \
73 return NULL; \
74 } \
75 } while (0)
76
77 #define PTR_FAIL_WITH_EXEC_IF(ptr) \
78 do { \
79 if (SLJIT_UNLIKELY(!(ptr))) { \
80 compiler->error = SLJIT_ERR_EX_ALLOC_FAILED; \
81 return NULL; \
82 } \
83 } while (0)
84
85 #if !(defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
86
87 #define GET_OPCODE(op) \
88 ((op) & ~(SLJIT_I32_OP | SLJIT_SET_E | SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_O | SLJIT_SET_C | SLJIT_KEEP_FLAGS))
89
90 #define GET_FLAGS(op) \
91 ((op) & (SLJIT_SET_E | SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_O | SLJIT_SET_C))
92
93 #define GET_ALL_FLAGS(op) \
94 ((op) & (SLJIT_I32_OP | SLJIT_SET_E | SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_O | SLJIT_SET_C | SLJIT_KEEP_FLAGS))
95
96 #define TYPE_CAST_NEEDED(op) \
97 (((op) >= SLJIT_MOV_U8 && (op) <= SLJIT_MOV_S16) || ((op) >= SLJIT_MOVU_U8 && (op) <= SLJIT_MOVU_S16))
98
99 #define BUF_SIZE 4096
100
101 #if (defined SLJIT_32BIT_ARCHITECTURE && SLJIT_32BIT_ARCHITECTURE)
102 #define ABUF_SIZE 2048
103 #else
104 #define ABUF_SIZE 4096
105 #endif
106
107 /* Parameter parsing. */
108 #define REG_MASK 0x3f
109 #define OFFS_REG(reg) (((reg) >> 8) & REG_MASK)
110 #define OFFS_REG_MASK (REG_MASK << 8)
111 #define TO_OFFS_REG(reg) ((reg) << 8)
112 /* When reg cannot be unused. */
113 #define FAST_IS_REG(reg) ((reg) <= REG_MASK)
114 /* When reg can be unused. */
115 #define SLOW_IS_REG(reg) ((reg) > 0 && (reg) <= REG_MASK)
116
117 /* Jump flags. */
118 #define JUMP_LABEL 0x1
119 #define JUMP_ADDR 0x2
120 /* SLJIT_REWRITABLE_JUMP is 0x1000. */
121
122 #if (defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86)
123 # define PATCH_MB 0x4
124 # define PATCH_MW 0x8
125 #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
126 # define PATCH_MD 0x10
127 #endif
128 #endif
129
130 #if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) || (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7)
131 # define IS_BL 0x4
132 # define PATCH_B 0x8
133 #endif
134
135 #if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5)
136 # define CPOOL_SIZE 512
137 #endif
138
139 #if (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
140 # define IS_COND 0x04
141 # define IS_BL 0x08
142 /* conditional + imm8 */
143 # define PATCH_TYPE1 0x10
144 /* conditional + imm20 */
145 # define PATCH_TYPE2 0x20
146 /* IT + imm24 */
147 # define PATCH_TYPE3 0x30
148 /* imm11 */
149 # define PATCH_TYPE4 0x40
150 /* imm24 */
151 # define PATCH_TYPE5 0x50
152 /* BL + imm24 */
153 # define PATCH_BL 0x60
154 /* 0xf00 cc code for branches */
155 #endif
156
157 #if (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64)
158 # define IS_COND 0x004
159 # define IS_CBZ 0x008
160 # define IS_BL 0x010
161 # define PATCH_B 0x020
162 # define PATCH_COND 0x040
163 # define PATCH_ABS48 0x080
164 # define PATCH_ABS64 0x100
165 #endif
166
167 #if (defined SLJIT_CONFIG_PPC && SLJIT_CONFIG_PPC)
168 # define IS_COND 0x004
169 # define IS_CALL 0x008
170 # define PATCH_B 0x010
171 # define PATCH_ABS_B 0x020
172 #if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
173 # define PATCH_ABS32 0x040
174 # define PATCH_ABS48 0x080
175 #endif
176 # define REMOVE_COND 0x100
177 #endif
178
179 #if (defined SLJIT_CONFIG_MIPS && SLJIT_CONFIG_MIPS)
180 # define IS_MOVABLE 0x004
181 # define IS_JAL 0x008
182 # define IS_CALL 0x010
183 # define IS_BIT26_COND 0x020
184 # define IS_BIT16_COND 0x040
185
186 # define IS_COND (IS_BIT26_COND | IS_BIT16_COND)
187
188 # define PATCH_B 0x080
189 # define PATCH_J 0x100
190
191 #if (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64)
192 # define PATCH_ABS32 0x200
193 # define PATCH_ABS48 0x400
194 #endif
195
196 /* instruction types */
197 # define MOVABLE_INS 0
198 /* 1 - 31 last destination register */
199 /* no destination (i.e: store) */
200 # define UNMOVABLE_INS 32
201 /* FPU status register */
202 # define FCSR_FCC 33
203 #endif
204
205 #if (defined SLJIT_CONFIG_TILEGX && SLJIT_CONFIG_TILEGX)
206 # define IS_JAL 0x04
207 # define IS_COND 0x08
208
209 # define PATCH_B 0x10
210 # define PATCH_J 0x20
211 #endif
212
213 #if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
214 # define IS_MOVABLE 0x04
215 # define IS_COND 0x08
216 # define IS_CALL 0x10
217
218 # define PATCH_B 0x20
219 # define PATCH_CALL 0x40
220
221 /* instruction types */
222 # define MOVABLE_INS 0
223 /* 1 - 31 last destination register */
224 /* no destination (i.e: store) */
225 # define UNMOVABLE_INS 32
226
227 # define DST_INS_MASK 0xff
228
229 /* ICC_SET is the same as SET_FLAGS. */
230 # define ICC_IS_SET (1 << 23)
231 # define FCC_IS_SET (1 << 24)
232 #endif
233
234 /* Stack management. */
235
236 #define GET_SAVED_REGISTERS_SIZE(scratches, saveds, extra) \
237 (((scratches < SLJIT_NUMBER_OF_SCRATCH_REGISTERS ? 0 : (scratches - SLJIT_NUMBER_OF_SCRATCH_REGISTERS)) + \
238 (saveds < SLJIT_NUMBER_OF_SAVED_REGISTERS ? saveds : SLJIT_NUMBER_OF_SAVED_REGISTERS) + \
239 extra) * sizeof(sljit_sw))
240
241 #define ADJUST_LOCAL_OFFSET(p, i) \
242 if ((p) == (SLJIT_MEM1(SLJIT_SP))) \
243 (i) += SLJIT_LOCALS_OFFSET;
244
245 #endif /* !(defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED) */
246
247 /* Utils can still be used even if SLJIT_CONFIG_UNSUPPORTED is set. */
248 #include "sljitUtils.c"
249
250 #if !(defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
251
252 #if (defined SLJIT_EXECUTABLE_ALLOCATOR && SLJIT_EXECUTABLE_ALLOCATOR)
253
254 #if (defined SLJIT_PROT_EXECUTABLE_ALLOCATOR && SLJIT_PROT_EXECUTABLE_ALLOCATOR)
255 #include "sljitProtExecAllocator.c"
256 #else
257 #include "sljitExecAllocator.c"
258 #endif
259
260 #endif
261
262 #if (defined SLJIT_PROT_EXECUTABLE_ALLOCATOR && SLJIT_PROT_EXECUTABLE_ALLOCATOR)
263 #define SLJIT_ADD_EXEC_OFFSET(ptr, exec_offset) ((sljit_u8 *)(ptr) + (exec_offset))
264 #else
265 #define SLJIT_ADD_EXEC_OFFSET(ptr, exec_offset) ((sljit_u8 *)(ptr))
266 #endif
267
268 /* Argument checking features. */
269
270 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
271
272 /* Returns with error when an invalid argument is passed. */
273
274 #define CHECK_ARGUMENT(x) \
275 do { \
276 if (SLJIT_UNLIKELY(!(x))) \
277 return 1; \
278 } while (0)
279
280 #define CHECK_RETURN_TYPE sljit_s32
281 #define CHECK_RETURN_OK return 0
282
283 #define CHECK(x) \
284 do { \
285 if (SLJIT_UNLIKELY(x)) { \
286 compiler->error = SLJIT_ERR_BAD_ARGUMENT; \
287 return SLJIT_ERR_BAD_ARGUMENT; \
288 } \
289 } while (0)
290
291 #define CHECK_PTR(x) \
292 do { \
293 if (SLJIT_UNLIKELY(x)) { \
294 compiler->error = SLJIT_ERR_BAD_ARGUMENT; \
295 return NULL; \
296 } \
297 } while (0)
298
299 #define CHECK_REG_INDEX(x) \
300 do { \
301 if (SLJIT_UNLIKELY(x)) { \
302 return -2; \
303 } \
304 } while (0)
305
306 #elif (defined SLJIT_DEBUG && SLJIT_DEBUG)
307
308 /* Assertion failure occures if an invalid argument is passed. */
309 #undef SLJIT_ARGUMENT_CHECKS
310 #define SLJIT_ARGUMENT_CHECKS 1
311
312 #define CHECK_ARGUMENT(x) SLJIT_ASSERT(x)
313 #define CHECK_RETURN_TYPE void
314 #define CHECK_RETURN_OK return
315 #define CHECK(x) x
316 #define CHECK_PTR(x) x
317 #define CHECK_REG_INDEX(x) x
318
319 #elif (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
320
321 /* Arguments are not checked. */
322 #define CHECK_RETURN_TYPE void
323 #define CHECK_RETURN_OK return
324 #define CHECK(x) x
325 #define CHECK_PTR(x) x
326 #define CHECK_REG_INDEX(x) x
327
328 #else
329
330 /* Arguments are not checked. */
331 #define CHECK(x)
332 #define CHECK_PTR(x)
333 #define CHECK_REG_INDEX(x)
334
335 #endif /* SLJIT_ARGUMENT_CHECKS */
336
337 /* --------------------------------------------------------------------- */
338 /* Public functions */
339 /* --------------------------------------------------------------------- */
340
341 #if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) || (defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86)
342 #define SLJIT_NEEDS_COMPILER_INIT 1
343 static sljit_s32 compiler_initialized = 0;
344 /* A thread safe initialization. */
345 static void init_compiler(void);
346 #endif
347
348 SLJIT_API_FUNC_ATTRIBUTE struct sljit_compiler* sljit_create_compiler(void *allocator_data)
349 {
350 struct sljit_compiler *compiler = (struct sljit_compiler*)SLJIT_MALLOC(sizeof(struct sljit_compiler), allocator_data);
351 if (!compiler)
352 return NULL;
353 SLJIT_ZEROMEM(compiler, sizeof(struct sljit_compiler));
354
355 SLJIT_COMPILE_ASSERT(
356 sizeof(sljit_s8) == 1 && sizeof(sljit_u8) == 1
357 && sizeof(sljit_s16) == 2 && sizeof(sljit_u16) == 2
358 && sizeof(sljit_s32) == 4 && sizeof(sljit_u32) == 4
359 && (sizeof(sljit_p) == 4 || sizeof(sljit_p) == 8)
360 && sizeof(sljit_p) <= sizeof(sljit_sw)
361 && (sizeof(sljit_sw) == 4 || sizeof(sljit_sw) == 8)
362 && (sizeof(sljit_uw) == 4 || sizeof(sljit_uw) == 8),
363 invalid_integer_types);
364 SLJIT_COMPILE_ASSERT(SLJIT_I32_OP == SLJIT_F32_OP,
365 int_op_and_single_op_must_be_the_same);
366 SLJIT_COMPILE_ASSERT(SLJIT_REWRITABLE_JUMP != SLJIT_F32_OP,
367 rewritable_jump_and_single_op_must_not_be_the_same);
368
369 /* Only the non-zero members must be set. */
370 compiler->error = SLJIT_SUCCESS;
371
372 compiler->allocator_data = allocator_data;
373 compiler->buf = (struct sljit_memory_fragment*)SLJIT_MALLOC(BUF_SIZE, allocator_data);
374 compiler->abuf = (struct sljit_memory_fragment*)SLJIT_MALLOC(ABUF_SIZE, allocator_data);
375
376 if (!compiler->buf || !compiler->abuf) {
377 if (compiler->buf)
378 SLJIT_FREE(compiler->buf, allocator_data);
379 if (compiler->abuf)
380 SLJIT_FREE(compiler->abuf, allocator_data);
381 SLJIT_FREE(compiler, allocator_data);
382 return NULL;
383 }
384
385 compiler->buf->next = NULL;
386 compiler->buf->used_size = 0;
387 compiler->abuf->next = NULL;
388 compiler->abuf->used_size = 0;
389
390 compiler->scratches = -1;
391 compiler->saveds = -1;
392 compiler->fscratches = -1;
393 compiler->fsaveds = -1;
394 compiler->local_size = -1;
395
396 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
397 compiler->args = -1;
398 #endif
399
400 #if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5)
401 compiler->cpool = (sljit_uw*)SLJIT_MALLOC(CPOOL_SIZE * sizeof(sljit_uw)
402 + CPOOL_SIZE * sizeof(sljit_u8), allocator_data);
403 if (!compiler->cpool) {
404 SLJIT_FREE(compiler->buf, allocator_data);
405 SLJIT_FREE(compiler->abuf, allocator_data);
406 SLJIT_FREE(compiler, allocator_data);
407 return NULL;
408 }
409 compiler->cpool_unique = (sljit_u8*)(compiler->cpool + CPOOL_SIZE);
410 compiler->cpool_diff = 0xffffffff;
411 #endif
412
413 #if (defined SLJIT_CONFIG_MIPS && SLJIT_CONFIG_MIPS)
414 compiler->delay_slot = UNMOVABLE_INS;
415 #endif
416
417 #if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
418 compiler->delay_slot = UNMOVABLE_INS;
419 #endif
420
421 #if (defined SLJIT_NEEDS_COMPILER_INIT && SLJIT_NEEDS_COMPILER_INIT)
422 if (!compiler_initialized) {
423 init_compiler();
424 compiler_initialized = 1;
425 }
426 #endif
427
428 return compiler;
429 }
430
431 SLJIT_API_FUNC_ATTRIBUTE void sljit_free_compiler(struct sljit_compiler *compiler)
432 {
433 struct sljit_memory_fragment *buf;
434 struct sljit_memory_fragment *curr;
435 void *allocator_data = compiler->allocator_data;
436 SLJIT_UNUSED_ARG(allocator_data);
437
438 buf = compiler->buf;
439 while (buf) {
440 curr = buf;
441 buf = buf->next;
442 SLJIT_FREE(curr, allocator_data);
443 }
444
445 buf = compiler->abuf;
446 while (buf) {
447 curr = buf;
448 buf = buf->next;
449 SLJIT_FREE(curr, allocator_data);
450 }
451
452 #if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5)
453 SLJIT_FREE(compiler->cpool, allocator_data);
454 #endif
455 SLJIT_FREE(compiler, allocator_data);
456 }
457
458 SLJIT_API_FUNC_ATTRIBUTE void sljit_set_compiler_memory_error(struct sljit_compiler *compiler)
459 {
460 if (compiler->error == SLJIT_SUCCESS)
461 compiler->error = SLJIT_ERR_ALLOC_FAILED;
462 }
463
464 #if (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
465 SLJIT_API_FUNC_ATTRIBUTE void sljit_free_code(void* code)
466 {
467 /* Remove thumb mode flag. */
468 SLJIT_FREE_EXEC((void*)((sljit_uw)code & ~0x1));
469 }
470 #elif (defined SLJIT_INDIRECT_CALL && SLJIT_INDIRECT_CALL)
471 SLJIT_API_FUNC_ATTRIBUTE void sljit_free_code(void* code)
472 {
473 /* Resolve indirection. */
474 code = (void*)(*(sljit_uw*)code);
475 SLJIT_FREE_EXEC(code);
476 }
477 #else
478 SLJIT_API_FUNC_ATTRIBUTE void sljit_free_code(void* code)
479 {
480 SLJIT_FREE_EXEC(code);
481 }
482 #endif
483
484 SLJIT_API_FUNC_ATTRIBUTE void sljit_set_label(struct sljit_jump *jump, struct sljit_label* label)
485 {
486 if (SLJIT_LIKELY(!!jump) && SLJIT_LIKELY(!!label)) {
487 jump->flags &= ~JUMP_ADDR;
488 jump->flags |= JUMP_LABEL;
489 jump->u.label = label;
490 }
491 }
492
493 SLJIT_API_FUNC_ATTRIBUTE void sljit_set_target(struct sljit_jump *jump, sljit_uw target)
494 {
495 if (SLJIT_LIKELY(!!jump)) {
496 jump->flags &= ~JUMP_LABEL;
497 jump->flags |= JUMP_ADDR;
498 jump->u.target = target;
499 }
500 }
501
502 /* --------------------------------------------------------------------- */
503 /* Private functions */
504 /* --------------------------------------------------------------------- */
505
506 static void* ensure_buf(struct sljit_compiler *compiler, sljit_uw size)
507 {
508 sljit_u8 *ret;
509 struct sljit_memory_fragment *new_frag;
510
511 SLJIT_ASSERT(size <= 256);
512 if (compiler->buf->used_size + size <= (BUF_SIZE - (sljit_uw)SLJIT_OFFSETOF(struct sljit_memory_fragment, memory))) {
513 ret = compiler->buf->memory + compiler->buf->used_size;
514 compiler->buf->used_size += size;
515 return ret;
516 }
517 new_frag = (struct sljit_memory_fragment*)SLJIT_MALLOC(BUF_SIZE, compiler->allocator_data);
518 PTR_FAIL_IF_NULL(new_frag);
519 new_frag->next = compiler->buf;
520 compiler->buf = new_frag;
521 new_frag->used_size = size;
522 return new_frag->memory;
523 }
524
525 static void* ensure_abuf(struct sljit_compiler *compiler, sljit_uw size)
526 {
527 sljit_u8 *ret;
528 struct sljit_memory_fragment *new_frag;
529
530 SLJIT_ASSERT(size <= 256);
531 if (compiler->abuf->used_size + size <= (ABUF_SIZE - (sljit_uw)SLJIT_OFFSETOF(struct sljit_memory_fragment, memory))) {
532 ret = compiler->abuf->memory + compiler->abuf->used_size;
533 compiler->abuf->used_size += size;
534 return ret;
535 }
536 new_frag = (struct sljit_memory_fragment*)SLJIT_MALLOC(ABUF_SIZE, compiler->allocator_data);
537 PTR_FAIL_IF_NULL(new_frag);
538 new_frag->next = compiler->abuf;
539 compiler->abuf = new_frag;
540 new_frag->used_size = size;
541 return new_frag->memory;
542 }
543
544 SLJIT_API_FUNC_ATTRIBUTE void* sljit_alloc_memory(struct sljit_compiler *compiler, sljit_s32 size)
545 {
546 CHECK_ERROR_PTR();
547
548 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
549 if (size <= 0 || size > 128)
550 return NULL;
551 size = (size + 7) & ~7;
552 #else
553 if (size <= 0 || size > 64)
554 return NULL;
555 size = (size + 3) & ~3;
556 #endif
557 return ensure_abuf(compiler, size);
558 }
559
560 static SLJIT_INLINE void reverse_buf(struct sljit_compiler *compiler)
561 {
562 struct sljit_memory_fragment *buf = compiler->buf;
563 struct sljit_memory_fragment *prev = NULL;
564 struct sljit_memory_fragment *tmp;
565
566 do {
567 tmp = buf->next;
568 buf->next = prev;
569 prev = buf;
570 buf = tmp;
571 } while (buf != NULL);
572
573 compiler->buf = prev;
574 }
575
576 static SLJIT_INLINE void set_emit_enter(struct sljit_compiler *compiler,
577 sljit_s32 options, sljit_s32 args, sljit_s32 scratches, sljit_s32 saveds,
578 sljit_s32 fscratches, sljit_s32 fsaveds, sljit_s32 local_size)
579 {
580 SLJIT_UNUSED_ARG(args);
581 SLJIT_UNUSED_ARG(local_size);
582
583 compiler->options = options;
584 compiler->scratches = scratches;
585 compiler->saveds = saveds;
586 compiler->fscratches = fscratches;
587 compiler->fsaveds = fsaveds;
588 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
589 compiler->logical_local_size = local_size;
590 #endif
591 }
592
593 static SLJIT_INLINE void set_set_context(struct sljit_compiler *compiler,
594 sljit_s32 options, sljit_s32 args, sljit_s32 scratches, sljit_s32 saveds,
595 sljit_s32 fscratches, sljit_s32 fsaveds, sljit_s32 local_size)
596 {
597 SLJIT_UNUSED_ARG(args);
598 SLJIT_UNUSED_ARG(local_size);
599
600 compiler->options = options;
601 compiler->scratches = scratches;
602 compiler->saveds = saveds;
603 compiler->fscratches = fscratches;
604 compiler->fsaveds = fsaveds;
605 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
606 compiler->logical_local_size = local_size;
607 #endif
608 }
609
610 static SLJIT_INLINE void set_label(struct sljit_label *label, struct sljit_compiler *compiler)
611 {
612 label->next = NULL;
613 label->size = compiler->size;
614 if (compiler->last_label)
615 compiler->last_label->next = label;
616 else
617 compiler->labels = label;
618 compiler->last_label = label;
619 }
620
621 static SLJIT_INLINE void set_jump(struct sljit_jump *jump, struct sljit_compiler *compiler, sljit_s32 flags)
622 {
623 jump->next = NULL;
624 jump->flags = flags;
625 if (compiler->last_jump)
626 compiler->last_jump->next = jump;
627 else
628 compiler->jumps = jump;
629 compiler->last_jump = jump;
630 }
631
632 static SLJIT_INLINE void set_const(struct sljit_const *const_, struct sljit_compiler *compiler)
633 {
634 const_->next = NULL;
635 const_->addr = compiler->size;
636 if (compiler->last_const)
637 compiler->last_const->next = const_;
638 else
639 compiler->consts = const_;
640 compiler->last_const = const_;
641 }
642
643 #define ADDRESSING_DEPENDS_ON(exp, reg) \
644 (((exp) & SLJIT_MEM) && (((exp) & REG_MASK) == reg || OFFS_REG(exp) == reg))
645
646 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
647 #define FUNCTION_CHECK_OP() \
648 CHECK_ARGUMENT(!GET_FLAGS(op) || !(op & SLJIT_KEEP_FLAGS)); \
649 switch (GET_OPCODE(op)) { \
650 case SLJIT_NOT: \
651 case SLJIT_CLZ: \
652 case SLJIT_AND: \
653 case SLJIT_OR: \
654 case SLJIT_XOR: \
655 case SLJIT_SHL: \
656 case SLJIT_LSHR: \
657 case SLJIT_ASHR: \
658 CHECK_ARGUMENT(!(op & (SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_O | SLJIT_SET_C))); \
659 break; \
660 case SLJIT_NEG: \
661 CHECK_ARGUMENT(!(op & (SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_C))); \
662 break; \
663 case SLJIT_MUL: \
664 CHECK_ARGUMENT(!(op & (SLJIT_SET_E | SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_C))); \
665 break; \
666 case SLJIT_ADD: \
667 CHECK_ARGUMENT(!(op & (SLJIT_SET_U | SLJIT_SET_S))); \
668 break; \
669 case SLJIT_SUB: \
670 break; \
671 case SLJIT_ADDC: \
672 case SLJIT_SUBC: \
673 CHECK_ARGUMENT(!(op & (SLJIT_SET_E | SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_O))); \
674 break; \
675 case SLJIT_BREAKPOINT: \
676 case SLJIT_NOP: \
677 case SLJIT_LMUL_UW: \
678 case SLJIT_LMUL_SW: \
679 case SLJIT_MOV: \
680 case SLJIT_MOV_U32: \
681 case SLJIT_MOV_P: \
682 case SLJIT_MOVU: \
683 case SLJIT_MOVU_U32: \
684 case SLJIT_MOVU_P: \
685 /* Nothing allowed */ \
686 CHECK_ARGUMENT(!(op & (SLJIT_I32_OP | SLJIT_SET_E | SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_O | SLJIT_SET_C | SLJIT_KEEP_FLAGS))); \
687 break; \
688 default: \
689 /* Only SLJIT_I32_OP or SLJIT_F32_OP is allowed. */ \
690 CHECK_ARGUMENT(!(op & (SLJIT_SET_E | SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_O | SLJIT_SET_C | SLJIT_KEEP_FLAGS))); \
691 break; \
692 }
693
694 #define FUNCTION_CHECK_FOP() \
695 CHECK_ARGUMENT(!GET_FLAGS(op) || !(op & SLJIT_KEEP_FLAGS)); \
696 switch (GET_OPCODE(op)) { \
697 case SLJIT_CMP_F64: \
698 CHECK_ARGUMENT(!(op & (SLJIT_SET_U | SLJIT_SET_O | SLJIT_SET_C | SLJIT_KEEP_FLAGS))); \
699 CHECK_ARGUMENT((op & (SLJIT_SET_E | SLJIT_SET_S))); \
700 break; \
701 default: \
702 /* Only SLJIT_I32_OP or SLJIT_F32_OP is allowed. */ \
703 CHECK_ARGUMENT(!(op & (SLJIT_SET_E | SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_O | SLJIT_SET_C | SLJIT_KEEP_FLAGS))); \
704 break; \
705 }
706
707 #define FUNCTION_CHECK_IS_REG(r) \
708 (((r) >= SLJIT_R0 && (r) < (SLJIT_R0 + compiler->scratches)) || \
709 ((r) > (SLJIT_S0 - compiler->saveds) && (r) <= SLJIT_S0))
710
711 #define FUNCTION_CHECK_IS_REG_OR_UNUSED(r) \
712 ((r) == SLJIT_UNUSED || \
713 ((r) >= SLJIT_R0 && (r) < (SLJIT_R0 + compiler->scratches)) || \
714 ((r) > (SLJIT_S0 - compiler->saveds) && (r) <= SLJIT_S0))
715
716 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
717 #define CHECK_NOT_VIRTUAL_REGISTER(p) \
718 CHECK_ARGUMENT((p) < SLJIT_R3 || (p) > SLJIT_R6);
719 #else
720 #define CHECK_NOT_VIRTUAL_REGISTER(p)
721 #endif
722
723 #define FUNCTION_CHECK_SRC(p, i) \
724 CHECK_ARGUMENT(compiler->scratches != -1 && compiler->saveds != -1); \
725 if (FUNCTION_CHECK_IS_REG(p)) \
726 CHECK_ARGUMENT((i) == 0); \
727 else if ((p) == SLJIT_IMM) \
728 ; \
729 else if ((p) == (SLJIT_MEM1(SLJIT_SP))) \
730 CHECK_ARGUMENT((i) >= 0 && (i) < compiler->logical_local_size); \
731 else { \
732 CHECK_ARGUMENT((p) & SLJIT_MEM); \
733 CHECK_ARGUMENT(FUNCTION_CHECK_IS_REG_OR_UNUSED((p) & REG_MASK)); \
734 CHECK_NOT_VIRTUAL_REGISTER((p) & REG_MASK); \
735 if ((p) & OFFS_REG_MASK) { \
736 CHECK_ARGUMENT(((p) & REG_MASK) != SLJIT_UNUSED); \
737 CHECK_ARGUMENT(FUNCTION_CHECK_IS_REG(OFFS_REG(p))); \
738 CHECK_NOT_VIRTUAL_REGISTER(OFFS_REG(p)); \
739 CHECK_ARGUMENT(!((i) & ~0x3)); \
740 } \
741 CHECK_ARGUMENT(!((p) & ~(SLJIT_MEM | SLJIT_IMM | REG_MASK | OFFS_REG_MASK))); \
742 }
743
744 #define FUNCTION_CHECK_DST(p, i) \
745 CHECK_ARGUMENT(compiler->scratches != -1 && compiler->saveds != -1); \
746 if (FUNCTION_CHECK_IS_REG_OR_UNUSED(p)) \
747 CHECK_ARGUMENT((i) == 0); \
748 else if ((p) == (SLJIT_MEM1(SLJIT_SP))) \
749 CHECK_ARGUMENT((i) >= 0 && (i) < compiler->logical_local_size); \
750 else { \
751 CHECK_ARGUMENT((p) & SLJIT_MEM); \
752 CHECK_ARGUMENT(FUNCTION_CHECK_IS_REG_OR_UNUSED((p) & REG_MASK)); \
753 CHECK_NOT_VIRTUAL_REGISTER((p) & REG_MASK); \
754 if ((p) & OFFS_REG_MASK) { \
755 CHECK_ARGUMENT(((p) & REG_MASK) != SLJIT_UNUSED); \
756 CHECK_ARGUMENT(FUNCTION_CHECK_IS_REG(OFFS_REG(p))); \
757 CHECK_NOT_VIRTUAL_REGISTER(OFFS_REG(p)); \
758 CHECK_ARGUMENT(!((i) & ~0x3)); \
759 } \
760 CHECK_ARGUMENT(!((p) & ~(SLJIT_MEM | SLJIT_IMM | REG_MASK | OFFS_REG_MASK))); \
761 }
762
763 #define FUNCTION_FCHECK(p, i) \
764 CHECK_ARGUMENT(compiler->fscratches != -1 && compiler->fsaveds != -1); \
765 if (((p) >= SLJIT_FR0 && (p) < (SLJIT_FR0 + compiler->fscratches)) || \
766 ((p) > (SLJIT_FS0 - compiler->fsaveds) && (p) <= SLJIT_FS0)) \
767 CHECK_ARGUMENT(i == 0); \
768 else if ((p) == (SLJIT_MEM1(SLJIT_SP))) \
769 CHECK_ARGUMENT((i) >= 0 && (i) < compiler->logical_local_size); \
770 else { \
771 CHECK_ARGUMENT((p) & SLJIT_MEM); \
772 CHECK_ARGUMENT(FUNCTION_CHECK_IS_REG_OR_UNUSED((p) & REG_MASK)); \
773 CHECK_NOT_VIRTUAL_REGISTER((p) & REG_MASK); \
774 if ((p) & OFFS_REG_MASK) { \
775 CHECK_ARGUMENT(((p) & REG_MASK) != SLJIT_UNUSED); \
776 CHECK_ARGUMENT(FUNCTION_CHECK_IS_REG(OFFS_REG(p))); \
777 CHECK_NOT_VIRTUAL_REGISTER(OFFS_REG(p)); \
778 CHECK_ARGUMENT(((p) & OFFS_REG_MASK) != TO_OFFS_REG(SLJIT_SP) && !(i & ~0x3)); \
779 } \
780 CHECK_ARGUMENT(!((p) & ~(SLJIT_MEM | SLJIT_IMM | REG_MASK | OFFS_REG_MASK))); \
781 }
782
783 #define FUNCTION_CHECK_OP1() \
784 if (GET_OPCODE(op) >= SLJIT_MOVU && GET_OPCODE(op) <= SLJIT_MOVU_P) { \
785 CHECK_ARGUMENT(!(src & SLJIT_MEM) || (src & REG_MASK) != SLJIT_SP); \
786 CHECK_ARGUMENT(!(dst & SLJIT_MEM) || (dst & REG_MASK) != SLJIT_SP); \
787 if ((src & SLJIT_MEM) && (src & REG_MASK)) \
788 CHECK_ARGUMENT((dst & REG_MASK) != (src & REG_MASK) && OFFS_REG(dst) != (src & REG_MASK)); \
789 }
790
791 #endif /* SLJIT_ARGUMENT_CHECKS */
792
793 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
794
795 SLJIT_API_FUNC_ATTRIBUTE void sljit_compiler_verbose(struct sljit_compiler *compiler, FILE* verbose)
796 {
797 compiler->verbose = verbose;
798 }
799
800 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
801 #ifdef _WIN64
802 # define SLJIT_PRINT_D "I64"
803 #else
804 # define SLJIT_PRINT_D "l"
805 #endif
806 #else
807 # define SLJIT_PRINT_D ""
808 #endif
809
810 #define sljit_verbose_reg(compiler, r) \
811 do { \
812 if ((r) < (SLJIT_R0 + compiler->scratches)) \
813 fprintf(compiler->verbose, "r%d", (r) - SLJIT_R0); \
814 else \
815 fprintf(compiler->verbose, "s%d", SLJIT_NUMBER_OF_REGISTERS - (r)); \
816 } while (0)
817
818 #define sljit_verbose_param(compiler, p, i) \
819 if ((p) & SLJIT_IMM) \
820 fprintf(compiler->verbose, "#%" SLJIT_PRINT_D "d", (i)); \
821 else if ((p) & SLJIT_MEM) { \
822 if ((p) & REG_MASK) { \
823 fputc('[', compiler->verbose); \
824 sljit_verbose_reg(compiler, (p) & REG_MASK); \
825 if ((p) & OFFS_REG_MASK) { \
826 fprintf(compiler->verbose, " + "); \
827 sljit_verbose_reg(compiler, OFFS_REG(p)); \
828 if (i) \
829 fprintf(compiler->verbose, " * %d", 1 << (i)); \
830 } \
831 else if (i) \
832 fprintf(compiler->verbose, " + %" SLJIT_PRINT_D "d", (i)); \
833 fputc(']', compiler->verbose); \
834 } \
835 else \
836 fprintf(compiler->verbose, "[#%" SLJIT_PRINT_D "d]", (i)); \
837 } else if (p) \
838 sljit_verbose_reg(compiler, p); \
839 else \
840 fprintf(compiler->verbose, "unused");
841
842 #define sljit_verbose_fparam(compiler, p, i) \
843 if ((p) & SLJIT_MEM) { \
844 if ((p) & REG_MASK) { \
845 fputc('[', compiler->verbose); \
846 sljit_verbose_reg(compiler, (p) & REG_MASK); \
847 if ((p) & OFFS_REG_MASK) { \
848 fprintf(compiler->verbose, " + "); \
849 sljit_verbose_reg(compiler, OFFS_REG(p)); \
850 if (i) \
851 fprintf(compiler->verbose, "%d", 1 << (i)); \
852 } \
853 else if (i) \
854 fprintf(compiler->verbose, "%" SLJIT_PRINT_D "d", (i)); \
855 fputc(']', compiler->verbose); \
856 } \
857 else \
858 fprintf(compiler->verbose, "[#%" SLJIT_PRINT_D "d]", (i)); \
859 } \
860 else { \
861 if ((p) < (SLJIT_FR0 + compiler->fscratches)) \
862 fprintf(compiler->verbose, "fr%d", (p) - SLJIT_FR0); \
863 else \
864 fprintf(compiler->verbose, "fs%d", SLJIT_NUMBER_OF_FLOAT_REGISTERS - (p)); \
865 }
866
867 static const char* op0_names[] = {
868 (char*)"breakpoint", (char*)"nop", (char*)"lmul.uw", (char*)"lmul.sw",
869 (char*)"divmod.u", (char*)"divmod.s", (char*)"div.u", (char*)"div.s"
870 };
871
872 static const char* op1_names[] = {
873 (char*)"", (char*)".u8", (char*)".s8", (char*)".u16",
874 (char*)".s16", (char*)".u32", (char*)".s32", (char*)".p",
875 (char*)"", (char*)".u8", (char*)".s8", (char*)".u16",
876 (char*)".s16", (char*)".u32", (char*)".s32", (char*)".p",
877 (char*)"not", (char*)"neg", (char*)"clz",
878 };
879
880 static const char* op2_names[] = {
881 (char*)"add", (char*)"addc", (char*)"sub", (char*)"subc",
882 (char*)"mul", (char*)"and", (char*)"or", (char*)"xor",
883 (char*)"shl", (char*)"lshr", (char*)"ashr",
884 };
885
886 static const char* fop1_names[] = {
887 (char*)"mov", (char*)"conv", (char*)"conv", (char*)"conv",
888 (char*)"conv", (char*)"conv", (char*)"cmp", (char*)"neg",
889 (char*)"abs",
890 };
891
892 static const char* fop2_names[] = {
893 (char*)"add", (char*)"sub", (char*)"mul", (char*)"div"
894 };
895
896 #define JUMP_POSTFIX(type) \
897 ((type & 0xff) <= SLJIT_MUL_NOT_OVERFLOW ? ((type & SLJIT_I32_OP) ? "32" : "") \
898 : ((type & 0xff) <= SLJIT_ORDERED_F64 ? ((type & SLJIT_F32_OP) ? ".f32" : ".f64") : ""))
899
900 static char* jump_names[] = {
901 (char*)"equal", (char*)"not_equal",
902 (char*)"less", (char*)"greater_equal",
903 (char*)"greater", (char*)"less_equal",
904 (char*)"sig_less", (char*)"sig_greater_equal",
905 (char*)"sig_greater", (char*)"sig_less_equal",
906 (char*)"overflow", (char*)"not_overflow",
907 (char*)"mul_overflow", (char*)"mul_not_overflow",
908 (char*)"equal", (char*)"not_equal",
909 (char*)"less", (char*)"greater_equal",
910 (char*)"greater", (char*)"less_equal",
911 (char*)"unordered", (char*)"ordered",
912 (char*)"jump", (char*)"fast_call",
913 (char*)"call0", (char*)"call1", (char*)"call2", (char*)"call3"
914 };
915
916 #endif /* SLJIT_VERBOSE */
917
918 /* --------------------------------------------------------------------- */
919 /* Arch dependent */
920 /* --------------------------------------------------------------------- */
921
922 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS) \
923 || (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
924
925 static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_generate_code(struct sljit_compiler *compiler)
926 {
927 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
928 struct sljit_jump *jump;
929 #endif
930
931 SLJIT_UNUSED_ARG(compiler);
932
933 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
934 CHECK_ARGUMENT(compiler->size > 0);
935 jump = compiler->jumps;
936 while (jump) {
937 /* All jumps have target. */
938 CHECK_ARGUMENT(jump->flags & (JUMP_LABEL | JUMP_ADDR));
939 jump = jump->next;
940 }
941 #endif
942 CHECK_RETURN_OK;
943 }
944
945 static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_enter(struct sljit_compiler *compiler,
946 sljit_s32 options, sljit_s32 args, sljit_s32 scratches, sljit_s32 saveds,
947 sljit_s32 fscratches, sljit_s32 fsaveds, sljit_s32 local_size)
948 {
949 SLJIT_UNUSED_ARG(compiler);
950
951 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
952 CHECK_ARGUMENT(!(options & ~SLJIT_DOUBLE_ALIGNMENT));
953 CHECK_ARGUMENT(args >= 0 && args <= 3);
954 CHECK_ARGUMENT(scratches >= 0 && scratches <= SLJIT_NUMBER_OF_REGISTERS);
955 CHECK_ARGUMENT(saveds >= 0 && saveds <= SLJIT_NUMBER_OF_REGISTERS);
956 CHECK_ARGUMENT(scratches + saveds <= SLJIT_NUMBER_OF_REGISTERS);
957 CHECK_ARGUMENT(args <= saveds);
958 CHECK_ARGUMENT(fscratches >= 0 && fscratches <= SLJIT_NUMBER_OF_FLOAT_REGISTERS);
959 CHECK_ARGUMENT(fsaveds >= 0 && fsaveds <= SLJIT_NUMBER_OF_FLOAT_REGISTERS);
960 CHECK_ARGUMENT(fscratches + fsaveds <= SLJIT_NUMBER_OF_FLOAT_REGISTERS);
961 CHECK_ARGUMENT(local_size >= 0 && local_size <= SLJIT_MAX_LOCAL_SIZE);
962 #endif
963 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
964 if (SLJIT_UNLIKELY(!!compiler->verbose))
965 fprintf(compiler->verbose, " enter options:none args:%d scratches:%d saveds:%d fscratches:%d fsaveds:%d local_size:%d\n",
966 args, scratches, saveds, fscratches, fsaveds, local_size);
967 #endif
968 CHECK_RETURN_OK;
969 }
970
971 static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_set_context(struct sljit_compiler *compiler,
972 sljit_s32 options, sljit_s32 args, sljit_s32 scratches, sljit_s32 saveds,
973 sljit_s32 fscratches, sljit_s32 fsaveds, sljit_s32 local_size)
974 {
975 if (SLJIT_UNLIKELY(compiler->skip_checks)) {
976 compiler->skip_checks = 0;
977 CHECK_RETURN_OK;
978 }
979
980 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
981 CHECK_ARGUMENT(!(options & ~SLJIT_DOUBLE_ALIGNMENT));
982 CHECK_ARGUMENT(args >= 0 && args <= 3);
983 CHECK_ARGUMENT(scratches >= 0 && scratches <= SLJIT_NUMBER_OF_REGISTERS);
984 CHECK_ARGUMENT(saveds >= 0 && saveds <= SLJIT_NUMBER_OF_REGISTERS);
985 CHECK_ARGUMENT(scratches + saveds <= SLJIT_NUMBER_OF_REGISTERS);
986 CHECK_ARGUMENT(args <= saveds);
987 CHECK_ARGUMENT(fscratches >= 0 && fscratches <= SLJIT_NUMBER_OF_FLOAT_REGISTERS);
988 CHECK_ARGUMENT(fsaveds >= 0 && fsaveds <= SLJIT_NUMBER_OF_FLOAT_REGISTERS);
989 CHECK_ARGUMENT(fscratches + fsaveds <= SLJIT_NUMBER_OF_FLOAT_REGISTERS);
990 CHECK_ARGUMENT(local_size >= 0 && local_size <= SLJIT_MAX_LOCAL_SIZE);
991 #endif
992 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
993 if (SLJIT_UNLIKELY(!!compiler->verbose))
994 fprintf(compiler->verbose, " set_context options:none args:%d scratches:%d saveds:%d fscratches:%d fsaveds:%d local_size:%d\n",
995 args, scratches, saveds, fscratches, fsaveds, local_size);
996 #endif
997 CHECK_RETURN_OK;
998 }
999
1000 static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_return(struct sljit_compiler *compiler, sljit_s32 op, sljit_s32 src, sljit_sw srcw)
1001 {
1002 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1003 CHECK_ARGUMENT(compiler->scratches >= 0);
1004 if (op != SLJIT_UNUSED) {
1005 CHECK_ARGUMENT(op >= SLJIT_MOV && op <= SLJIT_MOV_P);
1006 FUNCTION_CHECK_SRC(src, srcw);
1007 }
1008 else
1009 CHECK_ARGUMENT(src == 0 && srcw == 0);
1010 #endif
1011 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1012 if (SLJIT_UNLIKELY(!!compiler->verbose)) {
1013 if (op == SLJIT_UNUSED)
1014 fprintf(compiler->verbose, " return\n");
1015 else {
1016 fprintf(compiler->verbose, " return%s ", op1_names[op - SLJIT_OP1_BASE]);
1017 sljit_verbose_param(compiler, src, srcw);
1018 fprintf(compiler->verbose, "\n");
1019 }
1020 }
1021 #endif
1022 CHECK_RETURN_OK;
1023 }
1024
1025 static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_fast_enter(struct sljit_compiler *compiler, sljit_s32 dst, sljit_sw dstw)
1026 {
1027 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1028 FUNCTION_CHECK_DST(dst, dstw);
1029 #endif
1030 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1031 if (SLJIT_UNLIKELY(!!compiler->verbose)) {
1032 fprintf(compiler->verbose, " fast_enter ");
1033 sljit_verbose_param(compiler, dst, dstw);
1034 fprintf(compiler->verbose, "\n");
1035 }
1036 #endif
1037 CHECK_RETURN_OK;
1038 }
1039
1040 static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_fast_return(struct sljit_compiler *compiler, sljit_s32 src, sljit_sw srcw)
1041 {
1042 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1043 FUNCTION_CHECK_SRC(src, srcw);
1044 #endif
1045 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1046 if (SLJIT_UNLIKELY(!!compiler->verbose)) {
1047 fprintf(compiler->verbose, " fast_return ");
1048 sljit_verbose_param(compiler, src, srcw);
1049 fprintf(compiler->verbose, "\n");
1050 }
1051 #endif
1052 CHECK_RETURN_OK;
1053 }
1054
1055 static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_op0(struct sljit_compiler *compiler, sljit_s32 op)
1056 {
1057 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1058 CHECK_ARGUMENT((op >= SLJIT_BREAKPOINT && op <= SLJIT_LMUL_SW)
1059 || ((op & ~SLJIT_I32_OP) >= SLJIT_DIVMOD_UW && (op & ~SLJIT_I32_OP) <= SLJIT_DIV_SW));
1060 CHECK_ARGUMENT(op < SLJIT_LMUL_UW || compiler->scratches >= 2);
1061 #endif
1062 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1063 if (SLJIT_UNLIKELY(!!compiler->verbose))
1064 {
1065 fprintf(compiler->verbose, " %s", op0_names[GET_OPCODE(op) - SLJIT_OP0_BASE]);
1066 if (GET_OPCODE(op) >= SLJIT_DIVMOD_UW) {
1067 fprintf(compiler->verbose, (op & SLJIT_I32_OP) ? "32" : "w");
1068 }
1069 fprintf(compiler->verbose, "\n");
1070 }
1071 #endif
1072 CHECK_RETURN_OK;
1073 }
1074
1075 static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_op1(struct sljit_compiler *compiler, sljit_s32 op,
1076 sljit_s32 dst, sljit_sw dstw,
1077 sljit_s32 src, sljit_sw srcw)
1078 {
1079 if (SLJIT_UNLIKELY(compiler->skip_checks)) {
1080 compiler->skip_checks = 0;
1081 CHECK_RETURN_OK;
1082 }
1083
1084 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1085 CHECK_ARGUMENT(GET_OPCODE(op) >= SLJIT_MOV && GET_OPCODE(op) <= SLJIT_CLZ);
1086 FUNCTION_CHECK_OP();
1087 FUNCTION_CHECK_SRC(src, srcw);
1088 FUNCTION_CHECK_DST(dst, dstw);
1089 FUNCTION_CHECK_OP1();
1090 #endif
1091 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1092 if (SLJIT_UNLIKELY(!!compiler->verbose)) {
1093 if (GET_OPCODE(op) <= SLJIT_MOVU_P)
1094 {
1095 fprintf(compiler->verbose, " mov%s%s%s ", (GET_OPCODE(op) >= SLJIT_MOVU) ? "u" : "",
1096 !(op & SLJIT_I32_OP) ? "" : "32", (op != SLJIT_MOV32 && op != SLJIT_MOVU32) ? op1_names[GET_OPCODE(op) - SLJIT_OP1_BASE] : "");
1097 }
1098 else
1099 {
1100 fprintf(compiler->verbose, " %s%s%s%s%s%s%s%s ", op1_names[GET_OPCODE(op) - SLJIT_OP1_BASE], !(op & SLJIT_I32_OP) ? "" : "32",
1101 !(op & SLJIT_SET_E) ? "" : ".e", !(op & SLJIT_SET_U) ? "" : ".u", !(op & SLJIT_SET_S) ? "" : ".s",
1102 !(op & SLJIT_SET_O) ? "" : ".o", !(op & SLJIT_SET_C) ? "" : ".c", !(op & SLJIT_KEEP_FLAGS) ? "" : ".k");
1103 }
1104
1105 sljit_verbose_param(compiler, dst, dstw);
1106 fprintf(compiler->verbose, ", ");
1107 sljit_verbose_param(compiler, src, srcw);
1108 fprintf(compiler->verbose, "\n");
1109 }
1110 #endif
1111 CHECK_RETURN_OK;
1112 }
1113
1114 static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_op2(struct sljit_compiler *compiler, sljit_s32 op,
1115 sljit_s32 dst, sljit_sw dstw,
1116 sljit_s32 src1, sljit_sw src1w,
1117 sljit_s32 src2, sljit_sw src2w)
1118 {
1119 if (SLJIT_UNLIKELY(compiler->skip_checks)) {
1120 compiler->skip_checks = 0;
1121 CHECK_RETURN_OK;
1122 }
1123
1124 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1125 CHECK_ARGUMENT(GET_OPCODE(op) >= SLJIT_ADD && GET_OPCODE(op) <= SLJIT_ASHR);
1126 FUNCTION_CHECK_OP();
1127 FUNCTION_CHECK_SRC(src1, src1w);
1128 FUNCTION_CHECK_SRC(src2, src2w);
1129 FUNCTION_CHECK_DST(dst, dstw);
1130 #endif
1131 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1132 if (SLJIT_UNLIKELY(!!compiler->verbose)) {
1133 fprintf(compiler->verbose, " %s%s%s%s%s%s%s%s ", op2_names[GET_OPCODE(op) - SLJIT_OP2_BASE], !(op & SLJIT_I32_OP) ? "" : "32",
1134 !(op & SLJIT_SET_E) ? "" : ".e", !(op & SLJIT_SET_U) ? "" : ".u", !(op & SLJIT_SET_S) ? "" : ".s",
1135 !(op & SLJIT_SET_O) ? "" : ".o", !(op & SLJIT_SET_C) ? "" : ".c", !(op & SLJIT_KEEP_FLAGS) ? "" : ".k");
1136 sljit_verbose_param(compiler, dst, dstw);
1137 fprintf(compiler->verbose, ", ");
1138 sljit_verbose_param(compiler, src1, src1w);
1139 fprintf(compiler->verbose, ", ");
1140 sljit_verbose_param(compiler, src2, src2w);
1141 fprintf(compiler->verbose, "\n");
1142 }
1143 #endif
1144 CHECK_RETURN_OK;
1145 }
1146
1147 static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_get_register_index(sljit_s32 reg)
1148 {
1149 SLJIT_UNUSED_ARG(reg);
1150 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1151 CHECK_ARGUMENT(reg > 0 && reg <= SLJIT_NUMBER_OF_REGISTERS);
1152 #endif
1153 CHECK_RETURN_OK;
1154 }
1155
1156 static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_get_float_register_index(sljit_s32 reg)
1157 {
1158 SLJIT_UNUSED_ARG(reg);
1159 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1160 CHECK_ARGUMENT(reg > 0 && reg <= SLJIT_NUMBER_OF_FLOAT_REGISTERS);
1161 #endif
1162 CHECK_RETURN_OK;
1163 }
1164
1165 static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_op_custom(struct sljit_compiler *compiler,
1166 void *instruction, sljit_s32 size)
1167 {
1168 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1169 int i;
1170 #endif
1171
1172 SLJIT_UNUSED_ARG(compiler);
1173
1174 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1175 CHECK_ARGUMENT(instruction);
1176 #if (defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86)
1177 CHECK_ARGUMENT(size > 0 && size < 16);
1178 #elif (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
1179 CHECK_ARGUMENT((size == 2 && (((sljit_sw)instruction) & 0x1) == 0)
1180 || (size == 4 && (((sljit_sw)instruction) & 0x3) == 0));
1181 #else
1182 CHECK_ARGUMENT(size == 4 && (((sljit_sw)instruction) & 0x3) == 0);
1183 #endif
1184
1185 #endif
1186 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1187 if (SLJIT_UNLIKELY(!!compiler->verbose)) {
1188 fprintf(compiler->verbose, " op_custom");
1189 for (i = 0; i < size; i++)
1190 fprintf(compiler->verbose, " 0x%x", ((sljit_u8*)instruction)[i]);
1191 fprintf(compiler->verbose, "\n");
1192 }
1193 #endif
1194 CHECK_RETURN_OK;
1195 }
1196
1197 static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_fop1(struct sljit_compiler *compiler, sljit_s32 op,
1198 sljit_s32 dst, sljit_sw dstw,
1199 sljit_s32 src, sljit_sw srcw)
1200 {
1201 if (SLJIT_UNLIKELY(compiler->skip_checks)) {
1202 compiler->skip_checks = 0;
1203 CHECK_RETURN_OK;
1204 }
1205
1206 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1207 CHECK_ARGUMENT(sljit_is_fpu_available());
1208 CHECK_ARGUMENT(GET_OPCODE(op) >= SLJIT_MOV_F64 && GET_OPCODE(op) <= SLJIT_ABS_F64);
1209 FUNCTION_CHECK_FOP();
1210 FUNCTION_FCHECK(src, srcw);
1211 FUNCTION_FCHECK(dst, dstw);
1212 #endif
1213 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1214 if (SLJIT_UNLIKELY(!!compiler->verbose)) {
1215 if (GET_OPCODE(op) == SLJIT_CONV_F64_FROM_F32)
1216 fprintf(compiler->verbose, " %s%s ", fop1_names[SLJIT_CONV_F64_FROM_F32 - SLJIT_FOP1_BASE],
1217 (op & SLJIT_F32_OP) ? ".f32.from.f64" : ".f64.from.f32");
1218 else
1219 fprintf(compiler->verbose, " %s%s ", fop1_names[GET_OPCODE(op) - SLJIT_FOP1_BASE],
1220 (op & SLJIT_F32_OP) ? ".f32" : ".f64");
1221
1222 sljit_verbose_fparam(compiler, dst, dstw);
1223 fprintf(compiler->verbose, ", ");
1224 sljit_verbose_fparam(compiler, src, srcw);
1225 fprintf(compiler->verbose, "\n");
1226 }
1227 #endif
1228 CHECK_RETURN_OK;
1229 }
1230
1231 static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_fop1_cmp(struct sljit_compiler *compiler, sljit_s32 op,
1232 sljit_s32 src1, sljit_sw src1w,
1233 sljit_s32 src2, sljit_sw src2w)
1234 {
1235 if (SLJIT_UNLIKELY(compiler->skip_checks)) {
1236 compiler->skip_checks = 0;
1237 CHECK_RETURN_OK;
1238 }
1239
1240 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1241 CHECK_ARGUMENT(sljit_is_fpu_available());
1242 CHECK_ARGUMENT(GET_OPCODE(op) == SLJIT_CMP_F64);
1243 FUNCTION_CHECK_FOP();
1244 FUNCTION_FCHECK(src1, src1w);
1245 FUNCTION_FCHECK(src2, src2w);
1246 #endif
1247 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1248 if (SLJIT_UNLIKELY(!!compiler->verbose)) {
1249 fprintf(compiler->verbose, " %s%s%s%s ", fop1_names[SLJIT_CMP_F64 - SLJIT_FOP1_BASE], (op & SLJIT_F32_OP) ? ".f32" : ".f64",
1250 (op & SLJIT_SET_E) ? ".e" : "", (op & SLJIT_SET_S) ? ".s" : "");
1251 sljit_verbose_fparam(compiler, src1, src1w);
1252 fprintf(compiler->verbose, ", ");
1253 sljit_verbose_fparam(compiler, src2, src2w);
1254 fprintf(compiler->verbose, "\n");
1255 }
1256 #endif
1257 CHECK_RETURN_OK;
1258 }
1259
1260 static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_fop1_conv_sw_from_f64(struct sljit_compiler *compiler, sljit_s32 op,
1261 sljit_s32 dst, sljit_sw dstw,
1262 sljit_s32 src, sljit_sw srcw)
1263 {
1264 if (SLJIT_UNLIKELY(compiler->skip_checks)) {
1265 compiler->skip_checks = 0;
1266 CHECK_RETURN_OK;
1267 }
1268
1269 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1270 CHECK_ARGUMENT(sljit_is_fpu_available());
1271 CHECK_ARGUMENT(GET_OPCODE(op) >= SLJIT_CONV_SW_FROM_F64 && GET_OPCODE(op) <= SLJIT_CONV_S32_FROM_F64);
1272 FUNCTION_CHECK_FOP();
1273 FUNCTION_FCHECK(src, srcw);
1274 FUNCTION_CHECK_DST(dst, dstw);
1275 #endif
1276 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1277 if (SLJIT_UNLIKELY(!!compiler->verbose)) {
1278 fprintf(compiler->verbose, " %s%s.from%s ", fop1_names[GET_OPCODE(op) - SLJIT_FOP1_BASE],
1279 (GET_OPCODE(op) == SLJIT_CONV_S32_FROM_F64) ? ".s32" : ".sw",
1280 (op & SLJIT_F32_OP) ? ".f32" : ".f64");
1281 sljit_verbose_param(compiler, dst, dstw);
1282 fprintf(compiler->verbose, ", ");
1283 sljit_verbose_fparam(compiler, src, srcw);
1284 fprintf(compiler->verbose, "\n");
1285 }
1286 #endif
1287 CHECK_RETURN_OK;
1288 }
1289
1290 static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_fop1_conv_f64_from_sw(struct sljit_compiler *compiler, sljit_s32 op,
1291 sljit_s32 dst, sljit_sw dstw,
1292 sljit_s32 src, sljit_sw srcw)
1293 {
1294 if (SLJIT_UNLIKELY(compiler->skip_checks)) {
1295 compiler->skip_checks = 0;
1296 CHECK_RETURN_OK;
1297 }
1298
1299 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1300 CHECK_ARGUMENT(sljit_is_fpu_available());
1301 CHECK_ARGUMENT(GET_OPCODE(op) >= SLJIT_CONV_F64_FROM_SW && GET_OPCODE(op) <= SLJIT_CONV_F64_FROM_S32);
1302 FUNCTION_CHECK_FOP();
1303 FUNCTION_CHECK_SRC(src, srcw);
1304 FUNCTION_FCHECK(dst, dstw);
1305 #endif
1306 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1307 if (SLJIT_UNLIKELY(!!compiler->verbose)) {
1308 fprintf(compiler->verbose, " %s%s.from%s ", fop1_names[GET_OPCODE(op) - SLJIT_FOP1_BASE],
1309 (op & SLJIT_F32_OP) ? ".f32" : ".f64",
1310 (GET_OPCODE(op) == SLJIT_CONV_F64_FROM_S32) ? ".s32" : ".sw");
1311 sljit_verbose_fparam(compiler, dst, dstw);
1312 fprintf(compiler->verbose, ", ");
1313 sljit_verbose_param(compiler, src, srcw);
1314 fprintf(compiler->verbose, "\n");
1315 }
1316 #endif
1317 CHECK_RETURN_OK;
1318 }
1319
1320 static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_fop2(struct sljit_compiler *compiler, sljit_s32 op,
1321 sljit_s32 dst, sljit_sw dstw,
1322 sljit_s32 src1, sljit_sw src1w,
1323 sljit_s32 src2, sljit_sw src2w)
1324 {
1325 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1326 CHECK_ARGUMENT(sljit_is_fpu_available());
1327 CHECK_ARGUMENT(GET_OPCODE(op) >= SLJIT_ADD_F64 && GET_OPCODE(op) <= SLJIT_DIV_F64);
1328 FUNCTION_CHECK_FOP();
1329 FUNCTION_FCHECK(src1, src1w);
1330 FUNCTION_FCHECK(src2, src2w);
1331 FUNCTION_FCHECK(dst, dstw);
1332 #endif
1333 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1334 if (SLJIT_UNLIKELY(!!compiler->verbose)) {
1335 fprintf(compiler->verbose, " %s%s ", fop2_names[GET_OPCODE(op) - SLJIT_FOP2_BASE], (op & SLJIT_F32_OP) ? ".f32" : ".f64");
1336 sljit_verbose_fparam(compiler, dst, dstw);
1337 fprintf(compiler->verbose, ", ");
1338 sljit_verbose_fparam(compiler, src1, src1w);
1339 fprintf(compiler->verbose, ", ");
1340 sljit_verbose_fparam(compiler, src2, src2w);
1341 fprintf(compiler->verbose, "\n");
1342 }
1343 #endif
1344 CHECK_RETURN_OK;
1345 }
1346
1347 static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_label(struct sljit_compiler *compiler)
1348 {
1349 SLJIT_UNUSED_ARG(compiler);
1350
1351 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1352 if (SLJIT_UNLIKELY(!!compiler->verbose))
1353 fprintf(compiler->verbose, "label:\n");
1354 #endif
1355 CHECK_RETURN_OK;
1356 }
1357
1358 static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_jump(struct sljit_compiler *compiler, sljit_s32 type)
1359 {
1360 if (SLJIT_UNLIKELY(compiler->skip_checks)) {
1361 compiler->skip_checks = 0;
1362 CHECK_RETURN_OK;
1363 }
1364
1365 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1366 CHECK_ARGUMENT(!(type & ~(0xff | SLJIT_REWRITABLE_JUMP | SLJIT_I32_OP)));
1367 CHECK_ARGUMENT((type & 0xff) >= SLJIT_EQUAL && (type & 0xff) <= SLJIT_CALL3);
1368 CHECK_ARGUMENT((type & 0xff) < SLJIT_JUMP || !(type & SLJIT_I32_OP));
1369 CHECK_ARGUMENT((type & 0xff) <= SLJIT_CALL0 || ((type & 0xff) - SLJIT_CALL0) <= compiler->scratches);
1370 #endif
1371 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1372 if (SLJIT_UNLIKELY(!!compiler->verbose))
1373 fprintf(compiler->verbose, " jump%s %s%s\n", !(type & SLJIT_REWRITABLE_JUMP) ? "" : ".r",
1374 jump_names[type & 0xff], JUMP_POSTFIX(type));
1375 #endif
1376 CHECK_RETURN_OK;
1377 }
1378
1379 static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_cmp(struct sljit_compiler *compiler, sljit_s32 type,
1380 sljit_s32 src1, sljit_sw src1w,
1381 sljit_s32 src2, sljit_sw src2w)
1382 {
1383 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1384 CHECK_ARGUMENT(!(type & ~(0xff | SLJIT_REWRITABLE_JUMP | SLJIT_I32_OP)));
1385 CHECK_ARGUMENT((type & 0xff) >= SLJIT_EQUAL && (type & 0xff) <= SLJIT_SIG_LESS_EQUAL);
1386 FUNCTION_CHECK_SRC(src1, src1w);
1387 FUNCTION_CHECK_SRC(src2, src2w);
1388 #endif
1389 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1390 if (SLJIT_UNLIKELY(!!compiler->verbose)) {
1391 fprintf(compiler->verbose, " cmp%s %s%s, ", !(type & SLJIT_REWRITABLE_JUMP) ? "" : ".r",
1392 jump_names[type & 0xff], (type & SLJIT_I32_OP) ? "32" : "");
1393 sljit_verbose_param(compiler, src1, src1w);
1394 fprintf(compiler->verbose, ", ");
1395 sljit_verbose_param(compiler, src2, src2w);
1396 fprintf(compiler->verbose, "\n");
1397 }
1398 #endif
1399 CHECK_RETURN_OK;
1400 }
1401
1402 static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_fcmp(struct sljit_compiler *compiler, sljit_s32 type,
1403 sljit_s32 src1, sljit_sw src1w,
1404 sljit_s32 src2, sljit_sw src2w)
1405 {
1406 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1407 CHECK_ARGUMENT(sljit_is_fpu_available());
1408 CHECK_ARGUMENT(!(type & ~(0xff | SLJIT_REWRITABLE_JUMP | SLJIT_F32_OP)));
1409 CHECK_ARGUMENT((type & 0xff) >= SLJIT_EQUAL_F64 && (type & 0xff) <= SLJIT_ORDERED_F64);
1410 FUNCTION_FCHECK(src1, src1w);
1411 FUNCTION_FCHECK(src2, src2w);
1412 #endif
1413 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1414 if (SLJIT_UNLIKELY(!!compiler->verbose)) {
1415 fprintf(compiler->verbose, " fcmp%s %s%s, ", !(type & SLJIT_REWRITABLE_JUMP) ? "" : ".r",
1416 jump_names[type & 0xff], (type & SLJIT_F32_OP) ? ".f32" : ".f64");
1417 sljit_verbose_fparam(compiler, src1, src1w);
1418 fprintf(compiler->verbose, ", ");
1419 sljit_verbose_fparam(compiler, src2, src2w);
1420 fprintf(compiler->verbose, "\n");
1421 }
1422 #endif
1423 CHECK_RETURN_OK;
1424 }
1425
1426 static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_ijump(struct sljit_compiler *compiler, sljit_s32 type, sljit_s32 src, sljit_sw srcw)
1427 {
1428 if (SLJIT_UNLIKELY(compiler->skip_checks)) {
1429 compiler->skip_checks = 0;
1430 CHECK_RETURN_OK;
1431 }
1432
1433 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1434 CHECK_ARGUMENT(type >= SLJIT_JUMP && type <= SLJIT_CALL3);
1435 CHECK_ARGUMENT(type <= SLJIT_CALL0 || (type - SLJIT_CALL0) <= compiler->scratches);
1436 FUNCTION_CHECK_SRC(src, srcw);
1437 #endif
1438 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1439 if (SLJIT_UNLIKELY(!!compiler->verbose)) {
1440 fprintf(compiler->verbose, " ijump.%s ", jump_names[type]);
1441 sljit_verbose_param(compiler, src, srcw);
1442 fprintf(compiler->verbose, "\n");
1443 }
1444 #endif
1445 CHECK_RETURN_OK;
1446 }
1447
1448 static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_op_flags(struct sljit_compiler *compiler, sljit_s32 op,
1449 sljit_s32 dst, sljit_sw dstw,
1450 sljit_s32 src, sljit_sw srcw,
1451 sljit_s32 type)
1452 {
1453 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1454 CHECK_ARGUMENT(!(type & ~(0xff | SLJIT_I32_OP)));
1455 CHECK_ARGUMENT((type & 0xff) >= SLJIT_EQUAL && (type & 0xff) <= SLJIT_ORDERED_F64);
1456 CHECK_ARGUMENT(op == SLJIT_MOV || GET_OPCODE(op) == SLJIT_MOV_U32 || GET_OPCODE(op) == SLJIT_MOV_S32
1457 || (GET_OPCODE(op) >= SLJIT_AND && GET_OPCODE(op) <= SLJIT_XOR));
1458 CHECK_ARGUMENT((op & (SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_O | SLJIT_SET_C)) == 0);
1459 CHECK_ARGUMENT((op & (SLJIT_SET_E | SLJIT_KEEP_FLAGS)) != (SLJIT_SET_E | SLJIT_KEEP_FLAGS));
1460 if (GET_OPCODE(op) < SLJIT_ADD) {
1461 CHECK_ARGUMENT(src == SLJIT_UNUSED && srcw == 0);
1462 } else {
1463 CHECK_ARGUMENT(src == dst && srcw == dstw);
1464 }
1465 FUNCTION_CHECK_DST(dst, dstw);
1466 #endif
1467 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1468 if (SLJIT_UNLIKELY(!!compiler->verbose)) {
1469 fprintf(compiler->verbose, " flags %s%s%s%s, ",
1470 !(op & SLJIT_SET_E) ? "" : ".e", !(op & SLJIT_KEEP_FLAGS) ? "" : ".k",
1471 GET_OPCODE(op) < SLJIT_OP2_BASE ? "mov" : op2_names[GET_OPCODE(op) - SLJIT_OP2_BASE],
1472 GET_OPCODE(op) < SLJIT_OP2_BASE ? op1_names[GET_OPCODE(op) - SLJIT_OP1_BASE] : ((op & SLJIT_I32_OP) ? "32" : ""));
1473 sljit_verbose_param(compiler, dst, dstw);
1474 if (src != SLJIT_UNUSED) {
1475 fprintf(compiler->verbose, ", ");
1476 sljit_verbose_param(compiler, src, srcw);
1477 }
1478 fprintf(compiler->verbose, ", %s%s\n", jump_names[type & 0xff], JUMP_POSTFIX(type));
1479 }
1480 #endif
1481 CHECK_RETURN_OK;
1482 }
1483
1484 static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_get_local_base(struct sljit_compiler *compiler, sljit_s32 dst, sljit_sw dstw, sljit_sw offset)
1485 {
1486 SLJIT_UNUSED_ARG(offset);
1487
1488 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1489 FUNCTION_CHECK_DST(dst, dstw);
1490 #endif
1491 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1492 if (SLJIT_UNLIKELY(!!compiler->verbose)) {
1493 fprintf(compiler->verbose, " local_base ");
1494 sljit_verbose_param(compiler, dst, dstw);
1495 fprintf(compiler->verbose, ", #%" SLJIT_PRINT_D "d\n", offset);
1496 }
1497 #endif
1498 CHECK_RETURN_OK;
1499 }
1500
1501 static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_const(struct sljit_compiler *compiler, sljit_s32 dst, sljit_sw dstw, sljit_sw init_value)
1502 {
1503 SLJIT_UNUSED_ARG(init_value);
1504
1505 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1506 FUNCTION_CHECK_DST(dst, dstw);
1507 #endif
1508 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1509 if (SLJIT_UNLIKELY(!!compiler->verbose)) {
1510 fprintf(compiler->verbose, " const ");
1511 sljit_verbose_param(compiler, dst, dstw);
1512 fprintf(compiler->verbose, ", #%" SLJIT_PRINT_D "d\n", init_value);
1513 }
1514 #endif
1515 CHECK_RETURN_OK;
1516 }
1517
1518 #endif /* SLJIT_ARGUMENT_CHECKS || SLJIT_VERBOSE */
1519
1520 #define SELECT_FOP1_OPERATION_WITH_CHECKS(compiler, op, dst, dstw, src, srcw) \
1521 SLJIT_COMPILE_ASSERT(!(SLJIT_CONV_SW_FROM_F64 & 0x1) && !(SLJIT_CONV_F64_FROM_SW & 0x1), \
1522 invalid_float_opcodes); \
1523 if (GET_OPCODE(op) >= SLJIT_CONV_SW_FROM_F64 && GET_OPCODE(op) <= SLJIT_CMP_F64) { \
1524 if (GET_OPCODE(op) == SLJIT_CMP_F64) { \
1525 CHECK(check_sljit_emit_fop1_cmp(compiler, op, dst, dstw, src, srcw)); \
1526 ADJUST_LOCAL_OFFSET(dst, dstw); \
1527 ADJUST_LOCAL_OFFSET(src, srcw); \
1528 return sljit_emit_fop1_cmp(compiler, op, dst, dstw, src, srcw); \
1529 } \
1530 if ((GET_OPCODE(op) | 0x1) == SLJIT_CONV_S32_FROM_F64) { \
1531 CHECK(check_sljit_emit_fop1_conv_sw_from_f64(compiler, op, dst, dstw, src, srcw)); \
1532 ADJUST_LOCAL_OFFSET(dst, dstw); \
1533 ADJUST_LOCAL_OFFSET(src, srcw); \
1534 return sljit_emit_fop1_conv_sw_from_f64(compiler, op, dst, dstw, src, srcw); \
1535 } \
1536 CHECK(check_sljit_emit_fop1_conv_f64_from_sw(compiler, op, dst, dstw, src, srcw)); \
1537 ADJUST_LOCAL_OFFSET(dst, dstw); \
1538 ADJUST_LOCAL_OFFSET(src, srcw); \
1539 return sljit_emit_fop1_conv_f64_from_sw(compiler, op, dst, dstw, src, srcw); \
1540 } \
1541 CHECK(check_sljit_emit_fop1(compiler, op, dst, dstw, src, srcw)); \
1542 ADJUST_LOCAL_OFFSET(dst, dstw); \
1543 ADJUST_LOCAL_OFFSET(src, srcw);
1544
1545 static SLJIT_INLINE sljit_s32 emit_mov_before_return(struct sljit_compiler *compiler, sljit_s32 op, sljit_s32 src, sljit_sw srcw)
1546 {
1547 /* Return if don't need to do anything. */
1548 if (op == SLJIT_UNUSED)
1549 return SLJIT_SUCCESS;
1550
1551 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
1552 /* At the moment the pointer size is always equal to sljit_sw. May be changed in the future. */
1553 if (src == SLJIT_RETURN_REG && (op == SLJIT_MOV || op == SLJIT_MOV_P))
1554 return SLJIT_SUCCESS;
1555 #else
1556 if (src == SLJIT_RETURN_REG && (op == SLJIT_MOV || op == SLJIT_MOV_U32 || op == SLJIT_MOV_S32 || op == SLJIT_MOV_P))
1557 return SLJIT_SUCCESS;
1558 #endif
1559
1560 #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS) \
1561 || (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1562 compiler->skip_checks = 1;
1563 #endif
1564 return sljit_emit_op1(compiler, op, SLJIT_RETURN_REG, 0, src, srcw);
1565 }
1566
1567 /* CPU description section */
1568
1569 #if (defined SLJIT_32BIT_ARCHITECTURE && SLJIT_32BIT_ARCHITECTURE)
1570 #define SLJIT_CPUINFO_PART1 " 32bit ("
1571 #elif (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
1572 #define SLJIT_CPUINFO_PART1 " 64bit ("
1573 #else
1574 #error "Internal error: CPU type info missing"
1575 #endif
1576
1577 #if (defined SLJIT_LITTLE_ENDIAN && SLJIT_LITTLE_ENDIAN)
1578 #define SLJIT_CPUINFO_PART2 "little endian + "
1579 #elif (defined SLJIT_BIG_ENDIAN && SLJIT_BIG_ENDIAN)
1580 #define SLJIT_CPUINFO_PART2 "big endian + "
1581 #else
1582 #error "Internal error: CPU type info missing"
1583 #endif
1584
1585 #if (defined SLJIT_UNALIGNED && SLJIT_UNALIGNED)
1586 #define SLJIT_CPUINFO_PART3 "unaligned)"
1587 #else
1588 #define SLJIT_CPUINFO_PART3 "aligned)"
1589 #endif
1590
1591 #define SLJIT_CPUINFO SLJIT_CPUINFO_PART1 SLJIT_CPUINFO_PART2 SLJIT_CPUINFO_PART3
1592
1593 #if (defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86)
1594 # include "sljitNativeX86_common.c"
1595 #elif (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5)
1596 # include "sljitNativeARM_32.c"
1597 #elif (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7)
1598 # include "sljitNativeARM_32.c"
1599 #elif (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
1600 # include "sljitNativeARM_T2_32.c"
1601 #elif (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64)
1602 # include "sljitNativeARM_64.c"
1603 #elif (defined SLJIT_CONFIG_PPC && SLJIT_CONFIG_PPC)
1604 # include "sljitNativePPC_common.c"
1605 #elif (defined SLJIT_CONFIG_MIPS && SLJIT_CONFIG_MIPS)
1606 # include "sljitNativeMIPS_common.c"
1607 #elif (defined SLJIT_CONFIG_SPARC && SLJIT_CONFIG_SPARC)
1608 # include "sljitNativeSPARC_common.c"
1609 #elif (defined SLJIT_CONFIG_TILEGX && SLJIT_CONFIG_TILEGX)
1610 # include "sljitNativeTILEGX_64.c"
1611 #endif
1612
1613 #if !(defined SLJIT_CONFIG_MIPS && SLJIT_CONFIG_MIPS)
1614
1615 SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_cmp(struct sljit_compiler *compiler, sljit_s32 type,
1616 sljit_s32 src1, sljit_sw src1w,
1617 sljit_s32 src2, sljit_sw src2w)
1618 {
1619 /* Default compare for most architectures. */
1620 sljit_s32 flags, tmp_src, condition;
1621 sljit_sw tmp_srcw;
1622
1623 CHECK_ERROR_PTR();
1624 CHECK_PTR(check_sljit_emit_cmp(compiler, type, src1, src1w, src2, src2w));
1625
1626 condition = type & 0xff;
1627 #if (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64)
1628 if ((condition == SLJIT_EQUAL || condition == SLJIT_NOT_EQUAL)) {
1629 if ((src1 & SLJIT_IMM) && !src1w) {
1630 src1 = src2;
1631 src1w = src2w;
1632 src2 = SLJIT_IMM;
1633 src2w = 0;
1634 }
1635 if ((src2 & SLJIT_IMM) && !src2w)
1636 return emit_cmp_to0(compiler, type, src1, src1w);
1637 }
1638 #endif
1639
1640 if (SLJIT_UNLIKELY((src1 & SLJIT_IMM) && !(src2 & SLJIT_IMM))) {
1641 /* Immediate is prefered as second argument by most architectures. */
1642 switch (condition) {
1643 case SLJIT_LESS:
1644 condition = SLJIT_GREATER;
1645 break;
1646 case SLJIT_GREATER_EQUAL:
1647 condition = SLJIT_LESS_EQUAL;
1648 break;
1649 case SLJIT_GREATER:
1650 condition = SLJIT_LESS;
1651 break;
1652 case SLJIT_LESS_EQUAL:
1653 condition = SLJIT_GREATER_EQUAL;
1654 break;
1655 case SLJIT_SIG_LESS:
1656 condition = SLJIT_SIG_GREATER;
1657 break;
1658 case SLJIT_SIG_GREATER_EQUAL:
1659 condition = SLJIT_SIG_LESS_EQUAL;
1660 break;
1661 case SLJIT_SIG_GREATER:
1662 condition = SLJIT_SIG_LESS;
1663 break;
1664 case SLJIT_SIG_LESS_EQUAL:
1665 condition = SLJIT_SIG_GREATER_EQUAL;
1666 break;
1667 }
1668 type = condition | (type & (SLJIT_I32_OP | SLJIT_REWRITABLE_JUMP));
1669 tmp_src = src1;
1670 src1 = src2;
1671 src2 = tmp_src;
1672 tmp_srcw = src1w;
1673 src1w = src2w;
1674 src2w = tmp_srcw;
1675 }
1676
1677 if (condition <= SLJIT_NOT_ZERO)
1678 flags = SLJIT_SET_E;
1679 else if (condition <= SLJIT_LESS_EQUAL)
1680 flags = SLJIT_SET_U;
1681 else
1682 flags = SLJIT_SET_S;
1683
1684 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) \
1685 || (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1686 compiler->skip_checks = 1;
1687 #endif
1688 PTR_FAIL_IF(sljit_emit_op2(compiler, SLJIT_SUB | flags | (type & SLJIT_I32_OP),
1689 SLJIT_UNUSED, 0, src1, src1w, src2, src2w));
1690 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) \
1691 || (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1692 compiler->skip_checks = 1;
1693 #endif
1694 return sljit_emit_jump(compiler, condition | (type & SLJIT_REWRITABLE_JUMP));
1695 }
1696
1697 SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_fcmp(struct sljit_compiler *compiler, sljit_s32 type,
1698 sljit_s32 src1, sljit_sw src1w,
1699 sljit_s32 src2, sljit_sw src2w)
1700 {
1701 sljit_s32 flags, condition;
1702
1703 CHECK_ERROR_PTR();
1704 CHECK_PTR(check_sljit_emit_fcmp(compiler, type, src1, src1w, src2, src2w));
1705
1706 condition = type & 0xff;
1707 flags = (condition <= SLJIT_NOT_EQUAL_F64) ? SLJIT_SET_E : SLJIT_SET_S;
1708 if (type & SLJIT_F32_OP)
1709 flags |= SLJIT_F32_OP;
1710
1711 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) \
1712 || (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1713 compiler->skip_checks = 1;
1714 #endif
1715 sljit_emit_fop1(compiler, SLJIT_CMP_F64 | flags, src1, src1w, src2, src2w);
1716
1717 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) \
1718 || (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1719 compiler->skip_checks = 1;
1720 #endif
1721 return sljit_emit_jump(compiler, condition | (type & SLJIT_REWRITABLE_JUMP));
1722 }
1723
1724 #endif
1725
1726 #if !(defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86)
1727
1728 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_get_local_base(struct sljit_compiler *compiler, sljit_s32 dst, sljit_sw dstw, sljit_sw offset)
1729 {
1730 CHECK_ERROR();
1731 CHECK(check_sljit_get_local_base(compiler, dst, dstw, offset));
1732
1733 ADJUST_LOCAL_OFFSET(SLJIT_MEM1(SLJIT_SP), offset);
1734 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) \
1735 || (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
1736 compiler->skip_checks = 1;
1737 #endif
1738 if (offset != 0)
1739 return sljit_emit_op2(compiler, SLJIT_ADD | SLJIT_KEEP_FLAGS, dst, dstw, SLJIT_SP, 0, SLJIT_IMM, offset);
1740 return sljit_emit_op1(compiler, SLJIT_MOV, dst, dstw, SLJIT_SP, 0);
1741 }
1742
1743 #endif
1744
1745 #else /* SLJIT_CONFIG_UNSUPPORTED */
1746
1747 /* Empty function bodies for those machines, which are not (yet) supported. */
1748
1749 SLJIT_API_FUNC_ATTRIBUTE const char* sljit_get_platform_name(void)
1750 {
1751 return "unsupported";
1752 }
1753
1754 SLJIT_API_FUNC_ATTRIBUTE struct sljit_compiler* sljit_create_compiler(void)
1755 {
1756 SLJIT_ASSERT_STOP();
1757 return NULL;
1758 }
1759
1760 SLJIT_API_FUNC_ATTRIBUTE void sljit_free_compiler(struct sljit_compiler *compiler)
1761 {
1762 SLJIT_UNUSED_ARG(compiler);
1763 SLJIT_ASSERT_STOP();
1764 }
1765
1766 SLJIT_API_FUNC_ATTRIBUTE void* sljit_alloc_memory(struct sljit_compiler *compiler, sljit_s32 size)
1767 {
1768 SLJIT_UNUSED_ARG(compiler);
1769 SLJIT_UNUSED_ARG(size);
1770 SLJIT_ASSERT_STOP();
1771 return NULL;
1772 }
1773
1774 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1775 SLJIT_API_FUNC_ATTRIBUTE void sljit_compiler_verbose(struct sljit_compiler *compiler, FILE* verbose)
1776 {
1777 SLJIT_UNUSED_ARG(compiler);
1778 SLJIT_UNUSED_ARG(verbose);
1779 SLJIT_ASSERT_STOP();
1780 }
1781 #endif
1782
1783 SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compiler)
1784 {
1785 SLJIT_UNUSED_ARG(compiler);
1786 SLJIT_ASSERT_STOP();
1787 return NULL;
1788 }
1789
1790 SLJIT_API_FUNC_ATTRIBUTE void sljit_free_code(void* code)
1791 {
1792 SLJIT_UNUSED_ARG(code);
1793 SLJIT_ASSERT_STOP();
1794 }
1795
1796 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_enter(struct sljit_compiler *compiler,
1797 sljit_s32 options, sljit_s32 args, sljit_s32 scratches, sljit_s32 saveds,
1798 sljit_s32 fscratches, sljit_s32 fsaveds, sljit_s32 local_size)
1799 {
1800 SLJIT_UNUSED_ARG(compiler);
1801 SLJIT_UNUSED_ARG(options);
1802 SLJIT_UNUSED_ARG(args);
1803 SLJIT_UNUSED_ARG(scratches);
1804 SLJIT_UNUSED_ARG(saveds);
1805 SLJIT_UNUSED_ARG(fscratches);
1806 SLJIT_UNUSED_ARG(fsaveds);
1807 SLJIT_UNUSED_ARG(local_size);
1808 SLJIT_ASSERT_STOP();
1809 return SLJIT_ERR_UNSUPPORTED;
1810 }
1811
1812 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_set_context(struct sljit_compiler *compiler,
1813 sljit_s32 options, sljit_s32 args, sljit_s32 scratches, sljit_s32 saveds,
1814 sljit_s32 fscratches, sljit_s32 fsaveds, sljit_s32 local_size)
1815 {
1816 SLJIT_UNUSED_ARG(compiler);
1817 SLJIT_UNUSED_ARG(options);
1818 SLJIT_UNUSED_ARG(args);
1819 SLJIT_UNUSED_ARG(scratches);
1820 SLJIT_UNUSED_ARG(saveds);
1821 SLJIT_UNUSED_ARG(fscratches);
1822 SLJIT_UNUSED_ARG(fsaveds);
1823 SLJIT_UNUSED_ARG(local_size);
1824 SLJIT_ASSERT_STOP();
1825 return SLJIT_ERR_UNSUPPORTED;
1826 }
1827
1828 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_return(struct sljit_compiler *compiler, sljit_s32 op, sljit_s32 src, sljit_sw srcw)
1829 {
1830 SLJIT_UNUSED_ARG(compiler);
1831 SLJIT_UNUSED_ARG(op);
1832 SLJIT_UNUSED_ARG(src);
1833 SLJIT_UNUSED_ARG(srcw);
1834 SLJIT_ASSERT_STOP();
1835 return SLJIT_ERR_UNSUPPORTED;
1836 }
1837
1838 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_fast_enter(struct sljit_compiler *compiler, sljit_s32 dst, sljit_sw dstw)
1839 {
1840 SLJIT_UNUSED_ARG(compiler);
1841 SLJIT_UNUSED_ARG(dst);
1842 SLJIT_UNUSED_ARG(dstw);
1843 SLJIT_ASSERT_STOP();
1844 return SLJIT_ERR_UNSUPPORTED;
1845 }
1846
1847 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_fast_return(struct sljit_compiler *compiler, sljit_s32 src, sljit_sw srcw)
1848 {
1849 SLJIT_UNUSED_ARG(compiler);
1850 SLJIT_UNUSED_ARG(src);
1851 SLJIT_UNUSED_ARG(srcw);
1852 SLJIT_ASSERT_STOP();
1853 return SLJIT_ERR_UNSUPPORTED;
1854 }
1855
1856 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op0(struct sljit_compiler *compiler, sljit_s32 op)
1857 {
1858 SLJIT_UNUSED_ARG(compiler);
1859 SLJIT_UNUSED_ARG(op);
1860 SLJIT_ASSERT_STOP();
1861 return SLJIT_ERR_UNSUPPORTED;
1862 }
1863
1864 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op1(struct sljit_compiler *compiler, sljit_s32 op,
1865 sljit_s32 dst, sljit_sw dstw,
1866 sljit_s32 src, sljit_sw srcw)
1867 {
1868 SLJIT_UNUSED_ARG(compiler);
1869 SLJIT_UNUSED_ARG(op);
1870 SLJIT_UNUSED_ARG(dst);
1871 SLJIT_UNUSED_ARG(dstw);
1872 SLJIT_UNUSED_ARG(src);
1873 SLJIT_UNUSED_ARG(srcw);
1874 SLJIT_ASSERT_STOP();
1875 return SLJIT_ERR_UNSUPPORTED;
1876 }
1877
1878 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op2(struct sljit_compiler *compiler, sljit_s32 op,
1879 sljit_s32 dst, sljit_sw dstw,
1880 sljit_s32 src1, sljit_sw src1w,
1881 sljit_s32 src2, sljit_sw src2w)
1882 {
1883 SLJIT_UNUSED_ARG(compiler);
1884 SLJIT_UNUSED_ARG(op);
1885 SLJIT_UNUSED_ARG(dst);
1886 SLJIT_UNUSED_ARG(dstw);
1887 SLJIT_UNUSED_ARG(src1);
1888 SLJIT_UNUSED_ARG(src1w);
1889 SLJIT_UNUSED_ARG(src2);
1890 SLJIT_UNUSED_ARG(src2w);
1891 SLJIT_ASSERT_STOP();
1892 return SLJIT_ERR_UNSUPPORTED;
1893 }
1894
1895 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_get_register_index(sljit_s32 reg)
1896 {
1897 SLJIT_ASSERT_STOP();
1898 return reg;
1899 }
1900
1901 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op_custom(struct sljit_compiler *compiler,
1902 void *instruction, sljit_s32 size)
1903 {
1904 SLJIT_UNUSED_ARG(compiler);
1905 SLJIT_UNUSED_ARG(instruction);
1906 SLJIT_UNUSED_ARG(size);
1907 SLJIT_ASSERT_STOP();
1908 return SLJIT_ERR_UNSUPPORTED;
1909 }
1910
1911 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_is_fpu_available(void)
1912 {
1913 SLJIT_ASSERT_STOP();
1914 return 0;
1915 }
1916
1917 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_fop1(struct sljit_compiler *compiler, sljit_s32 op,
1918 sljit_s32 dst, sljit_sw dstw,
1919 sljit_s32 src, sljit_sw srcw)
1920 {
1921 SLJIT_UNUSED_ARG(compiler);
1922 SLJIT_UNUSED_ARG(op);
1923 SLJIT_UNUSED_ARG(dst);
1924 SLJIT_UNUSED_ARG(dstw);
1925 SLJIT_UNUSED_ARG(src);
1926 SLJIT_UNUSED_ARG(srcw);
1927 SLJIT_ASSERT_STOP();
1928 return SLJIT_ERR_UNSUPPORTED;
1929 }
1930
1931 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_fop2(struct sljit_compiler *compiler, sljit_s32 op,
1932 sljit_s32 dst, sljit_sw dstw,
1933 sljit_s32 src1, sljit_sw src1w,
1934 sljit_s32 src2, sljit_sw src2w)
1935 {
1936 SLJIT_UNUSED_ARG(compiler);
1937 SLJIT_UNUSED_ARG(op);
1938 SLJIT_UNUSED_ARG(dst);
1939 SLJIT_UNUSED_ARG(dstw);
1940 SLJIT_UNUSED_ARG(src1);
1941 SLJIT_UNUSED_ARG(src1w);
1942 SLJIT_UNUSED_ARG(src2);
1943 SLJIT_UNUSED_ARG(src2w);
1944 SLJIT_ASSERT_STOP();
1945 return SLJIT_ERR_UNSUPPORTED;
1946 }
1947
1948 SLJIT_API_FUNC_ATTRIBUTE struct sljit_label* sljit_emit_label(struct sljit_compiler *compiler)
1949 {
1950 SLJIT_UNUSED_ARG(compiler);
1951 SLJIT_ASSERT_STOP();
1952 return NULL;
1953 }
1954
1955 SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_jump(struct sljit_compiler *compiler, sljit_s32 type)
1956 {
1957 SLJIT_UNUSED_ARG(compiler);
1958 SLJIT_UNUSED_ARG(type);
1959 SLJIT_ASSERT_STOP();
1960 return NULL;
1961 }
1962
1963 SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_cmp(struct sljit_compiler *compiler, sljit_s32 type,
1964 sljit_s32 src1, sljit_sw src1w,
1965 sljit_s32 src2, sljit_sw src2w)
1966 {
1967 SLJIT_UNUSED_ARG(compiler);
1968 SLJIT_UNUSED_ARG(type);
1969 SLJIT_UNUSED_ARG(src1);
1970 SLJIT_UNUSED_ARG(src1w);
1971 SLJIT_UNUSED_ARG(src2);
1972 SLJIT_UNUSED_ARG(src2w);
1973 SLJIT_ASSERT_STOP();
1974 return NULL;
1975 }
1976
1977 SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_fcmp(struct sljit_compiler *compiler, sljit_s32 type,
1978 sljit_s32 src1, sljit_sw src1w,
1979 sljit_s32 src2, sljit_sw src2w)
1980 {
1981 SLJIT_UNUSED_ARG(compiler);
1982 SLJIT_UNUSED_ARG(type);
1983 SLJIT_UNUSED_ARG(src1);
1984 SLJIT_UNUSED_ARG(src1w);
1985 SLJIT_UNUSED_ARG(src2);
1986 SLJIT_UNUSED_ARG(src2w);
1987 SLJIT_ASSERT_STOP();
1988 return NULL;
1989 }
1990
1991 SLJIT_API_FUNC_ATTRIBUTE void sljit_set_label(struct sljit_jump *jump, struct sljit_label* label)
1992 {
1993 SLJIT_UNUSED_ARG(jump);
1994 SLJIT_UNUSED_ARG(label);
1995 SLJIT_ASSERT_STOP();
1996 }
1997
1998 SLJIT_API_FUNC_ATTRIBUTE void sljit_set_target(struct sljit_jump *jump, sljit_uw target)
1999 {
2000 SLJIT_UNUSED_ARG(jump);
2001 SLJIT_UNUSED_ARG(target);
2002 SLJIT_ASSERT_STOP();
2003 }
2004
2005 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_ijump(struct sljit_compiler *compiler, sljit_s32 type, sljit_s32 src, sljit_sw srcw)
2006 {
2007 SLJIT_UNUSED_ARG(compiler);
2008 SLJIT_UNUSED_ARG(type);
2009 SLJIT_UNUSED_ARG(src);
2010 SLJIT_UNUSED_ARG(srcw);
2011 SLJIT_ASSERT_STOP();
2012 return SLJIT_ERR_UNSUPPORTED;
2013 }
2014
2015 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op_flags(struct sljit_compiler *compiler, sljit_s32 op,
2016 sljit_s32 dst, sljit_sw dstw,
2017 sljit_s32 src, sljit_sw srcw,
2018 sljit_s32 type)
2019 {
2020 SLJIT_UNUSED_ARG(compiler);
2021 SLJIT_UNUSED_ARG(op);
2022 SLJIT_UNUSED_ARG(dst);
2023 SLJIT_UNUSED_ARG(dstw);
2024 SLJIT_UNUSED_ARG(src);
2025 SLJIT_UNUSED_ARG(srcw);
2026 SLJIT_UNUSED_ARG(type);
2027 SLJIT_ASSERT_STOP();
2028 return SLJIT_ERR_UNSUPPORTED;
2029 }
2030
2031 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_get_local_base(struct sljit_compiler *compiler, sljit_s32 dst, sljit_sw dstw, sljit_sw offset)
2032 {
2033 SLJIT_UNUSED_ARG(compiler);
2034 SLJIT_UNUSED_ARG(dst);
2035 SLJIT_UNUSED_ARG(dstw);
2036 SLJIT_UNUSED_ARG(offset);
2037 SLJIT_ASSERT_STOP();
2038 return SLJIT_ERR_UNSUPPORTED;
2039 }
2040
2041 SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compiler *compiler, sljit_s32 dst, sljit_sw dstw, sljit_sw initval)
2042 {
2043 SLJIT_UNUSED_ARG(compiler);
2044 SLJIT_UNUSED_ARG(dst);
2045 SLJIT_UNUSED_ARG(dstw);
2046 SLJIT_UNUSED_ARG(initval);
2047 SLJIT_ASSERT_STOP();
2048 return NULL;
2049 }
2050
2051 SLJIT_API_FUNC_ATTRIBUTE void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_target, sljit_sw executable_offset)
2052 {
2053 SLJIT_UNUSED_ARG(addr);
2054 SLJIT_UNUSED_ARG(new_target);
2055 SLJIT_UNUSED_ARG(executable_offset);
2056 SLJIT_ASSERT_STOP();
2057 }
2058
2059 SLJIT_API_FUNC_ATTRIBUTE void sljit_set_const(sljit_uw addr, sljit_sw new_constant, sljit_sw executable_offset)
2060 {
2061 SLJIT_UNUSED_ARG(addr);
2062 SLJIT_UNUSED_ARG(new_constant);
2063 SLJIT_UNUSED_ARG(executable_offset);
2064 SLJIT_ASSERT_STOP();
2065 }
2066
2067 #endif

  ViewVC Help
Powered by ViewVC 1.1.5