[win/asan] GetInstructionSize: Make `83 EC XX` a generic entry. (#119537)
[llvm-project.git] / mlir / test / lib / Dialect / MemRef / TestMultiBuffer.cpp
blob1ca63bbb2a0e8ed55354b39968bb9152cafff486
1 //===- TestComposeSubView.cpp - Test composed subviews --------------------===//
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 //===----------------------------------------------------------------------===//
9 #include "mlir/Dialect/Affine/IR/AffineOps.h"
10 #include "mlir/Dialect/MemRef/Transforms/Passes.h"
11 #include "mlir/Dialect/MemRef/Transforms/Transforms.h"
13 #include "mlir/Dialect/MemRef/IR/MemRef.h"
14 #include "mlir/Pass/Pass.h"
16 using namespace mlir;
18 namespace {
19 struct TestMultiBufferingPass
20 : public PassWrapper<TestMultiBufferingPass, OperationPass<>> {
21 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestMultiBufferingPass)
23 TestMultiBufferingPass() = default;
24 TestMultiBufferingPass(const TestMultiBufferingPass &pass)
25 : PassWrapper(pass) {}
26 void getDependentDialects(DialectRegistry &registry) const override {
27 registry.insert<affine::AffineDialect>();
29 StringRef getArgument() const final { return "test-multi-buffering"; }
30 StringRef getDescription() const final {
31 return "Test multi buffering transformation";
33 void runOnOperation() override;
34 Option<unsigned> multiplier{
35 *this, "multiplier",
36 llvm::cl::desc(
37 "Decide how many versions of the buffer should be created,"),
38 llvm::cl::init(2)};
41 void TestMultiBufferingPass::runOnOperation() {
42 SmallVector<memref::AllocOp> allocs;
43 getOperation()->walk(
44 [&allocs](memref::AllocOp alloc) { allocs.push_back(alloc); });
45 for (memref::AllocOp alloc : allocs)
46 (void)multiBuffer(alloc, multiplier);
48 } // namespace
50 namespace mlir {
51 namespace test {
52 void registerTestMultiBuffering() {
53 PassRegistration<TestMultiBufferingPass>();
55 } // namespace test
56 } // namespace mlir