Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions flang/include/flang/Parser/dump-parse-tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,8 @@ class ParseTreeDumper {
NODE(parser, OmpAlignClause)
NODE(parser, OmpAlignedClause)
NODE(OmpAlignedClause, Modifier)
NODE(parser, OmpAlwaysModifier)
NODE_ENUM(OmpAlwaysModifier, Value)
NODE(parser, OmpAtClause)
NODE_ENUM(OmpAtClause, ActionTime)
NODE_ENUM(OmpSeverityClause, Severity)
Expand All @@ -546,6 +548,8 @@ class ParseTreeDumper {
#include "llvm/Frontend/OpenMP/OMP.inc"
NODE(parser, OmpClauseList)
NODE(parser, OmpCancellationConstructTypeClause)
NODE(parser, OmpCloseModifier)
NODE_ENUM(OmpCloseModifier, Value)
NODE(parser, OmpContainsClause)
NODE(parser, OmpCriticalDirective)
NODE(parser, OmpErrorDirective)
Expand All @@ -561,6 +565,8 @@ class ParseTreeDumper {
NODE(parser, OmpDefaultmapClause)
NODE_ENUM(OmpDefaultmapClause, ImplicitBehavior)
NODE(OmpDefaultmapClause, Modifier)
NODE(parser, OmpDeleteModifier)
NODE_ENUM(OmpDeleteModifier, Value)
NODE(parser, OmpDependenceType)
NODE_ENUM(OmpDependenceType, Value)
NODE(parser, OmpTaskDependenceType)
Expand Down Expand Up @@ -628,6 +634,8 @@ class ParseTreeDumper {
NODE(OmpNumTasksClause, Modifier)
NODE(parser, OmpBindClause)
NODE_ENUM(OmpBindClause, Binding)
NODE(parser, OmpPresentModifier)
NODE_ENUM(OmpPresentModifier, Value)
NODE(parser, OmpProcBindClause)
NODE_ENUM(OmpProcBindClause, AffinityPolicy)
NODE(parser, OmpReductionModifier)
Expand All @@ -637,6 +645,10 @@ class ParseTreeDumper {
NODE(parser, OmpInReductionClause)
NODE(OmpInReductionClause, Modifier)
NODE(parser, OmpReductionCombiner)
NODE(parser, OmpRefModifier)
NODE_ENUM(OmpRefModifier, Value)
NODE(parser, OmpSelfModifier)
NODE_ENUM(OmpSelfModifier, Value)
NODE(parser, OmpTaskReductionClause)
NODE(OmpTaskReductionClause, Modifier)
NODE(parser, OmpInitializerProc)
Expand Down Expand Up @@ -673,6 +685,8 @@ class ParseTreeDumper {
NODE(parser, OmpSectionsDirective)
NODE(parser, OmpToClause)
NODE(OmpToClause, Modifier)
NODE(parser, OmpxHoldModifier)
NODE_ENUM(OmpxHoldModifier, Value)
NODE(parser, Only)
NODE(parser, OpenACCAtomicConstruct)
NODE(parser, OpenACCBlockConstruct)
Expand Down
138 changes: 120 additions & 18 deletions flang/include/flang/Parser/parse-tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -3756,6 +3756,19 @@ struct OmpAllocatorComplexModifier {
WRAPPER_CLASS_BOILERPLATE(OmpAllocatorComplexModifier, ScalarIntExpr);
};

// Ref: [4.5:216-219], [5.0:315-324], [5.1:347-355], [5.2:150-158],
// [6.0:279-288]
//
// always-modifier ->
// ALWAYS // since 4.5
//
// Until 5.2, it was a part of map-type-modifier. Since 6.0 the
// map-type-modifier has been split into individual modifiers.
struct OmpAlwaysModifier {
ENUM_CLASS(Value, Always)
WRAPPER_CLASS_BOILERPLATE(OmpAlwaysModifier, Value);
};

// Ref: [5.2:252-254]
//
// chunk-modifier ->
Expand All @@ -3767,17 +3780,29 @@ struct OmpChunkModifier {
WRAPPER_CLASS_BOILERPLATE(OmpChunkModifier, Value);
};

// Ref: [5.0:47-49], [5.1:49-51], [5.2:67-69]
// Ref: [4.5:216-219], [5.0:315-324], [5.1:347-355], [5.2:150-158],
// [6.0:279-288]
//
// iterator-specifier ->
// [iterator-type] iterator-identifier
// = range-specification | // since 5.0
// [iterator-type ::] iterator-identifier
// = range-specification // since 5.2
struct OmpIteratorSpecifier {
TUPLE_CLASS_BOILERPLATE(OmpIteratorSpecifier);
CharBlock source;
std::tuple<TypeDeclarationStmt, SubscriptTriplet> t;
// close-modifier ->
// CLOSE // since 5.0
//
// Until 5.2, it was a part of map-type-modifier. Since 6.0 the
// map-type-modifier has been split into individual modifiers.
struct OmpCloseModifier {
ENUM_CLASS(Value, Close)
WRAPPER_CLASS_BOILERPLATE(OmpCloseModifier, Value);
};

// Ref: [4.5:216-219], [5.0:315-324], [5.1:347-355], [5.2:150-158],
// [6.0:279-288]
//
// delete-modifier ->
// DELETE // since 6.0
//
// Until 5.2, it was a part of map-type.
struct OmpDeleteModifier {
ENUM_CLASS(Value, Delete)
WRAPPER_CLASS_BOILERPLATE(OmpDeleteModifier, Value);
};

// Ref: [4.5:169-170], [5.0:255-256], [5.1:288-289]
Expand Down Expand Up @@ -3867,6 +3892,19 @@ struct OmpInteropType {
WRAPPER_CLASS_BOILERPLATE(OmpInteropType, Value);
};

// Ref: [5.0:47-49], [5.1:49-51], [5.2:67-69]
//
// iterator-specifier ->
// [iterator-type] iterator-identifier
// = range-specification | // since 5.0
// [iterator-type ::] iterator-identifier
// = range-specification // since 5.2
struct OmpIteratorSpecifier {
TUPLE_CLASS_BOILERPLATE(OmpIteratorSpecifier);
CharBlock source;
std::tuple<TypeDeclarationStmt, SubscriptTriplet> t;
};

// Ref: [5.0:47-49], [5.1:49-51], [5.2:67-69]
//
// iterator-modifier ->
Expand Down Expand Up @@ -3901,21 +3939,28 @@ struct OmpMapper {
WRAPPER_CLASS_BOILERPLATE(OmpMapper, Name);
};

// Ref: [4.5:216-219], [5.0:315-324], [5.1:347-355], [5.2:150-158]
// Ref: [4.5:216-219], [5.0:315-324], [5.1:347-355], [5.2:150-158],
// [6.0:279-288]
//
// map-type ->
// ALLOC | DELETE | FROM | RELEASE | TO | TOFROM // since 4.5
// ALLOC | DELETE | RELEASE | // since 4.5, until 5.2
// FROM | TO | TOFROM | // since 4.5
// STORAGE // since 6.0
//
// Since 6.0 DELETE is a separate delete-modifier.
struct OmpMapType {
ENUM_CLASS(Value, Alloc, Delete, From, Release, To, Tofrom);
ENUM_CLASS(Value, Alloc, Delete, From, Release, Storage, To, Tofrom);
WRAPPER_CLASS_BOILERPLATE(OmpMapType, Value);
};

// Ref: [4.5:216-219], [5.0:315-324], [5.1:347-355], [5.2:150-158]
//
// map-type-modifier ->
// ALWAYS | // since 4.5
// CLOSE | // since 5.0
// PRESENT // since 5.1
// ALWAYS | // since 4.5, until 5.2
// CLOSE | // since 5.0, until 5.2
// PRESENT // since 5.1, until 5.2
// Since 6.0 the map-type-modifier has been split into individual modifiers.
//
struct OmpMapTypeModifier {
ENUM_CLASS(Value, Always, Close, Present, Ompx_Hold)
WRAPPER_CLASS_BOILERPLATE(OmpMapTypeModifier, Value);
Expand Down Expand Up @@ -3954,6 +3999,19 @@ struct OmpPrescriptiveness {
WRAPPER_CLASS_BOILERPLATE(OmpPrescriptiveness, Value);
};

// Ref: [4.5:216-219], [5.0:315-324], [5.1:347-355], [5.2:150-158],
// [6.0:279-288]
//
// present-modifier ->
// PRESENT // since 5.1
//
// Until 5.2, it was a part of map-type-modifier. Since 6.0 the
// map-type-modifier has been split into individual modifiers.
struct OmpPresentModifier {
ENUM_CLASS(Value, Present)
WRAPPER_CLASS_BOILERPLATE(OmpPresentModifier, Value);
};

// Ref: [5.0:300-302], [5.1:332-334], [5.2:134-137]
//
// reduction-modifier ->
Expand All @@ -3963,6 +4021,26 @@ struct OmpReductionModifier {
WRAPPER_CLASS_BOILERPLATE(OmpReductionModifier, Value);
};

// Ref: [6.0:279-288]
//
// ref-modifier ->
// REF_PTEE | REF_PTR | REF_PTR_PTEE // since 6.0
//
struct OmpRefModifier {
ENUM_CLASS(Value, Ref_Ptee, Ref_Ptr, Ref_Ptr_Ptee)
WRAPPER_CLASS_BOILERPLATE(OmpRefModifier, Value);
};

// Ref: [6.0:279-288]
//
// self-modifier ->
// SELF // since 6.0
//
struct OmpSelfModifier {
ENUM_CLASS(Value, Self)
WRAPPER_CLASS_BOILERPLATE(OmpSelfModifier, Value);
};

// Ref: [5.2:117-120]
//
// step-complex-modifier ->
Expand Down Expand Up @@ -4001,6 +4079,18 @@ struct OmpVariableCategory {
WRAPPER_CLASS_BOILERPLATE(OmpVariableCategory, Value);
};

// Extension
//
// ompx-hold-modifier ->
// OMPX_HOLD // since 4.5
//
// Until 5.2, it was a part of map-type-modifier. Since 6.0 the
// map-type-modifier has been split into individual modifiers.
struct OmpxHoldModifier {
ENUM_CLASS(Value, Ompx_Hold)
WRAPPER_CLASS_BOILERPLATE(OmpxHoldModifier, Value);
};

// context-selector
using OmpContextSelector = traits::OmpContextSelectorSpecification;
} // namespace modifier
Expand Down Expand Up @@ -4376,13 +4466,25 @@ struct OmpLinearClause {
// map-clause ->
// MAP([modifier...:] locator-list) // since 4.5
// modifier ->
// map-type-modifier | // since 4.5
// map-type-modifier [replaced] | // since 4.5, until 5.2
// always-modifier | // since 6.0
// close-modifier | // since 6.0
// delete-modifier | // since 6.0
// present-modifier | // since 6.0
// ref-modifier | // since 6.0
// self-modifier | // since 6.0
// mapper | // since 5.0
// iterator | // since 5.1
// map-type // since 4.5
// ompx-hold-modifier | // since 6.0
//
// Since 6.0 the map-type-modifier has been split into individual modifiers,
// and delete-modifier has been split from map-type.
struct OmpMapClause {
TUPLE_CLASS_BOILERPLATE(OmpMapClause);
MODIFIER_BOILERPLATE(OmpMapTypeModifier, OmpMapper, OmpIterator, OmpMapType);
MODIFIER_BOILERPLATE(OmpAlwaysModifier, OmpCloseModifier, OmpDeleteModifier,
OmpMapTypeModifier, OmpPresentModifier, OmpRefModifier, OmpSelfModifier,
OmpMapper, OmpIterator, OmpMapType, OmpxHoldModifier);
std::tuple<MODIFIERS(), OmpObjectList, /*CommaSeparated=*/bool> t;
};

Expand Down
7 changes: 7 additions & 0 deletions flang/include/flang/Semantics/openmp-modifiers.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,11 @@ DECLARE_DESCRIPTOR(parser::OmpAlignment);
DECLARE_DESCRIPTOR(parser::OmpAlignModifier);
DECLARE_DESCRIPTOR(parser::OmpAllocatorComplexModifier);
DECLARE_DESCRIPTOR(parser::OmpAllocatorSimpleModifier);
DECLARE_DESCRIPTOR(parser::OmpAlwaysModifier);
DECLARE_DESCRIPTOR(parser::OmpChunkModifier);
DECLARE_DESCRIPTOR(parser::OmpCloseModifier);
DECLARE_DESCRIPTOR(parser::OmpContextSelector);
DECLARE_DESCRIPTOR(parser::OmpDeleteModifier);
DECLARE_DESCRIPTOR(parser::OmpDependenceType);
DECLARE_DESCRIPTOR(parser::OmpDeviceModifier);
DECLARE_DESCRIPTOR(parser::OmpDirectiveNameModifier);
Expand All @@ -88,12 +91,16 @@ DECLARE_DESCRIPTOR(parser::OmpMapTypeModifier);
DECLARE_DESCRIPTOR(parser::OmpOrderModifier);
DECLARE_DESCRIPTOR(parser::OmpOrderingModifier);
DECLARE_DESCRIPTOR(parser::OmpPrescriptiveness);
DECLARE_DESCRIPTOR(parser::OmpPresentModifier);
DECLARE_DESCRIPTOR(parser::OmpReductionIdentifier);
DECLARE_DESCRIPTOR(parser::OmpReductionModifier);
DECLARE_DESCRIPTOR(parser::OmpRefModifier);
DECLARE_DESCRIPTOR(parser::OmpSelfModifier);
DECLARE_DESCRIPTOR(parser::OmpStepComplexModifier);
DECLARE_DESCRIPTOR(parser::OmpStepSimpleModifier);
DECLARE_DESCRIPTOR(parser::OmpTaskDependenceType);
DECLARE_DESCRIPTOR(parser::OmpVariableCategory);
DECLARE_DESCRIPTOR(parser::OmpxHoldModifier);

#undef DECLARE_DESCRIPTOR

Expand Down
16 changes: 8 additions & 8 deletions flang/lib/Lower/OpenMP/ClauseProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1315,7 +1315,8 @@ bool ClauseProcessor::processMap(
const parser::CharBlock &source) {
using Map = omp::clause::Map;
mlir::Location clauseLocation = converter.genLocation(source);
const auto &[mapType, typeMods, mappers, iterator, objects] = clause.t;
const auto &[mapType, typeMods, refMod, mappers, iterator, objects] =
clause.t;
llvm::omp::OpenMPOffloadMappingFlags mapTypeBits =
llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_NONE;
std::string mapperIdName = "__implicit_mapper";
Expand All @@ -1342,16 +1343,13 @@ bool ClauseProcessor::processMap(
mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO |
llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM;
break;
case Map::MapType::Alloc:
case Map::MapType::Release:
case Map::MapType::Storage:
// alloc and release is the default map_type for the Target Data
// Ops, i.e. if no bits for map_type is supplied then alloc/release
// is implicitly assumed based on the target directive. Default
// value for Target Data and Enter Data is alloc and for Exit Data
// it is release.
// (aka storage in 6.0+) is implicitly assumed based on the target
// directive. Default value for Target Data and Enter Data is alloc
// and for Exit Data it is release.
break;
case Map::MapType::Delete:
mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_DELETE;
}

if (typeMods) {
Expand All @@ -1362,6 +1360,8 @@ bool ClauseProcessor::processMap(
mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_PRESENT;
if (llvm::is_contained(*typeMods, Map::MapTypeModifier::Close))
mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_CLOSE;
if (llvm::is_contained(*typeMods, Map::MapTypeModifier::Delete))
mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_DELETE;
if (llvm::is_contained(*typeMods, Map::MapTypeModifier::OmpxHold))
mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_OMPX_HOLD;
}
Expand Down
Loading
Loading