add initial documentation for spirv_to_llvm
[kazan.git] / docs / spirv_to_llvm.md
1 # spirv_to_llvm library
2
3 ## `spirv_to_llvm/spirv_to_llvm.h`
4
5 ### `spirv_to_llvm::Type_descriptor`
6 Type representing a SPIR-V Type. Does custom type layout instead of letting LLVM layout types to avoid creating types that need a stricter alignment than `::operator new` provides.
7 Members:
8 - `decorations`: the SPIR-V decorations applied to this type.
9 - `get_or_make_type`: returns the LLVM type that `this` translates to, generating it if needed. Also returns the alignment used to store the returned LLVM type.
10 - `visit`
11 - `Recursion_checker`: helper type used to prevent infinite recursion when generating LLVM types.
12 See `spirv_to_llvm::Struct_type_descriptor::get_or_make_type` to see how to use it.
13 - `Recursion_checker_state`: state used by `Recursion_checker`.
14
15 ### `spirv_to_llvm::Simple_type_descriptor`
16 Wrap a fundamental type (not based on any other SPIR-V type).
17
18 ### `spirv_to_llvm::Vector_type_descriptor`
19 Wrap a vector type.
20
21 ### `spirv_to_llvm::Matrix_type_descriptor`
22 Wrap a matrix type.
23
24 ### `spirv_to_llvm::Array_type_descriptor`
25 Wrap an array type.
26
27 ### `spirv_to_llvm::Pointer_type_descriptor`
28 Wrap a pointer type. If `base == nullptr`, then `this` is a forward declaration.
29
30 ### `spirv_to_llvm::Function_type_descriptor`
31 Wrap a function type.
32
33 ### `spirv_to_llvm::Struct_type_descriptor`
34 Wrap a struct type.
35 This can be in one of two states:
36 - Incomplete: The default state upon construction. Members can be added in this state.
37 - Complete: The state transitioned to by calling `get_members(true)` or `get_or_make_type()`. Members can no longer be added.
38
39 ### `spirv_to_llvm::Constant_descriptor`
40 A SPIR-V constant.
41 Members:
42 - `get_or_make_value`: returns the LLVM value that `this` translates to, generating it if needed.
43
44 ### `spirv_to_llvm::Simple_constant_descriptor`
45 A simple SPIR-V constant. Wraps a LLVM value.
46
47 ### `spirv_to_llvm::Converted_module`
48 The results of converting a SPIR-V shader from SPIR-V to LLVM IR.
49
50 ### `spirv_to_llvm::Jit_symbol_resolver`
51 Resolve built-in symbols for the JIT. This is where to add new built-in functions that are called by LLVM IR.
52
53 ### `spirv_to_llvm::spirv_to_llvm`
54 Convert the provided SPIR-V shader to LLVM IR. Throws `spirv::Parser_error` on error.