Skip to content

Commit

Permalink
fixup! [FIRRTL] Fix Grand Central and Layers Directories
Browse files Browse the repository at this point in the history
  • Loading branch information
seldridge committed Feb 28, 2024
1 parent 6264b95 commit 0a451ea
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/Dialect/FIRRTL/Transforms/GrandCentral.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1731,10 +1731,10 @@ void GrandCentralPass::runOnOperation() {
// Skip modules that we've visited, that are are under the companion
// module, or are bound/under a layer block.
if (auto block = a->getInstance()->getParentOfType<LayerBlockOp>()) {
auto diag =
a->getInstance().emitOpError()
<< "is instantiated under a layerblock op which is unexpected by "
"GrandCentral (did you forget to run the LowerLayers pass?)";
auto diag = a->getInstance().emitOpError()
<< "is instantiated under a '" << block.getOperationName()
<< "' op which is unexpected by GrandCentral (did you "
"forget to run the LowerLayers pass?)";
diag.attachNote(block.getLoc())
<< "the '" << block.getOperationName() << "' op is here";
removalError = true;
Expand Down
33 changes: 33 additions & 0 deletions test/Dialect/FIRRTL/grand-central-errors.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -375,3 +375,36 @@ firrtl.circuit "CompanionWithOutputs"
firrtl.instance dut @DUT()
}
}

// -----

firrtl.circuit "UnexpectedLayer"
attributes {annotations = [
{class = "sifive.enterprise.grandcentral.AugmentedBundleType",
defName = "Foo",
elements = [
{class = "sifive.enterprise.grandcentral.AugmentedBundleType",
defName = "Bar",
elements = [],
name = "bar"}],
id = 0 : i64,
name = "MyView"}]} {
firrtl.layer @A bind {}
firrtl.module private @MyView_companion()
attributes {annotations = [{
class = "sifive.enterprise.grandcentral.ViewAnnotation.companion",
id = 0 : i64,
name = "MyView"}]} {}
firrtl.module private @Foo() {}
firrtl.module private @DUT() {
firrtl.instance MyView_companion @MyView_companion()
// expected-note @below {{the 'firrtl.layerblock' op is here}}
firrtl.layerblock @A {
// expected-error @below {{'firrtl.instance' op is instantiated under a 'firrtl.layerblock' op}}
firrtl.instance foo @Foo()
}
}
firrtl.module @UnexpectedLayer() {
firrtl.instance dut @DUT()
}
}

0 comments on commit 0a451ea

Please sign in to comment.