[mypyc] Remove symbol table and value index table from Environment #9768
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Instead of maintaining symbol tables in
Environment
, they are maintained inIRBuilder
and discarded after they are no longer needed.I also removed the value index table (
indexes
) fromEnvironment
. It wasmostly used for three purposes:
These use cases are now handled differently:
all_values
, that find values in IR byiterating over it and collecting them.
FuncIR
now stores argument registers explicitly.(
make_value_ordering
).There are three main reasons why I think that this PR makes sense. First, it
simplifies the IR and makes things easier to understand. Second, transforming
IR is easier and less error-prone, as the symbol tables and index dictionaries
no longer need to be kept in sync with the IR. Third, this makes it easy to get
rid of
Environment
altogether (in a follow-up PR).A nice side effect is that we can now just create a
Register
instance directlyand start using it, instead of having to call
alloc_temp()
.Some tests had to be updated, since the registers are now numbered differently
in some cases. Arguably, it's now more logical and predictable. There won't be
gaps in the numbering.
Work on mypyc/mypyc#781.