File tree Expand file tree Collapse file tree 2 files changed +34
-2
lines changed
lib/Dialect/FIRRTL/Transforms Expand file tree Collapse file tree 2 files changed +34
-2
lines changed Original file line number Diff line number Diff line change @@ -111,9 +111,18 @@ class EffectInfo {
111
111
});
112
112
}
113
113
114
+ // / Record whether the module-like op contains any effectful op.
114
115
void update (FModuleLike moduleOp) {
115
- if (!AnnotationSet (moduleOp).empty ())
116
- return markEffectful (moduleOp);
116
+ // If the module op has any annotations, then we pretend the module contains
117
+ // some kind of important effect, so that we cannot sink its instances.
118
+ if (auto annos = getAnnotationsIfPresent (moduleOp))
119
+ if (!annos.empty ())
120
+ return markEffectful (moduleOp);
121
+
122
+ for (auto annos : moduleOp.getPortAnnotations ())
123
+ if (!cast<ArrayAttr>(annos).empty ())
124
+ return markEffectful (moduleOp);
125
+
117
126
auto *op = moduleOp.getOperation ();
118
127
// Regular modules may be pure.
119
128
if (auto m = dyn_cast<FModuleOp>(op))
Original file line number Diff line number Diff line change @@ -715,3 +715,26 @@ firrtl.circuit "Sub" {
715
715
}
716
716
}
717
717
}
718
+
719
+ // Test that a port annotation on a module prevents us from sinking instances of
720
+ // that module into layerblocks.
721
+ firrtl.circuit " DoNotSinkInstanceOfModuleWithPortAnno" {
722
+ firrtl.layer @A bind {}
723
+ firrtl.module @ModuleWithPortAnno (out %out : !firrtl.uint <1 >)
724
+ attributes {
725
+ portAnnotations = [
726
+ [{class = " circt.FullResetAnnotation" , resetType = " async" }]
727
+ ]
728
+ }
729
+ {}
730
+
731
+ // CHECK: firrtl.module @DoNotSinkInstanceOfModuleWithPortAnno
732
+ firrtl.module @DoNotSinkInstanceOfModuleWithPortAnno () {
733
+ // CHECK-NEXT: firrtl.instance foo @ModuleWithPortAnn
734
+ %foo_out = firrtl.instance foo @ModuleWithPortAnno (out out : !firrtl.uint <1 >)
735
+ // CHECK-NEXT: firrtl.layerblock
736
+ firrtl.layerblock @A {
737
+ " unknown" (%foo_out ) : (!firrtl.uint <1 >) -> ()
738
+ }
739
+ }
740
+ }
You can’t perform that action at this time.
0 commit comments