Skip to main content

Module emit

Module emit 

Source
Expand description

Source-text rewriting engine: applies IR-node span substitutions to a source string for a given target backend.

Functions§

apply_replacements
Apply the span replacements for target against unit.source, returning the rewritten text. Replacements are applied in source order, tracking the cumulative byte shift so each edit lands at its original semantic position regardless of earlier edits’ length differences.
effective_end
Effective end-byte of a node for the given target. For HIP, the trailing .x / .y / .z field access is preserved (HIP’s builtins are dim3-typed and the field access is still valid). For every other target the field access must be consumed because the replacement is a scalar function call.
emit
Emit unit to target. Returns the rewritten source plus a list of warnings produced during the rewrite (structurally the rewriter also has the option of mutating the IR with Warning nodes up-front).
replacement_for
Decide what (if anything) to replace for a given node and target. Returns None if the node needs no rewrite for the given target.