Struct orca_wasm::ir::function::FunctionModifier

source ·
pub struct FunctionModifier<'a, 'b> {
    pub instr_flag: FuncInstrFlag<'a>,
    pub body: &'a mut Body<'b>,
    pub args: &'a mut Vec<LocalID>,
    /* private fields */
}
Expand description

Modify a function Uses same injection logic as Iterator, which is different from FunctionBuilder since FunctionModifier does side effect to operators at encoding (it only modifies the Instrument type)

Fields§

§instr_flag: FuncInstrFlag<'a>§body: &'a mut Body<'b>§args: &'a mut Vec<LocalID>

Implementations§

source§

impl<'a, 'b> FunctionModifier<'a, 'b>

source

pub fn init(body: &'a mut Body<'b>, args: &'a mut Vec<LocalID>) -> Self

source

pub fn add_local(&mut self, ty: DataType) -> LocalID

add a local and return local index

Trait Implementations§

source§

impl<'a, 'b> Inject<'b> for FunctionModifier<'a, 'b>

source§

fn inject(&mut self, instr: Operator<'b>)

Inject an operator at the current location
source§

fn inject_all(&mut self, instrs: &[Operator<'a>]) -> &mut Self

Inject multiple operators at the current location
source§

impl<'a, 'b> InjectAt<'b> for FunctionModifier<'a, 'b>

source§

fn inject_at( &mut self, idx: usize, mode: InstrumentationMode, instr: Operator<'b>, )

Inject an Instruction at a given Location with a given InstrumentationMode
source§

impl<'a, 'b> Instrumenter<'b> for FunctionModifier<'a, 'b>

source§

fn curr_instrument_mode(&self) -> &Option<InstrumentationMode>

Get the InstrumentType of the current location
source§

fn set_instrument_mode_at(&mut self, mode: InstrumentationMode, loc: Location)

Sets the type of Instrumentation Type of the specified location
source§

fn curr_func_instrument_mode(&self) -> &Option<FuncInstrMode>

Get the InstrumentType of the current function
source§

fn set_func_instrument_mode(&mut self, mode: FuncInstrMode)

Sets the type of Instrumentation Type of the current function
source§

fn clear_instr_at(&mut self, loc: Location, mode: InstrumentationMode)

Clears the instruction at a given Location
source§

fn add_instr_at(&mut self, loc: Location, instr: Operator<'b>)

Splice a new instruction into a specific location
source§

fn empty_alternate_at(&mut self, loc: Location) -> &mut Self

Injects an empty InstrumentationMode Alternate at a given location
source§

fn empty_block_alt_at(&mut self, loc: Location) -> &mut Self

Injects an empty block alternate at a given location
source§

fn get_injected_val(&self, idx: usize) -> &Operator<'_>

Get the instruction injected at index idx
source§

fn func_entry(&mut self) -> &mut Self

Mark the current function to InstrumentFuncEntry
source§

fn func_exit(&mut self) -> &mut Self

Mark the current function to InstrumentFuncExit
source§

fn before_at(&mut self, loc: Location) -> &mut Self

Injects an Instruction with InstrumentationMode Before at a given location
source§

fn after_at(&mut self, loc: Location) -> &mut Self

Injects an Instruction with InstrumentationMode After at a given location
source§

fn alternate_at(&mut self, loc: Location) -> &mut Self

Injects an Instruction with InstrumentationMode Alternate at a given location
source§

fn semantic_after_at(&mut self, loc: Location) -> &mut Self

Injects a Semantic After at a given location
source§

fn block_entry_at(&mut self, loc: Location) -> &mut Self

Injects a block entry at a given location
source§

fn block_exit_at(&mut self, loc: Location) -> &mut Self

Injects a block exit at a given location
source§

fn block_alt_at(&mut self, loc: Location) -> &mut Self

Injects a block alternate at a given location
source§

impl<'a, 'b> MacroOpcode<'b> for FunctionModifier<'a, 'b>

source§

fn u32_const(&mut self, value: u32) -> &mut Self

Helper function to reinterpret an u32 as an i32 and inject an i32.const instruction with that reinterpreted value. (Useful to emitting memory addresses.) We cast using the as keyword to accomplish this. See https://github.com/thesuhas/orca/issues/133 for an explanation.
source§

fn u64_const(&mut self, value: u64) -> &mut Self

Helper function to reinterpret an u64 as an i64 and inject an i64.const instruction with that reinterpreted value. (Useful to emitting memory addresses.) We cast using the as keyword to accomplish this. See https://github.com/thesuhas/orca/issues/133 for an explanation.
source§

impl<'a, 'b> Opcode<'b> for FunctionModifier<'a, 'b>

source§

fn call(&mut self, idx: FunctionID) -> &mut Self

Inject a call instruction
source§

fn return_stmt(&mut self) -> &mut Self

Inject a return statement
source§

fn nop(&mut self) -> &mut Self

Inject a no op instruction
source§

fn unreachable(&mut self) -> &mut Self

Inject an unreachable instruction
source§

fn if_stmt(&mut self, block_type: BlockType) -> &mut Self

Inject an if statement
source§

fn else_stmt(&mut self) -> &mut Self

Inject an else statement
source§

fn end(&mut self) -> &mut Self

Inject an end statement. Indicates the end of the current scope
source§

fn block(&mut self, block_type: BlockType) -> &mut Self

Inject a block statement. Indicates the start of a block
source§

fn loop_stmt(&mut self, block_type: BlockType) -> &mut Self

Inject a loop statement
source§

fn br(&mut self, relative_depth: u32) -> &mut Self

Inject a break statement
source§

fn br_if(&mut self, relative_depth: u32) -> &mut Self

Inject a conditional break statement
source§

fn local_get(&mut self, idx: LocalID) -> &mut Self

Inject a local.get
source§

fn local_set(&mut self, idx: LocalID) -> &mut Self

Inject a local.set
source§

fn local_tee(&mut self, idx: LocalID) -> &mut Self

source§

fn i32_const(&mut self, value: i32) -> &mut Self

Inject an i32.const instruction
source§

fn i32_add(&mut self) -> &mut Self

Inject an i32.add instruction
source§

fn i32_sub(&mut self) -> &mut Self

Inject an i32.sub instruction
source§

fn i32_mul(&mut self) -> &mut Self

Inject an i32.mul instruction
source§

fn i32_div_signed(&mut self) -> &mut Self

Inject an i32.divs instruction
source§

fn i32_div_unsigned(&mut self) -> &mut Self

Inject an i32.divu instruction
source§

fn i32_rem_unsigned(&mut self) -> &mut Self

Inject an i32.remu instruction
source§

fn i32_rem_signed(&mut self) -> &mut Self

Inject an i32.rems instruction
source§

fn i32_and(&mut self) -> &mut Self

Inject an i32.and instruction
source§

fn i32_or(&mut self) -> &mut Self

Inject an i32.or instruction
source§

fn i32_xor(&mut self) -> &mut Self

Inject an i32.xor instruction
source§

fn i32_shl(&mut self) -> &mut Self

Inject an i32.shl instruction
source§

fn i32_shr_signed(&mut self) -> &mut Self

Inject an i32.shrs instruction
source§

fn i32_shr_unsigned(&mut self) -> &mut Self

Inject an i32.shru instruction
source§

fn i32_rotl(&mut self) -> &mut Self

Inject an i32.rotl instruction
source§

fn i32_rotr(&mut self) -> &mut Self

Inject and i32.rotr instruction
source§

fn i32_eq(&mut self) -> &mut Self

Inject an i32.eq instruction
source§

fn i32_eqz(&mut self) -> &mut Self

Inject an i32.eqz instruction
source§

fn i32_ne(&mut self) -> &mut Self

Inject an i32.ne instruction
source§

fn i32_lt_unsigned(&mut self) -> &mut Self

Inject an i32.ltu instruction
source§

fn i32_lt_signed(&mut self) -> &mut Self

Inject an i32.lts instruction
source§

fn i32_gt_unsigned(&mut self) -> &mut Self

Inject an i32.gtu instruction
source§

fn i32_gt_signed(&mut self) -> &mut Self

Inject an i32.gts instruction
source§

fn i32_lte_unsigned(&mut self) -> &mut Self

Inject an i32.lteu instruction
source§

fn i32_lte_signed(&mut self) -> &mut Self

Inject an i32.ltes instruction
source§

fn i32_gte_unsigned(&mut self) -> &mut Self

Inject an i32.gteu instruction
source§

fn i32_gte_signed(&mut self) -> &mut Self

Inject an i32.gtes instruction
source§

fn i32_wrap_i64(&mut self) -> &mut Self

source§

fn i64_const(&mut self, value: i64) -> &mut Self

Inject an i64.const
source§

fn i64_add(&mut self) -> &mut Self

Inject an i64.add instruction
source§

fn i64_sub(&mut self) -> &mut Self

Inject an i64.sub instruction
source§

fn i64_mul(&mut self) -> &mut Self

Inject an i64.mul instruction
source§

fn i64_div_signed(&mut self) -> &mut Self

Inject an i64.divs instruction
source§

fn i64_div_unsigned(&mut self) -> &mut Self

Inject an i64.divu instruction
source§

fn i64_rem_unsigned(&mut self) -> &mut Self

Inject an i64.remu instruction
source§

fn i64_rem_signed(&mut self) -> &mut Self

Inject an i64.rems instruction
source§

fn i64_and(&mut self) -> &mut Self

Inject an i64.and instruction
source§

fn i64_or(&mut self) -> &mut Self

Inject an i64.or instruction
source§

fn i64_xor(&mut self) -> &mut Self

Inject an i64.xor instruction
source§

fn i64_shl(&mut self) -> &mut Self

Inject an i64.shl instruction
source§

fn i64_shr_signed(&mut self) -> &mut Self

Inject an i64.shrs instruction
source§

fn i64_shr_unsigned(&mut self) -> &mut Self

Inject an i64.shru instruction
source§

fn i64_rotl(&mut self) -> &mut Self

Inject an i64.rotl instruction
source§

fn i64_rotr(&mut self) -> &mut Self

Inject an i64.rotr instruction
source§

fn i64_eq(&mut self) -> &mut Self

Inject an i64.eq instruction
source§

fn i64_eqz(&mut self) -> &mut Self

Inject an i64.eqz instruction
source§

fn i64_ne(&mut self) -> &mut Self

Inject an i64.ne instruction
source§

fn i64_lt_unsigned(&mut self) -> &mut Self

Inject an i64.ltu instruction
source§

fn i64_lt_signed(&mut self) -> &mut Self

Inject an i64.lts instruction
source§

fn i64_gt_unsigned(&mut self) -> &mut Self

Inject an i64.gtu instruction
source§

fn i64_gt_signed(&mut self) -> &mut Self

Inject an i64.gts instruction
source§

fn i64_lte_unsigned(&mut self) -> &mut Self

Inject an i64.lteu instruction
source§

fn i64_lte_signed(&mut self) -> &mut Self

Inject an i64.ltes instruction
source§

fn i64_gte_unsigned(&mut self) -> &mut Self

Inject an i64.gteu instruction
source§

fn i64_gte_signed(&mut self) -> &mut Self

Inject an i64.gtes instruction
source§

fn i64_extend_i32u(&mut self) -> &mut Self

source§

fn f32_const(&mut self, val: f32) -> &mut Self

Inject a f32.const instruction
source§

fn f32_abs(&mut self) -> &mut Self

Inject a f32.abs instruction
source§

fn f32_ceil(&mut self) -> &mut Self

Inject a f32.ceil instruction
source§

fn f32_floor(&mut self) -> &mut Self

Inject a f32.floor instruction
source§

fn f32_trunc(&mut self) -> &mut Self

Inject a f32.trunc instruction
source§

fn f32_sqrt(&mut self) -> &mut Self

Inject a f32.sqrt instruction
source§

fn f32_add(&mut self) -> &mut Self

Inject a f32.add instruction
source§

fn f32_sub(&mut self) -> &mut Self

Inject a f32.sub instruction
source§

fn f32_mul(&mut self) -> &mut Self

Inject a f32.mul instruction
source§

fn f32_div(&mut self) -> &mut Self

Inject a f32.div instruction
source§

fn f32_min(&mut self) -> &mut Self

Inject a f32.min instruction
source§

fn f32_max(&mut self) -> &mut Self

Inject a f32.max instruction
source§

fn f32_eq(&mut self) -> &mut Self

Inject a f32.eq instruction
source§

fn f32_ne(&mut self) -> &mut Self

Inject a f32.ne instruction
source§

fn f32_gt(&mut self) -> &mut Self

Inject a f32.gt instruction
source§

fn f32_ge(&mut self) -> &mut Self

Inject a f32.ge instruction
source§

fn f32_lt(&mut self) -> &mut Self

Inject a f32.lt instruction
source§

fn f32_le(&mut self) -> &mut Self

Inject a f32.le instruction
source§

fn f32_convert_i32s(&mut self) -> &mut Self

Inject a f32_convert_i32s instruction
source§

fn f32_demote_f64(&mut self) -> &mut Self

Inject a f32_demote_f64 instruction
source§

fn f64_const(&mut self, val: f64) -> &mut Self

Inject a f64.const instruction
source§

fn f64_abs(&mut self) -> &mut Self

Inject a f64.abs instruction
source§

fn f64_ceil(&mut self) -> &mut Self

Inject a f64.ceil instruction
source§

fn f64_floor(&mut self) -> &mut Self

Inject a f64.floor instruction
source§

fn f64_trunc(&mut self) -> &mut Self

Inject a f64.trunc instruction
source§

fn f64_sqrt(&mut self) -> &mut Self

Inject a f64.sqrt instruction
source§

fn f64_add(&mut self) -> &mut Self

Inject a f64.add instruction
source§

fn f64_sub(&mut self) -> &mut Self

Inject a f64.sub instruction
source§

fn f64_mul(&mut self) -> &mut Self

Inject a f64.mul instruction
source§

fn f64_div(&mut self) -> &mut Self

Inject a f64.div instruction
source§

fn f64_min(&mut self) -> &mut Self

Inject a f64.min instruction
source§

fn f64_max(&mut self) -> &mut Self

Inject a f64.max instruction
source§

fn f64_eq(&mut self) -> &mut Self

Inject a f64.eq instruction
source§

fn f64_ne(&mut self) -> &mut Self

Inject a f64.ne instruction
source§

fn f64_gt(&mut self) -> &mut Self

Inject a f64.gt instruction
source§

fn f64_ge(&mut self) -> &mut Self

Inject a f64.ge instruction
source§

fn f64_lt(&mut self) -> &mut Self

Inject a f64.lt instruction
source§

fn f64_le(&mut self) -> &mut Self

Inject a f64.le instruction
source§

fn f64_reinterpret_i64(&mut self) -> &mut Self

Inject a f64_reinterpret_i64 instruction
source§

fn f64_promote_f32(&mut self) -> &mut Self

Inject a f64_promote_f32 instruction
source§

fn f64_convert_i32s(&mut self) -> &mut Self

Inject a f64_convert_i32s instruction
source§

fn memory_init(&mut self, data_index: u32, mem: u32) -> &mut Self

Inject a memory.init instruction
source§

fn memory_size(&mut self, mem: u32) -> &mut Self

Inject a memory.size instruction
source§

fn memory_grow(&mut self, mem: u32) -> &mut Self

Inject a memory.grow instruction
source§

fn memory_fill(&mut self, mem: u32) -> &mut Self

Inject a memory.fill instruction
source§

fn memory_copy(&mut self, dst_mem: u32, src_mem: u32) -> &mut Self

Inject a memory.copy instruction
source§

fn memory_discard(&mut self, mem: u32) -> &mut Self

Inject a memory.discard instruction
source§

fn data_drop(&mut self, data_index: u32) -> &mut Self

Inject a data drop instruction
source§

fn drop(&mut self) -> &mut Self

Inject a drop instruction
source§

fn i32_load8_s(&mut self, memarg: MemArg) -> &mut Self

load 1 byte and sign-extend i8 to i32
source§

fn i32_load8_u(&mut self, memarg: MemArg) -> &mut Self

load 1 byte and zero-extend i8 to i32
source§

fn i32_load16_s(&mut self, memarg: MemArg) -> &mut Self

load 2 bytes and sign-extend i16 to i32
source§

fn i32_load16_u(&mut self, memarg: MemArg) -> &mut Self

load 2 bytes and zero-extend i16 to i32
source§

fn i32_load(&mut self, memarg: MemArg) -> &mut Self

load 4 bytes as i32
source§

fn i32_store(&mut self, memarg: MemArg) -> &mut Self

source§

fn i64_load8_s(&mut self, memarg: MemArg) -> &mut Self

load 1 byte and sign-extend i8 to i64
source§

fn i64_load8_u(&mut self, memarg: MemArg) -> &mut Self

load 1 byte and zero-extend i8 to i64
source§

fn i64_load16_s(&mut self, memarg: MemArg) -> &mut Self

load 2 bytes and sign-extend i16 to i64
source§

fn i64_load16_u(&mut self, memarg: MemArg) -> &mut Self

load 2 bytes and zero-extend i16 to i64
source§

fn i64_load32_s(&mut self, memarg: MemArg) -> &mut Self

load 4 bytes and sign-extend i32 to i64
source§

fn i64_load32_u(&mut self, memarg: MemArg) -> &mut Self

load 4 bytes and zero-extend i32 to i64
source§

fn i64_load(&mut self, memarg: MemArg) -> &mut Self

load 4 bytes as i64
source§

fn i64_store(&mut self, memarg: MemArg) -> &mut Self

source§

fn f32_load(&mut self, memarg: MemArg) -> &mut Self

load 4 bytes as f32
source§

fn f32_store(&mut self, memarg: MemArg) -> &mut Self

source§

fn f64_load(&mut self, memarg: MemArg) -> &mut Self

load 8 bytes as f64
source§

fn f64_store(&mut self, memarg: MemArg) -> &mut Self

Inject an f64_store instruction
source§

fn global_get(&mut self, idx: GlobalID) -> &mut Self

Inject a global.get
source§

fn global_set(&mut self, idx: GlobalID) -> &mut Self

Inject a global.set

Auto Trait Implementations§

§

impl<'a, 'b> Freeze for FunctionModifier<'a, 'b>

§

impl<'a, 'b> RefUnwindSafe for FunctionModifier<'a, 'b>

§

impl<'a, 'b> Send for FunctionModifier<'a, 'b>

§

impl<'a, 'b> Sync for FunctionModifier<'a, 'b>

§

impl<'a, 'b> Unpin for FunctionModifier<'a, 'b>

§

impl<'a, 'b> !UnwindSafe for FunctionModifier<'a, 'b>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.