|Nvidia Offers New Fortran Frontend To LLVM|
|Written by Kay Ewbank|
|Monday, 04 March 2019|
Nvidia is proposing their ground-up rewrite of the Fortran front-end for LLVM, f18, becomes an LLVM project.
F18 is a front-end for Fortran. It is intended to replace the existing front-end in the Flang compiler. Flang is a Fortran compiler targeting LLVM that was developed by Nvidia in conjunction with the US Department of Energy's National Nuclear Security Administration.
LLVM (Low Level Virtual Machine)) is a compiler infrastructure that consists of a collection of libraries and tools for optimizing compilers and just-in-time code generators. Despite the name, LLVM is more an intermediate language that can be targeted by a compiler and then translated to various actual machine codes. The best known LLVM compiler is Clang for C/C++/Objective C.
Nvidia developed an open-source Fortran front-end for LLVM that consists of the flang front-end along with the corresponding Fortran runtime library. The existing front-end's code is mostly written in C, and the developers at Nvidia say that while it's a production-quality implementation, it doesn't follow modern software-engineering practices. This means that it is unlikely to be accepted as part of the LLVM project to be further developed by the LLVM community. The Nvidia team also have an ambition that Flang and the front-end become useful in the many ways that Clang is useful: not just as a front-end, but also for static analysis and tooling.
Because the current flang's code base wouldn't meet these needs, Nvidia has been working on a ground-up rewrite of the front-end in modern C++. This project is called f18.
At this point, the Nvidia team has documented and implemented what they describe as a healthy subset of the compiler for symbol tables and scoping, name resolution, USE statements and module files, constant representation, constant folding and much of declaration, label and expression semantics. The parser handles all of Fortran 2018 and OpenMP 4.5 and implements a Fortran-aware preprocessor. The Fortran control flow graph (CFG) is in review now.
The consensus at Nvidia is that the project is now at a point where the best route forward is that f18, and the existing Fortran runtime libraries, are contributed to the LLVM project. The Fortran front-end would become a proper LLVM subproject, design discussions would take place on an associated LLVM mailing list, code reviews would use phabricator, and so on.
Writing on the LLVM developer mailing list, the developers at Nvidia say:
"We're committed to developing LLVM's Fortran front-end for years to come, and together with other members of the LLVM community (e.g., ARM, US Dept of Energy) would like to do so as part of the LLVM project."
Alongside flang, Nvidia has developed a library of scalar, vector, and masked math functions that the team is also proposing for inclusion in LLVM.
While there are some aspects of the project that require negotiation (such as the use of C++17 for some parts of f18 where LLVM is standadised on C++11), it looks like f18 may well become an LLVM project this year. The f18 front-end is already hosted on GitHub under the Flang compiler project.
or email your comment to: firstname.lastname@example.org