This is an archive of the discontinued LLVM Phabricator instance.

[flang] Add DerivedTypeSpec::VectorTypeAsFortran for PPC vector type
ClosedPublic

Authored by kkwli0 on May 30 2023, 2:55 PM.

Diff Detail

Event Timeline

kkwli0 created this revision.May 30 2023, 2:55 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 30 2023, 2:56 PM
kkwli0 requested review of this revision.May 30 2023, 2:56 PM
klausler added inline comments.May 30 2023, 4:14 PM
flang/include/flang/Semantics/type.h
309

Why does this have to be a distinct public member function as opposed to extending the behavior of AsFortran() in place? It seems error-prone for callers to have to remember to test with IsVectorType() and then call one or the other, when that test could be automatic inside AsFortran().

tislam added inline comments.May 30 2023, 6:51 PM
flang/include/flang/Semantics/type.h
309

Thank you for the suggestion.
We started with your idea of checking for vector types inside DerivedTypeSpec::AsFortran. However, we found that the caller of DerivedTypeSpec::AsFortran can add a prefix (like TYPE() and a corresponding suffix. An example follows.

return "TYPE(" + derivedTypeSpec().AsFortran() + ')';

For vector types, this resulted in strings of the form TYPE(VECTOR(INTEGER(4))). We need VECTOR(INTEGER(4)) instead. For this reason, we added the checking for vector-type at the caller-side.

klausler accepted this revision.May 31 2023, 8:30 AM
This revision is now accepted and ready to land.May 31 2023, 8:30 AM