[flang-dev] RFC: Merging FIR

Mehdi AMINI via flang-dev flang-dev at lists.llvm.org
Fri Feb 7 19:34:16 PST 2020


Hi,

This is super exciting :)

Feel free to CC River Riddle and myself on the PR!
We're interested to keep an eye on it from the perspective of the future
maintenance when we're in the same repo (in the sense that MLIR Core
changes will take care of updating FIR API usages and tests).

Cheers,

-- 
Mehdi


On Tue, Jan 28, 2020 at 1:24 PM Jean Perier via flang-dev <
flang-dev at lists.llvm.org> wrote:

> Hello everyone,
>
>
>
> This RFC proposes the process for moving FIR from its experiment branch to
> the flang mainline branch.
>
>
>
> FIR is a dialect of MLIR.  The adoption and evolution of both of these IRs
> has been discussed in many forums and generally met with acceptance and
> enthusiasm.
>
>
>
> MLIR, since its unveiling in April 2019, and its adoption as an LLVM
> subproject late 2019, has been a rapidly evolving target.  Such evolution
> is expected and should not be read as a criticism.  The FIR experimental
> branch started as an exploration to gauge the suitability of MLIR as an IR
> for Fortran, and, as positive result accrued, this branch evolved into the
> work that we propose to upstream to flang.
>
>
>
> Because the FIR branch started as an experiment branch, and because it has
> been chasing MLIR changes, the complete commit history is not of particular
> value.  Also, because the sum total of the work as it stands is too large
> to be properly reviewed in one pull request, the patches will be
> presented as a series of incremental changes, each freestanding and
> logically organized.
>
>
>
> The actual series of patches will depend on review comments; however,
> currently, the rough organization is like this:
>
>
>
> * Add clang-format files for FIR source code (MLIR style)
>
>
>
> * Add ASTBuilder structure to help lowering the parse-tree
>
>
>
> The ASTBuilder structure is a transient data structure that
>
> is meant to be built from the parse tree just before lowering to
>
> FIR and that will be deleted just afterwards. It is not meant to perform
>
> optimization analysis and transformations. It only provides temporary
>
> information, such as label target information or parse tree parent nodes,
>
> that is meant to be used to lower the parse tree structure into
>
> FIR operations.
>
> A pretty printer is available to visualize this data structure.
>
>
>
> * Finish adding CMake files to build f18
>
> - Add cmake/modules files
>
> - Update f18 tools CMakeLists.txt
>
> - Update README.md with build instructions
>
> - Add a Version.h and Version.inic.in files for flang
>
> - These CMake files are temporary; better versions are under development
>
>
>
> * Add Doxygen configuration to flang
>
>
>
> * Add Fortran IR (FIR) MLIR dialect implementation
>
> Adds FIR library that implements an MLIR dialect to which Fortran
>
> parse-tree will be lowered to.
>
> FIR is documented in FIRLangRef.md added with this commit.
>
>
>
> * Add AbstractConverter interface and implement lowering of types to FIR
>
> - Add the AbstractConverter class that provides an interface to
>
> lower expressions and types but does not provide any implementation.
>
> - Add an implementation of lowering of front-end types to FIR types.
>
> - Add lowering of parser::CharBlock to mlir::Location
>
>
>
> * Lowering of Fortran Expression to FIR
>
> - Add helpers to manipulate MLIR OpBuilder and hide
>
>   boilerplate.
>
> - Lower Fortran scalar intrinsic operations
>
> - Add a framework to describe runtime and insert runtime calls in FIR.
>
>   It allows to create a constexpr map to describe the
>
>   runtime.
>
> - Start Lowering of numerical intrinsics
>
>
>
> * Add bridge from AST to FIR
>
> - Add the class that implements the lowering of
>
> the Fortran ASTs to FIR operations as described in
>
> BurnsidetoFIR.md.
>
> - The lowering of IO statements is done in another file
>
>   to keep the bridge smaller.
>
>
>
> * Add FIR optimizer library
>
> This library provides transformation passes that can be run of FIR
>
> to perform several high-level optimizations.
>
>
>
> * Add testing tools
>
> - Add bbc tool that takes a Fortran input file, drives parsing,
>
> semantic analysis, and then lowers the parse-tree to FIR. It can
>
> then run transformation passes on the obtained MLIR before
>
> generating LLVM IR. The bbc tool is used for testing.
>
> - Add tco tool that is meant to process mlir input files and
>
> drives transformations on it. The tco tool is used for testing.
>
>
>
> * Update lit config for FIR tests
>
>
>
> * Add FIR and lowering tests
>
> - A FIR round-trip tests (in test/fir)
>
> - Add new FIR lit tests (in test-lit/fir)
>
> - Add expression lowering test (in test/lower)
>
>
>
> The patches will be sent in successive PRs into f18 master because the
> later patches depend on the first ones.
>
> The first patch will bring a dependency upon LLVM but not MLIR. Note that
> current CMake files already require LLVM package but no code was actually
> using it yet (apart from LIT tests). Subsequent patches will require MLIR
> and new CMake files.
> ------------------------------
> This email message is for the sole use of the intended recipient(s) and
> may contain confidential information.  Any unauthorized review, use,
> disclosure or distribution is prohibited.  If you are not the intended
> recipient, please contact the sender by reply email and destroy all copies
> of the original message.
> ------------------------------
> _______________________________________________
> flang-dev mailing list
> flang-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/flang-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/flang-dev/attachments/20200207/03d58178/attachment.html>


More information about the flang-dev mailing list