Skip to content

Commit

Permalink
[OpenMP 5.0] - Extend defaultmap, by Chi Chun Chen.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
chichunchen authored and alexey-bataev committed Nov 15, 2019
1 parent d6de5f1 commit e06f3e0
Show file tree
Hide file tree
Showing 17 changed files with 3,151 additions and 478 deletions.
6 changes: 6 additions & 0 deletions clang/include/clang/Basic/DiagnosticSemaKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -9169,8 +9169,12 @@ def err_omp_threadprivate_incomplete_type : Error<
"threadprivate variable with incomplete type %0">;
def err_omp_no_dsa_for_variable : Error<
"variable %0 must have explicitly specified data sharing attributes">;
def err_omp_defaultmap_no_attr_for_variable : Error<
"variable %0 must have explicitly specified data sharing attributes, data mapping attributes, or in an is_device_ptr clause">;
def note_omp_default_dsa_none : Note<
"explicit data sharing attribute requested here">;
def note_omp_defaultmap_attr_none : Note<
"explicit data sharing attribute, data mapping attribute, or is_device_ptr clause requested here">;
def err_omp_wrong_dsa : Error<
"%0 variable cannot be %1">;
def err_omp_variably_modified_type_not_supported : Error<
Expand Down Expand Up @@ -9599,6 +9603,8 @@ def warn_omp_declare_variant_marked_as_declare_variant : Warning<
"variant function in '#pragma omp declare variant' is itself marked as '#pragma omp declare variant'"
>, InGroup<SourceUsesOpenMP>;
def note_omp_marked_declare_variant_here : Note<"marked as 'declare variant' here">;
def err_omp_one_defaultmap_each_category: Error<
"at most one defaultmap clause for each variable-category can appear on the directive">;
} // end of OpenMP category

let CategoryName = "Related Result Type Issue" in {
Expand Down
8 changes: 8 additions & 0 deletions clang/include/clang/Basic/OpenMPKinds.def
Original file line number Diff line number Diff line change
Expand Up @@ -435,9 +435,17 @@ OPENMP_SCHEDULE_MODIFIER(simd)

// Static attributes for 'defaultmap' clause.
OPENMP_DEFAULTMAP_KIND(scalar)
OPENMP_DEFAULTMAP_KIND(aggregate)
OPENMP_DEFAULTMAP_KIND(pointer)

// Modifiers for 'defaultmap' clause.
OPENMP_DEFAULTMAP_MODIFIER(alloc)
OPENMP_DEFAULTMAP_MODIFIER(to)
OPENMP_DEFAULTMAP_MODIFIER(from)
OPENMP_DEFAULTMAP_MODIFIER(tofrom)
OPENMP_DEFAULTMAP_MODIFIER(firstprivate)
OPENMP_DEFAULTMAP_MODIFIER(none)
OPENMP_DEFAULTMAP_MODIFIER(default)

// Static attributes for 'depend' clause.
OPENMP_DEPEND_KIND(in)
Expand Down
15 changes: 10 additions & 5 deletions clang/lib/Parse/ParseOpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2018,15 +2018,15 @@ OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind DKind,
case OMPC_defaultmap:
// OpenMP [2.7.1, Restrictions, p. 3]
// Only one schedule clause can appear on a loop directive.
// OpenMP [2.10.4, Restrictions, p. 106]
// OpenMP 4.5 [2.10.4, Restrictions, p. 106]
// At most one defaultmap clause can appear on the directive.
if (!FirstClause) {
if ((getLangOpts().OpenMP < 50 || CKind != OMPC_defaultmap) &&
!FirstClause) {
Diag(Tok, diag::err_omp_more_one_clause)
<< getOpenMPDirectiveName(DKind) << getOpenMPClauseName(CKind) << 0;
ErrorFound = true;
}
LLVM_FALLTHROUGH;

case OMPC_if:
Clause = ParseOpenMPSingleExprWithArgClause(CKind, WrongDirective);
break;
Expand Down Expand Up @@ -2310,8 +2310,13 @@ OMPClause *Parser::ParseOpenMPSingleExprWithArgClause(OpenMPClauseKind Kind,
DelimLoc = ConsumeAnyToken();
} else if (Kind == OMPC_defaultmap) {
// Get a defaultmap modifier
Arg.push_back(getOpenMPSimpleClauseType(
Kind, Tok.isAnnotation() ? "" : PP.getSpelling(Tok)));
unsigned Modifier = getOpenMPSimpleClauseType(
Kind, Tok.isAnnotation() ? "" : PP.getSpelling(Tok));
// Set defaultmap modifier to unknown if it is either scalar, aggregate, or
// pointer
if (Modifier < OMPC_DEFAULTMAP_MODIFIER_unknown)
Modifier = OMPC_DEFAULTMAP_MODIFIER_unknown;
Arg.push_back(Modifier);
KLoc.push_back(Tok.getLocation());
if (Tok.isNot(tok::r_paren) && Tok.isNot(tok::comma) &&
Tok.isNot(tok::annot_pragma_openmp_end))
Expand Down
Loading

0 comments on commit e06f3e0

Please sign in to comment.