[all-commits] [llvm/llvm-project] 69c330: [flang][driver] Add support for `-emit-mlir`

Andrzej Warzyński via All-commits all-commits at lists.llvm.org
Wed Feb 9 00:37:45 PST 2022

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 69c3309d4545cd729c41b102303686e19c92f55c
  Author: Andrzej Warzynski <andrzej.warzynski at arm.com>
  Date:   2022-02-09 (Wed, 09 Feb 2022)

  Changed paths:
    M clang/include/clang/Driver/Options.td
    M flang/include/flang/Frontend/CompilerInstance.h
    M flang/include/flang/Frontend/FrontendActions.h
    M flang/include/flang/Frontend/FrontendOptions.h
    M flang/lib/Frontend/CMakeLists.txt
    M flang/lib/Frontend/CompilerInvocation.cpp
    M flang/lib/Frontend/FrontendActions.cpp
    M flang/lib/FrontendTool/CMakeLists.txt
    M flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
    M flang/test/Driver/driver-help.f90
    A flang/test/Driver/emit-mlir.f90
    M flang/test/Driver/syntax-only.f90

  Log Message:
  [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

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

More information about the All-commits mailing list