1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//! 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, lowering it into LLVM
//! IR, and optionally driving external LLVM tools through reusable target
//! profiles.
//!
//! 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()"));
//! ```
//!
//! Lower-level callers can use [`bf`], [`ir`], and [`llvm`] directly. Tooling
//! that wants Hypothalamus' command-line behavior without shelling out can use
//! [`driver`] with a [`target::TargetProfile`].
/// Brainfuck parser and optimizer.
/// Compiler-driver configuration and LLVM tool invocation.
/// Toolchain and target diagnostics.
/// Optimized intermediate representation and Brainfuck-specific optimization.
/// LLVM IR backend for parsed Brainfuck operations.
/// Named target profiles and runtime ABI defaults.
/// Target-specific complete-image builders.
pub use ;
pub use ;
/// 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;