class ModuleOp;
class RewritePattern;
class Type;
-using OwningRewritePatternList = std::vector<std::unique_ptr<RewritePattern>>;
+class OwningRewritePatternList;
namespace LLVM {
class LLVMType;
} // end namespace LLVM
void linalg::populateLinalg1ToLLVMConversionPatterns(
mlir::OwningRewritePatternList &patterns, mlir::MLIRContext *context) {
- RewriteListBuilder<DropConsumer, RangeOpConversion, SliceOpConversion,
- ViewOpConversion>::build(patterns, context);
+ patterns.insert<DropConsumer, RangeOpConversion, SliceOpConversion,
+ ViewOpConversion>(context);
}
namespace {
// coverters to the list.
static void populateLinalg3ToLLVMConversionPatterns(
mlir::OwningRewritePatternList &patterns, mlir::MLIRContext *context) {
- RewriteListBuilder<LoadOpConversion, StoreOpConversion>::build(patterns,
- context);
+ patterns.insert<LoadOpConversion, StoreOpConversion>(context);
}
LogicalResult linalg::convertLinalg3ToLLVM(ModuleOp module) {
void runOnFunction() {
OwningRewritePatternList patterns;
auto *context = &getContext();
- patterns.push_back(llvm::make_unique<Rewriter<linalg::LoadOp>>(context));
- patterns.push_back(llvm::make_unique<Rewriter<linalg::StoreOp>>(context));
+ patterns.insert<Rewriter<linalg::LoadOp>, Rewriter<linalg::StoreOp>>(
+ context);
applyPatternsGreedily(getFunction(), std::move(patterns));
}
};
// Register our patterns for rewrite by the Canonicalization framework.
void TransposeOp::getCanonicalizationPatterns(
mlir::OwningRewritePatternList &results, mlir::MLIRContext *context) {
- results.push_back(llvm::make_unique<SimplifyRedundantTranspose>(context));
+ results.insert<SimplifyRedundantTranspose>(context);
}
// Register our patterns for rewrite by the Canonicalization framework.
void ReshapeOp::getCanonicalizationPatterns(
mlir::OwningRewritePatternList &results, mlir::MLIRContext *context) {
- mlir::RewriteListBuilder<SimplifyReshapeConstant, SimplifyReshapeReshape,
- SimplifyNullReshape>::build(results, context);
+ results.insert<SimplifyReshapeConstant, SimplifyReshapeReshape,
+ SimplifyNullReshape>(context);
}
} // namespace toy
target.addLegalOp<toy::AllocOp, toy::TypeCastOp>();
OwningRewritePatternList patterns;
- RewriteListBuilder<MulOpConversion>::build(patterns, &getContext());
+ patterns.insert<MulOpConversion>(&getContext());
if (failed(applyPartialConversion(getFunction(), target,
std::move(patterns)))) {
emitError(mlir::UnknownLoc::get(&getContext()), "Error lowering Toy\n");
void runOnModule() override {
ToyTypeConverter typeConverter;
OwningRewritePatternList toyPatterns;
- RewriteListBuilder<AddOpConversion, PrintOpConversion, ConstantOpConversion,
- TransposeOpConversion,
- ReturnOpConversion>::build(toyPatterns, &getContext());
+ toyPatterns.insert<AddOpConversion, PrintOpConversion, ConstantOpConversion,
+ TransposeOpConversion, ReturnOpConversion>(
+ &getContext());
mlir::populateFuncOpTypeConversionPattern(toyPatterns, &getContext(),
typeConverter);
// Register our patterns for rewrite by the Canonicalization framework.
void TransposeOp::getCanonicalizationPatterns(
mlir::OwningRewritePatternList &results, mlir::MLIRContext *context) {
- results.push_back(llvm::make_unique<SimplifyRedundantTranspose>(context));
+ results.insert<SimplifyRedundantTranspose>(context);
}
// Register our patterns for rewrite by the Canonicalization framework.
void ReshapeOp::getCanonicalizationPatterns(
mlir::OwningRewritePatternList &results, mlir::MLIRContext *context) {
- mlir::RewriteListBuilder<SimplifyReshapeConstant, SimplifyReshapeReshape,
- SimplifyNullReshape>::build(results, context);
+ results.insert<SimplifyReshapeConstant, SimplifyReshapeReshape,
+ SimplifyNullReshape>(context);
}
namespace {
void TypeCastOp::getCanonicalizationPatterns(
mlir::OwningRewritePatternList &results, mlir::MLIRContext *context) {
- results.push_back(llvm::make_unique<SimplifyIdentityTypeCast>(context));
+ results.insert<SimplifyIdentityTypeCast>(context);
}
} // namespace toy
class RewritePattern;
// Owning list of rewriting patterns.
-using OwningRewritePatternList = std::vector<std::unique_ptr<RewritePattern>>;
+class OwningRewritePatternList;
/// Collect a set of patterns to lower from loop.for, loop.if, and
/// loop.terminator to CFG operations within the Standard dialect, in particular
class Type;
// Owning list of rewriting patterns.
-using OwningRewritePatternList = std::vector<std::unique_ptr<RewritePattern>>;
+class OwningRewritePatternList;
/// Type for a callback constructing the owning list of patterns for the
/// conversion to the LLVMIR dialect. The callback is expected to append
/// either OpTy or OperandAdaptor<OpTy> seamlessly.
template <typename OpTy> using OperandAdaptor = typename OpTy::OperandAdaptor;
-/// This is a vector that owns the patterns inside of it.
-using OwningPatternList = std::vector<std::unique_ptr<Pattern>>;
-using OwningRewritePatternList = std::vector<std::unique_ptr<RewritePattern>>;
+class OwningRewritePatternList;
enum class OperationProperty {
/// This bit is set for an operation if it is a commutative operation: that
// Pattern-driven rewriters
//===----------------------------------------------------------------------===//
-/// This is a vector that owns the patterns inside of it.
-using OwningRewritePatternList = std::vector<std::unique_ptr<RewritePattern>>;
+class OwningRewritePatternList {
+ using PatternListT = std::vector<std::unique_ptr<RewritePattern>>;
+
+public:
+ PatternListT::iterator begin() { return patterns.begin(); }
+ PatternListT::iterator end() { return patterns.end(); }
+ PatternListT::const_iterator begin() const { return patterns.begin(); }
+ PatternListT::const_iterator end() const { return patterns.end(); }
+
+ //===--------------------------------------------------------------------===//
+ // Pattern Insertion
+ //===--------------------------------------------------------------------===//
+
+ void insert(RewritePattern *pattern) { patterns.emplace_back(pattern); }
+
+ /// Add an instance of each of the pattern types 'Ts' to the pattern list with
+ /// the given arguments.
+ // Note: ConstructorArg is necessary here to separate the two variadic lists.
+ template <typename... Ts, typename ConstructorArg,
+ typename... ConstructorArgs>
+ void insert(ConstructorArg &&arg, ConstructorArgs &&... args) {
+ // The following expands a call to emplace_back for each of the pattern
+ // types 'Ts'. This magic is necessary due to a limitation in the places
+ // that a parameter pack can be expanded in c++11.
+ // FIXME: In c++17 this can be simplified by using 'fold expressions'.
+ using dummy = int[];
+ (void)dummy{
+ 0, (patterns.emplace_back(llvm::make_unique<Ts>(arg, args...)), 0)...};
+ }
+
+private:
+ PatternListT patterns;
+};
/// This class manages optimization and execution of a group of rewrite
/// patterns, providing an API for finding and applying, the best match against
class RewritePatternMatcher {
public:
/// Create a RewritePatternMatcher with the specified set of patterns.
- explicit RewritePatternMatcher(OwningRewritePatternList &&patterns);
+ explicit RewritePatternMatcher(OwningRewritePatternList &patterns);
/// Try to match the given operation to a pattern and rewrite it. Return
/// true if any pattern matches.
/// The group of patterns that are matched for optimization through this
/// matcher.
- OwningRewritePatternList patterns;
+ std::vector<RewritePattern *> patterns;
};
/// Rewrite the regions of the specified operation, which must be isolated from
///
bool applyPatternsGreedily(Operation *op, OwningRewritePatternList &&patterns);
-/// Helper class to create a list of rewrite patterns given a list of their
-/// types and a list of attributes perfect-forwarded to each of the conversion
-/// constructors.
-template <typename Arg, typename... Args> struct RewriteListBuilder {
- template <typename... ConstructorArgs>
- static void build(OwningRewritePatternList &patterns,
- ConstructorArgs &&... constructorArgs) {
- RewriteListBuilder<Args...>::build(
- patterns, std::forward<ConstructorArgs>(constructorArgs)...);
- RewriteListBuilder<Arg>::build(
- patterns, std::forward<ConstructorArgs>(constructorArgs)...);
- }
-};
-
-// Template specialization to stop recursion.
-template <typename Arg> struct RewriteListBuilder<Arg> {
- template <typename... ConstructorArgs>
- static void build(OwningRewritePatternList &patterns,
- ConstructorArgs &&... constructorArgs) {
- patterns.emplace_back(llvm::make_unique<Arg>(
- std::forward<ConstructorArgs>(constructorArgs)...));
- }
-};
} // end namespace mlir
#endif // MLIR_PATTERN_MATCH_H
class Value;
// Owning list of rewriting patterns.
-using OwningRewritePatternList = std::vector<std::unique_ptr<RewritePattern>>;
+class OwningRewritePatternList;
/// Emit code that computes the given affine expression using standard
/// arithmetic operations applied to the provided dimension and symbol values.
void AffineApplyOp::getCanonicalizationPatterns(
OwningRewritePatternList &results, MLIRContext *context) {
- results.push_back(llvm::make_unique<SimplifyAffineApply>(context));
+ results.insert<SimplifyAffineApply>(context);
}
//===----------------------------------------------------------------------===//
void AffineDmaStartOp::getCanonicalizationPatterns(
OwningRewritePatternList &results, MLIRContext *context) {
/// dma_start(memrefcast) -> dma_start
- results.push_back(
- llvm::make_unique<MemRefCastFolder>(getOperationName(), context));
+ results.insert<MemRefCastFolder>(getOperationName(), context);
}
//===----------------------------------------------------------------------===//
void AffineDmaWaitOp::getCanonicalizationPatterns(
OwningRewritePatternList &results, MLIRContext *context) {
/// dma_wait(memrefcast) -> dma_wait
- results.push_back(
- llvm::make_unique<MemRefCastFolder>(getOperationName(), context));
+ results.insert<MemRefCastFolder>(getOperationName(), context);
}
//===----------------------------------------------------------------------===//
void AffineForOp::getCanonicalizationPatterns(OwningRewritePatternList &results,
MLIRContext *context) {
- results.push_back(llvm::make_unique<AffineForLoopBoundFolder>(context));
+ results.insert<AffineForLoopBoundFolder>(context);
}
AffineBound AffineForOp::getLowerBound() {
void AffineLoadOp::getCanonicalizationPatterns(
OwningRewritePatternList &results, MLIRContext *context) {
/// load(memrefcast) -> load
- results.push_back(
- llvm::make_unique<MemRefCastFolder>(getOperationName(), context));
+ results.insert<MemRefCastFolder>(getOperationName(), context);
}
//===----------------------------------------------------------------------===//
void AffineStoreOp::getCanonicalizationPatterns(
OwningRewritePatternList &results, MLIRContext *context) {
/// load(memrefcast) -> load
- results.push_back(
- llvm::make_unique<MemRefCastFolder>(getOperationName(), context));
+ results.insert<MemRefCastFolder>(getOperationName(), context);
}
#define GET_OP_CLASSES
void mlir::populateLoopToStdConversionPatterns(
OwningRewritePatternList &patterns, MLIRContext *ctx) {
- RewriteListBuilder<ForLowering, IfLowering, TerminatorLowering>::build(
- patterns, ctx);
+ patterns.insert<ForLowering, IfLowering, TerminatorLowering>(ctx);
}
void ControlFlowToCFGPass::runOnFunction() {
SPIRVTypeConverter typeConverter(context);
SPIRVEntryFnTypeConverter entryFnConverter(context);
OwningRewritePatternList patterns;
- RewriteListBuilder<KernelFnConversion>::build(
- patterns, context, typeConverter, entryFnConverter);
+ patterns.insert<KernelFnConversion>(context, typeConverter, entryFnConverter);
populateStandardToSPIRVPatterns(context, patterns);
ConversionTarget target(*context);
void mlir::populateStdToLLVMConversionPatterns(
LLVMTypeConverter &converter, OwningRewritePatternList &patterns) {
// FIXME: this should be tablegen'ed
- RewriteListBuilder<
+ patterns.insert<
AddFOpLowering, AddIOpLowering, AndOpLowering, AllocOpLowering,
BranchOpLowering, CallIndirectOpLowering, CallOpLowering, CmpIOpLowering,
CondBranchOpLowering, ConstLLVMOpLowering, DeallocOpLowering,
MemRefCastOpLowering, MulFOpLowering, MulIOpLowering, OrOpLowering,
RemISOpLowering, RemIUOpLowering, RemFOpLowering, ReturnOpLowering,
SelectOpLowering, SIToFPLowering, StoreOpLowering, SubFOpLowering,
- SubIOpLowering, XOrOpLowering>::build(patterns, *converter.getDialect(),
- converter);
+ SubIOpLowering, XOrOpLowering>(*converter.getDialect(), converter);
}
// Convert types using the stored LLVM IR module.
OwningRewritePatternList &patterns) {
populateWithGenerated(context, &patterns);
// Add the return op conversion.
- RewriteListBuilder<ReturnToSPIRVConversion>::build(patterns, context);
+ patterns.insert<ReturnToSPIRVConversion>(context);
}
} // namespace mlir
auto fn = getFunction();
OwningRewritePatternList patterns;
auto *context = &getContext();
- patterns.push_back(llvm::make_unique<UniformRealAddEwPattern>(context));
- patterns.push_back(llvm::make_unique<UniformRealMulEwPattern>(context));
+ patterns.insert<UniformRealAddEwPattern, UniformRealMulEwPattern>(context);
applyPatternsGreedily(fn, std::move(patterns));
}
auto fn = getFunction();
OwningRewritePatternList patterns;
auto *context = &getContext();
- patterns.push_back(llvm::make_unique<UniformDequantizePattern>(context));
+ patterns.insert<UniformDequantizePattern>(context);
applyPatternsGreedily(fn, std::move(patterns));
}
void LaunchOp::getCanonicalizationPatterns(OwningRewritePatternList &results,
MLIRContext *context) {
- RewriteListBuilder<PropagateConstantBounds>::build(results, context);
+ results.insert<PropagateConstantBounds>(context);
}
//===----------------------------------------------------------------------===//
void StorageCastOp::getCanonicalizationPatterns(
OwningRewritePatternList &patterns, MLIRContext *context) {
- patterns.push_back(
- llvm::make_unique<RemoveRedundantStorageCastsRewrite>(context));
+ patterns.insert<RemoveRedundantStorageCastsRewrite>(context);
}
QuantizationDialect::QuantizationDialect(MLIRContext *context)
OwningRewritePatternList patterns;
auto func = getFunction();
auto *context = &getContext();
- patterns.push_back(llvm::make_unique<QuantizedConstRewrite>(context));
+ patterns.insert<QuantizedConstRewrite>(context);
applyPatternsGreedily(func, std::move(patterns));
}
OwningRewritePatternList patterns;
auto func = getFunction();
auto *context = &getContext();
- patterns.push_back(
- llvm::make_unique<ConstFakeQuantRewrite>(context, &hadFailure));
+ patterns.insert<ConstFakeQuantRewrite>(context, &hadFailure);
applyPatternsGreedily(func, std::move(patterns));
if (hadFailure)
signalPassFailure();
//===----------------------------------------------------------------------===//
RewritePatternMatcher::RewritePatternMatcher(
- OwningRewritePatternList &&patterns)
- : patterns(std::move(patterns)) {
+ OwningRewritePatternList &patterns) {
+ for (auto &pattern : patterns)
+ this->patterns.push_back(pattern.get());
+
// Sort the patterns by benefit to simplify the matching logic.
std::stable_sort(this->patterns.begin(), this->patterns.end(),
- [](const std::unique_ptr<RewritePattern> &l,
- const std::unique_ptr<RewritePattern> &r) {
+ [](RewritePattern *l, RewritePattern *r) {
return r->getBenefit() < l->getBenefit();
});
}
/// Try to match the given operation to a pattern and rewrite it.
bool RewritePatternMatcher::matchAndRewrite(Operation *op,
PatternRewriter &rewriter) {
- for (auto &pattern : patterns) {
+ for (auto *pattern : patterns) {
// Ignore patterns that are for the wrong root or are impossible to match.
if (pattern->getRootKind() != op->getName() ||
pattern->getBenefit().isImpossibleToMatch())
populateLinalgToLLVMConversionPatterns(LinalgTypeConverter &converter,
OwningRewritePatternList &patterns,
MLIRContext *ctx) {
- RewriteListBuilder<BufferAllocOpConversion, BufferDeallocOpConversion,
- BufferSizeOpConversion, DimOpConversion,
- LinalgOpConversion<DotOp>, LinalgOpConversion<MatmulOp>,
- LoadOpConversion, RangeOpConversion, SliceOpConversion,
- StoreOpConversion, ViewOpConversion>::build(patterns, ctx,
- converter);
+ patterns.insert<BufferAllocOpConversion, BufferDeallocOpConversion,
+ BufferSizeOpConversion, DimOpConversion,
+ LinalgOpConversion<DotOp>, LinalgOpConversion<MatmulOp>,
+ LoadOpConversion, RangeOpConversion, SliceOpConversion,
+ StoreOpConversion, ViewOpConversion>(ctx, converter);
}
namespace {
OwningRewritePatternList patterns;
auto func = getFunction();
auto *context = &getContext();
- patterns.push_back(
- llvm::make_unique<RemoveIdentityOpRewrite<StatisticsOp>>(context));
- patterns.push_back(
- llvm::make_unique<RemoveIdentityOpRewrite<StatisticsRefOp>>(context));
- patterns.push_back(
- llvm::make_unique<RemoveIdentityOpRewrite<CoupledRefOp>>(context));
+ patterns.insert<RemoveIdentityOpRewrite<StatisticsOp>,
+ RemoveIdentityOpRewrite<StatisticsRefOp>,
+ RemoveIdentityOpRewrite<CoupledRefOp>>(context);
applyPatternsGreedily(func, std::move(patterns));
}
void AllocOp::getCanonicalizationPatterns(OwningRewritePatternList &results,
MLIRContext *context) {
- RewriteListBuilder<SimplifyAllocConst, SimplifyDeadAlloc>::build(results,
- context);
+ results.insert<SimplifyAllocConst, SimplifyDeadAlloc>(context);
}
//===----------------------------------------------------------------------===//
void CallIndirectOp::getCanonicalizationPatterns(
OwningRewritePatternList &results, MLIRContext *context) {
- results.push_back(
- llvm::make_unique<SimplifyIndirectCallWithKnownCallee>(context));
+ results.insert<SimplifyIndirectCallWithKnownCallee>(context);
}
//===----------------------------------------------------------------------===//
void CondBranchOp::getCanonicalizationPatterns(
OwningRewritePatternList &results, MLIRContext *context) {
- results.push_back(llvm::make_unique<SimplifyConstCondBranchPred>(context));
+ results.insert<SimplifyConstCondBranchPred>(context);
}
//===----------------------------------------------------------------------===//
void DeallocOp::getCanonicalizationPatterns(OwningRewritePatternList &results,
MLIRContext *context) {
/// dealloc(memrefcast) -> dealloc
- results.push_back(
- llvm::make_unique<MemRefCastFolder>(getOperationName(), context));
- results.push_back(llvm::make_unique<SimplifyDeadDealloc>(context));
+ results.insert<MemRefCastFolder>(getOperationName(), context);
+ results.insert<SimplifyDeadDealloc>(context);
}
//===----------------------------------------------------------------------===//
void DmaStartOp::getCanonicalizationPatterns(OwningRewritePatternList &results,
MLIRContext *context) {
/// dma_start(memrefcast) -> dma_start
- results.push_back(
- llvm::make_unique<MemRefCastFolder>(getOperationName(), context));
+ results.insert<MemRefCastFolder>(getOperationName(), context);
}
// ---------------------------------------------------------------------------
void DmaWaitOp::getCanonicalizationPatterns(OwningRewritePatternList &results,
MLIRContext *context) {
/// dma_wait(memrefcast) -> dma_wait
- results.push_back(
- llvm::make_unique<MemRefCastFolder>(getOperationName(), context));
+ results.insert<MemRefCastFolder>(getOperationName(), context);
}
//===----------------------------------------------------------------------===//
void LoadOp::getCanonicalizationPatterns(OwningRewritePatternList &results,
MLIRContext *context) {
/// load(memrefcast) -> load
- results.push_back(
- llvm::make_unique<MemRefCastFolder>(getOperationName(), context));
+ results.insert<MemRefCastFolder>(getOperationName(), context);
}
//===----------------------------------------------------------------------===//
void StoreOp::getCanonicalizationPatterns(OwningRewritePatternList &results,
MLIRContext *context) {
/// store(memrefcast) -> store
- results.push_back(
- llvm::make_unique<MemRefCastFolder>(getOperationName(), context));
+ results.insert<MemRefCastFolder>(getOperationName(), context);
}
//===----------------------------------------------------------------------===//
void mlir::populateFuncOpTypeConversionPattern(
OwningRewritePatternList &patterns, MLIRContext *ctx,
TypeConverter &converter) {
- RewriteListBuilder<FuncOpSignatureConversion>::build(patterns, ctx,
- converter);
+ patterns.insert<FuncOpSignatureConversion>(ctx, converter);
}
/// This function converts the type signature of the given block, by invoking
void mlir::populateAffineToStdConversionPatterns(
OwningRewritePatternList &patterns, MLIRContext *ctx) {
- RewriteListBuilder<AffineApplyLowering, AffineDmaStartLowering,
- AffineDmaWaitLowering, AffineLoadLowering,
- AffineStoreLowering, AffineForLowering, AffineIfLowering,
- AffineTerminatorLowering>::build(patterns, ctx);
+ patterns
+ .insert<AffineApplyLowering, AffineDmaStartLowering,
+ AffineDmaWaitLowering, AffineLoadLowering, AffineStoreLowering,
+ AffineForLowering, AffineIfLowering, AffineTerminatorLowering>(
+ ctx);
}
namespace {
void runOnFunction() {
OwningRewritePatternList patterns;
auto *context = &getContext();
- patterns.push_back(
- llvm::make_unique<VectorTransferRewriter<VectorTransferReadOp>>(
- context));
- patterns.push_back(
- llvm::make_unique<VectorTransferRewriter<VectorTransferWriteOp>>(
- context));
+ patterns.insert<VectorTransferRewriter<VectorTransferReadOp>,
+ VectorTransferRewriter<VectorTransferWriteOp>>(context);
applyPatternsGreedily(getFunction(), std::move(patterns));
}
};
class GreedyPatternRewriteDriver : public PatternRewriter {
public:
explicit GreedyPatternRewriteDriver(MLIRContext *ctx,
- OwningRewritePatternList &&patterns)
- : PatternRewriter(ctx), matcher(std::move(patterns)) {
+ OwningRewritePatternList &patterns)
+ : PatternRewriter(ctx), matcher(patterns) {
worklist.reserve(64);
}
if (!op->isKnownIsolatedFromAbove())
return false;
- GreedyPatternRewriteDriver driver(op->getContext(), std::move(patterns));
+ GreedyPatternRewriteDriver driver(op->getContext(), patterns);
bool converged = driver.simplify(op, maxPatternMatchIterations);
LLVM_DEBUG(if (!converged) {
llvm::dbgs() << "The pattern rewrite doesn't converge after scanning "
populateWithGenerated(&getContext(), &patterns);
// Verify named pattern is generated with expected name.
- RewriteListBuilder<TestNamedPatternRule>::build(patterns, &getContext());
+ patterns.insert<TestNamedPatternRule>(&getContext());
applyPatternsGreedily(getFunction(), std::move(patterns));
}
TestTypeConverter converter;
mlir::OwningRewritePatternList patterns;
populateWithGenerated(&getContext(), &patterns);
- RewriteListBuilder<TestRegionRewriteBlockMovement, TestRegionRewriteUndo,
- TestDropOp, TestPassthroughInvalidOp,
- TestSplitReturnType>::build(patterns, &getContext());
+ patterns.insert<TestRegionRewriteBlockMovement, TestRegionRewriteUndo,
+ TestDropOp, TestPassthroughInvalidOp, TestSplitReturnType>(
+ &getContext());
mlir::populateFuncOpTypeConversionPattern(patterns, &getContext(),
converter);
pm.addPass(createConvertToLLVMIRPass([](LLVMTypeConverter &converter,
OwningRewritePatternList &patterns) {
populateStdToLLVMConversionPatterns(converter, patterns);
- patterns.push_back(llvm::make_unique<GPULaunchFuncOpLowering>(converter));
+ patterns.insert<GPULaunchFuncOpLowering>(converter);
}));
pm.addPass(createLowerGpuOpsToNVVMOpsPass());
pm.addPass(createConvertGPUKernelToCubinPass(&compilePtxToCubin));
os << "void populateWithGenerated(MLIRContext *context, "
<< "OwningRewritePatternList *patterns) {\n";
for (const auto &name : rewriterNames) {
- os << " patterns->push_back(llvm::make_unique<" << name
- << ">(context));\n";
+ os << " patterns->insert<" << name << ">(context);\n";
}
os << "}\n";
}