[flang-commits] [flang] 79a5ff4 - [Flang][Driver] Add support for AsmPrinter -mmlir options

Arnamoy Bhattacharyya via flang-commits flang-commits at lists.llvm.org
Wed Jul 27 13:06:19 PDT 2022


Author: Prabhdeep Singh Soni
Date: 2022-07-27T16:11:11-04:00
New Revision: 79a5ff45cbda0c3b06b9a566c90407c7264c8692

URL: https://github.com/llvm/llvm-project/commit/79a5ff45cbda0c3b06b9a566c90407c7264c8692
DIFF: https://github.com/llvm/llvm-project/commit/79a5ff45cbda0c3b06b9a566c90407c7264c8692.diff

LOG: [Flang][Driver] Add support for AsmPrinter -mmlir options

This patch adds support for AsmPrinter  `-mmlir` options to the Flang driver.

Reviewed By: awarzynski

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

Added: 
    flang/test/Driver/mmlir-opts.f90

Modified: 
    flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp b/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
index f719530a772ed..54cbd2c99e4a0 100644
--- a/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ b/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -19,6 +19,7 @@
 #include "flang/Frontend/FrontendActions.h"
 #include "flang/Frontend/FrontendPluginRegistry.h"
 
+#include "mlir/IR/AsmState.h"
 #include "mlir/IR/MLIRContext.h"
 #include "mlir/Pass/PassManager.h"
 #include "clang/Driver/Options.h"
@@ -142,6 +143,7 @@ bool executeCompilerInvocation(CompilerInstance *flang) {
   if (!flang->getFrontendOpts().mlirArgs.empty()) {
     mlir::registerMLIRContextCLOptions();
     mlir::registerPassManagerCLOptions();
+    mlir::registerAsmPrinterCLOptions();
     unsigned numArgs = flang->getFrontendOpts().mlirArgs.size();
     auto args = std::make_unique<const char *[]>(numArgs + 2);
     args[0] = "flang (MLIR option parsing)";

diff  --git a/flang/test/Driver/mmlir-opts.f90 b/flang/test/Driver/mmlir-opts.f90
new file mode 100644
index 0000000000000..e99a1e777e7ed
--- /dev/null
+++ b/flang/test/Driver/mmlir-opts.f90
@@ -0,0 +1,12 @@
+! Verify that registerMLIRContextCLOptions, registerPassManagerCLOptions and
+! registerAsmPrinterCLOptions `-mmlir` options  are available to the driver.
+
+! RUN: %flang_fc1  -mmlir --help | FileCheck %s --check-prefix=MLIR
+
+! MLIR: flang (MLIR option parsing) [options]
+! Registered via registerPassManagerCLOptions
+! MLIR: --mlir-pass-pipeline-local-reproducer
+! Registered via registerAsmPrinterCLOptions
+! MLIR: --mlir-print-local-scope
+! Registered via registerMLIRContextCLOptions
+! MLIR: --mlir-print-op-on-diagnostic


        


More information about the flang-commits mailing list