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

Function insert_shuffle

cranelift/fuzzgen/src/function_generator.rs:393–424  ·  view source on GitHub ↗
(
    fgen: &mut FunctionGenerator,
    builder: &mut FunctionBuilder,
    opcode: Opcode,
    _: &[Type],
    rets: &[Type],
)

Source from the content-addressed store, hash-verified

391}
392
393fn insert_shuffle(
394 fgen: &mut FunctionGenerator,
395 builder: &mut FunctionBuilder,
396 opcode: Opcode,
397 _: &[Type],
398 rets: &[Type],
399) -> Result<()> {
400 let ctrl_type = *rets.first().unwrap();
401
402 let lhs = builder.use_var(fgen.get_variable_of_type(ctrl_type)?);
403 let rhs = builder.use_var(fgen.get_variable_of_type(ctrl_type)?);
404
405 let mask = {
406 let mut lanes = [0u8; 16];
407 for lane in lanes.iter_mut() {
408 *lane = fgen.u.int_in_range(0..=31)?;
409 }
410 let lanes = ConstantData::from(lanes.as_ref());
411 builder.func.dfg.immediates.push(lanes)
412 };
413
414 // This function is called for any `InstructionFormat::Shuffle`. Which today is just
415 // `shuffle`, but lets assert that, just to be sure we don't accidentally insert
416 // something else.
417 assert_eq!(opcode, Opcode::Shuffle);
418 let res = builder.ins().shuffle(lhs, rhs, mask);
419
420 let target_var = fgen.get_variable_of_type(ctrl_type)?;
421 builder.def_var(target_var, res);
422
423 Ok(())
424}
425
426fn insert_ins_ext_lane(
427 fgen: &mut FunctionGenerator,

Callers

nothing calls this directly

Calls 12

fromFunction · 0.85
OkFunction · 0.85
get_variable_of_typeMethod · 0.80
unwrapMethod · 0.45
firstMethod · 0.45
use_varMethod · 0.45
iter_mutMethod · 0.45
as_refMethod · 0.45
pushMethod · 0.45
shuffleMethod · 0.45
insMethod · 0.45
def_varMethod · 0.45

Tested by

no test coverage detected