php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
sljitConfigCPU.h
Go to the documentation of this file.
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_CPU_H_
28#define SLJIT_CONFIG_CPU_H_
29
30/* --------------------------------------------------------------------- */
31/* Architecture */
32/* --------------------------------------------------------------------- */
33
34/* Architecture selection. */
35/* #define SLJIT_CONFIG_X86_32 1 */
36/* #define SLJIT_CONFIG_X86_64 1 */
37/* #define SLJIT_CONFIG_ARM_V6 1 */
38/* #define SLJIT_CONFIG_ARM_V7 1 */
39/* #define SLJIT_CONFIG_ARM_THUMB2 1 */
40/* #define SLJIT_CONFIG_ARM_64 1 */
41/* #define SLJIT_CONFIG_PPC_32 1 */
42/* #define SLJIT_CONFIG_PPC_64 1 */
43/* #define SLJIT_CONFIG_MIPS_32 1 */
44/* #define SLJIT_CONFIG_MIPS_64 1 */
45/* #define SLJIT_CONFIG_RISCV_32 1 */
46/* #define SLJIT_CONFIG_RISCV_64 1 */
47/* #define SLJIT_CONFIG_S390X 1 */
48/* #define SLJIT_CONFIG_LOONGARCH_64 */
49
50/* #define SLJIT_CONFIG_AUTO 1 */
51/* #define SLJIT_CONFIG_UNSUPPORTED 1 */
52
53/*****************/
54/* Sanity check. */
55/*****************/
56
57#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) \
58 + (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) \
59 + (defined SLJIT_CONFIG_ARM_V6 && SLJIT_CONFIG_ARM_V6) \
60 + (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7) \
61 + (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2) \
62 + (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) \
63 + (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) \
64 + (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) \
65 + (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) \
66 + (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64) \
67 + (defined SLJIT_CONFIG_RISCV_32 && SLJIT_CONFIG_RISCV_32) \
68 + (defined SLJIT_CONFIG_RISCV_64 && SLJIT_CONFIG_RISCV_64) \
69 + (defined SLJIT_CONFIG_S390X && SLJIT_CONFIG_S390X) \
70 + (defined SLJIT_CONFIG_LOONGARCH_64 && SLJIT_CONFIG_LOONGARCH_64) \
71 + (defined SLJIT_CONFIG_AUTO && SLJIT_CONFIG_AUTO) \
72 + (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED) >= 2
73#error "Multiple architectures are selected"
74#endif
75
76#if !(defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) \
77 && !(defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) \
78 && !(defined SLJIT_CONFIG_ARM_V6 && SLJIT_CONFIG_ARM_V6) \
79 && !(defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7) \
80 && !(defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2) \
81 && !(defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) \
82 && !(defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) \
83 && !(defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) \
84 && !(defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) \
85 && !(defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64) \
86 && !(defined SLJIT_CONFIG_RISCV_32 && SLJIT_CONFIG_RISCV_32) \
87 && !(defined SLJIT_CONFIG_RISCV_64 && SLJIT_CONFIG_RISCV_64) \
88 && !(defined SLJIT_CONFIG_S390X && SLJIT_CONFIG_S390X) \
89 && !(defined SLJIT_CONFIG_LOONGARCH_64 && SLJIT_CONFIG_LOONGARCH_64) \
90 && !(defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED) \
91 && !(defined SLJIT_CONFIG_AUTO && SLJIT_CONFIG_AUTO)
92#if defined SLJIT_CONFIG_AUTO && !SLJIT_CONFIG_AUTO
93#error "An architecture must be selected"
94#else /* SLJIT_CONFIG_AUTO */
95#define SLJIT_CONFIG_AUTO 1
96#endif /* !SLJIT_CONFIG_AUTO */
97#endif /* !SLJIT_CONFIG */
98
99/********************************************************/
100/* Automatic CPU detection (requires compiler support). */
101/********************************************************/
102
103#if (defined SLJIT_CONFIG_AUTO && SLJIT_CONFIG_AUTO)
104#ifndef _WIN32
105
106#if defined(__i386__) || defined(__i386)
107#define SLJIT_CONFIG_X86_32 1
108#elif defined(__x86_64__)
109#define SLJIT_CONFIG_X86_64 1
110#elif defined(__aarch64__)
111#define SLJIT_CONFIG_ARM_64 1
112#elif defined(__thumb2__)
113#define SLJIT_CONFIG_ARM_THUMB2 1
114#elif (defined(__ARM_ARCH) && __ARM_ARCH >= 7) || \
115 ((defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7S__)) \
116 || (defined(__ARM_ARCH_8A__) || defined(__ARM_ARCH_8R__)) \
117 || (defined(__ARM_ARCH_9A__)))
118#define SLJIT_CONFIG_ARM_V7 1
119#elif defined(__arm__) || defined (__ARM__)
120#define SLJIT_CONFIG_ARM_V6 1
121#elif defined(__ppc64__) || defined(__powerpc64__) || (defined(_ARCH_PPC64) && defined(__64BIT__)) || (defined(_POWER) && defined(__64BIT__))
122#define SLJIT_CONFIG_PPC_64 1
123#elif defined(__ppc__) || defined(__powerpc__) || defined(_ARCH_PPC) || defined(_ARCH_PWR) || defined(_ARCH_PWR2) || defined(_POWER)
124#define SLJIT_CONFIG_PPC_32 1
125#elif defined(__mips__) && !defined(_LP64)
126#define SLJIT_CONFIG_MIPS_32 1
127#elif defined(__mips64)
128#define SLJIT_CONFIG_MIPS_64 1
129#elif defined (__riscv_xlen) && (__riscv_xlen == 32)
130#define SLJIT_CONFIG_RISCV_32 1
131#elif defined (__riscv_xlen) && (__riscv_xlen == 64)
132#define SLJIT_CONFIG_RISCV_64 1
133#elif defined (__loongarch_lp64)
134#define SLJIT_CONFIG_LOONGARCH_64 1
135#elif defined(__s390x__)
136#define SLJIT_CONFIG_S390X 1
137#else
138/* Unsupported architecture */
139#define SLJIT_CONFIG_UNSUPPORTED 1
140#endif
141
142#else /* _WIN32 */
143
144#if defined(_M_X64) || defined(__x86_64__)
145#define SLJIT_CONFIG_X86_64 1
146#elif (defined(_M_ARM) && _M_ARM >= 7 && defined(_M_ARMT)) || defined(__thumb2__)
147#define SLJIT_CONFIG_ARM_THUMB2 1
148#elif (defined(_M_ARM) && _M_ARM >= 7)
149#define SLJIT_CONFIG_ARM_V7 1
150#elif defined(_ARM_)
151#define SLJIT_CONFIG_ARM_V6 1
152#elif defined(_M_ARM64) || defined(__aarch64__)
153#define SLJIT_CONFIG_ARM_64 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 /* SLJIT_CONFIG_UNSUPPORTED */
164
165/******************************/
166/* CPU family type detection. */
167/******************************/
168
169#if (defined SLJIT_CONFIG_ARM_V6 && SLJIT_CONFIG_ARM_V6) || (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_RISCV_32 && SLJIT_CONFIG_RISCV_32) || (defined SLJIT_CONFIG_RISCV_64 && SLJIT_CONFIG_RISCV_64)
183#define SLJIT_CONFIG_RISCV 1
184#elif (defined SLJIT_CONFIG_LOONGARCH_64 && SLJIT_CONFIG_LOONGARCH_64)
185#define SLJIT_CONFIG_LOONGARCH 1
186#endif
187
188#endif /* SLJIT_CONFIG_CPU_H_ */