MLIR  16.0.0git
mlir::transform::TransformState Class Reference

The state maintained across applications of various ops implementing the TransformOpInterface. More...

#include "mlir/Dialect/Transform/IR/TransformInterfaces.h"

## Classes

class  Extension
Base class for TransformState extensions that allow TransformState to contain user-specified information in the state object. More...

class  RegionScope
A RAII object maintaining a "stack frame" for a transform IR region. More...

## Public Member Functions

TransformState (Region &region, Operation *root, const TransformOptions &options=TransformOptions())
Creates a state for transform ops living in the given region. More...

OperationgetTopLevel () const
Returns the op at which the transformation state is rooted. More...

ArrayRef< Operation * > getPayloadOps (Value value) const
Returns the list of ops that the given transform IR value corresponds to. More...

Returns the Transform IR handle for the given Payload IR op if it exists in the state, null otherwise. More...

DiagnosedSilenceableFailure applyTransform (TransformOpInterface transform)
Applies the transformation specified by the given transform op and updates the state accordingly. More...

LogicalResult mapBlockArguments (BlockArgument argument, ArrayRef< Operation *> operations)
Records the mapping between a block argument in the transform IR and a list of operations in the payload IR. More...

RegionScope make_region_scope (Region &region)
Creates a new region scope for the given region. More...

template<typename Ty , typename... Args>
Adds a new Extension of the type specified as template parameter, constructing it with the arguments provided. More...

template<typename Ty >
Ty * getExtension ()
Returns the extension of the specified type. More...

template<typename Ty >
void removeExtension ()
Removes the extension of the specified type. More...

## Friends

class RegionScope

## Detailed Description

The state maintained across applications of various ops implementing the TransformOpInterface.

The operations implementing this interface and the surrounding structure are referred to as transform IR. The operations to which transformations apply are referred to as payload IR. The state thus contains the mapping between values defined in the transform IR ops and payload IR ops. It assumes that each value in the transform IR can be used at most once (since transformations are likely to change the payload IR ops the value corresponds to). Checks that transform IR values correspond to disjoint sets of payload IR ops throughout the transformation.

A reference to this class is passed as an argument to "apply" methods of the transform op interface. Thus the "apply" method can call state.getPayloadOps( getSomeOperand() ) to obtain the list of operations associated with its operand and subject to transformation. The method is expected to populate the TransformResults class instance in order to update the mapping. The applyTransform method takes care of propagating the state of TransformResults into the instance of this class.

When applying transform IR operations with regions, the client is expected to create a RegionScope RAII object to create a new "stack frame" for values defined inside the region. The mappings from and to these values will be automatically dropped when the object goes out of scope, typically at the end of the "apply" function of the parent operation. If a region contains blocks with arguments, the client can map those arguments to payload IR ops using "mapBlockArguments".

Definition at line 233 of file TransformInterfaces.h.

## ◆ TransformState()

 transform::TransformState::TransformState ( Region & region, Operation * root, const TransformOptions & options = TransformOptions() )

Creates a state for transform ops living in the given region.

The parent operation of the region. The second argument points to the root operation in the payload IR beind transformed, which may or may not contain the region with transform ops. Additional options can be provided through the trailing configuration object.

Definition at line 26 of file TransformInterfaces.cpp.

## Member Function Documentation

template<typename Ty , typename... Args>
 Ty& mlir::transform::TransformState::addExtension ( Args &&... args )
inline

Adds a new Extension of the type specified as template parameter, constructing it with the arguments provided.

The extension is owned by the TransformState. It is expected that the state does not already have an extension of the same type. Extension constructors are expected to take a reference to TransformState as first argument, automatically supplied by this call.

Definition at line 397 of file TransformInterfaces.h.

References value.

Referenced by checkDoubleConsume().

## ◆ applyTransform()

 DiagnosedSilenceableFailure transform::TransformState::applyTransform ( TransformOpInterface transform )

Applies the transformation specified by the given transform op and updates the state accordingly.

Definition at line 192 of file TransformInterfaces.cpp.

Referenced by checkDoubleConsume(), and forwardTerminatorOperands().

## ◆ getExtension()

template<typename Ty >
 Ty* mlir::transform::TransformState::getExtension ( )
inline

Returns the extension of the specified type.

Definition at line 409 of file TransformInterfaces.h.

References value.

Referenced by forwardTerminatorOperands().

 Value transform::TransformState::getHandleForPayloadOp ( Operation * op ) const

Returns the Transform IR handle for the given Payload IR op if it exists in the state, null otherwise.

Definition at line 47 of file TransformInterfaces.cpp.

 ArrayRef< Operation * > transform::TransformState::getPayloadOps ( Value value ) const

Returns the list of ops that the given transform IR value corresponds to.

This is helpful for transformations that apply to a particular handle.

Definition at line 40 of file TransformInterfaces.cpp.

## ◆ getTopLevel()

 Operation * transform::TransformState::getTopLevel ( ) const

Returns the op at which the transformation state is rooted.

This is typically helpful for transformations that apply globally.

Definition at line 37 of file TransformInterfaces.cpp.

## ◆ make_region_scope()

 TransformState::RegionScope mlir::transform::TransformState::make_region_scope ( Region & region )
inline

Creates a new region scope for the given region.

The region is expected to be nested in the currently processed region.

Definition at line 560 of file TransformInterfaces.h.

Referenced by checkDoubleConsume(), and forwardTerminatorOperands().

## ◆ mapBlockArguments()

 LogicalResult mlir::transform::TransformState::mapBlockArguments ( BlockArgument argument, ArrayRef< Operation *> operations )
inline

Records the mapping between a block argument in the transform IR and a list of operations in the payload IR.

The arguments must be defined in blocks of the currently processed transform IR region, typically after a region scope is defined.

Definition at line 278 of file TransformInterfaces.h.

References mlir::Region::back(), and mlir::Value::getParentRegion().

## ◆ removeExtension()

template<typename Ty >
 void mlir::transform::TransformState::removeExtension ( )
inline

Removes the extension of the specified type.

Definition at line 421 of file TransformInterfaces.h.

Referenced by checkDoubleConsume().

## ◆ RegionScope

 friend class RegionScope
friend

Definition at line 336 of file TransformInterfaces.h.

The documentation for this class was generated from the following files: