QtBase  v6.3.1
arch.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 The Qt Company Ltd.
4 ** Copyright (C) 2016 Intel Corporation.
5 ** Contact: https://www.qt.io/licensing/
6 **
7 ** This file is part of the FOO module of the Qt Toolkit.
8 **
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** Commercial License Usage
11 ** Licensees holding valid commercial Qt licenses may use this file in
12 ** accordance with the commercial license agreement provided with the
13 ** Software or, alternatively, in accordance with the terms contained in
14 ** a written agreement between you and The Qt Company. For licensing terms
15 ** and conditions see https://www.qt.io/terms-conditions. For further
16 ** information use the contact form at https://www.qt.io/contact-us.
17 **
18 ** GNU Lesser General Public License Usage
19 ** Alternatively, this file may be used under the terms of the GNU Lesser
20 ** General Public License version 3 as published by the Free Software
21 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
22 ** packaging of this file. Please review the following information to
23 ** ensure the GNU Lesser General Public License version 3 requirements
24 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
25 **
26 ** GNU General Public License Usage
27 ** Alternatively, this file may be used under the terms of the GNU
28 ** General Public License version 2.0 or (at your option) the GNU General
29 ** Public license version 3 or any later version approved by the KDE Free
30 ** Qt Foundation. The licenses are as published by the Free Software
31 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
32 ** included in the packaging of this file. Please review the following
33 ** information to ensure the GNU General Public License requirements will
34 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
35 ** https://www.gnu.org/licenses/gpl-3.0.html.
36 **
37 ** $QT_END_LICENSE$
38 **
39 ****************************************************************************/
40 
41 #define QGLOBAL_H
42 #include "../../src/corelib/global/archdetect.cpp"
43 #include <stdio.h>
44 
45 extern const char msg[];
46 const char msg[] = "==Qt=magic=Qt== Architecture:" ARCH_PROCESSOR;
47 
48 extern const char msg2[];
49 const char msg2[] = "==Qt=magic=Qt== Sub-architecture:"
50  // This is the list of features found in GCC or MSVC
51  // We don't use all of them, but this is ready for future expansion
52 
53 // -- x86 --
54 #ifdef __3dNOW__
55 // 3dNow!, introduced with the AMD K6-2, discontinued after 2010
56 " 3dnow"
57 #endif
58 #ifdef __3dNOW_A__
59 // Athlon
60 " 3dnow-a"
61 #endif
62 #ifdef __ABM__
63 // Advanced Bit Manipulation, AMD Barcelona (family 10h)
64 " abm"
65 #endif
66 #ifdef __ADX__
67 // Multi-Precision Add-Carry Instruction Extensions, Intel Core 5th generation ("Broadwell")
68 " adx"
69 #endif
70 #ifdef __AES__
71 // AES New Instructions, Intel Core-i7 second generation ("Sandy Bridge")
72 " aes"
73 #endif
74 #ifdef __AVX__
75 // Advanced Vector Extensions, Intel Core-i7 second generation ("Sandy Bridge")
76 " avx"
77 #endif
78 #ifdef __AVX2__
79 // AVX 2, Intel Core 4th Generation ("Haswell")
80 " avx2"
81 #endif
82 #ifdef __AVX512F__
83 // AVX512 Foundation, Intel Xeon Scalable ("Skylake" server), some Intel Core 7th generation ("Skylake")
84 " avx512f"
85 #endif
86 #ifdef __AVX512CD__
87 // AVX512 Conflict Detection, Intel Xeon Scalable ("Skylake" server), some Intel Core 7th generation ("Skylake")
88 " avx512cd"
89 #endif
90 #ifdef __AVX512DQ__
91 // AVX512 Double & Quadword, Intel Xeon Scalable ("Skylake" server), some Intel Core 7th generation ("Skylake")
92 " avx512dq"
93 #endif
94 #ifdef __AVX512BW__
95 // AVX512 Byte & Word, Intel Xeon Scalable ("Skylake" server), some Intel Core 7th generation ("Skylake")
96 " avx512bw"
97 #endif
98 #ifdef __AVX512ER__
99 // AVX512 Exponentiation & Reciprocal, Intel Xeon Phi codename "Knights Landing"
100 " avx512ef"
101 #endif
102 #ifdef __AVX512PF__
103 // AVX512 Prefetch, Intel Xeon Phi codename "Knights Landing"
104 " avx512pf"
105 #endif
106 #ifdef __AVX512VL__
107 // AVX512 Vector Length, Intel Xeon Scalable ("Skylake" server), some Intel Core 7th generation ("Skylake")
108 " avx512vl"
109 #endif
110 #ifdef __AVX512IFMA__
111 // AVX512 Integer Fused Multiply-Add, Intel processor codename "Cannonlake"
112 " avx512ifma"
113 #endif
114 #ifdef __AVX512VBMI__
115 // AVX512 Vector Byte Manipulation Instructions, Intel processor codename "Cannonlake"
116 " avx512vbmi"
117 #endif
118 #ifdef __AVX512VBMI2__
119 // AVX512 Vector Byte Manipulation Instructions #2, Intel processor codename "Ice Lake"
120 " avx512vbmi2"
121 #endif
122 #ifdef __AVX512VPOPCNTDQ__
123 // AVX512 Vector Population Count Double & Quad, Future Intel Xeon Phi processor codename "Knights Mill", Intel processor codename "Ice Lake"
124 " avx512vpopcntdq"
125 #endif
126 #ifdef __AVX5124FMAPS__
127 // AVX512 4-iteration Fused Multiply Accumulation Packed Single, Future Intel Xeon Phi processor codename "Knights Mill"
128 " avx5124fmaps"
129 #endif
130 #ifdef __AVX5124VNNIW__
131 // AVX512 4-iteration Vector Neural Network Instructions Word, Future Intel Xeon Phi processor codename "Knights Mill"
132 " avx5124vnniw"
133 #endif
134 #ifdef __BMI__
135 // Bit Manipulation Instructions 1, Intel Core 4th Generation ("Haswell"), AMD "Bulldozer 2"
136 " bmi"
137 #endif
138 #ifdef __BMI2__
139 // Bit Manipulation Instructions 2, Intel Core 4th Generation ("Haswell")
140 " bmi2"
141 #endif
142 #ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16
143 // cmpxchg16b instruction, Intel Pentium 4 64-bit ("Nocona"), AMD Barcelona (family 10h)
144 // Notably, this instruction is missing on earlier AMD Athlon 64
145 " cx16"
146 #endif
147 #ifdef __F16C__
148 // 16-bit floating point conversion, Intel Core 3rd Generation ("Ivy Bridge")
149 " f16c"
150 #endif
151 #ifdef __FMA__
152 // Fused Multiply-Add with 3 arguments, Intel Core 4th Generation ("Haswell"), AMD "Bulldozer 2"
153 // a.k.a. "FMA3"
154 " fma"
155 #endif
156 #ifdef __FMA4__
157 // Fused Multiply-Add with 4 arguments, AMD "Bulldozer"
158 " fma4"
159 #endif
160 #ifdef __FSGSBASE__
161 // rdfsgsbase, wrfsgsbase, Intel Core 3rd Generation ("Ivy Bridge")
162 " fsgsbase"
163 #endif
164 #ifdef __GFNI__
165 // Galois Field new instructions, Intel processor codename "Ice Lake"
166 " gfni"
167 #endif
168 #ifdef __IBT__
169 // Indirect Branch Tracking, Intel processor TBA
170 " ibt"
171 #endif
172 #ifdef __LWP__
173 // LWP instructions, AMD "Bulldozer"
174 " lwp"
175 #endif
176 #ifdef __LZCNT__
177 // Leading-Zero bit count, Intel Core 4th Generation ("Haswell")
178 " lzcnt"
179 #endif
180 #ifdef __MMX__
181 // Multimedia Extensions, Pentium MMX, AMD K6-2
182 " mmx"
183 #endif
184 #ifdef __MOVBE__
185 // Move Big Endian, Intel Atom & "Haswell"
186 " movbe"
187 #endif
188 #ifdef __MPX__
189 // Memory Protection Extensions, Intel Core processor codename "Skylake"
190 " mpx"
191 #endif
192 #ifdef __NO_SAHF__
193 // missing SAHF instruction in 64-bit, up to Intel Pentium 4 64-bit ("Nocona"), AMD Athlon FX
194 // Note: the macro is not defined, so this will never show up
195 " no-sahf"
196 #endif
197 #ifdef __PCLMUL__
198 // (Packed) Carry-less multiplication, Intel Core-i7 second generation ("Sandy Bridge")
199 " pclmul"
200 #endif
201 #ifdef __POPCNT__
202 // Population Count (count of set bits), Intel Core-i7 second generation ("Sandy Bridge")
203 " popcnt"
204 #endif
205 #ifdef __PREFETCHWT1__
206 // Prefetch data for writing with T1 hint, Intel processor TBA
207 " prefetchwt1"
208 #endif
209 #ifdef __PRFCHW__
210 // Prefetch data for writing, Intel Core 5th Generation ("Broadwell")
211 " prfchw"
212 #endif
213 #ifdef __RDPID__
214 // Read Processor ID, Intel processors codename "Ice Lake" and "Goldmont Plus"
215 " rdpid"
216 #endif
217 #ifdef __RDRND__
218 // Random number generator, Intel Core 3rd Generation ("Ivy Bridge")
219 " rdrnd"
220 #endif
221 #ifdef __RDSEED__
222 // Random number generator, Intel Core 5th Generation ("Broadwell")
223 " rdseed"
224 #endif
225 #ifdef __RTM__
226 // Restricted Transactional Memory, Intel Core 4th Generation ("Haswell")
227 " rtm"
228 #endif
229 #ifdef __SHA__
230 // SHA-1 and SHA-256 instructions, Intel processors codename "Cannon Lake" and "Goldmont"
231 " sha"
232 #endif
233 #ifdef __SHSTK__
234 // Shadow stack, Intel processor TBA
235 " shstk"
236 #endif
237 #if defined(__SSE__) || (defined(_M_IX86_FP) && _M_IX86_FP >= 1) || defined(_M_X64)
238 // Streaming SIMD Extensions, Intel Pentium III, AMD Athlon
239 " sse"
240 #endif
241 #if defined(__SSE2__) || (defined(_M_IX86_FP) && _M_IX86_FP >= 2) || defined(_M_X64)
242 // SSE2, Intel Pentium-M, Intel Pentium 4, AMD Opteron and Athlon 64
243 " sse2"
244 #endif
245 #ifdef __SSE3__
246 // SSE3, Intel Pentium 4 "Prescott", AMD Athlon 64 rev E
247 " sse3"
248 #endif
249 #ifdef __SSSE3__
250 // Supplemental SSE3, Intel Core 2 ("Merom"), AMD "Bulldozer"
251 " ssse3"
252 #endif
253 #ifdef __SSE4A__
254 // SSE4a, AMD Barcelona
255 " sse4a"
256 #endif
257 #ifdef __SSE4_1__
258 // SSE 4.1, Intel Core2 45nm shrink ("Penryn"), AMD "Bulldozer"
259 " sse4.1"
260 #endif
261 #ifdef __SSE4_2__
262 // SSE 4.2, Intel Core-i7 ("Nehalem"), AMD "Bulldozer"
263 " sse4.2"
264 // Since no processor supports SSE4.2 without 4.1 and since no Intel processor
265 // supports SSE4a, define "sse4" to indicate SSE4"
266 " sse4"
267 #endif
268 #ifdef __TBM__
269 // TBM, AMD "Bulldozer"
270 " tbm"
271 #endif
272 #ifdef __XOP__
273 // XOP, AMD "Bulldozer"
274 " xop"
275 #endif
276 
277 // -- ARM --
278 #if defined(__ARM_NEON) || defined(__ARM_NEON__)
279 " neon"
280 #endif
281 #ifdef __IWMMXT__
282 " iwmmxt"
283 #endif
284 #ifdef __ARM_FEATURE_CRC32
285 " crc32"
286 #endif
287 #ifdef __ARM_FEATURE_CRYPTO
288 " crypto"
289 #endif
290 
291 // -- SPARC --
292 #ifdef __VIS__
293 " vis"
294 # if __VIS__ >= 0x200
295 " vis2"
296 # endif
297 # if __VIS__ >= 0x300
298 " vis3"
299 # endif
300 #endif
301 
302 // -- MIPS --
303 # if __mips_dsp
304 " dsp"
305 # endif
306 # if __mips_dspr2
307 " dspr2"
308 # endif
309 
310 // -- POWER, PowerPC --
311 #ifdef __ALTIVEC__
312 " altivec"
313 #endif
314 #ifdef __SPE__
315 " spe"
316 #endif
317 #ifdef __VSX__
318 " vsx"
319 #endif
320  "";
321 
322 extern const char msg3[];
323 const char msg3[] = "==Qt=magic=Qt== Build-ABI:" ARCH_FULL;
324 
325 int main()
326 {
327  puts(msg);
328  puts(msg2);
329  puts(msg3);
330 }
const char msg3[]
Definition: arch.cpp:323
const char msg2[]
Definition: arch.cpp:49
const char msg[]
Definition: arch.cpp:46
int main()
Definition: arch.cpp:325
#define ARCH_PROCESSOR
Definition: archdetect.cpp:87
#define ARCH_FULL
Definition: archdetect.cpp:142