MLIR  19.0.0git
Classes | Functions
mlir::transform::detail Namespace Reference

Classes

class  TransformDialectDataBase
 Concrete base class for CRTP TransformDialectDataBase. More...
 

Functions

LogicalResult verifyStructuredOpPredicateOpTrait (Operation *op, Value structuredOpHandle)
 
template<typename OpTy >
DiagnosedSilenceableFailure matchOptionalOperation (OpTy op, TransformResults &results, TransformState &state)
 Dispatch matchOperation based on Operation* or std::optional<Operation*> first operand. More...
 
LogicalResult mapPossibleTopLevelTransformOpBlockArguments (TransformState &state, Operation *op, Region &region)
 Maps the only block argument of the op with PossibleTopLevelTransformOpTrait to either the list of operations associated with its operand or the root of the payload IR, depending on what is available in the context. More...
 
LogicalResult verifyPossibleTopLevelTransformOpTrait (Operation *op)
 Verification hook for PossibleTopLevelTransformOpTrait. More...
 
void getPotentialTopLevelEffects (Operation *operation, Value root, Block &body, SmallVectorImpl< MemoryEffects::EffectInstance > &effects)
 Populates effects with side effects implied by PossibleTopLevelTransformOpTrait for the given operation. More...
 
LogicalResult verifyTransformOpInterface (Operation *op)
 Verification hook for TransformOpInterface. More...
 
LogicalResult appendValueMappings (MutableArrayRef< SmallVector< transform::MappedValue >> mappings, ValueRange values, const transform::TransformState &state, bool flatten=true)
 Appends the entities associated with the given transform values in state to the pre-existing list of mappings. More...
 
void prepareValueMappings (SmallVectorImpl< SmallVector< transform::MappedValue >> &mappings, ValueRange values, const transform::TransformState &state)
 Populates mappings with mapped values associated with the given transform IR values in the given state. More...
 
void forwardTerminatorOperands (Block *block, transform::TransformState &state, transform::TransformResults &results)
 Populates results with payload associations that match exactly those of the operands to block's terminator. More...
 
TransformState makeTransformStateForTesting (Region *region, Operation *payloadRoot)
 Make a dummy transform state for testing purposes. More...
 
SmallVector< OpOperand * > getConsumedHandleOpOperands (transform::TransformOpInterface transformOp)
 Returns all operands that are handles and being consumed by the given op. More...
 
void getParamProducerTransformOpTraitEffects (Operation *op, SmallVectorImpl< MemoryEffects::EffectInstance > &effects)
 Non-template implementation of ParamProducerTransformOpTrait::getEffects(). More...
 
LogicalResult verifyParamProducerTransformOpTrait (Operation *op)
 Non-template implementation of ParamProducerTransformOpTrait::verify(). More...
 
LogicalResult checkApplyToOne (Operation *transformOp, Location payloadOpLoc, const ApplyToEachResultList &partialResult)
 Check that the contents of partialResult matches the number, kind (payload op or parameter) and nullity (either all or none) requirements of transformOp. More...
 
void setApplyToOneResults (Operation *transformOp, TransformResults &transformResults, ArrayRef< ApplyToEachResultList > results)
 "Transpose" the results produced by individual applications, arranging them per result value of the transform op, and populate transformResults with that. More...
 
template<typename TransformOpTy , typename Range >
DiagnosedSilenceableFailure applyTransformToEach (TransformOpTy transformOp, TransformRewriter &rewriter, Range &&targets, SmallVectorImpl< ApplyToEachResultList > &results, TransformState &state)
 Applies a one-to-one or a one-to-many transform to each of the given targets. More...
 
LogicalResult checkNestedConsumption (Location loc, ArrayRef< Operation * > targets)
 Reports an error and returns failure if targets contains an ancestor operation before its descendant (or a copy of itself). More...
 
void checkImplementsTransformOpInterface (StringRef name, MLIRContext *context)
 Asserts that the operations provided as template arguments implement the TransformOpInterface and MemoryEffectsOpInterface. More...
 
void checkImplementsTransformHandleTypeInterface (TypeID typeID, MLIRContext *context)
 Asserts that the type provided as template argument implements the TransformHandleTypeInterface. More...
 
InFlightDiagnostic mergeSymbolsInto (Operation *target, OwningOpRef< Operation * > other)
 Merge all symbols from other into target. More...
 
LogicalResult expandPathsToMLIRFiles (ArrayRef< std::string > paths, MLIRContext *context, SmallVectorImpl< std::string > &fileNames)
 Expands the given list of paths to a list of .mlir files. More...
 
LogicalResult parseTransformModuleFromFile (MLIRContext *context, llvm::StringRef transformFileName, OwningOpRef< ModuleOp > &transformModule)
 Utility to parse and verify the content of a transformFileName MLIR file containing a transform dialect specification. More...
 
LogicalResult assembleTransformLibraryFromPaths (MLIRContext *context, ArrayRef< std::string > transformLibraryPaths, OwningOpRef< ModuleOp > &transformModule)
 Utility to parse, verify, aggregate and link the content of all mlir files nested under transformLibraryPaths and containing transform dialect specifications. More...
 
ModuleOp getPreloadedTransformModule (MLIRContext *context)
 Utility to load a transform interpreter module from a module that has already been preloaded in the context. More...
 
TransformOpInterface findTransformEntryPoint (Operation *root, ModuleOp module, StringRef entryPoint=TransformDialect::kTransformEntryPointSymbolName)
 Finds the first TransformOpInterface named kTransformEntryPointSymbolName that is either: More...
 

Function Documentation

◆ appendValueMappings()

LogicalResult mlir::transform::detail::appendValueMappings ( MutableArrayRef< SmallVector< transform::MappedValue >>  mappings,
ValueRange  values,
const transform::TransformState state,
bool  flatten = true 
)

Appends the entities associated with the given transform values in state to the pre-existing list of mappings.

The array of mappings must have as many elements as values. If flatten is set, multiple values may be associated with each transform value, and this always succeeds. Otherwise, checks that each value has exactly one mapping associated and return failure otherwise.

Definition at line 1539 of file TransformInterfaces.cpp.

◆ applyTransformToEach()

template<typename TransformOpTy , typename Range >
DiagnosedSilenceableFailure mlir::transform::detail::applyTransformToEach ( TransformOpTy  transformOp,
TransformRewriter rewriter,
Range &&  targets,
SmallVectorImpl< ApplyToEachResultList > &  results,
TransformState state 
)

Applies a one-to-one or a one-to-many transform to each of the given targets.

Puts the results of transforms, if any, in results in the same order. Fails if any of the application fails. Individual transforms must be callable with the following signature:

  • DiagnosedSilenceableFailure(OpTy, SmallVector<Operation*> &results, state) where OpTy is either
  • Operation *, in which case the transform is always applied;
  • a concrete Op class, in which case a check is performed whether targets contains operations of the same class and a silenceable failure is reported if it does not.

Definition at line 1482 of file TransformInterfaces.h.

◆ assembleTransformLibraryFromPaths()

LogicalResult mlir::transform::detail::assembleTransformLibraryFromPaths ( MLIRContext context,
ArrayRef< std::string >  transformLibraryPaths,
OwningOpRef< ModuleOp > &  transformModule 
)

Utility to parse, verify, aggregate and link the content of all mlir files nested under transformLibraryPaths and containing transform dialect specifications.

Definition at line 152 of file TransformInterpreterUtils.cpp.

References expandPathsToMLIRFiles(), mlir::OwningOpRef< OpTy >::get(), mlir::get(), mergeSymbolsInto(), and parseTransformModuleFromFile().

◆ checkApplyToOne()

LogicalResult mlir::transform::detail::checkApplyToOne ( Operation transformOp,
Location  payloadOpLoc,
const ApplyToEachResultList partialResult 
)

Check that the contents of partialResult matches the number, kind (payload op or parameter) and nullity (either all or none) requirements of transformOp.

Report errors and return failure otherwise.

Definition at line 1449 of file TransformInterfaces.cpp.

References diag(), emitDiag(), mlir::emitError(), mlir::Operation::getLoc(), mlir::Operation::getName(), mlir::Operation::getNumResults(), mlir::Operation::getResults(), mlir::OperationName::getStringRef(), and mlir::transform::ApplyToEachResultList::size().

◆ checkImplementsTransformHandleTypeInterface()

void mlir::transform::detail::checkImplementsTransformHandleTypeInterface ( TypeID  typeID,
MLIRContext context 
)

Asserts that the type provided as template argument implements the TransformHandleTypeInterface.

This must be a dynamic assertion since interface implementations may be registered at runtime.

Definition at line 47 of file TransformDialect.cpp.

References mlir::AbstractType::lookup().

◆ checkImplementsTransformOpInterface()

void mlir::transform::detail::checkImplementsTransformOpInterface ( StringRef  name,
MLIRContext context 
)

Asserts that the operations provided as template arguments implement the TransformOpInterface and MemoryEffectsOpInterface.

This must be a dynamic assertion since interface implementations may be registered at runtime.

Definition at line 23 of file TransformDialect.cpp.

References mlir::OperationName::hasInterface(), mlir::OperationName::hasTrait(), and mlir::RegisteredOperationName::lookup().

◆ checkNestedConsumption()

LogicalResult mlir::transform::detail::checkNestedConsumption ( Location  loc,
ArrayRef< Operation * >  targets 
)

Reports an error and returns failure if targets contains an ancestor operation before its descendant (or a copy of itself).

Implementation detail for expensive checks during TransformEachOpTrait::apply.

Definition at line 1427 of file TransformInterfaces.cpp.

References diag(), mlir::emitError(), and mlir::detail::enumerate().

◆ expandPathsToMLIRFiles()

LogicalResult mlir::transform::detail::expandPathsToMLIRFiles ( ArrayRef< std::string >  paths,
MLIRContext context,
SmallVectorImpl< std::string > &  fileNames 
)

Expands the given list of paths to a list of .mlir files.

Each entry in paths may either be a regular file, in which case it ends up in the result list, or a directory, in which case all (regular) .mlir files in that directory are added. Any other file types lead to a failure.

Definition at line 41 of file TransformInterpreterUtils.cpp.

References DBGS, mlir::emitError(), and mlir::get().

Referenced by assembleTransformLibraryFromPaths().

◆ findTransformEntryPoint()

transform::TransformOpInterface mlir::transform::detail::findTransformEntryPoint ( Operation root,
ModuleOp  module,
StringRef  entryPoint = TransformDialect::kTransformEntryPointSymbolName 
)

Finds the first TransformOpInterface named kTransformEntryPointSymbolName that is either:

  1. nested under root (takes precedence).
  2. nested under module, if not found in root. Reports errors and returns null if no such operation found.

Definition at line 127 of file TransformInterpreterUtils.cpp.

◆ forwardTerminatorOperands()

void mlir::transform::detail::forwardTerminatorOperands ( Block block,
transform::TransformState state,
transform::TransformResults results 
)

Populates results with payload associations that match exactly those of the operands to block's terminator.

Definition at line 1572 of file TransformInterfaces.cpp.

◆ getConsumedHandleOpOperands()

SmallVector<OpOperand *> mlir::transform::detail::getConsumedHandleOpOperands ( transform::TransformOpInterface  transformOp)

Returns all operands that are handles and being consumed by the given op.

◆ getParamProducerTransformOpTraitEffects()

void mlir::transform::detail::getParamProducerTransformOpTraitEffects ( Operation op,
SmallVectorImpl< MemoryEffects::EffectInstance > &  effects 
)

◆ getPotentialTopLevelEffects()

void mlir::transform::detail::getPotentialTopLevelEffects ( Operation operation,
Value  root,
Block body,
SmallVectorImpl< MemoryEffects::EffectInstance > &  effects 
)

Populates effects with side effects implied by PossibleTopLevelTransformOpTrait for the given operation.

The operation may have an optional root operand, indicating it is not in fact top-level. It is also expected to have a single-block body.

Definition at line 1635 of file TransformInterfaces.cpp.

References mlir::Operation::getOpOperands(), mlir::Operation::getOpResults(), mlir::transform::onlyReadsHandle(), and mlir::transform::producesHandle().

Referenced by mlir::transform::PossibleTopLevelTransformOpTrait< OpTy >::getPotentialTopLevelEffects().

◆ getPreloadedTransformModule()

ModuleOp mlir::transform::detail::getPreloadedTransformModule ( MLIRContext context)

Utility to load a transform interpreter module from a module that has already been preloaded in the context.

This mode is useful in cases where explicit parsing of a transform library from file is expected to be prohibitively expensive. In such cases, the transform module is expected to be found in the preloaded library modules of the transform dialect. Returns null if the module is not found.

Definition at line 121 of file TransformInterpreterUtils.cpp.

References mlir::MLIRContext::getOrLoadDialect().

◆ makeTransformStateForTesting()

transform::TransformState mlir::transform::detail::makeTransformStateForTesting ( Region region,
Operation payloadRoot 
)

Make a dummy transform state for testing purposes.

This MUST NOT be used outside of test cases.

Definition at line 1593 of file TransformInterfaces.cpp.

◆ mapPossibleTopLevelTransformOpBlockArguments()

LogicalResult mlir::transform::detail::mapPossibleTopLevelTransformOpBlockArguments ( TransformState state,
Operation op,
Region region 
)

Maps the only block argument of the op with PossibleTopLevelTransformOpTrait to either the list of operations associated with its operand or the root of the payload IR, depending on what is available in the context.

Definition at line 1658 of file TransformInterfaces.cpp.

◆ matchOptionalOperation()

template<typename OpTy >
DiagnosedSilenceableFailure mlir::transform::detail::matchOptionalOperation ( OpTy  op,
TransformResults results,
TransformState state 
)

Dispatch matchOperation based on Operation* or std::optional<Operation*> first operand.

Definition at line 27 of file MatchInterfaces.h.

◆ mergeSymbolsInto()

InFlightDiagnostic mlir::transform::detail::mergeSymbolsInto ( Operation target,
OwningOpRef< Operation * >  other 
)

Merge all symbols from other into target.

Both ops need to implement the SymbolTable trait. Operations are moved from other, i.e., other may be modified by this function and might not verify after the function returns. Upon merging, private symbols may be renamed in order to avoid collisions in the result. Public symbols may not collide, with the exception of instances of SymbolOpInterface, where collisions are allowed if at least one of the two is external, in which case the other op preserved (or any one of the two if both are external).

Definition at line 79 of file Utils.cpp.

References DBGS, and mlir::Operation::hasTrait().

Referenced by mlir::transform::applyTransformNamedSequence(), assembleTransformLibraryFromPaths(), and mlirMergeSymbolsIntoFromClone().

◆ parseTransformModuleFromFile()

LogicalResult mlir::transform::detail::parseTransformModuleFromFile ( MLIRContext context,
llvm::StringRef  transformFileName,
OwningOpRef< ModuleOp > &  transformModule 
)

Utility to parse and verify the content of a transformFileName MLIR file containing a transform dialect specification.

Definition at line 90 of file TransformInterpreterUtils.cpp.

References DBGS, mlir::emitError(), mlir::get(), mlir::openInputFile(), and mlir::verify().

Referenced by assembleTransformLibraryFromPaths().

◆ prepareValueMappings()

void mlir::transform::detail::prepareValueMappings ( SmallVectorImpl< SmallVector< transform::MappedValue >> &  mappings,
ValueRange  values,
const transform::TransformState state 
)

Populates mappings with mapped values associated with the given transform IR values in the given state.

Definition at line 1562 of file TransformInterfaces.cpp.

◆ setApplyToOneResults()

void mlir::transform::detail::setApplyToOneResults ( Operation transformOp,
TransformResults transformResults,
ArrayRef< ApplyToEachResultList results 
)

"Transpose" the results produced by individual applications, arranging them per result value of the transform op, and populate transformResults with that.

The number, kind and nullity of per-application results are assumed to have been verified.

Definition at line 1507 of file TransformInterfaces.cpp.

References mlir::detail::enumerate(), and mlir::Operation::getNumResults().

◆ verifyParamProducerTransformOpTrait()

LogicalResult mlir::transform::detail::verifyParamProducerTransformOpTrait ( Operation op)

Non-template implementation of ParamProducerTransformOpTrait::verify().

Definition at line 1775 of file TransformInterfaces.cpp.

◆ verifyPossibleTopLevelTransformOpTrait()

LogicalResult mlir::transform::detail::verifyPossibleTopLevelTransformOpTrait ( Operation op)

Verification hook for PossibleTopLevelTransformOpTrait.

Definition at line 1693 of file TransformInterfaces.cpp.

Referenced by mlir::transform::applyTransforms().

◆ verifyStructuredOpPredicateOpTrait()

LogicalResult mlir::transform::detail::verifyStructuredOpPredicateOpTrait ( Operation op,
Value  structuredOpHandle 
)

Definition at line 146 of file LinalgMatchOps.cpp.

◆ verifyTransformOpInterface()

LogicalResult mlir::transform::detail::verifyTransformOpInterface ( Operation op)

Verification hook for TransformOpInterface.

Definition at line 1932 of file TransformInterfaces.cpp.