[flang-commits] [flang] change exitstat and cmsstat from AnyInt to DefaultInt (PR #78286)
Yi Wu via flang-commits
flang-commits at lists.llvm.org
Tue Jan 16 08:57:30 PST 2024
https://github.com/yi-wu-arm updated https://github.com/llvm/llvm-project/pull/78286
>From d56eca56c8e4c64e649febc43e2c48b6e5146680 Mon Sep 17 00:00:00 2001
From: Yi Wu <yi.wu2 at arm.com>
Date: Tue, 16 Jan 2024 14:08:00 +0000
Subject: [PATCH 1/2] change exitstat and cmsstat from AnyInt to DefaultInt
---
flang/lib/Evaluate/intrinsics.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/flang/lib/Evaluate/intrinsics.cpp b/flang/lib/Evaluate/intrinsics.cpp
index da6d5970089884..0b9bdac88a78dc 100644
--- a/flang/lib/Evaluate/intrinsics.cpp
+++ b/flang/lib/Evaluate/intrinsics.cpp
@@ -1314,9 +1314,9 @@ static const IntrinsicInterface intrinsicSubroutine[]{
{"execute_command_line",
{{"command", DefaultChar, Rank::scalar},
{"wait", AnyLogical, Rank::scalar, Optionality::optional},
- {"exitstat", AnyInt, Rank::scalar, Optionality::optional,
+ {"exitstat", DefaultInt, Rank::scalar, Optionality::optional,
common::Intent::InOut},
- {"cmdstat", AnyInt, Rank::scalar, Optionality::optional,
+ {"cmdstat", DefaultInt, Rank::scalar, Optionality::optional,
common::Intent::Out},
{"cmdmsg", DefaultChar, Rank::scalar, Optionality::optional,
common::Intent::InOut}},
>From 2741652cae00ca1a94ae7a3310af1f25308e8105 Mon Sep 17 00:00:00 2001
From: Yi Wu <yi.wu2 at arm.com>
Date: Tue, 16 Jan 2024 16:54:42 +0000
Subject: [PATCH 2/2] add KindCode::greaterEqualToKind
Now execute_command_line will accept exitstat kind>=4, cmdstat kind >=2
---
flang/lib/Evaluate/intrinsics.cpp | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/flang/lib/Evaluate/intrinsics.cpp b/flang/lib/Evaluate/intrinsics.cpp
index 0b9bdac88a78dc..947e31967bdf45 100644
--- a/flang/lib/Evaluate/intrinsics.cpp
+++ b/flang/lib/Evaluate/intrinsics.cpp
@@ -77,7 +77,7 @@ static constexpr CategorySet AnyType{IntrinsicType | DerivedType};
ENUM_CLASS(KindCode, none, defaultIntegerKind,
defaultRealKind, // is also the default COMPLEX kind
- doublePrecision, defaultCharKind, defaultLogicalKind,
+ doublePrecision, defaultCharKind, defaultLogicalKind, greaterAndEqualToKind,
any, // matches any kind value; each instance is independent
// match any kind, but all "same" kinds must be equal. For characters, also
// implies that lengths must be equal.
@@ -104,7 +104,8 @@ ENUM_CLASS(KindCode, none, defaultIntegerKind,
struct TypePattern {
CategorySet categorySet;
KindCode kindCode{KindCode::none};
- int exactKindValue{0}; // for KindCode::exactKind
+ int kindValue{
+ 0}; // for KindCode::exactKind and KindCode::greaterAndEqualToKind
llvm::raw_ostream &Dump(llvm::raw_ostream &) const;
};
@@ -1314,10 +1315,12 @@ static const IntrinsicInterface intrinsicSubroutine[]{
{"execute_command_line",
{{"command", DefaultChar, Rank::scalar},
{"wait", AnyLogical, Rank::scalar, Optionality::optional},
- {"exitstat", DefaultInt, Rank::scalar, Optionality::optional,
- common::Intent::InOut},
- {"cmdstat", DefaultInt, Rank::scalar, Optionality::optional,
- common::Intent::Out},
+ {"exitstat",
+ TypePattern{IntType, KindCode::greaterAndEqualToKind, 4},
+ Rank::scalar, Optionality::optional, common::Intent::InOut},
+ {"cmdstat",
+ TypePattern{IntType, KindCode::greaterAndEqualToKind, 2},
+ Rank::scalar, Optionality::optional, common::Intent::Out},
{"cmdmsg", DefaultChar, Rank::scalar, Optionality::optional,
common::Intent::InOut}},
{}, Rank::elemental, IntrinsicClass::impureSubroutine},
@@ -1834,7 +1837,10 @@ std::optional<SpecificCall> IntrinsicInterface::Match(
argOk = true;
break;
case KindCode::exactKind:
- argOk = type->kind() == d.typePattern.exactKindValue;
+ argOk = type->kind() == d.typePattern.kindValue;
+ break;
+ case KindCode::greaterAndEqualToKind:
+ argOk = type->kind() >= d.typePattern.kindValue;
break;
case KindCode::sameAtom:
if (!sameArg) {
@@ -2177,8 +2183,9 @@ std::optional<SpecificCall> IntrinsicInterface::Match(
resultType = DynamicType{
GetBuiltinDerivedType(builtinsScope, "__builtin_team_type")};
break;
+ case KindCode::greaterAndEqualToKind:
case KindCode::exactKind:
- resultType = DynamicType{*category, result.exactKindValue};
+ resultType = DynamicType{*category, result.kindValue};
break;
case KindCode::typeless:
case KindCode::any:
More information about the flang-commits
mailing list