Lines Matching full:operation
20 /// Return true if the given operation is unknown and may potentially define a
22 static bool isPotentiallyUnknownSymbolTable(Operation *op) {
28 static StringAttr getNameIfSymbol(Operation *op) {
31 static StringAttr getNameIfSymbol(Operation *op, StringAttr symbolAttrNameId) {
37 /// to the given operation 'within', where 'within' is an ancestor of 'symbol'.
40 collectValidReferencesFor(Operation *symbol, StringAttr symbolName,
41 Operation *within,
50 Operation *symbolTableOp = symbol->getParentOp();
82 function_ref<std::optional<WalkResult>(Operation *)> callback) {
85 for (Operation &op : worklist.pop_back_val()->getOps()) {
101 /// Walk all of the operations nested under, and including, the given operation,
105 walkSymbolTable(Operation *op,
106 function_ref<std::optional<WalkResult>(Operation *)> callback) {
117 /// Build a symbol table with the symbols within the given operation.
118 SymbolTable::SymbolTable(Operation *symbolTableOp)
121 "expected operation to have SymbolTable trait");
123 "expected operation to have a single region");
125 "expected operation to have a single block");
143 Operation *SymbolTable::lookup(StringRef name) const {
146 Operation *SymbolTable::lookup(StringAttr name) const {
150 void SymbolTable::remove(Operation *op) {
154 "expected this operation to be inside of the operation with this "
162 void SymbolTable::erase(Operation *symbol) {
168 /// Insert a new symbol into the table and associated operation if not already
171 StringAttr SymbolTable::insert(Operation *symbol, Block::iterator insertPt) {
183 "expected insertPt to be in the associated module operation");
218 Operation *op = lookup(from);
222 LogicalResult SymbolTable::rename(Operation *op, StringAttr to) {
228 "expected this operation to be inside of the operation with this "
253 LogicalResult SymbolTable::rename(Operation *op, StringRef to) {
285 SymbolTable::renameToUnique(Operation *op, ArrayRef<SymbolTable *> others) {
291 /// Returns the name of the given symbol operation.
292 StringAttr SymbolTable::getSymbolName(Operation *symbol) {
298 /// Sets the name of the given symbol operation.
299 void SymbolTable::setSymbolName(Operation *symbol, StringAttr name) {
303 /// Returns the visibility of the given symbol operation.
304 SymbolTable::Visibility SymbolTable::getSymbolVisibility(Operation *symbol) {
316 /// Sets the visibility of the given symbol operation.
317 void SymbolTable::setSymbolVisibility(Operation *symbol, Visibility vis) {
335 /// Returns the nearest symbol table from a given operation `from`. Returns
337 Operation *SymbolTable::getNearestSymbolTable(Operation *from) {
338 assert(from && "expected valid operation");
353 /// each symbol table operation, the provided callback is invoked with the op
358 Operation *op, bool allSymUsesVisible,
359 function_ref<void(Operation *, bool)> callback) {
372 for (Operation &nestedOp : block)
381 /// Returns the operation registered with the given symbol name with the
382 /// regions of 'symbolTableOp'. 'symbolTableOp' is required to be an operation
385 Operation *SymbolTable::lookupSymbolIn(Operation *symbolTableOp,
400 Operation *SymbolTable::lookupSymbolIn(Operation *symbolTableOp,
402 SmallVector<Operation *, 4> resolvedSymbols;
411 Operation *symbolTableOp, SymbolRefAttr symbol,
412 SmallVectorImpl<Operation *> &symbols,
413 function_ref<Operation *(Operation *, StringAttr)> lookupSymbolFn) {
444 SymbolTable::lookupSymbolIn(Operation *symbolTableOp, SymbolRefAttr symbol,
445 SmallVectorImpl<Operation *> &symbols) {
446 auto lookupFn = [](Operation *symbolTableOp, StringAttr symbol) {
452 /// Returns the operation registered with the given symbol name within the
453 /// closes parent operation with the 'OpTrait::SymbolTable' trait. Returns
455 Operation *SymbolTable::lookupNearestSymbolFrom(Operation *from,
457 Operation *symbolTableOp = getNearestSymbolTable(from);
460 Operation *SymbolTable::lookupNearestSymbolFrom(Operation *from,
462 Operation *symbolTableOp = getNearestSymbolTable(from);
483 LogicalResult detail::verifySymbolTable(Operation *op) {
513 auto verifySymbolUserFn = [&](Operation *op) -> std::optional<WalkResult> {
524 LogicalResult detail::verifySymbol(Operation *op) {
552 /// Walk all of the symbol references within the given operation, invoking the
556 walkSymbolRefs(Operation *op,
575 [&](Operation *op) -> std::optional<WalkResult> {
585 /// operation 'from', invoking the provided callback for each. This does not
588 walkSymbolUses(Operation *from,
590 // If this operation has regions, and it, as well as its dialect, isn't
591 // registered then conservatively fail. The operation may define a
597 // Walk the uses on this operation.
601 // Only recurse if this operation is not a symbol table. A symbol table
613 /// operation itself, just its contained operations. A scope ends at leaf
614 /// operations or another symbol table operation.
626 return walkSymbolUses(cast<Operation *>(limit), cback);
646 return ::walkSymbolTable(cast<Operation *>(limit), cback);
653 llvm::PointerUnion<Operation *, Region *> limit;
658 static SmallVector<SymbolScope, 2> collectSymbolScopes(Operation *symbol,
659 Operation *limit) {
664 SetVector<Operation *, SmallVector<Operation *, 4>,
665 SmallPtrSet<Operation *, 4>>
667 Operation *limitAncestor = limit;
683 Operation *commonAncestor = symbol->getParentOp();
702 Operation *limitIt = symbol->getParentOp();
718 static SmallVector<SymbolScope, 2> collectSymbolScopes(Operation *symbol,
734 Operation *limit) {
777 /// within the given operation 'from'. This does not traverse into any nested
783 auto SymbolTable::getSymbolUses(Operation *from) -> std::optional<UseRange> {
809 /// operation 'from', invoking the provided callback for each. This does not
812 auto SymbolTable::getSymbolUses(StringAttr symbol, Operation *from)
816 auto SymbolTable::getSymbolUses(Operation *symbol, Operation *from)
824 auto SymbolTable::getSymbolUses(Operation *symbol, Region *from)
848 /// the given operation 'from'. This does not traverse into any nested symbol
851 bool SymbolTable::symbolKnownUseEmpty(StringAttr symbol, Operation *from) {
854 bool SymbolTable::symbolKnownUseEmpty(Operation *symbol, Operation *from) {
860 bool SymbolTable::symbolKnownUseEmpty(Operation *symbol, Region *from) {
909 auto walkFn = [&](Operation *op) -> std::optional<WalkResult> {
920 /// provided symbol 'newSymbol' that are nested within the given operation
926 Operation *from) {
929 LogicalResult SymbolTable::replaceAllSymbolUses(Operation *oldSymbol,
931 Operation *from) {
939 LogicalResult SymbolTable::replaceAllSymbolUses(Operation *oldSymbol,
949 Operation *SymbolTableCollection::lookupSymbolIn(Operation *symbolTableOp,
953 Operation *SymbolTableCollection::lookupSymbolIn(Operation *symbolTableOp,
955 SmallVector<Operation *, 4> symbols;
964 SymbolTableCollection::lookupSymbolIn(Operation *symbolTableOp,
966 SmallVectorImpl<Operation *> &symbols) {
967 auto lookupFn = [this](Operation *symbolTableOp, StringAttr symbol) {
973 /// Returns the operation registered with the given symbol name within the
974 /// closest parent operation of, or including, 'from' with the
977 Operation *SymbolTableCollection::lookupNearestSymbolFrom(Operation *from,
979 Operation *symbolTableOp = SymbolTable::getNearestSymbolTable(from);
982 Operation *
983 SymbolTableCollection::lookupNearestSymbolFrom(Operation *from,
985 Operation *symbolTableOp = SymbolTable::getNearestSymbolTable(from);
989 /// Lookup, or create, a symbol table for an operation.
990 SymbolTable &SymbolTableCollection::getSymbolTable(Operation *op) {
1001 Operation *LockedSymbolTableCollection::lookupSymbolIn(Operation *symbolTableOp,
1006 Operation *
1007 LockedSymbolTableCollection::lookupSymbolIn(Operation *symbolTableOp,
1012 Operation *LockedSymbolTableCollection::lookupSymbolIn(Operation *symbolTableOp,
1014 SmallVector<Operation *> symbols;
1021 Operation *symbolTableOp, SymbolRefAttr name,
1022 SmallVectorImpl<Operation *> &symbols) {
1023 auto lookupFn = [this](Operation *symbolTableOp, StringAttr symbol) {
1030 LockedSymbolTableCollection::getSymbolTable(Operation *symbolTableOp) {
1039 // Create a symbol table for the operation. Perform construction outside of
1054 Operation *symbolTableOp)
1057 SmallVector<Operation *> symbols;
1058 auto walkFn = [&](Operation *symbolTableOp, bool allUsesVisible) {
1059 for (Operation &nestedOp : symbolTableOp->getRegion(0).getOps()) {
1067 for (Operation *symbolOp : symbols)
1078 void SymbolUserMap::replaceAllUsesWith(Operation *symbol,
1085 for (Operation *user : it->second)
1090 Operation *newSymbol =
1095 auto newIt = symbolToUsers.try_emplace(newSymbol, SetVector<Operation *>{});