MLIR
20.0.0git
|
The state maintained across applications of various ops implementing the TransformOpInterface. More...
#include "mlir/Dialect/Transform/Interfaces/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 Types | |
using | Param = transform::Param |
Public Member Functions | |
const TransformOptions & | getOptions () const |
Operation * | getTopLevel () const |
Returns the op at which the transformation state is rooted. More... | |
size_t | getNumTopLevelMappings () const |
Returns the number of extra mappings for the top-level operation. More... | |
ArrayRef< MappedValue > | getTopLevelMapping (size_t position) const |
Returns the position-th extra mapping for the top-level operation. More... | |
auto | getPayloadOps (Value value) const |
Returns an iterator that enumerates all ops that the given transform IR value corresponds to. More... | |
ArrayRef< Attribute > | getParams (Value value) const |
Returns the list of parameters that the given transform IR value corresponds to. More... | |
auto | getPayloadValues (Value handleValue) const |
Returns an iterator that enumerates all payload IR values that the given transform IR value corresponds to. More... | |
LogicalResult | getHandlesForPayloadOp (Operation *op, SmallVectorImpl< Value > &handles, bool includeOutOfScope=false) const |
Populates handles with all handles pointing to the given Payload IR op. More... | |
LogicalResult | getHandlesForPayloadValue (Value payloadValue, SmallVectorImpl< Value > &handles, bool includeOutOfScope=false) const |
Populates handles with all handles pointing to the given payload IR value. 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... | |
LogicalResult | mapBlockArgument (BlockArgument argument, ArrayRef< MappedValue > values) |
LogicalResult | mapBlockArguments (Block::BlockArgListType arguments, ArrayRef< SmallVector< MappedValue >> mapping) |
RegionScope | make_region_scope (Region ®ion) |
Creates a new region scope for the given region. More... | |
template<typename Ty , typename... Args> | |
Ty & | addExtension (Args &&...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 |
LogicalResult | applyTransforms (Operation *, TransformOpInterface, const RaggedArray< MappedValue > &, const TransformOptions &, bool, function_ref< void(TransformState &)>, function_ref< LogicalResult(TransformState &)>) |
Entry point to the Transform dialect infrastructure. More... | |
TransformState | detail::makeTransformStateForTesting (Region *region, Operation *payloadRoot) |
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. Transform IR operates on values that can be associated either with a list of payload IR operations (such values are referred to as handles) or with a list of parameters represented as attributes. The state thus contains the mapping between values defined in the transform IR ops and either payload IR ops or parameters. For payload ops, the mapping is many-to-many and the reverse mapping is also stored. The "expensive-checks" option can be passed to the constructor at transformation execution time that transform IR values used as operands by a transform IR operation are not associated with dangling pointers to payload IR operations that are known to have been erased by previous transformation through the same or a different transform IR value.
A reference to this class is passed as an argument to "apply" methods of the transform op interface. Thus the "apply" method can call either state.getPayloadOps( getSomeOperand() )
to obtain the list of operations or state.getParams( getSomeOperand() )
to obtain the list of parameters associated with its operand. 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 173 of file TransformInterfaces.h.
Definition at line 175 of file TransformInterfaces.h.
|
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 452 of file TransformInterfaces.h.
DiagnosedSilenceableFailure transform::TransformState::applyTransform | ( | TransformOpInterface | transform | ) |
Applies the transformation specified by the given transform op and updates the state accordingly.
Definition at line 820 of file TransformInterfaces.cpp.
References mlir::DiagnosedSilenceableFailure::attachNote(), mlir::transform::ErrorCheckingTrackingListener::checkAndResetError(), DBGS, DEBUG_PRINT_AFTER_ALL, DEBUG_TYPE_FULL, mlir::DiagnosedSilenceableFailure::definiteFailure(), diag(), mlir::emitDefiniteFailure(), FULL_LDBG, mlir::Value::getDefiningOp(), mlir::Value::getLoc(), mlir::DiagnosedSilenceableFailure::getMessage(), mlir::Operation::getResults(), mlir::Value::getType(), mlir::DiagnosedSilenceableFailure::isDefiniteFailure(), mlir::transform::isHandleConsumed(), mlir::DiagnosedSilenceableFailure::isSilenceableFailure(), options, mlir::transform::TransformResults::setRemainingToEmpty(), mlir::DiagnosedSilenceableFailure::silence(), mlir::transform::TrackingListenerConfig::skipHandleFn, mlir::DiagnosedSilenceableFailure::succeeded(), and mlir::DiagnosedSilenceableFailure::success().
|
inline |
Returns the extension of the specified type.
Definition at line 464 of file TransformInterfaces.h.
LogicalResult transform::TransformState::getHandlesForPayloadOp | ( | Operation * | op, |
SmallVectorImpl< Value > & | handles, | ||
bool | includeOutOfScope = false |
||
) | const |
Populates handles
with all handles pointing to the given Payload IR op.
Returns success if such handles exist, failure otherwise. If includeOutOfScope
is set to "true", handles that are defined in regions beyond the most recent isolated from above region are included.
Definition at line 96 of file TransformInterfaces.cpp.
References mlir::Region::getParentOp(), and mlir::Operation::hasTrait().
LogicalResult transform::TransformState::getHandlesForPayloadValue | ( | Value | payloadValue, |
SmallVectorImpl< Value > & | handles, | ||
bool | includeOutOfScope = false |
||
) | const |
Populates handles
with all handles pointing to the given payload IR value.
Returns success if such handles exist, failure otherwise. If includeOutOfScope
is set to "true", handles that are defined in regions beyond the most recent isolated from above region are included.
Definition at line 115 of file TransformInterfaces.cpp.
References mlir::Region::getParentOp(), and mlir::Operation::hasTrait().
|
inline |
Returns the number of extra mappings for the top-level operation.
Definition at line 237 of file TransformInterfaces.h.
|
inline |
Definition at line 230 of file TransformInterfaces.h.
Returns the list of parameters that the given transform IR value corresponds to.
Definition at line 79 of file TransformInterfaces.cpp.
|
inline |
Returns an iterator that enumerates all ops that the given transform IR value corresponds to.
Ops may be erased while iterating; erased ops are not enumerated. This function is helpful for transformations that apply to a particular handle.
Definition at line 248 of file TransformInterfaces.h.
|
inline |
Returns an iterator that enumerates all payload IR values that the given transform IR value corresponds to.
Definition at line 277 of file TransformInterfaces.h.
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 67 of file TransformInterfaces.cpp.
|
inline |
Returns the position-th extra mapping for the top-level operation.
Definition at line 240 of file TransformInterfaces.h.
|
inline |
Creates a new region scope for the given region.
Creates a RAII object the lifetime of which corresponds to the new mapping for transform IR values defined in the given region.
The region is expected to be nested in the currently processed region.
Values defined in surrounding regions remain accessible.
Definition at line 937 of file TransformInterfaces.h.
References RegionScope.
LogicalResult transform::TransformState::mapBlockArgument | ( | BlockArgument | argument, |
ArrayRef< MappedValue > | values | ||
) |
Definition at line 192 of file TransformInterfaces.cpp.
References dispatchMappedValues().
LogicalResult transform::TransformState::mapBlockArguments | ( | Block::BlockArgListType | arguments, |
ArrayRef< SmallVector< MappedValue >> | mapping | ||
) |
Definition at line 208 of file TransformInterfaces.cpp.
|
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.
Returns failure if the payload does not satisfy the conditions associated with the type of the handle value.
Definition at line 326 of file TransformInterfaces.h.
References mlir::Value::getParentRegion().
|
inline |
Removes the extension of the specified type.
Definition at line 476 of file TransformInterfaces.h.
|
friend |
Entry point to the Transform dialect infrastructure.
Applies the transformation specified by transform
to payload IR contained in payloadRoot
. The transform
operation may contain other operations that will be executed following the internal logic of the operation. It must have the PossibleTopLevelTransformOp
trait and not have any operands. This function internally keeps track of the transformation state.
|
friend |
|
friend |
Definition at line 382 of file TransformInterfaces.h.
Referenced by make_region_scope().