1 //===-- Common header for FMA implementations -------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_LIBC_SRC_SUPPORT_FPUTIL_FMA_H
10 #define LLVM_LIBC_SRC_SUPPORT_FPUTIL_FMA_H
12 #include "src/__support/macros/properties/architectures.h"
13 #include "src/__support/macros/properties/cpu_features.h" // LIBC_TARGET_CPU_HAS_FMA
15 #if defined(LIBC_TARGET_CPU_HAS_FMA)
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_RISCV64)
22 #include "riscv64/FMA.h"
23 #elif defined(LIBC_TARGET_ARCH_IS_GPU)
28 // FMA instructions are not available
29 #include "generic/FMA.h"
30 #include "src/__support/CPP/type_traits.h"
32 namespace __llvm_libc
{
35 template <typename T
> LIBC_INLINE T
fma(T x
, T y
, T z
) {
36 return generic::fma(x
, y
, z
);
40 } // namespace __llvm_libc
44 #endif // LLVM_LIBC_SRC_SUPPORT_FPUTIL_FMA_H