pub struct SpirVBackend {
pub module: SpirVModule,
/* private fields */
}Expand description
The SPIR-V code generation backend for OxiLean.
Translates OxiLean expressions and declarations into SPIR-V modules targeting Vulkan compute or graphics shaders.
Fields§
§module: SpirVModuleThe SPIR-V module being built
Implementations§
Source§impl SpirVBackend
impl SpirVBackend
Sourcepub fn configure_for_vulkan(&mut self)
pub fn configure_for_vulkan(&mut self)
Enable the Shader capability and GLSL 450 memory model (typical Vulkan setup).
Sourcepub fn configure_for_opencl(&mut self)
pub fn configure_for_opencl(&mut self)
Configure for OpenCL/compute kernels.
Sourcepub fn get_void_type(&mut self) -> u32
pub fn get_void_type(&mut self) -> u32
Declare or retrieve the void type.
Sourcepub fn declare_int_type(&mut self, width: u32, signed: bool) -> u32
pub fn declare_int_type(&mut self, width: u32, signed: bool) -> u32
Declare a scalar integer type.
Sourcepub fn declare_float_type(&mut self, width: u32) -> u32
pub fn declare_float_type(&mut self, width: u32) -> u32
Declare a scalar float type.
Sourcepub fn declare_vector_type(&mut self, element_type_id: u32, count: u32) -> u32
pub fn declare_vector_type(&mut self, element_type_id: u32, count: u32) -> u32
Declare a vector type.
Sourcepub fn declare_pointer_type(
&mut self,
storage_class: StorageClass,
pointee_type_id: u32,
) -> u32
pub fn declare_pointer_type( &mut self, storage_class: StorageClass, pointee_type_id: u32, ) -> u32
Declare a pointer type.
Sourcepub fn declare_function_type(
&mut self,
return_type_id: u32,
param_type_ids: Vec<u32>,
) -> u32
pub fn declare_function_type( &mut self, return_type_id: u32, param_type_ids: Vec<u32>, ) -> u32
Declare a function type.
Sourcepub fn declare_int_constant(&mut self, type_id: u32, value: u64) -> u32
pub fn declare_int_constant(&mut self, type_id: u32, value: u64) -> u32
Declare an integer constant.
Sourcepub fn declare_float_constant(&mut self, type_id: u32, value: f32) -> u32
pub fn declare_float_constant(&mut self, type_id: u32, value: f32) -> u32
Declare a float constant.
Sourcepub fn declare_bool_constant(&mut self, type_id: u32, value: bool) -> u32
pub fn declare_bool_constant(&mut self, type_id: u32, value: bool) -> u32
Declare a bool constant.
Sourcepub fn declare_global_variable(
&mut self,
name: impl Into<String>,
type_id: u32,
storage_class: StorageClass,
decorations: Vec<Decoration>,
) -> u32
pub fn declare_global_variable( &mut self, name: impl Into<String>, type_id: u32, storage_class: StorageClass, decorations: Vec<Decoration>, ) -> u32
Declare a global variable.
Sourcepub fn begin_function(
&mut self,
name: impl Into<String>,
return_type_id: u32,
param_type_ids: Vec<u32>,
) -> SpirVFunction
pub fn begin_function( &mut self, name: impl Into<String>, return_type_id: u32, param_type_ids: Vec<u32>, ) -> SpirVFunction
Begin building a new function.
Sourcepub fn finish_function(&mut self, func: SpirVFunction)
pub fn finish_function(&mut self, func: SpirVFunction)
Finalize and add a function to the module.
Sourcepub fn emit_binary_header(&self) -> Vec<u32>
pub fn emit_binary_header(&self) -> Vec<u32>
Emit a minimal valid SPIR-V binary header (magic + version + generator + bound + schema).
Sourcepub fn function_count(&self) -> usize
pub fn function_count(&self) -> usize
Get the number of functions in the module.
Sourcepub fn lookup_symbol(&self, name: &str) -> Option<u32>
pub fn lookup_symbol(&self, name: &str) -> Option<u32>
Look up a symbol by name.