CIRCT 24.0.0git
Loading...
Searching...
No Matches
circt::Namespace Class Reference

A namespace that is used to store existing names and generate new names in some scope within the IR. More...

#include <Namespace.h>

Inheritance diagram for circt::Namespace:
Collaboration diagram for circt::Namespace:

Public Member Functions

 Namespace ()
 Namespace (const Namespace &other)=default
 Namespace (Namespace &&other)
Namespace & operator= (const Namespace &other)=default
Namespace & operator= (Namespace &&other)
void add (mlir::ModuleOp module)
void add (SymbolCache &symCache)
 SymbolCache initializer; initialize from every key that is convertible to a StringAttr in the SymbolCache.
void add (StringRef name)
bool erase (llvm::StringRef symbol)
 Removes a symbol from the namespace.
void clear ()
 Empty the namespace.
StringRef newName (const Twine &name)
 Return a unique name, derived from the input name, and add the new name to the internal namespace.
StringRef newName (const Twine &name, const Twine &suffix)
 Return a unique name, derived from the input name and ensure the returned name has the input suffix.

Protected Attributes

llvm::StringMap< size_t > nextIndex
bool locked = false

Detailed Description

A namespace that is used to store existing names and generate new names in some scope within the IR.

This exists to work around limitations of SymbolTables. This acts as a base class providing facilities common to all namespaces implementations.

Definition at line 30 of file Namespace.h.

Constructor & Destructor Documentation

◆ Namespace() [1/3]

circt::Namespace::Namespace ( )
inline

Definition at line 32 of file Namespace.h.

References nextIndex.

Referenced by Namespace(), Namespace(), operator=(), and operator=().

◆ Namespace() [2/3]

circt::Namespace::Namespace ( const Namespace & other)
default

References Namespace().

◆ Namespace() [3/3]

circt::Namespace::Namespace ( Namespace && other)
inline

Definition at line 38 of file Namespace.h.

References locked, Namespace(), and nextIndex.

Member Function Documentation

◆ add() [1/3]

void circt::Namespace::add ( mlir::ModuleOp module)
inline

Definition at line 48 of file Namespace.h.

References assert(), and nextIndex.

Referenced by circt::FirRegLowering::createPaths(), and resolveMacroSymName().

◆ add() [2/3]

void circt::Namespace::add ( StringRef name)
inline

Definition at line 63 of file Namespace.h.

References nextIndex.

◆ add() [3/3]

void circt::Namespace::add ( SymbolCache & symCache)
inline

SymbolCache initializer; initialize from every key that is convertible to a StringAttr in the SymbolCache.

Definition at line 57 of file Namespace.h.

References nextIndex.

◆ clear()

void circt::Namespace::clear ( )
inline

Empty the namespace.

Definition at line 74 of file Namespace.h.

References locked, and nextIndex.

Referenced by LowerLayersPass::runOnModuleBody().

◆ erase()

bool circt::Namespace::erase ( llvm::StringRef symbol)
inline

Removes a symbol from the namespace.

Returns true if the symbol was removed, false if the symbol was not found. This is only allowed to be called before any call to newName.

Definition at line 68 of file Namespace.h.

References assert(), locked, and nextIndex.

◆ newName() [1/2]

StringRef circt::Namespace::newName ( const Twine & name)
inline

Return a unique name, derived from the input name, and add the new name to the internal namespace.

There are two possible outcomes for the returned name:

  1. The original name is returned.
  2. The name is given a _<n> suffix where <n> is a number starting from 0 and incrementing by one each time (_0, ...).

Definition at line 86 of file Namespace.h.

References locked, and nextIndex.

Referenced by circt::firrtl::applyGCTMemTaps(), LowerLayersPass::buildBindFile(), getHierPathTo(), getInnerSymFor(), circt::reduce::MetasyntacticNameGenerator::getNextName(), LowerLayersPass::preprocessLayers(), LowerLayersPass::preprocessModule(), resolveMacroSymName(), LowerLayersPass::runOnModuleBody(), and uniqueInNamespace().

◆ newName() [2/2]

StringRef circt::Namespace::newName ( const Twine & name,
const Twine & suffix )
inline

Return a unique name, derived from the input name and ensure the returned name has the input suffix.

Also add the new name to the internal namespace. There are two possible outcomes for the returned name:

  1. The original name + _<suffix> is returned.
  2. The name is given a suffix _<n>_<suffix> where <n> is a number starting from 0 and incrementing by one each time.

Definition at line 120 of file Namespace.h.

References locked, and nextIndex.

◆ operator=() [1/2]

Namespace & circt::Namespace::operator= ( const Namespace & other)
default

References Namespace().

◆ operator=() [2/2]

Namespace & circt::Namespace::operator= ( Namespace && other)
inline

Definition at line 42 of file Namespace.h.

References locked, Namespace(), and nextIndex.

Member Data Documentation

◆ locked

bool circt::Namespace::locked = false
protected

Definition at line 165 of file Namespace.h.

Referenced by clear(), erase(), Namespace(), newName(), newName(), and operator=().

◆ nextIndex

llvm::StringMap<size_t> circt::Namespace::nextIndex
protected

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