1 | //===-- Common header for FMA implementations -------------------*- 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 | |
9 | #ifndef LLVM_LIBC_SRC___SUPPORT_FPUTIL_FMA_H |
10 | #define LLVM_LIBC_SRC___SUPPORT_FPUTIL_FMA_H |
11 | |
12 | #include "src/__support/macros/properties/architectures.h" |
13 | #include "src/__support/macros/properties/cpu_features.h" // LIBC_TARGET_CPU_HAS_FMA |
14 | |
15 | #if defined(LIBC_TARGET_CPU_HAS_FMA) |
16 | |
17 | #if defined(LIBC_TARGET_ARCH_IS_X86_64) |
18 | #include "x86_64/FMA.h" |
19 | #elif defined(LIBC_TARGET_ARCH_IS_AARCH64) |
20 | #include "aarch64/FMA.h" |
21 | #elif defined(LIBC_TARGET_ARCH_IS_ANY_RISCV) |
22 | #include "riscv/FMA.h" |
23 | #elif defined(LIBC_TARGET_ARCH_IS_GPU) |
24 | #include "gpu/FMA.h" |
25 | #endif |
26 | |
27 | #else |
28 | // FMA instructions are not available |
29 | #include "generic/FMA.h" |
30 | #include "src/__support/CPP/type_traits.h" |
31 | |
32 | namespace LIBC_NAMESPACE { |
33 | namespace fputil { |
34 | |
35 | template <typename T> LIBC_INLINE T fma(T x, T y, T z) { |
36 | return generic::fma(x, y, z); |
37 | } |
38 | |
39 | } // namespace fputil |
40 | } // namespace LIBC_NAMESPACE |
41 | |
42 | #endif |
43 | |
44 | #endif // LLVM_LIBC_SRC___SUPPORT_FPUTIL_FMA_H |
45 | |