MLIR
20.0.0git
|
#include "mlir/Dialect/Transform/IR/TransformOps.h"
#include "mlir/Conversion/ConvertToLLVM/ToLLVMInterface.h"
#include "mlir/Conversion/LLVMCommon/ConversionTarget.h"
#include "mlir/Conversion/LLVMCommon/TypeConverter.h"
#include "mlir/Dialect/Transform/IR/TransformAttrs.h"
#include "mlir/Dialect/Transform/IR/TransformDialect.h"
#include "mlir/Dialect/Transform/IR/TransformTypes.h"
#include "mlir/Dialect/Transform/Interfaces/MatchInterfaces.h"
#include "mlir/Dialect/Transform/Interfaces/TransformInterfaces.h"
#include "mlir/IR/BuiltinAttributes.h"
#include "mlir/IR/Diagnostics.h"
#include "mlir/IR/Dominance.h"
#include "mlir/IR/OpImplementation.h"
#include "mlir/IR/OperationSupport.h"
#include "mlir/IR/PatternMatch.h"
#include "mlir/IR/Verifier.h"
#include "mlir/Interfaces/CallInterfaces.h"
#include "mlir/Interfaces/ControlFlowInterfaces.h"
#include "mlir/Interfaces/FunctionImplementation.h"
#include "mlir/Interfaces/FunctionInterfaces.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Pass/PassManager.h"
#include "mlir/Pass/PassRegistry.h"
#include "mlir/Transforms/CSE.h"
#include "mlir/Transforms/DialectConversion.h"
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
#include "mlir/Transforms/LoopInvariantCodeMotionUtils.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/ScopeExit.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/TypeSwitch.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include <optional>
#include "mlir/Dialect/Transform/IR/TransformOps.cpp.inc"
Go to the source code of this file.
Macros | |
#define | DEBUG_TYPE "transform-dialect" |
#define | DBGS() (llvm::dbgs() << "[" DEBUG_TYPE "] ") |
#define | DEBUG_TYPE_MATCHER "transform-matcher" |
#define | DBGS_MATCHER() (llvm::dbgs() << "[" DEBUG_TYPE_MATCHER "] ") |
#define | DEBUG_MATCHER(x) DEBUG_WITH_TYPE(DEBUG_TYPE_MATCHER, x) |
#define | GET_OP_CLASSES |
Functions | |
static ParseResult | parseSequenceOpOperands (OpAsmParser &parser, std::optional< OpAsmParser::UnresolvedOperand > &root, Type &rootType, SmallVectorImpl< OpAsmParser::UnresolvedOperand > &extraBindings, SmallVectorImpl< Type > &extraBindingTypes) |
static void | printSequenceOpOperands (OpAsmPrinter &printer, Operation *op, Value root, Type rootType, ValueRange extraBindings, TypeRange extraBindingTypes) |
static void | printForeachMatchSymbols (OpAsmPrinter &printer, Operation *op, ArrayAttr matchers, ArrayAttr actions) |
Prints the comma-separated list of symbol reference pairs of the format @matcher -> @action . More... | |
static ParseResult | parseForeachMatchSymbols (OpAsmParser &parser, ArrayAttr &matchers, ArrayAttr &actions) |
Parses the comma-separated list of symbol reference pairs of the format @matcher -> @action . More... | |
static DiagnosedSilenceableFailure | ensurePayloadIsSeparateFromTransform (transform::TransformOpInterface transform, Operation *payload) |
Helper function to check if the given transform op is contained in (or equal to) the given payload target op. More... | |
static void | forwardEmptyOperands (Block *block, transform::TransformState &state, transform::TransformResults &results) |
static DiagnosedSilenceableFailure | matchBlock (Block &block, ArrayRef< SmallVector< transform::MappedValue >> blockArgumentMapping, transform::TransformState &state, SmallVectorImpl< SmallVector< transform::MappedValue >> &mappings) |
Applies matcher operations from the given block using blockArgumentMapping to initialize block arguments. More... | |
template<typename... Tys> | |
static bool | implementSameInterface (Type t1, Type t2) |
Returns true if both types implement one of the interfaces provided as template parameters. More... | |
static bool | implementSameTransformInterface (Type t1, Type t2) |
Returns true if both types implement one of the transform dialect interfaces. More... | |
static DiagnosedSilenceableFailure | verifyFunctionLikeConsumeAnnotations (FunctionOpInterface op, bool emitWarnings, bool alsoVerifyInternal=false) |
Checks that the attributes of the function-like operation have correct consumption effect annotations. More... | |
static DiagnosedSilenceableFailure | applySequenceBlock (Block &block, transform::FailurePropagationMode mode, transform::TransformState &state, transform::TransformResults &results) |
Applies the transform ops contained in block . More... | |
static DiagnosedSilenceableFailure | verifyNamedSequenceOp (transform::NamedSequenceOp op, bool emitWarnings) |
Verification of a NamedSequenceOp. More... | |
static DiagnosedSilenceableFailure | verifyYieldingSingleBlockOp (FunctionOpInterface op, bool allowExternal) |
Verifies that a symbol function-like transform dialect operation has the signature and the terminator that have conforming types, i.e., types implementing the same transform dialect type interface. More... | |
template<typename FnTy > | |
static void | buildSequenceBody (OpBuilder &builder, OperationState &state, Type bbArgType, TypeRange extraBindingTypes, FnTy bodyBuilder) |
static bool | isValueUsePotentialConsumer (OpOperand &use) |
Returns true if the given op operand may be consuming the handle value in the Transform IR. More... | |
LogicalResult | checkDoubleConsume (Value value, function_ref< InFlightDiagnostic()> reportError) |
#define DBGS | ( | ) | (llvm::dbgs() << "[" DEBUG_TYPE "] ") |
Definition at line 47 of file TransformOps.cpp.
#define DBGS_MATCHER | ( | ) | (llvm::dbgs() << "[" DEBUG_TYPE_MATCHER "] ") |
Definition at line 50 of file TransformOps.cpp.
#define DEBUG_MATCHER | ( | x | ) | DEBUG_WITH_TYPE(DEBUG_TYPE_MATCHER, x) |
Definition at line 51 of file TransformOps.cpp.
#define DEBUG_TYPE "transform-dialect" |
Definition at line 46 of file TransformOps.cpp.
#define DEBUG_TYPE_MATCHER "transform-matcher" |
Definition at line 49 of file TransformOps.cpp.
#define GET_OP_CLASSES |
Definition at line 90 of file TransformOps.cpp.
|
static |
Applies the transform ops contained in block
.
Maps results
to the same values as the operands of the block terminator.
Definition at line 1780 of file TransformOps.cpp.
|
static |
Definition at line 2308 of file TransformOps.cpp.
LogicalResult checkDoubleConsume | ( | Value | value, |
function_ref< InFlightDiagnostic()> | reportError | ||
) |
Definition at line 2612 of file TransformOps.cpp.
References diag(), mlir::Operation::getLoc(), mlir::OpOperand::getOperandNumber(), mlir::detail::IROperandBase::getOwner(), mlir::Value::getUses(), and isValueUsePotentialConsumer().
|
static |
Helper function to check if the given transform op is contained in (or equal to) the given payload target op.
In that case, an error is returned. Transforming transform IR that is currently executing is generally unsafe.
Definition at line 74 of file TransformOps.cpp.
References diag(), mlir::Operation::getLoc(), mlir::Operation::getParentOp(), and mlir::DiagnosedSilenceableFailure::success().
|
static |
Definition at line 129 of file TransformOps.cpp.
Returns true
if both types implement one of the interfaces provided as template parameters.
Definition at line 885 of file TransformOps.cpp.
Referenced by implementSameTransformInterface().
Returns true
if both types implement one of the transform dialect interfaces.
Definition at line 891 of file TransformOps.cpp.
References implementSameInterface().
|
static |
Returns true
if the given op operand may be consuming the handle value in the Transform IR.
That is, if it may have a Free effect on it.
Definition at line 2602 of file TransformOps.cpp.
References mlir::IROperand< DerivedT, IRValueT >::get(), mlir::detail::IROperandBase::getOwner(), and mlir::transform::isHandleConsumed().
Referenced by checkDoubleConsume().
|
static |
Applies matcher operations from the given block
using blockArgumentMapping
to initialize block arguments.
Updates state
accordingly. If any of the matcher produces a silenceable failure, discards it (printing the content to the debug output stream) and returns failure. If any of the matchers produces a definite failure, reports it and returns failure. If all matchers in the block succeed, populates mappings
with the payload entities associated with the block terminator operands. Note that mappings
will be cleared before that.
Definition at line 848 of file TransformOps.cpp.
|
static |
Parses the comma-separated list of symbol reference pairs of the format @matcher -> @action
.
Definition at line 1170 of file TransformOps.cpp.
References mlir::get(), mlir::Builder::getArrayAttr(), mlir::AsmParser::getBuilder(), mlir::AsmParser::parseArrow(), mlir::AsmParser::parseOptionalComma(), and mlir::AsmParser::parseSymbolName().
|
static |
Definition at line 2530 of file TransformOps.cpp.
References mlir::AsmParser::emitError(), mlir::AsmParser::getNameLoc(), mlir::OptionalParseResult::has_value(), mlir::AsmParser::parseColon(), mlir::AsmParser::parseComma(), mlir::OpAsmParser::parseOperandList(), mlir::AsmParser::parseOptionalComma(), mlir::AsmParser::parseOptionalLParen(), mlir::OpAsmParser::parseOptionalOperand(), mlir::AsmParser::parseOptionalRParen(), mlir::AsmParser::parseType(), mlir::AsmParser::parseTypeList(), and mlir::OptionalParseResult::value().
|
static |
Prints the comma-separated list of symbol reference pairs of the format @matcher -> @action
.
Definition at line 1193 of file TransformOps.cpp.
References mlir::OpAsmPrinter::decreaseIndent(), mlir::OpAsmPrinter::increaseIndent(), and mlir::OpAsmPrinter::printNewline().
|
static |
Definition at line 2574 of file TransformOps.cpp.
References mlir::AsmPrinter::getStream(), and mlir::OpAsmPrinter::printOperands().
|
static |
Checks that the attributes of the function-like operation have correct consumption effect annotations.
If alsoVerifyInternal
, checks for annotations being present even if they can be inferred from the body.
Definition at line 1230 of file TransformOps.cpp.
References mlir::emitWarning(), mlir::transform::getConsumedBlockArguments(), and mlir::DiagnosedSilenceableFailure::success().
Referenced by verifyNamedSequenceOp().
|
static |
Verification of a NamedSequenceOp.
This does not report the error immediately, so it can be used to check for op's well-formedness before the verifier runs, e.g., during trait verification.
Definition at line 2236 of file TransformOps.cpp.
References diag(), mlir::emitSilenceableFailure(), mlir::Operation::getAttr(), mlir::Operation::getLoc(), mlir::Operation::getNumOperands(), mlir::Operation::getOperands(), mlir::Operation::getParentOfType(), mlir::Operation::getParentWithTrait(), mlir::OperandRange::getType(), verifyFunctionLikeConsumeAnnotations(), and verifyYieldingSingleBlockOp().
|
static |
Verifies that a symbol function-like transform dialect operation has the signature and the terminator that have conforming types, i.e., types implementing the same transform dialect type interface.
If allowExternal
is set, allow external symbols (declarations) and don't check the terminator as it may not exist.
Definition at line 2184 of file TransformOps.cpp.
References diag(), mlir::emitSilenceableFailure(), mlir::Operation::getLoc(), mlir::Operation::getNumOperands(), mlir::Operation::getOperands(), mlir::Operation::getParentOfType(), mlir::OperandRange::getType(), and mlir::DiagnosedSilenceableFailure::success().
Referenced by verifyNamedSequenceOp().