|
MLIR 24.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/SmallString.h"#include "llvm/ADT/StringSwitch.h"#include <optional>#include "mlir/IR/SymbolInterfaces.cpp.inc"#include "mlir/IR/SymbolInterfacesAttrInterface.cpp.inc"#include "mlir/IR/SymbolInterfacesTypeInterface.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. | |
| static StringAttr | getNameIfSymbol (Operation *op) |
| Returns the string name of the given symbol, or null if this is not a symbol. | |
| 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'. | |
| 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. | |
| 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. | |
| 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. | |
| static LogicalResult | verifyOpTypeSymbolUses (Operation *op, SymbolTableCollection &symbolTable, SetVector< Type > &verifiedTypes) |
| Verify the symbol uses held by the types owned by op: its operand, result, and block-argument types, and any types nested within its attributes. | |
| 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. | |
| 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. | |
| 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. | |
| static SmallVector< SymbolScope, 2 > | collectSymbolScopes (Operation *symbol, Operation *limit) |
| Collect all of the symbol scopes from 'symbol' to (inclusive) 'limit'. | |
| 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. | |
| template<typename FromT> | |
| static std::optional< SymbolTable::UseRange > | getSymbolUsesImpl (FromT from) |
| The implementation of SymbolTable::getSymbolUses below. | |
| template<typename SymbolT, typename IRUnitT> | |
| static std::optional< SymbolTable::UseRange > | getSymbolUsesImpl (SymbolT symbol, IRUnitT *limit) |
| The implementation of SymbolTable::getSymbolUses below. | |
| template<typename SymbolT, typename IRUnitT> | |
| static bool | symbolKnownUseEmptyImpl (SymbolT symbol, IRUnitT *limit) |
| The implementation of SymbolTable::symbolKnownUseEmpty below. | |
| static SymbolRefAttr | generateNewRefAttr (SymbolRefAttr oldAttr, FlatSymbolRefAttr newLeafAttr) |
| Generates a new symbol reference attribute with a new leaf reference. | |
| template<typename SymbolT, typename IRUnitT> | |
| static LogicalResult | replaceAllSymbolUsesImpl (SymbolT symbol, StringAttr newSymbol, IRUnitT *limit) |
| The implementation of SymbolTable::replaceAllSymbolUses below. | |
|
static |
Collect all of the symbol scopes from 'symbol' to (inclusive) 'limit'.
Definition at line 717 of file SymbolTable.cpp.
References collectValidReferencesFor(), 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 777 of file SymbolTable.cpp.
References collectSymbolScopes(), and mlir::Region::getParentOp().
|
static |
Definition at line 792 of file SymbolTable.cpp.
References mlir::Operation::getRegions().
|
static |
Definition at line 787 of file SymbolTable.cpp.
|
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 39 of file SymbolTable.cpp.
References mlir::FlatSymbolRefAttr::get(), mlir::Operation::getContext(), getNameIfSymbol(), mlir::Operation::getParentOp(), mlir::SymbolTable::getSymbolAttrName(), mlir::Operation::hasTrait(), mlir::Operation::isAncestor(), and success().
Referenced by collectSymbolScopes().
|
static |
Generates a new symbol reference attribute with a new leaf reference.
Definition at line 931 of file SymbolTable.cpp.
Referenced by replaceAllSymbolUsesImpl().
|
static |
Returns the string name of the given symbol, or null if this is not a symbol.
Definition at line 27 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 30 of file SymbolTable.cpp.
References mlir::Operation::getAttrOfType().
|
static |
The implementation of SymbolTable::getSymbolUses below.
Definition at line 825 of file SymbolTable.cpp.
References mlir::WalkResult::advance(), result, and walkSymbolUses().
Referenced by mlir::SymbolTable::getSymbolUses(), mlir::SymbolTable::getSymbolUses(), mlir::SymbolTable::getSymbolUses(), mlir::SymbolTable::getSymbolUses(), mlir::SymbolTable::getSymbolUses(), and mlir::SymbolTable::getSymbolUses().
|
static |
The implementation of SymbolTable::getSymbolUses below.
Definition at line 856 of file SymbolTable.cpp.
References collectSymbolScopes().
Return true if the given operation is unknown and may potentially define a symbol table.
Definition at line 21 of file SymbolTable.cpp.
References mlir::Operation::getDialect(), and mlir::Operation::getNumRegions().
Referenced by mlir::SymbolTable::getNearestSymbolTable(), walkSymbolUses(), 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 803 of file SymbolTable.cpp.
Referenced by replaceAllSymbolUsesImpl().
|
static |
Internal implementation of lookupSymbolIn that allows for specialized implementations of the lookup function.
Definition at line 412 of file SymbolTable.cpp.
References mlir::SymbolTable::getSymbolVisibility(), mlir::Operation::hasTrait(), mlir::SymbolTable::Private, and success().
Referenced by mlir::LockedSymbolTableCollection::lookupSymbolIn(), mlir::SymbolTable::lookupSymbolIn(), and mlir::SymbolTableCollection::lookupSymbolIn().
|
static |
The implementation of SymbolTable::replaceAllSymbolUses below.
Definition at line 943 of file SymbolTable.cpp.
References mlir::detail::AttrTypeReplacerBase< Concrete >::addReplacement(), mlir::WalkResult::advance(), collectSymbolScopes(), generateNewRefAttr(), mlir::FlatSymbolRefAttr::get(), isReferencePrefixOf(), mlir::detail::AttrTypeReplacerBase< Concrete >::replaceElementsIn(), mlir::WalkResult::skip(), and success().
Referenced by mlir::SymbolTable::replaceAllSymbolUses(), mlir::SymbolTable::replaceAllSymbolUses(), mlir::SymbolTable::replaceAllSymbolUses(), and mlir::SymbolTable::replaceAllSymbolUses().
|
static |
The implementation of SymbolTable::symbolKnownUseEmpty below.
Definition at line 896 of file SymbolTable.cpp.
References mlir::WalkResult::advance(), and collectSymbolScopes().
Referenced by mlir::SymbolTable::symbolKnownUseEmpty(), mlir::SymbolTable::symbolKnownUseEmpty(), mlir::SymbolTable::symbolKnownUseEmpty(), and mlir::SymbolTable::symbolKnownUseEmpty().
|
static |
Verify the symbol uses held by the types owned by op: its operand, result, and block-argument types, and any types nested within its attributes.
op is the anchor used for symbol lookups. verifiedTypes records the types already verified within the current symbol table so that each type, which may be uniqued and shared across many positions or operations, is verified at most once. Verification fails fast on the first invalid symbol use.
Definition at line 486 of file SymbolTable.cpp.
References mlir::WalkResult::advance(), mlir::Operation::getAttrDictionary(), mlir::Operation::getOperandTypes(), mlir::Operation::getRegions(), mlir::Operation::getResultTypes(), mlir::WalkResult::interrupt(), mlir::PreOrder, mlir::verify(), and mlir::WalkResult::wasInterrupted().
Referenced by mlir::detail::verifySymbolTable().
|
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 615 of file SymbolTable.cpp.
References mlir::Operation::getAttrDictionary(), mlir::WalkResult::interrupt(), mlir::PreOrder, and mlir::WalkResult::skip().
Referenced by walkSymbolUses(), and 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 80 of file SymbolTable.cpp.
References mlir::WalkResult::advance(), and result.
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 104 of file SymbolTable.cpp.
References mlir::WalkResult::advance(), mlir::Operation::getRegions(), mlir::Operation::hasTrait(), result, 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 631 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 647 of file SymbolTable.cpp.
References mlir::WalkResult::advance(), mlir::Operation::getRegions(), mlir::Operation::hasTrait(), mlir::WalkResult::interrupt(), isPotentiallyUnknownSymbolTable(), walkSymbolRefs(), and walkSymbolUses().