/[pcre]/code/trunk/sljit/sljitLir.c
ViewVC logotype

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

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.5