gruel_cfg/lib.rs
1//! Control Flow Graph IR for the Gruel compiler.
2//!
3//! This crate provides a CFG-based intermediate representation that sits
4//! between AIR (typed, structured) and X86Mir (machine-specific).
5//!
6//! The CFG representation makes control flow explicit through basic blocks
7//! and terminators, which is essential for:
8//! - Linear type checking
9//! - Drop elaboration
10//! - Liveness analysis
11//! - Other dataflow analyses
12//!
13//! ## Pipeline
14//!
15//! ```text
16//! AIR (structured) → CFG (explicit control flow) → X86Mir (machine code)
17//! ```
18
19mod build;
20pub mod drop_names;
21mod inst;
22pub mod opt;
23
24use gruel_error::CompileWarning;
25
26pub use build::CfgBuilder;
27pub use inst::{
28 BasicBlock, BlockId, Cfg, CfgArgMode, CfgCallArg, CfgInst, CfgInstData, CfgValue, Place,
29 PlaceBase, Projection, Terminator,
30};
31pub use opt::OptLevel;
32
33// Re-export types from gruel-air that we use
34pub use gruel_air::{StructDef, StructId, Type, TypeKind};
35
36/// Output from CFG construction.
37///
38/// Contains the constructed CFG along with any warnings detected during
39/// construction (e.g., unreachable code).
40pub struct CfgOutput {
41 /// The constructed control flow graph.
42 pub cfg: Cfg,
43 /// Warnings detected during CFG construction.
44 pub warnings: Vec<CompileWarning>,
45}