Skip to content
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

Collect AST node should accept a complex expression in order to cooperate with L_Array #31

Open
leungbk opened this issue Jan 14, 2024 · 0 comments

Comments

@leungbk
Copy link

leungbk commented Jan 14, 2024

In the L_Array language, the abstract syntax includes (make-vector exp exp), where both arguments can be complex expressions. This would appear to include the case where the first exp happens to be a (read) invocation (or a Var bound to a read invocation).

When rewriting the expose_allocation pass for L_Array, the book suggests that we generate code for L_Array in a manner analogous to the case for L_Tup, which, among other things, generates a Collect node that accepts a plain integer (and not an Int AST node). In the case of L_Tup, the integer is always known at compile time, since in the compiler pass, we can simply count the entries passed into (vector entry-0 entry-1...), so it is fine to create a Collect AST node with that known length; however, for L_Array, if the specified length is a complex expression that cannot be known at compile time (such as a (read) invocation), then Collect in its present form does not seem appropriate. This is confusing to me, especially since it is stated in the text that AllocateArray takes a complex subexpression; possibly I am simply missing the right way to rewrite expose_allocation for L_Array.

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

No branches or pull requests

1 participant