summaryrefslogtreecommitdiff
path: root/mlir/lib/Dialect/MLProgram/IR/MLProgramOps.cpp
diff options
context:
space:
mode:
authorJeff Niu <jeff@modular.com>2022-12-06 11:28:47 -0800
committerJeff Niu <jeff@modular.com>2022-12-08 11:32:27 -0800
commitfbc253fe81da4e1d6bfa2519e01e03f21d8c40a8 (patch)
tree35056422a800b99c38fd8217172dd94d74a8220e /mlir/lib/Dialect/MLProgram/IR/MLProgramOps.cpp
parentf9b80ed7fb83fa585065cccadc8f033a9d566e74 (diff)
[mlir] FunctionOpInterface: make get/setFunctionType interface methods
This patch removes the concept of a `function_type`-named type attribute as a requirement for implementors of FunctionOpInterface. Instead, this type should be provided through two interface methods, `getFunctionType` and `setFunctionTypeAttr` (*Attr because functions may use different concrete function types), which should be automatically implemented by ODS for ops that define a `$function_type` attribute. This also allows FunctionOpInterface to materialize function types if they don't carry them in an attribute, for example. Importantly, all the function "helper" still accept an attribute name to use in parsing and printing functions, for example. Reviewed By: rriddle, lattner Differential Revision: https://reviews.llvm.org/D139447
Diffstat (limited to 'mlir/lib/Dialect/MLProgram/IR/MLProgramOps.cpp')
-rw-r--r--mlir/lib/Dialect/MLProgram/IR/MLProgramOps.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/mlir/lib/Dialect/MLProgram/IR/MLProgramOps.cpp b/mlir/lib/Dialect/MLProgram/IR/MLProgramOps.cpp
index 2f1e4b93a6ac..27c613088df5 100644
--- a/mlir/lib/Dialect/MLProgram/IR/MLProgramOps.cpp
+++ b/mlir/lib/Dialect/MLProgram/IR/MLProgramOps.cpp
@@ -152,11 +152,13 @@ ParseResult FuncOp::parse(OpAsmParser &parser, OperationState &result) {
std::string &) { return builder.getFunctionType(argTypes, results); };
return function_interface_impl::parseFunctionOp(
- parser, result, /*allowVariadic=*/false, buildFuncType);
+ parser, result, /*allowVariadic=*/false,
+ getFunctionTypeAttrName(result.name), buildFuncType);
}
void FuncOp::print(OpAsmPrinter &p) {
- function_interface_impl::printFunctionOp(p, *this, /*isVariadic=*/false);
+ function_interface_impl::printFunctionOp(p, *this, /*isVariadic=*/false,
+ getFunctionTypeAttrName());
}
//===----------------------------------------------------------------------===//
@@ -313,11 +315,13 @@ ParseResult SubgraphOp::parse(OpAsmParser &parser, OperationState &result) {
std::string &) { return builder.getFunctionType(argTypes, results); };
return function_interface_impl::parseFunctionOp(
- parser, result, /*allowVariadic=*/false, buildFuncType);
+ parser, result, /*allowVariadic=*/false,
+ getFunctionTypeAttrName(result.name), buildFuncType);
}
void SubgraphOp::print(OpAsmPrinter &p) {
- function_interface_impl::printFunctionOp(p, *this, /*isVariadic=*/false);
+ function_interface_impl::printFunctionOp(p, *this, /*isVariadic=*/false,
+ getFunctionTypeAttrName());
}
//===----------------------------------------------------------------------===//