1 | //===- TestAliasAnalysis.cpp - Test FIR lias analysis -----------------===// |
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 | #include "mlir/test/lib/Analysis/TestAliasAnalysis.h" |
10 | #include "mlir/Analysis/AliasAnalysis.h" |
11 | #include "mlir/Pass/Pass.h" |
12 | #include "flang/Optimizer/Analysis/AliasAnalysis.h" |
13 | |
14 | using namespace mlir; |
15 | |
16 | namespace { |
17 | |
18 | //===----------------------------------------------------------------------===// |
19 | // Testing AliasResult |
20 | //===----------------------------------------------------------------------===// |
21 | |
22 | struct TestFIRAliasAnalysisPass |
23 | : public test::TestAliasAnalysisBase, |
24 | PassWrapper<TestFIRAliasAnalysisPass, OperationPass<>> { |
25 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestFIRAliasAnalysisPass) |
26 | |
27 | StringRef getArgument() const final { return "test-fir-alias-analysis" ; } |
28 | StringRef getDescription() const final { |
29 | return "Test alias analysis results." ; |
30 | } |
31 | void runOnOperation() override { |
32 | mlir::AliasAnalysis aliasAnalysis(getOperation()); |
33 | aliasAnalysis.addAnalysisImplementation(fir::AliasAnalysis()); |
34 | runAliasAnalysisOnOperation(getOperation(), aliasAnalysis); |
35 | } |
36 | }; |
37 | |
38 | //===----------------------------------------------------------------------===// |
39 | // Testing ModRefResult |
40 | //===----------------------------------------------------------------------===// |
41 | |
42 | struct TestFIRAliasAnalysisModRefPass |
43 | : public test::TestAliasAnalysisModRefBase, |
44 | PassWrapper<TestFIRAliasAnalysisModRefPass, OperationPass<>> { |
45 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestFIRAliasAnalysisModRefPass) |
46 | |
47 | StringRef getArgument() const final { |
48 | return "test-fir-alias-analysis-modref" ; |
49 | } |
50 | StringRef getDescription() const final { |
51 | return "Test alias analysis ModRef results." ; |
52 | } |
53 | void runOnOperation() override { |
54 | mlir::AliasAnalysis aliasAnalysis(getOperation()); |
55 | aliasAnalysis.addAnalysisImplementation(fir::AliasAnalysis()); |
56 | runAliasAnalysisOnOperation(getOperation(), aliasAnalysis); |
57 | } |
58 | }; |
59 | } // namespace |
60 | |
61 | //===----------------------------------------------------------------------===// |
62 | // Pass Registration |
63 | //===----------------------------------------------------------------------===// |
64 | |
65 | namespace fir { |
66 | namespace test { |
67 | void registerTestFIRAliasAnalysisPass() { |
68 | PassRegistration<TestFIRAliasAnalysisPass>(); |
69 | PassRegistration<TestFIRAliasAnalysisModRefPass>(); |
70 | } |
71 | } // namespace test |
72 | } // namespace fir |