Skip to content

refactor(ir): create and insert statements at an InsertionPoint - #849

Open
alexcgatea wants to merge 3 commits into
alex/code-motionfrom
alex/insertion-api
Open

alexcgatea wants to merge 3 commits into
alex/code-motionfrom
alex/insertion-api

Conversation

@alexcgatea

Copy link
Copy Markdown
Collaborator

Summary

Replaces the six Rewriter insertion methods with one, create(InsertionPoint, definition), and adds insert(InsertionPoint, stmt) to place a detached statement.

API changes

  • insert_before / insert_after / insert_terminator / insert_node / insert_ungraph_node / insert_ungraph_edge are replaced by create(insertion_pt, definition). One method, with the insertion point as data: InsertionPoint::{Before, After, Terminator, DiGraph, UnGraph}. An UnGraph member is a node or an edge statement according to its definition, so UnexpectedEdgeStatement / ExpectedEdgeStatement are removed.
  • insert(insertion_pt, stmt) places a detached statement of this Rewriter: one it made but has not placed (NotDetached otherwise). It fits the insertion point under the same rules as create. Nothing public makes a detached statement yet; the next PR's clones are the first.
  • Detached statements never placed are tombstoned when the Rewriter drops. Readers of their results are left with dangling operands, which verify_derived reports and run_pass quarantines.
  • A detached producer can be placed after its consumers. When insert places it in a graph, it adds the DiGraph edges and UnGraph wire endpoints to consumers already there. Its regression tests come with the next PR, since they need clones to make a detached statement.

alexcgatea and others added 3 commits November 10, 2026 08:35
Replaces the six insert_* methods with create(point, definition) and
insert(point, stmt) for detached statements. UnGraph members are nodes
or edge statements as their definition says.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Renames check_point to check_insertion_pt and InsertionPoint
parameters to insertion_pt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Placing a detached DiGraph member now adds edges to member slots that
already read its results, and placing a detached UnGraph edge statement
resyncs its wires. Documents that a detached statement never placed
leaves its readers dangling.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant