[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
This commit is contained in:
Rahul Joshi 2020-11-09 11:43:45 -08:00
parent 8d51969bd4
commit 64be856f6d
5 changed files with 28 additions and 10 deletions

View File

@ -172,7 +172,7 @@ private:
// 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;
}

View File

@ -172,7 +172,7 @@ private:
// 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;
}

View File

@ -172,7 +172,7 @@ private:
// 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;
}

View File

@ -225,7 +225,7 @@ private:
// 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;
}

View File

@ -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'.