This is an archive of the discontinued LLVM Phabricator instance.

[flang] Lower binary and unary elemental array operations
ClosedPublic

Authored by jeanPerier on Dec 14 2022, 11:25 AM.

Details

Summary

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

Depends on D140031

Diff Detail

Event Timeline

jeanPerier created this revision.Dec 14 2022, 11:25 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 14 2022, 11:25 AM
jeanPerier requested review of this revision.Dec 14 2022, 11:25 AM

LGTM. Small comment about the unknown extent value.

flang/include/flang/Optimizer/Builder/HLFIRTools.h
204
flang/include/flang/Optimizer/HLFIR/HLFIROpBase.td
77

Should we use mlir::ShapedType::kDynamic as in FIR?

clementval accepted this revision.Dec 15 2022, 3:00 AM
This revision is now accepted and ready to land.Dec 15 2022, 3:00 AM
jeanPerier marked 2 inline comments as done.Dec 15 2022, 4:16 AM
jeanPerier added inline comments.
flang/include/flang/Optimizer/HLFIR/HLFIROpBase.td
77

Thanks, that's better yes.

This revision was automatically updated to reflect the committed changes.
jeanPerier marked an inline comment as done.