Skip to content

Commit 63635c1

Browse files
[clang] [OpenMP] New OpenMP 6.0 self_maps clause (#129888)
Initial parsing/sema support for self maps in map and requirement clause [Sections 7.9.6 and 10.5.1.6 in OpenMP 6.0 spec]
1 parent 4d17ae7 commit 63635c1

25 files changed

+213
-8
lines changed

clang/docs/OpenMPSupport.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ implementation.
408408
+-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+
409409
| Private reductions | :none:`unclaimed` | :none:`unclaimed` | |
410410
+-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+
411-
| Self maps | :none:`unclaimed` | :none:`unclaimed` | |
411+
| Self maps | :part:`partial` | :none:`unclaimed` | parsing/sema done: https://github.com/llvm/llvm-project/pull/129888 |
412412
+-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+
413413
| Release map type for declare mapper | :none:`unclaimed` | :none:`unclaimed` | |
414414
+-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,7 @@ Python Binding Changes
458458
OpenMP Support
459459
--------------
460460
- Added support 'no_openmp_constructs' assumption clause.
461+
- Added support for 'self_maps' in map and requirement clause.
461462
- Added support for 'omp stripe' directive.
462463

463464
Improvements

clang/include/clang/AST/OpenMPClause.h

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1656,6 +1656,49 @@ class OMPAtomicDefaultMemOrderClause final : public OMPClause {
16561656
}
16571657
};
16581658

1659+
/// This represents 'self_maps' clause in the '#pragma omp requires'
1660+
/// directive.
1661+
///
1662+
/// \code
1663+
/// #pragma omp requires self_maps
1664+
/// \endcode
1665+
/// In this example directive '#pragma omp requires' has 'self_maps'
1666+
/// clause.
1667+
class OMPSelfMapsClause final : public OMPClause {
1668+
public:
1669+
friend class OMPClauseReader;
1670+
/// Build 'self_maps' clause.
1671+
///
1672+
/// \param StartLoc Starting location of the clause.
1673+
/// \param EndLoc Ending location of the clause.
1674+
OMPSelfMapsClause(SourceLocation StartLoc, SourceLocation EndLoc)
1675+
: OMPClause(llvm::omp::OMPC_self_maps, StartLoc, EndLoc) {}
1676+
1677+
/// Build an empty clause.
1678+
OMPSelfMapsClause()
1679+
: OMPClause(llvm::omp::OMPC_self_maps, SourceLocation(),
1680+
SourceLocation()) {}
1681+
1682+
child_range children() {
1683+
return child_range(child_iterator(), child_iterator());
1684+
}
1685+
1686+
const_child_range children() const {
1687+
return const_child_range(const_child_iterator(), const_child_iterator());
1688+
}
1689+
1690+
child_range used_children() {
1691+
return child_range(child_iterator(), child_iterator());
1692+
}
1693+
const_child_range used_children() const {
1694+
return const_child_range(const_child_iterator(), const_child_iterator());
1695+
}
1696+
1697+
static bool classof(const OMPClause *T) {
1698+
return T->getClauseKind() == llvm::omp::OMPC_self_maps;
1699+
}
1700+
};
1701+
16591702
/// This represents 'at' clause in the '#pragma omp error' directive
16601703
///
16611704
/// \code
@@ -6349,7 +6392,8 @@ class OMPMapClause final : public OMPMappableExprListClause<OMPMapClause>,
63496392
OpenMPMapModifierKind MapTypeModifiers[NumberOfOMPMapClauseModifiers] = {
63506393
OMPC_MAP_MODIFIER_unknown, OMPC_MAP_MODIFIER_unknown,
63516394
OMPC_MAP_MODIFIER_unknown, OMPC_MAP_MODIFIER_unknown,
6352-
OMPC_MAP_MODIFIER_unknown, OMPC_MAP_MODIFIER_unknown};
6395+
OMPC_MAP_MODIFIER_unknown, OMPC_MAP_MODIFIER_unknown,
6396+
OMPC_MAP_MODIFIER_unknown};
63536397

63546398
/// Location of map-type-modifiers for the 'map' clause.
63556399
SourceLocation MapTypeModifiersLoc[NumberOfOMPMapClauseModifiers];

clang/include/clang/AST/RecursiveASTVisitor.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3443,6 +3443,11 @@ bool RecursiveASTVisitor<Derived>::VisitOMPAtomicDefaultMemOrderClause(
34433443
return true;
34443444
}
34453445

3446+
template <typename Derived>
3447+
bool RecursiveASTVisitor<Derived>::VisitOMPSelfMapsClause(OMPSelfMapsClause *) {
3448+
return true;
3449+
}
3450+
34463451
template <typename Derived>
34473452
bool RecursiveASTVisitor<Derived>::VisitOMPAtClause(OMPAtClause *) {
34483453
return true;

clang/include/clang/Basic/DiagnosticParseKinds.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1495,7 +1495,7 @@ def note_previous_map_type_specified_here
14951495
: Note<"map type '%0' is previous specified here">;
14961496
def err_omp_unknown_map_type_modifier : Error<
14971497
"incorrect map type modifier, expected one of: 'always', 'close', 'mapper'"
1498-
"%select{|, 'present'|, 'present', 'iterator'}0%select{|, 'ompx_hold'}1">;
1498+
"%select{|, 'present'|, 'present', 'iterator'}0%select{|, 'ompx_hold'}1%select{|, 'self'}2">;
14991499
def err_omp_map_type_missing : Error<
15001500
"missing map type">;
15011501
def err_omp_map_type_modifier_missing : Error<

clang/include/clang/Basic/OpenMPKinds.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ OPENMP_MAP_MODIFIER_KIND(close)
172172
OPENMP_MAP_MODIFIER_KIND(mapper)
173173
OPENMP_MAP_MODIFIER_KIND(iterator)
174174
OPENMP_MAP_MODIFIER_KIND(present)
175+
OPENMP_MAP_MODIFIER_KIND(self)
175176
// This is an OpenMP extension for the sake of OpenACC support.
176177
OPENMP_MAP_MODIFIER_KIND(ompx_hold)
177178

clang/include/clang/Sema/SemaOpenMP.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,6 +1112,10 @@ class SemaOpenMP : public SemaBase {
11121112
OpenMPAtomicDefaultMemOrderClauseKind Kind, SourceLocation KindLoc,
11131113
SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc);
11141114

1115+
/// Called on well-formed 'self_maps' clause.
1116+
OMPClause *ActOnOpenMPSelfMapsClause(SourceLocation StartLoc,
1117+
SourceLocation EndLoc);
1118+
11151119
/// Called on well-formed 'at' clause.
11161120
OMPClause *ActOnOpenMPAtClause(OpenMPAtClauseKind Kind,
11171121
SourceLocation KindLoc,

clang/lib/AST/OpenMPClause.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ const OMPClauseWithPreInit *OMPClauseWithPreInit::get(const OMPClause *C) {
155155
case OMPC_reverse_offload:
156156
case OMPC_dynamic_allocators:
157157
case OMPC_atomic_default_mem_order:
158+
case OMPC_self_maps:
158159
case OMPC_at:
159160
case OMPC_severity:
160161
case OMPC_message:
@@ -259,6 +260,7 @@ const OMPClauseWithPostUpdate *OMPClauseWithPostUpdate::get(const OMPClause *C)
259260
case OMPC_reverse_offload:
260261
case OMPC_dynamic_allocators:
261262
case OMPC_atomic_default_mem_order:
263+
case OMPC_self_maps:
262264
case OMPC_at:
263265
case OMPC_severity:
264266
case OMPC_message:
@@ -1941,6 +1943,10 @@ void OMPClausePrinter::VisitOMPAtomicDefaultMemOrderClause(
19411943
<< ")";
19421944
}
19431945

1946+
void OMPClausePrinter::VisitOMPSelfMapsClause(OMPSelfMapsClause *) {
1947+
OS << "self_maps";
1948+
}
1949+
19441950
void OMPClausePrinter::VisitOMPAtClause(OMPAtClause *Node) {
19451951
OS << "at(" << getOpenMPSimpleClauseTypeName(OMPC_at, Node->getAtKind())
19461952
<< ")";

clang/lib/AST/StmtProfile.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,8 @@ void OMPClauseProfiler::VisitOMPDynamicAllocatorsClause(
557557
void OMPClauseProfiler::VisitOMPAtomicDefaultMemOrderClause(
558558
const OMPAtomicDefaultMemOrderClause *C) {}
559559

560+
void OMPClauseProfiler::VisitOMPSelfMapsClause(const OMPSelfMapsClause *C) {}
561+
560562
void OMPClauseProfiler::VisitOMPAtClause(const OMPAtClause *C) {}
561563

562564
void OMPClauseProfiler::VisitOMPSeverityClause(const OMPSeverityClause *C) {}

clang/lib/Basic/OpenMPKinds.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ unsigned clang::getOpenMPSimpleClauseType(OpenMPClauseKind Kind, StringRef Str,
235235
case OMPC_unified_shared_memory:
236236
case OMPC_reverse_offload:
237237
case OMPC_dynamic_allocators:
238+
case OMPC_self_maps:
238239
case OMPC_match:
239240
case OMPC_nontemporal:
240241
case OMPC_destroy:
@@ -569,6 +570,7 @@ const char *clang::getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind,
569570
case OMPC_unified_shared_memory:
570571
case OMPC_reverse_offload:
571572
case OMPC_dynamic_allocators:
573+
case OMPC_self_maps:
572574
case OMPC_match:
573575
case OMPC_nontemporal:
574576
case OMPC_destroy:

0 commit comments

Comments
 (0)