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"
26 // FMA instructions are not available
27 #include "generic/FMA.h"
28 #include "src/__support/CPP/type_traits.h"
30 namespace __llvm_libc
{
33 template <typename T
> LIBC_INLINE T
fma(T x
, T y
, T z
) {
34 return generic::fma(x
, y
, z
);
38 } // namespace __llvm_libc
42 #endif // LLVM_LIBC_SRC_SUPPORT_FPUTIL_FMA_H