[llvm-branch-commits] [clang] [llvm] [openmp] [Clang][OpenMP] Add reverse directive (PR #92916)
Alexey Bataev via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue May 21 10:36:27 PDT 2024
================
@@ -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 EndLoc Location 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 &C, 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 &C,
+ unsigned NumClauses);
----------------
alexey-bataev wrote:
No need for NumClauses, always 0
https://github.com/llvm/llvm-project/pull/92916
More information about the llvm-branch-commits
mailing list