[Mlir-commits] [mlir] 3d316eb - [MLIR] Move SymbolOpInterface::isPublic() and friends to SymbolOpInterface Trait.
Rahul Joshi
llvmlistbot at llvm.org
Wed Jun 17 21:33:54 PDT 2020
Author: Rahul Joshi
Date: 2020-06-17T21:33:25-07:00
New Revision: 3d316eb06d91cd859f5da51715bab7ee3cae8bf0
URL: https://github.com/llvm/llvm-project/commit/3d316eb06d91cd859f5da51715bab7ee3cae8bf0
DIFF: https://github.com/llvm/llvm-project/commit/3d316eb06d91cd859f5da51715bab7ee3cae8bf0.diff
LOG: [MLIR] Move SymbolOpInterface::isPublic() and friends to SymbolOpInterface Trait.
- This will allow calling these functions from Op's that support this interface (like FuncOp) directly:
```
FuncOp func = ...
func.isPrivate()
```
Differential Revision: https://reviews.llvm.org/D82060
Added:
Modified:
mlir/include/mlir/IR/SymbolInterfaces.td
Removed:
################################################################################
diff --git a/mlir/include/mlir/IR/SymbolInterfaces.td b/mlir/include/mlir/IR/SymbolInterfaces.td
index 219ea6048f02..de2f4cda2b8d 100644
--- a/mlir/include/mlir/IR/SymbolInterfaces.td
+++ b/mlir/include/mlir/IR/SymbolInterfaces.td
@@ -58,6 +58,24 @@ def Symbol : OpInterface<"SymbolOpInterface"> {
mlir::SymbolTable::setSymbolVisibility(this->getOperation(), vis);
}]
>,
+ InterfaceMethod<"Returns true if this symbol has nested visibility.",
+ "bool", "isNested", (ins), [{}],
+ /*defaultImplementation=*/[{
+ return getVisibility() == mlir::SymbolTable::Visibility::Nested;
+ }]
+ >,
+ InterfaceMethod<"Returns true if this symbol has private visibility.",
+ "bool", "isPrivate", (ins), [{}],
+ /*defaultImplementation=*/[{
+ return getVisibility() == mlir::SymbolTable::Visibility::Private;
+ }]
+ >,
+ InterfaceMethod<"Returns true if this symbol has public visibility.",
+ "bool", "isPublic", (ins), [{}],
+ /*defaultImplementation=*/[{
+ return getVisibility() == mlir::SymbolTable::Visibility::Public;
+ }]
+ >,
InterfaceMethod<[{
Get all of the uses of the current symbol that are nested within the
given operation 'from'.
@@ -124,20 +142,11 @@ def Symbol : OpInterface<"SymbolOpInterface"> {
}];
let extraClassDeclaration = [{
- using Visibility = mlir::SymbolTable::Visibility;
-
/// Custom classof that handles the case where the symbol is optional.
static bool classof(Operation *op) {
return Base::classof(op)
&& op->getAttr(::mlir::SymbolTable::getSymbolAttrName());
}
-
- /// Returns true if this symbol has nested visibility.
- bool isNested() { return getVisibility() == Visibility::Nested; }
- /// Returns true if this symbol has private visibility.
- bool isPrivate() { return getVisibility() == Visibility::Private; }
- /// Returns true if this symbol has public visibility.
- bool isPublic() { return getVisibility() == Visibility::Public; }
}];
let extraTraitClassDeclaration = [{
More information about the Mlir-commits
mailing list