vyre 0.4.0

GPU compute intermediate representation with a standard operation library
Documentation
//! The vyre intermediate representation.
//!
//! Vyre is LLVM-for-GPU: this module is the IR layer. It defines pure Rust
//! data structures for GPU compute programs that can be constructed,
//! validated, optimized, serialized, and lowered to any backend without
//! touching GPU hardware. Frontends emit `Program` values; backends
//! consume them.

/// Core data model: `Program`, `Node`, `Expr`, `DataType`.
///
/// The data model is the source of truth for what a vyre program means.
/// Every other layer (serialization, validation, lowering) operates on
/// these types.
pub mod model;

/// Host-side helpers that prepare IR engine inputs without owning a backend.
pub mod engine;

/// Serialization: binary wire format and canonical text.
///
/// `serial` turns `Program` values into compact byte streams that can be
/// cached, transmitted, or stored. The wire format is stable and
/// version-agnostic.
pub mod serial;

/// IR passes: optimize, inline, visit.
///
/// `transform` contains compiler passes that run on `Program` before
/// lowering: call inlining, common-subexpression elimination, dead-code
/// elimination, and visitor utilities.
pub mod transform;

/// Structural and semantic validation.
///
/// `validate` checks a `Program` for well-formedness: type consistency,
/// bounded nesting, valid buffer references, and conformance to the vyre
/// specification. A program must pass validation before it can be lowered.
pub mod validate;

/// Expression nodes that produce values.
///
/// `Expr` is the building block of computation: literals, arithmetic,
/// buffer loads, and operation calls.
pub use model::arena::{ArenaProgram, ExprArena, ExprRef};
pub use model::expr::{Expr, Ident};

/// Statement nodes that execute effects.
///
/// `Node` represents imperative statements: declarations, assignments,
/// control flow, and buffer stores.
pub use model::node::Node;

/// Program and buffer declaration types.
///
/// `Program` is the frozen IR container. `BufferDecl` describes the
/// inputs, outputs, and scratch memory used by a program.
pub use model::program::{BufferDecl, Program};

/// Core IR types: data types, operators, access modes, and signatures.
///
/// These types form the vocabulary of every vyre program. They are
/// re-exported from `vyre-spec` so that frontends and backends can depend
/// on them without pulling in the full compiler.
pub use model::types::{
    AtomicOp, BinOp, BufferAccess, Convention, DataType, DataTypeSizeBytes, OpSignature, UnOp,
};

/// Canonical text serialization for programs and expressions.
///
/// The text format is human-readable and useful for debugging, logging,
/// and diffing IR changes in tests.
pub use serial::text;

/// Call inlining transformation and operation resolver.
///
/// `inline_calls` expands `Expr::Call` nodes into the callee's IR body.
/// This eliminates kernel-dispatch overhead for small compositional ops.
pub use transform::inline::{inline_calls, inline_calls_with_resolver, OpResolver};

/// Optimization passes: common subexpression elimination, dead code elimination, and full optimize.
///
/// These functions run standard compiler optimizations on vyre IR so that
/// frontends can emit naive code and rely on the core library to clean it
/// up before lowering.
pub use transform::optimize::{cse, dce, optimize};

/// Default depth limits and limit tracking for validation.
///
/// These constants guard against pathological programs: infinitely deep
/// call chains, excessively nested control flow, or programs with too many
/// nodes for the target adapter.
pub use validate::depth::{
    LimitState, DEFAULT_MAX_CALL_DEPTH, DEFAULT_MAX_NESTING_DEPTH, DEFAULT_MAX_NODE_COUNT,
};

/// Validate a program against structural and semantic rules.
///
/// `validate` is the mandatory gate between frontend emission and backend
/// lowering. It returns a detailed error report for every invariant
/// violation.
pub use validate::validate::validate;

/// Detailed validation failure report.
///
/// `ValidationError` describes exactly which invariant was violated, where
/// in the program it occurred, and how to fix it.
pub use validate::validation_error::ValidationError;