diff --git a/mlir/include/mlir/Dialect/OpenMP/CMakeLists.txt b/mlir/include/mlir/Dialect/OpenMP/CMakeLists.txt --- a/mlir/include/mlir/Dialect/OpenMP/CMakeLists.txt +++ b/mlir/include/mlir/Dialect/OpenMP/CMakeLists.txt @@ -14,3 +14,4 @@ add_mlir_doc(OpenMPOps OpenMPDialect Dialects/ -gen-dialect-doc) add_public_tablegen_target(MLIROpenMPOpsIncGen) add_dependencies(OpenMPDialectDocGen omp_common_td) +add_mlir_interface(OpenMPOpsInterfaces) diff --git a/mlir/include/mlir/Dialect/OpenMP/OpenMPDialect.h b/mlir/include/mlir/Dialect/OpenMP/OpenMPDialect.h --- a/mlir/include/mlir/Dialect/OpenMP/OpenMPDialect.h +++ b/mlir/include/mlir/Dialect/OpenMP/OpenMPDialect.h @@ -22,6 +22,7 @@ #include "mlir/Dialect/OpenMP/OpenMPOpsDialect.h.inc" #include "mlir/Dialect/OpenMP/OpenMPOpsEnums.h.inc" +#include "mlir/Dialect/OpenMP/OpenMPOpsInterfaces.h.inc" #include "mlir/Dialect/OpenMP/OpenMPTypeInterfaces.h.inc" #define GET_OP_CLASSES diff --git a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td --- a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td +++ b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td @@ -20,6 +20,7 @@ include "mlir/IR/SymbolInterfaces.td" include "mlir/Dialect/OpenMP/OmpCommon.td" include "mlir/Dialect/LLVMIR/LLVMOpBase.td" +include "mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td" def OpenMP_Dialect : Dialect { let name = "omp"; @@ -72,7 +73,8 @@ let cppNamespace = "::mlir::omp"; } -def ParallelOp : OpenMP_Op<"parallel", [AttrSizedOperandSegments]> { +def ParallelOp : OpenMP_Op<"parallel", [AttrSizedOperandSegments, + DeclareOpInterfaceMethods]> { let summary = "parallel construct"; let description = [{ The parallel construct includes a region of code which is to be executed diff --git a/mlir/include/mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td b/mlir/include/mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td new file mode 100644 --- /dev/null +++ b/mlir/include/mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td @@ -0,0 +1,34 @@ +//===-- OpenMPOpsInterfaces.td - OpenMP op interfaces ------*- tablegen -*-===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// +// This is the OpenMP Dialect interfaces definition file. +// +//===----------------------------------------------------------------------===// + +#ifndef OpenMP_OPS_INTERFACES +#define OpenMP_OPS_INTERFACES + +include "mlir/IR/OpBase.td" + +def OutlineableOpenMPOpInterface : OpInterface<"OutlineableOpenMPOpInterface"> { + let description = [{ + OpenMP operations whose region will be outlined will implement this + interface. These operations will + }]; + + let cppNamespace = "::mlir::omp"; + + let methods = [ + InterfaceMethod<"Get alloca block", "::mlir::Block*", "getAllocaBlock", + (ins), [{ + return &$_op.getRegion().front(); + }]>, + ]; +} + +#endif // OpenMP_OPS_INTERFACES diff --git a/mlir/lib/Dialect/OpenMP/CMakeLists.txt b/mlir/lib/Dialect/OpenMP/CMakeLists.txt --- a/mlir/lib/Dialect/OpenMP/CMakeLists.txt +++ b/mlir/lib/Dialect/OpenMP/CMakeLists.txt @@ -6,6 +6,7 @@ DEPENDS MLIROpenMPOpsIncGen + MLIROpenMPOpsInterfacesIncGen LINK_LIBS PUBLIC MLIRIR