[flang][hlfir] Lower procedure designators to HLFIR
authorJean Perier <jperier@nvidia.com>
Thu, 9 Feb 2023 08:02:43 +0000 (09:02 +0100)
committerJean Perier <jperier@nvidia.com>
Thu, 9 Feb 2023 08:02:52 +0000 (09:02 +0100)
commitcedfd2721e3492e5ab0ea86d24d8027846687c27
tree589b6c1aa51bd48fac2a74342f2746850bf3b7d5
parentf37d7c9381ffc720a00ab61945f96e083eb58f55
[flang][hlfir] Lower procedure designators to HLFIR

- Add a convertProcedureDesignatorToHLFIR that converts the
  fir::ExtendedValue from the current lowering to a
  fir.boxproc/tuple<fir.boxproc, len> mlir::Value.

- Allow fir.boxproc/tuple<fir.boxproc, len> as hlfir::Entity values
  (a function is an address, but from a Fortran entity point of view,
  procedure that are not procedure pointers cannot be assigned to, so
  it makes a lot more sense to consider those as values).

- Modify symbol association to not generate an hlfir.declare for dummy
  procedures. They are not needed and allowing hlfir.declare to declare
  function values would make its verifier and handling overly complex
  for little benefits (maybe an hlfir.declare_proc could be added if it
  turnout out useful later for debug info and attributes storing
  purposes).

- Allow translation from hlfir::Entity to fir::ExtendedValue.
  convertToBox return type had to be relaxed because some intrinsics
  handles both object and procedure arguments and need to lower their
  object arguments "asBox". fir::BoxValue is not intended to carry
  dummy procedures (all its member functions would make little sense
  and its verifier does not accept such type).
  Note that AsAddr, AsValue and AsBox will always return the same MLIR
  value for procedure designators because they are always handled the
  same way in FIR.

Differential Revision: https://reviews.llvm.org/D143585
14 files changed:
flang/include/flang/Lower/CallInterface.h
flang/include/flang/Lower/ConvertExprToHLFIR.h
flang/include/flang/Lower/ConvertProcedureDesignator.h
flang/include/flang/Optimizer/Builder/Character.h
flang/include/flang/Optimizer/Builder/HLFIRTools.h
flang/lib/Lower/Bridge.cpp
flang/lib/Lower/CallInterface.cpp
flang/lib/Lower/ConvertCall.cpp
flang/lib/Lower/ConvertExprToHLFIR.cpp
flang/lib/Lower/ConvertProcedureDesignator.cpp
flang/lib/Lower/ConvertVariable.cpp
flang/lib/Optimizer/Builder/Character.cpp
flang/lib/Optimizer/Builder/HLFIRTools.cpp
flang/test/Lower/HLFIR/procedure-designators.f90 [new file with mode: 0644]