Struct AcirTransformationMap

Source
pub struct AcirTransformationMap {
    old_indices_to_new_indices: HashMap<usize, Vec<usize>>,
}
Expand description

This module can move and decompose acir opcodes into multiple opcodes. The transformation map allows consumers of this module to map metadata they had about the opcodes to the new opcode structure generated after the transformation. ACIR opcodes are stored inside a vector of opcodes. A transformation pass will generate a new vector of opcodes, but each opcode is the result of the transformation of an opcode in the original vector. So we simply keep track of the relation: index of the original opcode -> index of the new opcode in the new vector However we need a vector of new indexes for the map values in the case the old opcode is decomposed into multiple opcodes.

Fields§

§old_indices_to_new_indices: HashMap<usize, Vec<usize>>

Maps the old acir indices to the new acir indices

Implementations§

Source§

impl AcirTransformationMap

Source

fn new(acir_opcode_positions: &[usize]) -> Self

Builds a map from a vector of pointers to the old acir opcodes. The index in the vector is the new opcode index. The value of the vector is where the old opcode index was pointed. E.g: If acir_opcode_positions = 0,1,2,4,5,5,6 that means that old indices 0,1,2,4,5,5,6 are mapped to the new indexes: 0,1,2,3,4,5,6 This gives the following map: 0 -> 0 1 -> 1 2 -> 2 4 -> 3 5 -> [4, 5] 6 -> 6

Source

pub fn new_locations( &self, old_location: OpcodeLocation, ) -> impl Iterator<Item = OpcodeLocation> + '_

Returns the new opcode location(s) corresponding to the old opcode. An OpcodeLocation contains the index of the opcode in the vector of opcodes This function returns the new OpcodeLocation by ‘updating’ the index within the given OpcodeLocation using the AcirTransformationMap. In fact, it does not update the given OpcodeLocation ‘in-memory’ but rather returns a new one, and even a vector of OpcodeLocation’s in case there are multiple new indexes corresponding to the old opcode index.

Source

pub fn new_acir_locations( &self, old_location: AcirOpcodeLocation, ) -> impl Iterator<Item = AcirOpcodeLocation> + '_

This function is similar to new_locations(), but only deals with the AcirOpcodeLocation variant

Trait Implementations§

Source§

impl Debug for AcirTransformationMap

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more