cranelift_codegen::ir::instructions

Type Alias ValueList

Source
pub type ValueList = EntityList<Value>;
Expand description

Some instructions use an external list of argument values because there is not enough space in the 16-byte InstructionData struct. These value lists are stored in a memory pool in dfg.value_lists.

Aliased Type§

struct ValueList { /* private fields */ }

Implementations

Source§

impl<T> EntityList<T>

Source

pub fn new() -> EntityList<T>

Create a new empty list.

Source

pub fn from_slice(slice: &[T], pool: &mut ListPool<T>) -> EntityList<T>

Create a new list with the contents initialized from a slice.

Source

pub fn is_empty(&self) -> bool

Returns true if the list has a length of 0.

Source

pub fn len(&self, pool: &ListPool<T>) -> usize

Get the number of elements in the list.

Source

pub fn is_valid(&self, pool: &ListPool<T>) -> bool

Returns true if the list is valid

Source

pub fn as_slice<'a>(&self, pool: &'a ListPool<T>) -> &'a [T]

Get the list as a slice.

Source

pub fn get(&self, index: usize, pool: &ListPool<T>) -> Option<T>

Get a single element from the list.

Source

pub fn first(&self, pool: &ListPool<T>) -> Option<T>

Get the first element from the list.

Source

pub fn as_mut_slice<'a>(&'a mut self, pool: &'a mut ListPool<T>) -> &'a mut [T]

Get the list as a mutable slice.

Source

pub fn get_mut<'a>( &'a mut self, index: usize, pool: &'a mut ListPool<T>, ) -> Option<&'a mut T>

Get a mutable reference to a single element from the list.

Source

pub fn deep_clone(&self, pool: &mut ListPool<T>) -> EntityList<T>

Create a deep clone of the list, which does not alias the original list.

Source

pub fn clear(&mut self, pool: &mut ListPool<T>)

Removes all elements from the list.

The memory used by the list is put back in the pool.

Source

pub fn take(&mut self) -> EntityList<T>

Take all elements from this list and return them as a new list. Leave this list empty.

This is the equivalent of Option::take().

Source

pub fn push(&mut self, element: T, pool: &mut ListPool<T>) -> usize

Appends an element to the back of the list. Returns the index where the element was inserted.

Source

pub fn from_iter<I>(elements: I, pool: &mut ListPool<T>) -> EntityList<T>
where I: IntoIterator<Item = T>,

Constructs a list from an iterator.

Source

pub fn extend<I>(&mut self, elements: I, pool: &mut ListPool<T>)
where I: IntoIterator<Item = T>,

Appends multiple elements to the back of the list.

Source

pub fn copy_from( &mut self, other: &EntityList<T>, slice: impl RangeBounds<usize>, index: usize, pool: &mut ListPool<T>, )

Copies a slice from an entity list in the same pool to a position in this one.

Will panic if self is the same list as other.

Source

pub fn insert(&mut self, index: usize, element: T, pool: &mut ListPool<T>)

Inserts an element as position index in the list, shifting all elements after it to the right.

Source

pub fn remove(&mut self, index: usize, pool: &mut ListPool<T>)

Removes the element at position index from the list. Potentially linear complexity.

Source

pub fn swap_remove(&mut self, index: usize, pool: &mut ListPool<T>)

Removes the element at index in constant time by switching it with the last element of the list.

Source

pub fn truncate(&mut self, new_len: usize, pool: &mut ListPool<T>)

Shortens the list down to len elements.

Does nothing if the list is already shorter than len.

Source

pub fn grow_at(&mut self, index: usize, count: usize, pool: &mut ListPool<T>)

Grow the list by inserting count elements at index.

The new elements are not initialized, they will contain whatever happened to be in memory. Since the memory comes from the pool, this will be either zero entity references or whatever where in a previously deallocated list.

Trait Implementations

Source§

impl<T> Clone for EntityList<T>

Source§

fn clone(&self) -> EntityList<T>

Returns a copy 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<T> Debug for EntityList<T>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<T> Default for EntityList<T>

Create an empty list.

Source§

fn default() -> EntityList<T>

Returns the “default value” for a type. Read more
Source§

impl<'de, T> Deserialize<'de> for EntityList<T>

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<EntityList<T>, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T> Hash for EntityList<T>

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T> PartialEq for EntityList<T>

Source§

fn eq(&self, other: &EntityList<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T> Serialize for EntityList<T>

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T> Copy for EntityList<T>

Source§

impl<T> Eq for EntityList<T>
where T: Eq + EntityRef + ReservedValue,

Source§

impl<T> StructuralPartialEq for EntityList<T>