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

Method get_label_for_constant

cranelift/codegen/src/machinst/buffer.rs:704–723  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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) {

Callers 8

mem_emitFunction · 0.80
finalizeMethod · 0.80
use_targetMethod · 0.80
emit_uncompressedMethod · 0.80
get_label_with_sinkMethod · 0.80
mem_finalizeFunction · 0.80

Calls 2

get_labelMethod · 0.45
pushMethod · 0.45

Tested by 2