pub struct Function {
pub name: Ident,
pub selector: Option<[u8; 4]>,
pub attributes: FunctionAttributes,
pub params: Vec<MirType>,
pub returns: Vec<MirType>,
pub internal_frame_size: u64,
pub external_static_return_size: u64,
pub values: IndexVec<ValueId, Value>,
pub instructions: IndexVec<InstId, Instruction>,
pub blocks: IndexVec<BlockId, BasicBlock>,
pub entry_block: BlockId,
}Expand description
A function in the MIR.
Fields§
§name: IdentFunction name.
selector: Option<[u8; 4]>Function selector (4 bytes, for external functions).
attributes: FunctionAttributesFunction attributes.
params: Vec<MirType>Parameter types.
returns: Vec<MirType>Return types.
internal_frame_size: u64Bytes reserved for lowered local memory slots.
Internal-call functions place these in the internal frame; external entries reserve the same space in their low-memory scratch layout.
external_static_return_size: u64Bytes reserved for the low-memory external ABI return buffer.
values: IndexVec<ValueId, Value>All values in this function.
instructions: IndexVec<InstId, Instruction>All instructions in this function.
blocks: IndexVec<BlockId, BasicBlock>All basic blocks in this function.
entry_block: BlockIdThe entry block.
Implementations§
Source§impl Function
impl Function
Sourcepub fn value_u256(&self, id: ValueId) -> Option<Uint<256, 4>>
pub fn value_u256(&self, id: ValueId) -> Option<Uint<256, 4>>
Returns an immediate value as U256.
Sourcepub fn value_u64(&self, id: ValueId) -> Option<u64>
pub fn value_u64(&self, id: ValueId) -> Option<u64>
Returns an immediate value as u64 when lossless.
Sourcepub fn value_u256_after_replacements(
&self,
id: ValueId,
replacements: &HashMap<ValueId, ValueId, FxBuildHasher>,
) -> Option<Uint<256, 4>>
pub fn value_u256_after_replacements( &self, id: ValueId, replacements: &HashMap<ValueId, ValueId, FxBuildHasher>, ) -> Option<Uint<256, 4>>
Returns a possibly replaced immediate value as U256.
Sourcepub fn memory_region_for_addr(&self, addr: ValueId) -> MemoryRegion
pub fn memory_region_for_addr(&self, addr: ValueId) -> MemoryRegion
Returns the statically known memory region for an address value.
Sourcepub fn instruction(&self, id: InstId) -> &Instruction
pub fn instruction(&self, id: InstId) -> &Instruction
Returns the instruction for the given ID.
Sourcepub fn inst_result_value(&self, id: InstId) -> Option<ValueId>
pub fn inst_result_value(&self, id: InstId) -> Option<ValueId>
Returns the value produced by the given instruction, if it has one.
Sourcepub fn inst_results(&self) -> HashMap<InstId, ValueId, FxBuildHasher>
pub fn inst_results(&self) -> HashMap<InstId, ValueId, FxBuildHasher>
Returns a map from each instruction to its result value.
Sourcepub fn inst_blocks(&self) -> HashMap<InstId, BlockId, FxBuildHasher>
pub fn inst_blocks(&self) -> HashMap<InstId, BlockId, FxBuildHasher>
Returns a map from each instruction to the block containing it.
Sourcepub fn unique_predecessors(&self, block: BlockId) -> Vec<BlockId>
pub fn unique_predecessors(&self, block: BlockId) -> Vec<BlockId>
Returns predecessors with duplicate CFG edges collapsed.
Sourcepub fn block_has_phi(&self, block: BlockId) -> bool
pub fn block_has_phi(&self, block: BlockId) -> bool
Returns true if the block contains any phi instruction.
Sourcepub fn block_has_only_phis(&self, block: BlockId) -> bool
pub fn block_has_only_phis(&self, block: BlockId) -> bool
Returns true if every instruction in the block is a phi instruction.
Sourcepub fn block_phi_results(
&self,
block: BlockId,
) -> HashSet<ValueId, FxBuildHasher>
pub fn block_phi_results( &self, block: BlockId, ) -> HashSet<ValueId, FxBuildHasher>
Returns the result values produced by phi instructions in the block.
Sourcepub fn block(&self, id: BlockId) -> &BasicBlock
pub fn block(&self, id: BlockId) -> &BasicBlock
Returns the basic block for the given ID.
Sourcepub fn block_mut(&mut self, id: BlockId) -> &mut BasicBlock
pub fn block_mut(&mut self, id: BlockId) -> &mut BasicBlock
Returns a mutable reference to the basic block.
Sourcepub fn entry(&self) -> &BasicBlock
pub fn entry(&self) -> &BasicBlock
Returns the entry block.
Sourcepub fn alloc_value(&mut self, value: Value) -> ValueId
pub fn alloc_value(&mut self, value: Value) -> ValueId
Allocates a new value.
Sourcepub fn alloc_inst(&mut self, inst: Instruction) -> InstId
pub fn alloc_inst(&mut self, inst: Instruction) -> InstId
Allocates a new instruction.
Sourcepub fn alloc_block(&mut self) -> BlockId
pub fn alloc_block(&mut self) -> BlockId
Allocates a new basic block.
Sourcepub fn replace_uses(
&mut self,
replacements: &HashMap<ValueId, ValueId, FxBuildHasher>,
)
pub fn replace_uses( &mut self, replacements: &HashMap<ValueId, ValueId, FxBuildHasher>, )
Replaces all value uses according to a one-step replacement map.
Sourcepub fn replace_uses_canonicalized(
&mut self,
replacements: &HashMap<ValueId, ValueId, FxBuildHasher>,
)
pub fn replace_uses_canonicalized( &mut self, replacements: &HashMap<ValueId, ValueId, FxBuildHasher>, )
Replaces all value uses according to a canonicalized replacement map.
Sourcepub fn storage_alias(&self, inst_id: InstId, slot: ValueId) -> StorageAlias
pub fn storage_alias(&self, inst_id: InstId, slot: ValueId) -> StorageAlias
Returns stored storage-alias metadata, or computes a conservative alias key.
Sourcepub fn storage_alias_after_replacements(
&self,
inst_id: InstId,
slot: ValueId,
replacements: &HashMap<ValueId, ValueId, FxBuildHasher>,
) -> StorageAlias
pub fn storage_alias_after_replacements( &self, inst_id: InstId, slot: ValueId, replacements: &HashMap<ValueId, ValueId, FxBuildHasher>, ) -> StorageAlias
Returns storage-alias metadata after applying value replacements.
Sourcepub fn selector_hex(&self) -> Option<String>
pub fn selector_hex(&self) -> Option<String>
Returns the function selector as a hex string.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Function
impl RefUnwindSafe for Function
impl Send for Function
impl Sync for Function
impl Unpin for Function
impl UnsafeUnpin for Function
impl UnwindSafe for Function
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more