CIRCT 21.0.0git
Loading...
Searching...
No Matches
Private Member Functions | Private Attributes | List of all members
LowerLayersPass Class Reference
Inheritance diagram for LowerLayersPass:
Inheritance graph
[legend]
Collaboration diagram for LowerLayersPass:
Collaboration graph
[legend]

Private Member Functions

hw::OutputFileAttr getOutputFile (SymbolRefAttr layerName)
 
hw::OutputFileAttr outputFileForLayer (StringRef moduleName, SymbolRefAttr layerName)
 
FModuleOp buildNewModule (OpBuilder &builder, LayerBlockOp layerBlock)
 Safely build a new module with a given namehint.
 
FailureOr< InnerRefMaprunOnModuleLike (FModuleLike moduleLike)
 Strip layer colors from the module's interface.
 
LogicalResult runOnModuleBody (FModuleOp moduleOp, InnerRefMap &innerRefMap)
 Extract layerblocks and strip probe colors from all ops under the module.
 
void removeLayersFromPorts (FModuleLike moduleLike)
 Update the module's port types to remove any explicit layer requirements from any probe types.
 
void removeLayersFromValue (Value value)
 Update the value's type to remove any layers from any probe types.
 
void lowerInlineLayerBlock (LayerOp layer, LayerBlockOp layerBlock)
 Lower an inline layerblock to an ifdef block.
 
void preprocessLayers (CircuitNamespace &ns, OpBuilder &b, LayerOp layer, StringRef circuitName, SmallVector< FlatSymbolRefAttr > &stack)
 Build macro declarations and cache information about the layers.
 
void preprocessLayers (CircuitNamespace &ns)
 
void preprocessModules (CircuitNamespace &ns, InstanceGraph &ig)
 For each module, build a bindfile for each bound-layer, if needed.
 
void preprocessModule (CircuitNamespace &ns, InstanceGraphNode *node)
 Build the bindfile skeletons for each module.
 
void buildBindFile (CircuitNamespace &ns, InstanceGraphNode *node, OpBuilder &b, SymbolRefAttr layerName, LayerOp layer)
 Build a bindfile skeleton for a particular module and layer.
 
void runOnOperation () override
 Entry point for the function.
 

Private Attributes

llvm::sys::SmartMutex< true > * circuitMutex
 Indicates exclusive access to modify the circuitNamespace and the circuit.
 
DenseMap< LayerBlockOp, LayerBlockGlobals > layerBlockGlobals
 A map of layer blocks to "safe" global names which are fine to create in the circuit namespace.
 
DenseMap< LayerOp, FlatSymbolRefAttr > macroNames
 A map from inline layers to their macro names.
 
llvm::MapVector< SymbolRefAttr, LayerOp > symbolToLayer
 A mapping of symbol name to layer operation.
 
hw::HierPathCache * hierPathCache
 Utility for creating hw::HierPathOp.
 
DenseMap< Operation *, DenseMap< LayerOp, BindFileInfo > > bindFiles
 A mapping from module*layer to bindfile name.
 

Detailed Description

Definition at line 187 of file LowerLayers.cpp.

Member Function Documentation

◆ buildBindFile()

void LowerLayersPass::buildBindFile ( CircuitNamespace ns,
InstanceGraphNode node,
OpBuilder &  b,
SymbolRefAttr  layerName,
LayerOp  layer 
)
private

Build a bindfile skeleton for a particular module and layer.

Definition at line 790 of file LowerLayers.cpp.

References assert(), bindFiles, fileNameForLayer(), guardMacroNameForLayer(), macroNames, and circt::Namespace::newName().

◆ buildNewModule()

FModuleOp LowerLayersPass::buildNewModule ( OpBuilder &  builder,
LayerBlockOp  layerBlock 
)
private

Safely build a new module with a given namehint.

Multi-process safe function to build a module in the circuit and return it.

This handles geting a lock to modify the top-level circuit.

The name provided is only a namehint for the module—a unique name will be generated if there are conflicts with the namehint in the circuit-level namespace.

Definition at line 275 of file LowerLayers.cpp.

References assert(), circuitMutex, getOutputFile(), and layerBlockGlobals.

Referenced by runOnModuleBody().

◆ getOutputFile()

hw::OutputFileAttr LowerLayersPass::getOutputFile ( SymbolRefAttr  layerName)
inlineprivate

Definition at line 189 of file LowerLayers.cpp.

References symbolToLayer.

Referenced by buildNewModule(), and outputFileForLayer().

◆ lowerInlineLayerBlock()

void LowerLayersPass::lowerInlineLayerBlock ( LayerOp  layer,
LayerBlockOp  layerBlock 
)
private

Lower an inline layerblock to an ifdef block.

Definition at line 358 of file LowerLayers.cpp.

References macroNames.

Referenced by runOnModuleBody().

◆ outputFileForLayer()

hw::OutputFileAttr LowerLayersPass::outputFileForLayer ( StringRef  moduleName,
SymbolRefAttr  layerName 
)
inlineprivate

Definition at line 196 of file LowerLayers.cpp.

References fileNameForLayer(), and getOutputFile().

Referenced by runOnModuleBody().

◆ preprocessLayers() [1/2]

void LowerLayersPass::preprocessLayers ( CircuitNamespace ns)
private

Definition at line 780 of file LowerLayers.cpp.

References preprocessLayers().

◆ preprocessLayers() [2/2]

void LowerLayersPass::preprocessLayers ( CircuitNamespace ns,
OpBuilder &  b,
LayerOp  layer,
StringRef  circuitName,
SmallVector< FlatSymbolRefAttr > &  stack 
)
private

Build macro declarations and cache information about the layers.

Definition at line 753 of file LowerLayers.cpp.

References macroNameForLayer(), macroNames, circt::Namespace::newName(), preprocessLayers(), and symbolToLayer.

Referenced by preprocessLayers(), preprocessLayers(), and runOnOperation().

◆ preprocessModule()

void LowerLayersPass::preprocessModule ( CircuitNamespace ns,
InstanceGraphNode node 
)
private

Build the bindfile skeletons for each module.

Set up a table which tells us for each module/layer pair, where to insert the bind operations.

Definition at line 867 of file LowerLayers.cpp.

References circt::igraph::InstanceGraphNode::getModule(), hierPathNameForLayer(), layerBlockGlobals, moduleNameForLayer(), circt::Namespace::newName(), and symbolToLayer.

Referenced by preprocessModules().

◆ preprocessModules()

void LowerLayersPass::preprocessModules ( CircuitNamespace ns,
InstanceGraph ig 
)
private

For each module, build a bindfile for each bound-layer, if needed.

Create the bind file skeleton for each layer, for each module.

Definition at line 930 of file LowerLayers.cpp.

References preprocessModule().

Referenced by runOnOperation().

◆ removeLayersFromPorts()

void LowerLayersPass::removeLayersFromPorts ( FModuleLike  moduleLike)
private

Update the module's port types to remove any explicit layer requirements from any probe types.

Definition at line 299 of file LowerLayers.cpp.

References removeLayersFromValue().

Referenced by runOnModuleLike().

◆ removeLayersFromValue()

void LowerLayersPass::removeLayersFromValue ( Value  value)
private

Update the value's type to remove any layers from any probe types.

Definition at line 292 of file LowerLayers.cpp.

Referenced by removeLayersFromPorts(), and runOnModuleBody().

◆ runOnModuleBody()

LogicalResult LowerLayersPass::runOnModuleBody ( FModuleOp  moduleOp,
InnerRefMap innerRefMap 
)
private

◆ runOnModuleLike()

FailureOr< InnerRefMap > LowerLayersPass::runOnModuleLike ( FModuleLike  moduleLike)
private

Strip layer colors from the module's interface.

Definition at line 328 of file LowerLayers.cpp.

References removeLayersFromPorts(), and runOnModuleBody().

◆ runOnOperation()

void LowerLayersPass::runOnOperation ( )
overrideprivate

Entry point for the function.

Process a circuit to remove all layer blocks in each module and top-level layer definition.

Definition at line 940 of file LowerLayers.cpp.

References bindFiles, circuitMutex, getBodyBlock(), hierPathCache, layerBlockGlobals, macroNames, preprocessLayers(), preprocessModules(), symbolToLayer, and circt::firrtl::transformReduce().

Member Data Documentation

◆ bindFiles

DenseMap<Operation *, DenseMap<LayerOp, BindFileInfo> > LowerLayersPass::bindFiles
private

A mapping from module*layer to bindfile name.

Definition at line 268 of file LowerLayers.cpp.

Referenced by buildBindFile(), runOnModuleBody(), and runOnOperation().

◆ circuitMutex

llvm::sys::SmartMutex<true>* LowerLayersPass::circuitMutex
private

Indicates exclusive access to modify the circuitNamespace and the circuit.

Definition at line 249 of file LowerLayers.cpp.

Referenced by buildNewModule(), runOnModuleBody(), and runOnOperation().

◆ hierPathCache

hw::HierPathCache* LowerLayersPass::hierPathCache
private

Utility for creating hw::HierPathOp.

Definition at line 265 of file LowerLayers.cpp.

Referenced by runOnModuleBody(), and runOnOperation().

◆ layerBlockGlobals

DenseMap<LayerBlockOp, LayerBlockGlobals> LowerLayersPass::layerBlockGlobals
private

A map of layer blocks to "safe" global names which are fine to create in the circuit namespace.

Definition at line 253 of file LowerLayers.cpp.

Referenced by buildNewModule(), preprocessModule(), runOnModuleBody(), and runOnOperation().

◆ macroNames

DenseMap<LayerOp, FlatSymbolRefAttr> LowerLayersPass::macroNames
private

A map from inline layers to their macro names.

Definition at line 256 of file LowerLayers.cpp.

Referenced by buildBindFile(), lowerInlineLayerBlock(), preprocessLayers(), and runOnOperation().

◆ symbolToLayer

llvm::MapVector<SymbolRefAttr, LayerOp> LowerLayersPass::symbolToLayer
private

A mapping of symbol name to layer operation.

This also serves as an iterable list of all layers declared in a circuit. We use a map vector so that the iteration order matches the order of declaration in the circuit. This order is not required for correctness, it helps with legibility.

Definition at line 262 of file LowerLayers.cpp.

Referenced by getOutputFile(), preprocessLayers(), preprocessModule(), runOnModuleBody(), and runOnOperation().


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