[flang][runtime] Added lowering and runtime for REAL(16) IEEE_FMA. (#85017)
This commit is contained in:
parent
286c3b500d
commit
d24ff9aec4
@ -922,6 +922,8 @@ mlir::Value genComplexMathOp(fir::FirOpBuilder &builder, mlir::Location loc,
|
||||
constexpr auto FuncTypeReal16Real16 = genFuncType<Ty::Real<16>, Ty::Real<16>>;
|
||||
constexpr auto FuncTypeReal16Real16Real16 =
|
||||
genFuncType<Ty::Real<16>, Ty::Real<16>, Ty::Real<16>>;
|
||||
constexpr auto FuncTypeReal16Real16Real16Real16 =
|
||||
genFuncType<Ty::Real<16>, Ty::Real<16>, Ty::Real<16>, Ty::Real<16>>;
|
||||
constexpr auto FuncTypeReal16Integer4Real16 =
|
||||
genFuncType<Ty::Real<16>, Ty::Integer<4>, Ty::Real<16>>;
|
||||
constexpr auto FuncTypeInteger4Real16 =
|
||||
@ -1143,6 +1145,8 @@ static constexpr MathOperation mathOperations[] = {
|
||||
{"fma", "llvm.fma.f64",
|
||||
genFuncType<Ty::Real<8>, Ty::Real<8>, Ty::Real<8>, Ty::Real<8>>,
|
||||
genMathOp<mlir::math::FmaOp>},
|
||||
{"fma", RTNAME_STRING(FmaF128), FuncTypeReal16Real16Real16Real16,
|
||||
genLibF128Call},
|
||||
{"gamma", "tgammaf", genFuncType<Ty::Real<4>, Ty::Real<4>>, genLibCall},
|
||||
{"gamma", "tgamma", genFuncType<Ty::Real<8>, Ty::Real<8>>, genLibCall},
|
||||
{"gamma", RTNAME_STRING(TgammaF128), FuncTypeReal16Real16, genLibF128Call},
|
||||
|
@ -33,6 +33,7 @@ set(sources
|
||||
exp.cpp
|
||||
exponent.cpp
|
||||
floor.cpp
|
||||
fma.cpp
|
||||
fraction.cpp
|
||||
hypot.cpp
|
||||
j0.cpp
|
||||
|
23
flang/runtime/Float128Math/fma.cpp
Normal file
23
flang/runtime/Float128Math/fma.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
//===-- runtime/Float128Math/fma.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(FmaF128)(
|
||||
CppTypeFor<TypeCategory::Real, 16> x, CppTypeFor<TypeCategory::Real, 16> y,
|
||||
CppTypeFor<TypeCategory::Real, 16> z) {
|
||||
return Fma<true>::invoke(x, y, z);
|
||||
}
|
||||
#endif
|
||||
|
||||
} // extern "C"
|
||||
} // namespace Fortran::runtime
|
@ -77,6 +77,7 @@ DEFINE_FALLBACK_F128(Erf)
|
||||
DEFINE_FALLBACK_F128(Erfc)
|
||||
DEFINE_FALLBACK_F128(Exp)
|
||||
DEFINE_FALLBACK_F128(Floor)
|
||||
DEFINE_FALLBACK_F128(Fma)
|
||||
DEFINE_FALLBACK_F128(Frexp)
|
||||
DEFINE_FALLBACK_F128(Hypot)
|
||||
DEFINE_FALLBACK_I32(Ilogb)
|
||||
@ -124,6 +125,7 @@ DEFINE_SIMPLE_ALIAS(Erf, erfq)
|
||||
DEFINE_SIMPLE_ALIAS(Erfc, erfcq)
|
||||
DEFINE_SIMPLE_ALIAS(Exp, expq)
|
||||
DEFINE_SIMPLE_ALIAS(Floor, floorq)
|
||||
DEFINE_SIMPLE_ALIAS(Fma, fmaq)
|
||||
DEFINE_SIMPLE_ALIAS(Frexp, frexpq)
|
||||
DEFINE_SIMPLE_ALIAS(Hypot, hypotq)
|
||||
DEFINE_SIMPLE_ALIAS(Ilogb, ilogbq)
|
||||
@ -177,6 +179,7 @@ DEFINE_SIMPLE_ALIAS(Erf, std::erf)
|
||||
DEFINE_SIMPLE_ALIAS(Erfc, std::erfc)
|
||||
DEFINE_SIMPLE_ALIAS(Exp, std::exp)
|
||||
DEFINE_SIMPLE_ALIAS(Floor, std::floor)
|
||||
DEFINE_SIMPLE_ALIAS(Fma, std::fma)
|
||||
DEFINE_SIMPLE_ALIAS(Frexp, std::frexp)
|
||||
DEFINE_SIMPLE_ALIAS(Hypot, std::hypot)
|
||||
DEFINE_SIMPLE_ALIAS(Ilogb, std::ilogb)
|
||||
|
9
flang/test/Lower/Intrinsics/fma_real16.f90
Normal file
9
flang/test/Lower/Intrinsics/fma_real16.f90
Normal file
@ -0,0 +1,9 @@
|
||||
! RUN: bbc -emit-fir %s -o - | FileCheck %s
|
||||
! RUN: bbc --math-runtime=precise -emit-fir %s -o - | FileCheck %s
|
||||
! RUN: %flang_fc1 -emit-fir %s -o - | FileCheck %s
|
||||
|
||||
! CHECK: fir.call @_FortranAFmaF128({{.*}}){{.*}}: (f128, f128, f128) -> f128
|
||||
use ieee_arithmetic, only: ieee_fma
|
||||
real(16) :: x, y, z
|
||||
x = ieee_fma(x, y, z)
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user