This is an archive of the discontinued LLVM Phabricator instance.

[flang] Add lowering for integer constant
ClosedPublic

Authored by clementval on Feb 2 2022, 6:33 AM.

Details

Summary

This patch enables the lowering of integer constant.

The ScalarExprLowering class is introduced in ConvertExpr.cpp to help
the lowering of expression. This patch adds all the placeholder as well for future
expression lowering with the appropriate TODOs.

Integer constant expression are lowered to arith.constant with an integer type corresponding to the kind value.

This patch is in support of D118787

This patch is part of the upstreaming effort from fir-dev branch.

Diff Detail

Event Timeline

clementval created this revision.Feb 2 2022, 6:33 AM
Herald added a project: Restricted Project. · View Herald Transcript
clementval requested review of this revision.Feb 2 2022, 6:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 2 2022, 6:33 AM
clementval edited the summary of this revision. (Show Details)Feb 2 2022, 6:42 AM
clementval added inline comments.
flang/lib/Lower/ConvertExpr.cpp
15

Sorry for the commented includes. I'll update the patch to remove them

clementval edited the summary of this revision. (Show Details)Feb 2 2022, 6:44 AM
clementval updated this revision to Diff 405251.Feb 2 2022, 6:48 AM

Remove commented includes

Thanks, @clementval. Great job in factoring out the scalar integer expressions.

Could you add to the commit message that genExprValue is the top-level function that is used in this patch? Will be a good starting point for reviewing.

LGTM.

flang/lib/Lower/ConvertExpr.cpp
252

Nit: Can the auto be removed here?
std::optional<Scalar<Type<TypeCategory::Character, KIND>>> ?

309

Nit: Is this used in this or the related patches? If not I think it might be better to skip in this one.

flang/lib/Lower/ConvertType.cpp
499

Nit: Should this be "non-INTEGER type translation not implemented"?

This revision is now accepted and ready to land.Feb 2 2022, 11:08 AM
schweitz accepted this revision.Feb 2 2022, 12:14 PM
clementval marked 3 inline comments as done.Feb 2 2022, 1:45 PM
clementval added inline comments.
flang/lib/Lower/ConvertType.cpp
499

It should only be called for Integer type but the kind might be off. I updated the message.

clementval updated this revision to Diff 405428.Feb 2 2022, 1:46 PM
clementval marked an inline comment as done.

Address review comments

clementval updated this revision to Diff 405547.Feb 3 2022, 1:50 AM

Fix clang-format

This revision was landed with ongoing or failed builds.Feb 3 2022, 2:10 AM
This revision was automatically updated to reflect the committed changes.