[flang][hlfir] Lower post f77 user calls
authorJean Perier <jperier@nvidia.com>
Wed, 1 Feb 2023 10:43:22 +0000 (11:43 +0100)
committerJean Perier <jperier@nvidia.com>
Wed, 1 Feb 2023 10:43:29 +0000 (11:43 +0100)
commit87cd6f934650c2403d776be0cc7f5c065479f77d
treeff0f6e1ff9c5e468c0aa31ce1300ab611d8b5a8e
parent7cedd956d0602bf6aca24c1fa5eda2bd585750ac
[flang][hlfir] Lower post f77 user calls

In lowering to HLFIR, deal with user calls involving a mix of:
 - dummy with VALUE
 - Polymorphism
 - contiguous dummy
 - assumed shape dummy
 - OPTIONAL arguments
 - NULL() passed to OPTIONAL arguments.
 - elemental calls

Does not deal with assumed ranked dummy arguments.

This patch unifies the preparation of all arguments that must be passed
in memory and are not passed as allocatable/pointers.

For optionals, the same argument preparation is done, except the utility
that generates the IR for the argument preparation is called inside a
fir.if.

The addressing of array arguments in elemental calls is delayed so that
it can also happen during this argument preparation, and be placed in
the fir.if when the array may be absent.

Structure helpers are added to convey a prepared dummy argument and the
data that may be needed to do the clean-up after the call (temporary
storage deallocation or copy-out). And a utility is added to wrap
the preparation code inside a fir.if and convey these values through
the fir.if.

Certain aspects of this patch brings the HLFIR lowering support beyond
what the current lowering to FIR supports (e.g. handling of NULL(), handling
of optional in elemental calls, handling of copy-in/copy-out involving
polymorphic entities).

Differential Revision: https://reviews.llvm.org/D142695
flang/include/flang/Lower/CallInterface.h
flang/include/flang/Optimizer/Builder/HLFIRTools.h
flang/lib/Lower/CallInterface.cpp
flang/lib/Lower/ConvertCall.cpp
flang/lib/Lower/ConvertExprToHLFIR.cpp
flang/lib/Optimizer/Builder/HLFIRTools.cpp
flang/lib/Optimizer/Dialect/FIROps.cpp
flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp
flang/test/Lower/HLFIR/calls-assumed-shape.f90 [new file with mode: 0644]
flang/test/Lower/HLFIR/calls-optional.f90 [new file with mode: 0644]
flang/test/Lower/HLFIR/elemental-intrinsics.f90