llvm / circt

Circuit IR Compilers and Tools
https://circt.org
Other
1.57k stars 277 forks source link

[FIRRTL] Add pass to specialize layers #7160

Closed youngar closed 2 weeks ago

youngar commented 2 weeks ago

Thanks for taking a look @seldridge.

if there is a module with layers enabled and we disable those layers, what do we do with that module?

Right now the code is deleting the module, there is a test here:

https://github.com/llvm/circt/pull/7160/files#diff-aab1abaeffdac59090e622bc6af09a5ca9489665e6cfad4fc7710332d482aec9R220

The logic is that it becomes impossible to instantiate the module, so implicitly every instance of the module would have been deleted by specialization, so its safe to remove the module. It might seem a aggressive to delete the module instead of letting something like IMDeadCodeElim remove it, but since we actually remove the layer declarations when they get specialized the enabled layer would become a dangling reference and fails to verify.

If we disable that layer and there are no public modules left, then the circuit just got whacked.

Yeah, had that problem when I was writing the test, there is a comment describing why there is a useless top level module :). I think the way things are going, we are eventually going to remove the concept of the top level module and then having an empty circuit would be fine.

seldridge commented 2 weeks ago

Awesome. That logic makes exact sense to me. I didn't read the tests closely enough.

Agree about multi-public making empty circuits sane constructions.