1 | //===- fir-opt.cpp - FIR Optimizer Driver -----------------------*- C++ -*-===// |
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 is to be like LLVM's opt program, only for FIR. Such a program is |
10 | // required for roundtrip testing, etc. |
11 | // |
12 | //===----------------------------------------------------------------------===// |
13 | |
14 | #include "mlir/Tools/mlir-opt/MlirOptMain.h" |
15 | #include "flang/Optimizer/CodeGen/CodeGen.h" |
16 | #include "flang/Optimizer/HLFIR/Passes.h" |
17 | #include "flang/Optimizer/Support/InitFIR.h" |
18 | #include "flang/Optimizer/Transforms/Passes.h" |
19 | |
20 | using namespace mlir; |
21 | namespace fir { |
22 | namespace test { |
23 | void registerTestFIRAliasAnalysisPass(); |
24 | } // namespace test |
25 | } // namespace fir |
26 | |
27 | // Defined in mlir/test, no pulic header. |
28 | namespace mlir { |
29 | void registerSideEffectTestPasses(); |
30 | } |
31 | |
32 | int main(int argc, char **argv) { |
33 | fir::support::registerMLIRPassesForFortranTools(); |
34 | fir::registerOptCodeGenPasses(); |
35 | fir::registerOptTransformPasses(); |
36 | hlfir::registerHLFIRPasses(); |
37 | #ifdef FLANG_INCLUDE_TESTS |
38 | fir::test::registerTestFIRAliasAnalysisPass(); |
39 | mlir::registerSideEffectTestPasses(); |
40 | #endif |
41 | DialectRegistry registry; |
42 | fir::support::registerDialects(registry); |
43 | fir::support::addFIRExtensions(registry); |
44 | return failed(MlirOptMain(argc, argv, "FIR modular optimizer driver\n" , |
45 | registry)); |
46 | } |
47 | |