Prevent variable reassignment#485
Closed
daniellerozenblit wants to merge 7 commits into
Closed
Conversation
Summary: This diff splits `CompilerTest.cpp` into separate test files per compiler stage. This makes it easier to test the functionality of each component in isolation; e.g making sure the parser produces the expected AST before optimizations. Differential Revision: D95084293
Summary: # Stack The goal of this stack is to add support for variable assignments and assume operations to SDDL2. # Diff This diff implements variable assignment and reference support in the code generator. This enables SDDL2 programs to use global variables for parameterizing field sizes and reusing type definitions. - Implemented `Op::ASSIGN` codegen: evaluates the RHS expression, allocates a VM register via `getOrAssignRegister()`, and emits `var.store`. - Implemented `ASTVar` reference codegen: looks up the variable's register and emits `var.load`. If this is the last reference to a particular variable, returns the register to the free pool. - Added a register allocator (`var_registry_`, `free_registers_`, `next_register_`) that reuses freed registers and enforces the `SDDL2_VAR_REGISTER_COUNT` (256) limit at compile time. Differential Revision: D94947414
Summary: # Stack The goal of this stack is to add support for variable assignments and assume operations to SDDL2. # Diff This diff adds a `MEMBER` op to the SDDL grammar, which can be used to access fields of consumed recrds. This operator (`.`) was already supported in the syntax. Differential Revision: D95396139
Summary: # Stack The goal of this stack is to add support for variable assignments and assume operations to SDDL2. # Diff This diff handles the `MEMBER` op in the dead var optimizer. Differential Revision: D95396507
Summary: # Stack The goal of this stack is to add support for variable assignments and assume operations to SDDL2. # Diff The diff updates the semantic analyzer to support the `MEMBER` operation. This mainly validates that operands are semantically correct (e.g., LHS is a consumed record, RHS is a field). Differential Revision: D95430690
Summary: # Stack The goal of this stack is to add support for variable assignments and assume operations to SDDL2. # Diff This diff extracts register allocation logic from `CodeGenerator` into a dedicated `RegisterAllocator` utility class. This improves code organization. Differential Revision: D95582393
Summary: This diff expands the SDDL semantic analyzer to prevent variable reassignment. This makes implementation of codegen much simpler in a lot of cases. Differential Revision: D95802815
|
@daniellerozenblit has exported this pull request. If you are a Meta employee, you can view the originating Diff in D95802815. |
daniellerozenblit
added a commit
to daniellerozenblit/openzl-1
that referenced
this pull request
Mar 9, 2026
Summary: This diff expands the SDDL semantic analyzer to prevent variable reassignment. This makes implementation of codegen much simpler in a lot of cases. Differential Revision: D95802815
daniellerozenblit
added a commit
to daniellerozenblit/openzl-1
that referenced
this pull request
Mar 10, 2026
Summary: This diff expands the SDDL semantic analyzer to prevent variable reassignment. This makes implementation of codegen much simpler in a lot of cases. Differential Revision: D95802815
|
This pull request has been merged in 014701c. |
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.
Summary: This diff expands the SDDL semantic analyzer to prevent variable reassignment. This makes implementation of codegen much simpler in a lot of cases.
Differential Revision: D95802815