[flang][OpenMP] Make OmpDependenceKind be a common enum, NFC (#172871)

In OpenMP 6.0 a subset of the dependence types is also used in the
`depinfo-modifier` on INIT clause. Make the enum be a common type to
avoid defining separate enum types with mostly identical members.

Use the name `OmpDependenceKind` because the other obvious candidate,
OmpDependenceType, used to be a modifier name in older OpenMP specs.
This commit is contained in:
Krzysztof Parzyszek 2025-12-18 10:23:57 -06:00 committed by GitHub
parent 55089733b6
commit 603904fa19
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 14 additions and 16 deletions

View File

@ -164,8 +164,7 @@ void OpenMPCounterVisitor::Post(const OmpOrderingModifier::Value &c) {
"modifier=" + std::string{OmpOrderingModifier::EnumToString(c)} + ";";
}
void OpenMPCounterVisitor::Post(const OmpTaskDependenceType::Value &c) {
clauseDetails +=
"type=" + std::string{OmpTaskDependenceType::EnumToString(c)} + ";";
clauseDetails += "type=" + std::string{common::EnumToString(c)} + ";";
}
void OpenMPCounterVisitor::Post(const OmpMapType::Value &c) {
clauseDetails += "type=" + std::string{OmpMapType::EnumToString(c)} + ";";

View File

@ -64,6 +64,7 @@ public:
NODE(std, uint64_t)
NODE_ENUM(common, CUDADataAttr)
NODE_ENUM(common, CUDASubprogramAttrs)
NODE_ENUM(common, OmpDependenceKind)
NODE_ENUM(common, OmpMemoryOrderType)
NODE_ENUM(common, OpenACCDeviceType)
NODE(format, ControlEditDesc)
@ -714,7 +715,6 @@ public:
NODE(parser, OmpStylizedInstance)
NODE(OmpStylizedInstance, Instance)
NODE(parser, OmpTaskDependenceType)
NODE_ENUM(OmpTaskDependenceType, Value)
NODE(parser, OmpTaskReductionClause)
NODE(OmpTaskReductionClause, Modifier)
NODE(parser, OmpThreadLimitClause)

View File

@ -4256,7 +4256,7 @@ struct OmpStepSimpleModifier {
// MUTEXINOUTSET | DEPOBJ | // since 5.0
// INOUTSET // since 5.2
struct OmpTaskDependenceType {
ENUM_CLASS(Value, In, Out, Inout, Inoutset, Mutexinoutset, Depobj)
using Value = common::OmpDependenceKind;
WRAPPER_CLASS_BOILERPLATE(OmpTaskDependenceType, Value);
};

View File

@ -72,6 +72,9 @@ ENUM_CLASS(
ENUM_CLASS(
OpenACCDeviceType, Star, Default, Nvidia, Radeon, Host, Multicore, None)
// OpenMP dependence kinds
ENUM_CLASS(OmpDependenceKind, In, Out, Inout, Inoutset, Mutexinoutset, Depobj)
// OpenMP memory-order types
ENUM_CLASS(OmpMemoryOrderType, Acq_Rel, Acquire, Relaxed, Release, Seq_Cst)

View File

@ -2518,10 +2518,6 @@ public:
#include "llvm/Frontend/OpenMP/OMP.inc"
void Unparse(const OmpObjectList &x) { Walk(x.v, ","); }
void Unparse(const common::OmpMemoryOrderType &x) {
Word(ToUpperCaseLetters(common::EnumToString(x)));
}
void Unparse(const OmpBeginDirective &x) {
BeginOpenMP();
Word("!$OMP ");
@ -2827,6 +2823,8 @@ public:
WALK_NESTED_ENUM(common, TypeParamAttr) // R734
WALK_NESTED_ENUM(common, CUDADataAttr) // CUDA
WALK_NESTED_ENUM(common, CUDASubprogramAttrs) // CUDA
WALK_NESTED_ENUM(common, OmpDependenceKind)
WALK_NESTED_ENUM(common, OmpMemoryOrderType)
WALK_NESTED_ENUM(IntentSpec, Intent) // R826
WALK_NESTED_ENUM(ImplicitStmt, ImplicitNoneNameSpec) // R866
WALK_NESTED_ENUM(ConnectSpec::CharExpr, Kind) // R1205
@ -2848,7 +2846,6 @@ public:
WALK_NESTED_ENUM(OmpChunkModifier, Value) // OMP chunk-modifier
WALK_NESTED_ENUM(OmpLinearModifier, Value) // OMP linear-modifier
WALK_NESTED_ENUM(OmpOrderingModifier, Value) // OMP ordering-modifier
WALK_NESTED_ENUM(OmpTaskDependenceType, Value) // OMP task-dependence-type
WALK_NESTED_ENUM(OmpScheduleClause, Kind) // OMP schedule-kind
WALK_NESTED_ENUM(OmpSeverityClause, SevLevel) // OMP severity
WALK_NESTED_ENUM(OmpThreadsetClause, ThreadsetPolicy) // OMP threadset

View File

@ -2650,9 +2650,8 @@ void OmpStructureChecker::CheckTaskDependenceType(
if (version < since) {
context_.Say(GetContext().clauseSource,
"%s task dependence type is not supported in %s, %s"_warn_en_US,
parser::ToUpperCaseLetters(
parser::OmpTaskDependenceType::EnumToString(x)),
ThisVersion(version), TryVersion(since));
parser::ToUpperCaseLetters(EnumToString(x)), ThisVersion(version),
TryVersion(since));
}
}

View File

@ -15,7 +15,7 @@ end
!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = depobj
!PARSE-TREE: | OmpArgumentList -> OmpArgument -> OmpLocator -> OmpObject -> Designator -> DataRef -> Name = 'x'
!PARSE-TREE: | OmpClauseList -> OmpClause -> Depend -> OmpDependClause -> TaskDep
!PARSE-TREE: | | Modifier -> OmpTaskDependenceType -> Value = In
!PARSE-TREE: | | Modifier -> OmpTaskDependenceType -> OmpDependenceKind = In
!PARSE-TREE: | | OmpObjectList -> OmpObject -> Designator -> DataRef -> Name = 'y'
subroutine f01
@ -31,7 +31,7 @@ end
!PARSE-TREE: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPStandaloneConstruct -> OpenMPDepobjConstruct -> OmpDirectiveSpecification
!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = depobj
!PARSE-TREE: | OmpArgumentList -> OmpArgument -> OmpLocator -> OmpObject -> Designator -> DataRef -> Name = 'x'
!PARSE-TREE: | OmpClauseList -> OmpClause -> Update -> OmpUpdateClause -> OmpTaskDependenceType -> Value = Out
!PARSE-TREE: | OmpClauseList -> OmpClause -> Update -> OmpUpdateClause -> OmpTaskDependenceType -> OmpDependenceKind = Out
subroutine f02
integer :: x

View File

@ -63,7 +63,7 @@ END SUBROUTINE test_interop_03
!PARSE-TREE: | | Modifier -> OmpInteropType -> Value = Targetsync
!PARSE-TREE: | | OmpObject -> Designator -> DataRef -> Name = 'obj'
!PARSE-TREE: | OmpClause -> Depend -> OmpDependClause -> TaskDep
!PARSE-TREE: | | Modifier -> OmpTaskDependenceType -> Value = Inout
!PARSE-TREE: | | Modifier -> OmpTaskDependenceType -> OmpDependenceKind = Inout
!PARSE-TREE: | | OmpObjectList -> OmpObject -> Designator -> DataRef -> Name = 'obj'
!PARSE-TREE: | Flags = {}
@ -94,7 +94,7 @@ END SUBROUTINE test_interop_04
!PARSE-TREE: | | Modifier -> OmpInteropType -> Value = Target
!PARSE-TREE: | | OmpObject -> Designator -> DataRef -> Name = 'obj'
!PARSE-TREE: | OmpClause -> Depend -> OmpDependClause -> TaskDep
!PARSE-TREE: | | Modifier -> OmpTaskDependenceType -> Value = Inout
!PARSE-TREE: | | Modifier -> OmpTaskDependenceType -> OmpDependenceKind = Inout
!PARSE-TREE: | | OmpObjectList -> OmpObject -> Designator -> DataRef -> Name = 'arr'
!PARSE-TREE: | OmpClause -> Nowait
!PARSE-TREE: | Flags = {}