19 #define GEN_PASS_DEF_SYMBOLPRIVATIZE
20 #include "mlir/Transforms/Passes.h.inc"
26 struct SymbolPrivatize :
public impl::SymbolPrivatizeBase<SymbolPrivatize> {
28 LogicalResult initialize(
MLIRContext *context)
override;
29 void runOnOperation()
override;
37 exclude = excludeSymbols;
40 LogicalResult SymbolPrivatize::initialize(
MLIRContext *context) {
41 for (
const std::string &symbol : exclude)
46 void SymbolPrivatize::runOnOperation() {
47 for (
Region ®ion : getOperation()->getRegions()) {
48 for (
Block &block : region) {
50 auto symbol = dyn_cast<SymbolOpInterface>(op);
53 if (!excludedSymbols.contains(symbol.getNameAttr()))
62 return std::make_unique<SymbolPrivatize>(exclude);
Block represents an ordered list of Operations.
MLIRContext is the top-level object for a collection of MLIR operations.
Operation is the basic unit of execution within MLIR.
This class contains a list of basic blocks and a link to the parent operation it is attached to.
@ Private
The symbol is private and may only be referenced by SymbolRefAttrs local to the operations within the...
Include the generated interface declarations.
auto get(MLIRContext *context, Ts &&...params)
Helper method that injects context only if needed, this helps unify some of the attribute constructio...
std::unique_ptr< Pass > createSymbolPrivatizePass(ArrayRef< std::string > excludeSymbols={})
Creates a pass which marks top-level symbol operations as private unless listed in excludeSymbols.