forked from OSchip/llvm-project
Rename FrozenRewritePatternList -> FrozenRewritePatternSet; NFC.
This nicely aligns the naming with RewritePatternSet. This type isn't as widely used, but we keep a using declaration in to help with downstream consumption of this change. Differential Revision: https://reviews.llvm.org/D99131
This commit is contained in:
parent
a0c776fc94
commit
79d7f618af
|
@ -19,7 +19,7 @@
|
|||
|
||||
namespace mlir {
|
||||
class BufferizeTypeConverter;
|
||||
class FrozenRewritePatternList;
|
||||
class FrozenRewritePatternSet;
|
||||
|
||||
namespace linalg {
|
||||
|
||||
|
@ -964,8 +964,8 @@ public:
|
|||
//===----------------------------------------------------------------------===//
|
||||
/// Helper function to allow applying rewrite patterns, interleaved with more
|
||||
/// global transformations, in a staged fashion:
|
||||
/// 1. the first stage consists of a list of FrozenRewritePatternList. Each
|
||||
/// FrozenRewritePatternList in this list is applied once, in order.
|
||||
/// 1. the first stage consists of a list of FrozenRewritePatternSet. Each
|
||||
/// FrozenRewritePatternSet in this list is applied once, in order.
|
||||
/// 2. the second stage consists of a single OwningRewritePattern that is
|
||||
/// applied greedily until convergence.
|
||||
/// 3. the third stage consists of applying a lambda, generally used for
|
||||
|
@ -973,8 +973,8 @@ public:
|
|||
/// transformations where patterns can be ordered and applied at a finer
|
||||
/// granularity than a sequence of traditional compiler passes.
|
||||
LogicalResult applyStagedPatterns(
|
||||
Operation *op, ArrayRef<FrozenRewritePatternList> stage1Patterns,
|
||||
const FrozenRewritePatternList &stage2Patterns,
|
||||
Operation *op, ArrayRef<FrozenRewritePatternSet> stage1Patterns,
|
||||
const FrozenRewritePatternSet &stage2Patterns,
|
||||
function_ref<LogicalResult(Operation *)> stage3Lambda = nullptr);
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -894,7 +894,7 @@ private:
|
|||
PDLPatternModule pdlPatterns;
|
||||
};
|
||||
|
||||
// TODO: RewritePatternSet is soft-deprecated and will be removed in the
|
||||
// TODO: OwningRewritePatternList is soft-deprecated and will be removed in the
|
||||
// future.
|
||||
using OwningRewritePatternList = RewritePatternSet;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//===- FrozenRewritePatternList.h - FrozenRewritePatternList ----*- C++ -*-===//
|
||||
//===- FrozenRewritePatternSet.h --------------------------------*- C++ -*-===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
|
@ -6,8 +6,8 @@
|
|||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef MLIR_REWRITE_FROZENREWRITEPATTERNLIST_H
|
||||
#define MLIR_REWRITE_FROZENREWRITEPATTERNLIST_H
|
||||
#ifndef MLIR_REWRITE_FROZENREWRITEPATTERNSET_H
|
||||
#define MLIR_REWRITE_FROZENREWRITEPATTERNSET_H
|
||||
|
||||
#include "mlir/IR/PatternMatch.h"
|
||||
|
||||
|
@ -21,20 +21,20 @@ class PDLByteCode;
|
|||
/// such that they need not be continuously recomputed. Note that all copies of
|
||||
/// this class share the same compiled pattern list, allowing for a reduction in
|
||||
/// the number of duplicated patterns that need to be created.
|
||||
class FrozenRewritePatternList {
|
||||
class FrozenRewritePatternSet {
|
||||
using NativePatternListT = std::vector<std::unique_ptr<RewritePattern>>;
|
||||
|
||||
public:
|
||||
/// Freeze the patterns held in `patterns`, and take ownership.
|
||||
FrozenRewritePatternList();
|
||||
FrozenRewritePatternList(RewritePatternSet &&patterns);
|
||||
FrozenRewritePatternList(FrozenRewritePatternList &&patterns) = default;
|
||||
FrozenRewritePatternList(const FrozenRewritePatternList &patterns) = default;
|
||||
FrozenRewritePatternList &
|
||||
operator=(const FrozenRewritePatternList &patterns) = default;
|
||||
FrozenRewritePatternList &
|
||||
operator=(FrozenRewritePatternList &&patterns) = default;
|
||||
~FrozenRewritePatternList();
|
||||
FrozenRewritePatternSet();
|
||||
FrozenRewritePatternSet(RewritePatternSet &&patterns);
|
||||
FrozenRewritePatternSet(FrozenRewritePatternSet &&patterns) = default;
|
||||
FrozenRewritePatternSet(const FrozenRewritePatternSet &patterns) = default;
|
||||
FrozenRewritePatternSet &
|
||||
operator=(const FrozenRewritePatternSet &patterns) = default;
|
||||
FrozenRewritePatternSet &
|
||||
operator=(FrozenRewritePatternSet &&patterns) = default;
|
||||
~FrozenRewritePatternSet();
|
||||
|
||||
/// Return the native patterns held by this list.
|
||||
iterator_range<llvm::pointee_iterator<NativePatternListT::const_iterator>>
|
||||
|
@ -66,6 +66,10 @@ private:
|
|||
std::shared_ptr<Impl> impl;
|
||||
};
|
||||
|
||||
// TODO: FrozenRewritePatternList is soft-deprecated and will be removed in the
|
||||
// future.
|
||||
using FrozenRewritePatternList = FrozenRewritePatternSet;
|
||||
|
||||
} // end namespace mlir
|
||||
|
||||
#endif // MLIR_REWRITE_FROZENREWRITEPATTERNLIST_H
|
||||
#endif // MLIR_REWRITE_FROZENREWRITEPATTERNSET_H
|
|
@ -14,7 +14,7 @@
|
|||
#ifndef MLIR_REWRITE_PATTERNAPPLICATOR_H
|
||||
#define MLIR_REWRITE_PATTERNAPPLICATOR_H
|
||||
|
||||
#include "mlir/Rewrite/FrozenRewritePatternList.h"
|
||||
#include "mlir/Rewrite/FrozenRewritePatternSet.h"
|
||||
|
||||
namespace mlir {
|
||||
class PatternRewriter;
|
||||
|
@ -33,7 +33,7 @@ public:
|
|||
/// `impossibleToMatch`.
|
||||
using CostModel = function_ref<PatternBenefit(const Pattern &)>;
|
||||
|
||||
explicit PatternApplicator(const FrozenRewritePatternList &frozenPatternList);
|
||||
explicit PatternApplicator(const FrozenRewritePatternSet &frozenPatternList);
|
||||
~PatternApplicator();
|
||||
|
||||
/// Attempt to match and rewrite the given op with any pattern, allowing a
|
||||
|
@ -65,7 +65,7 @@ public:
|
|||
|
||||
private:
|
||||
/// The list that owns the patterns used within this applicator.
|
||||
const FrozenRewritePatternList &frozenPatternList;
|
||||
const FrozenRewritePatternSet &frozenPatternList;
|
||||
/// The set of patterns to match for each operation, stable sorted by benefit.
|
||||
DenseMap<OperationName, SmallVector<const RewritePattern *, 2>> patterns;
|
||||
/// The set of patterns that may match against any operation type, stable
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#ifndef MLIR_TRANSFORMS_DIALECTCONVERSION_H_
|
||||
#define MLIR_TRANSFORMS_DIALECTCONVERSION_H_
|
||||
|
||||
#include "mlir/Rewrite/FrozenRewritePatternList.h"
|
||||
#include "mlir/Rewrite/FrozenRewritePatternSet.h"
|
||||
#include "llvm/ADT/MapVector.h"
|
||||
#include "llvm/ADT/StringMap.h"
|
||||
|
||||
|
@ -842,11 +842,11 @@ private:
|
|||
/// the `unconvertedOps` set will not necessarily be complete.)
|
||||
LogicalResult
|
||||
applyPartialConversion(ArrayRef<Operation *> ops, ConversionTarget &target,
|
||||
const FrozenRewritePatternList &patterns,
|
||||
const FrozenRewritePatternSet &patterns,
|
||||
DenseSet<Operation *> *unconvertedOps = nullptr);
|
||||
LogicalResult
|
||||
applyPartialConversion(Operation *op, ConversionTarget &target,
|
||||
const FrozenRewritePatternList &patterns,
|
||||
const FrozenRewritePatternSet &patterns,
|
||||
DenseSet<Operation *> *unconvertedOps = nullptr);
|
||||
|
||||
/// Apply a complete conversion on the given operations, and all nested
|
||||
|
@ -855,9 +855,9 @@ applyPartialConversion(Operation *op, ConversionTarget &target,
|
|||
/// within 'ops'.
|
||||
LogicalResult applyFullConversion(ArrayRef<Operation *> ops,
|
||||
ConversionTarget &target,
|
||||
const FrozenRewritePatternList &patterns);
|
||||
const FrozenRewritePatternSet &patterns);
|
||||
LogicalResult applyFullConversion(Operation *op, ConversionTarget &target,
|
||||
const FrozenRewritePatternList &patterns);
|
||||
const FrozenRewritePatternSet &patterns);
|
||||
|
||||
/// Apply an analysis conversion on the given operations, and all nested
|
||||
/// operations. This method analyzes which operations would be successfully
|
||||
|
@ -869,10 +869,10 @@ LogicalResult applyFullConversion(Operation *op, ConversionTarget &target,
|
|||
/// the regions nested within 'ops'.
|
||||
LogicalResult applyAnalysisConversion(ArrayRef<Operation *> ops,
|
||||
ConversionTarget &target,
|
||||
const FrozenRewritePatternList &patterns,
|
||||
const FrozenRewritePatternSet &patterns,
|
||||
DenseSet<Operation *> &convertedOps);
|
||||
LogicalResult applyAnalysisConversion(Operation *op, ConversionTarget &target,
|
||||
const FrozenRewritePatternList &patterns,
|
||||
const FrozenRewritePatternSet &patterns,
|
||||
DenseSet<Operation *> &convertedOps);
|
||||
} // end namespace mlir
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#ifndef MLIR_TRANSFORMS_GREEDYPATTERNREWRITEDRIVER_H_
|
||||
#define MLIR_TRANSFORMS_GREEDYPATTERNREWRITEDRIVER_H_
|
||||
|
||||
#include "mlir/Rewrite/FrozenRewritePatternList.h"
|
||||
#include "mlir/Rewrite/FrozenRewritePatternSet.h"
|
||||
|
||||
namespace mlir {
|
||||
|
||||
|
@ -35,25 +35,25 @@ namespace mlir {
|
|||
/// before attempting to match any of the provided patterns.
|
||||
LogicalResult
|
||||
applyPatternsAndFoldGreedily(Operation *op,
|
||||
const FrozenRewritePatternList &patterns,
|
||||
const FrozenRewritePatternSet &patterns,
|
||||
bool useTopDownTraversal = true);
|
||||
|
||||
/// Rewrite the regions of the specified operation, with a user-provided limit
|
||||
/// on iterations to attempt before reaching convergence.
|
||||
LogicalResult applyPatternsAndFoldGreedily(
|
||||
Operation *op, const FrozenRewritePatternList &patterns,
|
||||
Operation *op, const FrozenRewritePatternSet &patterns,
|
||||
unsigned maxIterations, bool useTopDownTraversal = true);
|
||||
|
||||
/// Rewrite the given regions, which must be isolated from above.
|
||||
LogicalResult
|
||||
applyPatternsAndFoldGreedily(MutableArrayRef<Region> regions,
|
||||
const FrozenRewritePatternList &patterns,
|
||||
const FrozenRewritePatternSet &patterns,
|
||||
bool useTopDownTraversal = true);
|
||||
|
||||
/// Rewrite the given regions, with a user-provided limit on iterations to
|
||||
/// attempt before reaching convergence.
|
||||
LogicalResult applyPatternsAndFoldGreedily(
|
||||
MutableArrayRef<Region> regions, const FrozenRewritePatternList &patterns,
|
||||
MutableArrayRef<Region> regions, const FrozenRewritePatternSet &patterns,
|
||||
unsigned maxIterations, bool useTopDownTraversal = true);
|
||||
|
||||
/// Applies the specified patterns on `op` alone while also trying to fold it,
|
||||
|
@ -62,7 +62,7 @@ LogicalResult applyPatternsAndFoldGreedily(
|
|||
/// was folded away or erased as a result of becoming dead. Note: This does not
|
||||
/// apply any patterns recursively to the regions of `op`.
|
||||
LogicalResult applyOpPatternsAndFold(Operation *op,
|
||||
const FrozenRewritePatternList &patterns,
|
||||
const FrozenRewritePatternSet &patterns,
|
||||
bool *erased = nullptr);
|
||||
|
||||
} // end namespace mlir
|
||||
|
|
|
@ -92,7 +92,7 @@ static LogicalResult applyPatterns(FuncOp func) {
|
|||
|
||||
RewritePatternSet patterns(func.getContext());
|
||||
patterns.add<ParallelOpLowering>(func.getContext());
|
||||
FrozenRewritePatternList frozen(std::move(patterns));
|
||||
FrozenRewritePatternSet frozen(std::move(patterns));
|
||||
return applyPartialConversion(func, target, frozen);
|
||||
}
|
||||
|
||||
|
|
|
@ -230,7 +230,7 @@ void AffineDataCopyGeneration::runOnFunction() {
|
|||
RewritePatternSet patterns(&getContext());
|
||||
AffineLoadOp::getCanonicalizationPatterns(patterns, &getContext());
|
||||
AffineStoreOp::getCanonicalizationPatterns(patterns, &getContext());
|
||||
FrozenRewritePatternList frozenPatterns(std::move(patterns));
|
||||
FrozenRewritePatternSet frozenPatterns(std::move(patterns));
|
||||
for (Operation *op : copyOps)
|
||||
(void)applyOpPatternsAndFold(op, frozenPatterns);
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ void SimplifyAffineStructures::runOnFunction() {
|
|||
AffineForOp::getCanonicalizationPatterns(patterns, func.getContext());
|
||||
AffineIfOp::getCanonicalizationPatterns(patterns, func.getContext());
|
||||
AffineApplyOp::getCanonicalizationPatterns(patterns, func.getContext());
|
||||
FrozenRewritePatternList frozenPatterns(std::move(patterns));
|
||||
FrozenRewritePatternSet frozenPatterns(std::move(patterns));
|
||||
func.walk([&](Operation *op) {
|
||||
for (auto attr : op->getAttrs()) {
|
||||
if (auto mapAttr = attr.second.dyn_cast<AffineMapAttr>())
|
||||
|
|
|
@ -191,7 +191,7 @@ LogicalResult mlir::hoistAffineIfOp(AffineIfOp ifOp, bool *folded) {
|
|||
RewritePatternSet patterns(ifOp.getContext());
|
||||
AffineIfOp::getCanonicalizationPatterns(patterns, ifOp.getContext());
|
||||
bool erased;
|
||||
FrozenRewritePatternList frozenPatterns(std::move(patterns));
|
||||
FrozenRewritePatternSet frozenPatterns(std::move(patterns));
|
||||
(void)applyOpPatternsAndFold(ifOp, frozenPatterns, &erased);
|
||||
if (erased) {
|
||||
if (folded)
|
||||
|
|
|
@ -31,7 +31,7 @@ void mlir::linalg::CodegenStrategy::transform(FuncOp func) const {
|
|||
// Emplace patterns one at a time while also maintaining a simple chained
|
||||
// state transition.
|
||||
unsigned stepCount = 0;
|
||||
SmallVector<FrozenRewritePatternList, 4> stage1Patterns;
|
||||
SmallVector<FrozenRewritePatternSet, 4> stage1Patterns;
|
||||
auto zeroState = Identifier::get(std::to_string(stepCount), context);
|
||||
auto currentState = zeroState;
|
||||
for (const std::unique_ptr<Transformation> &t : transformationSequence) {
|
||||
|
|
|
@ -479,8 +479,8 @@ LogicalResult mlir::linalg::LinalgBaseVectorizationPattern::matchAndRewrite(
|
|||
}
|
||||
|
||||
LogicalResult mlir::linalg::applyStagedPatterns(
|
||||
Operation *op, ArrayRef<FrozenRewritePatternList> stage1Patterns,
|
||||
const FrozenRewritePatternList &stage2Patterns,
|
||||
Operation *op, ArrayRef<FrozenRewritePatternSet> stage1Patterns,
|
||||
const FrozenRewritePatternSet &stage2Patterns,
|
||||
function_ref<LogicalResult(Operation *)> stage3Lambda) {
|
||||
unsigned iteration = 0;
|
||||
(void)iteration;
|
||||
|
|
|
@ -106,7 +106,7 @@ void DecorateSPIRVCompositeTypeLayoutPass::runOnOperation() {
|
|||
|
||||
// TODO: Change the type for the indirect users such as spv.Load, spv.Store,
|
||||
// spv.FunctionCall and so on.
|
||||
FrozenRewritePatternList frozenPatterns(std::move(patterns));
|
||||
FrozenRewritePatternSet frozenPatterns(std::move(patterns));
|
||||
for (auto spirvModule : module.getOps<spirv::ModuleOp>())
|
||||
if (failed(applyFullConversion(spirvModule, target, frozenPatterns)))
|
||||
signalPassFailure();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
add_mlir_library(MLIRRewrite
|
||||
ByteCode.cpp
|
||||
FrozenRewritePatternList.cpp
|
||||
FrozenRewritePatternSet.cpp
|
||||
PatternApplicator.cpp
|
||||
|
||||
ADDITIONAL_HEADER_DIRS
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//===- FrozenRewritePatternList.cpp - Frozen Pattern List -------*- C++ -*-===//
|
||||
//===- FrozenRewritePatternSet.cpp - Frozen Pattern List -------*- C++ -*-===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
|
@ -6,7 +6,7 @@
|
|||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "mlir/Rewrite/FrozenRewritePatternList.h"
|
||||
#include "mlir/Rewrite/FrozenRewritePatternSet.h"
|
||||
#include "ByteCode.h"
|
||||
#include "mlir/Conversion/PDLToPDLInterp/PDLToPDLInterp.h"
|
||||
#include "mlir/Dialect/PDL/IR/PDLOps.h"
|
||||
|
@ -47,13 +47,13 @@ static LogicalResult convertPDLToPDLInterp(ModuleOp pdlModule) {
|
|||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// FrozenRewritePatternList
|
||||
// FrozenRewritePatternSet
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
FrozenRewritePatternList::FrozenRewritePatternList()
|
||||
FrozenRewritePatternSet::FrozenRewritePatternSet()
|
||||
: impl(std::make_shared<Impl>()) {}
|
||||
|
||||
FrozenRewritePatternList::FrozenRewritePatternList(RewritePatternSet &&patterns)
|
||||
FrozenRewritePatternSet::FrozenRewritePatternSet(RewritePatternSet &&patterns)
|
||||
: impl(std::make_shared<Impl>()) {
|
||||
impl->nativePatterns = std::move(patterns.getNativePatterns());
|
||||
|
||||
|
@ -72,4 +72,4 @@ FrozenRewritePatternList::FrozenRewritePatternList(RewritePatternSet &&patterns)
|
|||
pdlPatterns.takeRewriteFunctions());
|
||||
}
|
||||
|
||||
FrozenRewritePatternList::~FrozenRewritePatternList() {}
|
||||
FrozenRewritePatternSet::~FrozenRewritePatternSet() {}
|
|
@ -19,7 +19,7 @@ using namespace mlir;
|
|||
using namespace mlir::detail;
|
||||
|
||||
PatternApplicator::PatternApplicator(
|
||||
const FrozenRewritePatternList &frozenPatternList)
|
||||
const FrozenRewritePatternSet &frozenPatternList)
|
||||
: frozenPatternList(frozenPatternList) {
|
||||
if (const PDLByteCode *bytecode = frozenPatternList.getPDLByteCode()) {
|
||||
mutableByteCodeState = std::make_unique<PDLByteCodeMutableState>();
|
||||
|
|
|
@ -35,7 +35,7 @@ struct Canonicalizer : public CanonicalizerBase<Canonicalizer> {
|
|||
(void)applyPatternsAndFoldGreedily(getOperation()->getRegions(), patterns);
|
||||
}
|
||||
|
||||
FrozenRewritePatternList patterns;
|
||||
FrozenRewritePatternSet patterns;
|
||||
};
|
||||
} // end anonymous namespace
|
||||
|
||||
|
|
|
@ -1506,7 +1506,7 @@ public:
|
|||
using LegalizationAction = ConversionTarget::LegalizationAction;
|
||||
|
||||
OperationLegalizer(ConversionTarget &targetInfo,
|
||||
const FrozenRewritePatternList &patterns);
|
||||
const FrozenRewritePatternSet &patterns);
|
||||
|
||||
/// Returns true if the given operation is known to be illegal on the target.
|
||||
bool isIllegal(Operation *op) const;
|
||||
|
@ -1602,7 +1602,7 @@ private:
|
|||
} // namespace
|
||||
|
||||
OperationLegalizer::OperationLegalizer(ConversionTarget &targetInfo,
|
||||
const FrozenRewritePatternList &patterns)
|
||||
const FrozenRewritePatternSet &patterns)
|
||||
: target(targetInfo), applicator(patterns) {
|
||||
// The set of patterns that can be applied to illegal operations to transform
|
||||
// them into legal ones.
|
||||
|
@ -2125,7 +2125,7 @@ enum OpConversionMode {
|
|||
// conversion mode.
|
||||
struct OperationConverter {
|
||||
explicit OperationConverter(ConversionTarget &target,
|
||||
const FrozenRewritePatternList &patterns,
|
||||
const FrozenRewritePatternSet &patterns,
|
||||
OpConversionMode mode,
|
||||
DenseSet<Operation *> *trackedOps = nullptr)
|
||||
: opLegalizer(target, patterns), mode(mode), trackedOps(trackedOps) {}
|
||||
|
@ -2755,7 +2755,7 @@ auto ConversionTarget::getOpInfo(OperationName op) const
|
|||
LogicalResult
|
||||
mlir::applyPartialConversion(ArrayRef<Operation *> ops,
|
||||
ConversionTarget &target,
|
||||
const FrozenRewritePatternList &patterns,
|
||||
const FrozenRewritePatternSet &patterns,
|
||||
DenseSet<Operation *> *unconvertedOps) {
|
||||
OperationConverter opConverter(target, patterns, OpConversionMode::Partial,
|
||||
unconvertedOps);
|
||||
|
@ -2763,7 +2763,7 @@ mlir::applyPartialConversion(ArrayRef<Operation *> ops,
|
|||
}
|
||||
LogicalResult
|
||||
mlir::applyPartialConversion(Operation *op, ConversionTarget &target,
|
||||
const FrozenRewritePatternList &patterns,
|
||||
const FrozenRewritePatternSet &patterns,
|
||||
DenseSet<Operation *> *unconvertedOps) {
|
||||
return applyPartialConversion(llvm::makeArrayRef(op), target, patterns,
|
||||
unconvertedOps);
|
||||
|
@ -2774,13 +2774,13 @@ mlir::applyPartialConversion(Operation *op, ConversionTarget &target,
|
|||
/// operation fails.
|
||||
LogicalResult
|
||||
mlir::applyFullConversion(ArrayRef<Operation *> ops, ConversionTarget &target,
|
||||
const FrozenRewritePatternList &patterns) {
|
||||
const FrozenRewritePatternSet &patterns) {
|
||||
OperationConverter opConverter(target, patterns, OpConversionMode::Full);
|
||||
return opConverter.convertOperations(ops);
|
||||
}
|
||||
LogicalResult
|
||||
mlir::applyFullConversion(Operation *op, ConversionTarget &target,
|
||||
const FrozenRewritePatternList &patterns) {
|
||||
const FrozenRewritePatternSet &patterns) {
|
||||
return applyFullConversion(llvm::makeArrayRef(op), target, patterns);
|
||||
}
|
||||
|
||||
|
@ -2793,7 +2793,7 @@ mlir::applyFullConversion(Operation *op, ConversionTarget &target,
|
|||
LogicalResult
|
||||
mlir::applyAnalysisConversion(ArrayRef<Operation *> ops,
|
||||
ConversionTarget &target,
|
||||
const FrozenRewritePatternList &patterns,
|
||||
const FrozenRewritePatternSet &patterns,
|
||||
DenseSet<Operation *> &convertedOps) {
|
||||
OperationConverter opConverter(target, patterns, OpConversionMode::Analysis,
|
||||
&convertedOps);
|
||||
|
@ -2801,7 +2801,7 @@ mlir::applyAnalysisConversion(ArrayRef<Operation *> ops,
|
|||
}
|
||||
LogicalResult
|
||||
mlir::applyAnalysisConversion(Operation *op, ConversionTarget &target,
|
||||
const FrozenRewritePatternList &patterns,
|
||||
const FrozenRewritePatternSet &patterns,
|
||||
DenseSet<Operation *> &convertedOps) {
|
||||
return applyAnalysisConversion(llvm::makeArrayRef(op), target, patterns,
|
||||
convertedOps);
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace {
|
|||
class GreedyPatternRewriteDriver : public PatternRewriter {
|
||||
public:
|
||||
explicit GreedyPatternRewriteDriver(MLIRContext *ctx,
|
||||
const FrozenRewritePatternList &patterns,
|
||||
const FrozenRewritePatternSet &patterns,
|
||||
bool useTopDownTraversal)
|
||||
: PatternRewriter(ctx), matcher(patterns), folder(ctx),
|
||||
useTopDownTraversal(useTopDownTraversal) {
|
||||
|
@ -242,13 +242,13 @@ bool GreedyPatternRewriteDriver::simplify(MutableArrayRef<Region> regions,
|
|||
///
|
||||
LogicalResult
|
||||
mlir::applyPatternsAndFoldGreedily(Operation *op,
|
||||
const FrozenRewritePatternList &patterns,
|
||||
const FrozenRewritePatternSet &patterns,
|
||||
bool useTopDownTraversal) {
|
||||
return applyPatternsAndFoldGreedily(op, patterns, maxPatternMatchIterations,
|
||||
useTopDownTraversal);
|
||||
}
|
||||
LogicalResult mlir::applyPatternsAndFoldGreedily(
|
||||
Operation *op, const FrozenRewritePatternList &patterns,
|
||||
Operation *op, const FrozenRewritePatternSet &patterns,
|
||||
unsigned maxIterations, bool useTopDownTraversal) {
|
||||
return applyPatternsAndFoldGreedily(op->getRegions(), patterns, maxIterations,
|
||||
useTopDownTraversal);
|
||||
|
@ -256,13 +256,13 @@ LogicalResult mlir::applyPatternsAndFoldGreedily(
|
|||
/// Rewrite the given regions, which must be isolated from above.
|
||||
LogicalResult
|
||||
mlir::applyPatternsAndFoldGreedily(MutableArrayRef<Region> regions,
|
||||
const FrozenRewritePatternList &patterns,
|
||||
const FrozenRewritePatternSet &patterns,
|
||||
bool useTopDownTraversal) {
|
||||
return applyPatternsAndFoldGreedily(
|
||||
regions, patterns, maxPatternMatchIterations, useTopDownTraversal);
|
||||
}
|
||||
LogicalResult mlir::applyPatternsAndFoldGreedily(
|
||||
MutableArrayRef<Region> regions, const FrozenRewritePatternList &patterns,
|
||||
MutableArrayRef<Region> regions, const FrozenRewritePatternSet &patterns,
|
||||
unsigned maxIterations, bool useTopDownTraversal) {
|
||||
if (regions.empty())
|
||||
return success();
|
||||
|
@ -298,7 +298,7 @@ namespace {
|
|||
class OpPatternRewriteDriver : public PatternRewriter {
|
||||
public:
|
||||
explicit OpPatternRewriteDriver(MLIRContext *ctx,
|
||||
const FrozenRewritePatternList &patterns)
|
||||
const FrozenRewritePatternSet &patterns)
|
||||
: PatternRewriter(ctx), matcher(patterns), folder(ctx) {
|
||||
// Apply a simple cost model based solely on pattern benefit.
|
||||
matcher.applyDefaultCostModel();
|
||||
|
@ -382,7 +382,7 @@ LogicalResult OpPatternRewriteDriver::simplifyLocally(Operation *op,
|
|||
/// folding. `erased` is set to true if the op is erased as a result of being
|
||||
/// folded, replaced, or dead.
|
||||
LogicalResult mlir::applyOpPatternsAndFold(
|
||||
Operation *op, const FrozenRewritePatternList &patterns, bool *erased) {
|
||||
Operation *op, const FrozenRewritePatternSet &patterns, bool *erased) {
|
||||
// Start the pattern driver.
|
||||
OpPatternRewriteDriver driver(op->getContext(), patterns);
|
||||
bool opErased;
|
||||
|
|
|
@ -61,7 +61,7 @@ void TestConvVectorization::runOnOperation() {
|
|||
|
||||
SmallVector<RewritePatternSet, 4> stage1Patterns;
|
||||
linalg::populateConvVectorizationPatterns(context, stage1Patterns, tileSizes);
|
||||
SmallVector<FrozenRewritePatternList, 4> frozenStage1Patterns;
|
||||
SmallVector<FrozenRewritePatternSet, 4> frozenStage1Patterns;
|
||||
llvm::move(stage1Patterns, std::back_inserter(frozenStage1Patterns));
|
||||
|
||||
RewritePatternSet stage2Patterns =
|
||||
|
|
|
@ -184,7 +184,7 @@ struct TestLinalgGreedyFusion
|
|||
RewritePatternSet patterns =
|
||||
linalg::getLinalgTilingCanonicalizationPatterns(context);
|
||||
patterns.add<AffineMinSCFCanonicalizationPattern>(context);
|
||||
FrozenRewritePatternList frozenPatterns(std::move(patterns));
|
||||
FrozenRewritePatternSet frozenPatterns(std::move(patterns));
|
||||
while (succeeded(fuseLinalgOpsGreedily(getFunction()))) {
|
||||
(void)applyPatternsAndFoldGreedily(getFunction(), frozenPatterns);
|
||||
PassManager pm(context);
|
||||
|
|
|
@ -478,9 +478,9 @@ applyMatmulToVectorPatterns(FuncOp funcOp,
|
|||
fillL1TilingAndMatmulToVectorPatterns(funcOp, Identifier::get("L2", ctx),
|
||||
stage1Patterns);
|
||||
}
|
||||
SmallVector<FrozenRewritePatternList, 4> frozenStage1Patterns;
|
||||
SmallVector<FrozenRewritePatternSet, 4> frozenStage1Patterns;
|
||||
llvm::move(stage1Patterns, std::back_inserter(frozenStage1Patterns));
|
||||
FrozenRewritePatternList stage2Patterns =
|
||||
FrozenRewritePatternSet stage2Patterns =
|
||||
getLinalgTilingCanonicalizationPatterns(ctx);
|
||||
(void)applyStagedPatterns(funcOp, frozenStage1Patterns,
|
||||
std::move(stage2Patterns));
|
||||
|
@ -505,7 +505,7 @@ static void applyLinalgToVectorPatterns(FuncOp funcOp) {
|
|||
static void applyAffineMinSCFCanonicalizationPatterns(FuncOp funcOp) {
|
||||
RewritePatternSet foldPattern(funcOp.getContext());
|
||||
foldPattern.add<AffineMinSCFCanonicalizationPattern>(funcOp.getContext());
|
||||
FrozenRewritePatternList frozenPatterns(std::move(foldPattern));
|
||||
FrozenRewritePatternSet frozenPatterns(std::move(foldPattern));
|
||||
|
||||
// Explicitly walk and apply the pattern locally to avoid more general folding
|
||||
// on the rest of the IR.
|
||||
|
|
|
@ -60,7 +60,7 @@ TEST(PatternBenefitTest, BenefitOrder) {
|
|||
patterns.add<Pattern1>(&context, &called1);
|
||||
patterns.add<Pattern2>(&called2);
|
||||
|
||||
FrozenRewritePatternList frozenPatterns(std::move(patterns));
|
||||
FrozenRewritePatternSet frozenPatterns(std::move(patterns));
|
||||
PatternApplicator pa(frozenPatterns);
|
||||
pa.applyDefaultCostModel();
|
||||
|
||||
|
|
Loading…
Reference in New Issue