[Mlir-commits] [mlir] 64be856 - [MLIR] Add setPublic(), setPrivate(), and setNested() to Symbol interface
Rahul Joshi
llvmlistbot at llvm.org
Mon Nov 9 13:56:52 PST 2020
Author: Rahul Joshi
Date: 2020-11-09T13:56:38-08:00
New Revision: 64be856f6da058ad99b1709c7f91f6a928f054a7
URL: https://github.com/llvm/llvm-project/commit/64be856f6da058ad99b1709c7f91f6a928f054a7
DIFF: https://github.com/llvm/llvm-project/commit/64be856f6da058ad99b1709c7f91f6a928f054a7.diff
LOG: [MLIR] Add setPublic(), setPrivate(), and setNested() to Symbol interface
- Add shorter helper functions to set visibility for Symbols.
Differential Revision: https://reviews.llvm.org/D91096
Added:
Modified:
mlir/examples/toy/Ch4/mlir/MLIRGen.cpp
mlir/examples/toy/Ch5/mlir/MLIRGen.cpp
mlir/examples/toy/Ch6/mlir/MLIRGen.cpp
mlir/examples/toy/Ch7/mlir/MLIRGen.cpp
mlir/include/mlir/IR/SymbolInterfaces.td
Removed:
################################################################################
diff --git a/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp
index 78399786007a..4a8115b815bb 100644
--- a/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp
+++ b/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp
@@ -172,7 +172,7 @@ class MLIRGenImpl {
// If this function isn't main, then set the visibility to private.
if (funcAST.getProto()->getName() != "main")
- function.setVisibility(mlir::FuncOp::Visibility::Private);
+ function.setPrivate();
return function;
}
diff --git a/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp
index 78399786007a..4a8115b815bb 100644
--- a/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp
+++ b/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp
@@ -172,7 +172,7 @@ class MLIRGenImpl {
// If this function isn't main, then set the visibility to private.
if (funcAST.getProto()->getName() != "main")
- function.setVisibility(mlir::FuncOp::Visibility::Private);
+ function.setPrivate();
return function;
}
diff --git a/mlir/examples/toy/Ch6/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch6/mlir/MLIRGen.cpp
index 78399786007a..4a8115b815bb 100644
--- a/mlir/examples/toy/Ch6/mlir/MLIRGen.cpp
+++ b/mlir/examples/toy/Ch6/mlir/MLIRGen.cpp
@@ -172,7 +172,7 @@ class MLIRGenImpl {
// If this function isn't main, then set the visibility to private.
if (funcAST.getProto()->getName() != "main")
- function.setVisibility(mlir::FuncOp::Visibility::Private);
+ function.setPrivate();
return function;
}
diff --git a/mlir/examples/toy/Ch7/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch7/mlir/MLIRGen.cpp
index 58a153b6127b..a6690b7f8af1 100644
--- a/mlir/examples/toy/Ch7/mlir/MLIRGen.cpp
+++ b/mlir/examples/toy/Ch7/mlir/MLIRGen.cpp
@@ -225,7 +225,7 @@ class MLIRGenImpl {
// If this function isn't main, then set the visibility to private.
if (funcAST.getProto()->getName() != "main")
- function.setVisibility(mlir::FuncOp::Visibility::Private);
+ function.setPrivate();
return function;
}
diff --git a/mlir/include/mlir/IR/SymbolInterfaces.td b/mlir/include/mlir/IR/SymbolInterfaces.td
index c5f2bb8f631d..a997acee07f7 100644
--- a/mlir/include/mlir/IR/SymbolInterfaces.td
+++ b/mlir/include/mlir/IR/SymbolInterfaces.td
@@ -53,12 +53,6 @@ def Symbol : OpInterface<"SymbolOpInterface"> {
return mlir::SymbolTable::getSymbolVisibility(this->getOperation());
}]
>,
- InterfaceMethod<"Sets the visibility of this symbol.",
- "void", "setVisibility", (ins "mlir::SymbolTable::Visibility":$vis), [{}],
- /*defaultImplementation=*/[{
- mlir::SymbolTable::setSymbolVisibility(this->getOperation(), vis);
- }]
- >,
InterfaceMethod<"Returns true if this symbol has nested visibility.",
"bool", "isNested", (ins), [{}],
/*defaultImplementation=*/[{
@@ -77,6 +71,30 @@ def Symbol : OpInterface<"SymbolOpInterface"> {
return getVisibility() == mlir::SymbolTable::Visibility::Public;
}]
>,
+ InterfaceMethod<"Sets the visibility of this symbol.",
+ "void", "setVisibility", (ins "mlir::SymbolTable::Visibility":$vis), [{}],
+ /*defaultImplementation=*/[{
+ mlir::SymbolTable::setSymbolVisibility(this->getOperation(), vis);
+ }]
+ >,
+ InterfaceMethod<"Sets the visibility of this symbol to be nested.",
+ "void", "setNested", (ins), [{}],
+ /*defaultImplementation=*/[{
+ setVisibility(mlir::SymbolTable::Visibility::Nested);
+ }]
+ >,
+ InterfaceMethod<"Sets the visibility of this symbol to be private.",
+ "void", "setPrivate", (ins), [{}],
+ /*defaultImplementation=*/[{
+ setVisibility(mlir::SymbolTable::Visibility::Private);
+ }]
+ >,
+ InterfaceMethod<"Sets the visibility of this symbol to be public.",
+ "void", "setPublic", (ins), [{}],
+ /*defaultImplementation=*/[{
+ setVisibility(mlir::SymbolTable::Visibility::Public);
+ }]
+ >,
InterfaceMethod<[{
Get all of the uses of the current symbol that are nested within the
given operation 'from'.
More information about the Mlir-commits
mailing list