Files
clang-p2996/flang/runtime/Float128Math/complex-math.c
Slava Zakharin 50d848d076 [flang] Added lowering and runtime for COMPLEX(16) intrinsics. (#83874)
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.
2024-03-05 13:36:48 -08:00

56 lines
1.9 KiB
C

/*===-- runtime/Float128Math/complex-math.c -------------------------*- 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
*
* ===-----------------------------------------------------------------------===
*/
#include "complex-math.h"
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
CFloat128Type RTDEF(CAbsF128)(CFloat128ComplexType x) { return CAbs(x); }
CFloat128ComplexType RTDEF(CAcosF128)(CFloat128ComplexType x) {
return CAcos(x);
}
CFloat128ComplexType RTDEF(CAcoshF128)(CFloat128ComplexType x) {
return CAcosh(x);
}
CFloat128ComplexType RTDEF(CAsinF128)(CFloat128ComplexType x) {
return CAsin(x);
}
CFloat128ComplexType RTDEF(CAsinhF128)(CFloat128ComplexType x) {
return CAsinh(x);
}
CFloat128ComplexType RTDEF(CAtanF128)(CFloat128ComplexType x) {
return CAtan(x);
}
CFloat128ComplexType RTDEF(CAtanhF128)(CFloat128ComplexType x) {
return CAtanh(x);
}
CFloat128ComplexType RTDEF(CCosF128)(CFloat128ComplexType x) { return CCos(x); }
CFloat128ComplexType RTDEF(CCoshF128)(CFloat128ComplexType x) {
return CCosh(x);
}
CFloat128ComplexType RTDEF(CExpF128)(CFloat128ComplexType x) { return CExp(x); }
CFloat128ComplexType RTDEF(CLogF128)(CFloat128ComplexType x) { return CLog(x); }
CFloat128ComplexType RTDEF(CPowF128)(
CFloat128ComplexType x, CFloat128ComplexType p) {
return CPow(x, p);
}
CFloat128ComplexType RTDEF(CSinF128)(CFloat128ComplexType x) { return CSin(x); }
CFloat128ComplexType RTDEF(CSinhF128)(CFloat128ComplexType x) {
return CSinh(x);
}
CFloat128ComplexType RTDEF(CSqrtF128)(CFloat128ComplexType x) {
return CSqrt(x);
}
CFloat128ComplexType RTDEF(CTanF128)(CFloat128ComplexType x) { return CTan(x); }
CFloat128ComplexType RTDEF(CTanhF128)(CFloat128ComplexType x) {
return CTanh(x);
}
#endif // LDBL_MANT_DIG == 113 || HAS_FLOAT128