@@ -916,6 +916,16 @@ mlir::Value genComplexMathOp(fir::FirOpBuilder &builder, mlir::Location loc,
916
916
// / See https://gcc.gnu.org/onlinedocs/gcc-12.1.0/gfortran/\
917
917
/// Intrinsic-Procedures.html for a reference.
918
918
constexpr 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 >>;
919
929
constexpr auto FuncTypeReal16Complex16 =
920
930
genFuncType<Ty::Real<16 >, Ty::Complex<16 >>;
921
931
@@ -933,10 +943,12 @@ static constexpr MathOperation mathOperations[] = {
933
943
{" abs" , RTNAME_STRING (CAbsF128), FuncTypeReal16Complex16, genLibF128Call},
934
944
{" acos" , " acosf" , genFuncType<Ty::Real<4 >, Ty::Real<4 >>, genLibCall},
935
945
{" acos" , " acos" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>, genLibCall},
946
+ {" acos" , RTNAME_STRING (AcosF128), FuncTypeReal16Real16, genLibF128Call},
936
947
{" acos" , " cacosf" , genFuncType<Ty::Complex<4 >, Ty::Complex<4 >>, genLibCall},
937
948
{" acos" , " cacos" , genFuncType<Ty::Complex<8 >, Ty::Complex<8 >>, genLibCall},
938
949
{" acosh" , " acoshf" , genFuncType<Ty::Real<4 >, Ty::Real<4 >>, genLibCall},
939
950
{" acosh" , " acosh" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>, genLibCall},
951
+ {" acosh" , RTNAME_STRING (AcoshF128), FuncTypeReal16Real16, genLibF128Call},
940
952
{" acosh" , " cacoshf" , genFuncType<Ty::Complex<4 >, Ty::Complex<4 >>,
941
953
genLibCall},
942
954
{" acosh" , " cacosh" , genFuncType<Ty::Complex<8 >, Ty::Complex<8 >>,
@@ -948,19 +960,23 @@ static constexpr MathOperation mathOperations[] = {
948
960
genLibCall},
949
961
{" aint" , " llvm.trunc.f80" , genFuncType<Ty::Real<10 >, Ty::Real<10 >>,
950
962
genLibCall},
963
+ {" aint" , RTNAME_STRING (TruncF128), FuncTypeReal16Real16, genLibF128Call},
951
964
// llvm.round behaves the same way as libm's round.
952
965
{" anint" , " llvm.round.f32" , genFuncType<Ty::Real<4 >, Ty::Real<4 >>,
953
966
genMathOp<mlir::LLVM::RoundOp>},
954
967
{" anint" , " llvm.round.f64" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>,
955
968
genMathOp<mlir::LLVM::RoundOp>},
956
969
{" anint" , " llvm.round.f80" , genFuncType<Ty::Real<10 >, Ty::Real<10 >>,
957
970
genMathOp<mlir::LLVM::RoundOp>},
971
+ {" anint" , RTNAME_STRING (RoundF128), FuncTypeReal16Real16, genLibF128Call},
958
972
{" asin" , " asinf" , genFuncType<Ty::Real<4 >, Ty::Real<4 >>, genLibCall},
959
973
{" asin" , " asin" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>, genLibCall},
974
+ {" asin" , RTNAME_STRING (AsinF128), FuncTypeReal16Real16, genLibF128Call},
960
975
{" asin" , " casinf" , genFuncType<Ty::Complex<4 >, Ty::Complex<4 >>, genLibCall},
961
976
{" asin" , " casin" , genFuncType<Ty::Complex<8 >, Ty::Complex<8 >>, genLibCall},
962
977
{" asinh" , " asinhf" , genFuncType<Ty::Real<4 >, Ty::Real<4 >>, genLibCall},
963
978
{" asinh" , " asinh" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>, genLibCall},
979
+ {" asinh" , RTNAME_STRING (AsinhF128), FuncTypeReal16Real16, genLibF128Call},
964
980
{" asinh" , " casinhf" , genFuncType<Ty::Complex<4 >, Ty::Complex<4 >>,
965
981
genLibCall},
966
982
{" asinh" , " casinh" , genFuncType<Ty::Complex<8 >, Ty::Complex<8 >>,
@@ -969,49 +985,64 @@ static constexpr MathOperation mathOperations[] = {
969
985
genMathOp<mlir::math::AtanOp>},
970
986
{" atan" , " atan" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>,
971
987
genMathOp<mlir::math::AtanOp>},
988
+ {" atan" , RTNAME_STRING (AtanF128), FuncTypeReal16Real16, genLibF128Call},
972
989
{" atan" , " catanf" , genFuncType<Ty::Complex<4 >, Ty::Complex<4 >>, genLibCall},
973
990
{" atan" , " catan" , genFuncType<Ty::Complex<8 >, Ty::Complex<8 >>, genLibCall},
974
991
{" atan2" , " atan2f" , genFuncType<Ty::Real<4 >, Ty::Real<4 >, Ty::Real<4 >>,
975
992
genMathOp<mlir::math::Atan2Op>},
976
993
{" atan2" , " atan2" , genFuncType<Ty::Real<8 >, Ty::Real<8 >, Ty::Real<8 >>,
977
994
genMathOp<mlir::math::Atan2Op>},
995
+ {" atan2" , RTNAME_STRING (Atan2F128), FuncTypeReal16Real16Real16,
996
+ genLibF128Call},
978
997
{" atanh" , " atanhf" , genFuncType<Ty::Real<4 >, Ty::Real<4 >>, genLibCall},
979
998
{" atanh" , " atanh" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>, genLibCall},
999
+ {" atanh" , RTNAME_STRING (AtanhF128), FuncTypeReal16Real16, genLibF128Call},
980
1000
{" atanh" , " catanhf" , genFuncType<Ty::Complex<4 >, Ty::Complex<4 >>,
981
1001
genLibCall},
982
1002
{" atanh" , " catanh" , genFuncType<Ty::Complex<8 >, Ty::Complex<8 >>,
983
1003
genLibCall},
984
1004
{" bessel_j0" , " j0f" , genFuncType<Ty::Real<4 >, Ty::Real<4 >>, genLibCall},
985
1005
{" bessel_j0" , " j0" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>, genLibCall},
1006
+ {" bessel_j0" , RTNAME_STRING (J0F128), FuncTypeReal16Real16, genLibF128Call},
986
1007
{" bessel_j1" , " j1f" , genFuncType<Ty::Real<4 >, Ty::Real<4 >>, genLibCall},
987
1008
{" bessel_j1" , " j1" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>, genLibCall},
1009
+ {" bessel_j1" , RTNAME_STRING (J1F128), FuncTypeReal16Real16, genLibF128Call},
988
1010
{" bessel_jn" , " jnf" , genFuncType<Ty::Real<4 >, Ty::Integer<4 >, Ty::Real<4 >>,
989
1011
genLibCall},
990
1012
{" bessel_jn" , " jn" , genFuncType<Ty::Real<8 >, Ty::Integer<4 >, Ty::Real<8 >>,
991
1013
genLibCall},
1014
+ {" bessel_jn" , RTNAME_STRING (JnF128), FuncTypeReal16Integer4Real16,
1015
+ genLibF128Call},
992
1016
{" bessel_y0" , " y0f" , genFuncType<Ty::Real<4 >, Ty::Real<4 >>, genLibCall},
993
1017
{" bessel_y0" , " y0" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>, genLibCall},
1018
+ {" bessel_y0" , RTNAME_STRING (Y0F128), FuncTypeReal16Real16, genLibF128Call},
994
1019
{" bessel_y1" , " y1f" , genFuncType<Ty::Real<4 >, Ty::Real<4 >>, genLibCall},
995
1020
{" bessel_y1" , " y1" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>, genLibCall},
1021
+ {" bessel_y1" , RTNAME_STRING (Y1F128), FuncTypeReal16Real16, genLibF128Call},
996
1022
{" bessel_yn" , " ynf" , genFuncType<Ty::Real<4 >, Ty::Integer<4 >, Ty::Real<4 >>,
997
1023
genLibCall},
998
1024
{" bessel_yn" , " yn" , genFuncType<Ty::Real<8 >, Ty::Integer<4 >, Ty::Real<8 >>,
999
1025
genLibCall},
1026
+ {" bessel_yn" , RTNAME_STRING (YnF128), FuncTypeReal16Integer4Real16,
1027
+ genLibF128Call},
1000
1028
// math::CeilOp returns a real, while Fortran CEILING returns integer.
1001
1029
{" ceil" , " ceilf" , genFuncType<Ty::Real<4 >, Ty::Real<4 >>,
1002
1030
genMathOp<mlir::math::CeilOp>},
1003
1031
{" ceil" , " ceil" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>,
1004
1032
genMathOp<mlir::math::CeilOp>},
1033
+ {" ceil" , RTNAME_STRING (CeilF128), FuncTypeReal16Real16, genLibF128Call},
1005
1034
{" cos" , " cosf" , genFuncType<Ty::Real<4 >, Ty::Real<4 >>,
1006
1035
genMathOp<mlir::math::CosOp>},
1007
1036
{" cos" , " cos" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>,
1008
1037
genMathOp<mlir::math::CosOp>},
1038
+ {" cos" , RTNAME_STRING (CosF128), FuncTypeReal16Real16, genLibF128Call},
1009
1039
{" cos" , " ccosf" , genFuncType<Ty::Complex<4 >, Ty::Complex<4 >>,
1010
1040
genComplexMathOp<mlir::complex::CosOp>},
1011
1041
{" cos" , " ccos" , genFuncType<Ty::Complex<8 >, Ty::Complex<8 >>,
1012
1042
genComplexMathOp<mlir::complex::CosOp>},
1013
1043
{" cosh" , " coshf" , genFuncType<Ty::Real<4 >, Ty::Real<4 >>, genLibCall},
1014
1044
{" cosh" , " cosh" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>, genLibCall},
1045
+ {" cosh" , RTNAME_STRING (CoshF128), FuncTypeReal16Real16, genLibF128Call},
1015
1046
{" cosh" , " ccoshf" , genFuncType<Ty::Complex<4 >, Ty::Complex<4 >>, genLibCall},
1016
1047
{" cosh" , " ccosh" , genFuncType<Ty::Complex<8 >, Ty::Complex<8 >>, genLibCall},
1017
1048
{" divc" ,
@@ -1038,12 +1069,15 @@ static constexpr MathOperation mathOperations[] = {
1038
1069
genMathOp<mlir::math::ErfOp>},
1039
1070
{" erf" , " erf" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>,
1040
1071
genMathOp<mlir::math::ErfOp>},
1072
+ {" erf" , RTNAME_STRING (ErfF128), FuncTypeReal16Real16, genLibF128Call},
1041
1073
{" erfc" , " erfcf" , genFuncType<Ty::Real<4 >, Ty::Real<4 >>, genLibCall},
1042
1074
{" erfc" , " erfc" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>, genLibCall},
1075
+ {" erfc" , RTNAME_STRING (ErfcF128), FuncTypeReal16Real16, genLibF128Call},
1043
1076
{" exp" , " expf" , genFuncType<Ty::Real<4 >, Ty::Real<4 >>,
1044
1077
genMathOp<mlir::math::ExpOp>},
1045
1078
{" exp" , " exp" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>,
1046
1079
genMathOp<mlir::math::ExpOp>},
1080
+ {" exp" , RTNAME_STRING (ExpF128), FuncTypeReal16Real16, genLibF128Call},
1047
1081
{" exp" , " cexpf" , genFuncType<Ty::Complex<4 >, Ty::Complex<4 >>,
1048
1082
genComplexMathOp<mlir::complex::ExpOp>},
1049
1083
{" exp" , " cexp" , genFuncType<Ty::Complex<8 >, Ty::Complex<8 >>,
@@ -1074,6 +1108,7 @@ static constexpr MathOperation mathOperations[] = {
1074
1108
genMathOp<mlir::math::FloorOp>},
1075
1109
{" floor" , " floor" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>,
1076
1110
genMathOp<mlir::math::FloorOp>},
1111
+ {" floor" , RTNAME_STRING (FloorF128), FuncTypeReal16Real16, genLibF128Call},
1077
1112
{" fma" , " llvm.fma.f32" ,
1078
1113
genFuncType<Ty::Real<4 >, Ty::Real<4 >, Ty::Real<4 >, Ty::Real<4 >>,
1079
1114
genMathOp<mlir::math::FmaOp>},
@@ -1082,14 +1117,18 @@ static constexpr MathOperation mathOperations[] = {
1082
1117
genMathOp<mlir::math::FmaOp>},
1083
1118
{" gamma" , " tgammaf" , genFuncType<Ty::Real<4 >, Ty::Real<4 >>, genLibCall},
1084
1119
{" gamma" , " tgamma" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>, genLibCall},
1120
+ {" gamma" , RTNAME_STRING (TgammaF128), FuncTypeReal16Real16, genLibF128Call},
1085
1121
{" hypot" , " hypotf" , genFuncType<Ty::Real<4 >, Ty::Real<4 >, Ty::Real<4 >>,
1086
1122
genLibCall},
1087
1123
{" hypot" , " hypot" , genFuncType<Ty::Real<8 >, Ty::Real<8 >, Ty::Real<8 >>,
1088
1124
genLibCall},
1125
+ {" hypot" , RTNAME_STRING (HypotF128), FuncTypeReal16Real16Real16,
1126
+ genLibF128Call},
1089
1127
{" log" , " logf" , genFuncType<Ty::Real<4 >, Ty::Real<4 >>,
1090
1128
genMathOp<mlir::math::LogOp>},
1091
1129
{" log" , " log" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>,
1092
1130
genMathOp<mlir::math::LogOp>},
1131
+ {" log" , RTNAME_STRING (LogF128), FuncTypeReal16Real16, genLibF128Call},
1093
1132
{" log" , " clogf" , genFuncType<Ty::Complex<4 >, Ty::Complex<4 >>,
1094
1133
genComplexMathOp<mlir::complex::LogOp>},
1095
1134
{" log" , " clog" , genFuncType<Ty::Complex<8 >, Ty::Complex<8 >>,
@@ -1098,17 +1137,23 @@ static constexpr MathOperation mathOperations[] = {
1098
1137
genMathOp<mlir::math::Log10Op>},
1099
1138
{" log10" , " log10" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>,
1100
1139
genMathOp<mlir::math::Log10Op>},
1140
+ {" log10" , RTNAME_STRING (Log10F128), FuncTypeReal16Real16, genLibF128Call},
1101
1141
{" log_gamma" , " lgammaf" , genFuncType<Ty::Real<4 >, Ty::Real<4 >>, genLibCall},
1102
1142
{" log_gamma" , " lgamma" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>, genLibCall},
1143
+ {" log_gamma" , RTNAME_STRING (LgammaF128), FuncTypeReal16Real16,
1144
+ genLibF128Call},
1103
1145
// llvm.lround behaves the same way as libm's lround.
1104
1146
{" nint" , " llvm.lround.i64.f64" , genFuncType<Ty::Integer<8 >, Ty::Real<8 >>,
1105
1147
genLibCall},
1106
1148
{" nint" , " llvm.lround.i64.f32" , genFuncType<Ty::Integer<8 >, Ty::Real<4 >>,
1107
1149
genLibCall},
1150
+ {" nint" , RTNAME_STRING (LlroundF128), FuncTypeInteger8Real16,
1151
+ genLibF128Call},
1108
1152
{" nint" , " llvm.lround.i32.f64" , genFuncType<Ty::Integer<4 >, Ty::Real<8 >>,
1109
1153
genLibCall},
1110
1154
{" nint" , " llvm.lround.i32.f32" , genFuncType<Ty::Integer<4 >, Ty::Real<4 >>,
1111
1155
genLibCall},
1156
+ {" nint" , RTNAME_STRING (LroundF128), FuncTypeInteger4Real16, genLibF128Call},
1112
1157
{" pow" ,
1113
1158
{},
1114
1159
genFuncType<Ty::Integer<1 >, Ty::Integer<1 >, Ty::Integer<1 >>,
@@ -1129,6 +1174,7 @@ static constexpr MathOperation mathOperations[] = {
1129
1174
genMathOp<mlir::math::PowFOp>},
1130
1175
{" pow" , " pow" , genFuncType<Ty::Real<8 >, Ty::Real<8 >, Ty::Real<8 >>,
1131
1176
genMathOp<mlir::math::PowFOp>},
1177
+ {" pow" , RTNAME_STRING (PowF128), FuncTypeReal16Real16Real16, genLibF128Call},
1132
1178
{" pow" , " cpowf" ,
1133
1179
genFuncType<Ty::Complex<4 >, Ty::Complex<4 >, Ty::Complex<4 >>,
1134
1180
genComplexMathOp<mlir::complex::PowOp>},
@@ -1140,12 +1186,18 @@ static constexpr MathOperation mathOperations[] = {
1140
1186
{" pow" , RTNAME_STRING (FPow8i),
1141
1187
genFuncType<Ty::Real<8 >, Ty::Real<8 >, Ty::Integer<4 >>,
1142
1188
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>},
1143
1192
{" pow" , RTNAME_STRING (FPow4k),
1144
1193
genFuncType<Ty::Real<4 >, Ty::Real<4 >, Ty::Integer<8 >>,
1145
1194
genMathOp<mlir::math::FPowIOp>},
1146
1195
{" pow" , RTNAME_STRING (FPow8k),
1147
1196
genFuncType<Ty::Real<8 >, Ty::Real<8 >, Ty::Integer<8 >>,
1148
1197
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>},
1149
1201
{" pow" , RTNAME_STRING (cpowi),
1150
1202
genFuncType<Ty::Complex<4 >, Ty::Complex<4 >, Ty::Integer<4 >>, genLibCall},
1151
1203
{" pow" , RTNAME_STRING (zpowi),
@@ -1174,6 +1226,7 @@ static constexpr MathOperation mathOperations[] = {
1174
1226
genComplexMathOp<mlir::complex::SinOp>},
1175
1227
{" sinh" , " sinhf" , genFuncType<Ty::Real<4 >, Ty::Real<4 >>, genLibCall},
1176
1228
{" sinh" , " sinh" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>, genLibCall},
1229
+ {" sinh" , RTNAME_STRING (SinhF128), FuncTypeReal16Real16, genLibF128Call},
1177
1230
{" sinh" , " csinhf" , genFuncType<Ty::Complex<4 >, Ty::Complex<4 >>, genLibCall},
1178
1231
{" sinh" , " csinh" , genFuncType<Ty::Complex<8 >, Ty::Complex<8 >>, genLibCall},
1179
1232
{" sqrt" , " sqrtf" , genFuncType<Ty::Real<4 >, Ty::Real<4 >>,
@@ -1189,6 +1242,7 @@ static constexpr MathOperation mathOperations[] = {
1189
1242
genMathOp<mlir::math::TanOp>},
1190
1243
{" tan" , " tan" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>,
1191
1244
genMathOp<mlir::math::TanOp>},
1245
+ {" tan" , RTNAME_STRING (TanF128), FuncTypeReal16Real16, genLibF128Call},
1192
1246
{" tan" , " ctanf" , genFuncType<Ty::Complex<4 >, Ty::Complex<4 >>,
1193
1247
genComplexMathOp<mlir::complex::TanOp>},
1194
1248
{" tan" , " ctan" , genFuncType<Ty::Complex<8 >, Ty::Complex<8 >>,
@@ -1197,6 +1251,7 @@ static constexpr MathOperation mathOperations[] = {
1197
1251
genMathOp<mlir::math::TanhOp>},
1198
1252
{" tanh" , " tanh" , genFuncType<Ty::Real<8 >, Ty::Real<8 >>,
1199
1253
genMathOp<mlir::math::TanhOp>},
1254
+ {" tanh" , RTNAME_STRING (TanhF128), FuncTypeReal16Real16, genLibF128Call},
1200
1255
{" tanh" , " ctanhf" , genFuncType<Ty::Complex<4 >, Ty::Complex<4 >>,
1201
1256
genComplexMathOp<mlir::complex::TanhOp>},
1202
1257
{" tanh" , " ctanh" , genFuncType<Ty::Complex<8 >, Ty::Complex<8 >>,
0 commit comments