Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions clang/bindings/python/clang/cindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -1446,6 +1446,9 @@ def is_unexposed(self):
# OpenMP stripe directive.
OMP_STRIPE_DIRECTIVE = 310

# OpenMP fuse directive.
OMP_FUSE_DIRECTIVE = 311

# OpenACC Compute Construct.
OPEN_ACC_COMPUTE_DIRECTIVE = 320

Expand Down
2 changes: 2 additions & 0 deletions clang/docs/OpenMPSupport.rst
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,8 @@ implementation.
+-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+
| loop transformation apply clause | :none:`unclaimed` | :none:`unclaimed` | |
+-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+
| loop fuse transformation | :good:`done` | :none:`unclaimed` | |
+-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+
| workdistribute construct | | :none:`in progress` | @skc7, @mjklemm |
+-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+
| task_iteration | :none:`unclaimed` | :none:`unclaimed` | |
Expand Down
1 change: 1 addition & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,7 @@ OpenMP Support
- Added support for ``defaultmap`` directive implicit-behavior ``storage``.
- Added support for ``defaultmap`` directive implicit-behavior ``private``.
- Added parsing and semantic analysis support for ``groupprivate`` directive.
- Added support for 'omp fuse' directive.

Improvements
^^^^^^^^^^^^
Expand Down
4 changes: 4 additions & 0 deletions clang/include/clang-c/Index.h
Original file line number Diff line number Diff line change
Expand Up @@ -2162,6 +2162,10 @@ enum CXCursorKind {
*/
CXCursor_OMPStripeDirective = 310,

/** OpenMP fuse directive
*/
CXCursor_OMPFuseDirective = 311,

/** OpenACC Compute Construct.
*/
CXCursor_OpenACCComputeConstruct = 320,
Expand Down
74 changes: 74 additions & 0 deletions clang/include/clang/AST/OpenMPClause.h
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,80 @@ class OMPFullClause final : public OMPNoChildClause<llvm::omp::OMPC_full> {
static OMPFullClause *CreateEmpty(const ASTContext &C);
};

/// This class represents the 'looprange' clause in the
/// '#pragma omp fuse' directive
///
/// \code {c}
/// #pragma omp fuse looprange(1,2)
/// {
/// for(int i = 0; i < 64; ++i)
/// for(int j = 0; j < 256; j+=2)
/// for(int k = 127; k >= 0; --k)
/// \endcode
class OMPLoopRangeClause final : public OMPClause {
friend class OMPClauseReader;
/// Location of '('
SourceLocation LParenLoc;

/// Location of first and count expressions
SourceLocation FirstLoc, CountLoc;

/// Number of looprange arguments (always 2: first, count)
static constexpr unsigned NumArgs = 2;
Stmt *Args[NumArgs] = {nullptr, nullptr};

/// Set looprange 'first' expression
void setFirst(Expr *E) { Args[0] = E; }

/// Set looprange 'count' expression
void setCount(Expr *E) { Args[1] = E; }

/// Build an empty clause for deserialization.
explicit OMPLoopRangeClause()
: OMPClause(llvm::omp::OMPC_looprange, {}, {}) {}

public:
/// Build a 'looprange' clause AST node.
static OMPLoopRangeClause *
Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
SourceLocation FirstLoc, SourceLocation CountLoc,
SourceLocation EndLoc, Expr *First, Expr *Count);

/// Build an empty 'looprange' clause node.
static OMPLoopRangeClause *CreateEmpty(const ASTContext &C);

// Location getters/setters
SourceLocation getLParenLoc() const { return LParenLoc; }
SourceLocation getFirstLoc() const { return FirstLoc; }
SourceLocation getCountLoc() const { return CountLoc; }

void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
void setFirstLoc(SourceLocation Loc) { FirstLoc = Loc; }
void setCountLoc(SourceLocation Loc) { CountLoc = Loc; }

/// Get looprange 'first' expression
Expr *getFirst() const { return cast_or_null<Expr>(Args[0]); }

/// Get looprange 'count' expression
Expr *getCount() const { return cast_or_null<Expr>(Args[1]); }

child_range children() { return child_range(Args, Args + NumArgs); }
const_child_range children() const {
return const_child_range(Args, Args + NumArgs);
}

child_range used_children() {
return child_range(child_iterator(), child_iterator());
}
const_child_range used_children() const {
return const_child_range(const_child_iterator(), const_child_iterator());
}

static bool classof(const OMPClause *T) {
return T->getClauseKind() == llvm::omp::OMPC_looprange;
}
};

/// Representation of the 'partial' clause of the '#pragma omp unroll'
/// directive.
///
Expand Down
11 changes: 11 additions & 0 deletions clang/include/clang/AST/RecursiveASTVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -3176,6 +3176,9 @@ DEF_TRAVERSE_STMT(OMPUnrollDirective,
DEF_TRAVERSE_STMT(OMPReverseDirective,
{ TRY_TO(TraverseOMPExecutableDirective(S)); })

DEF_TRAVERSE_STMT(OMPFuseDirective,
{ TRY_TO(TraverseOMPExecutableDirective(S)); })

DEF_TRAVERSE_STMT(OMPInterchangeDirective,
{ TRY_TO(TraverseOMPExecutableDirective(S)); })

Expand Down Expand Up @@ -3493,6 +3496,14 @@ bool RecursiveASTVisitor<Derived>::VisitOMPFullClause(OMPFullClause *C) {
return true;
}

template <typename Derived>
bool RecursiveASTVisitor<Derived>::VisitOMPLoopRangeClause(
OMPLoopRangeClause *C) {
TRY_TO(TraverseStmt(C->getFirst()));
TRY_TO(TraverseStmt(C->getCount()));
return true;
}

template <typename Derived>
bool RecursiveASTVisitor<Derived>::VisitOMPPartialClause(OMPPartialClause *C) {
TRY_TO(TraverseStmt(C->getFactor()));
Expand Down
Loading
Loading