Skip to content

Commit b4c2a2e

Browse files
committed
[FIRRTL] Few reduction tweaks
1 parent e152380 commit b4c2a2e

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

lib/Dialect/FIRRTL/FIRRTLReductions.cpp

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -634,24 +634,16 @@ struct AnnotationRemover : public Reduction {
634634
uint64_t matchId = 0;
635635

636636
// Generate matches for regular annotations
637-
if (auto annos = op->getAttrOfType<ArrayAttr>("annotations")) {
638-
for (auto anno : annos) {
639-
(void)anno;
637+
if (auto annos = op->getAttrOfType<ArrayAttr>("annotations"))
638+
for (auto _ : annos)
640639
addMatch(1, matchId++);
641-
}
642-
}
643640

644641
// Generate matches for port annotations
645-
if (auto portAnnos = op->getAttrOfType<ArrayAttr>("portAnnotations")) {
646-
for (auto portAnnoArray : portAnnos) {
647-
if (auto portAnnoArrayAttr = dyn_cast<ArrayAttr>(portAnnoArray)) {
648-
for (auto anno : portAnnoArrayAttr) {
649-
(void)anno;
642+
if (auto portAnnos = op->getAttrOfType<ArrayAttr>("portAnnotations"))
643+
for (auto portAnnoArray : portAnnos)
644+
if (auto portAnnoArrayAttr = dyn_cast<ArrayAttr>(portAnnoArray))
645+
for (auto _ : portAnnoArrayAttr)
650646
addMatch(1, matchId++);
651-
}
652-
}
653-
}
654-
}
655647
}
656648

657649
LogicalResult rewriteMatches(Operation *op,
@@ -1200,10 +1192,11 @@ struct ModuleSwapper : public OpReduction<InstanceOp> {
12001192
circuitStates.clear();
12011193

12021194
// Collect module type groups and NLA tables for all circuits up front
1203-
op.walk([&](CircuitOp circuitOp) {
1195+
op.walk<WalkOrder::PreOrder>([&](CircuitOp circuitOp) {
12041196
auto &state = circuitStates[circuitOp];
12051197
state.nlaTable = std::make_unique<NLATable>(circuitOp);
12061198
buildModuleTypeGroups(circuitOp, state);
1199+
return WalkResult::skip();
12071200
});
12081201
}
12091202
void afterReduction(mlir::ModuleOp op) override { nlaRemover.remove(op); }
@@ -1214,9 +1207,9 @@ struct ModuleSwapper : public OpReduction<InstanceOp> {
12141207
/// swapping.
12151208
PortSignature getModulePortSignature(FModuleLike module) {
12161209
PortSignature signature;
1217-
for (unsigned i = 0, e = module.getNumPorts(); i < e; ++i) {
1210+
signature.reserve(module.getNumPorts());
1211+
for (unsigned i = 0, e = module.getNumPorts(); i < e; ++i)
12181212
signature.emplace_back(module.getPortType(i), module.getPortDirection(i));
1219-
}
12201213
return signature;
12211214
}
12221215

@@ -1234,7 +1227,7 @@ struct ModuleSwapper : public OpReduction<InstanceOp> {
12341227
continue;
12351228

12361229
FModuleLike smallestModule = nullptr;
1237-
uint64_t smallestSize = UINT64_MAX;
1230+
uint64_t smallestSize = std::numeric_limits<uint64_t>::max();
12381231

12391232
for (auto module : modules) {
12401233
uint64_t size = moduleSizes.getModuleSize(module, symbols);

0 commit comments

Comments
 (0)