/[pcre]/code/trunk/sljit/sljitConfigInternal.h
ViewVC logotype

Contents of /code/trunk/sljit/sljitConfigInternal.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1506 - (show annotations)
Sat Sep 27 06:25:26 2014 UTC (4 years, 10 months ago) by zherczeg
File MIME type: text/plain
File size: 22765 byte(s)
Major JIT compiler update.
1 /*
2 * Stack-less Just-In-Time compiler
3 *
4 * Copyright 2009-2012 Zoltan Herczeg (hzmester@freemail.hu). All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without modification, are
7 * permitted provided that the following conditions are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright notice, this list of
10 * conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
13 * of conditions and the following disclaimer in the documentation and/or other materials
14 * provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND CONTRIBUTORS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19 * SHALL THE COPYRIGHT HOLDER(S) OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
21 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
22 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
24 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27 #ifndef _SLJIT_CONFIG_INTERNAL_H_
28 #define _SLJIT_CONFIG_INTERNAL_H_
29
30 /*
31 SLJIT defines the following architecture dependent types and macros:
32
33 Types:
34 sljit_sb, sljit_ub : signed and unsigned 8 bit byte
35 sljit_sh, sljit_uh : signed and unsigned 16 bit half-word (short) type
36 sljit_si, sljit_ui : signed and unsigned 32 bit integer type
37 sljit_sw, sljit_uw : signed and unsigned machine word, enough to store a pointer
38 sljit_p : unsgined pointer value (usually the same as sljit_uw, but
39 some 64 bit ABIs may use 32 bit pointers)
40 sljit_s : single precision floating point value
41 sljit_d : double precision floating point value
42
43 Macros for feature detection (boolean):
44 SLJIT_32BIT_ARCHITECTURE : 32 bit architecture
45 SLJIT_64BIT_ARCHITECTURE : 64 bit architecture
46 SLJIT_LITTLE_ENDIAN : little endian architecture
47 SLJIT_BIG_ENDIAN : big endian architecture
48 SLJIT_UNALIGNED : allows unaligned memory accesses for non-fpu operations (only!)
49 SLJIT_INDIRECT_CALL : see SLJIT_FUNC_OFFSET() for more information
50
51 Constants:
52 SLJIT_NUMBER_OF_REGISTERS : number of available registers
53 SLJIT_NUMBER_OF_SCRATCH_REGISTERS : number of available scratch registers
54 SLJIT_NUMBER_OF_SAVED_REGISTERS : number of available saved registers
55 SLJIT_NUMBER_OF_FLOAT_REGISTERS : number of available floating point registers
56 SLJIT_NUMBER_OF_SCRATCH_FLOAT_REGISTERS : number of available floating point scratch registers
57 SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS : number of available floating point saved registers
58 SLJIT_WORD_SHIFT : the shift required to apply when accessing a sljit_sw/sljit_uw array by index
59 SLJIT_DOUBLE_SHIFT : the shift required to apply when accessing
60 a double precision floating point array by index
61 SLJIT_SINGLE_SHIFT : the shift required to apply when accessing
62 a single precision floating point array by index
63 SLJIT_LOCALS_OFFSET : local space starting offset (SLJIT_SP + SLJIT_LOCALS_OFFSET)
64 SLJIT_RETURN_ADDRESS_OFFSET : a return instruction always adds this offset to the return address
65
66 Other macros:
67 SLJIT_CALL : C calling convention define for both calling JIT form C and C callbacks for JIT
68 SLJIT_W(number) : defining 64 bit constants on 64 bit architectures (compiler independent helper)
69 */
70
71 /*****************/
72 /* Sanity check. */
73 /*****************/
74
75 #if !((defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) \
76 || (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) \
77 || (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) \
78 || (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7) \
79 || (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2) \
80 || (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) \
81 || (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) \
82 || (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) \
83 || (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) \
84 || (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64) \
85 || (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32) \
86 || (defined SLJIT_CONFIG_TILEGX && SLJIT_CONFIG_TILEGX) \
87 || (defined SLJIT_CONFIG_AUTO && SLJIT_CONFIG_AUTO) \
88 || (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED))
89 #error "An architecture must be selected"
90 #endif
91
92 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) \
93 + (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) \
94 + (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) \
95 + (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7) \
96 + (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2) \
97 + (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) \
98 + (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) \
99 + (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) \
100 + (defined SLJIT_CONFIG_TILEGX && SLJIT_CONFIG_TILEGX) \
101 + (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) \
102 + (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64) \
103 + (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32) \
104 + (defined SLJIT_CONFIG_AUTO && SLJIT_CONFIG_AUTO) \
105 + (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED) >= 2
106 #error "Multiple architectures are selected"
107 #endif
108
109 /********************************************************/
110 /* Automatic CPU detection (requires compiler support). */
111 /********************************************************/
112
113 #if (defined SLJIT_CONFIG_AUTO && SLJIT_CONFIG_AUTO)
114
115 #ifndef _WIN32
116
117 #if defined(__i386__) || defined(__i386)
118 #define SLJIT_CONFIG_X86_32 1
119 #elif defined(__x86_64__)
120 #define SLJIT_CONFIG_X86_64 1
121 #elif defined(__arm__) || defined(__ARM__)
122 #ifdef __thumb2__
123 #define SLJIT_CONFIG_ARM_THUMB2 1
124 #elif defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__)
125 #define SLJIT_CONFIG_ARM_V7 1
126 #else
127 #define SLJIT_CONFIG_ARM_V5 1
128 #endif
129 #elif defined (__aarch64__)
130 #define SLJIT_CONFIG_ARM_64 1
131 #elif defined(__ppc64__) || defined(__powerpc64__) || defined(_ARCH_PPC64) || (defined(_POWER) && defined(__64BIT__))
132 #define SLJIT_CONFIG_PPC_64 1
133 #elif defined(__ppc__) || defined(__powerpc__) || defined(_ARCH_PPC) || defined(_ARCH_PWR) || defined(_ARCH_PWR2) || defined(_POWER)
134 #define SLJIT_CONFIG_PPC_32 1
135 #elif defined(__mips__) && !defined(_LP64)
136 #define SLJIT_CONFIG_MIPS_32 1
137 #elif defined(__mips64)
138 #define SLJIT_CONFIG_MIPS_64 1
139 #elif defined(__sparc__) || defined(__sparc)
140 #define SLJIT_CONFIG_SPARC_32 1
141 #elif defined(__tilegx__)
142 #define SLJIT_CONFIG_TILEGX 1
143 #else
144 /* Unsupported architecture */
145 #define SLJIT_CONFIG_UNSUPPORTED 1
146 #endif
147
148 #else /* !_WIN32 */
149
150 #if defined(_M_X64) || defined(__x86_64__)
151 #define SLJIT_CONFIG_X86_64 1
152 #elif defined(_ARM_)
153 #define SLJIT_CONFIG_ARM_V5 1
154 #else
155 #define SLJIT_CONFIG_X86_32 1
156 #endif
157
158 #endif /* !WIN32 */
159 #endif /* SLJIT_CONFIG_AUTO */
160
161 #if (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
162 #undef SLJIT_EXECUTABLE_ALLOCATOR
163 #endif
164
165 /******************************/
166 /* CPU family type detection. */
167 /******************************/
168
169 #if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) || (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7) \
170 || (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
171 #define SLJIT_CONFIG_ARM_32 1
172 #endif
173
174 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) || (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
175 #define SLJIT_CONFIG_X86 1
176 #elif (defined SLJIT_CONFIG_ARM_32 && SLJIT_CONFIG_ARM_32) || (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64)
177 #define SLJIT_CONFIG_ARM 1
178 #elif (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) || (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
179 #define SLJIT_CONFIG_PPC 1
180 #elif (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) || (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64)
181 #define SLJIT_CONFIG_MIPS 1
182 #elif (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32) || (defined SLJIT_CONFIG_SPARC_64 && SLJIT_CONFIG_SPARC_64)
183 #define SLJIT_CONFIG_SPARC 1
184 #endif
185
186 /**********************************/
187 /* External function definitions. */
188 /**********************************/
189
190 #if !(defined SLJIT_STD_MACROS_DEFINED && SLJIT_STD_MACROS_DEFINED)
191
192 /* These libraries are needed for the macros below. */
193 #include <stdlib.h>
194 #include <string.h>
195
196 #endif /* SLJIT_STD_MACROS_DEFINED */
197
198 /* General macros:
199 Note: SLJIT is designed to be independent from them as possible.
200
201 In release mode (SLJIT_DEBUG is not defined) only the following
202 external functions are needed:
203 */
204
205 #ifndef SLJIT_MALLOC
206 #define SLJIT_MALLOC(size) malloc(size)
207 #endif
208
209 #ifndef SLJIT_FREE
210 #define SLJIT_FREE(ptr) free(ptr)
211 #endif
212
213 #ifndef SLJIT_MEMMOVE
214 #define SLJIT_MEMMOVE(dest, src, len) memmove(dest, src, len)
215 #endif
216
217 #ifndef SLJIT_ZEROMEM
218 #define SLJIT_ZEROMEM(dest, len) memset(dest, 0, len)
219 #endif
220
221 /***************************/
222 /* Compiler helper macros. */
223 /***************************/
224
225 #if !defined(SLJIT_LIKELY) && !defined(SLJIT_UNLIKELY)
226
227 #if defined(__GNUC__) && (__GNUC__ >= 3)
228 #define SLJIT_LIKELY(x) __builtin_expect((x), 1)
229 #define SLJIT_UNLIKELY(x) __builtin_expect((x), 0)
230 #else
231 #define SLJIT_LIKELY(x) (x)
232 #define SLJIT_UNLIKELY(x) (x)
233 #endif
234
235 #endif /* !defined(SLJIT_LIKELY) && !defined(SLJIT_UNLIKELY) */
236
237 #ifndef SLJIT_INLINE
238 /* Inline functions. Some old compilers do not support them. */
239 #if defined(__SUNPRO_C) && __SUNPRO_C <= 0x510
240 #define SLJIT_INLINE
241 #else
242 #define SLJIT_INLINE __inline
243 #endif
244 #endif /* !SLJIT_INLINE */
245
246 #ifndef SLJIT_CONST
247 /* Const variables. */
248 #define SLJIT_CONST const
249 #endif
250
251 #ifndef SLJIT_UNUSED_ARG
252 /* Unused arguments. */
253 #define SLJIT_UNUSED_ARG(arg) (void)arg
254 #endif
255
256 /*********************************/
257 /* Type of public API functions. */
258 /*********************************/
259
260 #if (defined SLJIT_CONFIG_STATIC && SLJIT_CONFIG_STATIC)
261 /* Static ABI functions. For all-in-one programs. */
262
263 #if defined(__GNUC__)
264 /* Disable unused warnings in gcc. */
265 #define SLJIT_API_FUNC_ATTRIBUTE static __attribute__((unused))
266 #else
267 #define SLJIT_API_FUNC_ATTRIBUTE static
268 #endif
269
270 #else
271 #define SLJIT_API_FUNC_ATTRIBUTE
272 #endif /* (defined SLJIT_CONFIG_STATIC && SLJIT_CONFIG_STATIC) */
273
274 /****************************/
275 /* Instruction cache flush. */
276 /****************************/
277
278 #ifndef SLJIT_CACHE_FLUSH
279
280 #if (defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86)
281
282 /* Not required to implement on archs with unified caches. */
283 #define SLJIT_CACHE_FLUSH(from, to)
284
285 #elif defined __APPLE__
286
287 /* Supported by all macs since Mac OS 10.5.
288 However, it does not work on non-jailbroken iOS devices,
289 although the compilation is successful. */
290
291 #define SLJIT_CACHE_FLUSH(from, to) \
292 sys_icache_invalidate((char*)(from), (char*)(to) - (char*)(from))
293
294 #elif defined __ANDROID__
295
296 /* Android lacks __clear_cache; instead, cacheflush should be used. */
297
298 #define SLJIT_CACHE_FLUSH(from, to) \
299 cacheflush((long)(from), (long)(to), 0)
300
301 #elif (defined SLJIT_CONFIG_PPC && SLJIT_CONFIG_PPC)
302
303 /* The __clear_cache() implementation of GCC is a dummy function on PowerPC. */
304 #define SLJIT_CACHE_FLUSH(from, to) \
305 ppc_cache_flush((from), (to))
306
307 #elif (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
308
309 /* The __clear_cache() implementation of GCC is a dummy function on Sparc. */
310 #define SLJIT_CACHE_FLUSH(from, to) \
311 sparc_cache_flush((from), (to))
312
313 #else
314
315 /* Calls __ARM_NR_cacheflush on ARM-Linux. */
316 #define SLJIT_CACHE_FLUSH(from, to) \
317 __clear_cache((char*)(from), (char*)(to))
318
319 #endif
320
321 #endif /* !SLJIT_CACHE_FLUSH */
322
323 /******************************************************/
324 /* Byte/half/int/word/single/double type definitions. */
325 /******************************************************/
326
327 /* 8 bit byte type. */
328 typedef unsigned char sljit_ub;
329 typedef signed char sljit_sb;
330
331 /* 16 bit half-word type. */
332 typedef unsigned short int sljit_uh;
333 typedef signed short int sljit_sh;
334
335 /* 32 bit integer type. */
336 typedef unsigned int sljit_ui;
337 typedef signed int sljit_si;
338
339 /* Machine word type. Enough for storing a pointer.
340 32 bit for 32 bit machines.
341 64 bit for 64 bit machines. */
342 #if (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
343 /* Just to have something. */
344 #define SLJIT_WORD_SHIFT 0
345 typedef unsigned long int sljit_uw;
346 typedef long int sljit_sw;
347 #elif !(defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) \
348 && !(defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) \
349 && !(defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) \
350 && !(defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64) \
351 && !(defined SLJIT_CONFIG_TILEGX && SLJIT_CONFIG_TILEGX)
352 #define SLJIT_32BIT_ARCHITECTURE 1
353 #define SLJIT_WORD_SHIFT 2
354 typedef unsigned int sljit_uw;
355 typedef int sljit_sw;
356 #else
357 #define SLJIT_64BIT_ARCHITECTURE 1
358 #define SLJIT_WORD_SHIFT 3
359 #ifdef _WIN32
360 typedef unsigned __int64 sljit_uw;
361 typedef __int64 sljit_sw;
362 #else
363 typedef unsigned long int sljit_uw;
364 typedef long int sljit_sw;
365 #endif
366 #endif
367
368 typedef sljit_uw sljit_p;
369
370 /* Floating point types. */
371 typedef float sljit_s;
372 typedef double sljit_d;
373
374 /* Shift for pointer sized data. */
375 #define SLJIT_POINTER_SHIFT SLJIT_WORD_SHIFT
376
377 /* Shift for double precision sized data. */
378 #define SLJIT_DOUBLE_SHIFT 3
379 #define SLJIT_SINGLE_SHIFT 2
380
381 #ifndef SLJIT_W
382
383 /* Defining long constants. */
384 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
385 #define SLJIT_W(w) (w##ll)
386 #else
387 #define SLJIT_W(w) (w)
388 #endif
389
390 #endif /* !SLJIT_W */
391
392 /*************************/
393 /* Endianness detection. */
394 /*************************/
395
396 #if !defined(SLJIT_BIG_ENDIAN) && !defined(SLJIT_LITTLE_ENDIAN)
397
398 /* These macros are mostly useful for the applications. */
399 #if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) \
400 || (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
401
402 #ifdef __LITTLE_ENDIAN__
403 #define SLJIT_LITTLE_ENDIAN 1
404 #else
405 #define SLJIT_BIG_ENDIAN 1
406 #endif
407
408 #elif (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) \
409 || (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64)
410
411 #ifdef __MIPSEL__
412 #define SLJIT_LITTLE_ENDIAN 1
413 #else
414 #define SLJIT_BIG_ENDIAN 1
415 #endif
416
417 #elif (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
418
419 #define SLJIT_BIG_ENDIAN 1
420
421 #else
422 #define SLJIT_LITTLE_ENDIAN 1
423 #endif
424
425 #endif /* !defined(SLJIT_BIG_ENDIAN) && !defined(SLJIT_LITTLE_ENDIAN) */
426
427 /* Sanity check. */
428 #if (defined SLJIT_BIG_ENDIAN && SLJIT_BIG_ENDIAN) && (defined SLJIT_LITTLE_ENDIAN && SLJIT_LITTLE_ENDIAN)
429 #error "Exactly one endianness must be selected"
430 #endif
431
432 #if !(defined SLJIT_BIG_ENDIAN && SLJIT_BIG_ENDIAN) && !(defined SLJIT_LITTLE_ENDIAN && SLJIT_LITTLE_ENDIAN)
433 #error "Exactly one endianness must be selected"
434 #endif
435
436 #ifndef SLJIT_UNALIGNED
437
438 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) \
439 || (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) \
440 || (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7) \
441 || (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2) \
442 || (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) \
443 || (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) \
444 || (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
445 #define SLJIT_UNALIGNED 1
446 #endif
447
448 #endif /* !SLJIT_UNALIGNED */
449
450 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
451 /* Auto detect SSE2 support using CPUID.
452 On 64 bit x86 cpus, sse2 must be present. */
453 #define SLJIT_DETECT_SSE2 1
454 #endif
455
456 /*****************************************************************************************/
457 /* Calling convention of functions generated by SLJIT or called from the generated code. */
458 /*****************************************************************************************/
459
460 #ifndef SLJIT_CALL
461
462 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
463
464 #if defined(__GNUC__) && !defined(__APPLE__)
465
466 #define SLJIT_CALL __attribute__ ((fastcall))
467 #define SLJIT_X86_32_FASTCALL 1
468
469 #elif defined(_MSC_VER)
470
471 #define SLJIT_CALL __fastcall
472 #define SLJIT_X86_32_FASTCALL 1
473
474 #elif defined(__BORLANDC__)
475
476 #define SLJIT_CALL __msfastcall
477 #define SLJIT_X86_32_FASTCALL 1
478
479 #else /* Unknown compiler. */
480
481 /* The cdecl attribute is the default. */
482 #define SLJIT_CALL
483
484 #endif
485
486 #else /* Non x86-32 architectures. */
487
488 #define SLJIT_CALL
489
490 #endif /* SLJIT_CONFIG_X86_32 */
491
492 #endif /* !SLJIT_CALL */
493
494 #ifndef SLJIT_INDIRECT_CALL
495 #if ((defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) && (defined SLJIT_BIG_ENDIAN && SLJIT_BIG_ENDIAN)) \
496 || ((defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) && defined _AIX)
497 /* It seems certain ppc compilers use an indirect addressing for functions
498 which makes things complicated. */
499 #define SLJIT_INDIRECT_CALL 1
500 #endif
501 #endif /* SLJIT_INDIRECT_CALL */
502
503 /* The offset which needs to be substracted from the return address to
504 determine the next executed instruction after return. */
505 #ifndef SLJIT_RETURN_ADDRESS_OFFSET
506 #if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
507 #define SLJIT_RETURN_ADDRESS_OFFSET 8
508 #else
509 #define SLJIT_RETURN_ADDRESS_OFFSET 0
510 #endif
511 #endif /* SLJIT_RETURN_ADDRESS_OFFSET */
512
513 /***************************************************/
514 /* Functions of the built-in executable allocator. */
515 /***************************************************/
516
517 #if (defined SLJIT_EXECUTABLE_ALLOCATOR && SLJIT_EXECUTABLE_ALLOCATOR)
518 SLJIT_API_FUNC_ATTRIBUTE void* sljit_malloc_exec(sljit_uw size);
519 SLJIT_API_FUNC_ATTRIBUTE void sljit_free_exec(void* ptr);
520 SLJIT_API_FUNC_ATTRIBUTE void sljit_free_unused_memory_exec(void);
521 #define SLJIT_MALLOC_EXEC(size) sljit_malloc_exec(size)
522 #define SLJIT_FREE_EXEC(ptr) sljit_free_exec(ptr)
523 #endif
524
525 /**********************************************/
526 /* Registers and locals offset determination. */
527 /**********************************************/
528
529 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
530
531 #define SLJIT_NUMBER_OF_REGISTERS 10
532 #define SLJIT_NUMBER_OF_SAVED_REGISTERS 7
533 #if (defined SLJIT_X86_32_FASTCALL && SLJIT_X86_32_FASTCALL)
534 #define SLJIT_LOCALS_OFFSET_BASE ((2 + 4) * sizeof(sljit_sw))
535 #else
536 /* Maximum 3 arguments are passed on the stack, +1 for double alignment. */
537 #define SLJIT_LOCALS_OFFSET_BASE ((3 + 1 + 4) * sizeof(sljit_sw))
538 #endif /* SLJIT_X86_32_FASTCALL */
539
540 #elif (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
541
542 #ifndef _WIN64
543 #define SLJIT_NUMBER_OF_REGISTERS 12
544 #define SLJIT_NUMBER_OF_SAVED_REGISTERS 6
545 #define SLJIT_LOCALS_OFFSET_BASE (sizeof(sljit_sw))
546 #else
547 #define SLJIT_NUMBER_OF_REGISTERS 12
548 #define SLJIT_NUMBER_OF_SAVED_REGISTERS 8
549 #define SLJIT_LOCALS_OFFSET_BASE ((4 + 2) * sizeof(sljit_sw))
550 #endif /* _WIN64 */
551
552 #elif (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) || (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7)
553
554 #define SLJIT_NUMBER_OF_REGISTERS 11
555 #define SLJIT_NUMBER_OF_SAVED_REGISTERS 8
556 #define SLJIT_LOCALS_OFFSET_BASE 0
557
558 #elif (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
559
560 #define SLJIT_NUMBER_OF_REGISTERS 11
561 #define SLJIT_NUMBER_OF_SAVED_REGISTERS 7
562 #define SLJIT_LOCALS_OFFSET_BASE 0
563
564 #elif (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64)
565
566 #define SLJIT_NUMBER_OF_REGISTERS 25
567 #define SLJIT_NUMBER_OF_SAVED_REGISTERS 10
568 #define SLJIT_LOCALS_OFFSET_BASE (2 * sizeof(sljit_sw))
569
570 #elif (defined SLJIT_CONFIG_PPC && SLJIT_CONFIG_PPC)
571
572 #define SLJIT_NUMBER_OF_REGISTERS 22
573 #define SLJIT_NUMBER_OF_SAVED_REGISTERS 17
574 #if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) || (defined _AIX)
575 #define SLJIT_LOCALS_OFFSET_BASE ((6 + 8) * sizeof(sljit_sw))
576 #elif (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32)
577 /* Add +1 for double alignment. */
578 #define SLJIT_LOCALS_OFFSET_BASE ((3 + 1) * sizeof(sljit_sw))
579 #else
580 #define SLJIT_LOCALS_OFFSET_BASE (3 * sizeof(sljit_sw))
581 #endif /* SLJIT_CONFIG_PPC_64 || _AIX */
582
583 #elif (defined SLJIT_CONFIG_MIPS && SLJIT_CONFIG_MIPS)
584
585 #define SLJIT_NUMBER_OF_REGISTERS 17
586 #define SLJIT_NUMBER_OF_SAVED_REGISTERS 8
587 #if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
588 #define SLJIT_LOCALS_OFFSET_BASE (4 * sizeof(sljit_sw))
589 #else
590 #define SLJIT_LOCALS_OFFSET_BASE 0
591 #endif
592
593 #elif (defined SLJIT_CONFIG_SPARC && SLJIT_CONFIG_SPARC)
594
595 #define SLJIT_NUMBER_OF_REGISTERS 18
596 #define SLJIT_NUMBER_OF_SAVED_REGISTERS 14
597 #if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
598 /* Add +1 for double alignment. */
599 #define SLJIT_LOCALS_OFFSET_BASE ((23 + 1) * sizeof(sljit_sw))
600 #endif
601
602 #elif (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
603
604 #define SLJIT_NUMBER_OF_REGISTERS 0
605 #define SLJIT_NUMBER_OF_SAVED_REGISTERS 0
606 #define SLJIT_LOCALS_OFFSET_BASE 0
607
608 #endif
609
610 #define SLJIT_LOCALS_OFFSET (SLJIT_LOCALS_OFFSET_BASE)
611
612 #define SLJIT_NUMBER_OF_SCRATCH_REGISTERS \
613 (SLJIT_NUMBER_OF_REGISTERS - SLJIT_NUMBER_OF_SAVED_REGISTERS)
614
615 #define SLJIT_NUMBER_OF_FLOAT_REGISTERS 6
616 #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) && (defined _WIN64)
617 #define SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS 1
618 #else
619 #define SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS 0
620 #endif
621
622 #define SLJIT_NUMBER_OF_SCRATCH_FLOAT_REGISTERS \
623 (SLJIT_NUMBER_OF_FLOAT_REGISTERS - SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS)
624
625 /*************************************/
626 /* Debug and verbose related macros. */
627 /*************************************/
628
629 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
630 #include <stdio.h>
631 #endif
632
633 #if (defined SLJIT_DEBUG && SLJIT_DEBUG)
634
635 #if !defined(SLJIT_ASSERT) || !defined(SLJIT_ASSERT_STOP)
636
637 /* SLJIT_HALT_PROCESS must halt the process. */
638 #ifndef SLJIT_HALT_PROCESS
639 #include <stdlib.h>
640
641 #define SLJIT_HALT_PROCESS() \
642 abort();
643 #endif /* !SLJIT_HALT_PROCESS */
644
645 #include <stdio.h>
646
647 #endif /* !SLJIT_ASSERT || !SLJIT_ASSERT_STOP */
648
649 /* Feel free to redefine these two macros. */
650 #ifndef SLJIT_ASSERT
651
652 #define SLJIT_ASSERT(x) \
653 do { \
654 if (SLJIT_UNLIKELY(!(x))) { \
655 printf("Assertion failed at " __FILE__ ":%d\n", __LINE__); \
656 SLJIT_HALT_PROCESS(); \
657 } \
658 } while (0)
659
660 #endif /* !SLJIT_ASSERT */
661
662 #ifndef SLJIT_ASSERT_STOP
663
664 #define SLJIT_ASSERT_STOP() \
665 do { \
666 printf("Should never been reached " __FILE__ ":%d\n", __LINE__); \
667 SLJIT_HALT_PROCESS(); \
668 } while (0)
669
670 #endif /* !SLJIT_ASSERT_STOP */
671
672 #else /* (defined SLJIT_DEBUG && SLJIT_DEBUG) */
673
674 /* Forcing empty, but valid statements. */
675 #undef SLJIT_ASSERT
676 #undef SLJIT_ASSERT_STOP
677
678 #define SLJIT_ASSERT(x) \
679 do { } while (0)
680 #define SLJIT_ASSERT_STOP() \
681 do { } while (0)
682
683 #endif /* (defined SLJIT_DEBUG && SLJIT_DEBUG) */
684
685 #ifndef SLJIT_COMPILE_ASSERT
686
687 /* Should be improved eventually. */
688 #define SLJIT_COMPILE_ASSERT(x, description) \
689 SLJIT_ASSERT(x)
690
691 #endif /* !SLJIT_COMPILE_ASSERT */
692
693 #endif

  ViewVC Help
Powered by ViewVC 1.1.5