================
@@ -0,0 +1,76 @@
+//===--- CIRGenOpenMPClause.h - OpenMP clause processor ---------*- C++
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_LIB_CIR_CODEGEN_CIRGENOPENMPCLAUSE_H
+#define LLVM_CLANG_LIB_CIR_CODEGEN_CIRGENOPENMPCLAUSE_H
+
+#include "CIRGenBuilder.h"
+#include "CIRGenModule.h"
+#include "mlir/Dialect/OpenMP/OpenMPClauseOperands.h"
+#include "clang/AST/OpenMPClause.h"
+#include "clang/AST/StmtOpenMP.h"
+#include "llvm/Frontend/OpenMP/OMPConstants.h"
+
+namespace clang::CIRGen {
+
+class CIRGenFunction;
+
+/// Processes OpenMP clauses for a directive, writing results into the
+/// auto-generated ClauseOps from the OMP dialect.
+class OpenMPClauseProcessor {
+ CIRGenFunction &cgf;
+ CIRGenModule &cgm;
+ CIRGenBuilderTy &builder;
+ mlir::Location loc;
+ llvm::ArrayRef<const OMPClause *> clauses;
+
+public:
+ OpenMPClauseProcessor(CIRGenFunction &cgf, CIRGenModule &cgm,
+ CIRGenBuilderTy &builder, mlir::Location loc,
+ llvm::ArrayRef<const OMPClause *> clauses)
+ : cgf(cgf), cgm(cgm), builder(builder), loc(loc), clauses(clauses) {}
+
+ bool processProcBind(mlir::omp::ProcBindClauseOps &result) const;
+
+ /// Process map clauses. The optional \p mapSyms parameter collects the
+ /// VarDecls corresponding to each map operand.
+ bool
+ processMap(mlir::omp::MapClauseOps &result,
+ llvm::SmallVectorImpl<const VarDecl *> *mapSyms = nullptr) const;
+
+ /// Emit an errorNYI for each clause of the given types if present.
+ template <typename... ClauseTypes>
+ void processTODO(llvm::omp::Directive directive) const;
+
+private:
+ template <typename ClauseType>
+ void processTODOClause(llvm::omp::Directive directive) const;
+};
+
+template <typename ClauseType>
+void OpenMPClauseProcessor::processTODOClause(
+ llvm::omp::Directive directive) const {
+ for (const OMPClause *c : clauses) {
+ if (isa<ClauseType>(c)) {
----------------
skatrak wrote:
I think something like that could work well for this. The only thing I'd change
about that is making the two lists "implemented" and "not-yet-implemented",
which must be disjoint. The reasoning being that it's easier to see at a glance
what's currently missing support. Some pseudocode of what I'm thinking at the
moment:
```c++
template<typename... SuppClauseTypes, typename... NYIClauseTypes>
void OpenMPClauseProcessor::processNYI(
std::tuple<NYIClauseTypes...> /*nyi*/,
llvm::omp::Directive directive) const {
static_assert(intersection<SuppClauseTypes, NYIClauseTypes>::empty());
for (const OMPClause *clause : clauses) {
if (isa<NYIClauseTypes...>(clause)) {
std::string msg = "...";
cgm.errorNYI(..., msg);
} else if (!isa<SuppClauseTypes>(clause)) {
llvm_unreachable("unexpected clause");
}
}
}
// omp.parallel user.
cp.processNYI</*supported=*/OMPProcBindClause>(
/*nyi=*/std::tuple<OMPAllocateClause, OMPCopyinClause, OMPDefaultClause,
OMPFirstprivateClause, OMPIfClause, OMPNumThreadsClause,
OMPPrivateClause, OMPReductionClause, OMPSharedClause>{},
llvm::omp::Directive::OMPD_parallel);
```
https://github.com/llvm/llvm-project/pull/195452
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits