refactor(ir): move indentation and GEP layout out of model Display - #20
Open
Boreas618 wants to merge 2 commits into
Open
refactor(ir): move indentation and GEP layout out of model Display#20Boreas618 wants to merge 2 commits into
Boreas618 wants to merge 2 commits into
Conversation
Stmt's Display used to bake a leading tab into every instruction, making the model own the printer's layout policy; GepStmt's Display embedded struct/array layout computation and could fail with fmt::Error, so formatting doubled as a late error path. Both concerns now live at the printing boundary: instructions render as bare text, IrPrinter::emit_function_def owns the indent column, and the fallible GEP computation moved into the explicit GepStmt::render helper, which the printer consumes through its Result-returning emit path. GepStmt keeps no Display impl of its own; the Stmt::Gep Display arm preserves historical behaviour for hypothetical direct consumers (text for well-typed GEPs, fmt::Error for ill-typed ones). Emitted IR is byte-identical (verified by diffing --emit ir output against the pre-change binary across the tests/ corpus).
Rewrote 4 historical narratives as present-tense contracts (§3.1/§3.2): the removed-`\t` reference on Stmt's Display doc, "preserves their historical behaviour" in the GEP Display arm, "the previous fmt::Error-based failure" in GepStmt::render, and a "now needs" temporal marker on TARGET_TRIPLE. Fixed 1 stale claim against current code (§4.1/§8.1): emit_stmt's doc no longer asserts block labels are not statements — Label statements exist in the flat IR and are consumed when BasicBlocks are built. No commented-out code, dividers, or annotation tags found in these files.
Boreas618
force-pushed
the
refactor/ir-printer-boundary
branch
from
August 1, 2026 10:58
dd50b34 to
7f641f5
Compare
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.
Printer-boundary unification from the cross-layer audit:
Stmt's Display baked a leading\tinto every instruction — the model owned the printer's layout policy. Instructions now render bare text;IrPrinter::emit_function_defowns the indent column.GepStmt::fmtembedded struct/array layout computation that could fail withfmt::Error— formatting doubled as a late error path. The fallible logic is now an explicitGepStmt::renderhelper returningResult<_, ir::Error>, consumed by the printer'sResult-returning emit path.//!module docs forir/stmt.rsandir/printer.rs.Emitted IR is byte-identical (diffed
--emit iragainst the pre-change binary across the tests/ corpus). Verified:cargo test30/30 green.