Skip to content

Commit e06f3e0

Browse files
chichunchenalexey-bataev
authored andcommitted
[OpenMP 5.0] - Extend defaultmap, by Chi Chun Chen.
Summary: For the extended defaultmap, most of the work is inside sema. The only difference for codegen is to set different initial maptype for different implicit-behavior. Reviewers: jdoerfert, ABataev Reviewed By: ABataev Subscribers: dreachem, sandoval, cfe-commits Tags: #clang, #openmp Differential Revision: https://reviews.llvm.org/D69204
1 parent d6de5f1 commit e06f3e0

17 files changed

+3151
-478
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9169,8 +9169,12 @@ def err_omp_threadprivate_incomplete_type : Error<
91699169
"threadprivate variable with incomplete type %0">;
91709170
def err_omp_no_dsa_for_variable : Error<
91719171
"variable %0 must have explicitly specified data sharing attributes">;
9172+
def err_omp_defaultmap_no_attr_for_variable : Error<
9173+
"variable %0 must have explicitly specified data sharing attributes, data mapping attributes, or in an is_device_ptr clause">;
91729174
def note_omp_default_dsa_none : Note<
91739175
"explicit data sharing attribute requested here">;
9176+
def note_omp_defaultmap_attr_none : Note<
9177+
"explicit data sharing attribute, data mapping attribute, or is_device_ptr clause requested here">;
91749178
def err_omp_wrong_dsa : Error<
91759179
"%0 variable cannot be %1">;
91769180
def err_omp_variably_modified_type_not_supported : Error<
@@ -9599,6 +9603,8 @@ def warn_omp_declare_variant_marked_as_declare_variant : Warning<
95999603
"variant function in '#pragma omp declare variant' is itself marked as '#pragma omp declare variant'"
96009604
>, InGroup<SourceUsesOpenMP>;
96019605
def note_omp_marked_declare_variant_here : Note<"marked as 'declare variant' here">;
9606+
def err_omp_one_defaultmap_each_category: Error<
9607+
"at most one defaultmap clause for each variable-category can appear on the directive">;
96029608
} // end of OpenMP category
96039609

96049610
let CategoryName = "Related Result Type Issue" in {

clang/include/clang/Basic/OpenMPKinds.def

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,9 +435,17 @@ OPENMP_SCHEDULE_MODIFIER(simd)
435435

436436
// Static attributes for 'defaultmap' clause.
437437
OPENMP_DEFAULTMAP_KIND(scalar)
438+
OPENMP_DEFAULTMAP_KIND(aggregate)
439+
OPENMP_DEFAULTMAP_KIND(pointer)
438440

439441
// Modifiers for 'defaultmap' clause.
442+
OPENMP_DEFAULTMAP_MODIFIER(alloc)
443+
OPENMP_DEFAULTMAP_MODIFIER(to)
444+
OPENMP_DEFAULTMAP_MODIFIER(from)
440445
OPENMP_DEFAULTMAP_MODIFIER(tofrom)
446+
OPENMP_DEFAULTMAP_MODIFIER(firstprivate)
447+
OPENMP_DEFAULTMAP_MODIFIER(none)
448+
OPENMP_DEFAULTMAP_MODIFIER(default)
441449

442450
// Static attributes for 'depend' clause.
443451
OPENMP_DEPEND_KIND(in)

clang/lib/Parse/ParseOpenMP.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2018,15 +2018,15 @@ OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind DKind,
20182018
case OMPC_defaultmap:
20192019
// OpenMP [2.7.1, Restrictions, p. 3]
20202020
// Only one schedule clause can appear on a loop directive.
2021-
// OpenMP [2.10.4, Restrictions, p. 106]
2021+
// OpenMP 4.5 [2.10.4, Restrictions, p. 106]
20222022
// At most one defaultmap clause can appear on the directive.
2023-
if (!FirstClause) {
2023+
if ((getLangOpts().OpenMP < 50 || CKind != OMPC_defaultmap) &&
2024+
!FirstClause) {
20242025
Diag(Tok, diag::err_omp_more_one_clause)
20252026
<< getOpenMPDirectiveName(DKind) << getOpenMPClauseName(CKind) << 0;
20262027
ErrorFound = true;
20272028
}
20282029
LLVM_FALLTHROUGH;
2029-
20302030
case OMPC_if:
20312031
Clause = ParseOpenMPSingleExprWithArgClause(CKind, WrongDirective);
20322032
break;
@@ -2310,8 +2310,13 @@ OMPClause *Parser::ParseOpenMPSingleExprWithArgClause(OpenMPClauseKind Kind,
23102310
DelimLoc = ConsumeAnyToken();
23112311
} else if (Kind == OMPC_defaultmap) {
23122312
// Get a defaultmap modifier
2313-
Arg.push_back(getOpenMPSimpleClauseType(
2314-
Kind, Tok.isAnnotation() ? "" : PP.getSpelling(Tok)));
2313+
unsigned Modifier = getOpenMPSimpleClauseType(
2314+
Kind, Tok.isAnnotation() ? "" : PP.getSpelling(Tok));
2315+
// Set defaultmap modifier to unknown if it is either scalar, aggregate, or
2316+
// pointer
2317+
if (Modifier < OMPC_DEFAULTMAP_MODIFIER_unknown)
2318+
Modifier = OMPC_DEFAULTMAP_MODIFIER_unknown;
2319+
Arg.push_back(Modifier);
23152320
KLoc.push_back(Tok.getLocation());
23162321
if (Tok.isNot(tok::r_paren) && Tok.isNot(tok::comma) &&
23172322
Tok.isNot(tok::annot_pragma_openmp_end))

0 commit comments

Comments
 (0)