1 | //===-- Compile time cpu feature detection ----------------------*- C++ -*-===// |
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | // This file lists target cpu features by introspecting compiler enabled |
9 | // preprocessor definitions. |
10 | //===----------------------------------------------------------------------===// |
11 | |
12 | #ifndef LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_CPU_FEATURES_H |
13 | #define LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_CPU_FEATURES_H |
14 | |
15 | #include "architectures.h" |
16 | |
17 | #if defined(__SSE2__) |
18 | #define LIBC_TARGET_CPU_HAS_SSE2 |
19 | #endif |
20 | |
21 | #if defined(__SSE4_2__) |
22 | #define LIBC_TARGET_CPU_HAS_SSE4_2 |
23 | #endif |
24 | |
25 | #if defined(__AVX__) |
26 | #define LIBC_TARGET_CPU_HAS_AVX |
27 | #endif |
28 | |
29 | #if defined(__AVX2__) |
30 | #define LIBC_TARGET_CPU_HAS_AVX2 |
31 | #endif |
32 | |
33 | #if defined(__AVX512F__) |
34 | #define LIBC_TARGET_CPU_HAS_AVX512F |
35 | #endif |
36 | |
37 | #if defined(__AVX512BW__) |
38 | #define LIBC_TARGET_CPU_HAS_AVX512BW |
39 | #endif |
40 | |
41 | #if defined(__ARM_FEATURE_FMA) || (defined(__AVX2__) && defined(__FMA__)) || \ |
42 | defined(__NVPTX__) || defined(__AMDGPU__) || defined(__LIBC_RISCV_USE_FMA) |
43 | #define LIBC_TARGET_CPU_HAS_FMA |
44 | #endif |
45 | |
46 | #if defined(LIBC_TARGET_ARCH_IS_AARCH64) || \ |
47 | (defined(LIBC_TARGET_ARCH_IS_X86_64) && \ |
48 | defined(LIBC_TARGET_CPU_HAS_SSE4_2)) |
49 | #define LIBC_TARGET_CPU_HAS_NEAREST_INT |
50 | #endif |
51 | |
52 | #endif // LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_CPU_FEATURES_H |
53 | |