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

implement set_variable and unset_variable #157

Open
dcbaker opened this issue Nov 13, 2024 · 0 comments
Open

implement set_variable and unset_variable #157

dcbaker opened this issue Nov 13, 2024 · 0 comments
Labels
difficulty:moderate MIR Issues related to the MIR (Mid level IR)

Comments

@dcbaker
Copy link
Owner

dcbaker commented Nov 13, 2024

set_variable

We have the problem that you can use set_variable to set a variable by a variable. consider:

foreach x : ['a', 'b', 'c', 'd']
  set_variable(x, 'foo')
endforeach

It's tempting to try to do early lowering on this, where we would early on rewrite set_variable('x', 'foo') to x = 'foo', but I highly doubt that's useful. that's a case where someone can just write x = 'foo', and not get into the weeds of set_variable. Even in the case above, it's rather simple to handle this via loop unrolling. The real concern I have, is that we may not always be aware of what x is, and thus have invalid global value numbering, and perhaps even have invalid optimization of the program. This is more complicated when the value is also a variable, such as set_variable(x, y)

unset_variable

This will require better tracking of variables declared in blocks, since the biggest side effect of this is that we need to make sure that versions of variables that are undefined don't propagate across block boundaries. That probably means that we should move variable version tracking to either the cfg node or the block

@dcbaker dcbaker added MIR Issues related to the MIR (Mid level IR) difficulty:moderate labels Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty:moderate MIR Issues related to the MIR (Mid level IR)
Projects
None yet
Development

No branches or pull requests

1 participant