llvm / clangir

A new (MLIR based) high-level IR for clang.
https://clangir.org
Other
383 stars 100 forks source link

[CIR][OpenMP] Implementation of taskwait, taskyield and barrier #509

Closed eZWALT closed 7 months ago

eZWALT commented 7 months ago

This solves #499. I think this might be unnecessary, but I wasn't able to correctly compile the ClangIR project without the definitions I've added to openmp cmake as described in https://github.com/llvm/llvm-project/pull/73249. Feedback is greatly appreciated!

github-actions[bot] commented 7 months ago

:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

You can test this locally with the following command: ``````````bash git-clang-format --diff 9a9729e3ddb7ac6580954cc332ac032c0256b538 45e88e7323cf7ab702ed2140fa1afa4fbe17d01b -- clang/test/CIR/CodeGen/barrier.cpp clang/test/CIR/CodeGen/taskwait.cpp clang/test/CIR/CodeGen/taskyield.cpp clang/lib/CIR/CodeGen/CIRGenFunction.h clang/lib/CIR/CodeGen/CIRGenStmt.cpp clang/lib/CIR/CodeGen/CIRGenStmtOpenMP.cpp ``````````
View the diff from clang-format here. ``````````diff diff --git a/clang/lib/CIR/CodeGen/CIRGenFunction.h b/clang/lib/CIR/CodeGen/CIRGenFunction.h index a12cd2f636..c21416daa6 100644 --- a/clang/lib/CIR/CodeGen/CIRGenFunction.h +++ b/clang/lib/CIR/CodeGen/CIRGenFunction.h @@ -992,9 +992,10 @@ public: // OpenMP gen functions: mlir::LogicalResult buildOMPParallelDirective(const OMPParallelDirective &S); mlir::LogicalResult buildOMPTaskwaitDirective(const OMPTaskwaitDirective &S); - mlir::LogicalResult buildOMPTaskyieldDirective(const OMPTaskyieldDirective &S); + mlir::LogicalResult + buildOMPTaskyieldDirective(const OMPTaskyieldDirective &S); mlir::LogicalResult buildOMPBarrierDirective(const OMPBarrierDirective &S); - + LValue buildOpaqueValueLValue(const OpaqueValueExpr *e); /// Emit code to compute a designator that specifies the location diff --git a/clang/lib/CIR/CodeGen/CIRGenStmt.cpp b/clang/lib/CIR/CodeGen/CIRGenStmt.cpp index 7fd01b2b9f..582a782ceb 100644 --- a/clang/lib/CIR/CodeGen/CIRGenStmt.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenStmt.cpp @@ -180,8 +180,8 @@ mlir::LogicalResult CIRGenFunction::buildStmt(const Stmt *S, return buildOMPTaskwaitDirective(cast(*S)); case Stmt::OMPTaskyieldDirectiveClass: return buildOMPTaskyieldDirective(cast(*S)); - case Stmt::OMPBarrierDirectiveClass: - return buildOMPBarrierDirective(cast(*S)); + case Stmt::OMPBarrierDirectiveClass: + return buildOMPBarrierDirective(cast(*S)); // Unsupported AST nodes: case Stmt::CapturedStmtClass: case Stmt::ObjCAtTryStmtClass: diff --git a/clang/lib/CIR/CodeGen/CIRGenStmtOpenMP.cpp b/clang/lib/CIR/CodeGen/CIRGenStmtOpenMP.cpp index b7044bd580..5239ae7a24 100644 --- a/clang/lib/CIR/CodeGen/CIRGenStmtOpenMP.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenStmtOpenMP.cpp @@ -44,7 +44,7 @@ CIRGenFunction::buildOMPParallelDirective(const OMPParallelDirective &S) { return res; } -mlir::LogicalResult +mlir::LogicalResult CIRGenFunction::buildOMPTaskwaitDirective(const OMPTaskwaitDirective &S) { mlir::LogicalResult res = mlir::success(); // Getting the source location information of AST node S scope @@ -53,10 +53,9 @@ CIRGenFunction::buildOMPTaskwaitDirective(const OMPTaskwaitDirective &S) { auto taskwaitOp = builder.create(scopeLoc); return res; - } -mlir::LogicalResult -CIRGenFunction::buildOMPTaskyieldDirective(const OMPTaskyieldDirective &S){ +mlir::LogicalResult +CIRGenFunction::buildOMPTaskyieldDirective(const OMPTaskyieldDirective &S) { mlir::LogicalResult res = mlir::success(); // Getting the source location information of AST node S scope auto scopeLoc = getLoc(S.getSourceRange()); @@ -67,7 +66,7 @@ CIRGenFunction::buildOMPTaskyieldDirective(const OMPTaskyieldDirective &S){ } mlir::LogicalResult -CIRGenFunction::buildOMPBarrierDirective(const OMPBarrierDirective &S){ +CIRGenFunction::buildOMPBarrierDirective(const OMPBarrierDirective &S) { mlir::LogicalResult res = mlir::success(); // Getting the source location information of AST node S scope auto scopeLoc = getLoc(S.getSourceRange()); ``````````