calyx_opt/lib.rs
1//! # The Calyx Intermediate Language
2//!
3//! Calyx is an intermediate language for transforming high-level programs
4//! into synthesizable hardware designs.
5//! Calyx's key novelty is a split representation that captures the control-flow
6//! and the structural detail of a hardware design.
7//! Take a look at the [language tutorial][lang-tut] for a complete overview for the Calyx
8//! intermediate langauge.
9//!
10//! This library defines the intermediate representation, i.e., the data structures used by the
11//! compiler to analyze and transform programs.
12//! The following example shows how to parse a Calyx program and generate the core data structure,
13//! [ir::Context] which provides access to all the information in a program.
14//!
15//! ```rust
16//! use std::io::Write;
17//! use calyx_ir as ir;
18//! use calyx_frontend as frontend;
19//! use calyx_utils::CalyxResult;
20//! fn main() -> CalyxResult<()> {
21//! // File to parse
22//! let file: std::path::PathBuf = "../tests/correctness/seq.futil".into();
23//! // Location of the calyx repository
24//! let lib_path: std::path::PathBuf = "../".into();
25//! // Parse the calyx program
26//! let ws = frontend::Workspace::construct(&Some(file), &lib_path)?;
27//! // Convert it into an ir::Context
28//! let mut ctx = ir::from_ast::ast_to_ir(ws, AstConversionConfig::default())?;
29//! // Print out the components in the program
30//! let out = &mut std::io::stdout();
31//! for comp in &ctx.components {
32//! ir::Printer::write_component(comp, out)?;
33//! writeln!(out)?
34//! }
35//! Ok(())
36//! }
37//! ```
38//!
39//! [^1]: Calyx's guarded assignments are different from [Bluespec's rules][bsv-rules].
40//! Rules can be dynamically aborted if there are conflicts at runtime and the
41//! Bluespec compiler generates scheduling logic to detect such cases.
42//! In contract, Calyx's schedule is defined using the control program and
43//! requires no additional scheduling logic to detect aborts.
44//!
45//! [bsv-rules]: http://wiki.bluespec.com/Home/Rules
46//! [lang-tut]: https://docs.calyxir.org/tutorial/language-tut.html
47pub mod analysis;
48pub mod default_passes;
49pub mod pass_manager;
50pub mod passes;
51pub mod passes_experimental;
52pub mod traversal;