Skip to content

Commit 1703aa6

Browse files
author
Sunil Kuravinakop
committed
Support for dispatch construct (Sema & Codegen) support. Support for clauses depend, novariants & nocontext.
1 parent 7ed36b9 commit 1703aa6

File tree

11 files changed

+687
-14
lines changed

11 files changed

+687
-14
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11774,6 +11774,9 @@ def err_omp_clause_requires_dispatch_construct : Error<
1177411774
"'%0' clause requires 'dispatch' context selector">;
1177511775
def err_omp_append_args_with_varargs : Error<
1177611776
"'append_args' is not allowed with varargs functions">;
11777+
def warn_omp_dispatch_clause_novariants_nocontext : Warning<
11778+
"only 'novariants' clause is supported when 'novariants' & 'nocontext' clauses occur on the same dispatch construct">,
11779+
InGroup<SourceUsesOpenMP>;
1177711780
def err_openmp_vla_in_task_untied : Error<
1177811781
"variable length arrays are not supported in OpenMP tasking regions with 'untied' clause">;
1177911782
def warn_omp_unterminated_declare_target : Warning<

clang/include/clang/Basic/OpenMPKinds.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,12 @@ bool isOpenMPTaskLoopDirective(OpenMPDirectiveKind DKind);
269269
/// parallel', otherwise - false.
270270
bool isOpenMPParallelDirective(OpenMPDirectiveKind DKind);
271271

272+
/// Checks if the specified directive is a dispatch-kind directive.
273+
/// \param DKind Specified directive.
274+
/// \return true - the directive is a dispatch-like directive like 'omp
275+
/// dispatch', otherwise - false.
276+
bool isOpenMPDispatchDirective(OpenMPDirectiveKind DKind);
277+
272278
/// Checks if the specified directive is a target code offload directive.
273279
/// \param DKind Specified directive.
274280
/// \return true - the directive is a target code offload directive like

clang/include/clang/Sema/SemaOpenMP.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,6 +1462,13 @@ class SemaOpenMP : public SemaBase {
14621462
: OMPDeclareVariantScopes.back().TI;
14631463
}
14641464

1465+
StmtResult transformDispatchDirective(OpenMPDirectiveKind Kind,
1466+
const DeclarationNameInfo &DirName,
1467+
OpenMPDirectiveKind CancelRegion,
1468+
ArrayRef<OMPClause *> Clauses,
1469+
Stmt *AStmt, SourceLocation StartLoc,
1470+
SourceLocation EndLoc);
1471+
14651472
/// The current `omp begin/end declare variant` scopes.
14661473
SmallVector<OMPDeclareVariantScope, 4> OMPDeclareVariantScopes;
14671474

clang/lib/Basic/OpenMPKinds.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,11 @@ bool clang::isOpenMPParallelDirective(OpenMPDirectiveKind DKind) {
621621
llvm::is_contained(getLeafConstructs(DKind), OMPD_parallel);
622622
}
623623

624+
bool clang::isOpenMPDispatchDirective(OpenMPDirectiveKind DKind) {
625+
return DKind == OMPD_dispatch ||
626+
llvm::is_contained(getLeafConstructs(DKind), OMPD_target);
627+
}
628+
624629
bool clang::isOpenMPTargetExecutionDirective(OpenMPDirectiveKind DKind) {
625630
return DKind == OMPD_target ||
626631
llvm::is_contained(getLeafConstructs(DKind), OMPD_target);

clang/lib/CodeGen/CGStmt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ void CodeGenFunction::EmitStmt(const Stmt *S, ArrayRef<const Attr *> Attrs) {
417417
EmitOMPInteropDirective(cast<OMPInteropDirective>(*S));
418418
break;
419419
case Stmt::OMPDispatchDirectiveClass:
420-
CGM.ErrorUnsupported(S, "OpenMP dispatch directive");
420+
EmitOMPDispatchDirective(cast<OMPDispatchDirective>(*S));
421421
break;
422422
case Stmt::OMPScopeDirectiveClass:
423423
EmitOMPScopeDirective(cast<OMPScopeDirective>(*S));

clang/lib/CodeGen/CGStmtOpenMP.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4452,6 +4452,10 @@ void CodeGenFunction::EmitOMPMasterDirective(const OMPMasterDirective &S) {
44524452
emitMaster(*this, S);
44534453
}
44544454

4455+
void CodeGenFunction::EmitOMPDispatchDirective(const OMPDispatchDirective &S) {
4456+
EmitStmt(S.getAssociatedStmt());
4457+
}
4458+
44554459
static void emitMasked(CodeGenFunction &CGF, const OMPExecutableDirective &S) {
44564460
auto &&CodeGen = [&S](CodeGenFunction &CGF, PrePostActionTy &Action) {
44574461
Action.Enter(CGF);

clang/lib/CodeGen/CodeGenFunction.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3830,6 +3830,7 @@ class CodeGenFunction : public CodeGenTypeCache {
38303830
void EmitOMPSectionDirective(const OMPSectionDirective &S);
38313831
void EmitOMPSingleDirective(const OMPSingleDirective &S);
38323832
void EmitOMPMasterDirective(const OMPMasterDirective &S);
3833+
void EmitOMPDispatchDirective(const OMPDispatchDirective &S);
38333834
void EmitOMPMaskedDirective(const OMPMaskedDirective &S);
38343835
void EmitOMPCriticalDirective(const OMPCriticalDirective &S);
38353836
void EmitOMPParallelForDirective(const OMPParallelForDirective &S);

0 commit comments

Comments
 (0)