This is an archive of the discontinued LLVM Phabricator instance.

[flang] Introduce FortranVariableOpInterface for ops creating variable
ClosedPublic

Authored by jeanPerier on Oct 18 2022, 3:08 AM.

Details

Summary

HLFIR will rely on certain operations to create SSA memory values
that correspond to a Fortran variable. They will hold bounds and type
parameters information as well as metadata (like Fortran attributes).

This patch adds an interface that for such operations so that Fortran
variable can be stored, manipulated, and queried regardless of what
created them. This is so far intended for fir.declare, hlfir.designate
and hlfir.associate operations.
It is added to FIR and not HLFIR because fir.declare needs it and it
does not itself needs any HLFIR concepts.

Unit tests for the interface methods will be added alongside
fir.declare in the next patch.

Diff Detail

Event Timeline

jeanPerier created this revision.Oct 18 2022, 3:08 AM
Herald added a project: Restricted Project. · View Herald Transcript
jeanPerier requested review of this revision.Oct 18 2022, 3:08 AM
clementval accepted this revision.Oct 18 2022, 3:11 AM

LGTM. There is a small type in the revision title.

This revision is now accepted and ready to land.Oct 18 2022, 3:11 AM
jeanPerier retitled this revision from [flang] Introduce FortranVariablOpInterface for ops creating variable to [flang] Introduce FortranVariableOpInterface for ops creating variable.Oct 18 2022, 3:46 AM
PeteSteinfeld accepted this revision.Oct 18 2022, 7:47 AM

Looking good! Aside from a few nits, all builds and tests correctly and looks good.

flang/include/flang/Optimizer/Dialect/FortranVariableInterface.td
10

Should read "This file defines"

22

Should this be "Interface for operations that create"?

Fix typos in descriptions.

jeanPerier marked 2 inline comments as done.Oct 18 2022, 8:38 AM

Thanks for spotting the typos Pete and Valentin.

clementval accepted this revision.Oct 18 2022, 8:57 AM
vzakhari added inline comments.
flang/include/flang/Optimizer/Dialect/FortranVariableInterface.td
112

Is it worth asserting that getExplicitTypeParams returns an empty range or a range with exactly one element, when isCharacter is true?

jeanPerier added inline comments.Oct 18 2022, 11:54 PM
flang/include/flang/Optimizer/Dialect/FortranVariableInterface.td
112

Yes, this will actually be done in the FortranVariableOpInterface verifier that I am adding in https://reviews.llvm.org/D136181 (see fir::FortranVariableOpInterface::verifyImpl) (it won't be an assertion though, but an MLIR verifier error with line location).

DavidSpickett added a subscriber: DavidSpickett.EditedOct 19 2022, 4:18 AM

FYI this is failing on the out of tree flang bot: https://lab.llvm.org/buildbot/#/builders/175/builds/19348

For reasons I can't explain, this commit isn't listed in any of the builds but I confirmed locally (I think the buildbot config is a bit strange).

Anyway, it appears that when we build flang, this new .h.inc file is not created. There are others that are so I will see if we can just follow their lead to fix this.

In tree builds are fine.