Skip to content

Commit acc5075

Browse files
committed
[FIRRTL] Use InstanceInfo in MemToRegOfVec
Change the MemToRegOfVec pass to use the InstanceInfo analysis. This does subtly change the semantic of what is considered "in the design" to now treat layers and Grand Central Companions as "outside" the design. This should be safe. Signed-off-by: Schuyler Eldridge <[email protected]>
1 parent c92de74 commit acc5075

File tree

1 file changed

+7
-19
lines changed

1 file changed

+7
-19
lines changed

lib/Dialect/FIRRTL/Transforms/MemToRegOfVec.cpp

+7-19
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,14 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
#include "circt/Analysis/FIRRTLInstanceInfo.h"
1314
#include "circt/Dialect/FIRRTL/AnnotationDetails.h"
1415
#include "circt/Dialect/FIRRTL/FIRRTLAnnotations.h"
15-
#include "circt/Dialect/FIRRTL/FIRRTLInstanceGraph.h"
1616
#include "circt/Dialect/FIRRTL/FIRRTLOps.h"
1717
#include "circt/Dialect/FIRRTL/FIRRTLTypes.h"
1818
#include "circt/Dialect/FIRRTL/Passes.h"
1919
#include "mlir/IR/Threading.h"
2020
#include "mlir/Pass/Pass.h"
21-
#include "llvm/ADT/DepthFirstIterator.h"
2221
#include "llvm/Support/Debug.h"
2322

2423
#define DEBUG_TYPE "mem-to-reg-of-vec"
@@ -41,27 +40,16 @@ struct MemToRegOfVecPass
4140

4241
void runOnOperation() override {
4342
auto circtOp = getOperation();
44-
DenseSet<Operation *> dutModuleSet;
43+
auto &instanceInfo = getAnalysis<InstanceInfo>();
44+
4545
if (!AnnotationSet::removeAnnotations(circtOp,
4646
convertMemToRegOfVecAnnoClass))
4747
return markAllAnalysesPreserved();
48-
auto *body = circtOp.getBodyBlock();
4948

50-
// Find the device under test and create a set of all modules underneath it.
51-
auto it = llvm::find_if(*body, [&](Operation &op) -> bool {
52-
return AnnotationSet::hasAnnotation(&op, dutAnnoClass);
53-
});
54-
if (it != body->end()) {
55-
auto &instanceGraph = getAnalysis<InstanceGraph>();
56-
auto *node = instanceGraph.lookup(cast<igraph::ModuleOpInterface>(*it));
57-
llvm::for_each(llvm::depth_first(node),
58-
[&](igraph::InstanceGraphNode *node) {
59-
dutModuleSet.insert(node->getModule());
60-
});
61-
} else {
62-
auto mods = circtOp.getOps<FModuleOp>();
63-
dutModuleSet.insert(mods.begin(), mods.end());
64-
}
49+
DenseSet<Operation *> dutModuleSet;
50+
for (auto moduleOp : circtOp.getOps<FModuleOp>())
51+
if (instanceInfo.anyInstanceInEffectiveDesign(moduleOp))
52+
dutModuleSet.insert(moduleOp);
6553

6654
mlir::parallelForEach(circtOp.getContext(), dutModuleSet,
6755
[&](Operation *op) {

0 commit comments

Comments
 (0)