Skip to main content

TreeLoop

Struct TreeLoop 

Source
pub struct TreeLoop {
    pub inputargs: Vec<InputArg>,
    pub ops: Vec<Op>,
    pub snapshots: Vec<Snapshot>,
}
Expand description

A completed trace ready for optimization and compilation.

Fields§

§inputargs: Vec<InputArg>

Input arguments to the trace (loop header variables).

§ops: Vec<Op>

The recorded operations, in execution order.

§snapshots: Vec<Snapshot>

opencoder.py parity: per-guard snapshots captured during tracing. Indexed by the guard op’s rd_resume_position.

Implementations§

Source§

impl TreeLoop

Source

pub fn new(inputargs: Vec<InputArg>, ops: Vec<Op>) -> Self

Create a new trace from input arguments and operations.

Source

pub fn with_snapshots( inputargs: Vec<InputArg>, ops: Vec<Op>, snapshots: Vec<Snapshot>, ) -> Self

Create a new trace with snapshots.

Source

pub fn num_ops(&self) -> usize

Number of operations in the trace.

Source

pub fn num_inputargs(&self) -> usize

Number of input arguments.

Source

pub fn is_loop(&self) -> bool

Whether this trace ends with a JUMP (i.e., is a loop).

Source

pub fn is_finished(&self) -> bool

Whether this trace ends with FINISH.

Source

pub fn get_op(&self, opref: OpRef) -> Option<&Op>

Get a reference to the operation at the given OpRef index.

Source

pub fn iter_ops(&self) -> impl Iterator<Item = &Op>

Iterate over all operations.

Source

pub fn iter_guards(&self) -> impl Iterator<Item = &Op>

Iterate over all guard operations.

Source

pub fn num_guards(&self) -> usize

Number of guard operations.

Source

pub fn get_final_op(&self) -> Option<&Op>

Get the final operation (Jump or Finish).

Source

pub fn find_label(&self) -> Option<usize>

Get the Label position (if this is a peeled loop).

Source

pub fn split_at_label(&self) -> (&[Op], &[Op])

Split at Label: returns (preamble_ops, body_ops). If no Label, returns (all_ops, empty).

Source

pub fn inputarg_types(&self) -> Vec<Type>

Get the input arg types.

Source

pub fn get_iter(&self) -> TraceIterator<'_>

Create a trace iterator for this trace.

Source

pub fn check_consistency(&self) -> bool

history.py: check_consistency() Verify that the trace structure is valid.

Source

pub fn free_vars(&self) -> Vec<OpRef>

Get all OpRefs used as arguments but not defined by any op. These are the “free variables” — inputs from outside the trace.

Source

pub fn count_by_category(&self) -> (usize, usize, usize, usize)

Count operations by opcode category.

Source

pub fn cut_trace_from( &self, start: TracePosition, original_boxes: &[OpRef], original_box_types: &[Type], ) -> TreeLoop

opencoder.py CutTrace parity — create a new trace by cutting at the given position. original_boxes become the new inputargs; any OpRef referenced after the cut but defined before it (and not in original_boxes) is re-emitted as a prefix operation (transitive closure of dependencies).

Trait Implementations§

Source§

impl Clone for TreeLoop

Source§

fn clone(&self) -> TreeLoop

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TreeLoop

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 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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 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.