[fir] Clean up InitFIR.h
authorEric Schweitz <eschweitz@nvidia.com>
Mon, 11 Oct 2021 13:40:41 +0000 (15:40 +0200)
committerValentin Clement <clementval@gmail.com>
Mon, 11 Oct 2021 13:41:50 +0000 (15:41 +0200)
Clean up InitFIR.h file.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: kiranchandramohan

Differential Revision: https://reviews.llvm.org/D111539

Co-authored-by: Valentin Clement <clementval@gmail.com>
flang/include/flang/Optimizer/Support/InitFIR.h
flang/tools/fir-opt/fir-opt.cpp

index a69575a..534645d 100644 (file)
 #include "mlir/Pass/PassRegistry.h"
 #include "mlir/Transforms/LocationSnapshot.h"
 #include "mlir/Transforms/Passes.h"
-#include "flang/Optimizer/CodeGen/CodeGen.h"
 
 namespace fir::support {
 
-// The definitive list of dialects used by flang.
-#define FLANG_DIALECT_LIST                                                     \
-  mlir::AffineDialect, FIROpsDialect, FIRCodeGenDialect,                       \
-      mlir::LLVM::LLVMDialect, mlir::acc::OpenACCDialect,                      \
+#define FLANG_NONCODEGEN_DIALECT_LIST                                          \
+  mlir::AffineDialect, FIROpsDialect, mlir::acc::OpenACCDialect,               \
       mlir::omp::OpenMPDialect, mlir::scf::SCFDialect,                         \
       mlir::StandardOpsDialect, mlir::vector::VectorDialect
 
+// The definitive list of dialects used by flang.
+#define FLANG_DIALECT_LIST                                                     \
+  FLANG_NONCODEGEN_DIALECT_LIST, FIRCodeGenDialect, mlir::LLVM::LLVMDialect
+
 /// Register all the dialects used by flang.
 inline void registerDialects(mlir::DialectRegistry &registry) {
   registry.insert<FLANG_DIALECT_LIST>();
@@ -70,9 +71,6 @@ inline void registerMLIRPassesForFortranTools() {
   mlir::registerAffineDataCopyGenerationPass();
 
   mlir::registerConvertAffineToStandardPass();
-
-  // Flang passes
-  fir::registerOptCodeGenPasses();
 }
 
 } // namespace fir::support
index 246d584..2a0fb7d 100644 (file)
@@ -12,6 +12,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "mlir/Support/MlirOptMain.h"
+#include "flang/Optimizer/CodeGen/CodeGen.h"
 #include "flang/Optimizer/Support/InitFIR.h"
 #include "flang/Optimizer/Transforms/Passes.h"
 
@@ -19,6 +20,7 @@ using namespace mlir;
 
 int main(int argc, char **argv) {
   fir::support::registerMLIRPassesForFortranTools();
+  fir::registerOptCodeGenPasses();
   fir::registerOptTransformPasses();
   DialectRegistry registry;
   fir::support::registerDialects(registry);