From 653a638f94e456b8ad5d979fba814d6e3708f950 Mon Sep 17 00:00:00 2001 From: Alexey Bataev Date: Fri, 18 Oct 2019 16:47:35 +0000 Subject: [OPENMP50]Add support for master taskloop simd. Added trsing/semantics/codegen for combined construct master taskloop simd. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@375255 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang-c/Index.h | 7 +++- include/clang/AST/RecursiveASTVisitor.h | 3 ++ include/clang/AST/StmtOpenMP.h | 68 +++++++++++++++++++++++++++++++ include/clang/Basic/OpenMPKinds.def | 28 +++++++++++++ include/clang/Basic/OpenMPKinds.h | 3 +- include/clang/Basic/StmtNodes.td | 1 + include/clang/Sema/Sema.h | 5 +++ include/clang/Serialization/ASTBitCodes.h | 1 + 8 files changed, 114 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h index 4917ba5fb5..2268935054 100644 --- a/include/clang-c/Index.h +++ b/include/clang-c/Index.h @@ -2563,7 +2563,12 @@ enum CXCursorKind { */ CXCursor_OMPParallelMasterTaskLoopDirective = 282, - CXCursor_LastStmt = CXCursor_OMPParallelMasterTaskLoopDirective, + /** OpenMP master taskloop simd directive. + */ + CXCursor_OMPMasterTaskLoopSimdDirective = 283, + + + CXCursor_LastStmt = CXCursor_OMPMasterTaskLoopSimdDirective, /** * Cursor that represents the translation unit itself. diff --git a/include/clang/AST/RecursiveASTVisitor.h b/include/clang/AST/RecursiveASTVisitor.h index 951f656270..c01a2da926 100644 --- a/include/clang/AST/RecursiveASTVisitor.h +++ b/include/clang/AST/RecursiveASTVisitor.h @@ -2799,6 +2799,9 @@ DEF_TRAVERSE_STMT(OMPTaskLoopSimdDirective, DEF_TRAVERSE_STMT(OMPMasterTaskLoopDirective, { TRY_TO(TraverseOMPExecutableDirective(S)); }) +DEF_TRAVERSE_STMT(OMPMasterTaskLoopSimdDirective, + { TRY_TO(TraverseOMPExecutableDirective(S)); }) + DEF_TRAVERSE_STMT(OMPParallelMasterTaskLoopDirective, { TRY_TO(TraverseOMPExecutableDirective(S)); }) diff --git a/include/clang/AST/StmtOpenMP.h b/include/clang/AST/StmtOpenMP.h index d8a550a703..ddfb3060b1 100644 --- a/include/clang/AST/StmtOpenMP.h +++ b/include/clang/AST/StmtOpenMP.h @@ -1165,6 +1165,7 @@ public: T->getStmtClass() == OMPTaskLoopDirectiveClass || T->getStmtClass() == OMPTaskLoopSimdDirectiveClass || T->getStmtClass() == OMPMasterTaskLoopDirectiveClass || + T->getStmtClass() == OMPMasterTaskLoopSimdDirectiveClass || T->getStmtClass() == OMPParallelMasterTaskLoopDirectiveClass || T->getStmtClass() == OMPDistributeDirectiveClass || T->getStmtClass() == OMPTargetParallelForDirectiveClass || @@ -3189,6 +3190,73 @@ public: } }; +/// This represents '#pragma omp master taskloop simd' directive. +/// +/// \code +/// #pragma omp master taskloop simd private(a,b) grainsize(val) num_tasks(num) +/// \endcode +/// In this example directive '#pragma omp master taskloop simd' has clauses +/// 'private' with the variables 'a' and 'b', 'grainsize' with expression 'val' +/// and 'num_tasks' with expression 'num'. +/// +class OMPMasterTaskLoopSimdDirective : public OMPLoopDirective { + friend class ASTStmtReader; + /// Build directive with the given start and end location. + /// + /// \param StartLoc Starting location of the directive kind. + /// \param EndLoc Ending location of the directive. + /// \param CollapsedNum Number of collapsed nested loops. + /// \param NumClauses Number of clauses. + /// + OMPMasterTaskLoopSimdDirective(SourceLocation StartLoc, SourceLocation EndLoc, + unsigned CollapsedNum, unsigned NumClauses) + : OMPLoopDirective(this, OMPMasterTaskLoopSimdDirectiveClass, + OMPD_master_taskloop_simd, StartLoc, EndLoc, + CollapsedNum, NumClauses) {} + + /// Build an empty directive. + /// + /// \param CollapsedNum Number of collapsed nested loops. + /// \param NumClauses Number of clauses. + /// + explicit OMPMasterTaskLoopSimdDirective(unsigned CollapsedNum, + unsigned NumClauses) + : OMPLoopDirective(this, OMPMasterTaskLoopSimdDirectiveClass, + OMPD_master_taskloop_simd, SourceLocation(), + SourceLocation(), CollapsedNum, NumClauses) {} + +public: + /// Creates directive with a list of \p Clauses. + /// + /// \param C AST context. + /// \param StartLoc Starting location of the directive kind. + /// \param EndLoc Ending Location of the directive. + /// \param CollapsedNum Number of collapsed loops. + /// \param Clauses List of clauses. + /// \param AssociatedStmt Statement, associated with the directive. + /// \param Exprs Helper expressions for CodeGen. + /// + static OMPMasterTaskLoopSimdDirective * + Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, + unsigned CollapsedNum, ArrayRef Clauses, + Stmt *AssociatedStmt, const HelperExprs &Exprs); + + /// Creates an empty directive with the place for \p NumClauses clauses. + /// + /// \param C AST context. + /// \param CollapsedNum Number of collapsed nested loops. + /// \param NumClauses Number of clauses. + /// + static OMPMasterTaskLoopSimdDirective *CreateEmpty(const ASTContext &C, + unsigned NumClauses, + unsigned CollapsedNum, + EmptyShell); + + static bool classof(const Stmt *T) { + return T->getStmtClass() == OMPMasterTaskLoopSimdDirectiveClass; + } +}; + /// This represents '#pragma omp parallel master taskloop' directive. /// /// \code diff --git a/include/clang/Basic/OpenMPKinds.def b/include/clang/Basic/OpenMPKinds.def index 9c592251c6..ff8f07aa5d 100644 --- a/include/clang/Basic/OpenMPKinds.def +++ b/include/clang/Basic/OpenMPKinds.def @@ -95,6 +95,9 @@ #ifndef OPENMP_MASTER_TASKLOOP_CLAUSE # define OPENMP_MASTER_TASKLOOP_CLAUSE(Name) #endif +#ifndef OPENMP_MASTER_TASKLOOP_SIMD_CLAUSE +# define OPENMP_MASTER_TASKLOOP_SIMD_CLAUSE(Name) +#endif #ifndef OPENMP_PARALLEL_MASTER_TASKLOOP_CLAUSE # define OPENMP_PARALLEL_MASTER_TASKLOOP_CLAUSE(Name) #endif @@ -266,6 +269,7 @@ OPENMP_DIRECTIVE(allocate) OPENMP_DIRECTIVE_EXT(declare_variant, "declare variant") OPENMP_DIRECTIVE_EXT(master_taskloop, "master taskloop") OPENMP_DIRECTIVE_EXT(parallel_master_taskloop, "parallel master taskloop") +OPENMP_DIRECTIVE_EXT(master_taskloop_simd, "master taskloop simd") // OpenMP clauses. OPENMP_CLAUSE(allocator, OMPAllocatorClause) @@ -693,6 +697,29 @@ OPENMP_MASTER_TASKLOOP_CLAUSE(reduction) OPENMP_MASTER_TASKLOOP_CLAUSE(in_reduction) OPENMP_MASTER_TASKLOOP_CLAUSE(allocate) +// Clauses allowed for OpenMP directive 'master taskloop simd'. +OPENMP_MASTER_TASKLOOP_SIMD_CLAUSE(if) +OPENMP_MASTER_TASKLOOP_SIMD_CLAUSE(shared) +OPENMP_MASTER_TASKLOOP_SIMD_CLAUSE(private) +OPENMP_MASTER_TASKLOOP_SIMD_CLAUSE(firstprivate) +OPENMP_MASTER_TASKLOOP_SIMD_CLAUSE(lastprivate) +OPENMP_MASTER_TASKLOOP_SIMD_CLAUSE(default) +OPENMP_MASTER_TASKLOOP_SIMD_CLAUSE(collapse) +OPENMP_MASTER_TASKLOOP_SIMD_CLAUSE(final) +OPENMP_MASTER_TASKLOOP_SIMD_CLAUSE(untied) +OPENMP_MASTER_TASKLOOP_SIMD_CLAUSE(mergeable) +OPENMP_MASTER_TASKLOOP_SIMD_CLAUSE(priority) +OPENMP_MASTER_TASKLOOP_SIMD_CLAUSE(linear) +OPENMP_MASTER_TASKLOOP_SIMD_CLAUSE(aligned) +OPENMP_MASTER_TASKLOOP_SIMD_CLAUSE(safelen) +OPENMP_MASTER_TASKLOOP_SIMD_CLAUSE(simdlen) +OPENMP_MASTER_TASKLOOP_SIMD_CLAUSE(grainsize) +OPENMP_MASTER_TASKLOOP_SIMD_CLAUSE(nogroup) +OPENMP_MASTER_TASKLOOP_SIMD_CLAUSE(num_tasks) +OPENMP_MASTER_TASKLOOP_SIMD_CLAUSE(reduction) +OPENMP_MASTER_TASKLOOP_SIMD_CLAUSE(in_reduction) +OPENMP_MASTER_TASKLOOP_SIMD_CLAUSE(allocate) + // Clauses allowed for OpenMP directive 'parallel master taskloop'. OPENMP_PARALLEL_MASTER_TASKLOOP_CLAUSE(if) OPENMP_PARALLEL_MASTER_TASKLOOP_CLAUSE(shared) @@ -1027,6 +1054,7 @@ OPENMP_MATCH_KIND(implementation) #undef OPENMP_DECLARE_MAPPER_CLAUSE #undef OPENMP_TASKGROUP_CLAUSE #undef OPENMP_PARALLEL_MASTER_TASKLOOP_CLAUSE +#undef OPENMP_MASTER_TASKLOOP_SIMD_CLAUSE #undef OPENMP_MASTER_TASKLOOP_CLAUSE #undef OPENMP_TASKLOOP_SIMD_CLAUSE #undef OPENMP_TASKLOOP_CLAUSE diff --git a/include/clang/Basic/OpenMPKinds.h b/include/clang/Basic/OpenMPKinds.h index fe0ba51bec..4129cca0fe 100644 --- a/include/clang/Basic/OpenMPKinds.h +++ b/include/clang/Basic/OpenMPKinds.h @@ -269,7 +269,8 @@ bool isOpenMPPrivate(OpenMPClauseKind Kind); bool isOpenMPThreadPrivate(OpenMPClauseKind Kind); /// Checks if the specified directive kind is one of tasking directives - task, -/// taskloop or taksloop simd. +/// taskloop, taksloop simd, master taskloop, parallel master taskloop or master +/// taskloop simd. bool isOpenMPTaskingDirective(OpenMPDirectiveKind Kind); /// Checks if the specified directive kind is one of the composite or combined diff --git a/include/clang/Basic/StmtNodes.td b/include/clang/Basic/StmtNodes.td index 6231484e2b..8d972f75e4 100644 --- a/include/clang/Basic/StmtNodes.td +++ b/include/clang/Basic/StmtNodes.td @@ -246,6 +246,7 @@ def OMPCancelDirective : DStmt; def OMPTaskLoopDirective : DStmt; def OMPTaskLoopSimdDirective : DStmt; def OMPMasterTaskLoopDirective : DStmt; +def OMPMasterTaskLoopSimdDirective : DStmt; def OMPParallelMasterTaskLoopDirective : DStmt; def OMPDistributeDirective : DStmt; def OMPDistributeParallelForDirective : DStmt; diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index d2798eaf65..d3481af50a 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -9578,6 +9578,11 @@ public: StmtResult ActOnOpenMPMasterTaskLoopDirective( ArrayRef Clauses, Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); + /// Called on well-formed '\#pragma omp master taskloop simd' after parsing of + /// the associated statement. + StmtResult ActOnOpenMPMasterTaskLoopSimdDirective( + ArrayRef Clauses, Stmt *AStmt, SourceLocation StartLoc, + SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); /// Called on well-formed '\#pragma omp parallel master taskloop' after /// parsing of the associated statement. StmtResult ActOnOpenMPParallelMasterTaskLoopDirective( diff --git a/include/clang/Serialization/ASTBitCodes.h b/include/clang/Serialization/ASTBitCodes.h index 0d3971dd27..b95c281a58 100644 --- a/include/clang/Serialization/ASTBitCodes.h +++ b/include/clang/Serialization/ASTBitCodes.h @@ -1966,6 +1966,7 @@ namespace serialization { STMT_OMP_TASKLOOP_DIRECTIVE, STMT_OMP_TASKLOOP_SIMD_DIRECTIVE, STMT_OMP_MASTER_TASKLOOP_DIRECTIVE, + STMT_OMP_MASTER_TASKLOOP_SIMD_DIRECTIVE, STMT_OMP_PARALLEL_MASTER_TASKLOOP_DIRECTIVE, STMT_OMP_DISTRIBUTE_DIRECTIVE, STMT_OMP_TARGET_UPDATE_DIRECTIVE, -- cgit v1.2.1