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

An operation operation. Define an operation within a pattern.

pdl.operation operations define operation nodes within a pattern. Within a match sequence, i.e. when directly nested within a pdl.pattern, these operations correspond to input operations, or those that already existing within the MLIR module. Inside of a pdl.rewrite, these operations correspond to operations that should be created as part of the replacement sequence.

pdl.operations are composed of a name, and a set of attribute, operand, and result type values, that map to what those that would be on a constructed instance of that operation. The results of a pdl.operation are a handle to the operation itself. Handles to the results of the operation can be extracted via pdl.result.

Example:

// Define an instance of a `foo.op` operation.
%op = pdl.operation "foo.op"(%arg0, %arg1 : !pdl.value, !pdl.value)
  {"attrA" = %attr0} -> (%type, %type : !pdl.type, !pdl.type)

When used within a matching context, the name of the operation may be omitted.

When used within a rewriting context, i.e. when defined within a pdl.rewrite, all of the result types must be “inferable”. This means that the type must be attributable to either a constant type value or the result type of another entity, such as an attribute, the result of a apply_native_rewrite, or the result type of another operation. If the result type value does not meet any of these criteria, the operation must override the InferTypeOpInterface to ensure that the result types can be inferred.

The operands of the operation are interpreted in the following ways:

  1. A single !pdl.range:

In this case, the single range is treated as all of the operands of the operation.

// Define an instance with single range of operands.
%op = pdl.operation "func.return"(%allArgs : !pdl.range<value>)
  1. A variadic number of either !pdl.value or !pdl.range:

In this case, the inputs are expected to correspond with the operand groups defined on the operation in ODS.

// Given the following operation definition in ODS:
def MyIndirectCallOp {
  let results = (outs FunctionType:$call, Variadic<AnyType>:$args);
}
// We can match the operands as so:
%op = pdl.operation "my.indirect_call"(%call, %args : !pdl.value, !pdl.range<value>)

The results of the operation are interpreted in the following ways:

  1. A single !pdl.range:

In this case, the single range is treated as all of the result types of the operation.

// Define an instance with single range of types.
%allResultTypes = pdl.types
%op = pdl.operation "builtin.unrealized_conversion_cast" -> (%allResultTypes : !pdl.types)
  1. A variadic number of either !pdl.type or !pdl.range:

In this case, the inputs are expected to correspond with the result groups defined on the operation in ODS.

// Given the following operation definition in ODS:
def MyOp {
  let results = (outs SomeType:$result, Variadic<SomeType>:$otherResults);
}
// We can match the results as so:
%result = pdl.type
%otherResults = pdl.types
%op = pdl.operation "foo.op" -> (%result, %otherResults : !pdl.type, !pdl.range<type>)

Implementations§

source§

impl<'c> OperationOperation<'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> ) -> OperationOperationBuilder<'c, Unset, Unset, Unset, Unset, Unset>

Creates a builder.

source

pub fn op(&self) -> Result<OperationResult<'c, '_>, Error>

source

pub fn operand_values( &self ) -> Result<impl Iterator<Item = Value<'c, '_>>, Error>

source

pub fn attribute_values( &self ) -> Result<impl Iterator<Item = Value<'c, '_>>, Error>

source

pub fn type_values(&self) -> Result<impl Iterator<Item = Value<'c, '_>>, Error>

source

pub fn op_name(&self) -> Result<StringAttribute<'c>, Error>

source

pub fn set_op_name(&mut self, value: StringAttribute<'c>)

source

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

source

pub fn attribute_value_names(&self) -> Result<ArrayAttribute<'c>, Error>

source

pub fn set_attribute_value_names(&mut self, value: ArrayAttribute<'c>)

Trait Implementations§

source§

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

source§

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

Converts to this type from the input type.
source§

impl<'c> TryFrom<Operation<'c>> for OperationOperation<'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 OperationOperation<'c>

§

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

§

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

§

impl<'c> Unpin for OperationOperation<'c>

§

impl<'c> UnwindSafe for OperationOperation<'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.