Skip to content

Commit

Permalink
[FIRRTL] Make IMCP work with Layers
Browse files Browse the repository at this point in the history
Change IMCP to recurse into layers.  This has the effect of allowing IMCP
to sink constants into layers and to properly visit instances which are
instantiated under layers.

Signed-off-by: Schuyler Eldridge <[email protected]>
  • Loading branch information
seldridge committed Sep 13, 2024
1 parent 46014cd commit 3eadefc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/Dialect/FIRRTL/Transforms/IMConstProp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,8 @@ void IMConstPropPass::markBlockExecutable(Block *block) {
.Case<InstanceOp>([&](auto instance) { markInstanceOp(instance); })
.Case<ObjectOp>([&](auto obj) { markObjectOp(obj); })
.Case<MemOp>([&](auto mem) { markMemOp(mem); })
.Case<LayerBlockOp>(
[&](auto layer) { markBlockExecutable(layer.getBody(0)); })
.Default([&](auto _) {
if (isa<mlir::UnrealizedConversionCastOp, VerbatimExprOp,
VerbatimWireOp, SubaccessOp>(op) ||
Expand Down
17 changes: 17 additions & 0 deletions test/Dialect/FIRRTL/imconstprop.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -950,3 +950,20 @@ firrtl.circuit "OMIRRemoval" {
firrtl.matchingconnect %d, %tmp_3 : !firrtl.uint<4>
}
}


// -----

firrtl.circuit "Layers" {
// CHECK-LABEL: firrtl.module @Layers
firrtl.layer @A bind {}
firrtl.module @Layers() {
%c0_ui1 = firrtl.constant 0 : !firrtl.uint<1>
// CHECK: firrtl.layerblock
firrtl.layerblock @A {
%a = firrtl.node %c0_ui1 : !firrtl.uint<1>
// CHECK-NEXT: %b = firrtl.node sym @sym_b %c0_ui1
%b = firrtl.node sym @sym_b %a : !firrtl.uint<1>
}
}
}

0 comments on commit 3eadefc

Please sign in to comment.