()
| 2735 | |
| 2736 | #[test] |
| 2737 | fn test_island_backward() { |
| 2738 | let info = emit_info(); |
| 2739 | let mut buf = MachBuffer::new(); |
| 2740 | let mut state = <Inst as MachInstEmit>::State::default(); |
| 2741 | let constants = Default::default(); |
| 2742 | |
| 2743 | buf.reserve_labels_for_blocks(4); |
| 2744 | |
| 2745 | buf.bind_label(label(0), state.ctrl_plane_mut()); |
| 2746 | let inst = Inst::Nop4; |
| 2747 | inst.emit(&mut buf, &info, &mut state); |
| 2748 | |
| 2749 | buf.bind_label(label(1), state.ctrl_plane_mut()); |
| 2750 | let inst = Inst::Nop4; |
| 2751 | inst.emit(&mut buf, &info, &mut state); |
| 2752 | |
| 2753 | buf.bind_label(label(2), state.ctrl_plane_mut()); |
| 2754 | while buf.cur_offset() < 2000000 { |
| 2755 | let inst = Inst::Nop4; |
| 2756 | inst.emit(&mut buf, &info, &mut state); |
| 2757 | } |
| 2758 | |
| 2759 | buf.bind_label(label(3), state.ctrl_plane_mut()); |
| 2760 | let inst = Inst::CondBr { |
| 2761 | kind: CondBrKind::NotZero(xreg(0), OperandSize::Size64), |
| 2762 | taken: target(0), |
| 2763 | not_taken: target(1), |
| 2764 | }; |
| 2765 | inst.emit(&mut buf, &info, &mut state); |
| 2766 | |
| 2767 | let buf = buf.finish(&constants, state.ctrl_plane_mut()); |
| 2768 | |
| 2769 | assert_eq!(2000000 + 12, buf.total_size()); |
| 2770 | |
| 2771 | let mut buf2 = MachBuffer::new(); |
| 2772 | let mut state = Default::default(); |
| 2773 | let inst = Inst::CondBr { |
| 2774 | kind: CondBrKind::NotZero(xreg(0), OperandSize::Size64), |
| 2775 | taken: BranchTarget::ResolvedOffset(8), |
| 2776 | not_taken: BranchTarget::ResolvedOffset(4 - (2000000 + 4)), |
| 2777 | }; |
| 2778 | inst.emit(&mut buf2, &info, &mut state); |
| 2779 | let inst = Inst::Jump { |
| 2780 | dest: BranchTarget::ResolvedOffset(-(2000000 + 8)), |
| 2781 | }; |
| 2782 | inst.emit(&mut buf2, &info, &mut state); |
| 2783 | |
| 2784 | let buf2 = buf2.finish(&constants, state.ctrl_plane_mut()); |
| 2785 | |
| 2786 | assert_eq!(&buf.data[2000000..], &buf2.data[..]); |
| 2787 | } |
| 2788 | |
| 2789 | #[test] |
| 2790 | fn test_multiple_redirect() { |
nothing calls this directly
no test coverage detected