Files
clang-p2996/libc/utils/FPUtil/FMA.h
Siva Chandra 95934c3a37 [libc] Add hardware implementations of fma and fmaf for x86_64 and aarch64.
The current generic implementation of the fmaf function has been moved
to the FPUtil directory. This allows one use the fma operation from
implementations of other math functions like the trignometric functions
without depending on/requiring the fma/fmaf/fmal function targets. If
this pattern ends being convenient, we will switch all generic math
implementations to this pattern.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D100811
2021-04-21 04:31:27 +00:00

38 lines
1.1 KiB
C++

//===-- Common header for FMA implementations -------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_UTILS_FPUTIL_FMA_H
#define LLVM_LIBC_UTILS_FPUTIL_FMA_H
#include "utils/CPP/TypeTraits.h"
#ifdef __x86_64__
#include "x86_64/FMA.h"
#elif defined(__aarch64__)
#include "aarch64/FMA.h"
#else
#include "generic/FMA.h"
namespace __llvm_libc {
namespace fputil {
// We have a generic implementation available only for single precision fma os
// we restrict it to float values for now.
template <typename T>
static inline cpp::EnableIfType<cpp::IsSame<T, float>::Value, T> fma(T x, T y,
T z) {
return generic::fma(x, y, z);
}
} // namespace fputil
} // namespace __llvm_libc
#endif
#endif // LLVM_LIBC_UTILS_FPUTIL_FMA_H