pub struct ReallocOperation<'c> { /* private fields */ }
Expand description

A realloc operation. Memory reallocation operation.

The realloc operation changes the size of a memory region. The memory region is specified by a 1D source memref and the size of the new memory region is specified by a 1D result memref type and an optional dynamic Value of Index type. The source and the result memref must be in the same memory space and have the same element type.

The operation may move the memory region to a new location. In this case, the content of the memory block is preserved up to the lesser of the new and old sizes. If the new size if larger, the value of the extended memory is undefined. This is consistent with the ISO C realloc.

The operation returns an SSA value for the memref.

Example:

%0 = memref.realloc %src : memref<64xf32> to memref<124xf32>

The source memref may have a dynamic shape, in which case, the compiler will generate code to extract its size from the runtime data structure for the memref.

%1 = memref.realloc %src : memref<?xf32> to memref<124xf32>

If the result memref has a dynamic shape, a result dimension operand is needed to spefify its dynamic dimension. In the example below, the ssa value ‘%d’ specifies the unknown dimension of the result memref.

%2 = memref.realloc %src(%d) : memref<?xf32> to memref<?xf32>

An optional alignment attribute may be specified to ensure that the region of memory that will be indexed is aligned at the specified byte boundary. This is consistent with the fact that memref.alloc supports such an optional alignment attribute. Note that in ISO C standard, neither alloc nor realloc supports alignment, though there is aligned_alloc but not aligned_realloc.

%3 = memref.realloc %src {alignment = 8} : memref<64xf32> to memref<124xf32>

Referencing the memref through the old SSA value after realloc is undefined behavior.

%new = memref.realloc %old : memref<64xf32> to memref<124xf32>
%4 = memref.load %new[%index]   // ok
%5 = memref.load %old[%index]   // undefined behavior

Implementations§

source§

impl<'c> ReallocOperation<'c>

source

pub fn name() -> &'static str

Returns a name.

source

pub fn as_operation(&self) -> &Operation<'c>

Returns a generic operation.

source

pub fn builder( context: &'c Context, location: Location<'c> ) -> ReallocOperationBuilder<'c, Unset>

Creates a builder.

source

pub fn source(&self) -> Result<Value<'c, '_>, Error>

source

pub fn dynamic_result_size(&self) -> Result<Value<'c, '_>, Error>

source

pub fn alignment(&self) -> Result<IntegerAttribute<'c>, Error>

source

pub fn set_alignment(&mut self, value: IntegerAttribute<'c>)

source

pub fn remove_alignment(&mut self) -> Result<(), Error>

Trait Implementations§

source§

impl<'c> From<ReallocOperation<'c>> for Operation<'c>

source§

fn from(operation: ReallocOperation<'c>) -> Self

Converts to this type from the input type.
source§

impl<'c> TryFrom<Operation<'c>> for ReallocOperation<'c>

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(operation: Operation<'c>) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl<'c> RefUnwindSafe for ReallocOperation<'c>

§

impl<'c> !Send for ReallocOperation<'c>

§

impl<'c> !Sync for ReallocOperation<'c>

§

impl<'c> Unpin for ReallocOperation<'c>

§

impl<'c> UnwindSafe for ReallocOperation<'c>

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.

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, U> TryFrom<U> for T
where 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 T
where 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.