[Flang] Initial lowering of the Fortran Do loop
authorKiran Chandramohan <kiran.chandramohan@arm.com>
Thu, 28 Apr 2022 12:20:11 +0000 (12:20 +0000)
committerKiran Chandramohan <kiran.chandramohan@arm.com>
Thu, 28 Apr 2022 13:03:16 +0000 (13:03 +0000)
commitb5b3e50f65ee99257041723e7645d44c1aeb1117
treee5c0adacd9c83f94d8e4b1d70991c8986a5f7e92
parent3f2b76ec90b5f108272a3072a1345ba55d8ec75b
[Flang] Initial lowering of the Fortran Do loop

This patch adds code to lower simple Fortran Do loops with loop control.
Lowering is performed by the the `genFIR` function when called with a
`Fortran::parser::DoConstruct`. `genFIR` function calls `genFIRIncrementLoopBegin`
then calls functions to lower the body of the loop and finally calls
the function `genFIRIncrementLoopEnd`. `genFIRIncrementLoopBegin` is
responsible for creating the FIR `do_loop` as well as storing the value of
the loop index to the loop variable. `genFIRIncrementLoopEnd` returns
the incremented value of the loop index and also stores the index value
outside the loop. This is important since the loop variable can be used
outside the loop. Information about a loop is collected in a structure
`IncrementLoopInfo`.

Note 1: Future patches will bring in lowering for unstructured,
infinite, while loops
Note 2: This patch is part of upstreaming code from the fir-dev branch of
https://github.com/flang-compiler/f18-llvm-project.

Reviewed By: awarzynski

Differential Revision: https://reviews.llvm.org/D124277

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Val Donaldson <vdonaldson@nvidia.com>
Co-authored-by: Peter Klausler <pklausler@nvidia.com>
Co-authored-by: Valentin Clement <clementval@gmail.com>
flang/lib/Lower/Bridge.cpp
flang/test/Lower/do_loop.f90 [new file with mode: 0644]