Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-03 08:13:33

0001 //===----------------------------------------------------------------------===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef _LIBCPP___CXX03___MATH_FMA_H
0010 #define _LIBCPP___CXX03___MATH_FMA_H
0011 
0012 #include <__cxx03/__config>
0013 #include <__cxx03/__type_traits/enable_if.h>
0014 #include <__cxx03/__type_traits/is_arithmetic.h>
0015 #include <__cxx03/__type_traits/is_same.h>
0016 #include <__cxx03/__type_traits/promote.h>
0017 
0018 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0019 #  pragma GCC system_header
0020 #endif
0021 
0022 _LIBCPP_BEGIN_NAMESPACE_STD
0023 
0024 namespace __math {
0025 
0026 inline _LIBCPP_HIDE_FROM_ABI float fma(float __x, float __y, float __z) _NOEXCEPT {
0027   return __builtin_fmaf(__x, __y, __z);
0028 }
0029 
0030 template <class = int>
0031 _LIBCPP_HIDE_FROM_ABI double fma(double __x, double __y, double __z) _NOEXCEPT {
0032   return __builtin_fma(__x, __y, __z);
0033 }
0034 
0035 inline _LIBCPP_HIDE_FROM_ABI long double fma(long double __x, long double __y, long double __z) _NOEXCEPT {
0036   return __builtin_fmal(__x, __y, __z);
0037 }
0038 
0039 template <class _A1,
0040           class _A2,
0041           class _A3,
0042           __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value && is_arithmetic<_A3>::value, int> = 0>
0043 inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2, _A3>::type fma(_A1 __x, _A2 __y, _A3 __z) _NOEXCEPT {
0044   using __result_type = typename __promote<_A1, _A2, _A3>::type;
0045   static_assert(
0046       !(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value && _IsSame<_A3, __result_type>::value),
0047       "");
0048   return __builtin_fma((__result_type)__x, (__result_type)__y, (__result_type)__z);
0049 }
0050 
0051 } // namespace __math
0052 
0053 _LIBCPP_END_NAMESPACE_STD
0054 
0055 #endif // _LIBCPP___CXX03___MATH_FMA_H