MLIR
20.0.0git
|
#include "mlir/IR/SymbolTable.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/OpImplementation.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringSwitch.h"
#include <optional>
#include "mlir/IR/SymbolInterfaces.cpp.inc"
Go to the source code of this file.
Functions | |
static bool | isPotentiallyUnknownSymbolTable (Operation *op) |
Return true if the given operation is unknown and may potentially define a symbol table. More... | |
static StringAttr | getNameIfSymbol (Operation *op) |
Returns the string name of the given symbol, or null if this is not a symbol. More... | |
static StringAttr | getNameIfSymbol (Operation *op, StringAttr symbolAttrNameId) |
static LogicalResult | collectValidReferencesFor (Operation *symbol, StringAttr symbolName, Operation *within, SmallVectorImpl< SymbolRefAttr > &results) |
Computes the nested symbol reference attribute for the symbol 'symbolName' that are usable within the symbol table operations from 'symbol' as far up to the given operation 'within', where 'within' is an ancestor of 'symbol'. More... | |
static std::optional< WalkResult > | walkSymbolTable (MutableArrayRef< Region > regions, function_ref< std::optional< WalkResult >(Operation *)> callback) |
Walk all of the operations within the given set of regions, without traversing into any nested symbol tables. More... | |
static std::optional< WalkResult > | walkSymbolTable (Operation *op, function_ref< std::optional< WalkResult >(Operation *)> callback) |
Walk all of the operations nested under, and including, the given operation, without traversing into any nested symbol tables. More... | |
static LogicalResult | lookupSymbolInImpl (Operation *symbolTableOp, SymbolRefAttr symbol, SmallVectorImpl< Operation * > &symbols, function_ref< Operation *(Operation *, StringAttr)> lookupSymbolFn) |
Internal implementation of lookupSymbolIn that allows for specialized implementations of the lookup function. More... | |
static WalkResult | walkSymbolRefs (Operation *op, function_ref< WalkResult(SymbolTable::SymbolUse)> callback) |
Walk all of the symbol references within the given operation, invoking the provided callback for each found use. More... | |
static std::optional< WalkResult > | walkSymbolUses (MutableArrayRef< Region > regions, function_ref< WalkResult(SymbolTable::SymbolUse)> callback) |
Walk all of the uses, for any symbol, that are nested within the given regions, invoking the provided callback for each. More... | |
static std::optional< WalkResult > | walkSymbolUses (Operation *from, function_ref< WalkResult(SymbolTable::SymbolUse)> callback) |
Walk all of the uses, for any symbol, that are nested within the given operation 'from', invoking the provided callback for each. More... | |
static SmallVector< SymbolScope, 2 > | collectSymbolScopes (Operation *symbol, Operation *limit) |
Collect all of the symbol scopes from 'symbol' to (inclusive) 'limit'. More... | |
static SmallVector< SymbolScope, 2 > | collectSymbolScopes (Operation *symbol, Region *limit) |
static SmallVector< SymbolScope, 1 > | collectSymbolScopes (StringAttr symbol, Region *limit) |
static SmallVector< SymbolScope, 1 > | collectSymbolScopes (StringAttr symbol, Operation *limit) |
static bool | isReferencePrefixOf (SymbolRefAttr subRef, SymbolRefAttr ref) |
Returns true if the given reference 'SubRef' is a sub reference of the reference 'ref', i.e. More... | |
template<typename FromT > | |
static std::optional< SymbolTable::UseRange > | getSymbolUsesImpl (FromT from) |
The implementation of SymbolTable::getSymbolUses below. More... | |
template<typename SymbolT , typename IRUnitT > | |
static std::optional< SymbolTable::UseRange > | getSymbolUsesImpl (SymbolT symbol, IRUnitT *limit) |
The implementation of SymbolTable::getSymbolUses below. More... | |
template<typename SymbolT , typename IRUnitT > | |
static bool | symbolKnownUseEmptyImpl (SymbolT symbol, IRUnitT *limit) |
The implementation of SymbolTable::symbolKnownUseEmpty below. More... | |
static SymbolRefAttr | generateNewRefAttr (SymbolRefAttr oldAttr, FlatSymbolRefAttr newLeafAttr) |
Generates a new symbol reference attribute with a new leaf reference. More... | |
template<typename SymbolT , typename IRUnitT > | |
static LogicalResult | replaceAllSymbolUsesImpl (SymbolT symbol, StringAttr newSymbol, IRUnitT *limit) |
The implementation of SymbolTable::replaceAllSymbolUses below. More... | |
|
static |
Collect all of the symbol scopes from 'symbol' to (inclusive) 'limit'.
Definition at line 658 of file SymbolTable.cpp.
References collectValidReferencesFor(), mlir::get(), mlir::SymbolTable::getNearestSymbolTable(), mlir::Operation::getParentOp(), mlir::Operation::getRegion(), mlir::SymbolTable::getSymbolName(), and mlir::Operation::hasTrait().
Referenced by collectSymbolScopes(), getSymbolUsesImpl(), replaceAllSymbolUsesImpl(), and symbolKnownUseEmptyImpl().
|
static |
Definition at line 718 of file SymbolTable.cpp.
References collectSymbolScopes(), and mlir::Region::getParentOp().
|
static |
Definition at line 733 of file SymbolTable.cpp.
References mlir::get(), and mlir::Operation::getRegions().
|
static |
Definition at line 728 of file SymbolTable.cpp.
References mlir::get().
|
static |
Computes the nested symbol reference attribute for the symbol 'symbolName' that are usable within the symbol table operations from 'symbol' as far up to the given operation 'within', where 'within' is an ancestor of 'symbol'.
Returns success if all references up to 'within' could be computed.
Definition at line 40 of file SymbolTable.cpp.
References mlir::get(), mlir::FlatSymbolRefAttr::get(), mlir::Operation::getContext(), getNameIfSymbol(), mlir::Operation::getParentOp(), mlir::SymbolTable::getSymbolAttrName(), mlir::Operation::hasTrait(), and mlir::Operation::isAncestor().
Referenced by collectSymbolScopes().
|
static |
Generates a new symbol reference attribute with a new leaf reference.
Definition at line 868 of file SymbolTable.cpp.
References mlir::get().
Referenced by replaceAllSymbolUsesImpl().
|
static |
Returns the string name of the given symbol, or null if this is not a symbol.
Definition at line 28 of file SymbolTable.cpp.
References mlir::Operation::getAttrOfType(), and mlir::SymbolTable::getSymbolAttrName().
Referenced by collectValidReferencesFor(), mlir::SymbolTable::getSymbolName(), mlir::SymbolTable::lookupSymbolIn(), mlir::SymbolTable::remove(), mlir::SymbolTable::rename(), mlir::SymbolTable::renameToUnique(), and mlir::SymbolTable::SymbolTable().
|
static |
Definition at line 31 of file SymbolTable.cpp.
References mlir::Operation::getAttrOfType().
|
static |
The implementation of SymbolTable::getSymbolUses below.
Definition at line 765 of file SymbolTable.cpp.
References mlir::WalkResult::advance(), and walkSymbolUses().
Referenced by mlir::SymbolTable::getSymbolUses().
|
static |
The implementation of SymbolTable::getSymbolUses below.
Definition at line 795 of file SymbolTable.cpp.
References collectSymbolScopes().
|
static |
Return true if the given operation is unknown and may potentially define a symbol table.
Definition at line 22 of file SymbolTable.cpp.
References mlir::Operation::getDialect(), and mlir::Operation::getNumRegions().
Referenced by mlir::SymbolTable::getNearestSymbolTable(), and walkSymbolUses().
|
static |
Returns true if the given reference 'SubRef' is a sub reference of the reference 'ref', i.e.
'ref' is a further qualified reference.
Definition at line 744 of file SymbolTable.cpp.
Referenced by replaceAllSymbolUsesImpl().
|
static |
Internal implementation of lookupSymbolIn
that allows for specialized implementations of the lookup function.
Definition at line 410 of file SymbolTable.cpp.
References mlir::Operation::getAttr(), and mlir::Operation::hasTrait().
Referenced by mlir::SymbolTable::lookupSymbolIn(), mlir::SymbolTableCollection::lookupSymbolIn(), and mlir::LockedSymbolTableCollection::lookupSymbolIn().
|
static |
The implementation of SymbolTable::replaceAllSymbolUses below.
Definition at line 880 of file SymbolTable.cpp.
References mlir::detail::AttrTypeReplacerBase< Concrete >::addReplacement(), mlir::WalkResult::advance(), collectSymbolScopes(), generateNewRefAttr(), mlir::get(), mlir::FlatSymbolRefAttr::get(), isReferencePrefixOf(), mlir::detail::AttrTypeReplacerBase< Concrete >::replaceElementsIn(), and mlir::WalkResult::skip().
Referenced by mlir::SymbolTable::replaceAllSymbolUses().
|
static |
The implementation of SymbolTable::symbolKnownUseEmpty below.
Definition at line 834 of file SymbolTable.cpp.
References mlir::WalkResult::advance(), and collectSymbolScopes().
Referenced by mlir::SymbolTable::symbolKnownUseEmpty().
|
static |
Walk all of the symbol references within the given operation, invoking the provided callback for each found use.
The callbacks takes the use of the symbol.
Definition at line 556 of file SymbolTable.cpp.
References mlir::Operation::getAttrDictionary(), mlir::WalkResult::interrupt(), mlir::PreOrder, and mlir::WalkResult::skip().
Referenced by walkSymbolUses().
|
static |
Walk all of the operations within the given set of regions, without traversing into any nested symbol tables.
Stops walking if the result of the callback is anything other than WalkResult::advance
.
Definition at line 81 of file SymbolTable.cpp.
References mlir::WalkResult::advance().
Referenced by mlir::detail::verifySymbolTable(), walkSymbolTable(), and walkSymbolUses().
|
static |
Walk all of the operations nested under, and including, the given operation, without traversing into any nested symbol tables.
Stops walking if the result of the callback is anything other than WalkResult::advance
.
Definition at line 105 of file SymbolTable.cpp.
References mlir::WalkResult::advance(), mlir::Operation::getRegions(), mlir::Operation::hasTrait(), and walkSymbolTable().
|
static |
Walk all of the uses, for any symbol, that are nested within the given regions, invoking the provided callback for each.
This does not traverse into any nested symbol tables.
Definition at line 572 of file SymbolTable.cpp.
References isPotentiallyUnknownSymbolTable(), walkSymbolRefs(), and walkSymbolTable().
Referenced by getSymbolUsesImpl(), and walkSymbolUses().
|
static |
Walk all of the uses, for any symbol, that are nested within the given operation 'from', invoking the provided callback for each.
This does not traverse into any nested symbol tables.
Definition at line 588 of file SymbolTable.cpp.
References mlir::WalkResult::advance(), mlir::Operation::getRegions(), mlir::Operation::hasTrait(), mlir::WalkResult::interrupt(), isPotentiallyUnknownSymbolTable(), walkSymbolRefs(), and walkSymbolUses().