My Project
Classes | Public Member Functions | Static Public Member Functions | List of all members
mlir::SymbolTable Class Reference

#include <SymbolTable.h>

Classes

class  SymbolUse
 This class represents a specific symbol use. More...
 
class  UseRange
 This class implements a range of SymbolRef uses. More...
 

Public Member Functions

 SymbolTable (Operation *symbolTableOp)
 Build a symbol table with the symbols within the given operation. More...
 
Operationlookup (StringRef name) const
 
template<typename T >
lookup (StringRef name) const
 
void erase (Operation *symbol)
 Erase the given symbol from the table. More...
 
void insert (Operation *symbol, Block::iterator insertPt={})
 
OperationgetOp () const
 Returns the associated operation. More...
 

Static Public Member Functions

static StringRef getSymbolAttrName ()
 Return the name of the attribute used for symbol names. More...
 
static OperationlookupSymbolIn (Operation *op, StringRef symbol)
 
static OperationlookupNearestSymbolFrom (Operation *from, StringRef symbol)
 
static Optional< UseRangegetSymbolUses (Operation *from)
 
static Optional< UseRangegetSymbolUses (StringRef symbol, Operation *from)
 
static bool symbolKnownUseEmpty (StringRef symbol, Operation *from)
 
static LLVM_NODISCARD LogicalResult replaceAllSymbolUses (StringRef oldSymbol, StringRef newSymbol, Operation *from)
 

Detailed Description

This class allows for representing and managing the symbol table used by operations with the 'SymbolTable' trait. Inserting into and erasing from this SymbolTable will also insert and erase from the Operation given to it at construction.

Constructor & Destructor Documentation

◆ SymbolTable()

SymbolTable::SymbolTable ( Operation symbolTableOp)

Build a symbol table with the symbols within the given operation.

Member Function Documentation

◆ erase()

void SymbolTable::erase ( Operation symbol)

Erase the given symbol from the table.

◆ getOp()

Operation* mlir::SymbolTable::getOp ( ) const
inline

Returns the associated operation.

◆ getSymbolAttrName()

static StringRef mlir::SymbolTable::getSymbolAttrName ( )
inlinestatic

Return the name of the attribute used for symbol names.

◆ getSymbolUses() [1/2]

auto SymbolTable::getSymbolUses ( Operation from)
static

Get an iterator range for all of the uses, for any symbol, that are nested within the given operation 'from'. This does not traverse into any nested symbol tables, and will also only return uses on 'from' if it does not also define a symbol table. This is because we treat the region as the boundary of the symbol table, and not the op itself. This function returns None if there are any unknown operations that may potentially be symbol tables.

◆ getSymbolUses() [2/2]

auto SymbolTable::getSymbolUses ( StringRef  symbol,
Operation from 
)
static

Get all of the uses of the given symbol that are nested within the given operation 'from'. This does not traverse into any nested symbol tables, and will also only return uses on 'from' if it does not also define a symbol table. This is because we treat the region as the boundary of the symbol table, and not the op itself. This function returns None if there are any unknown operations that may potentially be symbol tables.

Get all of the uses of the given symbol that are nested within the given operation 'from', invoking the provided callback for each. This does not traverse into any nested symbol tables, and will also only return uses on 'from' if it does not also define a symbol table. This is because we treat the region as the boundary of the symbol table, and not the op itself. This function returns None if there are any unknown operations that may potentially be symbol tables.

◆ insert()

void SymbolTable::insert ( Operation symbol,
Block::iterator  insertPt = {} 
)

Insert a new symbol into the table, and rename it as necessary to avoid collisions. Also insert at the specified location in the body of the associated operation.

Insert a new symbol into the table and associated operation, and rename it as necessary to avoid collisions.

◆ lookup() [1/2]

Operation * SymbolTable::lookup ( StringRef  name) const

Look up a symbol with the specified name, returning null if no such name exists. Names never include the @ on them.

◆ lookup() [2/2]

template<typename T >
T mlir::SymbolTable::lookup ( StringRef  name) const
inline

◆ lookupNearestSymbolFrom()

Operation * SymbolTable::lookupNearestSymbolFrom ( Operation from,
StringRef  symbol 
)
static

Returns the operation registered with the given symbol name within the closest parent operation of, or including, 'from' with the 'OpTrait::SymbolTable' trait. Returns nullptr if no valid symbol was found.

Returns the operation registered with the given symbol name within the closes parent operation with the 'OpTrait::SymbolTable' trait. Returns nullptr if no valid symbol was found.

◆ lookupSymbolIn()

Operation * SymbolTable::lookupSymbolIn ( Operation symbolTableOp,
StringRef  symbol 
)
static

Returns the operation registered with the given symbol name with the regions of 'symbolTableOp'. 'symbolTableOp' is required to be an operation with the 'OpTrait::SymbolTable' trait.

Returns the operation registered with the given symbol name with the regions of 'symbolTableOp'. 'symbolTableOp' is required to be an operation with the 'OpTrait::SymbolTable' trait. Returns nullptr if no valid symbol was found.

◆ replaceAllSymbolUses()

LogicalResult SymbolTable::replaceAllSymbolUses ( StringRef  oldSymbol,
StringRef  newSymbol,
Operation from 
)
static

Attempt to replace all uses of the given symbol 'oldSymbol' with the provided symbol 'newSymbol' that are nested within the given operation 'from'. This does not traverse into any nested symbol tables, and will also only replace uses on 'from' if it does not also define a symbol table. This is because we treat the region as the boundary of the symbol table, and not the op itself. If there are any unknown operations that may potentially be symbol tables, no uses are replaced and failure is returned.

◆ symbolKnownUseEmpty()

bool SymbolTable::symbolKnownUseEmpty ( StringRef  symbol,
Operation from 
)
static

Return if the given symbol is known to have no uses that are nested within the given operation 'from'. This does not traverse into any nested symbol tables, and will also only count uses on 'from' if it does not also define a symbol table. This is because we treat the region as the boundary of the symbol table, and not the op itself. This function will also return false if there are any unknown operations that may potentially be symbol tables. This doesn't necessarily mean that there are no uses, we just can't conservatively prove it.

Return if the given symbol is known to have no uses that are nested within the given operation 'from'. This does not traverse into any nested symbol tables, and will also only count uses on 'from' if it does not also define a symbol table. This is because we treat the region as the boundary of the symbol table, and not the op itself. This function will also return false if there are any unknown operations that may potentially be symbol tables.


The documentation for this class was generated from the following files: