[llvm-branch-commits] [clang] [llvm] [openmp] [Clang][OpenMP] Add reverse directive (PR #92916)
@@ -5711,6 +5712,71 @@ class OMPUnrollDirective final : public OMPLoopTransformationDirective { } }; +/// Represents the '#pragma omp reverse' loop transformation directive. +/// +/// \code +/// #pragma omp reverse +/// for (int i = 0; i < n; ++i) +/// ... +/// \endcode +class OMPReverseDirective final : public OMPLoopTransformationDirective { + friend class ASTStmtReader; + friend class OMPExecutableDirective; + + /// Offsets of child members. + enum { +PreInitsOffset = 0, +TransformedStmtOffset, + }; + + explicit OMPReverseDirective(SourceLocation StartLoc, SourceLocation EndLoc) + : OMPLoopTransformationDirective(OMPReverseDirectiveClass, + llvm::omp::OMPD_reverse, StartLoc, + EndLoc, 1) {} + + void setPreInits(Stmt *PreInits) { +Data->getChildren()[PreInitsOffset] = PreInits; + } + + void setTransformedStmt(Stmt *S) { +Data->getChildren()[TransformedStmtOffset] = S; + } + +public: + /// Create a new AST node representation for '#pragma omp reverse'. + /// + /// \param C Context of the AST. + /// \param StartLoc Location of the introducer (e.g. the 'omp' token). + /// \param EndLocLocation of the directive's end (e.g. the tok::eod). + /// \param AssociatedStmt The outermost associated loop. + /// \param TransformedStmt The loop nest after tiling, or nullptr in + ///dependent contexts. + /// \param PreInits Helper preinits statements for the loop nest. + static OMPReverseDirective * + Create(const ASTContext , SourceLocation StartLoc, SourceLocation EndLoc, + Stmt *AssociatedStmt, Stmt *TransformedStmt, Stmt *PreInits); + + /// Build an empty '#pragma omp reverse' AST node for deserialization. + /// + /// \param C Context of the AST. + /// \param NumClauses Number of clauses to allocate. + static OMPReverseDirective *CreateEmpty(const ASTContext , + unsigned NumClauses); alexey-bataev wrote: No need for NumClauses, always 0 https://github.com/llvm/llvm-project/pull/92916 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [llvm] [openmp] [Clang][OpenMP] Add reverse directive (PR #92916)
@@ -5711,6 +5712,73 @@ class OMPUnrollDirective final : public OMPLoopTransformationDirective { } }; +/// Represents the '#pragma omp reverse' loop transformation directive. +/// +/// \code +/// #pragma omp reverse +/// for (int i = 0; i < n; ++i) +/// ... +/// \endcode +class OMPReverseDirective final : public OMPLoopTransformationDirective { + friend class ASTStmtReader; + friend class OMPExecutableDirective; + + /// Offsets of child members. + enum { +PreInitsOffset = 0, +TransformedStmtOffset, + }; + + explicit OMPReverseDirective(SourceLocation StartLoc, SourceLocation EndLoc) + : OMPLoopTransformationDirective(OMPReverseDirectiveClass, + llvm::omp::OMPD_reverse, StartLoc, + EndLoc, 1) {} + + void setPreInits(Stmt *PreInits) { +Data->getChildren()[PreInitsOffset] = PreInits; + } + + void setTransformedStmt(Stmt *S) { +Data->getChildren()[TransformedStmtOffset] = S; + } + +public: + /// Create a new AST node representation for '#pragma omp reverse'. + /// + /// \param C Context of the AST. + /// \param StartLoc Location of the introducer (e.g. the 'omp' token). + /// \param EndLocLocation of the directive's end (e.g. the tok::eod). + /// \param Clauses The directive's clauses. + /// \param AssociatedStmt The outermost associated loop. + /// \param TransformedStmt The loop nest after tiling, or nullptr in + ///dependent contexts. + /// \param PreInits Helper preinits statements for the loop nest. + static OMPReverseDirective * + Create(const ASTContext , SourceLocation StartLoc, SourceLocation EndLoc, + ArrayRef Clauses, Stmt *AssociatedStmt, alexey-bataev wrote: If it does not have clauses, this param must be excluded https://github.com/llvm/llvm-project/pull/92916 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [llvm] [openmp] [Clang][OpenMP] Add reverse directive (PR #92916)
@@ -6546,6 +6547,10 @@ StmtResult SemaOpenMP::ActOnOpenMPExecutableDirective( Res = ActOnOpenMPUnrollDirective(ClausesWithImplicit, AStmt, StartLoc, EndLoc); break; + case OMPD_reverse: +Res = ActOnOpenMPReverseDirective(ClausesWithImplicit, AStmt, StartLoc, alexey-bataev wrote: Do not pass clauses here, if they are not expected, just assert, that it should be empty https://github.com/llvm/llvm-project/pull/92916 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [llvm] [openmp] [Clang][OpenMP] Add reverse directive (PR #92916)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Michael Kruse (Meinersbur) Changes Add the reverse directive which will be introduced in the upcoming OpenMP 6.0 specification. A preview has been published in [Technical Report 12](https://www.openmp.org/wp-content/uploads/openmp-TR12.pdf). This is the reverse directive part extracted out of #92030 which included reverse and interchange. --- Patch is 144.58 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/92916.diff 30 Files Affected: - (modified) clang/include/clang-c/Index.h (+4) - (modified) clang/include/clang/AST/RecursiveASTVisitor.h (+3) - (modified) clang/include/clang/AST/StmtOpenMP.h (+70-2) - (modified) clang/include/clang/Basic/StmtNodes.td (+1) - (modified) clang/include/clang/Sema/SemaOpenMP.h (+5) - (modified) clang/include/clang/Serialization/ASTBitCodes.h (+1) - (modified) clang/lib/AST/StmtOpenMP.cpp (+19) - (modified) clang/lib/AST/StmtPrinter.cpp (+5) - (modified) clang/lib/AST/StmtProfile.cpp (+4) - (modified) clang/lib/Basic/OpenMPKinds.cpp (+2-1) - (modified) clang/lib/CodeGen/CGStmt.cpp (+3) - (modified) clang/lib/CodeGen/CGStmtOpenMP.cpp (+8) - (modified) clang/lib/CodeGen/CodeGenFunction.h (+1) - (modified) clang/lib/Parse/ParseOpenMP.cpp (+2) - (modified) clang/lib/Sema/SemaExceptionSpec.cpp (+1) - (modified) clang/lib/Sema/SemaOpenMP.cpp (+190) - (modified) clang/lib/Sema/TreeTransform.h (+11) - (modified) clang/lib/Serialization/ASTReaderStmt.cpp (+12) - (modified) clang/lib/Serialization/ASTWriterStmt.cpp (+5) - (added) clang/test/OpenMP/reverse_ast_print.cpp (+159) - (added) clang/test/OpenMP/reverse_codegen.cpp (+1554) - (added) clang/test/OpenMP/reverse_messages.cpp (+40) - (modified) clang/tools/libclang/CIndex.cpp (+7) - (modified) clang/tools/libclang/CXCursor.cpp (+3) - (modified) llvm/include/llvm/Frontend/OpenMP/OMP.td (+3) - (added) openmp/runtime/test/transform/reverse/foreach.cpp (+162) - (added) openmp/runtime/test/transform/reverse/intfor.c (+25) - (added) openmp/runtime/test/transform/reverse/iterfor.cpp (+164) - (added) openmp/runtime/test/transform/reverse/parallel-wsloop-collapse-foreach.cpp (+285) - (added) openmp/runtime/test/transform/reverse/parallel-wsloop-collapse-intfor.cpp (+51) ``diff diff --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h index 365b607c74117..c7d63818ece23 100644 --- a/clang/include/clang-c/Index.h +++ b/clang/include/clang-c/Index.h @@ -2146,6 +2146,10 @@ enum CXCursorKind { */ CXCursor_OMPScopeDirective = 306, + /** OpenMP reverse directive. + */ + CXCursor_OMPReverseDirective = 307, + /** OpenACC Compute Construct. */ CXCursor_OpenACCComputeConstruct = 320, diff --git a/clang/include/clang/AST/RecursiveASTVisitor.h b/clang/include/clang/AST/RecursiveASTVisitor.h index f5cefedb07e0e..06b29d59785f6 100644 --- a/clang/include/clang/AST/RecursiveASTVisitor.h +++ b/clang/include/clang/AST/RecursiveASTVisitor.h @@ -3021,6 +3021,9 @@ DEF_TRAVERSE_STMT(OMPTileDirective, DEF_TRAVERSE_STMT(OMPUnrollDirective, { TRY_TO(TraverseOMPExecutableDirective(S)); }) +DEF_TRAVERSE_STMT(OMPReverseDirective, + { TRY_TO(TraverseOMPExecutableDirective(S)); }) + DEF_TRAVERSE_STMT(OMPForDirective, { TRY_TO(TraverseOMPExecutableDirective(S)); }) diff --git a/clang/include/clang/AST/StmtOpenMP.h b/clang/include/clang/AST/StmtOpenMP.h index f735fa5643aec..4be2e2d3a4605 100644 --- a/clang/include/clang/AST/StmtOpenMP.h +++ b/clang/include/clang/AST/StmtOpenMP.h @@ -1007,8 +1007,9 @@ class OMPLoopTransformationDirective : public OMPLoopBasedDirective { Stmt *getPreInits() const; static bool classof(const Stmt *T) { -return T->getStmtClass() == OMPTileDirectiveClass || - T->getStmtClass() == OMPUnrollDirectiveClass; +Stmt::StmtClass C = T->getStmtClass(); +return C == OMPTileDirectiveClass || C == OMPUnrollDirectiveClass || + C == OMPReverseDirectiveClass; } }; @@ -5711,6 +5712,73 @@ class OMPUnrollDirective final : public OMPLoopTransformationDirective { } }; +/// Represents the '#pragma omp reverse' loop transformation directive. +/// +/// \code +/// #pragma omp reverse +/// for (int i = 0; i < n; ++i) +/// ... +/// \endcode +class OMPReverseDirective final : public OMPLoopTransformationDirective { + friend class ASTStmtReader; + friend class OMPExecutableDirective; + + /// Offsets of child members. + enum { +PreInitsOffset = 0, +TransformedStmtOffset, + }; + + explicit OMPReverseDirective(SourceLocation StartLoc, SourceLocation EndLoc) + : OMPLoopTransformationDirective(OMPReverseDirectiveClass, + llvm::omp::OMPD_reverse, StartLoc, + EndLoc, 1) {} + + void setPreInits(Stmt *PreInits) { +Data->getChildren()[PreInitsOffset] = PreInits; + } + + void
[llvm-branch-commits] [clang] [llvm] [openmp] [Clang][OpenMP] Add reverse directive (PR #92916)
llvmbot wrote: @llvm/pr-subscribers-flang-openmp @llvm/pr-subscribers-clang-modules Author: Michael Kruse (Meinersbur) Changes Add the reverse directive which will be introduced in the upcoming OpenMP 6.0 specification. A preview has been published in [Technical Report 12](https://www.openmp.org/wp-content/uploads/openmp-TR12.pdf). This is the reverse directive part extracted out of #92030 which included reverse and interchange. --- Patch is 144.58 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/92916.diff 30 Files Affected: - (modified) clang/include/clang-c/Index.h (+4) - (modified) clang/include/clang/AST/RecursiveASTVisitor.h (+3) - (modified) clang/include/clang/AST/StmtOpenMP.h (+70-2) - (modified) clang/include/clang/Basic/StmtNodes.td (+1) - (modified) clang/include/clang/Sema/SemaOpenMP.h (+5) - (modified) clang/include/clang/Serialization/ASTBitCodes.h (+1) - (modified) clang/lib/AST/StmtOpenMP.cpp (+19) - (modified) clang/lib/AST/StmtPrinter.cpp (+5) - (modified) clang/lib/AST/StmtProfile.cpp (+4) - (modified) clang/lib/Basic/OpenMPKinds.cpp (+2-1) - (modified) clang/lib/CodeGen/CGStmt.cpp (+3) - (modified) clang/lib/CodeGen/CGStmtOpenMP.cpp (+8) - (modified) clang/lib/CodeGen/CodeGenFunction.h (+1) - (modified) clang/lib/Parse/ParseOpenMP.cpp (+2) - (modified) clang/lib/Sema/SemaExceptionSpec.cpp (+1) - (modified) clang/lib/Sema/SemaOpenMP.cpp (+190) - (modified) clang/lib/Sema/TreeTransform.h (+11) - (modified) clang/lib/Serialization/ASTReaderStmt.cpp (+12) - (modified) clang/lib/Serialization/ASTWriterStmt.cpp (+5) - (added) clang/test/OpenMP/reverse_ast_print.cpp (+159) - (added) clang/test/OpenMP/reverse_codegen.cpp (+1554) - (added) clang/test/OpenMP/reverse_messages.cpp (+40) - (modified) clang/tools/libclang/CIndex.cpp (+7) - (modified) clang/tools/libclang/CXCursor.cpp (+3) - (modified) llvm/include/llvm/Frontend/OpenMP/OMP.td (+3) - (added) openmp/runtime/test/transform/reverse/foreach.cpp (+162) - (added) openmp/runtime/test/transform/reverse/intfor.c (+25) - (added) openmp/runtime/test/transform/reverse/iterfor.cpp (+164) - (added) openmp/runtime/test/transform/reverse/parallel-wsloop-collapse-foreach.cpp (+285) - (added) openmp/runtime/test/transform/reverse/parallel-wsloop-collapse-intfor.cpp (+51) ``diff diff --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h index 365b607c74117..c7d63818ece23 100644 --- a/clang/include/clang-c/Index.h +++ b/clang/include/clang-c/Index.h @@ -2146,6 +2146,10 @@ enum CXCursorKind { */ CXCursor_OMPScopeDirective = 306, + /** OpenMP reverse directive. + */ + CXCursor_OMPReverseDirective = 307, + /** OpenACC Compute Construct. */ CXCursor_OpenACCComputeConstruct = 320, diff --git a/clang/include/clang/AST/RecursiveASTVisitor.h b/clang/include/clang/AST/RecursiveASTVisitor.h index f5cefedb07e0e..06b29d59785f6 100644 --- a/clang/include/clang/AST/RecursiveASTVisitor.h +++ b/clang/include/clang/AST/RecursiveASTVisitor.h @@ -3021,6 +3021,9 @@ DEF_TRAVERSE_STMT(OMPTileDirective, DEF_TRAVERSE_STMT(OMPUnrollDirective, { TRY_TO(TraverseOMPExecutableDirective(S)); }) +DEF_TRAVERSE_STMT(OMPReverseDirective, + { TRY_TO(TraverseOMPExecutableDirective(S)); }) + DEF_TRAVERSE_STMT(OMPForDirective, { TRY_TO(TraverseOMPExecutableDirective(S)); }) diff --git a/clang/include/clang/AST/StmtOpenMP.h b/clang/include/clang/AST/StmtOpenMP.h index f735fa5643aec..4be2e2d3a4605 100644 --- a/clang/include/clang/AST/StmtOpenMP.h +++ b/clang/include/clang/AST/StmtOpenMP.h @@ -1007,8 +1007,9 @@ class OMPLoopTransformationDirective : public OMPLoopBasedDirective { Stmt *getPreInits() const; static bool classof(const Stmt *T) { -return T->getStmtClass() == OMPTileDirectiveClass || - T->getStmtClass() == OMPUnrollDirectiveClass; +Stmt::StmtClass C = T->getStmtClass(); +return C == OMPTileDirectiveClass || C == OMPUnrollDirectiveClass || + C == OMPReverseDirectiveClass; } }; @@ -5711,6 +5712,73 @@ class OMPUnrollDirective final : public OMPLoopTransformationDirective { } }; +/// Represents the '#pragma omp reverse' loop transformation directive. +/// +/// \code +/// #pragma omp reverse +/// for (int i = 0; i < n; ++i) +/// ... +/// \endcode +class OMPReverseDirective final : public OMPLoopTransformationDirective { + friend class ASTStmtReader; + friend class OMPExecutableDirective; + + /// Offsets of child members. + enum { +PreInitsOffset = 0, +TransformedStmtOffset, + }; + + explicit OMPReverseDirective(SourceLocation StartLoc, SourceLocation EndLoc) + : OMPLoopTransformationDirective(OMPReverseDirectiveClass, + llvm::omp::OMPD_reverse, StartLoc, + EndLoc, 1) {} + + void setPreInits(Stmt *PreInits) { +
[llvm-branch-commits] [clang] [llvm] [openmp] [Clang][OpenMP] Add reverse directive (PR #92916)
https://github.com/Meinersbur ready_for_review https://github.com/llvm/llvm-project/pull/92916 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits