diff --git a/flang/include/flang/Parser/dump-parse-tree.h b/flang/include/flang/Parser/dump-parse-tree.h --- a/flang/include/flang/Parser/dump-parse-tree.h +++ b/flang/include/flang/Parser/dump-parse-tree.h @@ -528,6 +528,8 @@ NODE_ENUM(OmpScheduleClause, ScheduleType) NODE(parser, OmpDeviceClause) NODE_ENUM(OmpDeviceClause, DeviceModifier) + NODE(parser, OmpDeviceTypeClause) + NODE_ENUM(OmpDeviceTypeClause, Type) NODE(parser, OmpScheduleModifier) NODE(OmpScheduleModifier, Modifier1) NODE(OmpScheduleModifier, Modifier2) diff --git a/flang/include/flang/Parser/parse-tree.h b/flang/include/flang/Parser/parse-tree.h --- a/flang/include/flang/Parser/parse-tree.h +++ b/flang/include/flang/Parser/parse-tree.h @@ -3396,6 +3396,12 @@ std::tuple, ScalarIntExpr> t; }; +// device_type(any | host | nohost) +struct OmpDeviceTypeClause { + ENUM_CLASS(Type, Any, Host, Nohost) + WRAPPER_CLASS_BOILERPLATE(OmpDeviceTypeClause, Type); +}; + // 2.12 if-clause -> IF ([ directive-name-modifier :] scalar-logical-expr) struct OmpIfClause { TUPLE_CLASS_BOILERPLATE(OmpIfClause); diff --git a/flang/lib/Parser/openmp-parsers.cpp b/flang/lib/Parser/openmp-parsers.cpp --- a/flang/lib/Parser/openmp-parsers.cpp +++ b/flang/lib/Parser/openmp-parsers.cpp @@ -105,6 +105,12 @@ ":"), scalarIntExpr)) +// device_type(any | host | nohost) +TYPE_PARSER(construct( + "ANY" >> pure(OmpDeviceTypeClause::Type::Any) || + "HOST" >> pure(OmpDeviceTypeClause::Type::Host) || + "NOHOST" >> pure(OmpDeviceTypeClause::Type::Nohost))) + // 2.12 IF (directive-name-modifier: scalar-logical-expr) TYPE_PARSER(construct( maybe( @@ -208,6 +214,8 @@ parenthesized(Parser{}))) || "DEVICE" >> construct(construct( parenthesized(Parser{}))) || + "DEVICE_TYPE" >> construct(construct( + parenthesized(Parser{}))) || "DIST_SCHEDULE" >> construct(construct( parenthesized("STATIC" >> maybe("," >> scalarIntExpr)))) || diff --git a/llvm/include/llvm/Frontend/OpenMP/OMP.td b/llvm/include/llvm/Frontend/OpenMP/OMP.td --- a/llvm/include/llvm/Frontend/OpenMP/OMP.td +++ b/llvm/include/llvm/Frontend/OpenMP/OMP.td @@ -222,6 +222,9 @@ let clangClass = "OMPDeviceClause"; let flangClass = "OmpDeviceClause"; } +def OMPC_DeviceType : Clause<"device_type"> { + let flangClass = "OmpDeviceTypeClause"; +} def OMPC_Threads : Clause<"threads"> { let clangClass = "OMPThreadsClause"; } def OMPC_Simd : Clause<"simd"> { let clangClass = "OMPSIMDClause"; } def OMPC_Map : Clause<"map"> { @@ -397,7 +400,6 @@ let flangClass = "Name"; let isValueList = true; } -def OMPC_DeviceType : Clause<"device_type"> {} def OMPC_Match : Clause<"match"> {} def OMPC_AdjustArgs : Clause<"adjust_args"> { } def OMPC_AppendArgs : Clause<"append_args"> { } @@ -1095,6 +1097,9 @@ VersionedClause, VersionedClause ]; + let allowedOnceClauses = [ + VersionedClause + ]; } def OMP_EndDeclareTarget : Directive<"end declare target"> {} def OMP_DistributeParallelFor : Directive<"distribute parallel for"> {