1 //===- fir-opt.cpp - FIR Optimizer Driver -----------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 // This is to be like LLVM's opt program, only for FIR. Such a program is
10 // required for roundtrip testing, etc.
12 //===----------------------------------------------------------------------===//
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/OpenMP/Passes.h"
18 #include "flang/Optimizer/Support/InitFIR.h"
19 #include "flang/Optimizer/Transforms/Passes.h"
24 void registerTestFIRAliasAnalysisPass();
25 void registerTestFIROpenACCInterfacesPass();
29 // Defined in mlir/test, no pulic header.
31 void registerSideEffectTestPasses();
34 int main(int argc
, char **argv
) {
35 fir::support::registerMLIRPassesForFortranTools();
36 fir::registerOptCodeGenPasses();
37 fir::registerOptTransformPasses();
38 hlfir::registerHLFIRPasses();
39 flangomp::registerFlangOpenMPPasses();
40 #ifdef FLANG_INCLUDE_TESTS
41 fir::test::registerTestFIRAliasAnalysisPass();
42 fir::test::registerTestFIROpenACCInterfacesPass();
43 mlir::registerSideEffectTestPasses();
45 DialectRegistry registry
;
46 fir::support::registerDialects(registry
);
47 registry
.insert
<mlir::gpu::GPUDialect
>();
48 registry
.insert
<mlir::NVVM::NVVMDialect
>();
49 fir::support::addFIRExtensions(registry
);
50 return failed(MlirOptMain(argc
, argv
, "FIR modular optimizer driver\n",