Trait cranelift_codegen::machinst::MachInstLabelUse [−][src]
A descriptor of a label reference (use) in an instruction set.
Associated Constants
const ALIGN: CodeOffset
[src]
Required alignment for any veneer. Usually the required instruction alignment (e.g., 4 for a RISC with 32-bit instructions, or 1 for x86).
Required methods
fn max_pos_range(self) -> CodeOffset
[src]
What is the maximum PC-relative range (positive)? E.g., if 1024
, a
label-reference fixup at offset x
is valid if the label resolves to x + 1024
.
fn max_neg_range(self) -> CodeOffset
[src]
What is the maximum PC-relative range (negative)? This is the absolute
value; i.e., if 1024
, then a label-reference fixup at offset x
is
valid if the label resolves to x - 1024
.
fn patch_size(self) -> CodeOffset
[src]
What is the size of code-buffer slice this label-use needs to patch in the label’s value?
fn patch(
self,
buffer: &mut [u8],
use_offset: CodeOffset,
label_offset: CodeOffset
)
[src]
self,
buffer: &mut [u8],
use_offset: CodeOffset,
label_offset: CodeOffset
)
Perform a code-patch, given the offset into the buffer of this label use
and the offset into the buffer of the label’s definition.
It is guaranteed that, given delta = offset - label_offset
, we will
have offset >= -self.max_neg_range()
and offset <= self.max_pos_range()
.
fn supports_veneer(self) -> bool
[src]
Can the label-use be patched to a veneer that supports a longer range? Usually valid for jumps (a short-range jump can jump to a longer-range jump), but not for e.g. constant pool references, because the constant load would require different code (one more level of indirection).
fn veneer_size(self) -> CodeOffset
[src]
How many bytes are needed for a veneer?
fn generate_veneer(
self,
buffer: &mut [u8],
veneer_offset: CodeOffset
) -> (CodeOffset, Self)
[src]
self,
buffer: &mut [u8],
veneer_offset: CodeOffset
) -> (CodeOffset, Self)
Generate a veneer. The given code-buffer slice is self.veneer_size()
bytes long at offset veneer_offset
in the buffer. The original
label-use will be patched to refer to this veneer’s offset. A new
(offset, LabelUse) is returned that allows the veneer to use the actual
label. For veneers to work properly, it is expected that the new veneer
has a larger range; on most platforms this probably means either a
“long-range jump” (e.g., on ARM, the 26-bit form), or if already at that
stage, a jump that supports a full 32-bit range, for example.