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

Function write_operands

cranelift/codegen/src/write.rs:390–568  ·  view source on GitHub ↗

Write the operands of `inst` to `w` with a prepended space.

(w: &mut dyn Write, dfg: &DataFlowGraph, inst: Inst)

Source from the content-addressed store, hash-verified

388
389/// Write the operands of `inst` to `w` with a prepended space.
390pub fn write_operands(w: &mut dyn Write, dfg: &DataFlowGraph, inst: Inst) -> fmt::Result {
391 let pool = &dfg.value_lists;
392 let jump_tables = &dfg.jump_tables;
393 let exception_tables = &dfg.exception_tables;
394 use crate::ir::instructions::InstructionData::*;
395 let ctrl_ty = dfg.ctrl_typevar(inst);
396 match dfg.insts[inst] {
397 AtomicRmw { op, args, .. } => write!(w, " {} {}, {}", op, args[0], args[1]),
398 AtomicCas { args, .. } => write!(w, " {}, {}, {}", args[0], args[1], args[2]),
399 LoadNoOffset { flags, arg, .. } => write!(w, "{} {arg}", dfg.mem_flags[flags]),
400 StoreNoOffset { flags, args, .. } => {
401 write!(w, "{} {}, {}", dfg.mem_flags[flags], args[0], args[1])
402 }
403 Unary { arg, .. } => write!(w, " {arg}"),
404 UnaryImm { imm, .. } => write!(w, " {}", {
405 let mut imm = imm;
406 if ctrl_ty.bits() != 0 {
407 imm = imm.sign_extend_from_width(ctrl_ty.bits());
408 }
409 imm
410 }),
411 UnaryIeee16 { imm, .. } => write!(w, " {imm}"),
412 UnaryIeee32 { imm, .. } => write!(w, " {imm}"),
413 UnaryIeee64 { imm, .. } => write!(w, " {imm}"),
414 UnaryGlobalValue { global_value, .. } => write!(w, " {global_value}"),
415 UnaryConst {
416 constant_handle, ..
417 } => write!(w, " {constant_handle}"),
418 Binary { args, .. } => write!(w, " {}, {}", args[0], args[1]),
419 BinaryImm8 { arg, imm, .. } => write!(w, " {arg}, {imm}"),
420 Ternary { args, .. } => write!(w, " {}, {}, {}", args[0], args[1], args[2]),
421 MultiAry { ref args, .. } => {
422 if args.is_empty() {
423 write!(w, "")
424 } else {
425 write!(w, " {}", DisplayValues(args.as_slice(pool)))
426 }
427 }
428 NullAry { .. } => write!(w, " "),
429 TernaryImm8 { imm, args, .. } => write!(w, " {}, {}, {}", args[0], args[1], imm),
430 Shuffle { imm, args, .. } => {
431 let data = dfg.immediates.get(imm).expect(
432 "Expected the shuffle mask to already be inserted into the immediates table",
433 );
434 write!(w, " {}, {}, {}", args[0], args[1], data)
435 }
436 IntCompare { cond, args, .. } => write!(w, " {} {}, {}", cond, args[0], args[1]),
437 IntAddTrap { args, code, .. } => write!(w, " {}, {}, {}", args[0], args[1], code),
438 FloatCompare { cond, args, .. } => write!(w, " {} {}, {}", cond, args[0], args[1]),
439 Jump { destination, .. } => {
440 write!(w, " {}", destination.display(pool))
441 }
442 Brif {
443 arg,
444 blocks: [block_then, block_else],
445 ..
446 } => {
447 write!(w, " {}, {}", arg, block_then.display(pool))?;

Callers 2

write_instructionFunction · 0.85
fmtMethod · 0.85

Calls 12

OkFunction · 0.85
ctrl_typevarMethod · 0.80
inst_valuesMethod · 0.80
value_defMethod · 0.80
is_emptyMethod · 0.45
expectMethod · 0.45
getMethod · 0.45
as_sliceMethod · 0.45
bitsMethod · 0.45
to_stringMethod · 0.45

Tested by

no test coverage detected