CIRCT
20.0.0git
|
This table tracks nlas and what modules participate in them. More...
#include <NLATable.h>
Public Member Functions | |
NLATable (Operation *operation) | |
Create a new NLA table of a circuit. More... | |
ArrayRef< hw::HierPathOp > | lookup (Operation *op) |
Lookup all NLAs an operation participates in. More... | |
ArrayRef< hw::HierPathOp > | lookup (StringAttr name) |
Lookup all NLAs an operation participates in. More... | |
hw::HierPathOp | getNLA (StringAttr name) |
Resolve a symbol to an NLA. More... | |
FModuleLike | getModule (StringAttr name) |
Resolve a symbol to a Module. More... | |
void | commonNLAs (StringAttr mod1, StringAttr mod2, DenseSet< hw::HierPathOp > &common) |
Compute the NLAs that are common between the two modules, mod1 and mod2 and insert them into the set common . More... | |
void | getInstanceNLAs (InstanceOp inst, DenseSet< hw::HierPathOp > &nlas) |
Get the NLAs that the InstanceOp participates in, insert it to the DenseSet nlas . More... | |
void | getNLAsInModule (StringAttr modName, DenseSet< hw::HierPathOp > &nlas) |
Get the NLAs that the module modName particiaptes in, and insert them into the DenseSet nlas . More... | |
void | addNLA (hw::HierPathOp nla) |
Insert a new NLA. More... | |
void | erase (hw::HierPathOp nlaOp, SymbolTable *symbolTable=nullptr) |
Remove the NLA from the analysis. More... | |
void | addModule (FModuleLike mod) |
Record a new FModuleLike operation. More... | |
void | eraseModule (StringAttr name) |
Stop tracking a module. More... | |
void | updateModuleInNLA (StringAttr nlaName, StringAttr oldModule, StringAttr newModule) |
Replace the module oldModule with newModule in the namepath of the nla nlaName . More... | |
void | updateModuleInNLA (hw::HierPathOp nlaOp, StringAttr oldModule, StringAttr newModule) |
Replace the module oldModule with newModule in the namepath of the nla nlaOp . More... | |
void | renameModule (StringAttr oldModName, StringAttr newModName) |
Rename a module, this updates the name to module tracking and the name to NLA tracking. More... | |
void | renameModuleAndInnerRef (StringAttr newModName, StringAttr oldModName, const DenseMap< StringAttr, StringAttr > &innerSymRenameMap) |
Replace the module oldModName with newModName in the namepath of any NLA. More... | |
void | removeNLAfromModule (hw::HierPathOp nla, StringAttr mod) |
Remove the NLA from the Module. More... | |
void | removeNLAsfromModule (const DenseSet< hw::HierPathOp > &nlas, StringAttr mod) |
Remove all the nlas in the set nlas from the module. More... | |
void | addNLAtoModule (hw::HierPathOp nla, StringAttr mod) |
Add the nla to the module. More... | |
Private Member Functions | |
NLATable (const NLATable &)=delete | |
Private Attributes | |
llvm::DenseMap< StringAttr, SmallVector< hw::HierPathOp, 4 > > | nodeMap |
Map modules to the NLA's that target them. More... | |
llvm::DenseMap< StringAttr, Operation * > | symToOp |
Map symbol names to module and NLA operations. More... | |
This table tracks nlas and what modules participate in them.
To use this class, retrieve a cached copy from the analysis manager: auto &nlaTable = getAnalysis<NLATable>(getOperation());
Definition at line 29 of file NLATable.h.
|
explicit |
Create a new NLA table of a circuit.
This must be called on a FIRRTL CircuitOp or MLIR ModuleOp. To ensure that the analysis does not return stale data while a pass is running, it should be kept up-to-date when modules are added or renamed and NLAs are updated.
Definition at line 17 of file NLATable.cpp.
|
privatedelete |
|
inline |
Record a new FModuleLike operation.
This updates the Module name to Module operation map.
Definition at line 125 of file NLATable.h.
References symToOp.
void NLATable::addNLA | ( | hw::HierPathOp | nla | ) |
Insert a new NLA.
This updates two internal records,
nlaOp
name to the Operation.Definition at line 58 of file NLATable.cpp.
References nodeMap, and symToOp.
Referenced by NLATable().
|
inline |
Add the nla to the module.
This ensures that the list of NLAs that the module participates in is updated. This will be required if mod
is added to the namepath of nla
.
Definition at line 182 of file NLATable.h.
References nodeMap.
|
inline |
Compute the NLAs that are common between the two modules, mod1
and mod2
and insert them into the set common
.
The set of NLAs that an instance op participates in is the set of common NLAs between the parent module and the instance target. This can be used to get the set of NLAs that an InstanceOp participates in, instead of recording them on the op in the IR.
Definition at line 60 of file NLATable.h.
References lookup().
Referenced by getInstanceNLAs().
void NLATable::erase | ( | hw::HierPathOp | nlaOp, |
SymbolTable * | symbolTable = nullptr |
||
) |
Remove the NLA from the analysis.
This updates two internal records,
Definition at line 68 of file NLATable.cpp.
|
inline |
Stop tracking a module.
Remove the module from two internal records,
Definition at line 130 of file NLATable.h.
|
inline |
Get the NLAs that the InstanceOp participates in, insert it to the DenseSet nlas
.
Definition at line 71 of file NLATable.h.
References commonNLAs(), and circt::firrtl::getInnerSymName().
FModuleLike NLATable::getModule | ( | StringAttr | name | ) |
Resolve a symbol to a Module.
Definition at line 53 of file NLATable.cpp.
References symToOp.
Referenced by ResolveTracesPass::updateModuleTarget(), and ResolveTracesPass::updateTargetImpl().
hw::HierPathOp NLATable::getNLA | ( | StringAttr | name | ) |
Resolve a symbol to an NLA.
Definition at line 48 of file NLATable.cpp.
References symToOp.
Referenced by updateModuleInNLA(), ResolveTracesPass::updateModuleTarget(), and ResolveTracesPass::updateTargetImpl().
|
inline |
Get the NLAs that the module modName
particiaptes in, and insert them into the DenseSet nlas
.
Definition at line 94 of file NLATable.h.
References lookup().
ArrayRef< hw::HierPathOp > NLATable::lookup | ( | Operation * | op | ) |
Lookup all NLAs an operation participates in.
This returns a reference to the internal record, so make a copy before making any update to the NLATable.
Definition at line 41 of file NLATable.cpp.
Referenced by commonNLAs(), getNLAsInModule(), and renameModuleAndInnerRef().
ArrayRef< hw::HierPathOp > NLATable::lookup | ( | StringAttr | name | ) |
Lookup all NLAs an operation participates in.
This returns a reference to the internal record, so make a copy before making any update to the NLATable.
Definition at line 34 of file NLATable.cpp.
References nodeMap.
|
inline |
Remove the NLA from the Module.
This updates the module name to NLA tracking.
Definition at line 167 of file NLATable.h.
References nodeMap.
|
inline |
Remove all the nlas in the set nlas
from the module.
This updates the module name to NLA tracking.
Definition at line 173 of file NLATable.h.
References nodeMap.
void NLATable::renameModule | ( | StringAttr | oldModName, |
StringAttr | newModName | ||
) |
Rename a module, this updates the name to module tracking and the name to NLA tracking.
This moves all the NLAs that oldModName
is participating in to the newModName
. The oldModName
must exist in the name to module record. This also removes all the entries for oldModName
.
Definition at line 100 of file NLATable.cpp.
void NLATable::renameModuleAndInnerRef | ( | StringAttr | newModName, |
StringAttr | oldModName, | ||
const DenseMap< StringAttr, StringAttr > & | innerSymRenameMap | ||
) |
Replace the module oldModName
with newModName
in the namepath of any NLA.
Since the module is being updated, the symbols inside the module should also be renamed. Use the rename map innerSymRenameMap
to update the inner_sym names in the namepath.
Definition at line 115 of file NLATable.cpp.
void NLATable::updateModuleInNLA | ( | hw::HierPathOp | nlaOp, |
StringAttr | oldModule, | ||
StringAttr | newModule | ||
) |
Replace the module oldModule
with newModule
in the namepath of the nla nlaOp
.
This moves the nla from the list of oldModule
to newModule
. Move nlaOp
from the list of NLAs that oldModule
participates in to newModule
. This can delete and invalidate any reference returned by lookup
.
Definition at line 79 of file NLATable.cpp.
References nodeMap.
void NLATable::updateModuleInNLA | ( | StringAttr | nlaName, |
StringAttr | oldModule, | ||
StringAttr | newModule | ||
) |
Replace the module oldModule
with newModule
in the namepath of the nla nlaName
.
This moves the nla from the list of oldModule
to newModule
. Move nlaName
from the list of NLAs that oldModule
participates in to newModule
. This can delete and invalidate any reference returned by lookup
.
Definition at line 92 of file NLATable.cpp.
References getNLA().
|
private |
Map modules to the NLA's that target them.
Definition at line 190 of file NLATable.h.
Referenced by addNLA(), addNLAtoModule(), erase(), eraseModule(), lookup(), removeNLAfromModule(), removeNLAsfromModule(), renameModule(), renameModuleAndInnerRef(), and updateModuleInNLA().
|
private |
Map symbol names to module and NLA operations.
Definition at line 193 of file NLATable.h.
Referenced by addModule(), addNLA(), erase(), eraseModule(), getModule(), getNLA(), NLATable(), and renameModule().