MCPcopy Create free account
hub / github.com/Rust-GPU/rust-gpu / collect

Method collect

crates/rustc_codegen_spirv/src/custom_decorations.rs:233–314  ·  view source on GitHub ↗
(module: Either<&'a Module, &'a spirt::Module>)

Source from the content-addressed store, hash-verified

231
232impl<'a> SpvDebugInfo<'a> {
233 fn collect(module: Either<&'a Module, &'a spirt::Module>) -> Self {
234 let mut this = Self::default();
235
236 let module = match module {
237 Either::Left(module) => module,
238
239 // HACK(eddyb) the SPIR-T codepath is simpler, and kind of silly,
240 // but we need the `SpvDebugFile`'s `regenerated_rustc_source_file`
241 // caching, so for now it reuses `SpvDebugInfo` overall.
242 Either::Right(module) => {
243 let cx = module.cx_ref();
244 match &module.debug_info {
245 spirt::ModuleDebugInfo::Spv(debug_info) => {
246 for sources in debug_info.source_languages.values() {
247 for (&file_name, src) in &sources.file_contents {
248 // FIXME(eddyb) what if the file is already present,
249 // should it be considered ambiguous overall?
250 this.files
251 .entry(&cx[file_name])
252 .or_default()
253 .op_source_parts = [&src[..]].into_iter().collect();
254 }
255 }
256 }
257 }
258 return this;
259 }
260 };
261
262 // FIXME(eddyb) avoid repeating this across different passes/helpers.
263 this.custom_ext_inst_set_import = module
264 .ext_inst_imports
265 .iter()
266 .find(|inst| {
267 assert_eq!(inst.class.opcode, Op::ExtInstImport);
268 inst.operands[0].unwrap_literal_string() == &custom_insts::CUSTOM_EXT_INST_SET[..]
269 })
270 .map(|inst| inst.result_id.unwrap());
271
272 this.id_to_op_constant_operand.extend(
273 module
274 .types_global_values
275 .iter()
276 .filter(|inst| inst.class.opcode == Op::Constant)
277 .map(|inst| (inst.result_id.unwrap(), &inst.operands[0])),
278 );
279
280 let mut insts = module.debug_string_source.iter().peekable();
281 while let Some(inst) = insts.next() {
282 match inst.class.opcode {
283 Op::String => {
284 this.id_to_op_string.insert(
285 inst.result_id.unwrap(),
286 inst.operands[0].unwrap_literal_string(),
287 );
288 }
289 Op::Source if inst.operands.len() == 4 => {
290 let file_name_id = inst.operands[2].unwrap_id_ref();

Callers 2

src_loc_for_idMethod · 0.45
zombie_for_idMethod · 0.45

Calls 5

into_iterMethod · 0.80
iterMethod · 0.80
insertMethod · 0.80
nextMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected