Expand description
The typed AST to IR walk: SSA construction and ABI-directed lowering.
Design: spec/08-ir.md. Layer rank 9, see spec/18-package-layout.md.
§What is here so far
lower, the walk from the typed tree to the IR, and Ssa, the SSA construction by
Braun’s algorithm that it drives: the thing that lets a local variable become a value
without ever having been a stack slot.
The walk is in three files, one per level of the thing it walks. unit is the
translation unit: objects with static storage, their images, and the functions. body is
one function: the statements, the control flow, and the expressions. repr is the answer
to what a C type is once the IR is the one asking.
What it does not build yet is reported rather than mislowered. A switch, a goto, an
aggregate passed or returned by value, a bit-field, a statement expression, va_arg, a
variable length array and inline asm each become a diagnostic, so a program that uses one
fails to compile rather than compiling into something that is not what it says.
Every crate in the workspace is published, and publishing implies a promise. This one is
tier 3: its Rust API is explicitly unstable and will change without a major version bump.
Depend on the rucc binary’s behaviour, not on this.
Structs§
- Context
- Everything the walk reads, which is a checked translation unit and the target it is for.
- Lowered
- What the walk produced.
- Ssa
- The state of an SSA construction over one function.
- Var
- A variable, which is somewhere in the source that can be written more than once.
Constants§
- MILESTONE
- The milestone in
spec/17-milestones.mdthat fills this crate in.
Functions§
- lower
- Walks a checked translation unit and builds the IR for it.