Skip to main content

rucc_lower/
lib.rs

1//! The typed AST to IR walk: SSA construction and ABI-directed lowering.
2//!
3//! Design: `spec/08-ir.md`. Layer rank 9, see `spec/18-package-layout.md`.
4//!
5//! # What is here so far
6//!
7//! [`lower`], the walk from the typed tree to the IR, and [`Ssa`], the SSA construction by
8//! Braun's algorithm that it drives: the thing that lets a local variable become a value
9//! without ever having been a stack slot.
10//!
11//! The walk is in three files, one per level of the thing it walks. `unit` is the
12//! translation unit: objects with static storage, their images, and the functions. `body` is
13//! one function: the statements, the control flow, and the expressions. `repr` is the answer
14//! to what a C type is once the IR is the one asking.
15//!
16//! What it does not build yet is reported rather than mislowered. A `switch`, a `goto`, an
17//! aggregate passed or returned by value, a bit-field, a statement expression, `va_arg`, a
18//! variable length array and inline asm each become a diagnostic, so a program that uses one
19//! fails to compile rather than compiling into something that is not what it says.
20//!
21//! Every crate in the workspace is published, and publishing implies a promise. This one is
22//! tier 3: its Rust API is explicitly unstable and will change without a major version bump.
23//! Depend on the `rucc` binary's behaviour, not on this.
24
25#![doc(html_root_url = "https://docs.rs/rucc-lower/0.2.13")]
26
27mod body;
28mod repr;
29mod ssa;
30mod unit;
31
32pub use ssa::{Ssa, Var};
33pub use unit::{Context, Lowered, lower};
34
35/// The milestone in `spec/17-milestones.md` that fills this crate in.
36pub const MILESTONE: &str = "M2";
37
38#[cfg(test)]
39mod tests {
40    #[test]
41    fn milestone_is_recorded() {
42        assert!(super::MILESTONE.starts_with('M'));
43    }
44}