(
&mut self,
id_map: &mut FxHashMap<&str, Word>,
defined_ids: &mut FxHashSet<Word>,
asm_block: &mut AsmBlock,
inst: dr::Instruction,
)
| 262 | } |
| 263 | |
| 264 | fn insert_inst( |
| 265 | &mut self, |
| 266 | id_map: &mut FxHashMap<&str, Word>, |
| 267 | defined_ids: &mut FxHashSet<Word>, |
| 268 | asm_block: &mut AsmBlock, |
| 269 | inst: dr::Instruction, |
| 270 | ) { |
| 271 | // Types declared must be registered in our type system. |
| 272 | let new_result_id = match inst.class.opcode { |
| 273 | Op::TypeVoid => SpirvType::Void.def(self.span(), self), |
| 274 | Op::TypeBool => SpirvType::Bool.def(self.span(), self), |
| 275 | Op::TypeInt => SpirvType::Integer( |
| 276 | inst.operands[0].unwrap_literal_int32(), |
| 277 | inst.operands[1].unwrap_literal_int32() != 0, |
| 278 | ) |
| 279 | .def(self.span(), self), |
| 280 | Op::TypeFloat => { |
| 281 | SpirvType::Float(inst.operands[0].unwrap_literal_int32()).def(self.span(), self) |
| 282 | } |
| 283 | Op::TypeStruct => { |
| 284 | self.err("OpTypeStruct in asm! is not supported yet"); |
| 285 | return; |
| 286 | } |
| 287 | Op::TypeVector => SpirvType::Vector { |
| 288 | element: inst.operands[0].unwrap_id_ref(), |
| 289 | count: inst.operands[1].unwrap_literal_int32(), |
| 290 | } |
| 291 | .def(self.span(), self), |
| 292 | Op::TypeMatrix => SpirvType::Matrix { |
| 293 | element: inst.operands[0].unwrap_id_ref(), |
| 294 | count: inst.operands[1].unwrap_literal_int32(), |
| 295 | } |
| 296 | .def(self.span(), self), |
| 297 | Op::TypeArray => { |
| 298 | self.err("OpTypeArray in asm! is not supported yet"); |
| 299 | return; |
| 300 | } |
| 301 | Op::TypeRuntimeArray => SpirvType::RuntimeArray { |
| 302 | element: inst.operands[0].unwrap_id_ref(), |
| 303 | } |
| 304 | .def(self.span(), self), |
| 305 | Op::TypePointer => { |
| 306 | let storage_class = inst.operands[0].unwrap_storage_class(); |
| 307 | if storage_class != StorageClass::Generic { |
| 308 | self.struct_err("TypePointer in asm! requires `Generic` storage class") |
| 309 | .note(format!( |
| 310 | "`{storage_class:?}` storage class was specified" |
| 311 | )) |
| 312 | .help(format!( |
| 313 | "the storage class will be inferred automatically (e.g. to `{storage_class:?}`)" |
| 314 | )) |
| 315 | .emit(); |
| 316 | } |
| 317 | SpirvType::Pointer { |
| 318 | pointee: inst.operands[1].unwrap_id_ref(), |
| 319 | } |
| 320 | .def(self.span(), self) |
| 321 | } |
no test coverage detected