ldc icon indicating copy to clipboard operation
ldc copied to clipboard

RISCV64: Initial support

Open Ast-x64 opened this issue 3 years ago • 3 comments

This adds support for riscv64gc with the default LP64D ABI. This work with https://github.com/ldc-developers/druntime/pull/204 and https://github.com/ldc-developers/phobos/pull/71. Enable attribute +d by default to support riscv64gc D standard extension. ABI is implemented according to RISCV Calling Convention.

Currently it is not able to pass all tests.

Most failed tests are related to NaN payload issue. But this maybe a issue related to the platform. e.g., after atan calculation, NaN payload will be cleared. This behavior is the same with GDC. C codes compiled with GCC and Clang act the same.

The zlib-debug and zlib-debug-shared test failure is probably caused by a wrong signed/unsigned compiler optimization. This needs further investigation.

The druntime-test-gc-* test also fails on x86-64 according to my test. Failing assertion is the same one.

Many GDB tests and profdata tests fail. This needs further investigation. Sanitizers seem to be unusable. LTO should not be enabled because of soft-float and double-float merging issue. This error may be triggered with Clang too. This seems to be a common issue for LLVM-based compilers.

In dmd-testsuite*, runnable/argufilem.d fails with a comment inside explaining this may be a known issue. dshell/dll_cxx.d fails because c++ on riscv64 do not accept argument -m64. fail_compilation/test15703.d seem to output some extra unexpected explanations for compilation error.

Ast-x64 avatar Jun 28 '22 15:06 Ast-x64

Cool, thanks for working on this!

kinke avatar Jun 28 '22 15:06 kinke

Wrt. ABI - is there any PDF or so that you could link?

And how did you approach this? Have you checked the C[++] ABI interop tests in dmd-testsuite and tried to fix those? And/or looked at generated clang IR and tried to replicate that?

kinke avatar Jul 04 '22 13:07 kinke

Wrt. ABI - is there any PDF or so that you could link?

And how did you approach this? Have you checked the C[++] ABI interop tests in dmd-testsuite and tried to fix those? And/or looked at generated clang IR and tried to replicate that?

Thanks for your reply. I mainly implement this according to the RISC-V Calling Conventions, and I did fix some errors to pass all tests related to abi in dmd-testsuite*, by comparing verbose outputs with LLVM IRs generated from corresponding C codes using Clang.

Ast-x64 avatar Jul 04 '22 13:07 Ast-x64

Is there anything blocking this?

JohanEngelen avatar Aug 24 '22 10:08 JohanEngelen

I haven't found time for a proper review yet. And a link to the spec as a code comment would be appreciated.

kinke avatar Aug 24 '22 11:08 kinke

Thanks @Ast-x64, much appreciated.

kinke avatar Sep 10 '22 17:09 kinke