[flang] Batch together the changes to the PFT intermediate data structure for upstreaming to llvm-project. These files have had many changes since they were originally upstreamed. Some of the changes are cosmetic. Most of the functional changes were done to support the lowering of control-flow syntax from the front-end parse trees to the FIR dialect. This patch is meant to be a reviewable size. The functionality it provides will be used by code yet to be upstreamed in lowering.
Generation of FIR (Fortran IR, a dialect of MLIR) from the front end f18 parse tree, occurs in two steps.
The first step builds a Pre-Fir Tree (PFT), a light weight tree of relevant indexes into the parse tree. This is done with a primary pass over the parse tree for a source file, which invokes a secondary pass at the function level. The primary pass creates the PFT data structure and fills in sequential pass information such as lexical successors for statements. The secondary pass (function analyzeBranches) is invoked at the end of each source function to fill in non-sequential branching information, such as the targets of goto statements.
The second step traverses the PFT to generate FIR. This step also has a primary traversal pass and a secondary, per-function pass. In this case, the secondary pass (function createEmptyBlocks) is a pre-pass invoked at the beginning of the primary pass for each function, which uses information gathered in the first step to generate most MLIR basic blocks in advance. The primary pass over the PFT then generates code in sequential order, which is possible since branch targets are valid without differentiating between forward and backward branches.
Why is this not a reference variant?