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 four files, one per level of the thing it walks. `unit` is the translation
12//! unit: objects with static storage, their images, and the functions. `body` is one function:
13//! the statements, the control flow, and the expressions. `repr` is the answer to what a C type
14//! is once the IR is the one asking, and `abi` is the answer to how a call travels, which is the
15//! target's rather than C's.
16//!
17//! What it does not build yet is reported rather than mislowered. An `asm` at file scope, a
18//! `goto` in a function that has a variable length array in it and a `va_arg` that reads a
19//! structure each become a diagnostic, so a program that uses one fails to compile rather than
20//! compiling into something that is not what it says.
21//!
22//! Every crate in the workspace is published, and publishing implies a promise. This one is
23//! tier 3: its Rust API is explicitly unstable and will change without a major version bump.
24//! Depend on the `rucc` binary's behaviour, not on this.
25
26#![doc(html_root_url = "https://docs.rs/rucc-lower/0.2.20")]
27
28mod abi;
29mod bits;
30mod body;
31mod repr;
32mod ssa;
33mod unit;
34
35pub use ssa::{Ssa, Var};
36pub use unit::{Context, Lowered, lower};
37
38/// The milestone in `spec/17-milestones.md` that fills this crate in.
39pub const MILESTONE: &str = "M2";
40
41#[cfg(test)]
42mod tests {
43    #[test]
44    fn milestone_is_recorded() {
45        assert!(super::MILESTONE.starts_with('M'));
46    }
47}