1//===- Bufferize.cpp - Bufferization for `vector` dialect ops -------------===//
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//
9// This file implements bufferization of `vector` dialect ops
10//
11//===----------------------------------------------------------------------===//
12
13#include "mlir/Dialect/Bufferization/Transforms/Bufferize.h"
14
15#include "mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h"
16#include "mlir/Dialect/Bufferization/IR/Bufferization.h"
17#include "mlir/Dialect/Func/IR/FuncOps.h"
18#include "mlir/Dialect/MemRef/IR/MemRef.h"
19#include "mlir/Dialect/Tensor/IR/Tensor.h"
20#include "mlir/Dialect/Vector/IR/VectorOps.h"
21#include "mlir/Dialect/Vector/Transforms/BufferizableOpInterfaceImpl.h"
22#include "mlir/Dialect/Vector/Transforms/Passes.h"
23
24namespace mlir {
25namespace vector {
26#define GEN_PASS_DEF_VECTORBUFFERIZE
27#include "mlir/Dialect/Vector/Transforms/Passes.h.inc"
28} // namespace vector
29} // namespace mlir
30
31using namespace mlir;
32using namespace bufferization;
33
34namespace {
35struct VectorBufferizePass
36 : public vector::impl::VectorBufferizeBase<VectorBufferizePass> {
37 void runOnOperation() override {
38 BufferizationOptions options = getPartialBufferizationOptions();
39 options.opFilter.allowDialect<vector::VectorDialect>();
40
41 if (failed(bufferizeOp(getOperation(), options)))
42 signalPassFailure();
43 }
44
45 void getDependentDialects(DialectRegistry &registry) const override {
46 registry.insert<bufferization::BufferizationDialect, memref::MemRefDialect,
47 tensor::TensorDialect, vector::VectorDialect>();
48 vector::registerBufferizableOpInterfaceExternalModels(registry);
49 }
50};
51} // namespace
52
53std::unique_ptr<Pass> mlir::vector::createVectorBufferizePass() {
54 return std::make_unique<VectorBufferizePass>();
55}
56

source code of mlir/lib/Dialect/Vector/Transforms/Bufferize.cpp