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

Function test_flip_cond

cranelift/codegen/src/machinst/buffer.rs:2622–2665  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2620
2621 #[test]
2622 fn test_flip_cond() {
2623 let info = emit_info();
2624 let mut buf = MachBuffer::new();
2625 let mut state = <Inst as MachInstEmit>::State::default();
2626 let constants = Default::default();
2627
2628 buf.reserve_labels_for_blocks(4);
2629
2630 buf.bind_label(label(0), state.ctrl_plane_mut());
2631 let inst = Inst::CondBr {
2632 kind: CondBrKind::Zero(xreg(0), OperandSize::Size64),
2633 taken: target(1),
2634 not_taken: target(2),
2635 };
2636 inst.emit(&mut buf, &info, &mut state);
2637
2638 buf.bind_label(label(1), state.ctrl_plane_mut());
2639 let inst = Inst::Nop4;
2640 inst.emit(&mut buf, &info, &mut state);
2641
2642 buf.bind_label(label(2), state.ctrl_plane_mut());
2643 let inst = Inst::Udf {
2644 trap_code: TrapCode::STACK_OVERFLOW,
2645 };
2646 inst.emit(&mut buf, &info, &mut state);
2647
2648 buf.bind_label(label(3), state.ctrl_plane_mut());
2649
2650 let buf = buf.finish(&constants, state.ctrl_plane_mut());
2651
2652 let mut buf2 = MachBuffer::new();
2653 let mut state = Default::default();
2654 let inst = Inst::TrapIf {
2655 kind: CondBrKind::NotZero(xreg(0), OperandSize::Size64),
2656 trap_code: TrapCode::STACK_OVERFLOW,
2657 };
2658 inst.emit(&mut buf2, &info, &mut state);
2659 let inst = Inst::Nop4;
2660 inst.emit(&mut buf2, &info, &mut state);
2661
2662 let buf2 = buf2.finish(&constants, state.ctrl_plane_mut());
2663
2664 assert_eq!(buf.data, buf2.data);
2665 }
2666
2667 #[test]
2668 fn test_island() {

Callers

nothing calls this directly

Calls 11

emit_infoFunction · 0.85
labelFunction · 0.85
ZeroEnum · 0.85
bind_labelMethod · 0.80
targetFunction · 0.70
newFunction · 0.50
xregFunction · 0.50
ctrl_plane_mutMethod · 0.45
emitMethod · 0.45
finishMethod · 0.45

Tested by

no test coverage detected