Struct rspirv::dr::Module

source ·
pub struct Module {
Show 13 fields pub header: Option<ModuleHeader>, pub capabilities: Vec<Instruction>, pub extensions: Vec<Instruction>, pub ext_inst_imports: Vec<Instruction>, pub memory_model: Option<Instruction>, pub entry_points: Vec<Instruction>, pub execution_modes: Vec<Instruction>, pub debug_string_source: Vec<Instruction>, pub debug_names: Vec<Instruction>, pub debug_module_processed: Vec<Instruction>, pub annotations: Vec<Instruction>, pub types_global_values: Vec<Instruction>, pub functions: Vec<Function>,
}
Expand description

Data representation of a SPIR-V module.

Most of the fields are just vectors of Instructions, but some fields store values decomposed from Instructions for better investigation.

The order of its fields basically reveal the requirements in the Logical Layout of a Module of the SPIR-V of the SPIR-V specification.

Fields§

§header: Option<ModuleHeader>

The module header.

§capabilities: Vec<Instruction>

All OpCapability instructions.

§extensions: Vec<Instruction>

All OpExtension instructions.

§ext_inst_imports: Vec<Instruction>

All OpExtInstImport instructions.

§memory_model: Option<Instruction>

The OpMemoryModel instruction.

Although it is required by the specification to appear exactly once per module, we keep it optional here to allow flexibility.

§entry_points: Vec<Instruction>

All entry point declarations, using OpEntryPoint.

§execution_modes: Vec<Instruction>

All execution mode declarations, using OpExecutionMode.

§debug_string_source: Vec<Instruction>

Debug subsection: All OpString, OpSourceExtension, OpSource, and OpSourceContinued.

§debug_names: Vec<Instruction>

Debug subsection: All OpName and all OpMemberName.

§debug_module_processed: Vec<Instruction>

Debug subsection: All OpModuleProcessed instructions.

§annotations: Vec<Instruction>

All annotation instructions.

§types_global_values: Vec<Instruction>

All types, constants, and global variables.

As per the specification, they have to be bundled together because they can depend on one another.

§functions: Vec<Function>

All functions.

Implementations§

source§

impl Module

source

pub fn new() -> Self

Creates a new empty Module instance.

source

pub fn global_inst_iter(&self) -> impl Iterator<Item = &Instruction>

Returns an iterator over all global instructions.

source

pub fn global_inst_iter_mut(&mut self) -> impl Iterator<Item = &mut Instruction>

Returns a mut iterator over all global instructions.

source

pub fn all_inst_iter(&self) -> impl Iterator<Item = &Instruction>

Returns a iterator over all instructions.

source

pub fn all_inst_iter_mut(&mut self) -> impl Iterator<Item = &mut Instruction>

Returns a mut iterator over all instructions.

Trait Implementations§

source§

impl Assemble for Module

source§

fn assemble_into(&self, result: &mut Vec<u32>)

Assembles the current object into the result vector, reducing the need for lots of allocations
source§

fn assemble(&self) -> Vec<u32>

Assembles the current object and returns the binary code. Helper method to remain backwards compatible, calls assemble_into
source§

impl Clone for Module

source§

fn clone(&self) -> Module

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Module

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Module

source§

fn default() -> Module

Returns the “default value” for a type. Read more
source§

impl Disassemble for Module

source§

fn disassemble(&self) -> String

Disassembles this module and returns the disassembly text.

This method will try to link information together to be wise. E.g., If the extended instruction set is recognized, the symbolic opcode for instructions in it will be shown.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.