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;
22
23use gruel_util::CompileWarning;
24
25pub use build::CfgBuilder;
26pub use inst::{
27 BasicBlock, BlockId, Cfg, CfgArgMode, CfgCallArg, CfgInst, CfgInstData, CfgValue,
28 MakeSliceData, Place, PlaceBase, Projection, SpawnTarget, Terminator,
29};
30
31// Re-export types from gruel-air that we use
32pub use gruel_air::{StructDef, StructId, Type, TypeKind};
33
34/// Output from CFG construction.
35///
36/// Contains the constructed CFG along with any warnings detected during
37/// construction (e.g., unreachable code).
38pub struct CfgOutput {
39 /// The constructed control flow graph.
40 pub cfg: Cfg,
41 /// Warnings detected during CFG construction.
42 pub warnings: Vec<CompileWarning>,
43}