vyre-foundation 0.4.1

Foundation layer: IR, type system, memory model, wire format. Zero application semantics. Part of the vyre GPU compiler.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//! Shared helpers for optimizer and transform unit tests.

use crate::ir::{Node, Program};

/// Return the effective entry body of a `Program`.
///
/// F-IR-29 invariant: `Program::wrapped` produces an entry whose first (and
/// usually only) top-level node is `Node::Region`. Most tests that inspect
/// the optimized IR need to look inside that Region. This helper hides the
/// unwrap so tests stay consistent even when the program has already been
/// through `region_inline` and the wrapper is gone.
pub(crate) fn region_body(program: &Program) -> &[Node] {
    match program.entry() {
        [Node::Region { body, .. }] => body,
        other => other,
    }
}