Struct debris_llir::CodeStats

source ·
pub struct CodeStats {
    pub variable_information: FxHashMap<ItemId, VariableUsage>,
    pub function_calls: FxHashMap<BlockId, usize>,
    pub call_graph: CallGraph,
    pub function_parameters: FunctionParameters,
    visited_functions: FxHashSet<BlockId>,
}
Expand description

tracks statistics about the global code which can be used to allow some optimizations

Fields§

§variable_information: FxHashMap<ItemId, VariableUsage>§function_calls: FxHashMap<BlockId, usize>§call_graph: CallGraph§function_parameters: FunctionParameters

Tracks which parameters a function takes. Due to the incremental updates, a function can declare to read a variable, Even if that is not the case anymore. It will never declare to not read a variable if it does so, though.

§visited_functions: FxHashSet<BlockId>

This local variable is cached, so no repeated allocations are required

Implementations§

source§

impl CodeStats

source

pub fn new(call_graph: CallGraph) -> Self

source

pub fn check_function_can_write_to( &self, blocks: &[BlockId], values: &FxHashSet<ItemId> ) -> bool

This function returns whether the call graph of any block of blocks can possibly write to any of the given variables

source

pub fn clear(&mut self)

source

pub fn update( &mut self, runtime: &Runtime, functions: &FxHashMap<BlockId, Function> )

Updates the variable reads and writes. The iterator does not technically need to give mutable nodes. However, due to some rust limitations (how to abstract over & and &mut at the same time?) Mutable references are required.

source

pub fn add_node(&mut self, node: &Node, id: &(BlockId, usize))

source

pub fn remove_node(&mut self, node: &Node, id: &(BlockId, usize))

source

fn update_node<FR, FW>( &mut self, node: &Node, read: FR, write: FW, block: Option<BlockId> )where FR: Fn(&mut VariableUsage), FW: Fn(&mut VariableUsage, Option<i32>),

Trait Implementations§

source§

impl Debug for CodeStats

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.