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
use crate::{
    sr::constants::Constant,
    sr::instructions,
    sr::ops::{self, Op},
    sr::storage::*,
    sr::types::Type,
};

#[derive(Debug)]
pub struct EntryPoint {
    pub execution_model: spirv::ExecutionModel,
    pub function: Token<Function>,
    pub name: String,
    //pub interface: Vec<spirv::Word>,
}

#[derive(Debug)]
pub struct Block {
    pub arguments: Vec<Token<Type>>,
    pub ops: Vec<Token<Op>>,
    pub terminator: ops::Terminator,
}

/// Jump destination parameters.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Jump {
    /// The block to jump to.
    pub block: Token<Block>,
    /// The argument values corresponding to the block arguments.
    pub arguments: Vec<Token<Op>>,
}

pub struct Function {
    pub control: spirv::FunctionControl,
    /// Function result type.
    pub result: Token<Type>,
    /// Function parameters.
    pub parameters: Vec<Token<Type>>,
    /// All blocks in this function.
    pub blocks: Storage<Block>,
    /// The first block of this function.
    pub start_block: Token<Block>,
}

pub struct Module {
    /// Version of the specification.
    pub version: spirv::Word,
    /// All OpCapability instructions.
    pub capabilities: Vec<spirv::Capability>,
    /// All OpExtension instructions.
    pub extensions: Vec<String>,
    /// All OpExtInstImport instructions.
    pub ext_inst_imports: Vec<String>,
    /// The OpMemoryModel instruction.
    pub memory_model: instructions::MemoryModel,
    /// All entry point declarations.
    pub entry_points: Vec<EntryPoint>,

    /// All types
    pub types: Storage<Type>,
    /// All constants.
    pub constants: Storage<Constant>,

    /// All operations.
    pub ops: Storage<Op>,

    /// All functions.
    pub functions: Vec<Function>,
}