1 | //===------ TestCompositePass.cpp --- composite test 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 | // |
9 | // This file implements a pass to test the composite pass utility. |
10 | // |
11 | //===----------------------------------------------------------------------===// |
12 | |
13 | #include "mlir/Pass/Pass.h" |
14 | #include "mlir/Pass/PassManager.h" |
15 | #include "mlir/Pass/PassRegistry.h" |
16 | #include "mlir/Transforms/Passes.h" |
17 | |
18 | namespace mlir { |
19 | namespace test { |
20 | void registerTestCompositePass() { |
21 | registerPassPipeline( |
22 | arg: "test-composite-fixed-point-pass" , description: "Test composite pass" , |
23 | function: [](OpPassManager &pm, StringRef optionsStr, |
24 | function_ref<LogicalResult(const Twine &)> errorHandler) { |
25 | if (!optionsStr.empty()) |
26 | return failure(); |
27 | |
28 | pm.addPass(createCompositeFixedPointPass( |
29 | "TestCompositePass" , [](OpPassManager &p) { |
30 | p.addPass(createCanonicalizerPass()); |
31 | p.addPass(createCSEPass()); |
32 | })); |
33 | return success(); |
34 | }, |
35 | optHandler: [](function_ref<void(const detail::PassOptions &)>) {}); |
36 | } |
37 | } // namespace test |
38 | } // namespace mlir |
39 | |