Index: mlir/include/mlir/Dialect/CMakeLists.txt =================================================================== --- mlir/include/mlir/Dialect/CMakeLists.txt +++ mlir/include/mlir/Dialect/CMakeLists.txt @@ -4,6 +4,7 @@ add_subdirectory(Linalg) add_subdirectory(LLVMIR) add_subdirectory(LoopOps) +add_subdirectory(OpenMP) add_subdirectory(QuantOps) add_subdirectory(SPIRV) add_subdirectory(StandardOps) Index: mlir/include/mlir/Dialect/OpenMP/CMakeLists.txt =================================================================== --- /dev/null +++ mlir/include/mlir/Dialect/OpenMP/CMakeLists.txt @@ -0,0 +1 @@ +add_mlir_dialect(OpenMPOps OpenMPOps) Index: mlir/include/mlir/Dialect/OpenMP/OpenMPDialect.h =================================================================== --- /dev/null +++ mlir/include/mlir/Dialect/OpenMP/OpenMPDialect.h @@ -0,0 +1,26 @@ +#ifndef MLIR_DIALECT_OPENMP_OPENMPDIALECT_H_ +#define MLIR_DIALECT_OPENMP_OPENMPDIALECT_H_ + +#include "mlir/IR/Dialect.h" +#include "mlir/IR/OpDefinition.h" +#include "mlir/IR/FunctionSupport.h" +#include "mlir/IR/OpImplementation.h" + + +namespace mlir { +namespace omp { + +#define GET_OP_CLASSES +#include "mlir/Dialect/OpenMP/OpenMPOps.h.inc" + +class OpenMPDialect : public Dialect { +public: + explicit OpenMPDialect(MLIRContext *context); + + static StringRef getDialectNamespace() { return "omp"; } +}; + +} // namespace openmp +} // namespace mlir + +#endif /* MLIR_DIALECT_OPENMP_OPENMPDIALECT_H_ */ Index: mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td =================================================================== --- /dev/null +++ mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td @@ -0,0 +1,24 @@ +#ifndef OPENMP_OPS +#define OPENMP_OPS + +include "mlir/IR/OpBase.td" + +def OpenMP_Dialect : Dialect { + let name = "omp"; +} + +class OpenMP_Op traits = []> : + Op; + +def BarrierOp : OpenMP_Op<"barrier"> { + let summary = "barrier construct"; + let description = [{ + The barrier construct specifies an explicit barrier at the point at which + the construct appears. + }]; + + let parser = [{ return success(); }]; + let printer = [{ p << getOperationName(); }]; +} + +#endif //OPENMP_OPS Index: mlir/lib/Dialect/CMakeLists.txt =================================================================== --- mlir/lib/Dialect/CMakeLists.txt +++ mlir/lib/Dialect/CMakeLists.txt @@ -4,6 +4,7 @@ add_subdirectory(Linalg) add_subdirectory(LLVMIR) add_subdirectory(LoopOps) +add_subdirectory(OpenMP) add_subdirectory(QuantOps) add_subdirectory(SDBM) add_subdirectory(SPIRV) Index: mlir/lib/Dialect/OpenMP/CMakeLists.txt =================================================================== --- /dev/null +++ mlir/lib/Dialect/OpenMP/CMakeLists.txt @@ -0,0 +1,8 @@ +add_llvm_library(MLIROpenMP + IR/OpenMPDialect.cpp + + ADDITIONAL_HEADER_DIRS + ${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/OpenMP + ) + +add_dependencies(MLIROpenMP MLIROpenMPOpsIncGen) Index: mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp =================================================================== --- /dev/null +++ mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp @@ -0,0 +1,22 @@ +#include "mlir/Dialect/OpenMP/OpenMPDialect.h" +#include "mlir/IR/MLIRContext.h" +#include "mlir/IR/Operation.h" +#include "mlir/IR/OperationSupport.h" + +namespace mlir { +namespace omp { + +OpenMPDialect::OpenMPDialect(MLIRContext *context) : Dialect("omp", context) { + addOperations< +#define GET_OP_LIST +#include "mlir/Dialect/OpenMP/OpenMPOps.cpp.inc" + >(); +} + +#define GET_OP_CLASSES +#include "mlir/Dialect/OpenMP/OpenMPOps.cpp.inc" + +static DialectRegistration openmpDialect; + +} // namespace openmp +} // namespace mlir Index: mlir/test/Dialect/OpenMP/ops.mlir =================================================================== --- /dev/null +++ mlir/test/Dialect/OpenMP/ops.mlir @@ -0,0 +1,7 @@ +// RUN: mlir-opt -verify-diagnostics %s | FileCheck %s + +func @omp_barrier() -> () { + // CHECK: omp.barrier + omp.barrier + return +} Index: mlir/tools/mlir-opt/CMakeLists.txt =================================================================== --- mlir/tools/mlir-opt/CMakeLists.txt +++ mlir/tools/mlir-opt/CMakeLists.txt @@ -33,6 +33,7 @@ MLIRLLVMIR MLIRLoopOps MLIRNVVMIR + MLIROpenMP MLIROptMain MLIRParser MLIRPass