CIRCT  19.0.0git
Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
circt::hw::InnerSymbolTable Class Reference

A table of inner symbols and their resolutions. More...

#include <InnerSymbolTable.h>

Collaboration diagram for circt::hw::InnerSymbolTable:
Collaboration graph
[legend]

Public Types

using InnerSymCallbackFn = llvm::function_ref< LogicalResult(StringAttr, const InnerSymTarget &)>
 

Public Member Functions

 InnerSymbolTable (Operation *op)
 Build an inner symbol table for the given operation. More...
 
 InnerSymbolTable (const InnerSymbolTable &)=delete
 Non-copyable. More...
 
InnerSymbolTableoperator= (const InnerSymbolTable &)=delete
 
 InnerSymbolTable (InnerSymbolTable &&)=default
 
InnerSymbolTableoperator= (InnerSymbolTable &&)=default
 
InnerSymTarget lookup (StringRef name) const
 Look up a symbol with the specified name, returning empty InnerSymTarget if no such name exists. More...
 
InnerSymTarget lookup (StringAttr name) const
 
Operation * lookupOp (StringRef name) const
 Look up a symbol with the specified name, returning null if no such name exists or doesn't target just an operation. More...
 
template<typename T >
lookupOp (StringRef name) const
 
Operation * lookupOp (StringAttr name) const
 Look up a symbol with the specified name, returning null if no such name exists or doesn't target just an operation. More...
 
template<typename T >
lookupOp (StringAttr name) const
 

Static Public Member Functions

static StringAttr getInnerSymbol (Operation *op)
 Get InnerSymbol for an operation. More...
 
static StringAttr getInnerSymbol (const InnerSymTarget &target)
 Get InnerSymbol for a target. More...
 
static StringRef getInnerSymbolAttrName ()
 Return the name of the attribute used for inner symbol names. More...
 
static FailureOr< InnerSymbolTableget (Operation *op)
 Construct an InnerSymbolTable, checking for verification failure. More...
 
template<typename FuncTy , typename RetTy = typename std::invoke_result_t< FuncTy, StringAttr, const InnerSymTarget &>>
static RetTy walkSymbols (Operation *op, FuncTy &&callback)
 Walk the given IST operation and invoke the callback for all encountered inner symbols. More...
 
static LogicalResult walkSymbols (Operation *op, InnerSymCallbackFn callback)
 Walk the given IST operation and invoke the callback for all encountered inner symbols. More...
 

Private Types

using TableTy = DenseMap< StringAttr, InnerSymTarget >
 

Private Member Functions

 InnerSymbolTable (Operation *op, TableTy &&table)
 Construct an inner symbol table for the given operation, with pre-populated table contents. More...
 

Private Attributes

Operation * innerSymTblOp
 This is the operation this table is constructed for, which must have the InnerSymbolTable trait. More...
 
TableTy symbolTable
 This maps inner symbol names to their targets. More...
 

Detailed Description

A table of inner symbols and their resolutions.

Definition at line 104 of file InnerSymbolTable.h.

Member Typedef Documentation

◆ InnerSymCallbackFn

using circt::hw::InnerSymbolTable::InnerSymCallbackFn = llvm::function_ref<LogicalResult(StringAttr, const InnerSymTarget &)>

Definition at line 152 of file InnerSymbolTable.h.

◆ TableTy

using circt::hw::InnerSymbolTable::TableTy = DenseMap<StringAttr, InnerSymTarget>
private

Definition at line 185 of file InnerSymbolTable.h.

Constructor & Destructor Documentation

◆ InnerSymbolTable() [1/4]

circt::hw::InnerSymbolTable::InnerSymbolTable ( Operation *  op)
explicit

Build an inner symbol table for the given operation.

The operation must have the InnerSymbolTable trait.

Definition at line 27 of file InnerSymbolTable.cpp.

References assert().

◆ InnerSymbolTable() [2/4]

circt::hw::InnerSymbolTable::InnerSymbolTable ( const InnerSymbolTable )
delete

Non-copyable.

◆ InnerSymbolTable() [3/4]

circt::hw::InnerSymbolTable::InnerSymbolTable ( InnerSymbolTable &&  )
default

◆ InnerSymbolTable() [4/4]

circt::hw::InnerSymbolTable::InnerSymbolTable ( Operation *  op,
TableTy &&  table 
)
inlineexplicitprivate

Construct an inner symbol table for the given operation, with pre-populated table contents.

Definition at line 188 of file InnerSymbolTable.h.

Member Function Documentation

◆ get()

FailureOr< InnerSymbolTable > circt::hw::InnerSymbolTable::get ( Operation *  op)
static

Construct an InnerSymbolTable, checking for verification failure.

Emits diagnostics describing encountered issues.

Definition at line 39 of file InnerSymbolTable.cpp.

References append(), assert(), and circt::hw::InnerSymTarget::getOp().

◆ getInnerSymbol() [1/2]

StringAttr circt::hw::InnerSymbolTable::getInnerSymbol ( const InnerSymTarget target)
static

Get InnerSymbol for a target.

Be robust to queries on unexpected operations to avoid users needing to know the details.

Definition at line 131 of file InnerSymbolTable.cpp.

References assert(), circt::hw::InnerSymTarget::getField(), circt::hw::InnerSymTarget::getOp(), circt::hw::InnerSymTarget::getPort(), and circt::hw::InnerSymTarget::isPort().

◆ getInnerSymbol() [2/2]

StringAttr circt::hw::InnerSymbolTable::getInnerSymbol ( Operation *  op)
static

Get InnerSymbol for an operation.

Definition at line 123 of file InnerSymbolTable.cpp.

Referenced by ResolveTracesPass::buildTarget().

◆ getInnerSymbolAttrName()

static StringRef circt::hw::InnerSymbolTable::getInnerSymbolAttrName ( )
inlinestatic

◆ lookup() [1/2]

InnerSymTarget circt::hw::InnerSymbolTable::lookup ( StringAttr  name) const

Definition at line 106 of file InnerSymbolTable.cpp.

◆ lookup() [2/2]

InnerSymTarget circt::hw::InnerSymbolTable::lookup ( StringRef  name) const

Look up a symbol with the specified name, returning empty InnerSymTarget if no such name exists.

Names never include the @ on them.

Definition at line 103 of file InnerSymbolTable.cpp.

References circt::calyx::direction::get().

Referenced by circt::hw::InnerRefNamespace::lookup().

◆ lookupOp() [1/4]

Operation * circt::hw::InnerSymbolTable::lookupOp ( StringAttr  name) const

Look up a symbol with the specified name, returning null if no such name exists or doesn't target just an operation.

Definition at line 115 of file InnerSymbolTable.cpp.

◆ lookupOp() [2/4]

template<typename T >
T circt::hw::InnerSymbolTable::lookupOp ( StringAttr  name) const
inline

Definition at line 135 of file InnerSymbolTable.h.

References lookupOp().

◆ lookupOp() [3/4]

Operation * circt::hw::InnerSymbolTable::lookupOp ( StringRef  name) const

Look up a symbol with the specified name, returning null if no such name exists or doesn't target just an operation.

Definition at line 112 of file InnerSymbolTable.cpp.

References circt::calyx::direction::get().

Referenced by circt::hw::InnerRefNamespace::lookupOp(), and lookupOp().

◆ lookupOp() [4/4]

template<typename T >
T circt::hw::InnerSymbolTable::lookupOp ( StringRef  name) const
inline

Definition at line 127 of file InnerSymbolTable.h.

References lookupOp().

◆ operator=() [1/2]

InnerSymbolTable& circt::hw::InnerSymbolTable::operator= ( const InnerSymbolTable )
delete

◆ operator=() [2/2]

InnerSymbolTable& circt::hw::InnerSymbolTable::operator= ( InnerSymbolTable &&  )
default

◆ walkSymbols() [1/2]

template<typename FuncTy , typename RetTy = typename std::invoke_result_t< FuncTy, StringAttr, const InnerSymTarget &>>
static RetTy circt::hw::InnerSymbolTable::walkSymbols ( Operation *  op,
FuncTy &&  callback 
)
inlinestatic

Walk the given IST operation and invoke the callback for all encountered inner symbols.

This variant allows callbacks that return LogicalResult OR void, and wraps the underlying implementation.

Definition at line 161 of file InnerSymbolTable.h.

Referenced by circt::hw::InnerSymbolNamespace::add().

◆ walkSymbols() [2/2]

LogicalResult circt::hw::InnerSymbolTable::walkSymbols ( Operation *  op,
InnerSymCallbackFn  callback 
)
static

Walk the given IST operation and invoke the callback for all encountered inner symbols.

This variant is the underlying implementation. If callback returns failure, the walk is aborted and failure is returned. A successful walk with no failures returns success.

Definition at line 62 of file InnerSymbolTable.cpp.

References assert(), and circt::hw::InnerSymTarget::getTargetForSubfield().

Member Data Documentation

◆ innerSymTblOp

Operation* circt::hw::InnerSymbolTable::innerSymTblOp
private

This is the operation this table is constructed for, which must have the InnerSymbolTable trait.

Definition at line 193 of file InnerSymbolTable.h.

◆ symbolTable

TableTy circt::hw::InnerSymbolTable::symbolTable
private

This maps inner symbol names to their targets.

Definition at line 196 of file InnerSymbolTable.h.


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