From 69c3309d4545cd729c41b102303686e19c92f55c Mon Sep 17 00:00:00 2001 From: Andrzej Warzynski Date: Thu, 3 Feb 2022 17:00:27 +0000 Subject: [flang][driver] Add support for `-emit-mlir` This patch adds support for generating MLIR files in Flang's frontend driver (i.e. `flang-new -fc1`). `-emit-fir` is added as an alias for `-emit-mlir`. We may want to decide to split the two in the future. A new parent class for code-gen frontend actions is introduced: `CodeGenAction`. We will be using this class to encapsulate logic shared between all code-generation actions, but not required otherwise. For now, it will: * run prescanning, parsing and semantic checks, * lower the input to MLIR. `EmitObjAction` is updated to inherit from this class. This means that the behaviour of `flang-new -fc1 -emit-obj` is also updated (previously, it would just exit immediately). This change required `flang/test/Driver/syntax-only.f90` to be updated. For `-emit-fir`, a specialisation of `CodeGenAction` is introduced: `EmitMLIRAction`. The key logic for this class is implemented in `EmitMLIRAction::ExecuteAction`. Differential Revision: https://reviews.llvm.org/D118985 --- flang/lib/Frontend/CompilerInvocation.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'flang/lib/Frontend/CompilerInvocation.cpp') diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp index dcfa741..af59cb6 100644 --- a/flang/lib/Frontend/CompilerInvocation.cpp +++ b/flang/lib/Frontend/CompilerInvocation.cpp @@ -134,6 +134,9 @@ static bool ParseFrontendArgs(FrontendOptions &opts, llvm::opt::ArgList &args, case clang::driver::options::OPT_fsyntax_only: opts.programAction = ParseSyntaxOnly; break; + case clang::driver::options::OPT_emit_mlir: + opts.programAction = EmitMLIR; + break; case clang::driver::options::OPT_emit_obj: opts.programAction = EmitObj; break; -- cgit v1.1