diff options
author | Andrzej Warzynski <andrzej.warzynski@arm.com> | 2022-02-03 17:00:27 +0000 |
---|---|---|
committer | Andrzej Warzynski <andrzej.warzynski@arm.com> | 2022-02-09 08:35:48 +0000 |
commit | 69c3309d4545cd729c41b102303686e19c92f55c (patch) | |
tree | 208bf3b689f4e1a29e1e4c3c0359645224a8e25d /flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp | |
parent | 68c1eeb4bad18753dbaa053a6c919c8f1a23fb9c (diff) | |
download | llvm-69c3309d4545cd729c41b102303686e19c92f55c.zip llvm-69c3309d4545cd729c41b102303686e19c92f55c.tar.gz llvm-69c3309d4545cd729c41b102303686e19c92f55c.tar.bz2 |
[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
Diffstat (limited to 'flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp')
-rw-r--r-- | flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp b/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp index 677f8cd..d69242f 100644 --- a/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp +++ b/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp @@ -33,6 +33,8 @@ static std::unique_ptr<FrontendAction> CreateFrontendBaseAction( return std::make_unique<PrintPreprocessedAction>(); case ParseSyntaxOnly: return std::make_unique<ParseSyntaxOnlyAction>(); + case EmitMLIR: + return std::make_unique<EmitMLIRAction>(); case EmitObj: return std::make_unique<EmitObjAction>(); case DebugUnparse: |