MLIR
19.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/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, Operation *op, transform::TransformState &state, SmallVectorImpl< SmallVector< transform::MappedValue >> &mappings) |
Applies matcher operations from the given block assigning op as the payload of the block's first argument. 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 46 of file TransformOps.cpp.
#define DBGS_MATCHER | ( | ) | (llvm::dbgs() << "[" DEBUG_TYPE_MATCHER "] ") |
Definition at line 49 of file TransformOps.cpp.
#define DEBUG_MATCHER | ( | x | ) | DEBUG_WITH_TYPE(DEBUG_TYPE_MATCHER, x) |
Definition at line 50 of file TransformOps.cpp.
#define DEBUG_TYPE "transform-dialect" |
Definition at line 45 of file TransformOps.cpp.
#define DEBUG_TYPE_MATCHER "transform-matcher" |
Definition at line 48 of file TransformOps.cpp.
#define GET_OP_CLASSES |
Definition at line 89 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 1629 of file TransformOps.cpp.
|
static |
Definition at line 2155 of file TransformOps.cpp.
LogicalResult checkDoubleConsume | ( | Value | value, |
function_ref< InFlightDiagnostic()> | reportError | ||
) |
Definition at line 2459 of file TransformOps.cpp.
References diag(), mlir::Operation::getLoc(), mlir::OpOperand::getOperandNumber(), mlir::detail::IROperandBase::getOwner(), mlir::Value::getUses(), isValueUsePotentialConsumer(), and mlir::success().
|
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 73 of file TransformOps.cpp.
References diag(), mlir::Operation::getLoc(), mlir::Operation::getParentOp(), and mlir::DiagnosedSilenceableFailure::success().
|
static |
Definition at line 128 of file TransformOps.cpp.
Returns true
if both types implement one of the interfaces provided as template parameters.
Definition at line 876 of file TransformOps.cpp.
Referenced by implementSameTransformInterface().
Returns true
if both types implement one of the transform dialect interfaces.
Definition at line 882 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 2449 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
assigning op
as the payload of the block's first argument.
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.
Definition at line 845 of file TransformOps.cpp.
|
static |
Parses the comma-separated list of symbol reference pairs of the format @matcher -> @action
.
Definition at line 1117 of file TransformOps.cpp.
References mlir::failure(), mlir::get(), mlir::Builder::getArrayAttr(), mlir::AsmParser::getBuilder(), mlir::AsmParser::parseArrow(), mlir::AsmParser::parseOptionalComma(), mlir::AsmParser::parseSymbolName(), mlir::LogicalResult::succeeded(), and mlir::success().
|
static |
Definition at line 2377 of file TransformOps.cpp.
References mlir::AsmParser::emitError(), mlir::failed(), mlir::failure(), 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(), mlir::succeeded(), mlir::success(), and mlir::OptionalParseResult::value().
|
static |
Prints the comma-separated list of symbol reference pairs of the format @matcher -> @action
.
Definition at line 1140 of file TransformOps.cpp.
|
static |
Definition at line 2421 of file TransformOps.cpp.
|
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 1177 of file TransformOps.cpp.
|
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 2083 of file TransformOps.cpp.
|
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 2031 of file TransformOps.cpp.