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

Function insert_inst

cranelift/codegen/src/ir/layout.rs:1062–1094  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1060
1061 #[test]
1062 fn insert_inst() {
1063 let mut layout = Layout::new();
1064 let e1 = Block::new(1);
1065
1066 layout.append_block(e1);
1067 let v: Vec<Inst> = layout.block_insts(e1).collect();
1068 assert_eq!(v, []);
1069
1070 let i0 = Inst::new(0);
1071 let i1 = Inst::new(1);
1072 let i2 = Inst::new(2);
1073
1074 assert_eq!(layout.inst_block(i0), None);
1075 assert_eq!(layout.inst_block(i1), None);
1076 assert_eq!(layout.inst_block(i2), None);
1077
1078 layout.append_inst(i1, e1);
1079 assert_eq!(layout.inst_block(i0), None);
1080 assert_eq!(layout.inst_block(i1), Some(e1));
1081 assert_eq!(layout.inst_block(i2), None);
1082 let v: Vec<Inst> = layout.block_insts(e1).collect();
1083 assert_eq!(v, [i1]);
1084
1085 layout.insert_inst(i2, i1);
1086 assert_eq!(layout.inst_block(i0), None);
1087 assert_eq!(layout.inst_block(i1), Some(e1));
1088 assert_eq!(layout.inst_block(i2), Some(e1));
1089 let v: Vec<Inst> = layout.block_insts(e1).collect();
1090 assert_eq!(v, [i2, i1]);
1091
1092 layout.insert_inst(i0, i1);
1093 verify(&mut layout, &[(e1, &[i2, i0, i1])]);
1094 }
1095
1096 #[test]
1097 fn multiple_blocks() {

Callers

nothing calls this directly

Calls 7

append_blockMethod · 0.80
collectMethod · 0.80
block_instsMethod · 0.80
append_instMethod · 0.80
verifyFunction · 0.70
newFunction · 0.50
insert_instMethod · 0.45

Tested by

no test coverage detected