Skip to content

Commit 79d7f61

Browse files
committed
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
1 parent a0c776f commit 79d7f61

23 files changed

+79
-75
lines changed

mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
namespace mlir {
2121
class BufferizeTypeConverter;
22-
class FrozenRewritePatternList;
22+
class FrozenRewritePatternSet;
2323

2424
namespace linalg {
2525

@@ -964,17 +964,17 @@ class ConvOpVectorization : public OpRewritePattern<ConvOp> {
964964
//===----------------------------------------------------------------------===//
965965
/// Helper function to allow applying rewrite patterns, interleaved with more
966966
/// global transformations, in a staged fashion:
967-
/// 1. the first stage consists of a list of FrozenRewritePatternList. Each
968-
/// FrozenRewritePatternList in this list is applied once, in order.
967+
/// 1. the first stage consists of a list of FrozenRewritePatternSet. Each
968+
/// FrozenRewritePatternSet in this list is applied once, in order.
969969
/// 2. the second stage consists of a single OwningRewritePattern that is
970970
/// applied greedily until convergence.
971971
/// 3. the third stage consists of applying a lambda, generally used for
972972
/// non-local transformation effects. This allows creating custom fused
973973
/// transformations where patterns can be ordered and applied at a finer
974974
/// granularity than a sequence of traditional compiler passes.
975975
LogicalResult applyStagedPatterns(
976-
Operation *op, ArrayRef<FrozenRewritePatternList> stage1Patterns,
977-
const FrozenRewritePatternList &stage2Patterns,
976+
Operation *op, ArrayRef<FrozenRewritePatternSet> stage1Patterns,
977+
const FrozenRewritePatternSet &stage2Patterns,
978978
function_ref<LogicalResult(Operation *)> stage3Lambda = nullptr);
979979

980980
//===----------------------------------------------------------------------===//

mlir/include/mlir/IR/PatternMatch.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,7 @@ class RewritePatternSet {
894894
PDLPatternModule pdlPatterns;
895895
};
896896

897-
// TODO: RewritePatternSet is soft-deprecated and will be removed in the
897+
// TODO: OwningRewritePatternList is soft-deprecated and will be removed in the
898898
// future.
899899
using OwningRewritePatternList = RewritePatternSet;
900900

mlir/include/mlir/Rewrite/FrozenRewritePatternList.h renamed to mlir/include/mlir/Rewrite/FrozenRewritePatternSet.h

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
//===- FrozenRewritePatternList.h - FrozenRewritePatternList ----*- C++ -*-===//
1+
//===- FrozenRewritePatternSet.h --------------------------------*- C++ -*-===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#ifndef MLIR_REWRITE_FROZENREWRITEPATTERNLIST_H
10-
#define MLIR_REWRITE_FROZENREWRITEPATTERNLIST_H
9+
#ifndef MLIR_REWRITE_FROZENREWRITEPATTERNSET_H
10+
#define MLIR_REWRITE_FROZENREWRITEPATTERNSET_H
1111

1212
#include "mlir/IR/PatternMatch.h"
1313

@@ -21,20 +21,20 @@ class PDLByteCode;
2121
/// such that they need not be continuously recomputed. Note that all copies of
2222
/// this class share the same compiled pattern list, allowing for a reduction in
2323
/// the number of duplicated patterns that need to be created.
24-
class FrozenRewritePatternList {
24+
class FrozenRewritePatternSet {
2525
using NativePatternListT = std::vector<std::unique_ptr<RewritePattern>>;
2626

2727
public:
2828
/// Freeze the patterns held in `patterns`, and take ownership.
29-
FrozenRewritePatternList();
30-
FrozenRewritePatternList(RewritePatternSet &&patterns);
31-
FrozenRewritePatternList(FrozenRewritePatternList &&patterns) = default;
32-
FrozenRewritePatternList(const FrozenRewritePatternList &patterns) = default;
33-
FrozenRewritePatternList &
34-
operator=(const FrozenRewritePatternList &patterns) = default;
35-
FrozenRewritePatternList &
36-
operator=(FrozenRewritePatternList &&patterns) = default;
37-
~FrozenRewritePatternList();
29+
FrozenRewritePatternSet();
30+
FrozenRewritePatternSet(RewritePatternSet &&patterns);
31+
FrozenRewritePatternSet(FrozenRewritePatternSet &&patterns) = default;
32+
FrozenRewritePatternSet(const FrozenRewritePatternSet &patterns) = default;
33+
FrozenRewritePatternSet &
34+
operator=(const FrozenRewritePatternSet &patterns) = default;
35+
FrozenRewritePatternSet &
36+
operator=(FrozenRewritePatternSet &&patterns) = default;
37+
~FrozenRewritePatternSet();
3838

3939
/// Return the native patterns held by this list.
4040
iterator_range<llvm::pointee_iterator<NativePatternListT::const_iterator>>
@@ -66,6 +66,10 @@ class FrozenRewritePatternList {
6666
std::shared_ptr<Impl> impl;
6767
};
6868

69+
// TODO: FrozenRewritePatternList is soft-deprecated and will be removed in the
70+
// future.
71+
using FrozenRewritePatternList = FrozenRewritePatternSet;
72+
6973
} // end namespace mlir
7074

71-
#endif // MLIR_REWRITE_FROZENREWRITEPATTERNLIST_H
75+
#endif // MLIR_REWRITE_FROZENREWRITEPATTERNSET_H

mlir/include/mlir/Rewrite/PatternApplicator.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#ifndef MLIR_REWRITE_PATTERNAPPLICATOR_H
1515
#define MLIR_REWRITE_PATTERNAPPLICATOR_H
1616

17-
#include "mlir/Rewrite/FrozenRewritePatternList.h"
17+
#include "mlir/Rewrite/FrozenRewritePatternSet.h"
1818

1919
namespace mlir {
2020
class PatternRewriter;
@@ -33,7 +33,7 @@ class PatternApplicator {
3333
/// `impossibleToMatch`.
3434
using CostModel = function_ref<PatternBenefit(const Pattern &)>;
3535

36-
explicit PatternApplicator(const FrozenRewritePatternList &frozenPatternList);
36+
explicit PatternApplicator(const FrozenRewritePatternSet &frozenPatternList);
3737
~PatternApplicator();
3838

3939
/// Attempt to match and rewrite the given op with any pattern, allowing a
@@ -65,7 +65,7 @@ class PatternApplicator {
6565

6666
private:
6767
/// The list that owns the patterns used within this applicator.
68-
const FrozenRewritePatternList &frozenPatternList;
68+
const FrozenRewritePatternSet &frozenPatternList;
6969
/// The set of patterns to match for each operation, stable sorted by benefit.
7070
DenseMap<OperationName, SmallVector<const RewritePattern *, 2>> patterns;
7171
/// The set of patterns that may match against any operation type, stable

mlir/include/mlir/Transforms/DialectConversion.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#ifndef MLIR_TRANSFORMS_DIALECTCONVERSION_H_
1414
#define MLIR_TRANSFORMS_DIALECTCONVERSION_H_
1515

16-
#include "mlir/Rewrite/FrozenRewritePatternList.h"
16+
#include "mlir/Rewrite/FrozenRewritePatternSet.h"
1717
#include "llvm/ADT/MapVector.h"
1818
#include "llvm/ADT/StringMap.h"
1919

@@ -842,11 +842,11 @@ class ConversionTarget {
842842
/// the `unconvertedOps` set will not necessarily be complete.)
843843
LogicalResult
844844
applyPartialConversion(ArrayRef<Operation *> ops, ConversionTarget &target,
845-
const FrozenRewritePatternList &patterns,
845+
const FrozenRewritePatternSet &patterns,
846846
DenseSet<Operation *> *unconvertedOps = nullptr);
847847
LogicalResult
848848
applyPartialConversion(Operation *op, ConversionTarget &target,
849-
const FrozenRewritePatternList &patterns,
849+
const FrozenRewritePatternSet &patterns,
850850
DenseSet<Operation *> *unconvertedOps = nullptr);
851851

852852
/// Apply a complete conversion on the given operations, and all nested
@@ -855,9 +855,9 @@ applyPartialConversion(Operation *op, ConversionTarget &target,
855855
/// within 'ops'.
856856
LogicalResult applyFullConversion(ArrayRef<Operation *> ops,
857857
ConversionTarget &target,
858-
const FrozenRewritePatternList &patterns);
858+
const FrozenRewritePatternSet &patterns);
859859
LogicalResult applyFullConversion(Operation *op, ConversionTarget &target,
860-
const FrozenRewritePatternList &patterns);
860+
const FrozenRewritePatternSet &patterns);
861861

862862
/// Apply an analysis conversion on the given operations, and all nested
863863
/// operations. This method analyzes which operations would be successfully
@@ -869,10 +869,10 @@ LogicalResult applyFullConversion(Operation *op, ConversionTarget &target,
869869
/// the regions nested within 'ops'.
870870
LogicalResult applyAnalysisConversion(ArrayRef<Operation *> ops,
871871
ConversionTarget &target,
872-
const FrozenRewritePatternList &patterns,
872+
const FrozenRewritePatternSet &patterns,
873873
DenseSet<Operation *> &convertedOps);
874874
LogicalResult applyAnalysisConversion(Operation *op, ConversionTarget &target,
875-
const FrozenRewritePatternList &patterns,
875+
const FrozenRewritePatternSet &patterns,
876876
DenseSet<Operation *> &convertedOps);
877877
} // end namespace mlir
878878

mlir/include/mlir/Transforms/GreedyPatternRewriteDriver.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#ifndef MLIR_TRANSFORMS_GREEDYPATTERNREWRITEDRIVER_H_
1515
#define MLIR_TRANSFORMS_GREEDYPATTERNREWRITEDRIVER_H_
1616

17-
#include "mlir/Rewrite/FrozenRewritePatternList.h"
17+
#include "mlir/Rewrite/FrozenRewritePatternSet.h"
1818

1919
namespace mlir {
2020

@@ -35,25 +35,25 @@ namespace mlir {
3535
/// before attempting to match any of the provided patterns.
3636
LogicalResult
3737
applyPatternsAndFoldGreedily(Operation *op,
38-
const FrozenRewritePatternList &patterns,
38+
const FrozenRewritePatternSet &patterns,
3939
bool useTopDownTraversal = true);
4040

4141
/// Rewrite the regions of the specified operation, with a user-provided limit
4242
/// on iterations to attempt before reaching convergence.
4343
LogicalResult applyPatternsAndFoldGreedily(
44-
Operation *op, const FrozenRewritePatternList &patterns,
44+
Operation *op, const FrozenRewritePatternSet &patterns,
4545
unsigned maxIterations, bool useTopDownTraversal = true);
4646

4747
/// Rewrite the given regions, which must be isolated from above.
4848
LogicalResult
4949
applyPatternsAndFoldGreedily(MutableArrayRef<Region> regions,
50-
const FrozenRewritePatternList &patterns,
50+
const FrozenRewritePatternSet &patterns,
5151
bool useTopDownTraversal = true);
5252

5353
/// Rewrite the given regions, with a user-provided limit on iterations to
5454
/// attempt before reaching convergence.
5555
LogicalResult applyPatternsAndFoldGreedily(
56-
MutableArrayRef<Region> regions, const FrozenRewritePatternList &patterns,
56+
MutableArrayRef<Region> regions, const FrozenRewritePatternSet &patterns,
5757
unsigned maxIterations, bool useTopDownTraversal = true);
5858

5959
/// Applies the specified patterns on `op` alone while also trying to fold it,
@@ -62,7 +62,7 @@ LogicalResult applyPatternsAndFoldGreedily(
6262
/// was folded away or erased as a result of becoming dead. Note: This does not
6363
/// apply any patterns recursively to the regions of `op`.
6464
LogicalResult applyOpPatternsAndFold(Operation *op,
65-
const FrozenRewritePatternList &patterns,
65+
const FrozenRewritePatternSet &patterns,
6666
bool *erased = nullptr);
6767

6868
} // end namespace mlir

mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ static LogicalResult applyPatterns(FuncOp func) {
9292

9393
RewritePatternSet patterns(func.getContext());
9494
patterns.add<ParallelOpLowering>(func.getContext());
95-
FrozenRewritePatternList frozen(std::move(patterns));
95+
FrozenRewritePatternSet frozen(std::move(patterns));
9696
return applyPartialConversion(func, target, frozen);
9797
}
9898

mlir/lib/Dialect/Affine/Transforms/AffineDataCopyGeneration.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ void AffineDataCopyGeneration::runOnFunction() {
230230
RewritePatternSet patterns(&getContext());
231231
AffineLoadOp::getCanonicalizationPatterns(patterns, &getContext());
232232
AffineStoreOp::getCanonicalizationPatterns(patterns, &getContext());
233-
FrozenRewritePatternList frozenPatterns(std::move(patterns));
233+
FrozenRewritePatternSet frozenPatterns(std::move(patterns));
234234
for (Operation *op : copyOps)
235235
(void)applyOpPatternsAndFold(op, frozenPatterns);
236236
}

mlir/lib/Dialect/Affine/Transforms/SimplifyAffineStructures.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ void SimplifyAffineStructures::runOnFunction() {
8383
AffineForOp::getCanonicalizationPatterns(patterns, func.getContext());
8484
AffineIfOp::getCanonicalizationPatterns(patterns, func.getContext());
8585
AffineApplyOp::getCanonicalizationPatterns(patterns, func.getContext());
86-
FrozenRewritePatternList frozenPatterns(std::move(patterns));
86+
FrozenRewritePatternSet frozenPatterns(std::move(patterns));
8787
func.walk([&](Operation *op) {
8888
for (auto attr : op->getAttrs()) {
8989
if (auto mapAttr = attr.second.dyn_cast<AffineMapAttr>())

mlir/lib/Dialect/Affine/Utils/Utils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ LogicalResult mlir::hoistAffineIfOp(AffineIfOp ifOp, bool *folded) {
191191
RewritePatternSet patterns(ifOp.getContext());
192192
AffineIfOp::getCanonicalizationPatterns(patterns, ifOp.getContext());
193193
bool erased;
194-
FrozenRewritePatternList frozenPatterns(std::move(patterns));
194+
FrozenRewritePatternSet frozenPatterns(std::move(patterns));
195195
(void)applyOpPatternsAndFold(ifOp, frozenPatterns, &erased);
196196
if (erased) {
197197
if (folded)

0 commit comments

Comments
 (0)