Skip to content

Commit 1837237

Browse files
jtb20Munesanzjosemonsalve2
committed
[OpenMP] Taskgraph frontend support
This is a version of the 'ompx taskgraph' support posted in PR66919, adapted to the official OpenMP 6.0 spelling of 'omp taskgraph', and with the 'ompx' extension parts removed. Co-authored-by: Adrian Munera <[email protected]> Co-authored-by: Jose M Monsalve Diaz <[email protected]>
1 parent 1339b9e commit 1837237

File tree

26 files changed

+253
-0
lines changed

26 files changed

+253
-0
lines changed

clang/bindings/python/clang/cindex.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1449,6 +1449,9 @@ def is_unexposed(self):
14491449
# OpenMP fuse directive.
14501450
OMP_FUSE_DIRECTIVE = 311
14511451

1452+
# OpenMP taskgraph directive.
1453+
OMP_TASKGRAPH_DIRECTIVE = 312
1454+
14521455
# OpenACC Compute Construct.
14531456
OPEN_ACC_COMPUTE_DIRECTIVE = 320
14541457

clang/include/clang-c/Index.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2166,6 +2166,10 @@ enum CXCursorKind {
21662166
*/
21672167
CXCursor_OMPFuseDirective = 311,
21682168

2169+
/** OpenMP taskgraph directive.
2170+
*/
2171+
CXCursor_OMPTaskgraphDirective = 312,
2172+
21692173
/** OpenACC Compute Construct.
21702174
*/
21712175
CXCursor_OpenACCComputeConstruct = 320,

clang/include/clang/AST/RecursiveASTVisitor.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3236,6 +3236,9 @@ DEF_TRAVERSE_STMT(OMPBarrierDirective,
32363236
DEF_TRAVERSE_STMT(OMPTaskwaitDirective,
32373237
{ TRY_TO(TraverseOMPExecutableDirective(S)); })
32383238

3239+
DEF_TRAVERSE_STMT(OMPTaskgraphDirective,
3240+
{ TRY_TO(TraverseOMPExecutableDirective(S)); })
3241+
32393242
DEF_TRAVERSE_STMT(OMPTaskgroupDirective,
32403243
{ TRY_TO(TraverseOMPExecutableDirective(S)); })
32413244

clang/include/clang/AST/StmtOpenMP.h

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2760,6 +2760,55 @@ class OMPTaskwaitDirective : public OMPExecutableDirective {
27602760
}
27612761
};
27622762

2763+
/// This represents '#pragma omp taskgraph' directive.
2764+
/// Available with OpenMP 6.0.
2765+
///
2766+
/// \code
2767+
/// #pragma omp taskgraph
2768+
/// \endcode
2769+
///
2770+
class OMPTaskgraphDirective final : public OMPExecutableDirective {
2771+
friend class ASTStmtReader;
2772+
friend class OMPExecutableDirective;
2773+
/// Build directive with the given start and end location.
2774+
///
2775+
/// \param StartLoc Starting location of the directive kind.
2776+
/// \param EndLoc Ending location of the directive.
2777+
///
2778+
OMPTaskgraphDirective(SourceLocation StartLoc, SourceLocation EndLoc)
2779+
: OMPExecutableDirective(OMPTaskgraphDirectiveClass,
2780+
llvm::omp::OMPD_taskgraph, StartLoc, EndLoc) {}
2781+
2782+
/// Build an empty directive.
2783+
///
2784+
explicit OMPTaskgraphDirective()
2785+
: OMPExecutableDirective(OMPTaskgraphDirectiveClass,
2786+
llvm::omp::OMPD_taskgraph, SourceLocation(),
2787+
SourceLocation()) {}
2788+
2789+
public:
2790+
/// Creates directive.
2791+
///
2792+
/// \param C AST context.
2793+
/// \param StartLoc Starting location of the directive kind.
2794+
/// \param EndLoc Ending Location of the directive.
2795+
///
2796+
static OMPTaskgraphDirective *
2797+
Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2798+
ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt);
2799+
2800+
/// Creates an empty directive.
2801+
///
2802+
/// \param C AST context.
2803+
///
2804+
static OMPTaskgraphDirective *CreateEmpty(const ASTContext &C,
2805+
unsigned NumClauses, EmptyShell);
2806+
2807+
static bool classof(const Stmt *T) {
2808+
return T->getStmtClass() == OMPTaskgraphDirectiveClass;
2809+
}
2810+
};
2811+
27632812
/// This represents '#pragma omp taskgroup' directive.
27642813
///
27652814
/// \code

clang/include/clang/Basic/StmtNodes.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ def OMPTaskDirective : StmtNode<OMPExecutableDirective>;
257257
def OMPTaskyieldDirective : StmtNode<OMPExecutableDirective>;
258258
def OMPBarrierDirective : StmtNode<OMPExecutableDirective>;
259259
def OMPTaskwaitDirective : StmtNode<OMPExecutableDirective>;
260+
def OMPTaskgraphDirective : StmtNode<OMPExecutableDirective>;
260261
def OMPTaskgroupDirective : StmtNode<OMPExecutableDirective>;
261262
def OMPFlushDirective : StmtNode<OMPExecutableDirective>;
262263
def OMPDepobjDirective : StmtNode<OMPExecutableDirective>;

clang/include/clang/Sema/SemaOpenMP.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,10 @@ class SemaOpenMP : public SemaBase {
557557
/// Called on well-formed '\#pragma omp barrier'.
558558
StmtResult ActOnOpenMPBarrierDirective(SourceLocation StartLoc,
559559
SourceLocation EndLoc);
560+
/// Called on well-formed '\#pragma omp taskgraph'.
561+
StmtResult ActOnOpenMPTaskgraphDirective(ArrayRef<OMPClause *> Clauses,
562+
Stmt *AStmt, SourceLocation StartLoc,
563+
SourceLocation EndLoc);
560564
/// Called on well-formed '\#pragma omp taskwait'.
561565
StmtResult ActOnOpenMPTaskwaitDirective(ArrayRef<OMPClause *> Clauses,
562566
SourceLocation StartLoc,

clang/include/clang/Serialization/ASTBitCodes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1969,6 +1969,7 @@ enum StmtCode {
19691969
STMT_OMP_ERROR_DIRECTIVE,
19701970
STMT_OMP_BARRIER_DIRECTIVE,
19711971
STMT_OMP_TASKWAIT_DIRECTIVE,
1972+
STMT_OMP_TASKGRAPH_DIRECTIVE,
19721973
STMT_OMP_FLUSH_DIRECTIVE,
19731974
STMT_OMP_DEPOBJ_DIRECTIVE,
19741975
STMT_OMP_SCAN_DIRECTIVE,

clang/lib/AST/StmtOpenMP.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -945,6 +945,21 @@ OMPTaskwaitDirective *OMPTaskwaitDirective::CreateEmpty(const ASTContext &C,
945945
return createEmptyDirective<OMPTaskwaitDirective>(C, NumClauses);
946946
}
947947

948+
OMPTaskgraphDirective *OMPTaskgraphDirective::Create(
949+
const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
950+
ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
951+
auto *Dir = createDirective<OMPTaskgraphDirective>(
952+
C, Clauses, AssociatedStmt, /*NumChildren=*/1, StartLoc, EndLoc);
953+
return Dir;
954+
}
955+
956+
OMPTaskgraphDirective *OMPTaskgraphDirective::CreateEmpty(const ASTContext &C,
957+
unsigned NumClauses,
958+
EmptyShell) {
959+
return createEmptyDirective<OMPTaskgraphDirective>(
960+
C, NumClauses, /*HasAssociatedStmt=*/true, /*NumChildren=*/1);
961+
}
962+
948963
OMPTaskgroupDirective *OMPTaskgroupDirective::Create(
949964
const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
950965
ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *ReductionRef) {

clang/lib/AST/StmtPrinter.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,11 @@ void StmtPrinter::VisitOMPAssumeDirective(OMPAssumeDirective *Node) {
899899
PrintOMPExecutableDirective(Node);
900900
}
901901

902+
void StmtPrinter::VisitOMPTaskgraphDirective(OMPTaskgraphDirective *Node) {
903+
Indent() << "#pragma omp taskgraph";
904+
PrintOMPExecutableDirective(Node);
905+
}
906+
902907
void StmtPrinter::VisitOMPErrorDirective(OMPErrorDirective *Node) {
903908
Indent() << "#pragma omp error";
904909
PrintOMPExecutableDirective(Node);

clang/lib/AST/StmtProfile.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,9 +1119,14 @@ void StmtProfiler::VisitOMPAssumeDirective(const OMPAssumeDirective *S) {
11191119
VisitOMPExecutableDirective(S);
11201120
}
11211121

1122+
void StmtProfiler::VisitOMPTaskgraphDirective(const OMPTaskgraphDirective *S) {
1123+
VisitOMPExecutableDirective(S);
1124+
}
1125+
11221126
void StmtProfiler::VisitOMPErrorDirective(const OMPErrorDirective *S) {
11231127
VisitOMPExecutableDirective(S);
11241128
}
1129+
11251130
void StmtProfiler::VisitOMPTaskgroupDirective(const OMPTaskgroupDirective *S) {
11261131
VisitOMPExecutableDirective(S);
11271132
if (const Expr *E = S->getReductionRef())

0 commit comments

Comments
 (0)