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

Function make_inst

cranelift/codegen/src/ir/dfg.rs:1607–1642  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1605
1606 #[test]
1607 fn make_inst() {
1608 let mut dfg = DataFlowGraph::new();
1609
1610 let idata = InstructionData::UnaryImm {
1611 opcode: Opcode::Iconst,
1612 imm: 0.into(),
1613 };
1614 let inst = dfg.make_inst(idata);
1615
1616 dfg.make_inst_results(inst, types::I32);
1617 assert_eq!(inst.to_string(), "inst0");
1618 assert_eq!(dfg.display_inst(inst).to_string(), "v0 = iconst.i32 0");
1619
1620 // Immutable reference resolution.
1621 {
1622 let immdfg = &dfg;
1623 let ins = &immdfg.insts[inst];
1624 assert_eq!(ins.opcode(), Opcode::Iconst);
1625 }
1626
1627 // Results.
1628 let val = dfg.first_result(inst);
1629 assert_eq!(dfg.inst_results(inst), &[val]);
1630
1631 assert_eq!(dfg.value_def(val), ValueDef::Result(inst, 0));
1632 assert_eq!(dfg.value_type(val), types::I32);
1633
1634 // Replacing results.
1635 assert!(dfg.value_is_attached(val));
1636 let v2 = dfg.replace_result(val, types::F64);
1637 assert!(!dfg.value_is_attached(val));
1638 assert!(dfg.value_is_attached(v2));
1639 assert_eq!(dfg.inst_results(inst), &[v2]);
1640 assert_eq!(dfg.value_def(v2), ValueDef::Result(inst, 0));
1641 assert_eq!(dfg.value_type(v2), types::F64);
1642 }
1643
1644 #[test]
1645 fn no_results() {

Callers

nothing calls this directly

Calls 5

make_instMethod · 0.80
make_inst_resultsMethod · 0.80
first_resultMethod · 0.80
replace_resultMethod · 0.80
newFunction · 0.50

Tested by

no test coverage detected