[libc][NFC] Move aligned access implementations to separate header
[llvm-project.git] / libc / src / __support / FPUtil / FMA.h
blob178d34fd73f14df4cf9f5ba7cc92e55ceb9047c4
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 //===----------------------------------------------------------------------===//
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)
24 #include "gpu/FMA.h"
25 #endif
27 #else
28 // FMA instructions are not available
29 #include "generic/FMA.h"
30 #include "src/__support/CPP/type_traits.h"
32 namespace __llvm_libc {
33 namespace fputil {
35 template <typename T> LIBC_INLINE T fma(T x, T y, T z) {
36 return generic::fma(x, y, z);
39 } // namespace fputil
40 } // namespace __llvm_libc
42 #endif
44 #endif // LLVM_LIBC_SRC_SUPPORT_FPUTIL_FMA_H