Skip to main content

Builder

Struct Builder 

Source
pub struct Builder<'str, 'ctx> { /* private fields */ }
Expand description

A builder for constructing instructions in a block. This provides a convenient API for creating instructions, and automatically manages temporary values and labels.

Implementations§

Source§

impl<'str, 'ctx> Builder<'str, 'ctx>

Source

pub fn make_temp(&mut self, size: usize) -> TempId

Creates an anonymous body-local temporary memory value.

Source

pub fn make_named_temp(&mut self, name: Cow<'str, str>, size: usize) -> TempId

Creates a named body-local temporary memory value.

Source

pub fn make_temp_labeled(&mut self, label: u32, size: usize) -> TempId

Creates a body-local temporary identified by a SLEIGH local label.

Source

pub fn new( body: &'ctx mut FunctionBody<'str>, shared: &'ctx Shared<'str>, interfaces: &'ctx Registry<FunctionId, FunctionInterface<'str>>, block: BlockId, ) -> Self

Creates a builder positioned at block.

The block is borrowed mutably for the lifetime 'ctx. New instructions will be appended to the end of block.

Source

pub fn new_local( body: &'ctx mut FunctionBody<'str>, shared: &'ctx Shared<'str>, interfaces: &'ctx Registry<FunctionId, FunctionInterface<'str>>, block: LocalBlockId, ) -> Self

Creates a builder positioned at a body-local block, without ever consulting the body’s registry identity. This is the id-less constructor: it works on a detached (uninstalled) body just as well as an installed one. is_terminated is read straight from the block’s own arena (its last instruction’s mnemonic), never through the composite BodyView path.

Source

pub fn view(&self) -> BodyView<'_, 'str>

A Copy read view over the builder’s backing, for arena reads. The builder reads through the backing’s static QCodeView.

Source

pub fn is_terminated(&self) -> bool

Returns true if the current block ends with a terminator instruction.

Source

pub fn set_address(&mut self, addr: u64)

Sets the current address for instructions added by this builder.

Source

pub fn clear_address(&mut self)

Remove the current address

Source

pub fn set_insert_point_to_start(&mut self)

Positions the builder at the beginning of the block.

Subsequent push_* calls insert instructions starting at index 0, advancing by 1 after each push, so they appear in push order as a contiguous prefix before any pre-existing instructions.

This allows inserting synthetic preamble instructions (e.g. a symbolic stack-pointer initialization) into a block that already contains lifted code, without disturbing the relative order of either the new or the existing instructions.

Source

pub fn set_insert_point_before(&mut self, before_id: InstructionId)

Positions the builder immediately before an existing instruction in the current block.

Subsequent push_* calls insert instructions starting at that position, advancing by 1 after each push, so they appear in push order immediately before before_id and after any earlier inserted instructions.

Panics if before_id is not an instruction in the current block.

Source

pub fn set_insert_point_to_end(&mut self)

Resets the insert point to append mode (the default).

Source

pub fn get_range( &mut self, src: ValueId, range: Range<usize>, ) -> Option<ValueRef<'str, '_, BodyView<'_, 'str>>>

Gets a sub-value from a given value, specified by a byte range.

Source

pub fn get_range_local( &mut self, src: LocalValueId, range: Range<usize>, ) -> Option<LocalValueId>

Body-local core of get_range: folds a literal/temp sub-range in place and emits a Range instruction for varnode/instruction sources. Operands and result are body-local; no registry identity is used.

Source

pub fn push_range( &mut self, src: ValueId, start: usize, size: usize, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Pushes a Range instruction extracting size bytes starting at byte start of src. Unlike get_range, this always emits a Range instruction (no constant/varnode folding), so the result is a fresh SSA value — used by the qcode! macro’s src[start:end] form.

Source

pub fn push_range_local( &mut self, src: LocalValueId, start: usize, size: usize, ) -> LocalInsnId

Body-local core of push_range.

Source

pub fn remove_alias(&mut self, name: &str)

Removes a name from the local namespace, freeing it for reuse.

Source

pub fn set_alias(&mut self, name: Cow<'str, str>, id: ValueId)

Sets a name in the local alias map without changing the qcode name hint. The alias map maps sleigh names to values for macro lookups; re-aliasing is allowed.

Source

pub fn switch_to_block(&mut self, block: BlockId)

Source

pub fn switch_to_block_local(&mut self, block: LocalBlockId)

Reposition the builder onto a body-local block (id-less).

Source

pub fn current_block(&self) -> BlockId

The block the builder is currently appending to.

Source

pub fn try_get_value( &self, name: &str, ) -> Option<ValueRef<'str, '_, BodyView<'_, 'str>>>

Gets the ID of a value in the current namespace

Source

pub fn shr(&self) -> &Shared<'str>

The module’s shared IR state (read) — types/literals/spaces/registers.

Source

pub fn push_mnemonic_with_type( &mut self, mnemonic: Mnemonic, type_id: TypeId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Adds an instruction with an explicit result type, for callers that compute the type themselves. Needed by passes that reference a minted (not-yet-installed) function from a Map/Scan/Apply: the typed push_map/push_scan/push_apply read the body function’s return type through the shared context, where a minted placeholder has no installed body — so the pass supplies the type it already knows instead.

Source

pub fn set_param_type(&mut self, id: BlockParamId, type_id: TypeId)

Source

pub fn get_or_make_local_label(&mut self, name: Cow<'str, str>) -> BlockId

Source

pub fn get_or_make_local_temp_space(&mut self, name: &str) -> LocalMemorySpaceId

Resolve a canonical textual $tempN token to one body-local temporary space, creating it on first use. This is a lowering compatibility seam; analysis and lifter producers append their spaces directly to the body.

Source

pub fn ensure_local(&mut self, src: ValueId) -> ValueId

Ensures an operand is not a memory value. If the operand is a shared varnode or body-local temporary, emits a load and returns its SSA result. Other values are already directly usable.

Source

pub fn ensure_local_local(&mut self, src: LocalValueId) -> LocalValueId

Body-local core of ensure_local: loads a shared varnode or body-local temporary into an SSA value, giving the load a related debug name; other operands pass through. Id-free.

Source

pub fn push_load<const CHECK_LOCAL: bool>( &mut self, src: ValueId, size: usize, space: impl Into<LocalMemorySpaceId>, ) -> ValueRef<'str, '_, BodyView<'_, 'str>>

Loads a value from memory, given a pointer value. Optionally specify the address space and size of the load. If the load space is the special CONST space, the pointer is treated as an immediate value rather than an address.

§Panics

Panics if space is SPACE_CONST and src is not a Literal value.

Source

pub fn push_load_local<const CHECK_LOCAL: bool>( &mut self, src: LocalValueId, size: usize, space: impl Into<LocalMemorySpaceId>, ) -> LocalValueId

Body-local core of push_load. Operand and result are body-local; consults no registry identity.

Source

pub fn push_bool_not( &mut self, src: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Logical NOT of a bool value, canonically src == false.

Source

pub fn push_bool_not_local(&mut self, src: LocalValueId) -> LocalInsnId

Body-local sibling of push_bool_not.

Source

pub fn push_bit_negate( &mut self, src: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Creates a bitwise NOT operation on the given value.

Source

pub fn push_bit_negate_local(&mut self, src: LocalValueId) -> LocalInsnId

Body-local sibling.

Source

pub fn push_neg( &mut self, src: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Creates a negation operation on the given value.

Source

pub fn push_neg_local(&mut self, src: LocalValueId) -> LocalInsnId

Body-local sibling.

Source

pub fn push_fneg( &mut self, src: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Creates a float negation operation on the given value.

Source

pub fn push_fneg_local(&mut self, src: LocalValueId) -> LocalInsnId

Body-local sibling.

Source

pub fn push_mul( &mut self, lhs: ValueId, rhs: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_mul_local( &mut self, lhs: LocalValueId, rhs: LocalValueId, ) -> LocalInsnId

Body-local sibling.

Source

pub fn push_div( &mut self, lhs: ValueId, rhs: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_div_local( &mut self, lhs: LocalValueId, rhs: LocalValueId, ) -> LocalInsnId

Body-local sibling.

Source

pub fn push_sdiv( &mut self, lhs: ValueId, rhs: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_sdiv_local( &mut self, lhs: LocalValueId, rhs: LocalValueId, ) -> LocalInsnId

Body-local sibling.

Source

pub fn push_mod( &mut self, lhs: ValueId, rhs: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_mod_local( &mut self, lhs: LocalValueId, rhs: LocalValueId, ) -> LocalInsnId

Body-local sibling.

Source

pub fn push_smod( &mut self, lhs: ValueId, rhs: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_smod_local( &mut self, lhs: LocalValueId, rhs: LocalValueId, ) -> LocalInsnId

Body-local sibling.

Source

pub fn push_add( &mut self, lhs: ValueId, rhs: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_add_local( &mut self, lhs: LocalValueId, rhs: LocalValueId, ) -> LocalInsnId

Body-local sibling.

Source

pub fn push_sub( &mut self, lhs: ValueId, rhs: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_sub_local( &mut self, lhs: LocalValueId, rhs: LocalValueId, ) -> LocalInsnId

Body-local sibling.

Source

pub fn push_fdiv( &mut self, lhs: ValueId, rhs: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_fdiv_local( &mut self, lhs: LocalValueId, rhs: LocalValueId, ) -> LocalInsnId

Body-local sibling.

Source

pub fn push_fmul( &mut self, lhs: ValueId, rhs: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_fmul_local( &mut self, lhs: LocalValueId, rhs: LocalValueId, ) -> LocalInsnId

Body-local sibling.

Source

pub fn push_fadd( &mut self, lhs: ValueId, rhs: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_fadd_local( &mut self, lhs: LocalValueId, rhs: LocalValueId, ) -> LocalInsnId

Body-local sibling.

Source

pub fn push_fsub( &mut self, lhs: ValueId, rhs: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_fsub_local( &mut self, lhs: LocalValueId, rhs: LocalValueId, ) -> LocalInsnId

Body-local sibling.

Source

pub fn push_shl( &mut self, lhs: ValueId, rhs: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_shl_local( &mut self, lhs: LocalValueId, rhs: LocalValueId, ) -> LocalInsnId

Body-local sibling.

Source

pub fn push_shr( &mut self, lhs: ValueId, rhs: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_shr_local( &mut self, lhs: LocalValueId, rhs: LocalValueId, ) -> LocalInsnId

Body-local sibling.

Source

pub fn push_sshr( &mut self, lhs: ValueId, rhs: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_sshr_local( &mut self, lhs: LocalValueId, rhs: LocalValueId, ) -> LocalInsnId

Body-local sibling.

Source

pub fn push_slt( &mut self, lhs: ValueId, rhs: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_slt_local( &mut self, lhs: LocalValueId, rhs: LocalValueId, ) -> LocalInsnId

Source

pub fn push_sgt( &mut self, lhs: ValueId, rhs: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_sgt_local( &mut self, lhs: LocalValueId, rhs: LocalValueId, ) -> LocalInsnId

Source

pub fn push_sle( &mut self, lhs: ValueId, rhs: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_sle_local( &mut self, lhs: LocalValueId, rhs: LocalValueId, ) -> LocalInsnId

Source

pub fn push_sge( &mut self, lhs: ValueId, rhs: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_sge_local( &mut self, lhs: LocalValueId, rhs: LocalValueId, ) -> LocalInsnId

Source

pub fn push_lt( &mut self, lhs: ValueId, rhs: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_lt_local( &mut self, lhs: LocalValueId, rhs: LocalValueId, ) -> LocalInsnId

Source

pub fn push_gt( &mut self, lhs: ValueId, rhs: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_gt_local( &mut self, lhs: LocalValueId, rhs: LocalValueId, ) -> LocalInsnId

Source

pub fn push_le( &mut self, lhs: ValueId, rhs: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_le_local( &mut self, lhs: LocalValueId, rhs: LocalValueId, ) -> LocalInsnId

Source

pub fn push_ge( &mut self, lhs: ValueId, rhs: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_ge_local( &mut self, lhs: LocalValueId, rhs: LocalValueId, ) -> LocalInsnId

Source

pub fn push_flt( &mut self, lhs: ValueId, rhs: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_flt_local( &mut self, lhs: LocalValueId, rhs: LocalValueId, ) -> LocalInsnId

Source

pub fn push_fgt( &mut self, lhs: ValueId, rhs: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_fgt_local( &mut self, lhs: LocalValueId, rhs: LocalValueId, ) -> LocalInsnId

Source

pub fn push_fle( &mut self, lhs: ValueId, rhs: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_fle_local( &mut self, lhs: LocalValueId, rhs: LocalValueId, ) -> LocalInsnId

Source

pub fn push_fge( &mut self, lhs: ValueId, rhs: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_fge_local( &mut self, lhs: LocalValueId, rhs: LocalValueId, ) -> LocalInsnId

Source

pub fn push_eq( &mut self, lhs: ValueId, rhs: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_eq_local( &mut self, lhs: LocalValueId, rhs: LocalValueId, ) -> LocalInsnId

Body-local sibling.

Source

pub fn push_ne( &mut self, lhs: ValueId, rhs: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_ne_local( &mut self, lhs: LocalValueId, rhs: LocalValueId, ) -> LocalInsnId

Body-local sibling.

Source

pub fn push_feq( &mut self, lhs: ValueId, rhs: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_feq_local( &mut self, lhs: LocalValueId, rhs: LocalValueId, ) -> LocalInsnId

Body-local sibling.

Source

pub fn push_fne( &mut self, lhs: ValueId, rhs: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_fne_local( &mut self, lhs: LocalValueId, rhs: LocalValueId, ) -> LocalInsnId

Body-local sibling.

Source

pub fn push_bool_xor( &mut self, lhs: ValueId, rhs: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Logical XOR of two bool operands — a bitwise Xor over bool, which yields bool (exact on the {0,1} domain).

Source

pub fn push_bool_xor_local( &mut self, lhs: LocalValueId, rhs: LocalValueId, ) -> LocalInsnId

Body-local sibling of push_bool_xor.

Source

pub fn push_bool_and( &mut self, lhs: ValueId, rhs: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Logical AND of two bool operands (bitwise And over bool).

Source

pub fn push_bool_and_local( &mut self, lhs: LocalValueId, rhs: LocalValueId, ) -> LocalInsnId

Body-local sibling of push_bool_and.

Source

pub fn push_bool_or( &mut self, lhs: ValueId, rhs: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Logical OR of two bool operands (bitwise Or over bool).

Source

pub fn push_bool_or_local( &mut self, lhs: LocalValueId, rhs: LocalValueId, ) -> LocalInsnId

Body-local sibling of push_bool_or.

Source

pub fn push_bit_xor( &mut self, lhs: ValueId, rhs: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_bit_xor_local( &mut self, lhs: LocalValueId, rhs: LocalValueId, ) -> LocalInsnId

Body-local sibling.

Source

pub fn push_bit_or( &mut self, lhs: ValueId, rhs: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_bit_or_local( &mut self, lhs: LocalValueId, rhs: LocalValueId, ) -> LocalInsnId

Body-local sibling.

Source

pub fn push_bit_and( &mut self, lhs: ValueId, rhs: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_bit_and_local( &mut self, lhs: LocalValueId, rhs: LocalValueId, ) -> LocalInsnId

Body-local sibling.

Source

pub fn push_is_nan( &mut self, src: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_is_nan_local(&mut self, src: LocalValueId) -> LocalInsnId

Body-local sibling of push_is_nan.

Source

pub fn push_abs( &mut self, src: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_abs_local(&mut self, src: LocalValueId) -> LocalInsnId

Body-local sibling.

Source

pub fn push_sqrt( &mut self, src: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_sqrt_local(&mut self, src: LocalValueId) -> LocalInsnId

Body-local sibling.

Source

pub fn push_floor( &mut self, src: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_floor_local(&mut self, src: LocalValueId) -> LocalInsnId

Body-local sibling.

Source

pub fn push_ceil( &mut self, src: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_ceil_local(&mut self, src: LocalValueId) -> LocalInsnId

Body-local sibling.

Source

pub fn push_round( &mut self, src: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_round_local(&mut self, src: LocalValueId) -> LocalInsnId

Body-local sibling.

Source

pub fn push_int_to_float( &mut self, src: ValueId, size: usize, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_int_to_float_local( &mut self, src: LocalValueId, size: usize, ) -> LocalInsnId

Body-local sibling.

Source

pub fn push_float_to_float( &mut self, src: ValueId, size: usize, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_float_to_float_local( &mut self, src: LocalValueId, size: usize, ) -> LocalInsnId

Body-local sibling.

Source

pub fn push_trunc( &mut self, src: ValueId, size: usize, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_trunc_local( &mut self, src: LocalValueId, size: usize, ) -> LocalInsnId

Body-local sibling.

Source

pub fn push_zext( &mut self, src: ValueId, size: usize, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_zext_local(&mut self, src: LocalValueId, size: usize) -> LocalInsnId

Body-local sibling.

Source

pub fn push_sext( &mut self, src: ValueId, size: usize, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_sext_local(&mut self, src: LocalValueId, size: usize) -> LocalInsnId

Body-local sibling.

Source

pub fn push_tuple( &mut self, fields: Vec<ValueId>, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Builds an aggregate value from fields using default field names (field1, field2, …). The result type is the Aggregate of the named fields’ types.

Source

pub fn push_tuple_local(&mut self, fields: Vec<LocalValueId>) -> LocalInsnId

Body-local sibling of push_tuple.

Source

pub fn push_named_tuple( &mut self, fields: Vec<(String, ValueId)>, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Builds an aggregate value from ordered named fields.

Source

pub fn push_named_tuple_local( &mut self, fields: Vec<(String, LocalValueId)>, ) -> LocalInsnId

Body-local sibling of push_named_tuple.

Source

pub fn push_named_tuple_with_type( &mut self, fields: Vec<(String, ValueId)>, ty: TypeId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Build a named tuple using an explicitly selected aggregate-like type. Used for nominal function-return records whose identity must not be structurally interned by push_named_tuple_local.

Source

pub fn push_named_tuple_local_with_type( &mut self, fields: Vec<(String, LocalValueId)>, ty: TypeId, ) -> LocalInsnId

Body-local sibling of push_named_tuple_with_type.

Source

pub fn push_extract( &mut self, agg: ValueId, index: usize, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Projects field index out of the aggregate value agg. The result type is that field’s type. Panics if agg is not an aggregate with that field.

Source

pub fn push_extract_local( &mut self, agg: LocalValueId, index: usize, ) -> LocalInsnId

Body-local sibling of push_extract.

Source

pub fn push_map( &mut self, body: impl Into<Callee>, src: ValueId, captures: Vec<ValueId>, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Builds a total element-wise map out[i] = body(src[i], captures…) over the array value src. The body is unary in the element (index-aware bodies take an enumerate tuple as that element); body is a function symbol, not an operand. Soundness of the body (pure, element-local) is the recognizer’s obligation; the builder only wires the value graph.

The result is [U; N] where N is src’s element count and U is the body’s return type — which need not equal the input element type (e.g. a map over enumerate(arr) consumes tuples but returns bare elements). When the body is a bare symbol with no return (or src is not an array), the result falls back to src’s type.

Source

pub fn push_map_local( &mut self, body: impl Into<Callee>, src: LocalValueId, captures: Vec<LocalValueId>, ) -> LocalInsnId

Body-local sibling of push_map.

Source

pub fn push_map_typed( &mut self, body: impl Into<Callee>, src: ValueId, captures: Vec<ValueId>, result_type: TypeId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Builds a map with an explicitly prepared result type. Use this when the body is foreign to this Builder and its body-derived return type is not part of the published function interface.

Source

pub fn push_map_typed_local( &mut self, body: impl Into<Callee>, src: LocalValueId, captures: Vec<LocalValueId>, result_type: TypeId, ) -> LocalInsnId

Body-local sibling of push_map_typed.

Source

pub fn push_scan( &mut self, body: impl Into<Callee>, init: ValueId, src: ValueId, captures: Vec<ValueId>, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Builds a total left-scan out[i] = body(acc_i, src[i], captures…) with acc_0 = init over the array value src (see Scan). The body is binary in (accumulator, element) — index-aware bodies take an enumerate tuple as the element; body is a function symbol, not an operand. Soundness of the body (pure, with the accumulator threaded only through the scan) is the recognizer’s obligation.

The result is [U; N] where N is src’s element count and U is the body’s return type (also the accumulator type). When the body is a bare symbol with no return (or src is not an array), the result falls back to src’s type.

Source

pub fn push_scan_local( &mut self, body: impl Into<Callee>, init: LocalValueId, src: LocalValueId, captures: Vec<LocalValueId>, ) -> LocalInsnId

Body-local sibling of push_scan.

Source

pub fn push_scan_typed( &mut self, body: impl Into<Callee>, init: ValueId, src: ValueId, captures: Vec<ValueId>, result_type: TypeId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Builds a scan with an explicitly prepared result type. This is the foreign-body counterpart to push_map_typed.

Source

pub fn push_scan_typed_local( &mut self, body: impl Into<Callee>, init: LocalValueId, src: LocalValueId, captures: Vec<LocalValueId>, result_type: TypeId, ) -> LocalInsnId

Body-local sibling of push_scan_typed.

Source

pub fn push_apply( &mut self, target: impl Into<Callee>, args: Vec<ValueId>, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Builds a value-level application of a pure lambda function. Unlike push_call, this is an ordinary SSA instruction and does not terminate the current block.

Source

pub fn push_apply_local( &mut self, target: impl Into<Callee>, args: Vec<LocalValueId>, ) -> LocalInsnId

Body-local sibling of push_apply.

Source

pub fn push_gep( &mut self, base: ValueId, offset: usize, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Computes the address of the field at byte offset of the struct that base points at: gep(base, offset). base must have a StructPointer type whose pointee has a field at exactly offset. The result type is a pointer (same width as base) to that field’s type. Panics otherwise.

Source

pub fn push_gep_local( &mut self, base: LocalValueId, offset: usize, ) -> LocalInsnId

Body-local sibling of push_gep.

Source

pub fn push_gep_field( &mut self, base: ValueId, name: &str, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Like push_gep but selects the field by name, resolving it to a byte offset via the pointee struct of base. Panics if base is not a struct pointer or has no field of that name.

Source

pub fn push_gep_field_local( &mut self, base: LocalValueId, name: &str, ) -> LocalInsnId

Body-local sibling of push_gep_field.

Source

pub fn push_popcount( &mut self, src: ValueId, size: usize, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_popcount_local( &mut self, src: LocalValueId, size: usize, ) -> LocalInsnId

Body-local sibling of push_popcount.

Source

pub fn push_lzcount( &mut self, src: ValueId, size: usize, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_lzcount_local( &mut self, src: LocalValueId, size: usize, ) -> LocalInsnId

Body-local sibling of push_lzcount.

Source

pub fn push_carry( &mut self, lhs: ValueId, rhs: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_carry_local( &mut self, lhs: LocalValueId, rhs: LocalValueId, ) -> LocalInsnId

Body-local sibling of push_carry.

Source

pub fn push_scarry( &mut self, lhs: ValueId, rhs: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_scarry_local( &mut self, lhs: LocalValueId, rhs: LocalValueId, ) -> LocalInsnId

Body-local sibling of push_scarry.

Source

pub fn push_sborrow( &mut self, lhs: ValueId, rhs: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_sborrow_local( &mut self, lhs: LocalValueId, rhs: LocalValueId, ) -> LocalInsnId

Body-local sibling of push_sborrow.

Source

pub fn push_pcode_op( &mut self, id: PCodeOpId, args: Vec<ValueId>, dst: Option<ValueId>, size: usize, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_pcode_op_local( &mut self, id: PCodeOpId, args: Vec<LocalValueId>, dst: Option<LocalValueId>, size: usize, ) -> LocalInsnId

Body-local sibling of push_pcode_op.

Source

pub fn push_intrinsic( &mut self, id: IntrinsicId, args: Vec<ValueId>, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Creates a pure intrinsic instruction (e.g. rol, ror, enumerate).

Validates the operand count against the intrinsic’s declared arity and types the node via the intrinsic’s result_type rule, so the result carries its full type (not just a width) — an array or aggregate result is projectable. Panics on an arity mismatch.

Source

pub fn push_intrinsic_local( &mut self, id: IntrinsicId, args: Vec<LocalValueId>, ) -> LocalInsnId

Body-local sibling of push_intrinsic.

Source

pub fn push_copy( &mut self, src: ValueId, dst: impl Into<ValueId>, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Creates a copy instruction from src to dst. Note that dst must already exist as a Value in the current context, and this will not create a new temporary value. If dst is a varnode, we aren’t allowed to write to it, this is a store operation If src is a varnode, we need to read from it first, then write to dst For values wider than 64 bits (e.g. XMM/YMM/ZMM registers), emits one store per 64-bit lane.

Source

pub fn push_copy_local( &mut self, src: LocalValueId, dst: LocalValueId, ) -> LocalInsnId

Body-local sibling of push_copy.

Source

pub fn push_store( &mut self, src: ValueId, ptr: ValueId, space: impl Into<LocalMemorySpaceId>, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_store_local( &mut self, src: LocalValueId, ptr: LocalValueId, space: impl Into<LocalMemorySpaceId>, ) -> LocalInsnId

Body-local sibling of push_store.

Source

pub fn push_param(&mut self, size: usize) -> BlockParamId

Declares a new parameter on the current block.

Source

pub fn push_param_local(&mut self, size: usize) -> LocalParamId

Body-local sibling of push_param.

Source

pub fn finalize(self, target: BlockId)

Terminates the current block with a branch to an already-resolved local target. Module/address discovery must happen before the Builder borrow.

Source

pub fn finalize_local(&mut self, target: LocalBlockId)

Body-local sibling of finalize.

Source

pub fn push_branch( &mut self, target: BlockId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Terminates this block with an unconditional jump to the given target block. The builder is now safe to drop without panicking, and the block is properly terminated.

Source

pub fn push_branch_local(&mut self, target: LocalBlockId) -> LocalInsnId

Body-local sibling of push_branch.

Source

pub fn push_branch_with_args( &mut self, target: BlockId, args: Vec<ValueId>, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Unconditional branch passing args to the target block’s parameters.

Source

pub fn push_branch_with_args_local( &mut self, target: LocalBlockId, args: Vec<LocalValueId>, ) -> LocalInsnId

Body-local sibling of push_branch_with_args.

Source

pub fn push_cbranch( &mut self, condition: ValueId, target: BlockId, fallthrough: BlockId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_cbranch_local( &mut self, condition: LocalValueId, target: LocalBlockId, fallthrough: LocalBlockId, ) -> LocalInsnId

Body-local sibling of push_cbranch.

Source

pub fn push_cbranch_with_args( &mut self, condition: ValueId, target: BlockId, target_args: Vec<ValueId>, fallthrough: BlockId, fallthrough_args: Vec<ValueId>, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Conditional branch with per-target arguments.

Source

pub fn push_cbranch_with_args_local( &mut self, condition: LocalValueId, target: LocalBlockId, target_args: Vec<LocalValueId>, fallthrough: LocalBlockId, fallthrough_args: Vec<LocalValueId>, ) -> LocalInsnId

Body-local sibling of push_cbranch_with_args.

Source

pub fn push_switch( &mut self, scrutinee: ValueId, cases: Vec<(u64, BlockId, Vec<ValueId>)>, default: Option<(BlockId, Vec<ValueId>)>, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Multi-way dispatch on scrutinee. Wires a CFG edge to every arm and to the default, exactly as the conditional branch wires its two.

Source

pub fn push_switch_local( &mut self, scrutinee: LocalValueId, cases: Vec<(u64, LocalBlockId, Vec<LocalValueId>)>, default: Option<(LocalBlockId, Vec<LocalValueId>)>, ) -> LocalInsnId

Body-local sibling of push_switch.

Source

pub fn push_branchind( &mut self, ptr: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_branchind_local(&mut self, ptr: LocalValueId) -> LocalInsnId

Body-local sibling of push_branchind.

Source

pub fn push_call( &mut self, target: impl Into<Callee>, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_call_with_args( &mut self, target: impl Into<Callee>, args: Vec<ValueId>, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_call_local(&mut self, target: impl Into<Callee>) -> LocalInsnId

Body-local sibling of push_call.

Source

pub fn push_call_with_args_local( &mut self, target: impl Into<Callee>, args: Vec<LocalValueId>, ) -> LocalInsnId

Body-local sibling of push_call_with_args.

Source

pub fn push_tail_call( &mut self, target: impl Into<Callee>, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Tail call to another function’s entry — a function-level terminator with no intra-function CFG successor (see TailCall). Unlike push_branch, this wires no CFG edge: control leaves the function.

Source

pub fn push_tail_call_with_args( &mut self, target: impl Into<Callee>, args: Vec<ValueId>, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_tail_call_local(&mut self, target: impl Into<Callee>) -> LocalInsnId

Body-local sibling of push_tail_call.

Source

pub fn push_tail_call_with_args_local( &mut self, target: impl Into<Callee>, args: Vec<LocalValueId>, ) -> LocalInsnId

Body-local sibling of push_tail_call_with_args.

Source

pub fn push_call_ind( &mut self, ptr: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_call_ind_with_args( &mut self, ptr: ValueId, args: Vec<ValueId>, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_call_ind_local(&mut self, ptr: LocalValueId) -> LocalInsnId

Body-local sibling of push_call_ind.

Source

pub fn push_call_ind_with_args_local( &mut self, ptr: LocalValueId, args: Vec<LocalValueId>, ) -> LocalInsnId

Body-local sibling of push_call_ind_with_args.

Source

pub fn push_return( &mut self, ptr: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_return_local(&mut self, ptr: LocalValueId) -> LocalInsnId

Body-local sibling of push_return.

Source

pub fn push_return_with_value( &mut self, value: ValueId, ptr: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_return_with_value_local( &mut self, value: LocalValueId, ptr: LocalValueId, ) -> LocalInsnId

Body-local sibling of push_return_with_value.

Source

pub fn push_return_value( &mut self, value: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Source

pub fn push_bad_insn(&mut self) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Terminate the current block with BadInsn: bytes that did not decode to a valid instruction. No successors, no operands.

Source

pub fn push_bad_insn_local(&mut self) -> LocalInsnId

Body-local sibling of push_bad_insn.

Source

pub fn push_return_value_local(&mut self, value: LocalValueId) -> LocalInsnId

Body-local sibling of push_return_value.

Source

pub fn push_assert( &mut self, condition: ValueId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>

Asserts that a condition holds at this point in execution

Source

pub fn push_assert_local(&mut self, condition: LocalValueId) -> LocalInsnId

Body-local sibling of push_assert.

Auto Trait Implementations§

§

impl<'str, 'ctx> !UnwindSafe for Builder<'str, 'ctx>

§

impl<'str, 'ctx> Freeze for Builder<'str, 'ctx>

§

impl<'str, 'ctx> RefUnwindSafe for Builder<'str, 'ctx>

§

impl<'str, 'ctx> Send for Builder<'str, 'ctx>

§

impl<'str, 'ctx> Sync for Builder<'str, 'ctx>

§

impl<'str, 'ctx> Unpin for Builder<'str, 'ctx>

§

impl<'str, 'ctx> UnsafeUnpin for Builder<'str, 'ctx>

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.