()
| 337 | |
| 338 | #[test] |
| 339 | fn reuse_results() { |
| 340 | let mut func = Function::new(); |
| 341 | let block0 = func.dfg.make_block(); |
| 342 | let arg0 = func.dfg.append_block_param(block0, I32); |
| 343 | let mut pos = FuncCursor::new(&mut func); |
| 344 | pos.insert_block(block0); |
| 345 | |
| 346 | let v0 = pos.ins().iadd_imm(arg0, 17); |
| 347 | assert_eq!(pos.func.dfg.value_type(v0), I32); |
| 348 | let iadd = pos.prev_inst().unwrap(); |
| 349 | assert_eq!(pos.func.dfg.value_def(v0), ValueDef::Result(iadd, 0)); |
| 350 | |
| 351 | // Detach v0 and reuse it for a different instruction. |
| 352 | pos.func.dfg.clear_results(iadd); |
| 353 | let v0b = pos.ins().with_result(v0).iconst(I32, 3); |
| 354 | assert_eq!(v0, v0b); |
| 355 | assert_eq!(pos.current_inst(), Some(iadd)); |
| 356 | let iconst = pos.prev_inst().unwrap(); |
| 357 | assert!(iadd != iconst); |
| 358 | assert_eq!(pos.func.dfg.value_def(v0), ValueDef::Result(iconst, 0)); |
| 359 | } |
| 360 | |
| 361 | #[test] |
| 362 | fn replace_with_imm_method() { |
nothing calls this directly
no test coverage detected