forked from OSchip/llvm-project
[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
This commit is contained in:
parent
f7453a97ce
commit
3d316eb06d
|
@ -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 = [{
|
||||
|
|
Loading…
Reference in New Issue