hypothalamus 0.3.0

An optimizing Brainfuck AOT compiler with an LLVM IR backend
Documentation
//! Hypothalamus' reusable compiler library.
//!
//! The crate exposes the pipeline stages used by the command-line compiler:
//! parsing Brainfuck source into a compact operation tree, optimizing that tree
//! into a backend-oriented intermediate representation, then lowering it into
//! LLVM IR.
//!
//! Typical library usage starts with [`bf::parse`] and passes the resulting
//! operations to [`llvm::generate_module`]:
//!
//! ```
//! use hypothalamus::bf;
//! use hypothalamus::llvm::{self, LlvmOptions};
//! use hypothalamus::DEFAULT_TAPE_SIZE;
//!
//! let ops = bf::parse(b"++.").expect("valid Brainfuck");
//! let ir = llvm::generate_module(
//!     &ops,
//!     &LlvmOptions {
//!         tape_size: DEFAULT_TAPE_SIZE,
//!         target_triple: None,
//!         source_filename: Some("example.bf".to_string()),
//!         bounds_check: false,
//!         runtime: hypothalamus::llvm::Runtime::Hosted,
//!     },
//! )
//! .expect("LLVM IR");
//!
//! assert!(ir.contains("define i32 @main()"));
//! ```
//!
//! Hypothalamus intentionally keeps policy in the binary and the mechanics in
//! this crate. The library does not invoke `clang` or `lli`, write files, choose
//! output paths, or validate platform toolchains; it only parses source,
//! optimizes operations, and produces text LLVM IR.

#![warn(missing_docs)]

/// Brainfuck parser and optimizer.
pub mod bf;

/// Optimized intermediate representation and Brainfuck-specific optimization.
pub mod ir;

/// LLVM IR backend for parsed Brainfuck operations.
pub mod llvm;

/// Default number of byte cells in the generated Brainfuck tape.
///
/// This matches the conventional 30,000-cell tape used by many Brainfuck
/// implementations. The parser itself is independent of the tape size; this
/// value is consumed by the LLVM backend when it declares the global tape.
pub const DEFAULT_TAPE_SIZE: usize = 30_000;