Given an ID, check if it's defined by an OpAccessChain, and if it is, return its ptr/indices
(&self, id: spirv::Word)
| 100 | |
| 101 | // Given an ID, check if it's defined by an OpAccessChain, and if it is, return its ptr/indices |
| 102 | fn find_access_chain(&self, id: spirv::Word) -> Option<(spirv::Word, Vec<spirv::Word>)> { |
| 103 | let emit = self.emit(); |
| 104 | let module = emit.module_ref(); |
| 105 | let func = &module.functions[emit.selected_function().unwrap()]; |
| 106 | let ptr_def_inst = func.all_inst_iter().find(|inst| inst.result_id == Some(id)); |
| 107 | if let Some(ptr_def_inst) = ptr_def_inst { |
| 108 | if ptr_def_inst.class.opcode == spirv::Op::AccessChain |
| 109 | || ptr_def_inst.class.opcode == spirv::Op::InBoundsAccessChain |
| 110 | { |
| 111 | let ptr = ptr_def_inst.operands[0].unwrap_id_ref(); |
| 112 | let indices = ptr_def_inst.operands[1..] |
| 113 | .iter() |
| 114 | .map(|op| op.unwrap_id_ref()) |
| 115 | .collect::<Vec<spirv::Word>>(); |
| 116 | return Some((ptr, indices)); |
| 117 | } |
| 118 | } |
| 119 | None |
| 120 | } |
| 121 | |
| 122 | pub fn gep_help( |
| 123 | &mut self, |