|
CIRCT 24.0.0git
|

Public Types | |
| using | RenameMap = DenseMap<StringAttr, StringAttr> |
Public Member Functions | |
| Deduper (InstanceGraph &instanceGraph, SymbolTable &symbolTable, NLATable *nlaTable, CircuitOp circuit) | |
| void | dedup (FModuleLike toModule, FModuleLike fromModule) |
| Remove the "fromModule", and replace all references to it with the "toModule". | |
| void | record (FModuleLike module) |
| Record the usages of any NLA's in this module, so that we may update the annotation if the parent module is deduped with another module. | |
Private Member Functions | |
| hw::InnerSymbolNamespace & | getNamespace (Operation *module) |
| Get a cached namespace for a module. | |
| void | recordAnnotations (AnnoTarget target) |
| For a specific annotation target, record all the unique NLAs which target it in the targetMap. | |
| void | recordAnnotations (Operation *op) |
| Record all targets which use an NLA. | |
| void | replaceInstances (FModuleLike toModule, Operation *fromModule) |
| This deletes and replaces all instances of the "fromModule" with instances of the "toModule". | |
| SmallVector< FlatSymbolRefAttr > | createNLAs (Operation *fromModule, ArrayRef< Attribute > baseNamepath, SymbolTable::Visibility vis=SymbolTable::Visibility::Private) |
| Look up the instantiations of the from module and create an NLA for each one, appending the baseNamepath to each NLA. | |
| SmallVector< FlatSymbolRefAttr > | createNLAs (StringAttr toModuleName, FModuleLike fromModule, SymbolTable::Visibility vis=SymbolTable::Visibility::Private) |
| Look up the instantiations of this module and create an NLA for each one. | |
| void | cloneAnnotation (SmallVectorImpl< FlatSymbolRefAttr > &nlas, Annotation anno, ArrayRef< NamedAttribute > attributes, unsigned nonLocalIndex, SmallVectorImpl< Annotation > &newAnnotations) |
| Clone the annotation for each NLA in a list. | |
| void | eraseNLA (hw::HierPathOp nla) |
| This erases the NLA op, and removes the NLA from every module's NLA map, but it does not delete the NLA reference from the target operation's annotations. | |
| void | addAnnotationContext (RenameMap &renameMap, FModuleOp toModule, FModuleOp fromModule) |
| Process all NLAs referencing the "from" module to point to the "to" module. | |
| void | rewriteModuleNLAs (RenameMap &renameMap, FModuleOp toModule, FModuleOp fromModule) |
| Process all the NLAs that the two modules participate in, replacing references to the "from" module with references to the "to" module, and adding more context if necessary. | |
| void | rewriteExtModuleNLAs (RenameMap &renameMap, StringAttr toName, StringAttr fromName) |
| bool | makeAnnotationNonLocal (StringAttr toModuleName, AnnoTarget to, FModuleLike fromModule, Annotation anno, SmallVectorImpl< Annotation > &newAnnotations) |
| Take an annotation, and update it to be a non-local annotation. | |
| void | copyAnnotations (FModuleLike toModule, AnnoTarget to, FModuleLike fromModule, AnnotationSet annos, SmallVectorImpl< Annotation > &newAnnotations, SmallPtrSetImpl< Attribute > &dontTouches) |
| void | mergeAnnotations (FModuleLike toModule, AnnoTarget to, AnnotationSet toAnnos, FModuleLike fromModule, AnnoTarget from, AnnotationSet fromAnnos) |
| Merge the annotations of a specific target, either a operation or a port on an operation. | |
| void | mergeAnnotations (FModuleLike toModule, Operation *to, FModuleLike fromModule, Operation *from) |
| Merge all annotations and port annotations on two operations. | |
| hw::InnerSymAttr | mergeInnerSymbols (RenameMap &renameMap, FModuleLike toModule, hw::InnerSymAttr toSym, hw::InnerSymAttr fromSym) |
| void | recordSymRenames (RenameMap &renameMap, FModuleLike toModule, Operation *to, FModuleLike fromModule, Operation *from) |
| void | mergeOps (RenameMap &renameMap, FModuleLike toModule, Operation *to, FModuleLike fromModule, Operation *from) |
| Recursively merge two operations. | |
| void | mergeBlocks (RenameMap &renameMap, FModuleLike toModule, Block &toBlock, FModuleLike fromModule, Block &fromBlock) |
| Recursively merge two blocks. | |
| void | mergeRegions (RenameMap &renameMap, FModuleLike toModule, Region &toRegion, FModuleLike fromModule, Region &fromRegion) |
Private Attributes | |
| MLIRContext * | context |
| InstanceGraph & | instanceGraph |
| SymbolTable & | symbolTable |
| NLATable * | nlaTable = nullptr |
| Cached nla table analysis. | |
| Block * | nlaBlock |
| We insert all NLAs to the beginning of this block. | |
| DenseMap< Attribute, llvm::SmallDenseSet< AnnoTarget > > | targetMap |
| DenseMap< Attribute, Attribute > | nlaCache |
| StringAttr | nonLocalString |
| StringAttr | classString |
| DenseMap< Operation *, hw::InnerSymbolNamespace > | moduleNamespaces |
| A module namespace cache. | |
| using Deduper::RenameMap = DenseMap<StringAttr, StringAttr> |
|
inline |
Definition at line 958 of file Dedup.cpp.
References classString, context, getBodyBlock(), instanceGraph, nlaBlock, nlaCache, nlaTable, nonLocalString, and symbolTable.
|
inlineprivate |
Process all NLAs referencing the "from" module to point to the "to" module.
This is used after merging two modules together.
Definition at line 1164 of file Dedup.cpp.
References cloneAnnotation(), context, createNLAs(), eraseNLA(), found, getNamespace(), circt::firrtl::OpAnnoTarget::getNLAReference(), instanceGraph, nlaCache, nlaTable, nonLocalString, and targetMap.
Referenced by rewriteModuleNLAs().
|
inlineprivate |
Clone the annotation for each NLA in a list.
The attribute list should have a placeholder for the "circt.nonlocal" field, and nonLocalIndex should be the index of this field.
Definition at line 1135 of file Dedup.cpp.
References context, and circt::firrtl::Annotation::setDict().
Referenced by addAnnotationContext(), and makeAnnotationNonLocal().
|
inlineprivate |
Definition at line 1317 of file Dedup.cpp.
References makeAnnotationNonLocal(), and targetMap.
Referenced by mergeAnnotations().
|
inlineprivate |
Look up the instantiations of the from module and create an NLA for each one, appending the baseNamepath to each NLA.
This is used to add more context to an already existing NLA. The fromModule is used to indicate which module the annotation is coming from before the merge, and will be used to create the namepaths.
Definition at line 1089 of file Dedup.cpp.
References context, getNamespace(), circt::firrtl::OpAnnoTarget::getNLAReference(), instanceGraph, nlaBlock, nlaCache, nlaTable, and symbolTable.
Referenced by addAnnotationContext(), createNLAs(), and makeAnnotationNonLocal().
|
inlineprivate |
Look up the instantiations of this module and create an NLA for each one.
This returns an array of symbol references which can be used to reference the NLAs.
Definition at line 1127 of file Dedup.cpp.
References createNLAs().
|
inline |
Remove the "fromModule", and replace all references to it with the "toModule".
Modules should be deduplicated in a bottom-up order. Any module which is not deduplicated needs to be recorded with the record call.
Definition at line 974 of file Dedup.cpp.
References context, mergeLoc(), mergeOps(), replaceInstances(), rewriteExtModuleNLAs(), and rewriteModuleNLAs().
|
inlineprivate |
This erases the NLA op, and removes the NLA from every module's NLA map, but it does not delete the NLA reference from the target operation's annotations.
Definition at line 1154 of file Dedup.cpp.
References nlaCache, nlaTable, symbolTable, and targetMap.
Referenced by addAnnotationContext().
|
inlineprivate |
Get a cached namespace for a module.
Definition at line 1021 of file Dedup.cpp.
References moduleNamespaces.
Referenced by addAnnotationContext(), createNLAs(), and mergeInnerSymbols().
|
inlineprivate |
Take an annotation, and update it to be a non-local annotation.
If the annotation is already non-local and has enough context, it will be skipped for now. Return true if the annotation was made non-local.
Definition at line 1275 of file Dedup.cpp.
References assert(), circt::firrtl::Annotation::begin(), cloneAnnotation(), createNLAs(), circt::firrtl::Annotation::end(), nonLocalString, and targetMap.
Referenced by copyAnnotations().
|
inlineprivate |
Merge the annotations of a specific target, either a operation or a port on an operation.
Definition at line 1346 of file Dedup.cpp.
References context, copyAnnotations(), and circt::firrtl::AnnoTarget::setAnnotations().
Referenced by mergeAnnotations(), and mergeOps().
|
inlineprivate |
Merge all annotations and port annotations on two operations.
Definition at line 1369 of file Dedup.cpp.
References circt::firrtl::AnnotationSet::forPort(), circt::firrtl::getNumPorts(), and mergeAnnotations().
|
inlineprivate |
Recursively merge two blocks.
Definition at line 1508 of file Dedup.cpp.
References context, mergeLoc(), and mergeOps().
Referenced by mergeRegions().
|
inlineprivate |
Definition at line 1394 of file Dedup.cpp.
References context, and getNamespace().
Referenced by recordSymRenames().
|
inlineprivate |
Recursively merge two operations.
Definition at line 1489 of file Dedup.cpp.
References context, mergeAnnotations(), mergeLoc(), mergeRegions(), and recordSymRenames().
Referenced by dedup(), and mergeBlocks().
|
inlineprivate |
Definition at line 1522 of file Dedup.cpp.
References mergeBlocks().
|
inline |
Record the usages of any NLA's in this module, so that we may update the annotation if the parent module is deduped with another module.
Definition at line 1009 of file Dedup.cpp.
References circt::firrtl::getNumPorts(), and recordAnnotations().
|
inlineprivate |
For a specific annotation target, record all the unique NLAs which target it in the targetMap.
Definition at line 1028 of file Dedup.cpp.
References circt::firrtl::AnnoTarget::getAnnotations(), and targetMap.
Referenced by record(), and recordAnnotations().
|
inlineprivate |
Record all targets which use an NLA.
Definition at line 1035 of file Dedup.cpp.
References recordAnnotations().
|
inlineprivate |
Definition at line 1444 of file Dedup.cpp.
References mergeInnerSymbols().
Referenced by mergeOps().
|
inlineprivate |
This deletes and replaces all instances of the "fromModule" with instances of the "toModule".
Definition at line 1051 of file Dedup.cpp.
References context, and instanceGraph.
Referenced by dedup().
|
inlineprivate |
|
inlineprivate |
Process all the NLAs that the two modules participate in, replacing references to the "from" module with references to the "to" module, and adding more context if necessary.
Definition at line 1259 of file Dedup.cpp.
References addAnnotationContext().
Referenced by dedup().
|
private |
|
private |
Definition at line 1530 of file Dedup.cpp.
Referenced by addAnnotationContext(), cloneAnnotation(), createNLAs(), dedup(), Deduper(), mergeAnnotations(), mergeBlocks(), mergeInnerSymbols(), mergeOps(), and replaceInstances().
|
private |
Definition at line 1531 of file Dedup.cpp.
Referenced by addAnnotationContext(), createNLAs(), Deduper(), and replaceInstances().
|
private |
|
private |
We insert all NLAs to the beginning of this block.
Definition at line 1538 of file Dedup.cpp.
Referenced by createNLAs(), and Deduper().
|
private |
Definition at line 1545 of file Dedup.cpp.
Referenced by addAnnotationContext(), createNLAs(), Deduper(), and eraseNLA().
|
private |
Cached nla table analysis.
Definition at line 1535 of file Dedup.cpp.
Referenced by addAnnotationContext(), createNLAs(), Deduper(), eraseNLA(), and rewriteExtModuleNLAs().
|
private |
Definition at line 1548 of file Dedup.cpp.
Referenced by addAnnotationContext(), Deduper(), and makeAnnotationNonLocal().
|
private |
Definition at line 1532 of file Dedup.cpp.
Referenced by createNLAs(), Deduper(), and eraseNLA().
|
private |
Definition at line 1541 of file Dedup.cpp.
Referenced by addAnnotationContext(), copyAnnotations(), eraseNLA(), makeAnnotationNonLocal(), and recordAnnotations().