[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
This commit is contained in:
Prabhdeep Singh Soni 2022-07-27 16:09:24 -04:00 committed by Arnamoy Bhattacharyya
parent 41f7bb9975
commit 79a5ff45cb
2 changed files with 14 additions and 0 deletions

View File

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

View File

@ -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