Introduce a Var entity to give an identity to region inputs and node outputs.#34
Draft
eddyb wants to merge 4 commits intoeddyb/insts-are-nodesfrom
Draft
Introduce a Var entity to give an identity to region inputs and node outputs.#34eddyb wants to merge 4 commits intoeddyb/insts-are-nodesfrom
Var entity to give an identity to region inputs and node outputs.#34eddyb wants to merge 4 commits intoeddyb/insts-are-nodesfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Note: this PR is a draft to avoid accidental merging onto its "base" branch (used as a form of ad-hoc PR stacking), and will remain as such, until its "base" branch can be set to
main, i.e. all prerequisite PRs will have landed, up to and including this PR (whose branch is the "base" of this one):DataInstandNode(removingNodeKind::Blockin the process). #33Before this PR,
Valuehad these two variants (besidesValue::Const(Const)):Value::RegionInput { region: Region, input_idx: u32 }Value::NodeOutput { node: Node, output_idx: u32 }These "positional" references felt simple, but were fragile/inefficient in a few ways:
After this PR, those
Valuevariants become a singleValue::Var(Var), where:Varis a new entity, mapping to aVarDecl(the name is more in the sense of lambda calculus and SSA, than anything like "memory-backed mutable variable")
RegionDef'sinputsfield andNodeDef'soutputfields holdsVars nowVarDecltracks the parentRegion/Nodeand theVar's own index in that parentWhile
Vars can themselves be misused, and require extra indirection and redundancy, now:VarDecls have to be updated, not anyVaruses, when making any additions/reorderings/removals/etc. to region inputs/node outputs, andVars' "ownership" can even be moved from e.g. a region input to a node output (without having to update any of its uses)Vars can easily tell them apart from the oldVars it hasn't replaced yet, even if they might end up in the same positional slots of e.g. a node's outputsVarDecls to be checked against its parent region/node's list ofVars (and there is logic in the pretty-printer to do some of that, mostly to avoid a misleading view of the IR if someVars have been orphaned/misplaced/etc.)TODO: using the name "var(iable)" for this, while having some precedent in math/CS, does mean that
GlobalVarandmem::MemOp::FuncLocalVarneed to be updated to avoid overlapping with it - perhaps by describing those as "(memory) bindings" instead of "variables".