pub struct Emitter<'a> { /* private fields */ }Expand description
Emits QCode before a site’s anchor, on the hook’s behalf.
Values are ValueIds: literals from constant,
operands of the anchor from store_operands and
friends, or the results of arithmetic emitted here. Everything emitted
stays before the anchor, in emission order.
Implementations§
Source§impl<'a> Emitter<'a>
impl<'a> Emitter<'a>
pub fn new(ctx: &'a mut Context<'static>, site: &Site) -> Self
pub fn ctx(&self) -> &Context<'static>
Sourcepub fn store_operands(&self) -> Option<(ValueId, usize, ValueId)>
pub fn store_operands(&self) -> Option<(ValueId, usize, ValueId)>
The anchor’s store operands: pointer, width and stored value, if the anchor is a store.
Sourcepub fn load_operands(&self) -> Option<(ValueId, usize)>
pub fn load_operands(&self) -> Option<(ValueId, usize)>
The anchor’s load operands: pointer and width, if the anchor is a load.
Sourcepub fn binop_operands(&self) -> Option<(Binop, ValueId, ValueId)>
pub fn binop_operands(&self) -> Option<(Binop, ValueId, ValueId)>
The anchor’s binary operands, if the anchor is a binary operation.
Sourcepub fn binop(&mut self, op: IntBinop, lhs: ValueId, rhs: ValueId) -> ValueId
pub fn binop(&mut self, op: IntBinop, lhs: ValueId, rhs: ValueId) -> ValueId
Emits an integer binary operation before the anchor.
Emitted arithmetic carries no guest address: it is the hook’s, not the guest instruction’s, and stamping it would make it look like the start of that instruction to the next hook choosing sites.
Sourcepub fn zext(&mut self, value: ValueId, size: usize) -> ValueId
pub fn zext(&mut self, value: ValueId, size: usize) -> ValueId
Zero-extends (or truncates) value to size bytes.
Sourcepub fn in_range(&mut self, value: ValueId, begin: u64, end: u64) -> ValueId
pub fn in_range(&mut self, value: ValueId, begin: u64, end: u64) -> ValueId
value - begin < end - begin + 1, as a one-byte condition: whether a
64-bit value lies in begin..=end.
Sourcepub fn interrupt(&mut self, code: u64, args: &[ValueId]) -> InstructionId
pub fn interrupt(&mut self, code: u64, args: &[ValueId]) -> InstructionId
Stops unconditionally before the anchor with vm.interrupt(code, args...).
Sourcepub fn interrupt_if(
&mut self,
cond: ValueId,
code: u64,
args: &[ValueId],
) -> InstructionId
pub fn interrupt_if( &mut self, cond: ValueId, code: u64, args: &[ValueId], ) -> InstructionId
Stops before the anchor only when cond is non-zero, without leaving
compiled code otherwise.
The block is split before the anchor; the code emitted so far stays in
the first half, which ends in cbranch cond -> hook, rest, where
hook holds the interrupt and falls through to rest, the second
half. Later emissions go before the anchor in rest.