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(__ARM_FEATURE_FP16_SCALAR_ARITHMETIC) 18 #define LIBC_TARGET_CPU_HAS_FULLFP16 19 #endif 20 21 #if defined(__SSE2__) 22 #define LIBC_TARGET_CPU_HAS_SSE2 23 #endif 24 25 #if defined(__SSE4_2__) 26 #define LIBC_TARGET_CPU_HAS_SSE4_2 27 #endif 28 29 #if defined(__AVX__) 30 #define LIBC_TARGET_CPU_HAS_AVX 31 #endif 32 33 #if defined(__AVX2__) 34 #define LIBC_TARGET_CPU_HAS_AVX2 35 #endif 36 37 #if defined(__AVX512F__) 38 #define LIBC_TARGET_CPU_HAS_AVX512F 39 #endif 40 41 #if defined(__AVX512BW__) 42 #define LIBC_TARGET_CPU_HAS_AVX512BW 43 #endif 44 45 #if defined(__ARM_FEATURE_FMA) || (defined(__AVX2__) && defined(__FMA__)) || \ 46 defined(__NVPTX__) || defined(__AMDGPU__) || defined(__LIBC_RISCV_USE_FMA) 47 #define LIBC_TARGET_CPU_HAS_FMA 48 #endif 49 50 #if defined(LIBC_TARGET_ARCH_IS_AARCH64) || \ 51 (defined(LIBC_TARGET_ARCH_IS_X86_64) && \ 52 defined(LIBC_TARGET_CPU_HAS_SSE4_2)) 53 #define LIBC_TARGET_CPU_HAS_NEAREST_INT 54 #endif 55 56 #if defined(LIBC_TARGET_ARCH_IS_AARCH64) || defined(LIBC_TARGET_ARCH_IS_GPU) 57 #define LIBC_TARGET_CPU_HAS_FAST_FLOAT16_OPS 58 #endif 59 60 #endif // LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_CPU_FEATURES_H 61