Struct debris_llir::opt::code_stats::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
impl CodeStats
pub fn new(call_graph: CallGraph) -> Self
sourcepub fn check_function_can_write_to(
&self,
blocks: &[BlockId],
values: &FxHashSet<ItemId>
) -> bool
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
pub fn clear(&mut self)
sourcepub fn update(
&mut self,
runtime: &Runtime,
functions: &FxHashMap<BlockId, Function>
)
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.
pub fn add_node(&mut self, node: &Node, id: &(BlockId, usize))
pub fn remove_node(&mut self, node: &Node, id: &(BlockId, usize))
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§
Auto Trait Implementations§
impl RefUnwindSafe for CodeStats
impl Send for CodeStats
impl Sync for CodeStats
impl Unpin for CodeStats
impl UnwindSafe for CodeStats
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