[flang-commits] [PATCH] D141612: [flang] Lower elemental intrinsics to hlfir.elemental

Jean Perier via Phabricator via flang-commits flang-commits at lists.llvm.org
Thu Jan 12 07:43:48 PST 2023


jeanPerier created this revision.
jeanPerier added reviewers: PeteSteinfeld, clementval.
jeanPerier added a project: Flang.
Herald added subscribers: mehdi_amini, jdoerfert.
Herald added a project: All.
jeanPerier requested review of this revision.

- 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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141612

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D141612.488650.patch
Type: text/x-patch
Size: 34687 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20230112/a0614783/attachment-0001.bin>


More information about the flang-commits mailing list