Conversation
rwy7
commented
Apr 28, 2026
- move layer utilities to LayerSet.h header
- adds new source LayerSet.cpp which contains the implementations of the layer utilities
- when lowering a layer block, if the layer is enabled, inline it instead, by splicing the layer block's body into the parent block.
seldridge
left a comment
There was a problem hiding this comment.
Nice. This will improve the output quality a fair amount by avoiding unnecessary layer cruft.
Two things:
- Can the PR include an end-to-end test to lock-in the Verilog quality improvement?
- Is this still ABI-preserving? This would be obvious with (1). I.e., what happens if there is a public module that has an enabled layer, yet it runs into this optimization?
I did not review that no changes were made in the factoring out of the the layer utilities into the new header/file. While not required, that can be factored out into a separate commit / rebase-and-merged. Not required.
| .Case<FModuleOp>([&](auto op) { | ||
| LayerSet enabledLayers; | ||
| enabledLayers.insert_range( | ||
| op.getLayersAttr().template getAsRange<SymbolRefAttr>()); |
There was a problem hiding this comment.
This is cleaner without the .template .
| .Case<FModuleOp>([&](auto op) { | |
| LayerSet enabledLayers; | |
| enabledLayers.insert_range( | |
| op.getLayersAttr().template getAsRange<SymbolRefAttr>()); | |
| .Case<FModuleOp>([&](FModuleOp op) { | |
| LayerSet enabledLayers; | |
| enabledLayers.insert_range( | |
| op.getLayersAttr().getAsRange<SymbolRefAttr>()); |
| LayerSet enabledLayers; | ||
| enabledLayers.insert_range( | ||
| op.getLayersAttr().template getAsRange<SymbolRefAttr>()); |
There was a problem hiding this comment.
Super nit: if this is a frequent pattern, i.e., "get a layer set of a module", then this would be good as an alternative constructor for LayerSet. I think this would require making LayerSet an actual class as opposed to a type alias.
| layerBlock->getBlock()->getOperations().splice( | ||
| Block::iterator(layerBlock), layerBlock.getBody()->getOperations()); |
There was a problem hiding this comment.
Nice splice! It's clean and super efficient. 💯