1#![warn(missing_docs)]
2
3use gaia_assembler::{
4 backends::{Backend, GeneratedFiles},
5 config::GaiaConfig,
6 program::GaiaModule,
7};
8use gaia_types::{
9 helpers::{AbiCompatible, ApiCompatible, Architecture, CompilationTarget},
10 Result,
11};
12use std::collections::HashMap;
13
14pub struct SpirvGenerator;
15
16impl Backend for SpirvGenerator {
17 fn name(&self) -> &'static str {
18 "spirv"
19 }
20
21 fn primary_target(&self) -> CompilationTarget {
22 CompilationTarget {
23 build: Architecture::X86_64, host: AbiCompatible::SPIRV,
25 target: ApiCompatible::Vulkan,
26 }
27 }
28
29 fn match_score(&self, target: &CompilationTarget) -> f32 {
30 if target.host == AbiCompatible::SPIRV {
31 100.0
32 }
33 else {
34 0.0
35 }
36 }
37
38 fn generate(&self, program: &GaiaModule, _config: &GaiaConfig) -> Result<GeneratedFiles> {
39 let files = HashMap::new();
40 let diagnostics = Vec::new();
41
42 for function in &program.functions {
43 for block in &function.blocks {
44 for _instruction in &block.instructions {
45 }
47 }
48 }
49
50 Ok(GeneratedFiles { files, diagnostics })
51 }
52}
53
54impl SpirvGenerator {
55 pub fn compile_to_spirv_raw(&self, _source: &str) -> Result<Vec<u8>> {
56 Ok(vec![0x03, 0x02, 0x23, 0x07]) }
59}