Lowering & rendering
cheetah.internal.core_to_codegen
performs lowering from core IR to codegen IR and final rendering.
Steps
- Collect dependencies: walk all bodies reachable from the selected entry points (calls and addresses)
- Generate names: export names reserved first, internal names derived from function internal names or generic prefixes (with deconfliction)
- Inlining analysis: mark pure/read expressions used once as inlineable; track control/memory epochs to avoid unsafe movement
- Emit codegen IR: walk blocks and convert expressions/statements; hoist decls for values not inlined
- Compose program: headers, prototypes, definitions; optional pybind11 stub if
bind=True
Naming
- Variables derive names from user-provided names (via
ch.set_name
and instrumentation) or type-driven prefixes - Functions get stable names with numeric suffixes if needed
Safety and ordering
- Epoch tracking enforces barriers around control constructs and side-effecting ops (writes, raw code/asm, calls)
- Logical
&&
/||
force operands not to be inlined across short-circuit boundaries