Emit a reference to the given label with the given reference type (i.e., branch-instruction format) at the current offset. This is like a relocation, but handled internally. This can be called before the branch is actually emitted; fixups will not happen until an island is emitted or the buffer is finished.
(&mut self, offset: CodeOffset, label: MachLabel, kind: I::LabelUse)
| 787 | /// This can be called before the branch is actually emitted; fixups will |
| 788 | /// not happen until an island is emitted or the buffer is finished. |
| 789 | pub fn use_label_at_offset(&mut self, offset: CodeOffset, label: MachLabel, kind: I::LabelUse) { |
| 790 | trace!( |
| 791 | "MachBuffer: use_label_at_offset: offset {} label {:?} kind {:?}", |
| 792 | offset, label, kind |
| 793 | ); |
| 794 | |
| 795 | // Add the fixup, and update the worst-case island size based on a |
| 796 | // veneer for this label use. |
| 797 | let fixup = MachLabelFixup { |
| 798 | label, |
| 799 | offset, |
| 800 | kind, |
| 801 | }; |
| 802 | self.pending_fixup_deadline = self |
| 803 | .pending_fixup_deadline |
| 804 | // Subtract one alignment here to the deadline to account for |
| 805 | // extra space taken by aligning an island. |
| 806 | .min(fixup.deadline() - I::LabelUse::ALIGN); |
| 807 | trace!("pending_fixup_deadline = {}", self.pending_fixup_deadline); |
| 808 | self.pending_fixup_records.push(fixup); |
| 809 | |
| 810 | // Post-invariant: no mutations to branches/labels data structures. |
| 811 | } |
| 812 | |
| 813 | /// Inform the buffer of an unconditional branch at the given offset, |
| 814 | /// targeting the given label. May be used to optimize branches. |