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
//! # panproto-llvm
//!
//! LLVM IR protocol definition and lowering morphisms for panproto.
//!
//! This crate provides:
//!
//! 1. **LLVM IR protocol**: A GAT theory and protocol definition for
//! representing LLVM IR modules as panproto schemas. Vertex kinds cover
//! modules, functions, basic blocks, instructions, types, and values.
//! Edge kinds cover containment, data flow (SSA use-def chains),
//! control flow (successors), and typing.
//!
//! 2. **Lowering morphisms**: Theory morphisms from language AST protocols
//! (TypeScript, Python, Rust) to LLVM IR. These express compilation as
//! structure-preserving maps, enabling cross-level migration via
//! functoriality.
//!
//! 3. **inkwell backend** (optional, feature-gated): LLVM IR parsing from
//! `.ll`/`.bc` files, emission, and C/C++ compilation via clang.
//! Requires LLVM installed locally. Enable with `--features=inkwell-backend`.
//!
//! ## Category theory
//!
//! Lowering morphisms are theory morphisms in the GAT system. If
//! `lower: ThTypeScriptFullAST → ThLLVMIR` is the lowering morphism, then:
//!
//! - `restrict(lower) ∘ restrict(mig) = restrict(lower ∘ mig)` (functoriality)
//! - The complement of the lowering captures source-level info lost in IR
//! - LLVM passes (DCE, inlining) are protolenses on `ThLLVMIR`
/// Error types for LLVM IR operations.
/// LLVM IR protocol definition (theory, vertex kinds, edge rules).
/// Theory morphisms from language ASTs to LLVM IR.
/// LLVM IR text parsing into panproto schemas via inkwell.
pub use LlvmError;
pub use all_lowering_morphisms;
pub use protocol as llvm_ir_protocol;
pub use parse_llvm_ir;