File tree Expand file tree Collapse file tree 9 files changed +125
-0
lines changed Expand file tree Collapse file tree 9 files changed +125
-0
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ add_subdirectory(GPU)
44add_subdirectory (Linalg)
55add_subdirectory (LLVMIR)
66add_subdirectory (LoopOps)
7+ add_subdirectory (OpenMP)
78add_subdirectory (QuantOps)
89add_subdirectory (SPIRV)
910add_subdirectory (StandardOps)
Original file line number Diff line number Diff line change 1+ add_mlir_dialect(OpenMPOps OpenMPOps)
Original file line number Diff line number Diff line change 1+ // ===- OpenMPDialect.h - MLIR Dialect for OpenMP ----------------*- C++ -*-===//
2+ //
3+ // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+ // See https://llvm.org/LICENSE.txt for license information.
5+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+ //
7+ // ===----------------------------------------------------------------------===//
8+ //
9+ // This file declares the OpenMP dialect in MLIR.
10+ //
11+ // ===----------------------------------------------------------------------===//
12+
13+ #ifndef MLIR_DIALECT_OPENMP_OPENMPDIALECT_H_
14+ #define MLIR_DIALECT_OPENMP_OPENMPDIALECT_H_
15+
16+ #include " mlir/IR/Dialect.h"
17+ #include " mlir/IR/OpDefinition.h"
18+
19+ namespace mlir {
20+ namespace omp {
21+
22+ #define GET_OP_CLASSES
23+ #include " mlir/Dialect/OpenMP/OpenMPOps.h.inc"
24+
25+ class OpenMPDialect : public Dialect {
26+ public:
27+ explicit OpenMPDialect (MLIRContext *context);
28+
29+ static StringRef getDialectNamespace () { return " omp" ; }
30+ };
31+
32+ } // namespace omp
33+ } // namespace mlir
34+
35+ #endif // MLIR_DIALECT_OPENMP_OPENMPDIALECT_H_
Original file line number Diff line number Diff line change 1+ //===-- OpenMPOps.td - OpenMP dialect operation definitions *- tablegen -*-===//
2+ //
3+ // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+ // See https://llvm.org/LICENSE.txt for license information.
5+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+ //
7+ //===----------------------------------------------------------------------===//
8+ //
9+ // This file defines the basic operations for the OpenMP dialect.
10+ //
11+ //===----------------------------------------------------------------------===//
12+
13+
14+ #ifndef OPENMP_OPS
15+ #define OPENMP_OPS
16+
17+ include "mlir/IR/OpBase.td"
18+
19+ def OpenMP_Dialect : Dialect {
20+ let name = "omp";
21+ }
22+
23+ class OpenMP_Op<string mnemonic, list<OpTrait> traits = []> :
24+ Op<OpenMP_Dialect, mnemonic, traits>;
25+
26+ def BarrierOp : OpenMP_Op<"barrier"> {
27+ let summary = "barrier construct";
28+ let description = [{
29+ The barrier construct specifies an explicit barrier at the point at which
30+ the construct appears.
31+ }];
32+
33+ let parser = [{ return success(); }];
34+ let printer = [{ p << getOperationName(); }];
35+ }
36+
37+ #endif // OPENMP_OPS
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ add_subdirectory(GPU)
44add_subdirectory (Linalg)
55add_subdirectory (LLVMIR)
66add_subdirectory (LoopOps)
7+ add_subdirectory (OpenMP)
78add_subdirectory (QuantOps)
89add_subdirectory (SDBM)
910add_subdirectory (SPIRV)
Original file line number Diff line number Diff line change 1+ add_llvm_library(MLIROpenMP
2+ IR/OpenMPDialect.cpp
3+
4+ ADDITIONAL_HEADER_DIRS
5+ ${MLIR_MAIN_INCLUDE_DIR} /mlir/Dialect/OpenMP
6+ )
7+
8+ add_dependencies (MLIROpenMP MLIROpenMPOpsIncGen)
Original file line number Diff line number Diff line change 1+ // ===- OpenMPDialect.cpp - MLIR Dialect for OpenMP implementation ---------===//
2+ //
3+ // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+ // See https://llvm.org/LICENSE.txt for license information.
5+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+ //
7+ // ===----------------------------------------------------------------------===//
8+ //
9+ // This file implements the OpenMP dialect and its operations.
10+ //
11+ // ===----------------------------------------------------------------------===//
12+
13+ #include " mlir/Dialect/OpenMP/OpenMPDialect.h"
14+ #include " mlir/IR/OpImplementation.h"
15+
16+ using namespace mlir ;
17+ using namespace mlir ::omp;
18+
19+ OpenMPDialect::OpenMPDialect (MLIRContext *context)
20+ : Dialect(getDialectNamespace(), context) {
21+ addOperations<
22+ #define GET_OP_LIST
23+ #include " mlir/Dialect/OpenMP/OpenMPOps.cpp.inc"
24+ >();
25+ }
26+
27+ namespace mlir {
28+ namespace omp {
29+ #define GET_OP_CLASSES
30+ #include " mlir/Dialect/OpenMP/OpenMPOps.cpp.inc"
31+ } // namespace omp
32+ } // namespace mlir
33+
34+ static DialectRegistration<OpenMPDialect> ompDialect;
Original file line number Diff line number Diff line change 1+ // RUN: mlir-opt -verify-diagnostics %s | FileCheck %s
2+
3+ func @omp_barrier () -> () {
4+ // CHECK: omp.barrier
5+ omp.barrier
6+ return
7+ }
Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ set(LIBS
3333 MLIRLLVMIR
3434 MLIRLoopOps
3535 MLIRNVVMIR
36+ MLIROpenMP
3637 MLIROptMain
3738 MLIRParser
3839 MLIRPass
You can’t perform that action at this time.
0 commit comments