summaryrefslogtreecommitdiffstats
path: root/mlir/lib/IR/SymbolTable.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Make helper functions static or move them into anonymous namespaces. NFC.Benjamin Kramer2020-01-141-2/+2
|
* [mlir] Add support for attaching a visibility to symbols.River Riddle2020-01-131-0/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The visibility defines the structural reachability of the symbol within the IR. Symbols can define one of three visibilities: * Public The symbol \may be accessed from outside of the visible IR. We cannot assume that we can observe all of the uses of this symbol. * Private The symbol may only be referenced from within the operations in the current symbol table, via SymbolRefAttr. * Nested The symbol may be referenced by operations in symbol tables above the current symbol table, as long as each symbol table parent also defines a non-private symbol. This allows or referencing the symbol from outside of the defining symbol table, while retaining the ability for the compiler to see all uses. These properties help to reason about the properties of a symbol, and will be used in a follow up to implement a dce pass on dead symbols. A few examples of what this would look like in the IR are shown below: module @public_module { // This function can be accessed by 'live.user' func @nested_function() attributes { sym_visibility = "nested" } // This function cannot be accessed outside of 'public_module' func @private_function() attributes { sym_visibility = "private" } } // This function can only be accessed from within this module. func @private_function() attributes { sym_visibility = "private" } // This function may be referenced externally. func @public_function() "live.user"() {uses = [@public_module::@nested_function, @private_function, @public_function]} : () -> () Depends On D72043 Reviewed By: mehdi_amini Differential Revision: https://reviews.llvm.org/D72044
* [mlir] Update the use-list algorithms in SymbolTable to support nested ↵River Riddle2020-01-131-103/+380
| | | | | | | | | | references. Summary: This updates the use list algorithms to support querying from a specific symbol, allowing for the collection and detection of nested references. This works by walking the parent "symbol scopes" and applying the existing algorithm at each level. Reviewed By: jpienaar Differential Revision: https://reviews.llvm.org/D72042
* Adjust License.txt file to use the LLVM licenseMehdi Amini2019-12-231-13/+4
| | | | PiperOrigin-RevId: 286906740
* minor spelling tweaksKazuaki Ishizaki2019-12-061-1/+1
| | | | | | | Closes tensorflow/mlir#290 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/290 from kiszk:spelling_tweaks_201912 9d9afd16a723dd65754a04698b3976f150a6054a PiperOrigin-RevId: 284169681
* Move ModuleManager functionality into mlir::SymbolTable.Tres Popp2019-12-051-20/+39
| | | | | | | | | | Note for broken code, the following transformations occurred: ModuleManager::insert(Block::iterator, Operation*) - > SymbolTable::insert(Operation*, Block::iterator) ModuleManager::lookupSymbol -> SymbolTable::lookup ModuleManager::getModule() -> SymbolTable::getOp() ModuleManager::getContext() -> SymbolTable::getOp()->getContext() ModuleManager::* -> SymbolTable::* PiperOrigin-RevId: 283944635
* Add support for replacing all uses of a symbol.River Riddle2019-10-241-37/+165
| | | | | | This requires reconstructing the attribute dictionary of each operation containing a use. PiperOrigin-RevId: 276520544
* Add a Symbol trait to simplify defining operations that represent symbols.River Riddle2019-10-211-1/+8
| | | | | | This trait provides accessors for the name, symbol use list methods, verification, with more to be added. PiperOrigin-RevId: 275864554
* Fix minor spelling tweaks (NFC)Kazuaki Ishizaki2019-10-201-1/+1
| | | | | | Closes tensorflow/mlir#177 PiperOrigin-RevId: 275692653
* NFC: Cleanup the implementation of walkSymbolUses.River Riddle2019-10-181-66/+35
| | | | | | Refactor the implementation to be much cleaner by adding a `make_second_range` utility to walk the `second` value of a range of pairs. PiperOrigin-RevId: 275598985
* Update the symbol utility methods to handle the case of unknown operations.River Riddle2019-10-081-24/+68
| | | | | | This enhances the symbol table utility methods to handle the case where an unknown operation may define a symbol table. When walking symbols, we now collect all symbol uses before allowing the user to iterate. This prevents the user from assuming that all symbols are actually known before performing a transformation. PiperOrigin-RevId: 273651963
* Add support for walking the uses of a symbol.River Riddle2019-10-081-0/+157
| | | | | | MLIR uses symbol references to model references to many global entities, such as functions/variables/etc. Before this change, there is no way to actually reason about the uses of such entities. This change provides a walker for symbol references(via SymbolTable::walkSymbolUses), as well as 'use_empty' support(via SymbolTable::symbol_use_empty). It also resolves some deficiencies in the LangRef definition of SymbolRefAttr, namely the restrictions on where a SymbolRefAttr can be stored, ArrayAttr and DictionaryAttr, and the relationship with operations containing the SymbolTable trait. PiperOrigin-RevId: 273549331
* Add initial callgraph support.River Riddle2019-09-231-0/+30
| | | | | | | | | | | | | | Using the two call interfaces, CallOpInterface and CallableOpInterface, this change adds support for an initial multi-level CallGraph. This call graph builds a set of nodes for each callable region, and connects them via edges. An edge may be any of the following types: * Abstract - An edge not produced by a call operation, used for connecting to internal nodes from external nodes. * Call - A call edge is an edge defined via a call-like operation. * Child - This is an artificial edge connecting nested callgraph nodes. This callgraph will be used, and improved upon, to begin supporting more interesting interprocedural analyses and transformation. In a followup, this callgraph will be used to support more complex inlining support. PiperOrigin-RevId: 270724968
* Generalize the symbol table functionality of ModuleOp into a trait ↵River Riddle2019-07-081-25/+66
| | | | | | | | 'OpTrait::SymbolTable'. Operations must only contain a single region. Once attached, all operations that contain a 'mlir::SymbolTable::getSymbolAttrName()' StringAttr attribute within the child region will be verified to ensure that the names are uniqued. Operations using this trait also gain access to the 'SymbolTable' class, which can be used to manage the symbol table of the operation. This class also provides constant-time lookup of symbols by name, and will automatically rename symbols on insertion. PiperOrigin-RevId: 257123573
* NFC: Remove `Module::getFunctions` in favor of a general `getOps<T>`.River Riddle2019-07-081-1/+1
| | | | | | Modules can now contain more than just Functions, this just updates the iteration API to reflect that. The 'begin'/'end' methods have also been updated to iterate over opaque Operations. PiperOrigin-RevId: 257099084
* Replace the implementation of Function and Module with FuncOp and ModuleOp.River Riddle2019-07-031-5/+5
| | | | | | This is an important step in allowing for the top-level of the IR to be extensible. FuncOp and ModuleOp contain all of the necessary functionality, while using the existing operation infrastructure. As an interim step, many of the usages of Function and Module, including the name, will remain the same. In the future, many of these will be relaxed to allow for many different types of top-level operations to co-exist. PiperOrigin-RevId: 256427100
* NFC: Refactor Module to be value typed.River Riddle2019-07-021-2/+2
| | | | | | As with Functions, Module will soon become an operation, which are value-typed. This eases the transition from Module to ModuleOp. A new class, OwningModuleRef is provided to allow for owning a reference to a Module, and will auto-delete the held module on destruction. PiperOrigin-RevId: 256196193
* NFC: Refactor Function to be value typed.River Riddle2019-07-011-11/+11
| | | | | | Move the data members out of Function and into a new impl storage class 'FunctionStorage'. This allows for Function to become value typed, which will greatly simplify the transition of Function to FuncOp(given that FuncOp is also value typed). PiperOrigin-RevId: 255983022
* Extract the automatic function renaming and symbol table out of Module.River Riddle2019-07-011-1/+11
| | | | | | This functionality is now moved to a new class, ModuleManager. This class allows for inserting functions into a module, and will auto-rename them on insert to ensure a unique name. This now means that users adding new functions to a module must ensure that the function name is unique, as the Module will no longer do it automatically. This also means that Module::getNamedFunction now operates in O(N) instead of the O(c) time it did before. This simplifies the move of Modules to Operations as the ModuleOp will not be able to have this functionality. PiperOrigin-RevId: 255846088
* Extract the function symbol table functionality, i.e. mapping and name ↵River Riddle2019-06-191-0/+63
uniquing, out of Module and into a new class SymbolTable. As modules become operations it is necessary to extract out this functionality that cannot be represented with a generic operation. PiperOrigin-RevId: 254041734
OpenPOWER on IntegriCloud