/[pcre]/code/branches/pcre16/sljit/sljitConfigInternal.h
ViewVC logotype

Contents of /code/branches/pcre16/sljit/sljitConfigInternal.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 703 - (hide annotations) (download)
Tue Sep 20 16:27:11 2011 UTC (2 years, 6 months ago) by zherczeg
Original Path: code/trunk/sljit/sljitConfigInternal.h
File MIME type: text/plain
File size: 11386 byte(s)
Small, MIPS related fix in the JIT compiler
1 ph10 662 /*
2     * Stack-less Just-In-Time compiler
3     *
4     * Copyright 2009-2010 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 variables itself depending on the configuration:
32     sljit_b, sljit_ub : signed and unsigned 8 bit byte
33     sljit_h, sljit_uh : signed and unsigned 16 bit half-word (short) type
34     sljit_i, sljit_ui : signed and unsigned 32 bit integer type
35     sljit_w, sljit_uw : signed and unsigned machine word, enough to store a pointer (same as intptr_t)
36     SLJIT_CALL : C calling convention for both calling JIT and C callbacks from JIT
37     SLJIT_32BIT_ARCHITECTURE : 32 bit architecture
38     SLJIT_64BIT_ARCHITECTURE : 64 bit architecture
39     SLJIT_WORD_SHIFT : the shift required to apply when accessing a sljit_w/sljit_uw array by index
40     SLJIT_FLOAT_SHIFT : the shift required to apply when accessing a double array by index
41     SLJIT_BIG_ENDIAN : big endian architecture
42     SLJIT_LITTLE_ENDIAN : little endian architecture
43     SLJIT_INDIRECT_CALL : see SLJIT_FUNC_OFFSET()
44     SLJIT_W : for defining 64 bit constants on 64 bit architectures (compiler workaround)
45     SLJIT_UNALIGNED : allows unaligned memory accesses for integer arithmetic (only!)
46     */
47    
48     #if !((defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) \
49     || (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) \
50     || (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) \
51     || (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7) \
52     || (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2) \
53     || (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) \
54     || (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) \
55     || (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) \
56     || (defined SLJIT_CONFIG_AUTO && SLJIT_CONFIG_AUTO) \
57     || (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED))
58     #error "An architecture must be selected"
59     #endif
60    
61     /* Sanity check. */
62     #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) \
63     + (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) \
64     + (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) \
65     + (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7) \
66     + (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2) \
67     + (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) \
68     + (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) \
69     + (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) \
70     + (defined SLJIT_CONFIG_AUTO && SLJIT_CONFIG_AUTO) \
71     + (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED) >= 2
72     #error "Multiple architectures are selected"
73     #endif
74    
75     /* Auto select option (requires compiler support) */
76     #if (defined SLJIT_CONFIG_AUTO && SLJIT_CONFIG_AUTO)
77    
78     #ifndef _WIN32
79    
80     #if defined(__i386__) || defined(__i386)
81     #define SLJIT_CONFIG_X86_32 1
82     #elif defined(__x86_64__)
83     #define SLJIT_CONFIG_X86_64 1
84     #elif defined(__arm__) || defined(__ARM__)
85     #ifdef __thumb2__
86     #define SLJIT_CONFIG_ARM_THUMB2 1
87     #elif defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__)
88     #define SLJIT_CONFIG_ARM_V7 1
89     #else
90     #define SLJIT_CONFIG_ARM_V5 1
91     #endif
92     #elif defined(__ppc64__) || defined(__powerpc64__)
93     #define SLJIT_CONFIG_PPC_64 1
94     #elif defined(__ppc__) || defined(__powerpc__)
95     #define SLJIT_CONFIG_PPC_32 1
96     #elif defined(__mips__)
97     #define SLJIT_CONFIG_MIPS_32 1
98     #else
99     /* Unsupported architecture */
100     #define SLJIT_CONFIG_UNSUPPORTED 1
101     #endif
102    
103     #else /* !_WIN32 */
104    
105     #if defined(_M_X64) || defined(__x86_64__)
106     #define SLJIT_CONFIG_X86_64 1
107     #elif defined(_ARM_)
108     #define SLJIT_CONFIG_ARM_V5 1
109     #else
110     #define SLJIT_CONFIG_X86_32 1
111     #endif
112    
113     #endif /* !WIN32 */
114     #endif /* SLJIT_CONFIG_AUTO */
115    
116     #if (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
117     #undef SLJIT_EXECUTABLE_ALLOCATOR
118     #endif
119    
120     #if !(defined SLJIT_STD_MACROS_DEFINED && SLJIT_STD_MACROS_DEFINED)
121    
122     #include <stdlib.h>
123     #include <string.h>
124    
125     /* General libraries:
126     Note: SLJIT is designed to be independent from them as possible.
127    
128     In release mode (SLJIT_DEBUG is not defined) only the following macros are needed: */
129    
130     /* General allocation. */
131     #define SLJIT_MALLOC(size) malloc(size)
132     #define SLJIT_FREE(ptr) free(ptr)
133     #define SLJIT_MEMMOVE(dest, src, len) memmove(dest, src, len)
134    
135     #endif /* STD_MACROS_DEFINED */
136    
137     #if !defined(SLJIT_LIKELY) && !defined(SLJIT_UNLIKELY)
138    
139     #if defined(__GNUC__) && (__GNUC__ >= 3)
140     #define SLJIT_LIKELY(x) __builtin_expect((x), 1)
141     #define SLJIT_UNLIKELY(x) __builtin_expect((x), 0)
142     #else
143     #define SLJIT_LIKELY(x) (x)
144     #define SLJIT_UNLIKELY(x) (x)
145     #endif
146    
147     #endif /* !defined(SLJIT_LIKELY) && !defined(SLJIT_UNLIKELY) */
148    
149     #ifndef SLJIT_INLINE
150     /* Inline functions. */
151     #define SLJIT_INLINE __inline
152     #endif
153    
154     #ifndef SLJIT_CONST
155     /* Const variables. */
156     #define SLJIT_CONST const
157     #endif
158    
159     #ifndef SLJIT_UNUSED_ARG
160     /* Unused arguments. */
161     #define SLJIT_UNUSED_ARG(arg) (void)arg
162     #endif
163    
164     #ifndef SLJIT_CACHE_FLUSH
165    
166     #if !(defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) && !(defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
167     /* Just call __ARM_NR_cacheflush on Linux. */
168     #define SLJIT_CACHE_FLUSH(from, to) \
169     __clear_cache((char*)(from), (char*)(to))
170     #else
171     /* Not required to implement on archs with unified caches. */
172     #define SLJIT_CACHE_FLUSH(from, to)
173     #endif
174    
175     #endif /* !SLJIT_CACHE_FLUSH */
176    
177     /* 8 bit byte type. */
178     typedef unsigned char sljit_ub;
179     typedef signed char sljit_b;
180    
181     /* 16 bit half-word type. */
182     typedef unsigned short int sljit_uh;
183     typedef signed short int sljit_h;
184    
185     /* 32 bit integer type. */
186     typedef unsigned int sljit_ui;
187     typedef signed int sljit_i;
188    
189     /* Machine word type. Can encapsulate a pointer.
190     32 bit for 32 bit machines.
191     64 bit for 64 bit machines. */
192     #if !(defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) && !(defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
193     #define SLJIT_32BIT_ARCHITECTURE 1
194     #define SLJIT_WORD_SHIFT 2
195     typedef unsigned int sljit_uw;
196     typedef int sljit_w;
197     #else
198     #define SLJIT_64BIT_ARCHITECTURE 1
199     #define SLJIT_WORD_SHIFT 3
200     #ifdef _WIN32
201     typedef unsigned __int64 sljit_uw;
202     typedef __int64 sljit_w;
203     #else
204     typedef unsigned long int sljit_uw;
205     typedef long int sljit_w;
206     #endif
207     #endif
208    
209     /* Double precision. */
210     #define SLJIT_FLOAT_SHIFT 3
211    
212     #ifndef SLJIT_W
213    
214     /* Defining long constants. */
215     #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
216     #define SLJIT_W(w) (w##ll)
217     #else
218     #define SLJIT_W(w) (w)
219     #endif
220    
221     #endif /* !SLJIT_W */
222    
223     #ifndef SLJIT_CALL
224    
225     /* ABI (Application Binary Interface) types. */
226     #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
227    
228     #ifdef __GNUC__
229     #define SLJIT_CALL __attribute__ ((fastcall))
230     #define SLJIT_X86_32_FASTCALL 1
231     #elif defined(_WIN32)
232     #define SLJIT_CALL __fastcall
233     #define SLJIT_X86_32_FASTCALL 1
234     #else
235     #define SLJIT_CALL __stdcall
236     #endif
237    
238     #else /* Other architectures. */
239    
240     #define SLJIT_CALL
241    
242     #endif /* SLJIT_CONFIG_X86_32 */
243    
244     #endif /* !SLJIT_CALL */
245    
246     #if !defined(SLJIT_BIG_ENDIAN) && !defined(SLJIT_LITTLE_ENDIAN)
247    
248     /* These macros are useful for the application. */
249 zherczeg 703 #if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) || (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
250 ph10 662 #define SLJIT_BIG_ENDIAN 1
251 zherczeg 703
252     #elif (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
253    
254     #ifdef __MIPSEL__
255     #define SLJIT_LITTLE_ENDIAN 1
256 ph10 662 #else
257 zherczeg 703 #define SLJIT_BIG_ENDIAN 1
258     #endif
259    
260     #else
261 ph10 662 #define SLJIT_LITTLE_ENDIAN 1
262     #endif
263    
264     #endif /* !defined(SLJIT_BIG_ENDIAN) && !defined(SLJIT_LITTLE_ENDIAN) */
265    
266     /* Sanity check. */
267     #if (defined SLJIT_BIG_ENDIAN && SLJIT_BIG_ENDIAN) && (defined SLJIT_LITTLE_ENDIAN && SLJIT_LITTLE_ENDIAN)
268     #error "Exactly one endianness must be selected"
269     #endif
270    
271     #if !(defined SLJIT_BIG_ENDIAN && SLJIT_BIG_ENDIAN) && !(defined SLJIT_LITTLE_ENDIAN && SLJIT_LITTLE_ENDIAN)
272     #error "Exactly one endianness must be selected"
273     #endif
274    
275     #if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
276     /* It seems ppc64 compilers use an indirect addressing for functions.
277     It makes things really complicated. */
278     #define SLJIT_INDIRECT_CALL 1
279     #endif
280    
281     #ifndef SLJIT_SSE2
282    
283     #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) || (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
284     /* Turn on SSE2 support on x86 (operating on doubles).
285     (Better performance than legacy fpu instructions). */
286     #define SLJIT_SSE2 1
287    
288     #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
289     /* Auto detect SSE2 support using CPUID.
290     On 64 bit x86 cpus, sse2 must be present. */
291     #define SLJIT_SSE2_AUTO 1
292     #endif
293    
294     #endif /* (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) || (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) */
295    
296     #endif /* !SLJIT_SSE2 */
297    
298     #ifndef SLJIT_UNALIGNED
299    
300     #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) \
301     || (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) \
302     || (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7) \
303     || (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2) \
304     || (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) \
305     || (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
306     #define SLJIT_UNALIGNED 1
307     #endif
308    
309     #endif /* !SLJIT_UNALIGNED */
310    
311     #if (defined SLJIT_EXECUTABLE_ALLOCATOR && SLJIT_EXECUTABLE_ALLOCATOR)
312     void* sljit_malloc_exec(sljit_uw size);
313     void sljit_free_exec(void* ptr);
314     #define SLJIT_MALLOC_EXEC(size) sljit_malloc_exec(size)
315     #define SLJIT_FREE_EXEC(ptr) sljit_free_exec(ptr)
316     #endif
317    
318     #if (defined SLJIT_DEBUG && SLJIT_DEBUG) || (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
319     #include <stdio.h>
320     #endif
321    
322     #if (defined SLJIT_DEBUG && SLJIT_DEBUG)
323    
324     /* Feel free to redefine these two macros. */
325     #ifndef SLJIT_ASSERT
326    
327     #define SLJIT_ASSERT(x) \
328     do { \
329     if (SLJIT_UNLIKELY(!(x))) { \
330     printf("Assertion failed at " __FILE__ ":%d\n", __LINE__); \
331     *((int*)0) = 0; \
332     } \
333     } while (0)
334    
335     #endif /* !SLJIT_ASSERT */
336    
337     #ifndef SLJIT_ASSERT_STOP
338    
339     #define SLJIT_ASSERT_STOP() \
340     do { \
341     printf("Should never been reached " __FILE__ ":%d\n", __LINE__); \
342     *((int*)0) = 0; \
343     } while (0)
344    
345     #endif /* !SLJIT_ASSERT_STOP */
346    
347     #else /* (defined SLJIT_DEBUG && SLJIT_DEBUG) */
348    
349     #undef SLJIT_ASSERT
350     #undef SLJIT_ASSERT_STOP
351    
352     #define SLJIT_ASSERT(x) \
353     do { } while (0)
354     #define SLJIT_ASSERT_STOP() \
355     do { } while (0)
356    
357     #endif /* (defined SLJIT_DEBUG && SLJIT_DEBUG) */
358    
359     #endif

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12