Struct orca_wasm::ir::function::FunctionBuilder
source · pub struct FunctionBuilder<'a> {
pub body: Body<'a>,
/* private fields */
}
Expand description
Build a function from scratch See an example here.
Fields§
§body: Body<'a>
Implementations§
source§impl<'a> FunctionBuilder<'a>
impl<'a> FunctionBuilder<'a>
pub fn new(params: &[DataType], results: &[DataType]) -> Self
sourcepub fn finish_module(self, module: &mut Module<'a>) -> FunctionID
pub fn finish_module(self, module: &mut Module<'a>) -> FunctionID
Finish building a function (have side effect on module IR), return function index
pub fn replace_import_in_module( self, module: &mut Module<'a>, import_id: ImportsID, )
sourcepub fn finish_component(
self,
comp: &mut Component<'a>,
mod_idx: ModuleID,
) -> FunctionID
pub fn finish_component( self, comp: &mut Component<'a>, mod_idx: ModuleID, ) -> FunctionID
Finish building a function (have side effect on component IR), return function index
pub fn set_name(&mut self, name: String)
Trait Implementations§
source§impl AddLocal for FunctionBuilder<'_>
impl AddLocal for FunctionBuilder<'_>
source§impl<'a> Inject<'a> for FunctionBuilder<'a>
impl<'a> Inject<'a> for FunctionBuilder<'a>
source§impl<'a> MacroOpcode<'a> for FunctionBuilder<'a>
impl<'a> MacroOpcode<'a> for FunctionBuilder<'a>
source§fn u32_const(&mut self, value: u32) -> &mut Self
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
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> Opcode<'a> for FunctionBuilder<'a>
impl<'a> Opcode<'a> for FunctionBuilder<'a>
source§fn return_stmt(&mut self) -> &mut Self
fn return_stmt(&mut self) -> &mut Self
Inject a return statement
source§fn unreachable(&mut self) -> &mut Self
fn unreachable(&mut self) -> &mut Self
Inject an unreachable instruction
source§fn end(&mut self) -> &mut Self
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
fn block(&mut self, block_type: BlockType) -> &mut Self
Inject a block statement. Indicates the start of a block
fn local_tee(&mut self, idx: LocalID) -> &mut Self
source§fn i32_div_signed(&mut self) -> &mut Self
fn i32_div_signed(&mut self) -> &mut Self
Inject an i32.divs instruction
source§fn i32_div_unsigned(&mut self) -> &mut Self
fn i32_div_unsigned(&mut self) -> &mut Self
Inject an i32.divu instruction
source§fn i32_rem_unsigned(&mut self) -> &mut Self
fn i32_rem_unsigned(&mut self) -> &mut Self
Inject an i32.remu instruction
source§fn i32_rem_signed(&mut self) -> &mut Self
fn i32_rem_signed(&mut self) -> &mut Self
Inject an i32.rems instruction
source§fn i32_shr_signed(&mut self) -> &mut Self
fn i32_shr_signed(&mut self) -> &mut Self
Inject an i32.shrs instruction
source§fn i32_shr_unsigned(&mut self) -> &mut Self
fn i32_shr_unsigned(&mut self) -> &mut Self
Inject an i32.shru instruction
source§fn i32_lt_unsigned(&mut self) -> &mut Self
fn i32_lt_unsigned(&mut self) -> &mut Self
Inject an i32.ltu instruction
source§fn i32_lt_signed(&mut self) -> &mut Self
fn i32_lt_signed(&mut self) -> &mut Self
Inject an i32.lts instruction
source§fn i32_gt_unsigned(&mut self) -> &mut Self
fn i32_gt_unsigned(&mut self) -> &mut Self
Inject an i32.gtu instruction
source§fn i32_gt_signed(&mut self) -> &mut Self
fn i32_gt_signed(&mut self) -> &mut Self
Inject an i32.gts instruction
source§fn i32_lte_unsigned(&mut self) -> &mut Self
fn i32_lte_unsigned(&mut self) -> &mut Self
Inject an i32.lteu instruction
source§fn i32_lte_signed(&mut self) -> &mut Self
fn i32_lte_signed(&mut self) -> &mut Self
Inject an i32.ltes instruction
source§fn i32_gte_unsigned(&mut self) -> &mut Self
fn i32_gte_unsigned(&mut self) -> &mut Self
Inject an i32.gteu instruction
source§fn i32_gte_signed(&mut self) -> &mut Self
fn i32_gte_signed(&mut self) -> &mut Self
Inject an i32.gtes instruction
fn i32_wrap_i64(&mut self) -> &mut Self
source§fn i64_div_signed(&mut self) -> &mut Self
fn i64_div_signed(&mut self) -> &mut Self
Inject an i64.divs instruction
source§fn i64_div_unsigned(&mut self) -> &mut Self
fn i64_div_unsigned(&mut self) -> &mut Self
Inject an i64.divu instruction
source§fn i64_rem_unsigned(&mut self) -> &mut Self
fn i64_rem_unsigned(&mut self) -> &mut Self
Inject an i64.remu instruction
source§fn i64_rem_signed(&mut self) -> &mut Self
fn i64_rem_signed(&mut self) -> &mut Self
Inject an i64.rems instruction
source§fn i64_shr_signed(&mut self) -> &mut Self
fn i64_shr_signed(&mut self) -> &mut Self
Inject an i64.shrs instruction
source§fn i64_shr_unsigned(&mut self) -> &mut Self
fn i64_shr_unsigned(&mut self) -> &mut Self
Inject an i64.shru instruction
source§fn i64_lt_unsigned(&mut self) -> &mut Self
fn i64_lt_unsigned(&mut self) -> &mut Self
Inject an i64.ltu instruction
source§fn i64_lt_signed(&mut self) -> &mut Self
fn i64_lt_signed(&mut self) -> &mut Self
Inject an i64.lts instruction
source§fn i64_gt_unsigned(&mut self) -> &mut Self
fn i64_gt_unsigned(&mut self) -> &mut Self
Inject an i64.gtu instruction
source§fn i64_gt_signed(&mut self) -> &mut Self
fn i64_gt_signed(&mut self) -> &mut Self
Inject an i64.gts instruction
source§fn i64_lte_unsigned(&mut self) -> &mut Self
fn i64_lte_unsigned(&mut self) -> &mut Self
Inject an i64.lteu instruction
source§fn i64_lte_signed(&mut self) -> &mut Self
fn i64_lte_signed(&mut self) -> &mut Self
Inject an i64.ltes instruction
source§fn i64_gte_unsigned(&mut self) -> &mut Self
fn i64_gte_unsigned(&mut self) -> &mut Self
Inject an i64.gteu instruction
source§fn i64_gte_signed(&mut self) -> &mut Self
fn i64_gte_signed(&mut self) -> &mut Self
Inject an i64.gtes instruction
fn i64_extend_i32u(&mut self) -> &mut Self
source§fn f32_convert_i32s(&mut self) -> &mut Self
fn f32_convert_i32s(&mut self) -> &mut Self
Inject a f32_convert_i32s instruction
source§fn f32_demote_f64(&mut self) -> &mut Self
fn f32_demote_f64(&mut self) -> &mut Self
Inject a f32_demote_f64 instruction
source§fn f64_reinterpret_i64(&mut self) -> &mut Self
fn f64_reinterpret_i64(&mut self) -> &mut Self
Inject a f64_reinterpret_i64 instruction
source§fn f64_promote_f32(&mut self) -> &mut Self
fn f64_promote_f32(&mut self) -> &mut Self
Inject a f64_promote_f32 instruction
source§fn f64_convert_i32s(&mut self) -> &mut Self
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
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
fn memory_size(&mut self, mem: u32) -> &mut Self
Inject a memory.size instruction
source§fn memory_grow(&mut self, mem: u32) -> &mut Self
fn memory_grow(&mut self, mem: u32) -> &mut Self
Inject a memory.grow instruction
source§fn memory_fill(&mut self, mem: u32) -> &mut Self
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
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
fn memory_discard(&mut self, mem: u32) -> &mut Self
Inject a memory.discard instruction
source§fn i32_load8_s(&mut self, memarg: MemArg) -> &mut Self
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
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
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
fn i32_load16_u(&mut self, memarg: MemArg) -> &mut Self
load 2 bytes and zero-extend i16 to i32
fn i32_store(&mut self, memarg: MemArg) -> &mut Self
source§fn i64_load8_s(&mut self, memarg: MemArg) -> &mut Self
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
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
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
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
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
fn i64_load32_u(&mut self, memarg: MemArg) -> &mut Self
load 4 bytes and zero-extend i32 to i64
fn i64_store(&mut self, memarg: MemArg) -> &mut Self
fn f32_store(&mut self, memarg: MemArg) -> &mut Self
source§fn global_get(&mut self, idx: GlobalID) -> &mut Self
fn global_get(&mut self, idx: GlobalID) -> &mut Self
Inject a global.get
source§fn global_set(&mut self, idx: GlobalID) -> &mut Self
fn global_set(&mut self, idx: GlobalID) -> &mut Self
Inject a global.set
Auto Trait Implementations§
impl<'a> Freeze for FunctionBuilder<'a>
impl<'a> RefUnwindSafe for FunctionBuilder<'a>
impl<'a> Send for FunctionBuilder<'a>
impl<'a> Sync for FunctionBuilder<'a>
impl<'a> Unpin for FunctionBuilder<'a>
impl<'a> UnwindSafe for FunctionBuilder<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more