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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.5