"Fossies" - the Fresh Open Source Software Archive

Member "pcre-8.44/sljit/sljitConfigInternal.h" (19 Nov 2019, 24659 Bytes) of package /linux/misc/pcre-8.44.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "sljitConfigInternal.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 8.43_vs_8.44.

    1 /*
    2  *    Stack-less Just-In-Time compiler
    3  *
    4  *    Copyright 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_s8, sljit_u8   : signed and unsigned 8 bit integer type
   35      sljit_s16, sljit_u16 : signed and unsigned 16 bit integer type
   36      sljit_s32, sljit_u32 : 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_f32            : 32 bit single precision floating point value
   41      sljit_f64            : 64 bit 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_F32_SHIFT : the shift required to apply when accessing
   60                        a single precision floating point array by index
   61      SLJIT_F64_SHIFT : the shift required to apply when accessing
   62                        a double precision floating point array by index
   63      SLJIT_PREF_SHIFT_REG : x86 systems prefers ecx for shifting by register
   64                             the scratch register index of ecx is stored in this variable
   65      SLJIT_LOCALS_OFFSET : local space starting offset (SLJIT_SP + SLJIT_LOCALS_OFFSET)
   66      SLJIT_RETURN_ADDRESS_OFFSET : a return instruction always adds this offset to the return address
   67 
   68    Other macros:
   69      SLJIT_FUNC : calling convention attribute for both calling JIT from C and C calling back from JIT
   70      SLJIT_W(number) : defining 64 bit constants on 64 bit architectures (compiler independent helper)
   71 */
   72 
   73 /*****************/
   74 /* Sanity check. */
   75 /*****************/
   76 
   77 #if !((defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) \
   78     || (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) \
   79     || (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) \
   80     || (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7) \
   81     || (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2) \
   82     || (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) \
   83     || (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) \
   84     || (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) \
   85     || (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) \
   86     || (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64) \
   87     || (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32) \
   88     || (defined SLJIT_CONFIG_TILEGX && SLJIT_CONFIG_TILEGX) \
   89     || (defined SLJIT_CONFIG_AUTO && SLJIT_CONFIG_AUTO) \
   90     || (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED))
   91 #error "An architecture must be selected"
   92 #endif
   93 
   94 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) \
   95     + (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) \
   96     + (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) \
   97     + (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7) \
   98     + (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2) \
   99     + (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) \
  100     + (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) \
  101     + (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) \
  102     + (defined SLJIT_CONFIG_TILEGX && SLJIT_CONFIG_TILEGX) \
  103     + (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) \
  104     + (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64) \
  105     + (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32) \
  106     + (defined SLJIT_CONFIG_AUTO && SLJIT_CONFIG_AUTO) \
  107     + (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED) >= 2
  108 #error "Multiple architectures are selected"
  109 #endif
  110 
  111 /********************************************************/
  112 /* Automatic CPU detection (requires compiler support). */
  113 /********************************************************/
  114 
  115 #if (defined SLJIT_CONFIG_AUTO && SLJIT_CONFIG_AUTO)
  116 
  117 #ifndef _WIN32
  118 
  119 #if defined(__i386__) || defined(__i386)
  120 #define SLJIT_CONFIG_X86_32 1
  121 #elif defined(__x86_64__)
  122 #define SLJIT_CONFIG_X86_64 1
  123 #elif defined(__arm__) || defined(__ARM__)
  124 #ifdef __thumb2__
  125 #define SLJIT_CONFIG_ARM_THUMB2 1
  126 #elif defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__)
  127 #define SLJIT_CONFIG_ARM_V7 1
  128 #else
  129 #define SLJIT_CONFIG_ARM_V5 1
  130 #endif
  131 #elif defined (__aarch64__)
  132 #define SLJIT_CONFIG_ARM_64 1
  133 #elif defined(__ppc64__) || defined(__powerpc64__) || defined(_ARCH_PPC64) || (defined(_POWER) && defined(__64BIT__))
  134 #define SLJIT_CONFIG_PPC_64 1
  135 #elif defined(__ppc__) || defined(__powerpc__) || defined(_ARCH_PPC) || defined(_ARCH_PWR) || defined(_ARCH_PWR2) || defined(_POWER)
  136 #define SLJIT_CONFIG_PPC_32 1
  137 #elif defined(__mips__) && !defined(_LP64)
  138 #define SLJIT_CONFIG_MIPS_32 1
  139 #elif defined(__mips64)
  140 #define SLJIT_CONFIG_MIPS_64 1
  141 #elif defined(__sparc__) || defined(__sparc)
  142 #define SLJIT_CONFIG_SPARC_32 1
  143 #elif defined(__tilegx__)
  144 #define SLJIT_CONFIG_TILEGX 1
  145 #else
  146 /* Unsupported architecture */
  147 #define SLJIT_CONFIG_UNSUPPORTED 1
  148 #endif
  149 
  150 #else /* _WIN32 */
  151 
  152 #if defined(_M_X64) || defined(__x86_64__)
  153 #define SLJIT_CONFIG_X86_64 1
  154 #elif (defined(_M_ARM) && _M_ARM >= 7 && defined(_M_ARMT)) || defined(__thumb2__)
  155 #define SLJIT_CONFIG_ARM_THUMB2 1
  156 #elif (defined(_M_ARM) && _M_ARM >= 7)
  157 #define SLJIT_CONFIG_ARM_V7 1
  158 #elif defined(_ARM_)
  159 #define SLJIT_CONFIG_ARM_V5 1
  160 #elif defined(_M_ARM64) || defined(__aarch64__)
  161 #define SLJIT_CONFIG_ARM_64 1
  162 #else
  163 #define SLJIT_CONFIG_X86_32 1
  164 #endif
  165 
  166 #endif /* !_WIN32 */
  167 #endif /* SLJIT_CONFIG_AUTO */
  168 
  169 #if (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
  170 #undef SLJIT_EXECUTABLE_ALLOCATOR
  171 #endif
  172 
  173 /******************************/
  174 /* CPU family type detection. */
  175 /******************************/
  176 
  177 #if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) || (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7) \
  178     || (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
  179 #define SLJIT_CONFIG_ARM_32 1
  180 #endif
  181 
  182 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) || (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
  183 #define SLJIT_CONFIG_X86 1
  184 #elif (defined SLJIT_CONFIG_ARM_32 && SLJIT_CONFIG_ARM_32) || (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64)
  185 #define SLJIT_CONFIG_ARM 1
  186 #elif (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) || (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
  187 #define SLJIT_CONFIG_PPC 1
  188 #elif (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) || (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64)
  189 #define SLJIT_CONFIG_MIPS 1
  190 #elif (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32) || (defined SLJIT_CONFIG_SPARC_64 && SLJIT_CONFIG_SPARC_64)
  191 #define SLJIT_CONFIG_SPARC 1
  192 #endif
  193 
  194 /**********************************/
  195 /* External function definitions. */
  196 /**********************************/
  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, allocator_data) malloc(size)
  207 #endif
  208 
  209 #ifndef SLJIT_FREE
  210 #define SLJIT_FREE(ptr, allocator_data) free(ptr)
  211 #endif
  212 
  213 #ifndef SLJIT_MEMCPY
  214 #define SLJIT_MEMCPY(dest, src, len) memcpy(dest, src, len)
  215 #endif
  216 
  217 #ifndef SLJIT_MEMMOVE
  218 #define SLJIT_MEMMOVE(dest, src, len) memmove(dest, src, len)
  219 #endif
  220 
  221 #ifndef SLJIT_ZEROMEM
  222 #define SLJIT_ZEROMEM(dest, len) memset(dest, 0, len)
  223 #endif
  224 
  225 /***************************/
  226 /* Compiler helper macros. */
  227 /***************************/
  228 
  229 #if !defined(SLJIT_LIKELY) && !defined(SLJIT_UNLIKELY)
  230 
  231 #if defined(__GNUC__) && (__GNUC__ >= 3)
  232 #define SLJIT_LIKELY(x)     __builtin_expect((x), 1)
  233 #define SLJIT_UNLIKELY(x)   __builtin_expect((x), 0)
  234 #else
  235 #define SLJIT_LIKELY(x)     (x)
  236 #define SLJIT_UNLIKELY(x)   (x)
  237 #endif
  238 
  239 #endif /* !defined(SLJIT_LIKELY) && !defined(SLJIT_UNLIKELY) */
  240 
  241 #ifndef SLJIT_INLINE
  242 /* Inline functions. Some old compilers do not support them. */
  243 #if defined(__SUNPRO_C) && __SUNPRO_C <= 0x510
  244 #define SLJIT_INLINE
  245 #else
  246 #define SLJIT_INLINE __inline
  247 #endif
  248 #endif /* !SLJIT_INLINE */
  249 
  250 #ifndef SLJIT_NOINLINE
  251 /* Not inline functions. */
  252 #if defined(__GNUC__)
  253 #define SLJIT_NOINLINE __attribute__ ((noinline))
  254 #else
  255 #define SLJIT_NOINLINE
  256 #endif
  257 #endif /* !SLJIT_INLINE */
  258 
  259 #ifndef SLJIT_UNUSED_ARG
  260 /* Unused arguments. */
  261 #define SLJIT_UNUSED_ARG(arg) (void)arg
  262 #endif
  263 
  264 /*********************************/
  265 /* Type of public API functions. */
  266 /*********************************/
  267 
  268 #if (defined SLJIT_CONFIG_STATIC && SLJIT_CONFIG_STATIC)
  269 /* Static ABI functions. For all-in-one programs. */
  270 
  271 #if defined(__GNUC__)
  272 /* Disable unused warnings in gcc. */
  273 #define SLJIT_API_FUNC_ATTRIBUTE static __attribute__((unused))
  274 #else
  275 #define SLJIT_API_FUNC_ATTRIBUTE static
  276 #endif
  277 
  278 #else
  279 #define SLJIT_API_FUNC_ATTRIBUTE
  280 #endif /* (defined SLJIT_CONFIG_STATIC && SLJIT_CONFIG_STATIC) */
  281 
  282 /****************************/
  283 /* Instruction cache flush. */
  284 /****************************/
  285 
  286 #if (!defined SLJIT_CACHE_FLUSH && defined __has_builtin)
  287 #if __has_builtin(__builtin___clear_cache)
  288 
  289 #define SLJIT_CACHE_FLUSH(from, to) \
  290     __builtin___clear_cache((char*)from, (char*)to)
  291 
  292 #endif /* __has_builtin(__builtin___clear_cache) */
  293 #endif /* (!defined SLJIT_CACHE_FLUSH && defined __has_builtin) */
  294 
  295 #ifndef SLJIT_CACHE_FLUSH
  296 
  297 #if (defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86)
  298 
  299 /* Not required to implement on archs with unified caches. */
  300 #define SLJIT_CACHE_FLUSH(from, to)
  301 
  302 #elif defined __APPLE__
  303 
  304 /* Supported by all macs since Mac OS 10.5.
  305    However, it does not work on non-jailbroken iOS devices,
  306    although the compilation is successful. */
  307 
  308 #define SLJIT_CACHE_FLUSH(from, to) \
  309     sys_icache_invalidate((char*)(from), (char*)(to) - (char*)(from))
  310 
  311 #elif (defined SLJIT_CONFIG_PPC && SLJIT_CONFIG_PPC)
  312 
  313 /* The __clear_cache() implementation of GCC is a dummy function on PowerPC. */
  314 #define SLJIT_CACHE_FLUSH(from, to) \
  315     ppc_cache_flush((from), (to))
  316 #define SLJIT_CACHE_FLUSH_OWN_IMPL 1
  317 
  318 #elif (defined(__GNUC__) && (__GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)))
  319 
  320 #define SLJIT_CACHE_FLUSH(from, to) \
  321     __builtin___clear_cache((char*)from, (char*)to)
  322 
  323 #elif defined __ANDROID__
  324 
  325 /* Android lacks __clear_cache; instead, cacheflush should be used. */
  326 
  327 #define SLJIT_CACHE_FLUSH(from, to) \
  328     cacheflush((long)(from), (long)(to), 0)
  329 
  330 #elif (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
  331 
  332 /* The __clear_cache() implementation of GCC is a dummy function on Sparc. */
  333 #define SLJIT_CACHE_FLUSH(from, to) \
  334     sparc_cache_flush((from), (to))
  335 #define SLJIT_CACHE_FLUSH_OWN_IMPL 1
  336 
  337 #elif defined _WIN32
  338 
  339 #define SLJIT_CACHE_FLUSH(from, to) \
  340     FlushInstructionCache(GetCurrentProcess(), (char*)(from), (char*)(to) - (char*)(from))
  341 
  342 #else
  343 
  344 /* Calls __ARM_NR_cacheflush on ARM-Linux. */
  345 #define SLJIT_CACHE_FLUSH(from, to) \
  346     __clear_cache((char*)(from), (char*)(to))
  347 
  348 #endif
  349 
  350 #endif /* !SLJIT_CACHE_FLUSH */
  351 
  352 /******************************************************/
  353 /*    Integer and floating point type definitions.    */
  354 /******************************************************/
  355 
  356 /* 8 bit byte type. */
  357 typedef unsigned char sljit_u8;
  358 typedef signed char sljit_s8;
  359 
  360 /* 16 bit half-word type. */
  361 typedef unsigned short int sljit_u16;
  362 typedef signed short int sljit_s16;
  363 
  364 /* 32 bit integer type. */
  365 typedef unsigned int sljit_u32;
  366 typedef signed int sljit_s32;
  367 
  368 /* Machine word type. Enough for storing a pointer.
  369      32 bit for 32 bit machines.
  370      64 bit for 64 bit machines. */
  371 #if (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
  372 /* Just to have something. */
  373 #define SLJIT_WORD_SHIFT 0
  374 typedef unsigned long int sljit_uw;
  375 typedef long int sljit_sw;
  376 #elif !(defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) \
  377     && !(defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) \
  378     && !(defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) \
  379     && !(defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64) \
  380     && !(defined SLJIT_CONFIG_TILEGX && SLJIT_CONFIG_TILEGX)
  381 #define SLJIT_32BIT_ARCHITECTURE 1
  382 #define SLJIT_WORD_SHIFT 2
  383 typedef unsigned int sljit_uw;
  384 typedef int sljit_sw;
  385 #else
  386 #define SLJIT_64BIT_ARCHITECTURE 1
  387 #define SLJIT_WORD_SHIFT 3
  388 #ifdef _WIN32
  389 #ifdef __GNUC__
  390 /* These types do not require windows.h */
  391 typedef unsigned long long sljit_uw;
  392 typedef long long sljit_sw;
  393 #else
  394 typedef unsigned __int64 sljit_uw;
  395 typedef __int64 sljit_sw;
  396 #endif
  397 #else /* !_WIN32 */
  398 typedef unsigned long int sljit_uw;
  399 typedef long int sljit_sw;
  400 #endif /* _WIN32 */
  401 #endif
  402 
  403 typedef sljit_uw sljit_p;
  404 
  405 /* Floating point types. */
  406 typedef float sljit_f32;
  407 typedef double sljit_f64;
  408 
  409 /* Shift for pointer sized data. */
  410 #define SLJIT_POINTER_SHIFT SLJIT_WORD_SHIFT
  411 
  412 /* Shift for double precision sized data. */
  413 #define SLJIT_F32_SHIFT 2
  414 #define SLJIT_F64_SHIFT 3
  415 
  416 #ifndef SLJIT_W
  417 
  418 /* Defining long constants. */
  419 #if (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
  420 #define SLJIT_W(w)  (w##l)
  421 #elif (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
  422 #define SLJIT_W(w)  (w##ll)
  423 #else
  424 #define SLJIT_W(w)  (w)
  425 #endif
  426 
  427 #endif /* !SLJIT_W */
  428 
  429 /*************************/
  430 /* Endianness detection. */
  431 /*************************/
  432 
  433 #if !defined(SLJIT_BIG_ENDIAN) && !defined(SLJIT_LITTLE_ENDIAN)
  434 
  435 /* These macros are mostly useful for the applications. */
  436 #if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) \
  437     || (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
  438 
  439 #ifdef __LITTLE_ENDIAN__
  440 #define SLJIT_LITTLE_ENDIAN 1
  441 #else
  442 #define SLJIT_BIG_ENDIAN 1
  443 #endif
  444 
  445 #elif (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) \
  446     || (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64)
  447 
  448 #ifdef __MIPSEL__
  449 #define SLJIT_LITTLE_ENDIAN 1
  450 #else
  451 #define SLJIT_BIG_ENDIAN 1
  452 #endif
  453 
  454 #elif (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
  455 
  456 #define SLJIT_BIG_ENDIAN 1
  457 
  458 #else
  459 #define SLJIT_LITTLE_ENDIAN 1
  460 #endif
  461 
  462 #endif /* !defined(SLJIT_BIG_ENDIAN) && !defined(SLJIT_LITTLE_ENDIAN) */
  463 
  464 /* Sanity check. */
  465 #if (defined SLJIT_BIG_ENDIAN && SLJIT_BIG_ENDIAN) && (defined SLJIT_LITTLE_ENDIAN && SLJIT_LITTLE_ENDIAN)
  466 #error "Exactly one endianness must be selected"
  467 #endif
  468 
  469 #if !(defined SLJIT_BIG_ENDIAN && SLJIT_BIG_ENDIAN) && !(defined SLJIT_LITTLE_ENDIAN && SLJIT_LITTLE_ENDIAN)
  470 #error "Exactly one endianness must be selected"
  471 #endif
  472 
  473 #ifndef SLJIT_UNALIGNED
  474 
  475 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) \
  476     || (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) \
  477     || (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7) \
  478     || (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2) \
  479     || (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) \
  480     || (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) \
  481     || (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
  482 #define SLJIT_UNALIGNED 1
  483 #endif
  484 
  485 #endif /* !SLJIT_UNALIGNED */
  486 
  487 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
  488 /* Auto detect SSE2 support using CPUID.
  489    On 64 bit x86 cpus, sse2 must be present. */
  490 #define SLJIT_DETECT_SSE2 1
  491 #endif
  492 
  493 /*****************************************************************************************/
  494 /* Calling convention of functions generated by SLJIT or called from the generated code. */
  495 /*****************************************************************************************/
  496 
  497 #ifndef SLJIT_FUNC
  498 
  499 #if (defined SLJIT_USE_CDECL_CALLING_CONVENTION && SLJIT_USE_CDECL_CALLING_CONVENTION)
  500 
  501 /* Force cdecl. */
  502 #define SLJIT_FUNC
  503 
  504 #elif (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
  505 
  506 #if defined(__GNUC__) && !defined(__APPLE__)
  507 
  508 #define SLJIT_FUNC __attribute__ ((fastcall))
  509 #define SLJIT_X86_32_FASTCALL 1
  510 
  511 #elif defined(_MSC_VER)
  512 
  513 #define SLJIT_FUNC __fastcall
  514 #define SLJIT_X86_32_FASTCALL 1
  515 
  516 #elif defined(__BORLANDC__)
  517 
  518 #define SLJIT_FUNC __msfastcall
  519 #define SLJIT_X86_32_FASTCALL 1
  520 
  521 #else /* Unknown compiler. */
  522 
  523 /* The cdecl attribute is the default. */
  524 #define SLJIT_FUNC
  525 
  526 #endif
  527 
  528 #else /* Non x86-32 architectures. */
  529 
  530 #define SLJIT_FUNC
  531 
  532 #endif /* SLJIT_CONFIG_X86_32 */
  533 
  534 #endif /* !SLJIT_FUNC */
  535 
  536 #ifndef SLJIT_INDIRECT_CALL
  537 #if ((defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) && (!defined _CALL_ELF || _CALL_ELF == 1)) \
  538     || ((defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) && defined _AIX)
  539 /* It seems certain ppc compilers use an indirect addressing for functions
  540    which makes things complicated. */
  541 #define SLJIT_INDIRECT_CALL 1
  542 #endif
  543 #endif /* SLJIT_INDIRECT_CALL */
  544 
  545 /* The offset which needs to be substracted from the return address to
  546 determine the next executed instruction after return. */
  547 #ifndef SLJIT_RETURN_ADDRESS_OFFSET
  548 #if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
  549 #define SLJIT_RETURN_ADDRESS_OFFSET 8
  550 #else
  551 #define SLJIT_RETURN_ADDRESS_OFFSET 0
  552 #endif
  553 #endif /* SLJIT_RETURN_ADDRESS_OFFSET */
  554 
  555 /***************************************************/
  556 /* Functions of the built-in executable allocator. */
  557 /***************************************************/
  558 
  559 #if (defined SLJIT_EXECUTABLE_ALLOCATOR && SLJIT_EXECUTABLE_ALLOCATOR)
  560 SLJIT_API_FUNC_ATTRIBUTE void* sljit_malloc_exec(sljit_uw size);
  561 SLJIT_API_FUNC_ATTRIBUTE void sljit_free_exec(void* ptr);
  562 SLJIT_API_FUNC_ATTRIBUTE void sljit_free_unused_memory_exec(void);
  563 #define SLJIT_MALLOC_EXEC(size) sljit_malloc_exec(size)
  564 #define SLJIT_FREE_EXEC(ptr) sljit_free_exec(ptr)
  565 
  566 #if (defined SLJIT_PROT_EXECUTABLE_ALLOCATOR && SLJIT_PROT_EXECUTABLE_ALLOCATOR)
  567 SLJIT_API_FUNC_ATTRIBUTE sljit_sw sljit_exec_offset(void* ptr);
  568 #define SLJIT_EXEC_OFFSET(ptr) sljit_exec_offset(ptr)
  569 #else
  570 #define SLJIT_EXEC_OFFSET(ptr) 0
  571 #endif
  572 
  573 #endif
  574 
  575 /**********************************************/
  576 /* Registers and locals offset determination. */
  577 /**********************************************/
  578 
  579 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
  580 
  581 #define SLJIT_NUMBER_OF_REGISTERS 12
  582 #define SLJIT_NUMBER_OF_SAVED_REGISTERS 9
  583 #define SLJIT_LOCALS_OFFSET_BASE (compiler->locals_offset)
  584 #define SLJIT_PREF_SHIFT_REG SLJIT_R2
  585 
  586 #elif (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
  587 
  588 #define SLJIT_NUMBER_OF_REGISTERS 13
  589 #ifndef _WIN64
  590 #define SLJIT_NUMBER_OF_SAVED_REGISTERS 6
  591 #define SLJIT_LOCALS_OFFSET_BASE 0
  592 #else /* _WIN64 */
  593 #define SLJIT_NUMBER_OF_SAVED_REGISTERS 8
  594 #define SLJIT_LOCALS_OFFSET_BASE (compiler->locals_offset)
  595 #endif /* !_WIN64 */
  596 #define SLJIT_PREF_SHIFT_REG SLJIT_R3
  597 
  598 #elif (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) || (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7)
  599 
  600 #define SLJIT_NUMBER_OF_REGISTERS 12
  601 #define SLJIT_NUMBER_OF_SAVED_REGISTERS 8
  602 #define SLJIT_LOCALS_OFFSET_BASE 0
  603 
  604 #elif (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
  605 
  606 #define SLJIT_NUMBER_OF_REGISTERS 12
  607 #define SLJIT_NUMBER_OF_SAVED_REGISTERS 8
  608 #define SLJIT_LOCALS_OFFSET_BASE 0
  609 
  610 #elif (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64)
  611 
  612 #define SLJIT_NUMBER_OF_REGISTERS 26
  613 #define SLJIT_NUMBER_OF_SAVED_REGISTERS 10
  614 #define SLJIT_LOCALS_OFFSET_BASE 0
  615 
  616 #elif (defined SLJIT_CONFIG_PPC && SLJIT_CONFIG_PPC)
  617 
  618 #define SLJIT_NUMBER_OF_REGISTERS 23
  619 #define SLJIT_NUMBER_OF_SAVED_REGISTERS 17
  620 #if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) || (defined _AIX)
  621 #define SLJIT_LOCALS_OFFSET_BASE ((6 + 8) * sizeof(sljit_sw))
  622 #elif (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32)
  623 /* Add +1 for double alignment. */
  624 #define SLJIT_LOCALS_OFFSET_BASE ((3 + 1) * sizeof(sljit_sw))
  625 #else
  626 #define SLJIT_LOCALS_OFFSET_BASE (3 * sizeof(sljit_sw))
  627 #endif /* SLJIT_CONFIG_PPC_64 || _AIX */
  628 
  629 #elif (defined SLJIT_CONFIG_MIPS && SLJIT_CONFIG_MIPS)
  630 
  631 #define SLJIT_NUMBER_OF_REGISTERS 21
  632 #define SLJIT_NUMBER_OF_SAVED_REGISTERS 8
  633 #if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
  634 #define SLJIT_LOCALS_OFFSET_BASE (4 * sizeof(sljit_sw))
  635 #else
  636 #define SLJIT_LOCALS_OFFSET_BASE 0
  637 #endif
  638 
  639 #elif (defined SLJIT_CONFIG_SPARC && SLJIT_CONFIG_SPARC)
  640 
  641 #define SLJIT_NUMBER_OF_REGISTERS 18
  642 #define SLJIT_NUMBER_OF_SAVED_REGISTERS 14
  643 #if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
  644 /* saved registers (16), return struct pointer (1), space for 6 argument words (1),
  645    4th double arg (2), double alignment (1). */
  646 #define SLJIT_LOCALS_OFFSET_BASE ((16 + 1 + 6 + 2 + 1) * sizeof(sljit_sw))
  647 #endif
  648 
  649 #elif (defined SLJIT_CONFIG_TILEGX && SLJIT_CONFIG_TILEGX)
  650 
  651 #define SLJIT_NUMBER_OF_REGISTERS 10
  652 #define SLJIT_NUMBER_OF_SAVED_REGISTERS 5
  653 #define SLJIT_LOCALS_OFFSET_BASE 0
  654 
  655 #elif (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
  656 
  657 #define SLJIT_NUMBER_OF_REGISTERS 0
  658 #define SLJIT_NUMBER_OF_SAVED_REGISTERS 0
  659 #define SLJIT_LOCALS_OFFSET_BASE 0
  660 
  661 #endif
  662 
  663 #define SLJIT_LOCALS_OFFSET (SLJIT_LOCALS_OFFSET_BASE)
  664 
  665 #define SLJIT_NUMBER_OF_SCRATCH_REGISTERS \
  666     (SLJIT_NUMBER_OF_REGISTERS - SLJIT_NUMBER_OF_SAVED_REGISTERS)
  667 
  668 #define SLJIT_NUMBER_OF_FLOAT_REGISTERS 6
  669 #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) && (defined _WIN64)
  670 #define SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS 1
  671 #else
  672 #define SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS 0
  673 #endif
  674 
  675 #define SLJIT_NUMBER_OF_SCRATCH_FLOAT_REGISTERS \
  676     (SLJIT_NUMBER_OF_FLOAT_REGISTERS - SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS)
  677 
  678 /*************************************/
  679 /* Debug and verbose related macros. */
  680 /*************************************/
  681 
  682 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
  683 #include <stdio.h>
  684 #endif
  685 
  686 #if (defined SLJIT_DEBUG && SLJIT_DEBUG)
  687 
  688 #if !defined(SLJIT_ASSERT) || !defined(SLJIT_UNREACHABLE)
  689 
  690 /* SLJIT_HALT_PROCESS must halt the process. */
  691 #ifndef SLJIT_HALT_PROCESS
  692 #include <stdlib.h>
  693 
  694 #define SLJIT_HALT_PROCESS() \
  695     abort();
  696 #endif /* !SLJIT_HALT_PROCESS */
  697 
  698 #include <stdio.h>
  699 
  700 #endif /* !SLJIT_ASSERT || !SLJIT_UNREACHABLE */
  701 
  702 /* Feel free to redefine these two macros. */
  703 #ifndef SLJIT_ASSERT
  704 
  705 #define SLJIT_ASSERT(x) \
  706     do { \
  707         if (SLJIT_UNLIKELY(!(x))) { \
  708             printf("Assertion failed at " __FILE__ ":%d\n", __LINE__); \
  709             SLJIT_HALT_PROCESS(); \
  710         } \
  711     } while (0)
  712 
  713 #endif /* !SLJIT_ASSERT */
  714 
  715 #ifndef SLJIT_UNREACHABLE
  716 
  717 #define SLJIT_UNREACHABLE() \
  718     do { \
  719         printf("Should never been reached " __FILE__ ":%d\n", __LINE__); \
  720         SLJIT_HALT_PROCESS(); \
  721     } while (0)
  722 
  723 #endif /* !SLJIT_UNREACHABLE */
  724 
  725 #else /* (defined SLJIT_DEBUG && SLJIT_DEBUG) */
  726 
  727 /* Forcing empty, but valid statements. */
  728 #undef SLJIT_ASSERT
  729 #undef SLJIT_UNREACHABLE
  730 
  731 #define SLJIT_ASSERT(x) \
  732     do { } while (0)
  733 #define SLJIT_UNREACHABLE() \
  734     do { } while (0)
  735 
  736 #endif /* (defined SLJIT_DEBUG && SLJIT_DEBUG) */
  737 
  738 #ifndef SLJIT_COMPILE_ASSERT
  739 
  740 #define SLJIT_COMPILE_ASSERT(x, description) \
  741     switch(0) { case 0: case ((x) ? 1 : 0): break; }
  742 
  743 #endif /* !SLJIT_COMPILE_ASSERT */
  744 
  745 #endif