@@ -916,6 +916,16 @@ mlir::Value genComplexMathOp(fir::FirOpBuilder &builder, mlir::Location loc,
916916// / See https://gcc.gnu.org/onlinedocs/gcc-12.1.0/gfortran/\
917917/// Intrinsic-Procedures.html for a reference.
918918constexpr auto FuncTypeReal16Real16 = genFuncType<Ty::Real<16 >, Ty::Real<16 >>;
919+ constexpr auto FuncTypeReal16Real16Real16 =
920+ genFuncType<Ty::Real<16 >, Ty::Real<16 >, Ty::Real<16 >>;
921+ constexpr auto FuncTypeReal16Integer4Real16 =
922+ genFuncType<Ty::Real<16 >, Ty::Integer<4 >, Ty::Real<16 >>;
923+ constexpr auto FuncTypeReal16Integer8Real16 =
924+ genFuncType<Ty::Real<16 >, Ty::Integer<8 >, Ty::Real<16 >>;
925+ constexpr auto FuncTypeInteger4Real16 =
926+ genFuncType<Ty::Integer<4 >, Ty::Real<16 >>;
927+ constexpr auto FuncTypeInteger8Real16 =
928+ genFuncType<Ty::Integer<8 >, Ty::Real<16 >>;
919929constexpr auto FuncTypeReal16Complex16 =
920930 genFuncType<Ty::Real<16 >, Ty::Complex<16 >>;
921931
@@ -933,10 +943,12 @@ static constexpr MathOperation mathOperations[] = {
933943 {" abs" , RTNAME_STRING (CAbsF128), FuncTypeReal16Complex16, genLibF128Call},
934944 {" acos" , " acosf" , genFuncType<Ty::Real<4 >, Ty::Real<4 >>, genLibCall},
935945 {" acos" , " acos" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>, genLibCall},
946+ {" acos" , RTNAME_STRING (AcosF128), FuncTypeReal16Real16, genLibF128Call},
936947 {" acos" , " cacosf" , genFuncType<Ty::Complex<4 >, Ty::Complex<4 >>, genLibCall},
937948 {" acos" , " cacos" , genFuncType<Ty::Complex<8 >, Ty::Complex<8 >>, genLibCall},
938949 {" acosh" , " acoshf" , genFuncType<Ty::Real<4 >, Ty::Real<4 >>, genLibCall},
939950 {" acosh" , " acosh" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>, genLibCall},
951+ {" acosh" , RTNAME_STRING (AcoshF128), FuncTypeReal16Real16, genLibF128Call},
940952 {" acosh" , " cacoshf" , genFuncType<Ty::Complex<4 >, Ty::Complex<4 >>,
941953 genLibCall},
942954 {" acosh" , " cacosh" , genFuncType<Ty::Complex<8 >, Ty::Complex<8 >>,
@@ -948,19 +960,23 @@ static constexpr MathOperation mathOperations[] = {
948960 genLibCall},
949961 {" aint" , " llvm.trunc.f80" , genFuncType<Ty::Real<10 >, Ty::Real<10 >>,
950962 genLibCall},
963+ {" aint" , RTNAME_STRING (TruncF128), FuncTypeReal16Real16, genLibF128Call},
951964 // llvm.round behaves the same way as libm's round.
952965 {" anint" , " llvm.round.f32" , genFuncType<Ty::Real<4 >, Ty::Real<4 >>,
953966 genMathOp<mlir::LLVM::RoundOp>},
954967 {" anint" , " llvm.round.f64" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>,
955968 genMathOp<mlir::LLVM::RoundOp>},
956969 {" anint" , " llvm.round.f80" , genFuncType<Ty::Real<10 >, Ty::Real<10 >>,
957970 genMathOp<mlir::LLVM::RoundOp>},
971+ {" anint" , RTNAME_STRING (RoundF128), FuncTypeReal16Real16, genLibF128Call},
958972 {" asin" , " asinf" , genFuncType<Ty::Real<4 >, Ty::Real<4 >>, genLibCall},
959973 {" asin" , " asin" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>, genLibCall},
974+ {" asin" , RTNAME_STRING (AsinF128), FuncTypeReal16Real16, genLibF128Call},
960975 {" asin" , " casinf" , genFuncType<Ty::Complex<4 >, Ty::Complex<4 >>, genLibCall},
961976 {" asin" , " casin" , genFuncType<Ty::Complex<8 >, Ty::Complex<8 >>, genLibCall},
962977 {" asinh" , " asinhf" , genFuncType<Ty::Real<4 >, Ty::Real<4 >>, genLibCall},
963978 {" asinh" , " asinh" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>, genLibCall},
979+ {" asinh" , RTNAME_STRING (AsinhF128), FuncTypeReal16Real16, genLibF128Call},
964980 {" asinh" , " casinhf" , genFuncType<Ty::Complex<4 >, Ty::Complex<4 >>,
965981 genLibCall},
966982 {" asinh" , " casinh" , genFuncType<Ty::Complex<8 >, Ty::Complex<8 >>,
@@ -969,49 +985,64 @@ static constexpr MathOperation mathOperations[] = {
969985 genMathOp<mlir::math::AtanOp>},
970986 {" atan" , " atan" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>,
971987 genMathOp<mlir::math::AtanOp>},
988+ {" atan" , RTNAME_STRING (AtanF128), FuncTypeReal16Real16, genLibF128Call},
972989 {" atan" , " catanf" , genFuncType<Ty::Complex<4 >, Ty::Complex<4 >>, genLibCall},
973990 {" atan" , " catan" , genFuncType<Ty::Complex<8 >, Ty::Complex<8 >>, genLibCall},
974991 {" atan2" , " atan2f" , genFuncType<Ty::Real<4 >, Ty::Real<4 >, Ty::Real<4 >>,
975992 genMathOp<mlir::math::Atan2Op>},
976993 {" atan2" , " atan2" , genFuncType<Ty::Real<8 >, Ty::Real<8 >, Ty::Real<8 >>,
977994 genMathOp<mlir::math::Atan2Op>},
995+ {" atan2" , RTNAME_STRING (Atan2F128), FuncTypeReal16Real16Real16,
996+ genLibF128Call},
978997 {" atanh" , " atanhf" , genFuncType<Ty::Real<4 >, Ty::Real<4 >>, genLibCall},
979998 {" atanh" , " atanh" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>, genLibCall},
999+ {" atanh" , RTNAME_STRING (AtanhF128), FuncTypeReal16Real16, genLibF128Call},
9801000 {" atanh" , " catanhf" , genFuncType<Ty::Complex<4 >, Ty::Complex<4 >>,
9811001 genLibCall},
9821002 {" atanh" , " catanh" , genFuncType<Ty::Complex<8 >, Ty::Complex<8 >>,
9831003 genLibCall},
9841004 {" bessel_j0" , " j0f" , genFuncType<Ty::Real<4 >, Ty::Real<4 >>, genLibCall},
9851005 {" bessel_j0" , " j0" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>, genLibCall},
1006+ {" bessel_j0" , RTNAME_STRING (J0F128), FuncTypeReal16Real16, genLibF128Call},
9861007 {" bessel_j1" , " j1f" , genFuncType<Ty::Real<4 >, Ty::Real<4 >>, genLibCall},
9871008 {" bessel_j1" , " j1" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>, genLibCall},
1009+ {" bessel_j1" , RTNAME_STRING (J1F128), FuncTypeReal16Real16, genLibF128Call},
9881010 {" bessel_jn" , " jnf" , genFuncType<Ty::Real<4 >, Ty::Integer<4 >, Ty::Real<4 >>,
9891011 genLibCall},
9901012 {" bessel_jn" , " jn" , genFuncType<Ty::Real<8 >, Ty::Integer<4 >, Ty::Real<8 >>,
9911013 genLibCall},
1014+ {" bessel_jn" , RTNAME_STRING (JnF128), FuncTypeReal16Integer4Real16,
1015+ genLibF128Call},
9921016 {" bessel_y0" , " y0f" , genFuncType<Ty::Real<4 >, Ty::Real<4 >>, genLibCall},
9931017 {" bessel_y0" , " y0" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>, genLibCall},
1018+ {" bessel_y0" , RTNAME_STRING (Y0F128), FuncTypeReal16Real16, genLibF128Call},
9941019 {" bessel_y1" , " y1f" , genFuncType<Ty::Real<4 >, Ty::Real<4 >>, genLibCall},
9951020 {" bessel_y1" , " y1" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>, genLibCall},
1021+ {" bessel_y1" , RTNAME_STRING (Y1F128), FuncTypeReal16Real16, genLibF128Call},
9961022 {" bessel_yn" , " ynf" , genFuncType<Ty::Real<4 >, Ty::Integer<4 >, Ty::Real<4 >>,
9971023 genLibCall},
9981024 {" bessel_yn" , " yn" , genFuncType<Ty::Real<8 >, Ty::Integer<4 >, Ty::Real<8 >>,
9991025 genLibCall},
1026+ {" bessel_yn" , RTNAME_STRING (YnF128), FuncTypeReal16Integer4Real16,
1027+ genLibF128Call},
10001028 // math::CeilOp returns a real, while Fortran CEILING returns integer.
10011029 {" ceil" , " ceilf" , genFuncType<Ty::Real<4 >, Ty::Real<4 >>,
10021030 genMathOp<mlir::math::CeilOp>},
10031031 {" ceil" , " ceil" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>,
10041032 genMathOp<mlir::math::CeilOp>},
1033+ {" ceil" , RTNAME_STRING (CeilF128), FuncTypeReal16Real16, genLibF128Call},
10051034 {" cos" , " cosf" , genFuncType<Ty::Real<4 >, Ty::Real<4 >>,
10061035 genMathOp<mlir::math::CosOp>},
10071036 {" cos" , " cos" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>,
10081037 genMathOp<mlir::math::CosOp>},
1038+ {" cos" , RTNAME_STRING (CosF128), FuncTypeReal16Real16, genLibF128Call},
10091039 {" cos" , " ccosf" , genFuncType<Ty::Complex<4 >, Ty::Complex<4 >>,
10101040 genComplexMathOp<mlir::complex ::CosOp>},
10111041 {" cos" , " ccos" , genFuncType<Ty::Complex<8 >, Ty::Complex<8 >>,
10121042 genComplexMathOp<mlir::complex ::CosOp>},
10131043 {" cosh" , " coshf" , genFuncType<Ty::Real<4 >, Ty::Real<4 >>, genLibCall},
10141044 {" cosh" , " cosh" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>, genLibCall},
1045+ {" cosh" , RTNAME_STRING (CoshF128), FuncTypeReal16Real16, genLibF128Call},
10151046 {" cosh" , " ccoshf" , genFuncType<Ty::Complex<4 >, Ty::Complex<4 >>, genLibCall},
10161047 {" cosh" , " ccosh" , genFuncType<Ty::Complex<8 >, Ty::Complex<8 >>, genLibCall},
10171048 {" divc" ,
@@ -1038,12 +1069,15 @@ static constexpr MathOperation mathOperations[] = {
10381069 genMathOp<mlir::math::ErfOp>},
10391070 {" erf" , " erf" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>,
10401071 genMathOp<mlir::math::ErfOp>},
1072+ {" erf" , RTNAME_STRING (ErfF128), FuncTypeReal16Real16, genLibF128Call},
10411073 {" erfc" , " erfcf" , genFuncType<Ty::Real<4 >, Ty::Real<4 >>, genLibCall},
10421074 {" erfc" , " erfc" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>, genLibCall},
1075+ {" erfc" , RTNAME_STRING (ErfcF128), FuncTypeReal16Real16, genLibF128Call},
10431076 {" exp" , " expf" , genFuncType<Ty::Real<4 >, Ty::Real<4 >>,
10441077 genMathOp<mlir::math::ExpOp>},
10451078 {" exp" , " exp" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>,
10461079 genMathOp<mlir::math::ExpOp>},
1080+ {" exp" , RTNAME_STRING (ExpF128), FuncTypeReal16Real16, genLibF128Call},
10471081 {" exp" , " cexpf" , genFuncType<Ty::Complex<4 >, Ty::Complex<4 >>,
10481082 genComplexMathOp<mlir::complex ::ExpOp>},
10491083 {" exp" , " cexp" , genFuncType<Ty::Complex<8 >, Ty::Complex<8 >>,
@@ -1074,6 +1108,7 @@ static constexpr MathOperation mathOperations[] = {
10741108 genMathOp<mlir::math::FloorOp>},
10751109 {" floor" , " floor" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>,
10761110 genMathOp<mlir::math::FloorOp>},
1111+ {" floor" , RTNAME_STRING (FloorF128), FuncTypeReal16Real16, genLibF128Call},
10771112 {" fma" , " llvm.fma.f32" ,
10781113 genFuncType<Ty::Real<4 >, Ty::Real<4 >, Ty::Real<4 >, Ty::Real<4 >>,
10791114 genMathOp<mlir::math::FmaOp>},
@@ -1082,14 +1117,18 @@ static constexpr MathOperation mathOperations[] = {
10821117 genMathOp<mlir::math::FmaOp>},
10831118 {" gamma" , " tgammaf" , genFuncType<Ty::Real<4 >, Ty::Real<4 >>, genLibCall},
10841119 {" gamma" , " tgamma" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>, genLibCall},
1120+ {" gamma" , RTNAME_STRING (TgammaF128), FuncTypeReal16Real16, genLibF128Call},
10851121 {" hypot" , " hypotf" , genFuncType<Ty::Real<4 >, Ty::Real<4 >, Ty::Real<4 >>,
10861122 genLibCall},
10871123 {" hypot" , " hypot" , genFuncType<Ty::Real<8 >, Ty::Real<8 >, Ty::Real<8 >>,
10881124 genLibCall},
1125+ {" hypot" , RTNAME_STRING (HypotF128), FuncTypeReal16Real16Real16,
1126+ genLibF128Call},
10891127 {" log" , " logf" , genFuncType<Ty::Real<4 >, Ty::Real<4 >>,
10901128 genMathOp<mlir::math::LogOp>},
10911129 {" log" , " log" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>,
10921130 genMathOp<mlir::math::LogOp>},
1131+ {" log" , RTNAME_STRING (LogF128), FuncTypeReal16Real16, genLibF128Call},
10931132 {" log" , " clogf" , genFuncType<Ty::Complex<4 >, Ty::Complex<4 >>,
10941133 genComplexMathOp<mlir::complex ::LogOp>},
10951134 {" log" , " clog" , genFuncType<Ty::Complex<8 >, Ty::Complex<8 >>,
@@ -1098,17 +1137,23 @@ static constexpr MathOperation mathOperations[] = {
10981137 genMathOp<mlir::math::Log10Op>},
10991138 {" log10" , " log10" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>,
11001139 genMathOp<mlir::math::Log10Op>},
1140+ {" log10" , RTNAME_STRING (Log10F128), FuncTypeReal16Real16, genLibF128Call},
11011141 {" log_gamma" , " lgammaf" , genFuncType<Ty::Real<4 >, Ty::Real<4 >>, genLibCall},
11021142 {" log_gamma" , " lgamma" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>, genLibCall},
1143+ {" log_gamma" , RTNAME_STRING (LgammaF128), FuncTypeReal16Real16,
1144+ genLibF128Call},
11031145 // llvm.lround behaves the same way as libm's lround.
11041146 {" nint" , " llvm.lround.i64.f64" , genFuncType<Ty::Integer<8 >, Ty::Real<8 >>,
11051147 genLibCall},
11061148 {" nint" , " llvm.lround.i64.f32" , genFuncType<Ty::Integer<8 >, Ty::Real<4 >>,
11071149 genLibCall},
1150+ {" nint" , RTNAME_STRING (LlroundF128), FuncTypeInteger8Real16,
1151+ genLibF128Call},
11081152 {" nint" , " llvm.lround.i32.f64" , genFuncType<Ty::Integer<4 >, Ty::Real<8 >>,
11091153 genLibCall},
11101154 {" nint" , " llvm.lround.i32.f32" , genFuncType<Ty::Integer<4 >, Ty::Real<4 >>,
11111155 genLibCall},
1156+ {" nint" , RTNAME_STRING (LroundF128), FuncTypeInteger4Real16, genLibF128Call},
11121157 {" pow" ,
11131158 {},
11141159 genFuncType<Ty::Integer<1 >, Ty::Integer<1 >, Ty::Integer<1 >>,
@@ -1129,6 +1174,7 @@ static constexpr MathOperation mathOperations[] = {
11291174 genMathOp<mlir::math::PowFOp>},
11301175 {" pow" , " pow" , genFuncType<Ty::Real<8 >, Ty::Real<8 >, Ty::Real<8 >>,
11311176 genMathOp<mlir::math::PowFOp>},
1177+ {" pow" , RTNAME_STRING (PowF128), FuncTypeReal16Real16Real16, genLibF128Call},
11321178 {" pow" , " cpowf" ,
11331179 genFuncType<Ty::Complex<4 >, Ty::Complex<4 >, Ty::Complex<4 >>,
11341180 genComplexMathOp<mlir::complex ::PowOp>},
@@ -1140,12 +1186,18 @@ static constexpr MathOperation mathOperations[] = {
11401186 {" pow" , RTNAME_STRING (FPow8i),
11411187 genFuncType<Ty::Real<8 >, Ty::Real<8 >, Ty::Integer<4 >>,
11421188 genMathOp<mlir::math::FPowIOp>},
1189+ {" pow" , RTNAME_STRING (FPow16i),
1190+ genFuncType<Ty::Real<16 >, Ty::Real<16 >, Ty::Integer<4 >>,
1191+ genMathOp<mlir::math::FPowIOp>},
11431192 {" pow" , RTNAME_STRING (FPow4k),
11441193 genFuncType<Ty::Real<4 >, Ty::Real<4 >, Ty::Integer<8 >>,
11451194 genMathOp<mlir::math::FPowIOp>},
11461195 {" pow" , RTNAME_STRING (FPow8k),
11471196 genFuncType<Ty::Real<8 >, Ty::Real<8 >, Ty::Integer<8 >>,
11481197 genMathOp<mlir::math::FPowIOp>},
1198+ {" pow" , RTNAME_STRING (FPow16k),
1199+ genFuncType<Ty::Real<16 >, Ty::Real<16 >, Ty::Integer<8 >>,
1200+ genMathOp<mlir::math::FPowIOp>},
11491201 {" pow" , RTNAME_STRING (cpowi),
11501202 genFuncType<Ty::Complex<4 >, Ty::Complex<4 >, Ty::Integer<4 >>, genLibCall},
11511203 {" pow" , RTNAME_STRING (zpowi),
@@ -1174,6 +1226,7 @@ static constexpr MathOperation mathOperations[] = {
11741226 genComplexMathOp<mlir::complex ::SinOp>},
11751227 {" sinh" , " sinhf" , genFuncType<Ty::Real<4 >, Ty::Real<4 >>, genLibCall},
11761228 {" sinh" , " sinh" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>, genLibCall},
1229+ {" sinh" , RTNAME_STRING (SinhF128), FuncTypeReal16Real16, genLibF128Call},
11771230 {" sinh" , " csinhf" , genFuncType<Ty::Complex<4 >, Ty::Complex<4 >>, genLibCall},
11781231 {" sinh" , " csinh" , genFuncType<Ty::Complex<8 >, Ty::Complex<8 >>, genLibCall},
11791232 {" sqrt" , " sqrtf" , genFuncType<Ty::Real<4 >, Ty::Real<4 >>,
@@ -1189,6 +1242,7 @@ static constexpr MathOperation mathOperations[] = {
11891242 genMathOp<mlir::math::TanOp>},
11901243 {" tan" , " tan" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>,
11911244 genMathOp<mlir::math::TanOp>},
1245+ {" tan" , RTNAME_STRING (TanF128), FuncTypeReal16Real16, genLibF128Call},
11921246 {" tan" , " ctanf" , genFuncType<Ty::Complex<4 >, Ty::Complex<4 >>,
11931247 genComplexMathOp<mlir::complex ::TanOp>},
11941248 {" tan" , " ctan" , genFuncType<Ty::Complex<8 >, Ty::Complex<8 >>,
@@ -1197,6 +1251,7 @@ static constexpr MathOperation mathOperations[] = {
11971251 genMathOp<mlir::math::TanhOp>},
11981252 {" tanh" , " tanh" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>,
11991253 genMathOp<mlir::math::TanhOp>},
1254+ {" tanh" , RTNAME_STRING (TanhF128), FuncTypeReal16Real16, genLibF128Call},
12001255 {" tanh" , " ctanhf" , genFuncType<Ty::Complex<4 >, Ty::Complex<4 >>,
12011256 genComplexMathOp<mlir::complex ::TanhOp>},
12021257 {" tanh" , " ctanh" , genFuncType<Ty::Complex<8 >, Ty::Complex<8 >>,
0 commit comments