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

Method alloc_instance_id

crates/rustc_codegen_spirv/src/linker/specializer.rs:2265–2279  ·  view source on GitHub ↗

Allocate a new ID for `instance`, or return a cached one if it exists. If a new ID is created, `instance` is added to `propagate_instances_queue`, so that `propagate_instances` can later find all transitive dependencies.

(&mut self, instance: Instance<SmallVec<[CopyOperand; 4]>>)

Source from the content-addressed store, hash-verified

2263 /// If a new ID is created, `instance` is added to `propagate_instances_queue`,
2264 /// so that `propagate_instances` can later find all transitive dependencies.
2265 fn alloc_instance_id(&mut self, instance: Instance<SmallVec<[CopyOperand; 4]>>) -> Word {
2266 use std::collections::btree_map::Entry;
2267
2268 match self.instances.entry(instance) {
2269 Entry::Occupied(entry) => *entry.get(),
2270 Entry::Vacant(entry) => {
2271 // Get the `Instance` back from the map key, to avoid having to
2272 // clone it earlier when calling `self.instances.entry(instance)`.
2273 let instance = entry.key().clone();
2274
2275 self.propagate_instances_queue.push_back(instance);
2276 *entry.insert(self.builder.id())
2277 }
2278 }
2279 }
2280
2281 /// Process all instances seen (by `alloc_instance_id`) up until this point,
2282 /// to find the full set of instances (transitively) needed by the module.

Callers 2

specializeFunction · 0.80
propagate_instancesMethod · 0.80

Calls 3

insertMethod · 0.80
idMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected