• Home
  • Raw
  • Download

Lines Matching refs:symbol

27 static Optional<StringRef> getNameIfSymbol(Operation *symbol) {  in getNameIfSymbol()  argument
29 symbol->getAttrOfType<StringAttr>(SymbolTable::getSymbolAttrName()); in getNameIfSymbol()
32 static Optional<StringRef> getNameIfSymbol(Operation *symbol, in getNameIfSymbol() argument
34 auto nameAttr = symbol->getAttrOfType<StringAttr>(symbolAttrNameId); in getNameIfSymbol()
43 collectValidReferencesFor(Operation *symbol, StringRef symbolName, in collectValidReferencesFor() argument
46 assert(within->isAncestor(symbol) && "expected 'within' to be an ancestor"); in collectValidReferencesFor()
47 MLIRContext *ctx = symbol->getContext(); in collectValidReferencesFor()
53 Operation *symbolTableOp = symbol->getParentOp(); in collectValidReferencesFor()
140 void SymbolTable::erase(Operation *symbol) { in erase() argument
141 Optional<StringRef> name = getNameIfSymbol(symbol); in erase()
143 assert(symbol->getParentOp() == symbolTableOp && in erase()
148 if (it != symbolTable.end() && it->second == symbol) { in erase()
150 symbol->erase(); in erase()
156 void SymbolTable::insert(Operation *symbol, Block::iterator insertPt) { in insert() argument
164 body.getOperations().insert(insertPt, symbol); in insert()
168 StringRef name = getSymbolName(symbol); in insert()
169 if (symbolTable.insert({name, symbol}).second) in insert()
181 } while (!symbolTable.insert({nameBuffer, symbol}).second); in insert()
182 setSymbolName(symbol, nameBuffer); in insert()
186 StringRef SymbolTable::getSymbolName(Operation *symbol) { in getSymbolName() argument
187 Optional<StringRef> name = getNameIfSymbol(symbol); in getSymbolName()
192 void SymbolTable::setSymbolName(Operation *symbol, StringRef name) { in setSymbolName() argument
193 symbol->setAttr(getSymbolAttrName(), in setSymbolName()
194 StringAttr::get(name, symbol->getContext())); in setSymbolName()
198 SymbolTable::Visibility SymbolTable::getSymbolVisibility(Operation *symbol) { in getSymbolVisibility() argument
200 StringAttr vis = symbol->getAttrOfType<StringAttr>(getVisibilityAttrName()); in getSymbolVisibility()
211 void SymbolTable::setSymbolVisibility(Operation *symbol, Visibility vis) { in setSymbolVisibility() argument
212 MLIRContext *ctx = symbol->getContext(); in setSymbolVisibility()
217 symbol->removeAttr(Identifier::get(getVisibilityAttrName(), ctx)); in setSymbolVisibility()
226 symbol->setAttr(getVisibilityAttrName(), StringAttr::get(visName, ctx)); in setSymbolVisibility()
256 SymbolOpInterface symbol = dyn_cast<SymbolOpInterface>(op); in walkSymbolTables() local
257 allSymUsesVisible |= !symbol || symbol.isPrivate(); in walkSymbolTables()
280 StringRef symbol) { in lookupSymbolIn() argument
287 if (getNameIfSymbol(&op, symbolNameId) == symbol) in lookupSymbolIn()
292 SymbolRefAttr symbol) { in lookupSymbolIn() argument
294 if (failed(lookupSymbolIn(symbolTableOp, symbol, resolvedSymbols))) in lookupSymbolIn()
302 Operation *symbolTableOp, SymbolRefAttr symbol, in lookupSymbolInImpl() argument
308 symbolTableOp = lookupSymbolFn(symbolTableOp, symbol.getRootReference()); in lookupSymbolInImpl()
314 ArrayRef<FlatSymbolRefAttr> nestedRefs = symbol.getNestedReferences(); in lookupSymbolInImpl()
330 symbols.push_back(lookupSymbolFn(symbolTableOp, symbol.getLeafReference())); in lookupSymbolInImpl()
335 SymbolTable::lookupSymbolIn(Operation *symbolTableOp, SymbolRefAttr symbol, in lookupSymbolIn() argument
337 auto lookupFn = [](Operation *symbolTableOp, StringRef symbol) { in lookupSymbolIn() argument
338 return lookupSymbolIn(symbolTableOp, symbol); in lookupSymbolIn()
340 return lookupSymbolInImpl(symbolTableOp, symbol, symbols, lookupFn); in lookupSymbolIn()
347 StringRef symbol) { in lookupNearestSymbolFrom() argument
349 return symbolTableOp ? lookupSymbolIn(symbolTableOp, symbol) : nullptr; in lookupNearestSymbolFrom()
352 SymbolRefAttr symbol) { in lookupNearestSymbolFrom() argument
354 return symbolTableOp ? lookupSymbolIn(symbolTableOp, symbol) : nullptr; in lookupNearestSymbolFrom()
569 SymbolRefAttr symbol; member
577 static SmallVector<SymbolScope, 2> collectSymbolScopes(Operation *symbol, in collectSymbolScopes() argument
579 StringRef symName = SymbolTable::getSymbolName(symbol); in collectSymbolScopes()
580 assert(!symbol->hasTrait<OpTrait::SymbolTable>() || symbol != limit); in collectSymbolScopes()
589 if (limitAncestor == symbol) { in collectSymbolScopes()
593 symbol->getParentOp()) in collectSymbolScopes()
594 return {{SymbolRefAttr::get(symName, symbol->getContext()), limit}}; in collectSymbolScopes()
602 Operation *commonAncestor = symbol->getParentOp(); in collectSymbolScopes()
613 collectValidReferencesFor(symbol, symName, commonAncestor, references)); in collectSymbolScopes()
621 Operation *limitIt = symbol->getParentOp(); in collectSymbolScopes()
637 static SmallVector<SymbolScope, 2> collectSymbolScopes(Operation *symbol, in collectSymbolScopes() argument
639 auto scopes = collectSymbolScopes(symbol, limit->getParentOp()); in collectSymbolScopes()
648 static SmallVector<SymbolScope, 1> collectSymbolScopes(StringRef symbol, in collectSymbolScopes() argument
650 return {{SymbolRefAttr::get(symbol, limit->getContext()), limit}}; in collectSymbolScopes()
705 static Optional<SymbolTable::UseRange> getSymbolUsesImpl(SymbolT symbol, in getSymbolUsesImpl() argument
708 for (SymbolScope &scope : collectSymbolScopes(symbol, limit)) { in getSymbolUsesImpl()
710 if (isReferencePrefixOf(scope.symbol, symbolUse.getSymbolRef())) in getSymbolUsesImpl()
722 auto SymbolTable::getSymbolUses(StringRef symbol, Operation *from) in getSymbolUses() argument
724 return getSymbolUsesImpl(symbol, from); in getSymbolUses()
726 auto SymbolTable::getSymbolUses(Operation *symbol, Operation *from) in getSymbolUses() argument
728 return getSymbolUsesImpl(symbol, from); in getSymbolUses()
730 auto SymbolTable::getSymbolUses(StringRef symbol, Region *from) in getSymbolUses() argument
732 return getSymbolUsesImpl(symbol, from); in getSymbolUses()
734 auto SymbolTable::getSymbolUses(Operation *symbol, Region *from) in getSymbolUses() argument
736 return getSymbolUsesImpl(symbol, from); in getSymbolUses()
744 static bool symbolKnownUseEmptyImpl(SymbolT symbol, IRUnitT *limit) { in symbolKnownUseEmptyImpl() argument
745 for (SymbolScope &scope : collectSymbolScopes(symbol, limit)) { in symbolKnownUseEmptyImpl()
748 return isReferencePrefixOf(scope.symbol, symbolUse.getSymbolRef()) in symbolKnownUseEmptyImpl()
761 bool SymbolTable::symbolKnownUseEmpty(StringRef symbol, Operation *from) { in symbolKnownUseEmpty() argument
762 return symbolKnownUseEmptyImpl(symbol, from); in symbolKnownUseEmpty()
764 bool SymbolTable::symbolKnownUseEmpty(Operation *symbol, Operation *from) { in symbolKnownUseEmpty() argument
765 return symbolKnownUseEmptyImpl(symbol, from); in symbolKnownUseEmpty()
767 bool SymbolTable::symbolKnownUseEmpty(StringRef symbol, Region *from) { in symbolKnownUseEmpty() argument
768 return symbolKnownUseEmptyImpl(symbol, from); in symbolKnownUseEmpty()
770 bool SymbolTable::symbolKnownUseEmpty(Operation *symbol, Region *from) { in symbolKnownUseEmpty() argument
771 return symbolKnownUseEmptyImpl(symbol, from); in symbolKnownUseEmpty()
837 replaceAllSymbolUsesImpl(SymbolT symbol, StringRef newSymbol, IRUnitT *limit) { in replaceAllSymbolUsesImpl() argument
859 for (SymbolScope &scope : collectSymbolScopes(symbol, limit)) { in replaceAllSymbolUsesImpl()
860 SymbolRefAttr newAttr = generateNewRefAttr(scope.symbol, newLeafAttr); in replaceAllSymbolUsesImpl()
864 if (!isReferencePrefixOf(scope.symbol, useRef)) in replaceAllSymbolUsesImpl()
871 if (useRef != scope.symbol) { in replaceAllSymbolUsesImpl()
872 if (scope.symbol.isa<FlatSymbolRefAttr>()) { in replaceAllSymbolUsesImpl()
877 nestedRefs[scope.symbol.getNestedReferences().size() - 1] = in replaceAllSymbolUsesImpl()
944 StringRef symbol) { in lookupSymbolIn() argument
945 return getSymbolTable(symbolTableOp).lookup(symbol); in lookupSymbolIn()
961 auto lookupFn = [this](Operation *symbolTableOp, StringRef symbol) { in lookupSymbolIn() argument
962 return lookupSymbolIn(symbolTableOp, symbol); in lookupSymbolIn()
972 StringRef symbol) { in lookupNearestSymbolFrom() argument
974 return symbolTableOp ? lookupSymbolIn(symbolTableOp, symbol) : nullptr; in lookupNearestSymbolFrom()
978 SymbolRefAttr symbol) { in lookupNearestSymbolFrom() argument
980 return symbolTableOp ? lookupSymbolIn(symbolTableOp, symbol) : nullptr; in lookupNearestSymbolFrom()