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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1182 - (show annotations)
Sun Oct 28 05:22:32 2012 UTC (6 years, 9 months ago) by zherczeg
File MIME type: text/plain
File size: 52105 byte(s)
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_S | SLJIT_SET_U | SLJIT_SET_O | SLJIT_SET_C | SLJIT_KEEP_FLAGS))
87
88 #define GET_FLAGS(op) \
89 ((op) & (SLJIT_SET_E | SLJIT_SET_S | SLJIT_SET_U | SLJIT_SET_O | SLJIT_SET_C))
90
91 #define GET_ALL_FLAGS(op) \
92 ((op) & (SLJIT_SET_E | SLJIT_SET_S | SLJIT_SET_U | SLJIT_SET_O | SLJIT_SET_C | SLJIT_KEEP_FLAGS))
93
94 #define BUF_SIZE 4096
95
96 #if (defined SLJIT_32BIT_ARCHITECTURE && SLJIT_32BIT_ARCHITECTURE)
97 #define ABUF_SIZE 2048
98 #else
99 #define ABUF_SIZE 4096
100 #endif
101
102 /* Jump flags. */
103 #define JUMP_LABEL 0x1
104 #define JUMP_ADDR 0x2
105 /* SLJIT_REWRITABLE_JUMP is 0x1000. */
106
107 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) || (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
108 #define PATCH_MB 0x4
109 #define PATCH_MW 0x8
110 #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
111 #define PATCH_MD 0x10
112 #endif
113 #endif
114
115 #if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) || (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7)
116 #define IS_BL 0x4
117 #define PATCH_B 0x8
118 #endif
119
120 #if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5)
121 #define CPOOL_SIZE 512
122 #endif
123
124 #if (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
125 #define IS_COND 0x04
126 #define IS_BL 0x08
127 /* cannot be encoded as branch */
128 #define B_TYPE0 0x00
129 /* conditional + imm8 */
130 #define B_TYPE1 0x10
131 /* conditional + imm20 */
132 #define B_TYPE2 0x20
133 /* IT + imm24 */
134 #define B_TYPE3 0x30
135 /* imm11 */
136 #define B_TYPE4 0x40
137 /* imm24 */
138 #define B_TYPE5 0x50
139 /* BL + imm24 */
140 #define BL_TYPE6 0x60
141 /* 0xf00 cc code for branches */
142 #endif
143
144 #if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) || (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
145 #define UNCOND_B 0x04
146 #define PATCH_B 0x08
147 #define ABSOLUTE_B 0x10
148 #endif
149
150 #if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
151 #define IS_MOVABLE 0x04
152 #define IS_JAL 0x08
153 #define IS_BIT26_COND 0x10
154 #define IS_BIT16_COND 0x20
155
156 #define IS_COND (IS_BIT26_COND | IS_BIT16_COND)
157
158 #define PATCH_B 0x40
159 #define PATCH_J 0x80
160
161 /* instruction types */
162 #define MOVABLE_INS 0
163 /* 1 - 31 last destination register */
164 /* no destination (i.e: store) */
165 #define UNMOVABLE_INS 32
166 /* FPU status register */
167 #define FCSR_FCC 33
168 #endif
169
170 #if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
171 #define IS_MOVABLE 0x04
172 #define IS_COND 0x08
173 #define IS_CALL 0x10
174
175 #define PATCH_B 0x20
176 #define PATCH_CALL 0x40
177
178 /* instruction types */
179 #define MOVABLE_INS 0
180 /* 1 - 31 last destination register */
181 /* no destination (i.e: store) */
182 #define UNMOVABLE_INS 32
183
184 #define DST_INS_MASK 0xff
185
186 /* ICC_SET is the same as SET_FLAGS. */
187 #define ICC_IS_SET (1 << 23)
188 #define FCC_IS_SET (1 << 24)
189 #endif
190
191 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
192 #define SLJIT_HAS_VARIABLE_LOCALS_OFFSET 1
193 #endif
194
195 #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
196 #define SLJIT_HAS_FIXED_LOCALS_OFFSET 1
197 #ifdef _WIN64
198 #define FIXED_LOCALS_OFFSET (4 * sizeof(sljit_w))
199 #else
200 #define FIXED_LOCALS_OFFSET (sizeof(sljit_w))
201 #endif
202 #endif
203
204 #if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32)
205 #define SLJIT_HAS_FIXED_LOCALS_OFFSET 1
206 #if (defined SLJIT_INDIRECT_CALL && SLJIT_INDIRECT_CALL)
207 #define FIXED_LOCALS_OFFSET ((6 + 8) * sizeof(sljit_w))
208 #else
209 #define FIXED_LOCALS_OFFSET (2 * sizeof(sljit_w))
210 #endif
211 #endif
212
213 #if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
214 #define SLJIT_HAS_FIXED_LOCALS_OFFSET 1
215 #define FIXED_LOCALS_OFFSET ((6 + 8) * sizeof(sljit_w))
216 #endif
217
218 #if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
219 #define SLJIT_HAS_FIXED_LOCALS_OFFSET 1
220 #define FIXED_LOCALS_OFFSET (4 * sizeof(sljit_w))
221 #endif
222
223 #if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
224 #define SLJIT_HAS_FIXED_LOCALS_OFFSET 1
225 #define FIXED_LOCALS_OFFSET (23 * sizeof(sljit_w))
226 #endif
227
228 #if (defined SLJIT_HAS_VARIABLE_LOCALS_OFFSET && SLJIT_HAS_VARIABLE_LOCALS_OFFSET)
229
230 #define ADJUST_LOCAL_OFFSET(p, i) \
231 if ((p) == (SLJIT_MEM1(SLJIT_LOCALS_REG))) \
232 (i) += compiler->locals_offset;
233
234 #elif (defined SLJIT_HAS_FIXED_LOCALS_OFFSET && SLJIT_HAS_FIXED_LOCALS_OFFSET)
235
236 #define ADJUST_LOCAL_OFFSET(p, i) \
237 if ((p) == (SLJIT_MEM1(SLJIT_LOCALS_REG))) \
238 (i) += FIXED_LOCALS_OFFSET;
239
240 #else
241
242 #define ADJUST_LOCAL_OFFSET(p, i)
243
244 #endif
245
246 #endif /* !(defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED) */
247
248 /* Utils can still be used even if SLJIT_CONFIG_UNSUPPORTED is set. */
249 #include "sljitUtils.c"
250
251 #if !(defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
252
253 #if (defined SLJIT_EXECUTABLE_ALLOCATOR && SLJIT_EXECUTABLE_ALLOCATOR)
254 #include "sljitExecAllocator.c"
255 #endif
256
257 #if (defined SLJIT_SSE2_AUTO && SLJIT_SSE2_AUTO) && !(defined SLJIT_SSE2 && SLJIT_SSE2)
258 #error SLJIT_SSE2_AUTO cannot be enabled without SLJIT_SSE2
259 #endif
260
261 /* --------------------------------------------------------------------- */
262 /* Public functions */
263 /* --------------------------------------------------------------------- */
264
265 #if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) || ((defined SLJIT_SSE2 && SLJIT_SSE2) && ((defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) || (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)))
266 #define SLJIT_NEEDS_COMPILER_INIT 1
267 static int compiler_initialized = 0;
268 /* A thread safe initialization. */
269 static void init_compiler(void);
270 #endif
271
272 SLJIT_API_FUNC_ATTRIBUTE struct sljit_compiler* sljit_create_compiler(void)
273 {
274 struct sljit_compiler *compiler = (struct sljit_compiler*)SLJIT_MALLOC(sizeof(struct sljit_compiler));
275 if (!compiler)
276 return NULL;
277 SLJIT_ZEROMEM(compiler, sizeof(struct sljit_compiler));
278
279 SLJIT_COMPILE_ASSERT(
280 sizeof(sljit_b) == 1 && sizeof(sljit_ub) == 1
281 && sizeof(sljit_h) == 2 && sizeof(sljit_uh) == 2
282 && sizeof(sljit_i) == 4 && sizeof(sljit_ui) == 4
283 && (sizeof(sljit_p) == 4 || sizeof(sljit_p) == 8)
284 && (sizeof(sljit_w) == 4 || sizeof(sljit_w) == 8)
285 && (sizeof(sljit_uw) == 4 || sizeof(sljit_uw) == 8),
286 invalid_integer_types);
287
288 /* Only the non-zero members must be set. */
289 compiler->error = SLJIT_SUCCESS;
290
291 compiler->buf = (struct sljit_memory_fragment*)SLJIT_MALLOC(BUF_SIZE);
292 compiler->abuf = (struct sljit_memory_fragment*)SLJIT_MALLOC(ABUF_SIZE);
293
294 if (!compiler->buf || !compiler->abuf) {
295 if (compiler->buf)
296 SLJIT_FREE(compiler->buf);
297 if (compiler->abuf)
298 SLJIT_FREE(compiler->abuf);
299 SLJIT_FREE(compiler);
300 return NULL;
301 }
302
303 compiler->buf->next = NULL;
304 compiler->buf->used_size = 0;
305 compiler->abuf->next = NULL;
306 compiler->abuf->used_size = 0;
307
308 compiler->temporaries = -1;
309 compiler->saveds = -1;
310
311 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
312 compiler->args = -1;
313 #endif
314
315 #if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5)
316 compiler->cpool = (sljit_uw*)SLJIT_MALLOC(CPOOL_SIZE * sizeof(sljit_uw) + CPOOL_SIZE * sizeof(sljit_ub));
317 if (!compiler->cpool) {
318 SLJIT_FREE(compiler->buf);
319 SLJIT_FREE(compiler->abuf);
320 SLJIT_FREE(compiler);
321 return NULL;
322 }
323 compiler->cpool_unique = (sljit_ub*)(compiler->cpool + CPOOL_SIZE);
324 compiler->cpool_diff = 0xffffffff;
325 #endif
326
327 #if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
328 compiler->delay_slot = UNMOVABLE_INS;
329 #endif
330
331 #if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
332 compiler->delay_slot = UNMOVABLE_INS;
333 #endif
334
335 #if (defined SLJIT_NEEDS_COMPILER_INIT && SLJIT_NEEDS_COMPILER_INIT)
336 if (!compiler_initialized) {
337 init_compiler();
338 compiler_initialized = 1;
339 }
340 #endif
341
342 return compiler;
343 }
344
345 SLJIT_API_FUNC_ATTRIBUTE void sljit_free_compiler(struct sljit_compiler *compiler)
346 {
347 struct sljit_memory_fragment *buf;
348 struct sljit_memory_fragment *curr;
349
350 buf = compiler->buf;
351 while (buf) {
352 curr = buf;
353 buf = buf->next;
354 SLJIT_FREE(curr);
355 }
356
357 buf = compiler->abuf;
358 while (buf) {
359 curr = buf;
360 buf = buf->next;
361 SLJIT_FREE(curr);
362 }
363
364 #if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5)
365 SLJIT_FREE(compiler->cpool);
366 #endif
367 SLJIT_FREE(compiler);
368 }
369
370 #if (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
371 SLJIT_API_FUNC_ATTRIBUTE void sljit_free_code(void* code)
372 {
373 /* Remove thumb mode flag. */
374 SLJIT_FREE_EXEC((void*)((sljit_uw)code & ~0x1));
375 }
376 #elif (defined SLJIT_INDIRECT_CALL && SLJIT_INDIRECT_CALL)
377 SLJIT_API_FUNC_ATTRIBUTE void sljit_free_code(void* code)
378 {
379 /* Resolve indirection. */
380 code = (void*)(*(sljit_uw*)code);
381 SLJIT_FREE_EXEC(code);
382 }
383 #else
384 SLJIT_API_FUNC_ATTRIBUTE void sljit_free_code(void* code)
385 {
386 SLJIT_FREE_EXEC(code);
387 }
388 #endif
389
390 SLJIT_API_FUNC_ATTRIBUTE void sljit_set_label(struct sljit_jump *jump, struct sljit_label* label)
391 {
392 if (SLJIT_LIKELY(!!jump) && SLJIT_LIKELY(!!label)) {
393 jump->flags &= ~JUMP_ADDR;
394 jump->flags |= JUMP_LABEL;
395 jump->u.label = label;
396 }
397 }
398
399 SLJIT_API_FUNC_ATTRIBUTE void sljit_set_target(struct sljit_jump *jump, sljit_uw target)
400 {
401 if (SLJIT_LIKELY(!!jump)) {
402 SLJIT_ASSERT(jump->flags & SLJIT_REWRITABLE_JUMP);
403
404 jump->flags &= ~JUMP_LABEL;
405 jump->flags |= JUMP_ADDR;
406 jump->u.target = target;
407 }
408 }
409
410 /* --------------------------------------------------------------------- */
411 /* Private functions */
412 /* --------------------------------------------------------------------- */
413
414 static void* ensure_buf(struct sljit_compiler *compiler, int size)
415 {
416 sljit_ub *ret;
417 struct sljit_memory_fragment *new_frag;
418
419 if (compiler->buf->used_size + size <= (int)(BUF_SIZE - sizeof(sljit_uw) - sizeof(void*))) {
420 ret = compiler->buf->memory + compiler->buf->used_size;
421 compiler->buf->used_size += size;
422 return ret;
423 }
424 new_frag = (struct sljit_memory_fragment*)SLJIT_MALLOC(BUF_SIZE);
425 PTR_FAIL_IF_NULL(new_frag);
426 new_frag->next = compiler->buf;
427 compiler->buf = new_frag;
428 new_frag->used_size = size;
429 return new_frag->memory;
430 }
431
432 static void* ensure_abuf(struct sljit_compiler *compiler, int size)
433 {
434 sljit_ub *ret;
435 struct sljit_memory_fragment *new_frag;
436
437 if (compiler->abuf->used_size + size <= (int)(ABUF_SIZE - sizeof(sljit_uw) - sizeof(void*))) {
438 ret = compiler->abuf->memory + compiler->abuf->used_size;
439 compiler->abuf->used_size += size;
440 return ret;
441 }
442 new_frag = (struct sljit_memory_fragment*)SLJIT_MALLOC(ABUF_SIZE);
443 PTR_FAIL_IF_NULL(new_frag);
444 new_frag->next = compiler->abuf;
445 compiler->abuf = new_frag;
446 new_frag->used_size = size;
447 return new_frag->memory;
448 }
449
450 SLJIT_API_FUNC_ATTRIBUTE void* sljit_alloc_memory(struct sljit_compiler *compiler, int size)
451 {
452 CHECK_ERROR_PTR();
453
454 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
455 if (size <= 0 || size > 128)
456 return NULL;
457 size = (size + 7) & ~7;
458 #else
459 if (size <= 0 || size > 64)
460 return NULL;
461 size = (size + 3) & ~3;
462 #endif
463 return ensure_abuf(compiler, size);
464 }
465
466 static SLJIT_INLINE void reverse_buf(struct sljit_compiler *compiler)
467 {
468 struct sljit_memory_fragment *buf = compiler->buf;
469 struct sljit_memory_fragment *prev = NULL;
470 struct sljit_memory_fragment *tmp;
471
472 do {
473 tmp = buf->next;
474 buf->next = prev;
475 prev = buf;
476 buf = tmp;
477 } while (buf != NULL);
478
479 compiler->buf = prev;
480 }
481
482 static SLJIT_INLINE void set_label(struct sljit_label *label, struct sljit_compiler *compiler)
483 {
484 label->next = NULL;
485 label->size = compiler->size;
486 if (compiler->last_label)
487 compiler->last_label->next = label;
488 else
489 compiler->labels = label;
490 compiler->last_label = label;
491 }
492
493 static SLJIT_INLINE void set_jump(struct sljit_jump *jump, struct sljit_compiler *compiler, int flags)
494 {
495 jump->next = NULL;
496 jump->flags = flags;
497 if (compiler->last_jump)
498 compiler->last_jump->next = jump;
499 else
500 compiler->jumps = jump;
501 compiler->last_jump = jump;
502 }
503
504 static SLJIT_INLINE void set_const(struct sljit_const *const_, struct sljit_compiler *compiler)
505 {
506 const_->next = NULL;
507 const_->addr = compiler->size;
508 if (compiler->last_const)
509 compiler->last_const->next = const_;
510 else
511 compiler->consts = const_;
512 compiler->last_const = const_;
513 }
514
515 #define ADDRESSING_DEPENDS_ON(exp, reg) \
516 (((exp) & SLJIT_MEM) && (((exp) & 0xf) == reg || (((exp) >> 4) & 0xf) == reg))
517
518 #if (defined SLJIT_DEBUG && SLJIT_DEBUG)
519 #define FUNCTION_CHECK_OP() \
520 SLJIT_ASSERT(!GET_FLAGS(op) || !(op & SLJIT_KEEP_FLAGS)); \
521 switch (GET_OPCODE(op)) { \
522 case SLJIT_NOT: \
523 case SLJIT_CLZ: \
524 case SLJIT_AND: \
525 case SLJIT_OR: \
526 case SLJIT_XOR: \
527 case SLJIT_SHL: \
528 case SLJIT_LSHR: \
529 case SLJIT_ASHR: \
530 SLJIT_ASSERT(!(op & (SLJIT_SET_S | SLJIT_SET_U | SLJIT_SET_O | SLJIT_SET_C))); \
531 break; \
532 case SLJIT_NEG: \
533 SLJIT_ASSERT(!(op & (SLJIT_SET_S | SLJIT_SET_U | SLJIT_SET_C))); \
534 break; \
535 case SLJIT_MUL: \
536 SLJIT_ASSERT(!(op & (SLJIT_SET_E | SLJIT_SET_S | SLJIT_SET_U | SLJIT_SET_C))); \
537 break; \
538 case SLJIT_FCMP: \
539 SLJIT_ASSERT(!(op & (SLJIT_INT_OP | SLJIT_SET_U | SLJIT_SET_O | SLJIT_SET_C | SLJIT_KEEP_FLAGS))); \
540 SLJIT_ASSERT((op & (SLJIT_SET_E | SLJIT_SET_S))); \
541 break; \
542 case SLJIT_ADD: \
543 SLJIT_ASSERT(!(op & (SLJIT_SET_S | SLJIT_SET_U))); \
544 break; \
545 case SLJIT_SUB: \
546 break; \
547 case SLJIT_ADDC: \
548 case SLJIT_SUBC: \
549 SLJIT_ASSERT(!(op & (SLJIT_SET_E | SLJIT_SET_S | SLJIT_SET_U | SLJIT_SET_O))); \
550 break; \
551 default: \
552 /* Nothing allowed */ \
553 SLJIT_ASSERT(!(op & (SLJIT_INT_OP | SLJIT_SET_E | SLJIT_SET_S | SLJIT_SET_U | SLJIT_SET_O | SLJIT_SET_C | SLJIT_KEEP_FLAGS))); \
554 break; \
555 }
556
557 #define FUNCTION_CHECK_IS_REG(r) \
558 ((r) == SLJIT_UNUSED || \
559 ((r) >= SLJIT_TEMPORARY_REG1 && (r) <= SLJIT_TEMPORARY_REG1 - 1 + compiler->temporaries) || \
560 ((r) >= SLJIT_SAVED_REG1 && (r) <= SLJIT_SAVED_REG1 - 1 + compiler->saveds))
561
562 #define FUNCTION_CHECK_SRC(p, i) \
563 SLJIT_ASSERT(compiler->temporaries != -1 && compiler->saveds != -1); \
564 if (FUNCTION_CHECK_IS_REG(p)) \
565 SLJIT_ASSERT((i) == 0 && (p) != SLJIT_UNUSED); \
566 else if ((p) == SLJIT_IMM) \
567 ; \
568 else if ((p) == (SLJIT_MEM1(SLJIT_LOCALS_REG))) \
569 SLJIT_ASSERT((i) >= 0 && (i) < compiler->logical_local_size); \
570 else if ((p) & SLJIT_MEM) { \
571 SLJIT_ASSERT(FUNCTION_CHECK_IS_REG((p) & 0xf)); \
572 if ((p) & 0xf0) { \
573 SLJIT_ASSERT(FUNCTION_CHECK_IS_REG(((p) >> 4) & 0xf)); \
574 SLJIT_ASSERT(!((i) & ~0x3)); \
575 } \
576 SLJIT_ASSERT(((p) >> 9) == 0); \
577 } \
578 else \
579 SLJIT_ASSERT_STOP();
580
581 #define FUNCTION_CHECK_DST(p, i) \
582 SLJIT_ASSERT(compiler->temporaries != -1 && compiler->saveds != -1); \
583 if (FUNCTION_CHECK_IS_REG(p)) \
584 SLJIT_ASSERT((i) == 0); \
585 else if ((p) == (SLJIT_MEM1(SLJIT_LOCALS_REG))) \
586 SLJIT_ASSERT((i) >= 0 && (i) < compiler->logical_local_size); \
587 else if ((p) & SLJIT_MEM) { \
588 SLJIT_ASSERT(FUNCTION_CHECK_IS_REG((p) & 0xf)); \
589 if ((p) & 0xf0) { \
590 SLJIT_ASSERT(FUNCTION_CHECK_IS_REG(((p) >> 4) & 0xf)); \
591 SLJIT_ASSERT(!((i) & ~0x3)); \
592 } \
593 SLJIT_ASSERT(((p) >> 9) == 0); \
594 } \
595 else \
596 SLJIT_ASSERT_STOP();
597
598 #define FUNCTION_FCHECK(p, i) \
599 if ((p) >= SLJIT_FLOAT_REG1 && (p) <= SLJIT_FLOAT_REG4) \
600 SLJIT_ASSERT(i == 0); \
601 else if ((p) & SLJIT_MEM) { \
602 SLJIT_ASSERT(FUNCTION_CHECK_IS_REG((p) & 0xf)); \
603 if ((p) & 0xf0) { \
604 SLJIT_ASSERT(FUNCTION_CHECK_IS_REG(((p) >> 4) & 0xf)); \
605 SLJIT_ASSERT(((p) & 0xf0) != (SLJIT_LOCALS_REG << 4) && !(i & ~0x3)); \
606 } else \
607 SLJIT_ASSERT((((p) >> 4) & 0xf) == 0); \
608 SLJIT_ASSERT(((p) >> 9) == 0); \
609 } \
610 else \
611 SLJIT_ASSERT_STOP();
612
613 #define FUNCTION_CHECK_OP1() \
614 if (GET_OPCODE(op) >= SLJIT_MOV && GET_OPCODE(op) <= SLJIT_MOVU_P) { \
615 SLJIT_ASSERT(!GET_ALL_FLAGS(op)); \
616 } \
617 if (GET_OPCODE(op) >= SLJIT_MOVU && GET_OPCODE(op) <= SLJIT_MOVU_P) { \
618 SLJIT_ASSERT(!(src & SLJIT_MEM) || (src & 0xf) != SLJIT_LOCALS_REG); \
619 SLJIT_ASSERT(!(dst & SLJIT_MEM) || (dst & 0xf) != SLJIT_LOCALS_REG); \
620 if ((src & SLJIT_MEM) && (src & 0xf)) \
621 SLJIT_ASSERT((dst & 0xf) != (src & 0xf) && ((dst >> 4) & 0xf) != (src & 0xf)); \
622 }
623
624 #endif
625
626 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
627
628 SLJIT_API_FUNC_ATTRIBUTE void sljit_compiler_verbose(struct sljit_compiler *compiler, FILE* verbose)
629 {
630 compiler->verbose = verbose;
631 }
632
633 static char* reg_names[] = {
634 (char*)"<noreg>", (char*)"t1", (char*)"t2", (char*)"t3",
635 (char*)"te1", (char*)"te2", (char*)"s1", (char*)"s2",
636 (char*)"s3", (char*)"se1", (char*)"se2", (char*)"lcr"
637 };
638
639 static char* freg_names[] = {
640 (char*)"<noreg>", (char*)"float_r1", (char*)"float_r2", (char*)"float_r3", (char*)"float_r4"
641 };
642
643 #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) || (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
644 #ifdef _WIN64
645 #define SLJIT_PRINT_D "I64"
646 #else
647 #define SLJIT_PRINT_D "l"
648 #endif
649 #else
650 #define SLJIT_PRINT_D ""
651 #endif
652
653 #define sljit_verbose_param(p, i) \
654 if ((p) & SLJIT_IMM) \
655 fprintf(compiler->verbose, "#%" SLJIT_PRINT_D "d", (i)); \
656 else if ((p) & SLJIT_MEM) { \
657 if ((p) & 0xf) { \
658 if (i) { \
659 if (((p) >> 4) & 0xf) \
660 fprintf(compiler->verbose, "[%s + %s * %d]", reg_names[(p) & 0xF], reg_names[((p) >> 4)& 0xF], 1 << (i)); \
661 else \
662 fprintf(compiler->verbose, "[%s + #%" SLJIT_PRINT_D "d]", reg_names[(p) & 0xF], (i)); \
663 } \
664 else { \
665 if (((p) >> 4) & 0xf) \
666 fprintf(compiler->verbose, "[%s + %s]", reg_names[(p) & 0xF], reg_names[((p) >> 4)& 0xF]); \
667 else \
668 fprintf(compiler->verbose, "[%s]", reg_names[(p) & 0xF]); \
669 } \
670 } \
671 else \
672 fprintf(compiler->verbose, "[#%" SLJIT_PRINT_D "d]", (i)); \
673 } else \
674 fprintf(compiler->verbose, "%s", reg_names[p]);
675 #define sljit_verbose_fparam(p, i) \
676 if ((p) & SLJIT_MEM) { \
677 if ((p) & 0xf) { \
678 if (i) { \
679 if (((p) >> 4) & 0xf) \
680 fprintf(compiler->verbose, "[%s + %s * %d]", reg_names[(p) & 0xF], reg_names[((p) >> 4)& 0xF], 1 << (i)); \
681 else \
682 fprintf(compiler->verbose, "[%s + #%" SLJIT_PRINT_D "d]", reg_names[(p) & 0xF], (i)); \
683 } \
684 else { \
685 if (((p) >> 4) & 0xF) \
686 fprintf(compiler->verbose, "[%s + %s]", reg_names[(p) & 0xF], reg_names[((p) >> 4)& 0xF]); \
687 else \
688 fprintf(compiler->verbose, "[%s]", reg_names[(p) & 0xF]); \
689 } \
690 } \
691 else \
692 fprintf(compiler->verbose, "[#%" SLJIT_PRINT_D "d]", (i)); \
693 } else \
694 fprintf(compiler->verbose, "%s", freg_names[p]);
695
696 static SLJIT_CONST char* op_names[] = {
697 /* op0 */
698 (char*)"breakpoint", (char*)"nop",
699 (char*)"umul", (char*)"smul", (char*)"udiv", (char*)"sdiv",
700 /* op1 */
701 (char*)"mov", (char*)"mov.ub", (char*)"mov.sb", (char*)"mov.uh",
702 (char*)"mov.sh", (char*)"mov.ui", (char*)"mov.si", (char*)"mov.p",
703 (char*)"movu", (char*)"movu.ub", (char*)"movu.sb", (char*)"movu.uh",
704 (char*)"movu.sh", (char*)"movu.ui", (char*)"movu.si", (char*)"movu.p",
705 (char*)"not", (char*)"neg", (char*)"clz",
706 /* op2 */
707 (char*)"add", (char*)"addc", (char*)"sub", (char*)"subc",
708 (char*)"mul", (char*)"and", (char*)"or", (char*)"xor",
709 (char*)"shl", (char*)"lshr", (char*)"ashr",
710 /* fop1 */
711 (char*)"fcmp", (char*)"fmov", (char*)"fneg", (char*)"fabs",
712 /* fop2 */
713 (char*)"fadd", (char*)"fsub", (char*)"fmul", (char*)"fdiv"
714 };
715
716 static char* jump_names[] = {
717 (char*)"c_equal", (char*)"c_not_equal",
718 (char*)"c_less", (char*)"c_greater_equal",
719 (char*)"c_greater", (char*)"c_less_equal",
720 (char*)"c_sig_less", (char*)"c_sig_greater_equal",
721 (char*)"c_sig_greater", (char*)"c_sig_less_equal",
722 (char*)"c_overflow", (char*)"c_not_overflow",
723 (char*)"c_mul_overflow", (char*)"c_mul_not_overflow",
724 (char*)"c_float_equal", (char*)"c_float_not_equal",
725 (char*)"c_float_less", (char*)"c_float_greater_equal",
726 (char*)"c_float_greater", (char*)"c_float_less_equal",
727 (char*)"c_float_nan", (char*)"c_float_not_nan",
728 (char*)"jump", (char*)"fast_call",
729 (char*)"call0", (char*)"call1", (char*)"call2", (char*)"call3"
730 };
731
732 #endif
733
734 /* --------------------------------------------------------------------- */
735 /* Arch dependent */
736 /* --------------------------------------------------------------------- */
737
738 static SLJIT_INLINE void check_sljit_generate_code(struct sljit_compiler *compiler)
739 {
740 #if (defined SLJIT_DEBUG && SLJIT_DEBUG)
741 struct sljit_jump *jump;
742 #endif
743 /* If debug and verbose are disabled, all arguments are unused. */
744 SLJIT_UNUSED_ARG(compiler);
745
746 SLJIT_ASSERT(compiler->size > 0);
747 #if (defined SLJIT_DEBUG && SLJIT_DEBUG)
748 jump = compiler->jumps;
749 while (jump) {
750 /* All jumps have target. */
751 SLJIT_ASSERT(jump->flags & (JUMP_LABEL | JUMP_ADDR));
752 jump = jump->next;
753 }
754 #endif
755 }
756
757 static SLJIT_INLINE void check_sljit_emit_enter(struct sljit_compiler *compiler, int args, int temporaries, int saveds, int local_size)
758 {
759 /* If debug and verbose are disabled, all arguments are unused. */
760 SLJIT_UNUSED_ARG(compiler);
761 SLJIT_UNUSED_ARG(args);
762 SLJIT_UNUSED_ARG(temporaries);
763 SLJIT_UNUSED_ARG(saveds);
764 SLJIT_UNUSED_ARG(local_size);
765
766 SLJIT_ASSERT(args >= 0 && args <= 3);
767 SLJIT_ASSERT(temporaries >= 0 && temporaries <= SLJIT_NO_TMP_REGISTERS);
768 SLJIT_ASSERT(saveds >= 0 && saveds <= SLJIT_NO_GEN_REGISTERS);
769 SLJIT_ASSERT(args <= saveds);
770 SLJIT_ASSERT(local_size >= 0 && local_size <= SLJIT_MAX_LOCAL_SIZE);
771 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
772 if (SLJIT_UNLIKELY(!!compiler->verbose))
773 fprintf(compiler->verbose, " enter args=%d temporaries=%d saveds=%d local_size=%d\n", args, temporaries, saveds, local_size);
774 #endif
775 }
776
777 static SLJIT_INLINE void check_sljit_set_context(struct sljit_compiler *compiler, int args, int temporaries, int saveds, int local_size)
778 {
779 /* If debug and verbose are disabled, all arguments are unused. */
780 SLJIT_UNUSED_ARG(compiler);
781 SLJIT_UNUSED_ARG(args);
782 SLJIT_UNUSED_ARG(temporaries);
783 SLJIT_UNUSED_ARG(saveds);
784 SLJIT_UNUSED_ARG(local_size);
785
786 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG)
787 if (SLJIT_UNLIKELY(compiler->skip_checks)) {
788 compiler->skip_checks = 0;
789 return;
790 }
791 #endif
792
793 SLJIT_ASSERT(args >= 0 && args <= 3);
794 SLJIT_ASSERT(temporaries >= 0 && temporaries <= SLJIT_NO_TMP_REGISTERS);
795 SLJIT_ASSERT(saveds >= 0 && saveds <= SLJIT_NO_GEN_REGISTERS);
796 SLJIT_ASSERT(args <= saveds);
797 SLJIT_ASSERT(local_size >= 0 && local_size <= SLJIT_MAX_LOCAL_SIZE);
798 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
799 if (SLJIT_UNLIKELY(!!compiler->verbose))
800 fprintf(compiler->verbose, " set_context args=%d temporaries=%d saveds=%d local_size=%d\n", args, temporaries, saveds, local_size);
801 #endif
802 }
803
804 static SLJIT_INLINE void check_sljit_emit_return(struct sljit_compiler *compiler, int op, int src, sljit_w srcw)
805 {
806 /* If debug and verbose are disabled, all arguments are unused. */
807 SLJIT_UNUSED_ARG(compiler);
808 SLJIT_UNUSED_ARG(op);
809 SLJIT_UNUSED_ARG(src);
810 SLJIT_UNUSED_ARG(srcw);
811
812 #if (defined SLJIT_DEBUG && SLJIT_DEBUG)
813 if (op != SLJIT_UNUSED) {
814 SLJIT_ASSERT(op >= SLJIT_MOV && op <= SLJIT_MOV_P);
815 FUNCTION_CHECK_SRC(src, srcw);
816 }
817 else
818 SLJIT_ASSERT(src == 0 && srcw == 0);
819 #endif
820 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
821 if (SLJIT_UNLIKELY(!!compiler->verbose)) {
822 if (op == SLJIT_UNUSED)
823 fprintf(compiler->verbose, " return\n");
824 else {
825 fprintf(compiler->verbose, " return %s ", op_names[op]);
826 sljit_verbose_param(src, srcw);
827 fprintf(compiler->verbose, "\n");
828 }
829 }
830 #endif
831 }
832
833 static SLJIT_INLINE void check_sljit_emit_fast_enter(struct sljit_compiler *compiler, int dst, sljit_w dstw)
834 {
835 /* If debug and verbose are disabled, all arguments are unused. */
836 SLJIT_UNUSED_ARG(compiler);
837 SLJIT_UNUSED_ARG(dst);
838 SLJIT_UNUSED_ARG(dstw);
839
840 #if (defined SLJIT_DEBUG && SLJIT_DEBUG)
841 FUNCTION_CHECK_DST(dst, dstw);
842 #endif
843 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
844 if (SLJIT_UNLIKELY(!!compiler->verbose)) {
845 fprintf(compiler->verbose, " fast_enter ");
846 sljit_verbose_param(dst, dstw);
847 fprintf(compiler->verbose, "\n");
848 }
849 #endif
850 }
851
852 static SLJIT_INLINE void check_sljit_emit_fast_return(struct sljit_compiler *compiler, int src, sljit_w srcw)
853 {
854 /* If debug and verbose are disabled, all arguments are unused. */
855 SLJIT_UNUSED_ARG(compiler);
856 SLJIT_UNUSED_ARG(src);
857 SLJIT_UNUSED_ARG(srcw);
858
859 #if (defined SLJIT_DEBUG && SLJIT_DEBUG)
860 FUNCTION_CHECK_SRC(src, srcw);
861 #endif
862 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
863 if (SLJIT_UNLIKELY(!!compiler->verbose)) {
864 fprintf(compiler->verbose, " fast_return ");
865 sljit_verbose_param(src, srcw);
866 fprintf(compiler->verbose, "\n");
867 }
868 #endif
869 }
870
871 static SLJIT_INLINE void check_sljit_emit_op0(struct sljit_compiler *compiler, int op)
872 {
873 /* If debug and verbose are disabled, all arguments are unused. */
874 SLJIT_UNUSED_ARG(compiler);
875 SLJIT_UNUSED_ARG(op);
876
877 SLJIT_ASSERT((op >= SLJIT_BREAKPOINT && op <= SLJIT_SMUL)
878 || ((op & ~SLJIT_INT_OP) >= SLJIT_UDIV && (op & ~SLJIT_INT_OP) <= SLJIT_SDIV));
879 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
880 if (SLJIT_UNLIKELY(!!compiler->verbose))
881 fprintf(compiler->verbose, " %s%s\n", !(op & SLJIT_INT_OP) ? "" : "i", op_names[GET_OPCODE(op)]);
882 #endif
883 }
884
885 static SLJIT_INLINE void check_sljit_emit_op1(struct sljit_compiler *compiler, int op,
886 int dst, sljit_w dstw,
887 int src, sljit_w srcw)
888 {
889 /* If debug and verbose are disabled, all arguments are unused. */
890 SLJIT_UNUSED_ARG(compiler);
891 SLJIT_UNUSED_ARG(op);
892 SLJIT_UNUSED_ARG(dst);
893 SLJIT_UNUSED_ARG(dstw);
894 SLJIT_UNUSED_ARG(src);
895 SLJIT_UNUSED_ARG(srcw);
896
897 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG)
898 if (SLJIT_UNLIKELY(compiler->skip_checks)) {
899 compiler->skip_checks = 0;
900 return;
901 }
902 #endif
903
904 SLJIT_ASSERT(GET_OPCODE(op) >= SLJIT_MOV && GET_OPCODE(op) <= SLJIT_CLZ);
905 #if (defined SLJIT_DEBUG && SLJIT_DEBUG)
906 FUNCTION_CHECK_OP();
907 FUNCTION_CHECK_SRC(src, srcw);
908 FUNCTION_CHECK_DST(dst, dstw);
909 FUNCTION_CHECK_OP1();
910 #endif
911 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
912 if (SLJIT_UNLIKELY(!!compiler->verbose)) {
913 fprintf(compiler->verbose, " %s%s%s%s%s%s%s%s ", !(op & SLJIT_INT_OP) ? "" : "i", op_names[GET_OPCODE(op)],
914 !(op & SLJIT_SET_E) ? "" : "E", !(op & SLJIT_SET_S) ? "" : "S", !(op & SLJIT_SET_U) ? "" : "U", !(op & SLJIT_SET_O) ? "" : "O", !(op & SLJIT_SET_C) ? "" : "C", !(op & SLJIT_KEEP_FLAGS) ? "" : "K");
915 sljit_verbose_param(dst, dstw);
916 fprintf(compiler->verbose, ", ");
917 sljit_verbose_param(src, srcw);
918 fprintf(compiler->verbose, "\n");
919 }
920 #endif
921 }
922
923 static SLJIT_INLINE void check_sljit_emit_op2(struct sljit_compiler *compiler, int op,
924 int dst, sljit_w dstw,
925 int src1, sljit_w src1w,
926 int src2, sljit_w src2w)
927 {
928 /* If debug and verbose are disabled, all arguments are unused. */
929 SLJIT_UNUSED_ARG(compiler);
930 SLJIT_UNUSED_ARG(op);
931 SLJIT_UNUSED_ARG(dst);
932 SLJIT_UNUSED_ARG(dstw);
933 SLJIT_UNUSED_ARG(src1);
934 SLJIT_UNUSED_ARG(src1w);
935 SLJIT_UNUSED_ARG(src2);
936 SLJIT_UNUSED_ARG(src2w);
937
938 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG)
939 if (SLJIT_UNLIKELY(compiler->skip_checks)) {
940 compiler->skip_checks = 0;
941 return;
942 }
943 #endif
944
945 SLJIT_ASSERT(GET_OPCODE(op) >= SLJIT_ADD && GET_OPCODE(op) <= SLJIT_ASHR);
946 #if (defined SLJIT_DEBUG && SLJIT_DEBUG)
947 FUNCTION_CHECK_OP();
948 FUNCTION_CHECK_SRC(src1, src1w);
949 FUNCTION_CHECK_SRC(src2, src2w);
950 FUNCTION_CHECK_DST(dst, dstw);
951 #endif
952 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
953 if (SLJIT_UNLIKELY(!!compiler->verbose)) {
954 fprintf(compiler->verbose, " %s%s%s%s%s%s%s%s ", !(op & SLJIT_INT_OP) ? "" : "i", op_names[GET_OPCODE(op)],
955 !(op & SLJIT_SET_E) ? "" : "E", !(op & SLJIT_SET_S) ? "" : "S", !(op & SLJIT_SET_U) ? "" : "U", !(op & SLJIT_SET_O) ? "" : "O", !(op & SLJIT_SET_C) ? "" : "C", !(op & SLJIT_KEEP_FLAGS) ? "" : "K");
956 sljit_verbose_param(dst, dstw);
957 fprintf(compiler->verbose, ", ");
958 sljit_verbose_param(src1, src1w);
959 fprintf(compiler->verbose, ", ");
960 sljit_verbose_param(src2, src2w);
961 fprintf(compiler->verbose, "\n");
962 }
963 #endif
964 }
965
966 static SLJIT_INLINE void check_sljit_get_register_index(int reg)
967 {
968 SLJIT_UNUSED_ARG(reg);
969 SLJIT_ASSERT(reg > 0 && reg <= SLJIT_NO_REGISTERS);
970 }
971
972 static SLJIT_INLINE void check_sljit_emit_op_custom(struct sljit_compiler *compiler,
973 void *instruction, int size)
974 {
975 SLJIT_UNUSED_ARG(compiler);
976 SLJIT_UNUSED_ARG(instruction);
977 SLJIT_UNUSED_ARG(size);
978 SLJIT_ASSERT(instruction);
979 }
980
981 static SLJIT_INLINE void check_sljit_emit_fop1(struct sljit_compiler *compiler, int op,
982 int dst, sljit_w dstw,
983 int src, sljit_w srcw)
984 {
985 /* If debug and verbose are disabled, all arguments are unused. */
986 SLJIT_UNUSED_ARG(compiler);
987 SLJIT_UNUSED_ARG(op);
988 SLJIT_UNUSED_ARG(dst);
989 SLJIT_UNUSED_ARG(dstw);
990 SLJIT_UNUSED_ARG(src);
991 SLJIT_UNUSED_ARG(srcw);
992
993 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG)
994 if (SLJIT_UNLIKELY(compiler->skip_checks)) {
995 compiler->skip_checks = 0;
996 return;
997 }
998 #endif
999
1000 SLJIT_ASSERT(sljit_is_fpu_available());
1001 SLJIT_ASSERT(GET_OPCODE(op) >= SLJIT_FCMP && GET_OPCODE(op) <= SLJIT_FABS);
1002 #if (defined SLJIT_DEBUG && SLJIT_DEBUG)
1003 FUNCTION_CHECK_OP();
1004 FUNCTION_FCHECK(src, srcw);
1005 FUNCTION_FCHECK(dst, dstw);
1006 #endif
1007 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1008 if (SLJIT_UNLIKELY(!!compiler->verbose)) {
1009 fprintf(compiler->verbose, " %s%s%s ", op_names[GET_OPCODE(op)],
1010 !(op & SLJIT_SET_E) ? "" : "E", !(op & SLJIT_SET_S) ? "" : "S");
1011 sljit_verbose_fparam(dst, dstw);
1012 fprintf(compiler->verbose, ", ");
1013 sljit_verbose_fparam(src, srcw);
1014 fprintf(compiler->verbose, "\n");
1015 }
1016 #endif
1017 }
1018
1019 static SLJIT_INLINE void check_sljit_emit_fop2(struct sljit_compiler *compiler, int op,
1020 int dst, sljit_w dstw,
1021 int src1, sljit_w src1w,
1022 int src2, sljit_w src2w)
1023 {
1024 /* If debug and verbose are disabled, all arguments are unused. */
1025 SLJIT_UNUSED_ARG(compiler);
1026 SLJIT_UNUSED_ARG(op);
1027 SLJIT_UNUSED_ARG(dst);
1028 SLJIT_UNUSED_ARG(dstw);
1029 SLJIT_UNUSED_ARG(src1);
1030 SLJIT_UNUSED_ARG(src1w);
1031 SLJIT_UNUSED_ARG(src2);
1032 SLJIT_UNUSED_ARG(src2w);
1033
1034 SLJIT_ASSERT(sljit_is_fpu_available());
1035 SLJIT_ASSERT(GET_OPCODE(op) >= SLJIT_FADD && GET_OPCODE(op) <= SLJIT_FDIV);
1036 #if (defined SLJIT_DEBUG && SLJIT_DEBUG)
1037 FUNCTION_CHECK_OP();
1038 FUNCTION_FCHECK(src1, src1w);
1039 FUNCTION_FCHECK(src2, src2w);
1040 FUNCTION_FCHECK(dst, dstw);
1041 #endif
1042 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1043 if (SLJIT_UNLIKELY(!!compiler->verbose)) {
1044 fprintf(compiler->verbose, " %s ", op_names[GET_OPCODE(op)]);
1045 sljit_verbose_fparam(dst, dstw);
1046 fprintf(compiler->verbose, ", ");
1047 sljit_verbose_fparam(src1, src1w);
1048 fprintf(compiler->verbose, ", ");
1049 sljit_verbose_fparam(src2, src2w);
1050 fprintf(compiler->verbose, "\n");
1051 }
1052 #endif
1053 }
1054
1055 static SLJIT_INLINE void check_sljit_emit_label(struct sljit_compiler *compiler)
1056 {
1057 /* If debug and verbose are disabled, all arguments are unused. */
1058 SLJIT_UNUSED_ARG(compiler);
1059
1060 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1061 if (SLJIT_UNLIKELY(!!compiler->verbose))
1062 fprintf(compiler->verbose, "label:\n");
1063 #endif
1064 }
1065
1066 static SLJIT_INLINE void check_sljit_emit_jump(struct sljit_compiler *compiler, int type)
1067 {
1068 /* If debug and verbose are disabled, all arguments are unused. */
1069 SLJIT_UNUSED_ARG(compiler);
1070 SLJIT_UNUSED_ARG(type);
1071
1072 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG)
1073 if (SLJIT_UNLIKELY(compiler->skip_checks)) {
1074 compiler->skip_checks = 0;
1075 return;
1076 }
1077 #endif
1078
1079 SLJIT_ASSERT(!(type & ~(0xff | SLJIT_REWRITABLE_JUMP)));
1080 SLJIT_ASSERT((type & 0xff) >= SLJIT_C_EQUAL && (type & 0xff) <= SLJIT_CALL3);
1081 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1082 if (SLJIT_UNLIKELY(!!compiler->verbose))
1083 fprintf(compiler->verbose, " jump%s <%s>\n", !(type & SLJIT_REWRITABLE_JUMP) ? "" : "R", jump_names[type & 0xff]);
1084 #endif
1085 }
1086
1087 static SLJIT_INLINE void check_sljit_emit_cmp(struct sljit_compiler *compiler, int type,
1088 int src1, sljit_w src1w,
1089 int src2, sljit_w src2w)
1090 {
1091 SLJIT_UNUSED_ARG(compiler);
1092 SLJIT_UNUSED_ARG(type);
1093 SLJIT_UNUSED_ARG(src1);
1094 SLJIT_UNUSED_ARG(src1w);
1095 SLJIT_UNUSED_ARG(src2);
1096 SLJIT_UNUSED_ARG(src2w);
1097
1098 SLJIT_ASSERT(!(type & ~(0xff | SLJIT_INT_OP | SLJIT_REWRITABLE_JUMP)));
1099 SLJIT_ASSERT((type & 0xff) >= SLJIT_C_EQUAL && (type & 0xff) <= SLJIT_C_SIG_LESS_EQUAL);
1100 #if (defined SLJIT_DEBUG && SLJIT_DEBUG)
1101 FUNCTION_CHECK_SRC(src1, src1w);
1102 FUNCTION_CHECK_SRC(src2, src2w);
1103 #endif
1104 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1105 if (SLJIT_UNLIKELY(!!compiler->verbose)) {
1106 fprintf(compiler->verbose, " %scmp%s <%s> ", !(type & SLJIT_INT_OP) ? "" : "i", !(type & SLJIT_REWRITABLE_JUMP) ? "" : "R", jump_names[type & 0xff]);
1107 sljit_verbose_param(src1, src1w);
1108 fprintf(compiler->verbose, ", ");
1109 sljit_verbose_param(src2, src2w);
1110 fprintf(compiler->verbose, "\n");
1111 }
1112 #endif
1113 }
1114
1115 static SLJIT_INLINE void check_sljit_emit_fcmp(struct sljit_compiler *compiler, int type,
1116 int src1, sljit_w src1w,
1117 int src2, sljit_w src2w)
1118 {
1119 SLJIT_UNUSED_ARG(compiler);
1120 SLJIT_UNUSED_ARG(type);
1121 SLJIT_UNUSED_ARG(src1);
1122 SLJIT_UNUSED_ARG(src1w);
1123 SLJIT_UNUSED_ARG(src2);
1124 SLJIT_UNUSED_ARG(src2w);
1125
1126 SLJIT_ASSERT(sljit_is_fpu_available());
1127 SLJIT_ASSERT(!(type & ~(0xff | SLJIT_REWRITABLE_JUMP)));
1128 SLJIT_ASSERT((type & 0xff) >= SLJIT_C_FLOAT_EQUAL && (type & 0xff) <= SLJIT_C_FLOAT_ORDERED);
1129 #if (defined SLJIT_DEBUG && SLJIT_DEBUG)
1130 FUNCTION_FCHECK(src1, src1w);
1131 FUNCTION_FCHECK(src2, src2w);
1132 #endif
1133 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1134 if (SLJIT_UNLIKELY(!!compiler->verbose)) {
1135 fprintf(compiler->verbose, " fcmp%s <%s> ", !(type & SLJIT_REWRITABLE_JUMP) ? "" : "R", jump_names[type & 0xff]);
1136 sljit_verbose_fparam(src1, src1w);
1137 fprintf(compiler->verbose, ", ");
1138 sljit_verbose_fparam(src2, src2w);
1139 fprintf(compiler->verbose, "\n");
1140 }
1141 #endif
1142 }
1143
1144 static SLJIT_INLINE void check_sljit_emit_ijump(struct sljit_compiler *compiler, int type, int src, sljit_w srcw)
1145 {
1146 /* If debug and verbose are disabled, all arguments are unused. */
1147 SLJIT_UNUSED_ARG(compiler);
1148 SLJIT_UNUSED_ARG(type);
1149 SLJIT_UNUSED_ARG(src);
1150 SLJIT_UNUSED_ARG(srcw);
1151
1152 SLJIT_ASSERT(type >= SLJIT_JUMP && type <= SLJIT_CALL3);
1153 #if (defined SLJIT_DEBUG && SLJIT_DEBUG)
1154 FUNCTION_CHECK_SRC(src, srcw);
1155 #endif
1156 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1157 if (SLJIT_UNLIKELY(!!compiler->verbose)) {
1158 fprintf(compiler->verbose, " ijump <%s> ", jump_names[type]);
1159 sljit_verbose_param(src, srcw);
1160 fprintf(compiler->verbose, "\n");
1161 }
1162 #endif
1163 }
1164
1165 static SLJIT_INLINE void check_sljit_emit_cond_value(struct sljit_compiler *compiler, int op, int dst, sljit_w dstw, int type)
1166 {
1167 /* If debug and verbose are disabled, all arguments are unused. */
1168 SLJIT_UNUSED_ARG(compiler);
1169 SLJIT_UNUSED_ARG(op);
1170 SLJIT_UNUSED_ARG(dst);
1171 SLJIT_UNUSED_ARG(dstw);
1172 SLJIT_UNUSED_ARG(type);
1173
1174 SLJIT_ASSERT(type >= SLJIT_C_EQUAL && type < SLJIT_JUMP);
1175 SLJIT_ASSERT(op == SLJIT_MOV || GET_OPCODE(op) == SLJIT_OR);
1176 SLJIT_ASSERT(GET_ALL_FLAGS(op) == 0 || GET_ALL_FLAGS(op) == SLJIT_SET_E || GET_ALL_FLAGS(op) == SLJIT_KEEP_FLAGS);
1177 #if (defined SLJIT_DEBUG && SLJIT_DEBUG)
1178 FUNCTION_CHECK_DST(dst, dstw);
1179 #endif
1180 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1181 if (SLJIT_UNLIKELY(!!compiler->verbose)) {
1182 fprintf(compiler->verbose, " cond_set%s%s <%s> ", !(op & SLJIT_SET_E) ? "" : "E",
1183 !(op & SLJIT_KEEP_FLAGS) ? "" : "K", op_names[GET_OPCODE(op)]);
1184 sljit_verbose_param(dst, dstw);
1185 fprintf(compiler->verbose, ", <%s>\n", jump_names[type]);
1186 }
1187 #endif
1188 }
1189
1190 static SLJIT_INLINE void check_sljit_get_local_base(struct sljit_compiler *compiler, int dst, sljit_w dstw, sljit_w offset)
1191 {
1192 SLJIT_UNUSED_ARG(compiler);
1193 SLJIT_UNUSED_ARG(dst);
1194 SLJIT_UNUSED_ARG(dstw);
1195 SLJIT_UNUSED_ARG(offset);
1196
1197 #if (defined SLJIT_DEBUG && SLJIT_DEBUG)
1198 FUNCTION_CHECK_DST(dst, dstw);
1199 #endif
1200 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1201 if (SLJIT_UNLIKELY(!!compiler->verbose)) {
1202 fprintf(compiler->verbose, " local_base ");
1203 sljit_verbose_param(dst, dstw);
1204 fprintf(compiler->verbose, ", #%" SLJIT_PRINT_D "d\n", offset);
1205 }
1206 #endif
1207 }
1208
1209 static SLJIT_INLINE void check_sljit_emit_const(struct sljit_compiler *compiler, int dst, sljit_w dstw, sljit_w init_value)
1210 {
1211 /* If debug and verbose are disabled, all arguments are unused. */
1212 SLJIT_UNUSED_ARG(compiler);
1213 SLJIT_UNUSED_ARG(dst);
1214 SLJIT_UNUSED_ARG(dstw);
1215 SLJIT_UNUSED_ARG(init_value);
1216
1217 #if (defined SLJIT_DEBUG && SLJIT_DEBUG)
1218 FUNCTION_CHECK_DST(dst, dstw);
1219 #endif
1220 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1221 if (SLJIT_UNLIKELY(!!compiler->verbose)) {
1222 fprintf(compiler->verbose, " const ");
1223 sljit_verbose_param(dst, dstw);
1224 fprintf(compiler->verbose, ", #%" SLJIT_PRINT_D "d\n", init_value);
1225 }
1226 #endif
1227 }
1228
1229 static SLJIT_INLINE int emit_mov_before_return(struct sljit_compiler *compiler, int op, int src, sljit_w srcw)
1230 {
1231 /* Return if don't need to do anything. */
1232 if (op == SLJIT_UNUSED)
1233 return SLJIT_SUCCESS;
1234
1235 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
1236 /* At the moment the pointer size is always equal to sljit_w. May be changed in the future. */
1237 if (src == SLJIT_RETURN_REG && (op == SLJIT_MOV || op == SLJIT_MOV_P))
1238 return SLJIT_SUCCESS;
1239 #else
1240 if (src == SLJIT_RETURN_REG && (op == SLJIT_MOV || op == SLJIT_MOV_UI || op == SLJIT_MOV_SI || op == SLJIT_MOV_P))
1241 return SLJIT_SUCCESS;
1242 #endif
1243
1244 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG)
1245 compiler->skip_checks = 1;
1246 #endif
1247 return sljit_emit_op1(compiler, op, SLJIT_RETURN_REG, 0, src, srcw);
1248 }
1249
1250 /* CPU description section */
1251
1252 #if (defined SLJIT_32BIT_ARCHITECTURE && SLJIT_32BIT_ARCHITECTURE)
1253 #define SLJIT_CPUINFO_PART1 " 32bit ("
1254 #elif (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
1255 #define SLJIT_CPUINFO_PART1 " 64bit ("
1256 #else
1257 #error "Internal error: CPU type info missing"
1258 #endif
1259
1260 #if (defined SLJIT_LITTLE_ENDIAN && SLJIT_LITTLE_ENDIAN)
1261 #define SLJIT_CPUINFO_PART2 "little endian + "
1262 #elif (defined SLJIT_BIG_ENDIAN && SLJIT_BIG_ENDIAN)
1263 #define SLJIT_CPUINFO_PART2 "big endian + "
1264 #else
1265 #error "Internal error: CPU type info missing"
1266 #endif
1267
1268 #if (defined SLJIT_UNALIGNED && SLJIT_UNALIGNED)
1269 #define SLJIT_CPUINFO_PART3 "unaligned)"
1270 #else
1271 #define SLJIT_CPUINFO_PART3 "aligned)"
1272 #endif
1273
1274 #define SLJIT_CPUINFO SLJIT_CPUINFO_PART1 SLJIT_CPUINFO_PART2 SLJIT_CPUINFO_PART3
1275
1276 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
1277 #include "sljitNativeX86_common.c"
1278 #elif (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
1279 #include "sljitNativeX86_common.c"
1280 #elif (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5)
1281 #include "sljitNativeARM_v5.c"
1282 #elif (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7)
1283 #include "sljitNativeARM_v5.c"
1284 #elif (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
1285 #include "sljitNativeARM_Thumb2.c"
1286 #elif (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32)
1287 #include "sljitNativePPC_common.c"
1288 #elif (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
1289 #include "sljitNativePPC_common.c"
1290 #elif (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
1291 #include "sljitNativeMIPS_common.c"
1292 #elif (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
1293 #include "sljitNativeSPARC_common.c"
1294 #endif
1295
1296 #if !(defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
1297
1298 SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_cmp(struct sljit_compiler *compiler, int type,
1299 int src1, sljit_w src1w,
1300 int src2, sljit_w src2w)
1301 {
1302 /* Default compare for most architectures. */
1303 int flags, tmp_src, condition;
1304 sljit_w tmp_srcw;
1305
1306 CHECK_ERROR_PTR();
1307 check_sljit_emit_cmp(compiler, type, src1, src1w, src2, src2w);
1308
1309 condition = type & 0xff;
1310 if (SLJIT_UNLIKELY((src1 & SLJIT_IMM) && !(src2 & SLJIT_IMM))) {
1311 /* Immediate is prefered as second argument by most architectures. */
1312 switch (condition) {
1313 case SLJIT_C_LESS:
1314 condition = SLJIT_C_GREATER;
1315 break;
1316 case SLJIT_C_GREATER_EQUAL:
1317 condition = SLJIT_C_LESS_EQUAL;
1318 break;
1319 case SLJIT_C_GREATER:
1320 condition = SLJIT_C_LESS;
1321 break;
1322 case SLJIT_C_LESS_EQUAL:
1323 condition = SLJIT_C_GREATER_EQUAL;
1324 break;
1325 case SLJIT_C_SIG_LESS:
1326 condition = SLJIT_C_SIG_GREATER;
1327 break;
1328 case SLJIT_C_SIG_GREATER_EQUAL:
1329 condition = SLJIT_C_SIG_LESS_EQUAL;
1330 break;
1331 case SLJIT_C_SIG_GREATER:
1332 condition = SLJIT_C_SIG_LESS;
1333 break;
1334 case SLJIT_C_SIG_LESS_EQUAL:
1335 condition = SLJIT_C_SIG_GREATER_EQUAL;
1336 break;
1337 }
1338 type = condition | (type & (SLJIT_INT_OP | SLJIT_REWRITABLE_JUMP));
1339 tmp_src = src1;
1340 src1 = src2;
1341 src2 = tmp_src;
1342 tmp_srcw = src1w;
1343 src1w = src2w;
1344 src2w = tmp_srcw;
1345 }
1346
1347 if (condition <= SLJIT_C_NOT_ZERO)
1348 flags = SLJIT_SET_E;
1349 else if (condition <= SLJIT_C_LESS_EQUAL)
1350 flags = SLJIT_SET_U;
1351 else
1352 flags = SLJIT_SET_S;
1353
1354 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG)
1355 compiler->skip_checks = 1;
1356 #endif
1357 PTR_FAIL_IF(sljit_emit_op2(compiler, SLJIT_SUB | flags | (type & SLJIT_INT_OP),
1358 SLJIT_UNUSED, 0, src1, src1w, src2, src2w));
1359 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG)
1360 compiler->skip_checks = 1;
1361 #endif
1362 return sljit_emit_jump(compiler, condition | (type & SLJIT_REWRITABLE_JUMP));
1363 }
1364
1365 SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_fcmp(struct sljit_compiler *compiler, int type,
1366 int src1, sljit_w src1w,
1367 int src2, sljit_w src2w)
1368 {
1369 int flags, condition;
1370
1371 check_sljit_emit_fcmp(compiler, type, src1, src1w, src2, src2w);
1372
1373 condition = type & 0xff;
1374 if (condition <= SLJIT_C_FLOAT_NOT_EQUAL)
1375 flags = SLJIT_SET_E;
1376 else
1377 flags = SLJIT_SET_S;
1378
1379 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG)
1380 compiler->skip_checks = 1;
1381 #endif
1382 sljit_emit_fop1(compiler, SLJIT_FCMP | flags, src1, src1w, src2, src2w);
1383
1384 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG)
1385 compiler->skip_checks = 1;
1386 #endif
1387 return sljit_emit_jump(compiler, condition | (type & SLJIT_REWRITABLE_JUMP));
1388 }
1389
1390 #endif
1391
1392 #if !(defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) && !(defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
1393
1394 SLJIT_API_FUNC_ATTRIBUTE int sljit_get_local_base(struct sljit_compiler *compiler, int dst, sljit_w dstw, sljit_w offset)
1395 {
1396 CHECK_ERROR();
1397 check_sljit_get_local_base(compiler, dst, dstw, offset);
1398
1399 ADJUST_LOCAL_OFFSET(SLJIT_MEM1(SLJIT_LOCALS_REG), offset);
1400 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG)
1401 compiler->skip_checks = 1;
1402 #endif
1403 if (offset != 0)
1404 return sljit_emit_op2(compiler, SLJIT_ADD | SLJIT_KEEP_FLAGS, dst, dstw, SLJIT_LOCALS_REG, 0, SLJIT_IMM, offset);
1405 return sljit_emit_op1(compiler, SLJIT_MOV, dst, dstw, SLJIT_LOCALS_REG, 0);
1406 }
1407
1408 #endif
1409
1410 #else /* SLJIT_CONFIG_UNSUPPORTED */
1411
1412 /* Empty function bodies for those machines, which are not (yet) supported. */
1413
1414 SLJIT_API_FUNC_ATTRIBUTE SLJIT_CONST char* sljit_get_platform_name(void)
1415 {
1416 return "unsupported";
1417 }
1418
1419 SLJIT_API_FUNC_ATTRIBUTE struct sljit_compiler* sljit_create_compiler(void)
1420 {
1421 SLJIT_ASSERT_STOP();
1422 return NULL;
1423 }
1424
1425 SLJIT_API_FUNC_ATTRIBUTE void sljit_free_compiler(struct sljit_compiler *compiler)
1426 {
1427 SLJIT_UNUSED_ARG(compiler);
1428 SLJIT_ASSERT_STOP();
1429 }
1430
1431 SLJIT_API_FUNC_ATTRIBUTE void* sljit_alloc_memory(struct sljit_compiler *compiler, int size)
1432 {
1433 SLJIT_UNUSED_ARG(compiler);
1434 SLJIT_UNUSED_ARG(size);
1435 SLJIT_ASSERT_STOP();
1436 return NULL;
1437 }
1438
1439 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1440 SLJIT_API_FUNC_ATTRIBUTE void sljit_compiler_verbose(struct sljit_compiler *compiler, FILE* verbose)
1441 {
1442 SLJIT_UNUSED_ARG(compiler);
1443 SLJIT_UNUSED_ARG(verbose);
1444 SLJIT_ASSERT_STOP();
1445 }
1446 #endif
1447
1448 SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compiler)
1449 {
1450 SLJIT_UNUSED_ARG(compiler);
1451 SLJIT_ASSERT_STOP();
1452 return NULL;
1453 }
1454
1455 SLJIT_API_FUNC_ATTRIBUTE void sljit_free_code(void* code)
1456 {
1457 SLJIT_UNUSED_ARG(code);
1458 SLJIT_ASSERT_STOP();
1459 }
1460
1461 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_enter(struct sljit_compiler *compiler, int args, int temporaries, int saveds, int local_size)
1462 {
1463 SLJIT_UNUSED_ARG(compiler);
1464 SLJIT_UNUSED_ARG(args);
1465 SLJIT_UNUSED_ARG(temporaries);
1466 SLJIT_UNUSED_ARG(saveds);
1467 SLJIT_UNUSED_ARG(local_size);
1468 SLJIT_ASSERT_STOP();
1469 return SLJIT_ERR_UNSUPPORTED;
1470 }
1471
1472 SLJIT_API_FUNC_ATTRIBUTE void sljit_set_context(struct sljit_compiler *compiler, int args, int temporaries, int saveds, int local_size)
1473 {
1474 SLJIT_UNUSED_ARG(compiler);
1475 SLJIT_UNUSED_ARG(args);
1476 SLJIT_UNUSED_ARG(temporaries);
1477 SLJIT_UNUSED_ARG(saveds);
1478 SLJIT_UNUSED_ARG(local_size);
1479 SLJIT_ASSERT_STOP();
1480 }
1481
1482 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_return(struct sljit_compiler *compiler, int op, int src, sljit_w srcw)
1483 {
1484 SLJIT_UNUSED_ARG(compiler);
1485 SLJIT_UNUSED_ARG(op);
1486 SLJIT_UNUSED_ARG(src);
1487 SLJIT_UNUSED_ARG(srcw);
1488 SLJIT_ASSERT_STOP();
1489 return SLJIT_ERR_UNSUPPORTED;
1490 }
1491
1492 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fast_enter(struct sljit_compiler *compiler, int dst, sljit_w dstw, int args, int temporaries, int saveds, int local_size)
1493 {
1494 SLJIT_UNUSED_ARG(compiler);
1495 SLJIT_UNUSED_ARG(dst);
1496 SLJIT_UNUSED_ARG(dstw);
1497 SLJIT_UNUSED_ARG(args);
1498 SLJIT_UNUSED_ARG(temporaries);
1499 SLJIT_UNUSED_ARG(saveds);
1500 SLJIT_UNUSED_ARG(local_size);
1501 SLJIT_ASSERT_STOP();
1502 return SLJIT_ERR_UNSUPPORTED;
1503 }
1504
1505 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fast_return(struct sljit_compiler *compiler, int src, sljit_w srcw)
1506 {
1507 SLJIT_UNUSED_ARG(compiler);
1508 SLJIT_UNUSED_ARG(src);
1509 SLJIT_UNUSED_ARG(srcw);
1510 SLJIT_ASSERT_STOP();
1511 return SLJIT_ERR_UNSUPPORTED;
1512 }
1513
1514 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op0(struct sljit_compiler *compiler, int op)
1515 {
1516 SLJIT_UNUSED_ARG(compiler);
1517 SLJIT_UNUSED_ARG(op);
1518 SLJIT_ASSERT_STOP();
1519 return SLJIT_ERR_UNSUPPORTED;
1520 }
1521
1522 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op1(struct sljit_compiler *compiler, int op,
1523 int dst, sljit_w dstw,
1524 int src, sljit_w srcw)
1525 {
1526 SLJIT_UNUSED_ARG(compiler);
1527 SLJIT_UNUSED_ARG(op);
1528 SLJIT_UNUSED_ARG(dst);
1529 SLJIT_UNUSED_ARG(dstw);
1530 SLJIT_UNUSED_ARG(src);
1531 SLJIT_UNUSED_ARG(srcw);
1532 SLJIT_ASSERT_STOP();
1533 return SLJIT_ERR_UNSUPPORTED;
1534 }
1535
1536 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op2(struct sljit_compiler *compiler, int op,
1537 int dst, sljit_w dstw,
1538 int src1, sljit_w src1w,
1539 int src2, sljit_w src2w)
1540 {
1541 SLJIT_UNUSED_ARG(compiler);
1542 SLJIT_UNUSED_ARG(op);
1543 SLJIT_UNUSED_ARG(dst);
1544 SLJIT_UNUSED_ARG(dstw);
1545 SLJIT_UNUSED_ARG(src1);
1546 SLJIT_UNUSED_ARG(src1w);
1547 SLJIT_UNUSED_ARG(src2);
1548 SLJIT_UNUSED_ARG(src2w);
1549 SLJIT_ASSERT_STOP();
1550 return SLJIT_ERR_UNSUPPORTED;
1551 }
1552
1553 SLJIT_API_FUNC_ATTRIBUTE int sljit_get_register_index(int reg)
1554 {
1555 SLJIT_ASSERT_STOP();
1556 return reg;
1557 }
1558
1559 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op_custom(struct sljit_compiler *compiler,
1560 void *instruction, int size)
1561 {
1562 SLJIT_UNUSED_ARG(compiler);
1563 SLJIT_UNUSED_ARG(instruction);
1564 SLJIT_UNUSED_ARG(size);
1565 SLJIT_ASSERT_STOP();
1566 return SLJIT_ERR_UNSUPPORTED;
1567 }
1568
1569 SLJIT_API_FUNC_ATTRIBUTE int sljit_is_fpu_available(void)
1570 {
1571 SLJIT_ASSERT_STOP();
1572 return 0;
1573 }
1574
1575 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fop1(struct sljit_compiler *compiler, int op,
1576 int dst, sljit_w dstw,
1577 int src, sljit_w srcw)
1578 {
1579 SLJIT_UNUSED_ARG(compiler);
1580 SLJIT_UNUSED_ARG(op);
1581 SLJIT_UNUSED_ARG(dst);
1582 SLJIT_UNUSED_ARG(dstw);
1583 SLJIT_UNUSED_ARG(src);
1584 SLJIT_UNUSED_ARG(srcw);
1585 SLJIT_ASSERT_STOP();
1586 return SLJIT_ERR_UNSUPPORTED;
1587 }
1588
1589 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fop2(struct sljit_compiler *compiler, int op,
1590 int dst, sljit_w dstw,
1591 int src1, sljit_w src1w,
1592 int src2, sljit_w src2w)
1593 {
1594 SLJIT_UNUSED_ARG(compiler);
1595 SLJIT_UNUSED_ARG(op);
1596 SLJIT_UNUSED_ARG(dst);
1597 SLJIT_UNUSED_ARG(dstw);
1598 SLJIT_UNUSED_ARG(src1);
1599 SLJIT_UNUSED_ARG(src1w);
1600 SLJIT_UNUSED_ARG(src2);
1601 SLJIT_UNUSED_ARG(src2w);
1602 SLJIT_ASSERT_STOP();
1603 return SLJIT_ERR_UNSUPPORTED;
1604 }
1605
1606 SLJIT_API_FUNC_ATTRIBUTE struct sljit_label* sljit_emit_label(struct sljit_compiler *compiler)
1607 {
1608 SLJIT_UNUSED_ARG(compiler);
1609 SLJIT_ASSERT_STOP();
1610 return NULL;
1611 }
1612
1613 SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_jump(struct sljit_compiler *compiler, int type)
1614 {
1615 SLJIT_UNUSED_ARG(compiler);
1616 SLJIT_UNUSED_ARG(type);
1617 SLJIT_ASSERT_STOP();
1618 return NULL;
1619 }
1620
1621 SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_cmp(struct sljit_compiler *compiler, int type,
1622 int src1, sljit_w src1w,
1623 int src2, sljit_w src2w)
1624 {
1625 SLJIT_UNUSED_ARG(compiler);
1626 SLJIT_UNUSED_ARG(type);
1627 SLJIT_UNUSED_ARG(src1);
1628 SLJIT_UNUSED_ARG(src1w);
1629 SLJIT_UNUSED_ARG(src2);
1630 SLJIT_UNUSED_ARG(src2w);
1631 SLJIT_ASSERT_STOP();
1632 return NULL;
1633 }
1634
1635 SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_fcmp(struct sljit_compiler *compiler, int type,
1636 int src1, sljit_w src1w,
1637 int src2, sljit_w src2w)
1638 {
1639 SLJIT_UNUSED_ARG(compiler);
1640 SLJIT_UNUSED_ARG(type);
1641 SLJIT_UNUSED_ARG(src1);
1642 SLJIT_UNUSED_ARG(src1w);
1643 SLJIT_UNUSED_ARG(src2);
1644 SLJIT_UNUSED_ARG(src2w);
1645 SLJIT_ASSERT_STOP();
1646 return NULL;
1647 }
1648
1649 SLJIT_API_FUNC_ATTRIBUTE void sljit_set_label(struct sljit_jump *jump, struct sljit_label* label)
1650 {
1651 SLJIT_UNUSED_ARG(jump);
1652 SLJIT_UNUSED_ARG(label);
1653 SLJIT_ASSERT_STOP();
1654 }
1655
1656 SLJIT_API_FUNC_ATTRIBUTE void sljit_set_target(struct sljit_jump *jump, sljit_uw target)
1657 {
1658 SLJIT_UNUSED_ARG(jump);
1659 SLJIT_UNUSED_ARG(target);
1660 SLJIT_ASSERT_STOP();
1661 }
1662
1663 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_ijump(struct sljit_compiler *compiler, int type, int src, sljit_w srcw)
1664 {
1665 SLJIT_UNUSED_ARG(compiler);
1666 SLJIT_UNUSED_ARG(type);
1667 SLJIT_UNUSED_ARG(src);
1668 SLJIT_UNUSED_ARG(srcw);
1669 SLJIT_ASSERT_STOP();
1670 return SLJIT_ERR_UNSUPPORTED;
1671 }
1672
1673 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_cond_value(struct sljit_compiler *compiler, int op, int dst, sljit_w dstw, int type)
1674 {
1675 SLJIT_UNUSED_ARG(compiler);
1676 SLJIT_UNUSED_ARG(op);
1677 SLJIT_UNUSED_ARG(dst);
1678 SLJIT_UNUSED_ARG(dstw);
1679 SLJIT_UNUSED_ARG(type);
1680 SLJIT_ASSERT_STOP();
1681 return SLJIT_ERR_UNSUPPORTED;
1682 }
1683
1684 SLJIT_API_FUNC_ATTRIBUTE int sljit_get_local_base(struct sljit_compiler *compiler, int dst, sljit_w dstw, sljit_w offset)
1685 {
1686 SLJIT_UNUSED_ARG(compiler);
1687 SLJIT_UNUSED_ARG(dst);
1688 SLJIT_UNUSED_ARG(dstw);
1689 SLJIT_UNUSED_ARG(offset);
1690 SLJIT_ASSERT_STOP();
1691 return SLJIT_ERR_UNSUPPORTED;
1692 }
1693
1694 SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compiler *compiler, int dst, sljit_w dstw, sljit_w initval)
1695 {
1696 SLJIT_UNUSED_ARG(compiler);
1697 SLJIT_UNUSED_ARG(dst);
1698 SLJIT_UNUSED_ARG(dstw);
1699 SLJIT_UNUSED_ARG(initval);
1700 SLJIT_ASSERT_STOP();
1701 return NULL;
1702 }
1703
1704 SLJIT_API_FUNC_ATTRIBUTE void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_addr)
1705 {
1706 SLJIT_UNUSED_ARG(addr);
1707 SLJIT_UNUSED_ARG(new_addr);
1708 SLJIT_ASSERT_STOP();
1709 }
1710
1711 SLJIT_API_FUNC_ATTRIBUTE void sljit_set_const(sljit_uw addr, sljit_w new_constant)
1712 {
1713 SLJIT_UNUSED_ARG(addr);
1714 SLJIT_UNUSED_ARG(new_constant);
1715 SLJIT_ASSERT_STOP();
1716 }
1717
1718 #endif

  ViewVC Help
Powered by ViewVC 1.1.5