rucc_opt/lib.rs
1//! The pass manager, the acyclic e-graph, the rewrite rules and the analyses.
2//!
3//! Design: `spec/09-optimizer.md`. Layer rank 9, see `spec/18-package-layout.md`.
4//!
5//! # What is here
6//!
7//! The pass manager and four passes. [`pipeline`] holds the six pipelines, one per optimization
8//! level, written out rather than assembled from flags, along with the fuel, the dumps and the
9//! verification that section 9.10 asks of every pass. [`fold`] is the first pass through it,
10//! [`simplify`] is the peephole the e-graph will eventually absorb, [`narrow`] takes the width
11//! back off arithmetic that C promoted, and [`dce`] is what clears up after all three of them.
12//! [`uses`] is the one thing two of them share, which is a count of who reads what.
13//!
14//! [`stats`] is what a pass has to return, and [`optinfo`] is that printed. A pass reports what
15//! it did and what it gave up on, and there is no other way for it to tell the manager it changed
16//! anything, so the instrumentation cannot be the thing nobody got round to. Section 42.2 of
17//! `spec/optimizer/42-measurement.md` counted what happens otherwise.
18//!
19//! [`mod@cfg`], [`dom`] and [`loops`] are the analyses so far, and everything in
20//! `spec/optimizer/07` through `spec/optimizer/11` is built on them. [`mod@cfg`] is the shape of a
21//! function with the instructions taken out, [`dom`] answers what every path has to go through,
22//! forwards and backwards, and [`loops`] says what loops there are, how they nest, and which
23//! cycles are not loops at all.
24//!
25//! The e-graph and the rewrite rule set are still M4 work and are not here yet. So is the
26//! analysis manager, which section 9.10 also asks for: a pass declares which analyses it
27//! requires, preserves and invalidates, and a debug check recomputes one it claimed to preserve
28//! and compares. The three here are built by their callers for now, and the manager lands with
29//! the passes that consume more than one of them at a time.
30//!
31//! # Stability
32//!
33//! Every crate in the workspace is published, and publishing implies a promise. This one is
34//! tier 3: its Rust API is explicitly unstable and will change without a major version bump.
35//! Depend on the `rucc` binary's behaviour, not on this.
36
37#![doc(html_root_url = "https://docs.rs/rucc-opt/0.4.2")]
38
39pub mod cfg;
40pub mod dce;
41pub mod dom;
42pub mod fold;
43pub mod fuel;
44pub mod loops;
45pub mod narrow;
46pub mod optinfo;
47pub mod pass;
48pub mod pipeline;
49pub mod simplify;
50pub mod stats;
51#[cfg(test)]
52mod testing;
53pub mod uses;
54
55pub use cfg::Cfg;
56pub use dom::{Dominators, PostDominators};
57pub use fuel::Fuel;
58pub use loops::{Exit, LoopId, Loops};
59pub use optinfo::Wants;
60pub use pass::{PASSES, Pass};
61pub use pipeline::{Dump, Dumps, Options, Remark, Report, run};
62pub use stats::Stats;
63
64/// The milestone in `spec/17-milestones.md` that fills this crate in.
65pub const MILESTONE: &str = "M4";
66
67#[cfg(test)]
68mod tests {
69 #[test]
70 fn milestone_is_recorded() {
71 assert!(super::MILESTONE.starts_with('M'));
72 }
73}