Returns a label that can be used to refer to the `constant` provided. This will automatically defer a new constant to be emitted for `constant` if it has not been previously emitted. Note that this function may return a different label for the same constant at different points in time. The label is valid to use only from the current location; the MachBuffer takes care to emit the same constant mu
(&mut self, constant: VCodeConstant)
| 702 | /// current location; the MachBuffer takes care to emit the same constant |
| 703 | /// multiple times if needed so the constant is always in range. |
| 704 | pub fn get_label_for_constant(&mut self, constant: VCodeConstant) -> MachLabel { |
| 705 | let MachBufferConstant { |
| 706 | align, |
| 707 | size, |
| 708 | upcoming_label, |
| 709 | } = self.constants[constant]; |
| 710 | if let Some(label) = upcoming_label { |
| 711 | return label; |
| 712 | } |
| 713 | |
| 714 | let label = self.get_label(); |
| 715 | trace!( |
| 716 | "defer constant: eventually emit {size} bytes aligned \ |
| 717 | to {align} at label {label:?}", |
| 718 | ); |
| 719 | self.pending_constants.push(constant); |
| 720 | self.pending_constants_size += size as u32; |
| 721 | self.constants[constant].upcoming_label = Some(label); |
| 722 | label |
| 723 | } |
| 724 | |
| 725 | /// Bind a label to the current offset. A label can only be bound once. |
| 726 | pub fn bind_label(&mut self, label: MachLabel, ctrl_plane: &mut ControlPlane) { |