This is an archive of the discontinued LLVM Phabricator instance.

[flang] Enable character type guard in select type
ClosedPublic

Authored by clementval on Dec 1 2022, 6:07 AM.

Details

Summary

SELECT TYPE lower and conversion was not handling
character type guard. This add support for it.

Diff Detail

Event Timeline

clementval created this revision.Dec 1 2022, 6:07 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptDec 1 2022, 6:07 AM
Herald added a subscriber: mehdi_amini. · View Herald Transcript
clementval requested review of this revision.Dec 1 2022, 6:07 AM
jeanPerier added inline comments.Dec 1 2022, 6:33 AM
flang/lib/Lower/Bridge.cpp
2308

Shouldn't the length come from the selector fir.class instead of being unknow at runtime ? (fir::factory::CharacterExprHelper.readLengthFromBox might be able to do this).
This code also seems to only deal with scalars, SELECT TYPE support for intrinsic types is still TODO right ?

clementval added inline comments.Dec 1 2022, 8:23 AM
flang/lib/Lower/Bridge.cpp
2308

We can use the BoxEleSizeOp but not fir::factory::CharacterExprHelper.readLengthFromBox since it requires a fir.char type.

The support for intrinsic type is already in.

jeanPerier added inline comments.Dec 1 2022, 8:57 AM
flang/lib/Lower/Bridge.cpp
2308

We can use the BoxEleSizeOp but not fir:🏭:CharacterExprHelper.readLengthFromBox since it requires a fir.char type

Makes sense. Do not forget to divide by the character kind.

The support for intrinsic type is already in.

Sorry, my question was about intrinsic arrays, I forgot the important word.... It seems the code does not care about the shape at that point for intrinsic types.

clementval added inline comments.Dec 1 2022, 9:25 AM
flang/lib/Lower/Bridge.cpp
2308

Makes sense. Do not forget to divide by the character kind.

Right. Kind might not be retrievable since the the selector is always unlimited polymorphic for intrinsic type guards. So we might need to keep unknownLen unless there is another way to retrive the kind?

Sorry, my question was about intrinsic arrays, I forgot the important word.... It seems the code does not care about the shape at that point for intrinsic types.

Oh ok. Yeah it might need some update for arrays.

jeanPerier added inline comments.Dec 1 2022, 9:35 AM
flang/lib/Lower/Bridge.cpp
2308

You should be able to get the kind from the type guard of the TYPE_IS (attr.getType()) that should be a fir.char<kind, len> here right ?

clementval added inline comments.Dec 1 2022, 10:00 AM
flang/lib/Lower/Bridge.cpp
2308

Yeah my bad. I'm not thinking correctly today :)

Get char length from box

clementval marked 3 inline comments as done.Dec 1 2022, 11:42 AM
clementval added inline comments.
flang/lib/Lower/Bridge.cpp
2308

I'll do array in a separate patch.

jeanPerier accepted this revision.Dec 2 2022, 12:01 AM

Looks good

flang/lib/Lower/Bridge.cpp
2308

I'll do array in a separate patch.

Sound good to me

This revision is now accepted and ready to land.Dec 2 2022, 12:01 AM
This revision was automatically updated to reflect the committed changes.