MLIR  20.0.0git
Bufferize.cpp
Go to the documentation of this file.
1 //===- Bufferize.cpp - scf bufferize pass ---------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
10 
17 
18 namespace mlir {
19 #define GEN_PASS_DEF_SCFBUFFERIZE
20 #include "mlir/Dialect/SCF/Transforms/Passes.h.inc"
21 } // namespace mlir
22 
23 using namespace mlir;
24 using namespace mlir::scf;
25 
26 namespace {
27 struct SCFBufferizePass : public impl::SCFBufferizeBase<SCFBufferizePass> {
28  void runOnOperation() override {
29  auto *func = getOperation();
30  auto *context = &getContext();
31 
33  RewritePatternSet patterns(context);
34  ConversionTarget target(*context);
35 
38  target);
39  if (failed(applyPartialConversion(func, target, std::move(patterns))))
40  return signalPassFailure();
41  };
42 };
43 } // namespace
44 
45 std::unique_ptr<Pass> mlir::createSCFBufferizePass() {
46  return std::make_unique<SCFBufferizePass>();
47 }
static MLIRContext * getContext(OpFoldResult val)
This class describes a specific conversion target.
A helper type converter class that automatically populates the relevant materializations and type con...
Definition: Bufferize.h:43
void populateBufferizeMaterializationLegality(ConversionTarget &target)
Marks ops used by bufferization for type conversion materializations as "legal" in the given Conversi...
Definition: Bufferize.cpp:95
void populateSCFStructuralTypeConversionsAndLegality(const TypeConverter &typeConverter, RewritePatternSet &patterns, ConversionTarget &target)
Populates patterns for SCF structural type conversions and sets up the provided ConversionTarget with...
Include the generated interface declarations.
std::unique_ptr< Pass > createSCFBufferizePass()
Creates a pass that bufferizes the SCF dialect.
Definition: Bufferize.cpp:45
LogicalResult applyPartialConversion(ArrayRef< Operation * > ops, const ConversionTarget &target, const FrozenRewritePatternSet &patterns, ConversionConfig config=ConversionConfig())
Below we define several entry points for operation conversion.