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

Function apply_rewrite_rules

crates/rustc_codegen_spirv/src/linker/mod.rs:88–118  ·  view source on GitHub ↗
(rewrite_rules: &FxHashMap<Word, Word>, blocks: &mut [Block])

Source from the content-addressed store, hash-verified

86}
87
88fn apply_rewrite_rules(rewrite_rules: &FxHashMap<Word, Word>, blocks: &mut [Block]) {
89 let apply = |inst: &mut Instruction| {
90 if let Some(ref mut id) = &mut inst.result_id {
91 if let Some(&rewrite) = rewrite_rules.get(id) {
92 *id = rewrite;
93 }
94 }
95
96 if let Some(ref mut id) = &mut inst.result_type {
97 if let Some(&rewrite) = rewrite_rules.get(id) {
98 *id = rewrite;
99 }
100 }
101
102 inst.operands.iter_mut().for_each(|op| {
103 if let Some(id) = op.id_ref_any_mut() {
104 if let Some(&rewrite) = rewrite_rules.get(id) {
105 *id = rewrite;
106 }
107 }
108 });
109 };
110 for block in blocks {
111 for inst in &mut block.label {
112 apply(inst);
113 }
114 for inst in &mut block.instructions {
115 apply(inst);
116 }
117 }
118}
119
120fn get_names(module: &Module) -> FxHashMap<Word, &str> {
121 let entry_names = module

Callers 5

insert_phis_allFunction · 0.85
destructure_compositesFunction · 0.85
inline_blockMethod · 0.85
expand_moduleMethod · 0.85
bool_fusionFunction · 0.85

Calls 1

getMethod · 0.45

Tested by 1

expand_moduleMethod · 0.68