#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>
#define DEBUG_TYPE …
#define DBGS() …
#define DEBUG_TYPE_MATCHER …
#define DBGS_MATCHER() …
#define DEBUG_MATCHER(x) …
usingnamespacemlir;
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);
static ParseResult parseForeachMatchSymbols(OpAsmParser &parser,
ArrayAttr &matchers,
ArrayAttr &actions);
static DiagnosedSilenceableFailure
ensurePayloadIsSeparateFromTransform(transform::TransformOpInterface transform,
Operation *payload) { … }
#define GET_OP_CLASSES
#include "mlir/Dialect/Transform/IR/TransformOps.cpp.inc"
OperandRange
transform::AlternativesOp::getEntrySuccessorOperands(RegionBranchPoint point) { … }
void transform::AlternativesOp::getSuccessorRegions(
RegionBranchPoint point, SmallVectorImpl<RegionSuccessor> ®ions) { … }
void transform::AlternativesOp::getRegionInvocationBounds(
ArrayRef<Attribute> operands, SmallVectorImpl<InvocationBounds> &bounds) { … }
static void forwardEmptyOperands(Block *block, transform::TransformState &state,
transform::TransformResults &results) { … }
DiagnosedSilenceableFailure
transform::AlternativesOp::apply(transform::TransformRewriter &rewriter,
transform::TransformResults &results,
transform::TransformState &state) { … }
void transform::AlternativesOp::getEffects(
SmallVectorImpl<MemoryEffects::EffectInstance> &effects) { … }
LogicalResult transform::AlternativesOp::verify() { … }
DiagnosedSilenceableFailure
transform::AnnotateOp::apply(transform::TransformRewriter &rewriter,
transform::TransformResults &results,
transform::TransformState &state) { … }
void transform::AnnotateOp::getEffects(
SmallVectorImpl<MemoryEffects::EffectInstance> &effects) { … }
DiagnosedSilenceableFailure
transform::ApplyCommonSubexpressionEliminationOp::applyToOne(
transform::TransformRewriter &rewriter, Operation *target,
ApplyToEachResultList &results, transform::TransformState &state) { … }
void transform::ApplyCommonSubexpressionEliminationOp::getEffects(
SmallVectorImpl<MemoryEffects::EffectInstance> &effects) { … }
DiagnosedSilenceableFailure transform::ApplyDeadCodeEliminationOp::applyToOne(
transform::TransformRewriter &rewriter, Operation *target,
ApplyToEachResultList &results, transform::TransformState &state) { … }
void transform::ApplyDeadCodeEliminationOp::getEffects(
SmallVectorImpl<MemoryEffects::EffectInstance> &effects) { … }
DiagnosedSilenceableFailure transform::ApplyPatternsOp::applyToOne(
transform::TransformRewriter &rewriter, Operation *target,
ApplyToEachResultList &results, transform::TransformState &state) { … }
LogicalResult transform::ApplyPatternsOp::verify() { … }
void transform::ApplyPatternsOp::getEffects(
SmallVectorImpl<MemoryEffects::EffectInstance> &effects) { … }
void transform::ApplyPatternsOp::build(
OpBuilder &builder, OperationState &result, Value target,
function_ref<void(OpBuilder &, Location)> bodyBuilder) { … }
void transform::ApplyCanonicalizationPatternsOp::populatePatterns(
RewritePatternSet &patterns) { … }
DiagnosedSilenceableFailure transform::ApplyConversionPatternsOp::apply(
transform::TransformRewriter &rewriter,
transform::TransformResults &results, transform::TransformState &state) { … }
LogicalResult transform::ApplyConversionPatternsOp::verify() { … }
void transform::ApplyConversionPatternsOp::getEffects(
SmallVectorImpl<MemoryEffects::EffectInstance> &effects) { … }
void transform::ApplyConversionPatternsOp::build(
OpBuilder &builder, OperationState &result, Value target,
function_ref<void(OpBuilder &, Location)> patternsBodyBuilder,
function_ref<void(OpBuilder &, Location)> typeConverterBodyBuilder) { … }
void transform::ApplyToLLVMConversionPatternsOp::populatePatterns(
TypeConverter &typeConverter, RewritePatternSet &patterns) { … }
LogicalResult transform::ApplyToLLVMConversionPatternsOp::verifyTypeConverter(
transform::TypeConverterBuilderOpInterface builder) { … }
LogicalResult transform::ApplyToLLVMConversionPatternsOp::verify() { … }
DiagnosedSilenceableFailure
transform::ApplyLoopInvariantCodeMotionOp::applyToOne(
transform::TransformRewriter &rewriter, LoopLikeOpInterface target,
transform::ApplyToEachResultList &results,
transform::TransformState &state) { … }
void transform::ApplyLoopInvariantCodeMotionOp::getEffects(
SmallVectorImpl<MemoryEffects::EffectInstance> &effects) { … }
DiagnosedSilenceableFailure transform::ApplyRegisteredPassOp::applyToOne(
transform::TransformRewriter &rewriter, Operation *target,
ApplyToEachResultList &results, transform::TransformState &state) { … }
DiagnosedSilenceableFailure
transform::CastOp::applyToOne(transform::TransformRewriter &rewriter,
Operation *target, ApplyToEachResultList &results,
transform::TransformState &state) { … }
void transform::CastOp::getEffects(
SmallVectorImpl<MemoryEffects::EffectInstance> &effects) { … }
bool transform::CastOp::areCastCompatible(TypeRange inputs, TypeRange outputs) { … }
static DiagnosedSilenceableFailure
matchBlock(Block &block,
ArrayRef<SmallVector<transform::MappedValue>> blockArgumentMapping,
transform::TransformState &state,
SmallVectorImpl<SmallVector<transform::MappedValue>> &mappings) { … }
template <typename... Tys>
static bool implementSameInterface(Type t1, Type t2) { … }
static bool implementSameTransformInterface(Type t1, Type t2) { … }
DiagnosedSilenceableFailure
transform::CollectMatchingOp::apply(transform::TransformRewriter &rewriter,
transform::TransformResults &results,
transform::TransformState &state) { … }
void transform::CollectMatchingOp::getEffects(
SmallVectorImpl<MemoryEffects::EffectInstance> &effects) { … }
LogicalResult transform::CollectMatchingOp::verifySymbolUses(
SymbolTableCollection &symbolTable) { … }
bool transform::ForeachMatchOp::allowsRepeatedHandleOperands() { … }
DiagnosedSilenceableFailure
transform::ForeachMatchOp::apply(transform::TransformRewriter &rewriter,
transform::TransformResults &results,
transform::TransformState &state) { … }
void transform::ForeachMatchOp::getAsmResultNames(
OpAsmSetValueNameFn setNameFn) { … }
void transform::ForeachMatchOp::getEffects(
SmallVectorImpl<MemoryEffects::EffectInstance> &effects) { … }
static ParseResult parseForeachMatchSymbols(OpAsmParser &parser,
ArrayAttr &matchers,
ArrayAttr &actions) { … }
static void printForeachMatchSymbols(OpAsmPrinter &printer, Operation *op,
ArrayAttr matchers, ArrayAttr actions) { … }
LogicalResult transform::ForeachMatchOp::verify() { … }
static DiagnosedSilenceableFailure
verifyFunctionLikeConsumeAnnotations(FunctionOpInterface op, bool emitWarnings,
bool alsoVerifyInternal = false) { … }
LogicalResult transform::ForeachMatchOp::verifySymbolUses(
SymbolTableCollection &symbolTable) { … }
DiagnosedSilenceableFailure
transform::ForeachOp::apply(transform::TransformRewriter &rewriter,
transform::TransformResults &results,
transform::TransformState &state) { … }
void transform::ForeachOp::getEffects(
SmallVectorImpl<MemoryEffects::EffectInstance> &effects) { … }
void transform::ForeachOp::getSuccessorRegions(
RegionBranchPoint point, SmallVectorImpl<RegionSuccessor> ®ions) { … }
OperandRange
transform::ForeachOp::getEntrySuccessorOperands(RegionBranchPoint point) { … }
transform::YieldOp transform::ForeachOp::getYieldOp() { … }
LogicalResult transform::ForeachOp::verify() { … }
DiagnosedSilenceableFailure
transform::GetParentOp::apply(transform::TransformRewriter &rewriter,
transform::TransformResults &results,
transform::TransformState &state) { … }
DiagnosedSilenceableFailure
transform::GetConsumersOfResult::apply(transform::TransformRewriter &rewriter,
transform::TransformResults &results,
transform::TransformState &state) { … }
DiagnosedSilenceableFailure
transform::GetDefiningOp::apply(transform::TransformRewriter &rewriter,
transform::TransformResults &results,
transform::TransformState &state) { … }
DiagnosedSilenceableFailure
transform::GetProducerOfOperand::apply(transform::TransformRewriter &rewriter,
transform::TransformResults &results,
transform::TransformState &state) { … }
DiagnosedSilenceableFailure
transform::GetOperandOp::apply(transform::TransformRewriter &rewriter,
transform::TransformResults &results,
transform::TransformState &state) { … }
LogicalResult transform::GetOperandOp::verify() { … }
DiagnosedSilenceableFailure
transform::GetResultOp::apply(transform::TransformRewriter &rewriter,
transform::TransformResults &results,
transform::TransformState &state) { … }
LogicalResult transform::GetResultOp::verify() { … }
void transform::GetTypeOp::getEffects(
SmallVectorImpl<MemoryEffects::EffectInstance> &effects) { … }
DiagnosedSilenceableFailure
transform::GetTypeOp::apply(transform::TransformRewriter &rewriter,
transform::TransformResults &results,
transform::TransformState &state) { … }
static DiagnosedSilenceableFailure
applySequenceBlock(Block &block, transform::FailurePropagationMode mode,
transform::TransformState &state,
transform::TransformResults &results) { … }
DiagnosedSilenceableFailure
transform::IncludeOp::apply(transform::TransformRewriter &rewriter,
transform::TransformResults &results,
transform::TransformState &state) { … }
static DiagnosedSilenceableFailure
verifyNamedSequenceOp(transform::NamedSequenceOp op, bool emitWarnings);
void transform::IncludeOp::getEffects(
SmallVectorImpl<MemoryEffects::EffectInstance> &effects) { … }
LogicalResult
transform::IncludeOp::verifySymbolUses(SymbolTableCollection &symbolTable) { … }
DiagnosedSilenceableFailure transform::MatchOperationEmptyOp::matchOperation(
::std::optional<::mlir::Operation *> maybeCurrent,
transform::TransformResults &results, transform::TransformState &state) { … }
DiagnosedSilenceableFailure transform::MatchOperationNameOp::matchOperation(
Operation *current, transform::TransformResults &results,
transform::TransformState &state) { … }
DiagnosedSilenceableFailure
transform::MatchParamCmpIOp::apply(transform::TransformRewriter &rewriter,
transform::TransformResults &results,
transform::TransformState &state) { … }
void transform::MatchParamCmpIOp::getEffects(
SmallVectorImpl<MemoryEffects::EffectInstance> &effects) { … }
DiagnosedSilenceableFailure
transform::ParamConstantOp::apply(transform::TransformRewriter &rewriter,
transform::TransformResults &results,
transform::TransformState &state) { … }
DiagnosedSilenceableFailure
transform::MergeHandlesOp::apply(transform::TransformRewriter &rewriter,
transform::TransformResults &results,
transform::TransformState &state) { … }
bool transform::MergeHandlesOp::allowsRepeatedHandleOperands() { … }
void transform::MergeHandlesOp::getEffects(
SmallVectorImpl<MemoryEffects::EffectInstance> &effects) { … }
OpFoldResult transform::MergeHandlesOp::fold(FoldAdaptor adaptor) { … }
DiagnosedSilenceableFailure
transform::NamedSequenceOp::apply(transform::TransformRewriter &rewriter,
transform::TransformResults &results,
transform::TransformState &state) { … }
void transform::NamedSequenceOp::getEffects(
SmallVectorImpl<MemoryEffects::EffectInstance> &effects) { … }
ParseResult transform::NamedSequenceOp::parse(OpAsmParser &parser,
OperationState &result) { … }
void transform::NamedSequenceOp::print(OpAsmPrinter &printer) { … }
static DiagnosedSilenceableFailure
verifyYieldingSingleBlockOp(FunctionOpInterface op, bool allowExternal) { … }
static DiagnosedSilenceableFailure
verifyNamedSequenceOp(transform::NamedSequenceOp op, bool emitWarnings) { … }
LogicalResult transform::NamedSequenceOp::verify() { … }
template <typename FnTy>
static void buildSequenceBody(OpBuilder &builder, OperationState &state,
Type bbArgType, TypeRange extraBindingTypes,
FnTy bodyBuilder) { … }
void transform::NamedSequenceOp::build(OpBuilder &builder,
OperationState &state, StringRef symName,
Type rootType, TypeRange resultTypes,
SequenceBodyBuilderFn bodyBuilder,
ArrayRef<NamedAttribute> attrs,
ArrayRef<DictionaryAttr> argAttrs) { … }
DiagnosedSilenceableFailure
transform::NumAssociationsOp::apply(transform::TransformRewriter &rewriter,
transform::TransformResults &results,
transform::TransformState &state) { … }
LogicalResult transform::NumAssociationsOp::verify() { … }
DiagnosedSilenceableFailure
transform::SelectOp::apply(transform::TransformRewriter &rewriter,
transform::TransformResults &results,
transform::TransformState &state) { … }
void transform::SplitHandleOp::build(OpBuilder &builder, OperationState &result,
Value target, int64_t numResultHandles) { … }
DiagnosedSilenceableFailure
transform::SplitHandleOp::apply(transform::TransformRewriter &rewriter,
transform::TransformResults &results,
transform::TransformState &state) { … }
void transform::SplitHandleOp::getEffects(
SmallVectorImpl<MemoryEffects::EffectInstance> &effects) { … }
LogicalResult transform::SplitHandleOp::verify() { … }
DiagnosedSilenceableFailure
transform::ReplicateOp::apply(transform::TransformRewriter &rewriter,
transform::TransformResults &results,
transform::TransformState &state) { … }
void transform::ReplicateOp::getEffects(
SmallVectorImpl<MemoryEffects::EffectInstance> &effects) { … }
DiagnosedSilenceableFailure
transform::SequenceOp::apply(transform::TransformRewriter &rewriter,
transform::TransformResults &results,
transform::TransformState &state) { … }
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 bool isValueUsePotentialConsumer(OpOperand &use) { … }
LogicalResult
checkDoubleConsume(Value value,
function_ref<InFlightDiagnostic()> reportError) { … }
LogicalResult transform::SequenceOp::verify() { … }
void transform::SequenceOp::getEffects(
SmallVectorImpl<MemoryEffects::EffectInstance> &effects) { … }
OperandRange
transform::SequenceOp::getEntrySuccessorOperands(RegionBranchPoint point) { … }
void transform::SequenceOp::getSuccessorRegions(
RegionBranchPoint point, SmallVectorImpl<RegionSuccessor> ®ions) { … }
void transform::SequenceOp::getRegionInvocationBounds(
ArrayRef<Attribute> operands, SmallVectorImpl<InvocationBounds> &bounds) { … }
void transform::SequenceOp::build(OpBuilder &builder, OperationState &state,
TypeRange resultTypes,
FailurePropagationMode failurePropagationMode,
Value root,
SequenceBodyBuilderFn bodyBuilder) { … }
void transform::SequenceOp::build(OpBuilder &builder, OperationState &state,
TypeRange resultTypes,
FailurePropagationMode failurePropagationMode,
Value root, ValueRange extraBindings,
SequenceBodyBuilderArgsFn bodyBuilder) { … }
void transform::SequenceOp::build(OpBuilder &builder, OperationState &state,
TypeRange resultTypes,
FailurePropagationMode failurePropagationMode,
Type bbArgType,
SequenceBodyBuilderFn bodyBuilder) { … }
void transform::SequenceOp::build(OpBuilder &builder, OperationState &state,
TypeRange resultTypes,
FailurePropagationMode failurePropagationMode,
Type bbArgType, TypeRange extraBindingTypes,
SequenceBodyBuilderArgsFn bodyBuilder) { … }
void transform::PrintOp::build(OpBuilder &builder, OperationState &result,
StringRef name) { … }
void transform::PrintOp::build(OpBuilder &builder, OperationState &result,
Value target, StringRef name) { … }
DiagnosedSilenceableFailure
transform::PrintOp::apply(transform::TransformRewriter &rewriter,
transform::TransformResults &results,
transform::TransformState &state) { … }
void transform::PrintOp::getEffects(
SmallVectorImpl<MemoryEffects::EffectInstance> &effects) { … }
DiagnosedSilenceableFailure
transform::VerifyOp::applyToOne(transform::TransformRewriter &rewriter,
Operation *target,
transform::ApplyToEachResultList &results,
transform::TransformState &state) { … }
void transform::VerifyOp::getEffects(
SmallVectorImpl<MemoryEffects::EffectInstance> &effects) { … }
void transform::YieldOp::getEffects(
SmallVectorImpl<MemoryEffects::EffectInstance> &effects) { … }