calyxir / calyx

Intermediate Language (IL) for Hardware Accelerator Generators
https://calyxir.org
MIT License
450 stars 44 forks source link

Toplevel `ref` cells are not kept after `compile_invoke` pass #1993

Open nathanielnrn opened 1 month ago

nathanielnrn commented 1 month ago

The external-to-ref PR #1952 also removed a well-formedness check so that toplevel components can now contain ref cells. In terms of eventually deprecating @external in favor of ref, it seems like we may want to change the behavior of how the compiler handles ref cells in the toplevel in particular. Namely, the standard compilation currently removes these cells from the top level, so that they are not part of the components' struct. I believe this removal happens in the compile_invoke pass, but I'm not certain about that.

To keep ref in line with how @external behaves, I think it would make sense to both raise the ports of cells to the toplevel, and keep them in the struct. This is in line with how @external doesn't cause cell removal from toplevel components.

In terms of immediate consequences, this would allow yxi to interface with programs that have ref cells in their toplevel, as yxi relies on traversing through memory cells to determine the interface of a program.

Unfortunately this means that #1932 should be reopened.