[all-commits] [llvm/llvm-project] 199e49: [flang] Lower elemental intrinsics to hlfir.elemental

jeanPerier via All-commits all-commits at lists.llvm.org
Fri Jan 13 00:19:36 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 199e49746db83f1e56d5899f1905784bbfa142e3
      https://github.com/llvm/llvm-project/commit/199e49746db83f1e56d5899f1905784bbfa142e3
  Author: Jean Perier <jperier at nvidia.com>
  Date:   2023-01-13 (Fri, 13 Jan 2023)

  Changed paths:
    M flang/include/flang/Lower/ConvertExprToHLFIR.h
    M flang/include/flang/Optimizer/Builder/HLFIRTools.h
    M flang/lib/Lower/Bridge.cpp
    M flang/lib/Lower/ConvertCall.cpp
    M flang/lib/Lower/ConvertExprToHLFIR.cpp
    A flang/test/Lower/HLFIR/elemental-intrinsics.f90

  Log Message:
  -----------
  [flang] Lower elemental intrinsics to hlfir.elemental

- Move the core code generating hlfir.elemental for user calls from
  genUserElementalCall into a new ElementalCallBuilder class and use
  C++ CRTP (curiously recursive template pattern) to implement the
  parts specific to user and intrinsic call into ElementalUserCallBuilder
  and ElementalIntrinsicCallBuilder. This allows sharing the core logic
  to lower elemental procedures for both user defined and intrinsics
  procedures.

- To allow using ElementalCallBuilder, split the intrinsic lowering code
  into two parts: first lower the arguments to hlfir::Entity regardless
  of the interface of the intrinsics, and then, in a different function
  (genIntrinsicProcRefCore), prepare the hlfir::Entity according to the
  interface. This allows using the same core logic to prepare "normal"
  arguments for non-elemental intrinsics, and to prepare the elements of
  array arguments inside elemental call (ElementalIntrinsicCallBuilder
  calls genIntrinsicProcRefCore once it has computed the scalar actual
  arguments).
  To allow this split, genExprBox/genExprAddr/genExprValue logic had to
  be split in ConvertExprToHlfir.[cpp/h].

- Add missing statement context pushScope/finalizeAndPop around the
  code generation inside the hlfir.elemental so that any temps created
  while lowering the call at the element level is correctly cleaned-up.

- One piece of code in hlfir::Entity::hasNonDefaultLowerBounds() was wrong for assumed shape arrays (returned true when an assumed shaped array had no explicit lower bounds). This caused the added test to hit a bogus TODO, so fix it.

Elemental intrinsics returning are still TODO (e.g., adjustl). I will implement this in a next patch, this one is big enough.

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




More information about the All-commits mailing list