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
//! Core type definitions for the vyre IR.
//!
//! These public types are defined by `vyre-spec` so that backend
//! conformance can be proved without depending on `vyre`. The extension
//! trait `DataTypeSizeBytes` adds conservative size queries needed by
//! lowering and validation code.
//!
//! # Examples
//!
//! ```
//! use vyre::ir::{DataType, BufferAccess, BinOp};
//!
//! // Element type for a U32 buffer
//! let elem = DataType::U32;
//!
//! // Read-write access for an output buffer
//! let access = BufferAccess::ReadWrite;
//!
//! // The arithmetic operator used inside an Expr::BinOp
//! let op = BinOp::Add;
//! ```
/// Re-export of frozen IR types from `vyre-spec`.
///
/// These types are the vocabulary of every vyre program: data types,
/// buffer access modes, binary and unary operators, function calling
/// conventions, and operation signatures. Because they live in the spec
/// crate, frontends and backends can depend on them without pulling in
/// the full compiler.
pub use ;
/// Conservative byte-size query for IR data types.
///
/// This extension trait mirrors [`DataType::min_bytes`] under a name used by
/// lowering and validation code that needs a fixed per-value size. `Bytes`
/// returns `0` because it represents variable-length byte buffers rather than a
/// scalar element.
///
/// # Examples
///
/// ```
/// use vyre::ir::{DataType, DataTypeSizeBytes};
///
/// assert_eq!(DataType::U32.size_bytes(), 4);
/// assert_eq!(DataType::Bytes.size_bytes(), 0);
/// ```