2 * Copyright (C) 2006, 2007, 2008, 2009, 2013 Apple Inc. All rights reserved.
3 * Copyright (C) 2007-2009 Torch Mobile, Inc.
4 * Copyright (C) 2010, 2011 Research In Motion Limited. All rights reserved.
5 * Copyright (C) 2013 Samsung Electronics. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
20 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
24 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 #include "wtf/Compiler.h"
34 /* CPU() - the target CPU architecture */
35 #define CPU(WTF_FEATURE) (defined WTF_CPU_##WTF_FEATURE && WTF_CPU_##WTF_FEATURE)
37 /* ==== CPU() - the target CPU architecture ==== */
39 /* This defines CPU(BIG_ENDIAN) or nothing, as appropriate. */
40 /* This defines CPU(32BIT) or CPU(64BIT), as appropriate. */
42 /* CPU(X86) - i386 / x86 32-bit */
43 #if defined(__i386__) \
47 || defined(__THW_INTEL)
51 /* CPU(X86_64) - AMD64 / Intel64 / x86_64 64-bit */
52 #if defined(__x86_64__) \
54 #define WTF_CPU_X86_64 1
55 #define WTF_CPU_64BIT 1
58 /* CPU(ARM) - ARM, any version*/
59 #define WTF_ARM_ARCH_AT_LEAST(N) (CPU(ARM) && defined(WTF_ARM_ARCH_VERSION) && WTF_ARM_ARCH_VERSION >= N)
67 #if defined(__ARMEB__)
68 #define WTF_CPU_BIG_ENDIAN 1
70 #elif !defined(__ARM_EABI__) \
71 && !defined(__EABI__) \
72 && !defined(__VFP_FP__) \
73 && !defined(_WIN32_WCE) \
75 #define WTF_CPU_MIDDLE_ENDIAN 1
79 /* Set WTF_ARM_ARCH_VERSION */
80 #if defined(__ARM_ARCH_4__) \
81 || defined(__ARM_ARCH_4T__) \
82 || defined(__MARM_ARMV4__)
83 #define WTF_ARM_ARCH_VERSION 4
85 #elif defined(__ARM_ARCH_5__) \
86 || defined(__ARM_ARCH_5T__) \
87 || defined(__MARM_ARMV5__)
88 #define WTF_ARM_ARCH_VERSION 5
90 #elif defined(__ARM_ARCH_5E__) \
91 || defined(__ARM_ARCH_5TE__) \
92 || defined(__ARM_ARCH_5TEJ__)
93 #define WTF_ARM_ARCH_VERSION 5
95 #elif defined(__ARM_ARCH_6__) \
96 || defined(__ARM_ARCH_6J__) \
97 || defined(__ARM_ARCH_6K__) \
98 || defined(__ARM_ARCH_6Z__) \
99 || defined(__ARM_ARCH_6ZK__) \
100 || defined(__ARM_ARCH_6T2__) \
101 || defined(__ARMV6__)
102 #define WTF_ARM_ARCH_VERSION 6
104 #elif defined(__ARM_ARCH_7A__) \
105 || defined(__ARM_ARCH_7R__) \
106 || defined(__ARM_ARCH_7S__)
107 #define WTF_ARM_ARCH_VERSION 7
109 /* MSVC sets _M_ARM */
110 #elif defined(_M_ARM)
111 #define WTF_ARM_ARCH_VERSION _M_ARM
113 #define WTF_ARM_ARCH_VERSION 0
117 /* Set WTF_THUMB_ARCH_VERSION */
118 #if defined(__ARM_ARCH_4T__)
119 #define WTF_THUMB_ARCH_VERSION 1
121 #elif defined(__ARM_ARCH_5T__) \
122 || defined(__ARM_ARCH_5TE__) \
123 || defined(__ARM_ARCH_5TEJ__)
124 #define WTF_THUMB_ARCH_VERSION 2
126 #elif defined(__ARM_ARCH_6J__) \
127 || defined(__ARM_ARCH_6K__) \
128 || defined(__ARM_ARCH_6Z__) \
129 || defined(__ARM_ARCH_6ZK__) \
130 || defined(__ARM_ARCH_6M__)
131 #define WTF_THUMB_ARCH_VERSION 3
133 #elif defined(__ARM_ARCH_6T2__) \
134 || defined(__ARM_ARCH_7__) \
135 || defined(__ARM_ARCH_7A__) \
136 || defined(__ARM_ARCH_7M__) \
137 || defined(__ARM_ARCH_7R__) \
138 || defined(__ARM_ARCH_7S__)
139 #define WTF_THUMB_ARCH_VERSION 4
142 #define WTF_THUMB_ARCH_VERSION 0
146 /* CPU(ARM_THUMB2) - Thumb2 instruction set is available */
147 #if !defined(WTF_CPU_ARM_THUMB2)
148 # if defined(thumb2) || defined(__thumb2__) \
149 || ((defined(__thumb) || defined(__thumb__)) && WTF_THUMB_ARCH_VERSION == 4)
150 # define WTF_CPU_ARM_THUMB2 1
151 # elif WTF_ARM_ARCH_AT_LEAST(4)
152 # define WTF_CPU_ARM_THUMB2 0
154 # error "Unsupported ARM architecture"
156 #endif /* !defined(WTF_CPU_ARM_THUMB2) */
158 #if defined(__ARM_NEON__) && !defined(WTF_CPU_ARM_NEON)
159 #define WTF_CPU_ARM_NEON 1
162 #if CPU(ARM_NEON) && (!COMPILER(GCC) || GCC_VERSION_AT_LEAST(4, 7, 0))
163 // All NEON intrinsics usage can be disabled by this macro.
164 #define HAVE_ARM_NEON_INTRINSICS 1
167 #if defined(__ARM_ARCH_7S__)
168 #define WTF_CPU_APPLE_ARMV7S 1
173 /* CPU(ARM64) - AArch64 64-bit */
174 #if defined(__aarch64__)
175 #define WTF_CPU_ARM64 1
176 #define WTF_CPU_64BIT 1
179 /* This defines CPU(64BIT). */
180 #if defined(__mips__) && (_MIPS_SIM == _ABI64)
181 #define WTF_CPU_64BIT 1
184 #if !defined(WTF_CPU_64BIT)
185 #define WTF_CPU_32BIT 1
188 #endif /* WTF_CPU_h */