comparison flang/lib/Evaluate/fold-real.cpp @ 207:2e18cbf3894f

LLVM12
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 08 Jun 2021 06:07:14 +0900
parents 0572611fdcc8
children 5f17cb93ff66
comparison
equal deleted inserted replaced
173:0572611fdcc8 207:2e18cbf3894f
27 name == "erfc" || name == "erfc_scaled" || name == "exp" || 27 name == "erfc" || name == "erfc_scaled" || name == "exp" ||
28 name == "gamma" || name == "log" || name == "log10" || 28 name == "gamma" || name == "log" || name == "log10" ||
29 name == "log_gamma" || name == "sin" || name == "sinh" || 29 name == "log_gamma" || name == "sin" || name == "sinh" ||
30 name == "sqrt" || name == "tan" || name == "tanh") { 30 name == "sqrt" || name == "tan" || name == "tanh") {
31 CHECK(args.size() == 1); 31 CHECK(args.size() == 1);
32 if (auto callable{context.hostIntrinsicsLibrary() 32 if (auto callable{GetHostRuntimeWrapper<T, T>(name)}) {
33 .GetHostProcedureWrapper<Scalar, T, T>(name)}) {
34 return FoldElementalIntrinsic<T, T>( 33 return FoldElementalIntrinsic<T, T>(
35 context, std::move(funcRef), *callable); 34 context, std::move(funcRef), *callable);
36 } else { 35 } else {
37 context.messages().Say( 36 context.messages().Say(
38 "%s(real(kind=%d)) cannot be folded on host"_en_US, name, KIND); 37 "%s(real(kind=%d)) cannot be folded on host"_en_US, name, KIND);
39 } 38 }
39 } else if (name == "amax0" || name == "amin0" || name == "amin1" ||
40 name == "amax1" || name == "dmin1" || name == "dmax1") {
41 return RewriteSpecificMINorMAX(context, std::move(funcRef));
40 } else if (name == "atan" || name == "atan2" || name == "hypot" || 42 } else if (name == "atan" || name == "atan2" || name == "hypot" ||
41 name == "mod") { 43 name == "mod") {
42 std::string localName{name == "atan2" ? "atan" : name}; 44 std::string localName{name == "atan" ? "atan2" : name};
43 CHECK(args.size() == 2); 45 CHECK(args.size() == 2);
44 if (auto callable{ 46 if (auto callable{GetHostRuntimeWrapper<T, T, T>(localName)}) {
45 context.hostIntrinsicsLibrary()
46 .GetHostProcedureWrapper<Scalar, T, T, T>(localName)}) {
47 return FoldElementalIntrinsic<T, T, T>( 47 return FoldElementalIntrinsic<T, T, T>(
48 context, std::move(funcRef), *callable); 48 context, std::move(funcRef), *callable);
49 } else { 49 } else {
50 context.messages().Say( 50 context.messages().Say(
51 "%s(real(kind=%d), real(kind%d)) cannot be folded on host"_en_US, 51 "%s(real(kind=%d), real(kind%d)) cannot be folded on host"_en_US,
53 } 53 }
54 } else if (name == "bessel_jn" || name == "bessel_yn") { 54 } else if (name == "bessel_jn" || name == "bessel_yn") {
55 if (args.size() == 2) { // elemental 55 if (args.size() == 2) { // elemental
56 // runtime functions use int arg 56 // runtime functions use int arg
57 using Int4 = Type<TypeCategory::Integer, 4>; 57 using Int4 = Type<TypeCategory::Integer, 4>;
58 if (auto callable{ 58 if (auto callable{GetHostRuntimeWrapper<T, Int4, T>(name)}) {
59 context.hostIntrinsicsLibrary()
60 .GetHostProcedureWrapper<Scalar, T, Int4, T>(name)}) {
61 return FoldElementalIntrinsic<T, Int4, T>( 59 return FoldElementalIntrinsic<T, Int4, T>(
62 context, std::move(funcRef), *callable); 60 context, std::move(funcRef), *callable);
63 } else { 61 } else {
64 context.messages().Say( 62 context.messages().Say(
65 "%s(integer(kind=4), real(kind=%d)) cannot be folded on host"_en_US, 63 "%s(integer(kind=4), real(kind=%d)) cannot be folded on host"_en_US,
70 // Argument can be complex or real 68 // Argument can be complex or real
71 if (auto *x{UnwrapExpr<Expr<SomeReal>>(args[0])}) { 69 if (auto *x{UnwrapExpr<Expr<SomeReal>>(args[0])}) {
72 return FoldElementalIntrinsic<T, T>( 70 return FoldElementalIntrinsic<T, T>(
73 context, std::move(funcRef), &Scalar<T>::ABS); 71 context, std::move(funcRef), &Scalar<T>::ABS);
74 } else if (auto *z{UnwrapExpr<Expr<SomeComplex>>(args[0])}) { 72 } else if (auto *z{UnwrapExpr<Expr<SomeComplex>>(args[0])}) {
75 if (auto callable{ 73 if (auto callable{GetHostRuntimeWrapper<T, ComplexT>("abs")}) {
76 context.hostIntrinsicsLibrary()
77 .GetHostProcedureWrapper<Scalar, T, ComplexT>("abs")}) {
78 return FoldElementalIntrinsic<T, ComplexT>( 74 return FoldElementalIntrinsic<T, ComplexT>(
79 context, std::move(funcRef), *callable); 75 context, std::move(funcRef), *callable);
80 } else { 76 } else {
81 context.messages().Say( 77 context.messages().Say(
82 "abs(complex(kind=%d)) cannot be folded on host"_en_US, KIND); 78 "abs(complex(kind=%d)) cannot be folded on host"_en_US, KIND);