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_UTILS_FPUTIL_FMA_H 10 #define LLVM_LIBC_UTILS_FPUTIL_FMA_H 11 12 #include "utils/CPP/TypeTraits.h" 13 14 #ifdef __x86_64__ 15 #include "x86_64/FMA.h" 16 #elif defined(__aarch64__) 17 #include "aarch64/FMA.h" 18 #else 19 #include "generic/FMA.h" 20 21 namespace __llvm_libc { 22 namespace fputil { 23 24 // We have a generic implementation available only for single precision fma os 25 // we restrict it to float values for now. 26 template <typename T> fma(T x,T y,T z)27static inline cpp::EnableIfType<cpp::IsSame<T, float>::Value, T> fma(T x, T y, 28 T z) { 29 return generic::fma(x, y, z); 30 } 31 32 } // namespace fputil 33 } // namespace __llvm_libc 34 35 #endif 36 37 #endif // LLVM_LIBC_UTILS_FPUTIL_FMA_H 38