[Mlir-commits] [mlir] b2bdb0b - [mlir] Make FunctionOpInterface inherit SymbolOpInterface
River Riddle
llvmlistbot at llvm.org
Wed Jan 18 19:16:51 PST 2023
Author: River Riddle
Date: 2023-01-18T19:16:30-08:00
New Revision: b2bdb0ba0f6d331844c1b9dcccd522472c7188c9
URL: https://github.com/llvm/llvm-project/commit/b2bdb0ba0f6d331844c1b9dcccd522472c7188c9
DIFF: https://github.com/llvm/llvm-project/commit/b2bdb0ba0f6d331844c1b9dcccd522472c7188c9.diff
LOG: [mlir] Make FunctionOpInterface inherit SymbolOpInterface
This lets users of FunctionOpInterface finally have the
name/visibility accessors from SymbolOpInterface. This also
lets us remove the clunky "getName" method from FunctionOpInterface.
Differential Revision: https://reviews.llvm.org/D140199
Added:
Modified:
mlir/examples/toy/Ch2/include/toy/Ops.td
mlir/examples/toy/Ch3/include/toy/Ops.td
mlir/examples/toy/Ch4/include/toy/Ops.td
mlir/examples/toy/Ch5/include/toy/Ops.td
mlir/examples/toy/Ch6/include/toy/Ops.td
mlir/examples/toy/Ch7/include/toy/Ops.td
mlir/include/mlir/Dialect/Async/IR/AsyncOps.td
mlir/include/mlir/Dialect/Func/IR/FuncOps.td
mlir/include/mlir/Dialect/GPU/IR/GPUOps.td
mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
mlir/include/mlir/Dialect/PDLInterp/IR/PDLInterpOps.td
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVStructureOps.td
mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
mlir/include/mlir/IR/FunctionInterfaces.td
mlir/test/Dialect/Func/invalid.mlir
Removed:
################################################################################
diff --git a/mlir/examples/toy/Ch2/include/toy/Ops.td b/mlir/examples/toy/Ch2/include/toy/Ops.td
index 08514d4fad0b2..ffe56e219ee72 100644
--- a/mlir/examples/toy/Ch2/include/toy/Ops.td
+++ b/mlir/examples/toy/Ch2/include/toy/Ops.td
@@ -114,7 +114,7 @@ def AddOp : Toy_Op<"add"> {
//===----------------------------------------------------------------------===//
def FuncOp : Toy_Op<"func", [
- FunctionOpInterface, IsolatedFromAbove, Symbol
+ FunctionOpInterface, IsolatedFromAbove
]> {
let summary = "user defined function operation";
let description = [{
diff --git a/mlir/examples/toy/Ch3/include/toy/Ops.td b/mlir/examples/toy/Ch3/include/toy/Ops.td
index 0836e3c37b52b..41536c0df44d7 100644
--- a/mlir/examples/toy/Ch3/include/toy/Ops.td
+++ b/mlir/examples/toy/Ch3/include/toy/Ops.td
@@ -113,7 +113,7 @@ def AddOp : Toy_Op<"add", [Pure]> {
//===----------------------------------------------------------------------===//
def FuncOp : Toy_Op<"func", [
- FunctionOpInterface, IsolatedFromAbove, Symbol
+ FunctionOpInterface, IsolatedFromAbove
]> {
let summary = "user defined function operation";
let description = [{
diff --git a/mlir/examples/toy/Ch4/include/toy/Ops.td b/mlir/examples/toy/Ch4/include/toy/Ops.td
index dcf999685ce0d..a91786f083525 100644
--- a/mlir/examples/toy/Ch4/include/toy/Ops.td
+++ b/mlir/examples/toy/Ch4/include/toy/Ops.td
@@ -143,7 +143,7 @@ def CastOp : Toy_Op<"cast", [
def FuncOp : Toy_Op<"func", [
DeclareOpInterfaceMethods<CallableOpInterface>, FunctionOpInterface,
- IsolatedFromAbove, Symbol
+ IsolatedFromAbove
]> {
let summary = "user defined function operation";
let description = [{
diff --git a/mlir/examples/toy/Ch5/include/toy/Ops.td b/mlir/examples/toy/Ch5/include/toy/Ops.td
index d6675b7ded922..5cf677d6fa7ac 100644
--- a/mlir/examples/toy/Ch5/include/toy/Ops.td
+++ b/mlir/examples/toy/Ch5/include/toy/Ops.td
@@ -143,7 +143,7 @@ def CastOp : Toy_Op<"cast", [
def FuncOp : Toy_Op<"func", [
DeclareOpInterfaceMethods<CallableOpInterface>, FunctionOpInterface,
- IsolatedFromAbove, Symbol
+ IsolatedFromAbove
]> {
let summary = "user defined function operation";
let description = [{
diff --git a/mlir/examples/toy/Ch6/include/toy/Ops.td b/mlir/examples/toy/Ch6/include/toy/Ops.td
index 2229cde162de4..e15bcb903949f 100644
--- a/mlir/examples/toy/Ch6/include/toy/Ops.td
+++ b/mlir/examples/toy/Ch6/include/toy/Ops.td
@@ -143,7 +143,7 @@ def CastOp : Toy_Op<"cast", [
def FuncOp : Toy_Op<"func", [
DeclareOpInterfaceMethods<CallableOpInterface>, FunctionOpInterface,
- IsolatedFromAbove, Symbol
+ IsolatedFromAbove
]> {
let summary = "user defined function operation";
let description = [{
diff --git a/mlir/examples/toy/Ch7/include/toy/Ops.td b/mlir/examples/toy/Ch7/include/toy/Ops.td
index 504d316f2f937..04d6e314574bd 100644
--- a/mlir/examples/toy/Ch7/include/toy/Ops.td
+++ b/mlir/examples/toy/Ch7/include/toy/Ops.td
@@ -167,7 +167,7 @@ def CastOp : Toy_Op<"cast", [
def FuncOp : Toy_Op<"func", [
DeclareOpInterfaceMethods<CallableOpInterface>, FunctionOpInterface,
- IsolatedFromAbove, Symbol
+ IsolatedFromAbove
]> {
let summary = "user defined function operation";
let description = [{
diff --git a/mlir/include/mlir/Dialect/Async/IR/AsyncOps.td b/mlir/include/mlir/Dialect/Async/IR/AsyncOps.td
index 9db2167de7baa..2cf5ee810b7a0 100644
--- a/mlir/include/mlir/Dialect/Async/IR/AsyncOps.td
+++ b/mlir/include/mlir/Dialect/Async/IR/AsyncOps.td
@@ -106,7 +106,7 @@ def Async_ExecuteOp :
def Async_FuncOp : Async_Op<"func",
[CallableOpInterface, FunctionOpInterface,
- IsolatedFromAbove, OpAsmOpInterface, Symbol]> {
+ IsolatedFromAbove, OpAsmOpInterface]> {
let summary = "async function operation";
let description = [{
An async function is like a normal function, but supports non-blocking
diff --git a/mlir/include/mlir/Dialect/Func/IR/FuncOps.td b/mlir/include/mlir/Dialect/Func/IR/FuncOps.td
index 50c01cff57048..8804c31a97cd8 100644
--- a/mlir/include/mlir/Dialect/Func/IR/FuncOps.td
+++ b/mlir/include/mlir/Dialect/Func/IR/FuncOps.td
@@ -209,7 +209,7 @@ def ConstantOp : Func_Op<"constant",
def FuncOp : Func_Op<"func", [
AffineScope, AutomaticAllocationScope, CallableOpInterface,
- FunctionOpInterface, IsolatedFromAbove, OpAsmOpInterface, Symbol
+ FunctionOpInterface, IsolatedFromAbove, OpAsmOpInterface
]> {
let summary = "An operation with a name containing a single `SSACFG` region";
let description = [{
diff --git a/mlir/include/mlir/Dialect/GPU/IR/GPUOps.td b/mlir/include/mlir/Dialect/GPU/IR/GPUOps.td
index 650ebe4b2b109..498117eb43ca6 100644
--- a/mlir/include/mlir/Dialect/GPU/IR/GPUOps.td
+++ b/mlir/include/mlir/Dialect/GPU/IR/GPUOps.td
@@ -180,7 +180,7 @@ def GPU_SubgroupSizeOp : GPU_Op<"subgroup_size", [
def GPU_GPUFuncOp : GPU_Op<"func", [
HasParent<"GPUModuleOp">, AutomaticAllocationScope, FunctionOpInterface,
- IsolatedFromAbove, Symbol
+ IsolatedFromAbove
]> {
let summary = "Function executable on a GPU";
diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
index e01c6bb81e89a..a97073e792afd 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
@@ -1443,7 +1443,7 @@ def LLVM_GlobalDtorsOp : LLVM_Op<"mlir.global_dtors", [
def LLVM_LLVMFuncOp : LLVM_Op<"func", [
AutomaticAllocationScope, IsolatedFromAbove, FunctionOpInterface,
- CallableOpInterface, Symbol
+ CallableOpInterface
]> {
let summary = "LLVM dialect function.";
diff --git a/mlir/include/mlir/Dialect/PDLInterp/IR/PDLInterpOps.td b/mlir/include/mlir/Dialect/PDLInterp/IR/PDLInterpOps.td
index af6fcb93100be..9734e1d1d021c 100644
--- a/mlir/include/mlir/Dialect/PDLInterp/IR/PDLInterpOps.td
+++ b/mlir/include/mlir/Dialect/PDLInterp/IR/PDLInterpOps.td
@@ -631,7 +631,7 @@ def PDLInterp_ForEachOp
//===----------------------------------------------------------------------===//
def PDLInterp_FuncOp : PDLInterp_Op<"func", [
- FunctionOpInterface, IsolatedFromAbove, Symbol
+ FunctionOpInterface, IsolatedFromAbove
]> {
let summary = "PDL Interpreter Function Operation";
let description = [{
diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVStructureOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVStructureOps.td
index 8c432b21a1b7d..78944e809899e 100644
--- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVStructureOps.td
+++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVStructureOps.td
@@ -257,7 +257,7 @@ def SPIRV_ExecutionModeOp : SPIRV_Op<"ExecutionMode", [InModuleScope]> {
def SPIRV_FuncOp : SPIRV_Op<"func", [
AutomaticAllocationScope, DeclareOpInterfaceMethods<CallableOpInterface>,
- FunctionOpInterface, InModuleScope, IsolatedFromAbove, Symbol
+ FunctionOpInterface, InModuleScope, IsolatedFromAbove
]> {
let summary = "Declare or define a function";
diff --git a/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td b/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
index b8a3fb7b4f199..ae84b07acab2d 100644
--- a/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
+++ b/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
@@ -1103,7 +1103,7 @@ def Shape_FunctionLibraryOp : Shape_Op<"function_library",
def Shape_FuncOp : Shape_Op<"func",
[AffineScope, AutomaticAllocationScope, CallableOpInterface,
- FunctionOpInterface, IsolatedFromAbove, OpAsmOpInterface, Symbol]> {
+ FunctionOpInterface, IsolatedFromAbove, OpAsmOpInterface]> {
let summary = "Shape function";
let description = [{
An operation with a name containing a single `SSACFG` region which
diff --git a/mlir/include/mlir/IR/FunctionInterfaces.td b/mlir/include/mlir/IR/FunctionInterfaces.td
index 0e8a3addfa7ee..c30454a5268c1 100644
--- a/mlir/include/mlir/IR/FunctionInterfaces.td
+++ b/mlir/include/mlir/IR/FunctionInterfaces.td
@@ -14,13 +14,13 @@
#ifndef MLIR_IR_FUNCTIONINTERFACES_TD_
#define MLIR_IR_FUNCTIONINTERFACES_TD_
-include "mlir/IR/OpBase.td"
+include "mlir/IR/SymbolInterfaces.td"
//===----------------------------------------------------------------------===//
// FunctionOpInterface
//===----------------------------------------------------------------------===//
-def FunctionOpInterface : OpInterface<"FunctionOpInterface"> {
+def FunctionOpInterface : OpInterface<"FunctionOpInterface", [Symbol]> {
let cppNamespace = "::mlir";
let description = [{
This interfaces provides support for interacting with operations that
@@ -164,14 +164,6 @@ def FunctionOpInterface : OpInterface<"FunctionOpInterface"> {
}]>,
];
- let extraClassDeclaration = [{
- //===------------------------------------------------------------------===//
- // Name
- //===------------------------------------------------------------------===//
-
- /// Return the name of the function.
- StringRef getName() { return SymbolTable::getSymbolName(*this); }
- }];
let extraTraitClassDeclaration = [{
//===------------------------------------------------------------------===//
// Builders
diff --git a/mlir/test/Dialect/Func/invalid.mlir b/mlir/test/Dialect/Func/invalid.mlir
index 34eda5e7b2747..a30aa448a1b09 100644
--- a/mlir/test/Dialect/Func/invalid.mlir
+++ b/mlir/test/Dialect/Func/invalid.mlir
@@ -181,12 +181,12 @@ func.func @$invalid_function_name()
// -----
// expected-error @+1 {{arguments may only have dialect attributes}}
-func.func @invalid_func_arg_attr(i1 {non_dialect_attr = 10})
+func.func private @invalid_func_arg_attr(i1 {non_dialect_attr = 10})
// -----
// expected-error @+1 {{results may only have dialect attributes}}
-func.func @invalid_func_result_attr() -> (i1 {non_dialect_attr = 10})
+func.func private @invalid_func_result_attr() -> (i1 {non_dialect_attr = 10})
// -----
More information about the Mlir-commits
mailing list