Upstreaming Lowering of Parse Tree/PFT to FIR

Hi,

In last week’s technical call we discussed ways to progress upstreaming the lowering of FIR to llvm-project/flang. It was mentioned that people interested in FIR should suggest plans to Nvidia to help with upstreaming the lowering. For this purpose, I created a patch in https://reviews.llvm.org/D79731 which captures the basic lowering (empty named subroutines) from the parse tree to FIR. The patch requires a bit of cleanup but is functional, passes existing tests and two simple tests (in flang/test/Lower/program-units-fir-mangling.f90) for lowering/name mangling of subroutines.

The patch brings in the lowering code in Bridge.cpp, FIRBuilder.cpp, Mangler.cpp. In Bridge.cpp, only portions of the code for lowering a Function’s header/footer is included. Code for instantiating local variables, alternate returns, genFIR for loops and other constructs are removed. The FIROpBuilder in FIRBuilder.cpp/FIRBuilder.h only derives from the mlir OpBuilder, other builders (characterops,complexops,instrinsicops) are removed. The tool for invoking and testing the lowering, bbc, is included. Portions of the code for generating llvm dialect is removed. All other code for handling expressions, type conversions, runtime etc are not included. All the excluded code can be upstreamed later in further patches.

The patch is around 3300 lines of changes. It can be further simplified in further revisions if required. Almost half of the changes are in PFTBuilder.cpp, PFTBuilder.h. Some of these are NFC which are needed to keep pace with fir-dev branch of f18-llvm-project in github/flang-compiler. Changes for the tool bbc can also be stripped out into a separate patch if necessary.

I wanted to get some feedback before proceeding further.

Thanks,
Kiran