This is an archive of the discontinued LLVM Phabricator instance.

[flang] Add RISCV-64 support to Optimizer/CodeGen/Target.cpp
ClosedPublic

Authored by realqhc on Oct 23 2022, 12:53 AM.

Details

Summary

As an attempt to fix errors in Flang regression tests on RISCV64 platform, RISCV64 target was added, and subsequent tests were provided.

Diff Detail

Event Timeline

realqhc created this revision.Oct 23 2022, 12:53 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptOct 23 2022, 12:53 AM
realqhc requested review of this revision.Oct 23 2022, 12:53 AM

Do you have a buildbot that test this target for Flang?

Your patch has clang-format issues.

realqhc updated this revision to Diff 470065.Oct 24 2022, 12:21 AM

Run clang-format on the patch

brad added a comment.Oct 31 2022, 12:12 AM

Please rebase the patch.

Do you have a buildbot that test this target for Flang?

Ping.

Do you have a buildbot that test this target for Flang?

Ping.

I have test it under qemu-user locally with good results, and am actively trying to compile it under risc-v unmatched board. The compilation is extremely lengthy and I can post the result once it has been finished.

realqhc updated this revision to Diff 471983.Oct 31 2022, 6:21 AM

rebase the commit

brad added a comment.Oct 31 2022, 4:45 PM

rebase the commit

Make sure your source tree is up to date. Target.cpp specifically changed in the area the last chunk is making changes to.

realqhc updated this revision to Diff 472210.Oct 31 2022, 10:11 PM

rebase commit to up to date main

Your patch still has some clang-format issues

realqhc updated this revision to Diff 473171.Nov 4 2022, 2:16 AM

run clang-format to fix it

vzakhari added inline comments.
flang/lib/Optimizer/CodeGen/Target.cpp
357

I am not sure about this. Can you please take a look at https://godbolt.org/z/7PYsv8PjM?

It seems that the arguments are passed as two separate values.

realqhc added inline comments.Nov 21 2022, 10:22 PM
flang/lib/Optimizer/CodeGen/Target.cpp
357

The riscv-cc says

A struct containing two floating-point reals is passed in two floating-point registers, if neither real is more than ABI_FLEN bits wide and at least two floating-point argument registers are available. (The registers need not be an aligned pair.) Otherwise, it is passed according to the integer calling convention.

A complex floating-point number, or a struct containing just one complex floating-point number, is passed as though it were a struct containing two floating-point reals.

so I was a bit unsure about whether or not this procedure(reducing struct of two values into two separate value) should be done here.

realqhc added a comment.EditedNov 22 2022, 12:03 AM

ping.

Failed Tests (1):

flang-OldUnit :: Evaluate/real.test

FAIL: flang-OldUnit :: Evaluate/real.test (1044 of 1652)

  • TEST 'flang-OldUnit :: Evaluate/real.test' FAILED ****

.../llvm-project/flang/unittests/Evaluate/real.cpp:504: FAIL: FlagsToBits(prod.flags) == 0x18, not 0x10
0 0x800001 * 0xbf7ffffe

The only test failed was not due to this patch and it is caused by risc-v not flagging for underflow.

realqhc updated this revision to Diff 477138.Nov 22 2022, 4:31 AM

change the argument type to match clang behaviors

realqhc marked an inline comment as done.Nov 22 2022, 4:31 AM

ping.

Failed Tests (1):

flang-OldUnit :: Evaluate/real.test

FAIL: flang-OldUnit :: Evaluate/real.test (1044 of 1652)

  • TEST 'flang-OldUnit :: Evaluate/real.test' FAILED ****

.../llvm-project/flang/unittests/Evaluate/real.cpp:504: FAIL: FlagsToBits(prod.flags) == 0x18, not 0x10
0 0x800001 * 0xbf7ffffe

The only test failed was not due to this patch and it is caused by risc-v not flagging for underflow.

Issues and a fix is created for this error.
https://github.com/llvm/llvm-project/issues/59132
https://reviews.llvm.org/D138503

vzakhari accepted this revision.Nov 28 2022, 11:24 AM

Thanks!

This revision is now accepted and ready to land.Nov 28 2022, 11:24 AM
This revision was landed with ongoing or failed builds.Nov 28 2022, 2:49 PM
This revision was automatically updated to reflect the committed changes.
This comment was removed by kiranchandramohan.