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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12