For `LDBL_MANT_DIG == 113` targets the FortranFloat128Math library is just an interface library that provides sources and compilation options to be used for building FortranRuntime - there are not extra dependencies on other libraries, so it can be a part of FortranRuntime, which helps to avoid extra linking steps in the compiler driver. Targets with __float128 support in libc will also use this path. Other targets, where the math support comes from FLANG_RUNTIME_F128_MATH_LIB, FortranFloat128Math is built as a standalone static library, and the compiler driver needs to conduct the linking. Flang APIs for COMPLEX(16) are just thin C wrappers around the C math functions. Flang uses C _Complex ABI for passing/returning COMPLEX values, so the runtime is aligned to this.
24 lines
744 B
C++
24 lines
744 B
C++
//===-- runtime/Float128Math/nearest.cpp ----------------------------------===//
|
|
//
|
|
// 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "math-entries.h"
|
|
|
|
namespace Fortran::runtime {
|
|
extern "C" {
|
|
|
|
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
|
|
CppTypeFor<TypeCategory::Real, 16> RTDEF(Nearest16)(
|
|
CppTypeFor<TypeCategory::Real, 16> x, bool positive) {
|
|
return Nextafter<true>::invoke(
|
|
x, positive ? F128_RT_INFINITY : -F128_RT_INFINITY);
|
|
}
|
|
#endif
|
|
|
|
} // extern "C"
|
|
} // namespace Fortran::runtime
|