| 182 | } |
| 183 | |
| 184 | fn emit_access_chain( |
| 185 | &self, |
| 186 | result_type: spirv::Word, |
| 187 | pointer: spirv::Word, |
| 188 | base: SpirvValue, |
| 189 | indices: Vec<spirv::Word>, |
| 190 | is_inbounds: bool, |
| 191 | ) -> SpirvValue { |
| 192 | let mut emit = self.emit(); |
| 193 | if self.builder.lookup_const_u64(base) == Some(0) { |
| 194 | if is_inbounds { |
| 195 | emit.in_bounds_access_chain(result_type, None, pointer, indices) |
| 196 | } else { |
| 197 | emit.access_chain(result_type, None, pointer, indices) |
| 198 | } |
| 199 | .unwrap() |
| 200 | .with_type(result_type) |
| 201 | } else { |
| 202 | let result = if is_inbounds { |
| 203 | emit.in_bounds_ptr_access_chain(result_type, None, pointer, base.def(self), indices) |
| 204 | } else { |
| 205 | emit.ptr_access_chain(result_type, None, pointer, base.def(self), indices) |
| 206 | } |
| 207 | .unwrap() |
| 208 | .with_type(result_type); |
| 209 | self.zombie( |
| 210 | result.def(self), |
| 211 | "cannot offset a pointer to an arbitrary element", |
| 212 | ); |
| 213 | result |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | // TODO: Definitely add tests to make sure this impl is right. |
| 218 | fn rotate(&mut self, value: SpirvValue, shift: SpirvValue, is_left: bool) -> SpirvValue { |