Skip to content

[SCFToCalyx] Modify top-level function in place and propagate external memory allocations #8446

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jiahanxie353
Copy link
Contributor

@jiahanxie353 jiahanxie353 commented Apr 25, 2025

This patch refactors the logic when there are memref type function arguments in the top-level function (because Calyx only supports interacting with memory data if that memory is allocated using @external and does not support function argument memory data passing).
We used to create a new top-level function, which does nothing but invokeing the old top-level function. This approach is fine semantically, but recently @ayakayorihiro discovered that this prevents the static inference from inferencing the number of cycles in the Calyx project: calyxir/calyx#2452.
As a solution, we can just modify the top-level function in-place by moving those memref function arguments to explicit memref.allocs in the function body.

Moreover, this patch also supports propagating external memory allocations from non-top-level functions to the top-level function because of the constraint in the Calyx project: https://github.com/calyxir/calyx/blob/50f817f9991df4fa87f2178222ba45a026aba549/calyx/opt/src/passes/well_formed.rs#L185

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant