Skip to content

Commit 3b01cf9

Browse files
kiranchandramohanclementval
authored andcommitted
[mlir][openmp] Add an interface for Outlineable OpenMP ops
Add an interface for outlineable OpenMP operations. This patch was initially done in fir-dev and is now needed for the upstreaming. Reviewed By: schweitz Differential Revision: https://reviews.llvm.org/D111310
1 parent c5f445d commit 3b01cf9

File tree

5 files changed

+40
-1
lines changed

5 files changed

+40
-1
lines changed

mlir/include/mlir/Dialect/OpenMP/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ mlir_tablegen(OpenMPTypeInterfaces.cpp.inc -gen-type-interface-defs)
1414
add_mlir_doc(OpenMPOps OpenMPDialect Dialects/ -gen-dialect-doc)
1515
add_public_tablegen_target(MLIROpenMPOpsIncGen)
1616
add_dependencies(OpenMPDialectDocGen omp_common_td)
17+
add_mlir_interface(OpenMPOpsInterfaces)

mlir/include/mlir/Dialect/OpenMP/OpenMPDialect.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
#include "mlir/Dialect/OpenMP/OpenMPOpsDialect.h.inc"
2424
#include "mlir/Dialect/OpenMP/OpenMPOpsEnums.h.inc"
25+
#include "mlir/Dialect/OpenMP/OpenMPOpsInterfaces.h.inc"
2526
#include "mlir/Dialect/OpenMP/OpenMPTypeInterfaces.h.inc"
2627

2728
#define GET_OP_CLASSES

mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ include "mlir/Interfaces/ControlFlowInterfaces.td"
2020
include "mlir/IR/SymbolInterfaces.td"
2121
include "mlir/Dialect/OpenMP/OmpCommon.td"
2222
include "mlir/Dialect/LLVMIR/LLVMOpBase.td"
23+
include "mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td"
2324

2425
def OpenMP_Dialect : Dialect {
2526
let name = "omp";
@@ -72,7 +73,8 @@ def ClauseDefault : StrEnumAttr<
7273
let cppNamespace = "::mlir::omp";
7374
}
7475

75-
def ParallelOp : OpenMP_Op<"parallel", [AttrSizedOperandSegments]> {
76+
def ParallelOp : OpenMP_Op<"parallel", [AttrSizedOperandSegments,
77+
DeclareOpInterfaceMethods<OutlineableOpenMPOpInterface>]> {
7678
let summary = "parallel construct";
7779
let description = [{
7880
The parallel construct includes a region of code which is to be executed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//===-- OpenMPOpsInterfaces.td - OpenMP op interfaces ------*- 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 is the OpenMP Dialect interfaces definition file.
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#ifndef OpenMP_OPS_INTERFACES
14+
#define OpenMP_OPS_INTERFACES
15+
16+
include "mlir/IR/OpBase.td"
17+
18+
def OutlineableOpenMPOpInterface : OpInterface<"OutlineableOpenMPOpInterface"> {
19+
let description = [{
20+
OpenMP operations whose region will be outlined will implement this
21+
interface. These operations will
22+
}];
23+
24+
let cppNamespace = "::mlir::omp";
25+
26+
let methods = [
27+
InterfaceMethod<"Get alloca block", "::mlir::Block*", "getAllocaBlock",
28+
(ins), [{
29+
return &$_op.getRegion().front();
30+
}]>,
31+
];
32+
}
33+
34+
#endif // OpenMP_OPS_INTERFACES

mlir/lib/Dialect/OpenMP/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ add_mlir_dialect_library(MLIROpenMP
66

77
DEPENDS
88
MLIROpenMPOpsIncGen
9+
MLIROpenMPOpsInterfacesIncGen
910

1011
LINK_LIBS PUBLIC
1112
MLIRIR

0 commit comments

Comments
 (0)