[firrtl] Fix bug in sibling layer specialization

Fix a bug in the `SpecializeLayers` pass where sibling layers would not be
enabled/disabled correctly if an earlier sibling layer was also
enabled/disabled.

Fixes #7525.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
This commit is contained in:
Schuyler Eldridge 2024-08-16 19:23:40 -04:00
parent 27d3965c59
commit 209d9fb80e
No known key found for this signature in database
GPG Key ID: 50C5E9936AAD536D
2 changed files with 17 additions and 0 deletions

View File

@ -605,6 +605,7 @@ struct SpecializeLayers {
llvm::make_early_inc_range(block->getOps<LayerOp>())) {
nestedRefs.push_back(SymbolRefAttr::get(nested));
handleLayer(nested, Block::iterator(nested), "");
nestedRefs.pop_back();
}
return;
}
@ -617,6 +618,7 @@ struct SpecializeLayers {
nestedRefs.push_back(SymbolRefAttr::get(nested));
handleLayer(nested, insertionPoint,
prefix + layer.getSymName() + "_");
nestedRefs.pop_back();
}
// Erase the now empty layer.
layer->erase();

View File

@ -115,6 +115,21 @@ firrtl.circuit "LayerDisableInARow" attributes {
firrtl.extmodule @LayerDisableInARow()
}
// CHECK: firrtl.circuit "LayerblockEnableNestedChildren"
// CHECK-NOT: firrtl.layer
firrtl.circuit "LayerblockEnableNestedChildren" attributes {
enable_layers = [@A, @A::@B, @A::@C]
} {
firrtl.layer @A bind {
firrtl.layer @B bind {
}
firrtl.layer @C bind {
}
}
firrtl.module @LayerblockEnableNestedChildren() {
}
}
//===----------------------------------------------------------------------===//
// LayerBlock Specialization
//===----------------------------------------------------------------------===//