MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / replace_block_param

Method replace_block_param

cranelift/codegen/src/ir/dfg.rs:1367–1385  ·  view source on GitHub ↗

Replace a block parameter with a new value of type `ty`. The `old_value` must be an attached block parameter. It is removed from its place in the list of parameters and replaced by a new value of type `new_type`. The new value gets the same position in the list, and other parameters are not disturbed. The old value is left detached, so it should probably be changed into something else. Returns

(&mut self, old_value: Value, new_type: Type)

Source from the content-addressed store, hash-verified

1365 ///
1366 /// Returns the new value.
1367 pub fn replace_block_param(&mut self, old_value: Value, new_type: Type) -> Value {
1368 // Create new value identical to the old one except for the type.
1369 let (block, num) =
1370 if let ValueData::Param { num, block, .. } = ValueData::from(self.values[old_value]) {
1371 (block, num)
1372 } else {
1373 panic!("{old_value} must be a block parameter");
1374 };
1375 let new_arg = self.make_value(ValueData::Param {
1376 ty: new_type,
1377 num,
1378 block,
1379 });
1380
1381 self.blocks[block]
1382 .params
1383 .as_mut_slice(&mut self.value_lists)[num as usize] = new_arg;
1384 new_arg
1385 }
1386
1387 /// Detach all the parameters from `block` and return them as a `ValueList`.
1388 ///

Callers 1

replace_block_paramsFunction · 0.80

Calls 3

fromFunction · 0.85
make_valueMethod · 0.80
as_mut_sliceMethod · 0.45

Tested by 1

replace_block_paramsFunction · 0.64