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

Function block

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

Source from the content-addressed store, hash-verified

1658
1659 #[test]
1660 fn block() {
1661 let mut dfg = DataFlowGraph::new();
1662
1663 let block = dfg.make_block();
1664 assert_eq!(block.to_string(), "block0");
1665 assert_eq!(dfg.num_block_params(block), 0);
1666 assert_eq!(dfg.block_params(block), &[]);
1667 assert!(dfg.detach_block_params(block).is_empty());
1668 assert_eq!(dfg.num_block_params(block), 0);
1669 assert_eq!(dfg.block_params(block), &[]);
1670
1671 let arg1 = dfg.append_block_param(block, types::F32);
1672 assert_eq!(arg1.to_string(), "v0");
1673 assert_eq!(dfg.num_block_params(block), 1);
1674 assert_eq!(dfg.block_params(block), &[arg1]);
1675
1676 let arg2 = dfg.append_block_param(block, types::I16);
1677 assert_eq!(arg2.to_string(), "v1");
1678 assert_eq!(dfg.num_block_params(block), 2);
1679 assert_eq!(dfg.block_params(block), &[arg1, arg2]);
1680
1681 assert_eq!(dfg.value_def(arg1), ValueDef::Param(block, 0));
1682 assert_eq!(dfg.value_def(arg2), ValueDef::Param(block, 1));
1683 assert_eq!(dfg.value_type(arg1), types::F32);
1684 assert_eq!(dfg.value_type(arg2), types::I16);
1685
1686 // Swap the two block parameters.
1687 let vlist = dfg.detach_block_params(block);
1688 assert_eq!(dfg.num_block_params(block), 0);
1689 assert_eq!(dfg.block_params(block), &[]);
1690 assert_eq!(vlist.as_slice(&dfg.value_lists), &[arg1, arg2]);
1691 dfg.attach_block_param(block, arg2);
1692 let arg3 = dfg.append_block_param(block, types::I32);
1693 dfg.attach_block_param(block, arg1);
1694 assert_eq!(dfg.block_params(block), &[arg2, arg3, arg1]);
1695 }
1696
1697 #[test]
1698 fn replace_block_params() {

Callers 3

visit_blockMethod · 0.85
emit_bodyMethod · 0.85
blockMethod · 0.85

Calls 5

make_blockMethod · 0.80
detach_block_paramsMethod · 0.80
attach_block_paramMethod · 0.80
newFunction · 0.50
append_block_paramMethod · 0.45

Tested by

no test coverage detected