[flang] Lower binary and unary elemental array operations
authorJean Perier <jperier@nvidia.com>
Thu, 15 Dec 2022 11:54:56 +0000 (12:54 +0100)
committerJean Perier <jperier@nvidia.com>
Thu, 15 Dec 2022 12:15:12 +0000 (13:15 +0100)
commit3191e8e19f1a7007ddd0e55cee60a51a058c99f5
tree061d515483ddc249a0641d407902eeaf41557c8a
parent731abdfdcc33d813e6c3b4b89eff307aa5c18083
[flang] Lower binary and unary elemental array operations

Lower binary and unary elemental operations with an array argument
using hlfir.elemental, hlfir.yield_element, and hlfir.apply.

Concat implementation, which is a binary operation, is moved to a
BinaryOp struct so that it can leverage this new code.

This patch implements the "not yet implemented: character array
expression temp with dynamic length" TODO of the current lowering
by splitting the result length computation from the result value
computation. That way, the result length computation can be done
before lowering the operation to an hlfir.elemental, and the length
of the hlfir.elemental is known and storage for it can later be
allocated.

It adds a DesignatorOp builder to make "dumb" indexing (without triplets,
component, substrings or derived type component ref) easier since indexing
needs to be generated for array variables in elemental expression (in
the added hlfir::genElementAt helper).

Differential Revision: https://reviews.llvm.org/D140040
flang/include/flang/Optimizer/Builder/HLFIRTools.h
flang/include/flang/Optimizer/HLFIR/HLFIROpBase.td
flang/include/flang/Optimizer/HLFIR/HLFIROps.td
flang/lib/Lower/ConvertExprToHLFIR.cpp
flang/lib/Optimizer/Builder/HLFIRTools.cpp
flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp
flang/test/Lower/HLFIR/elemental-array-ops.f90 [new file with mode: 0644]