[PATCH] D70401: [RISCV] Complete RV32E/ilp32e implementation

Zakk Chen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 18 01:04:46 PDT 2022


khchen added a comment.
Herald added a subscriber: s.

In D70401#3384758 <https://reviews.llvm.org/D70401#3384758>, @pcwang-thead wrote:

> In D70401#3250049 <https://reviews.llvm.org/D70401#3250049>, @khchen wrote:
>
>> 1. please add a check here <https://github.com/llvm/llvm-project/blob/c29d6c410e769938ed5db1090a1b894cf6061a4e/llvm/lib/Support/RISCVISAInfo.cpp#L704> and a clang cc1 test for it.
>> 2. Have you try to run llvm-test-suite with rv32e config on qemu?
>
>
>
> 1. Thanks, I may do it later. And here is a question: the comment <https://github.com/llvm/llvm-project/blob/c29d6c410e769938ed5db1090a1b894cf6061a4e/llvm/lib/Support/RISCVISAInfo.cpp#L704> says `It is illegal to specify 'e' extensions with 'f' and 'd'`.
>
> While ilp32e <https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-cc.adoc#ilp32e-calling-convention> says:
>
>> The ILP32E calling convention is not compatible with ISAs that have registers that require load and store alignments of more than 32 bits. In particular, this calling convention must not be used with the D ISA extension.
>
> And, the RV32E <https://github.com/riscv/riscv-isa-manual/blob/master/src/rv32e.tex> chapter in RISCV ISA manual says:
>
>> RV32E can be combined with all current standard extensions.
>
> If I understand correctly, E can't be combined with D in current specification since E must use ILP32E calling convention.

IMO, at least clang need to follows the gcc's implementation.
I guess gcc implementation follow riscv-elf-psabi-doc, @kito-cheng could you please confirm that?

> 2. I have run llvm-test-suite with rv32e on qemu, and found no major fault for current implementation. Some tests are disabled because they can't run on bare mental (sees Disabled llvm-test-suite cases <https://pastebin.com/9j4ydQFf>).
>
> There are some failed tests due to floating-point precision, but I saw the same result when run with  rv32imc on bare mental. I haven't taken the time to find out the reason, but I guess it may be soft-float issues.

Thanks for testing!! I also tested your patch locally, 
Could you please make sure all gcc and clang results are the same in your failed tests?

I found https://github.com/llvm/llvm-test-suite/blob/main/SingleSource/UnitTests/2003-05-26-Shorts.c result is mismatched with gcc's (-march=rv32e -mabi=ilp32e).
Did you have same issue?

my build option:

  $/path/to/rv32e-gcc/bin/riscv32-unknown-elf-gcc -march=rv32e -mabi=ilp32e 2003-05-26-Shorts.c
  $./bin/clang --target=riscv32 -march=rv32e -mabi=ilp32e --gcc-toolchain=/path/to/rv32e-gcc/ 2003-05-26-Shorts.c 

clang output:

     ui = 3318069411 (0xc5c5b8a3)         UL-ui = 0 (0xafafafaf)                            
  ui*ui = 2382936009 (0x8e08b7c9)   UL/ui = -2060025877491592863 (0xe369516100000000)       
                                                                                            
      i = -976897885 (0xc5c5b8a3) L-i = 0 (0xafafafb0)                                      
   i* i = -1912031287 (0x8e08b7c9)        L/ i = 6996953267980741613 (0x611a2bed00000001)   
                                                                                            
  us    = 47267 (0xb8a3)          UL-us = -4195947477825748992 (0xc5c50000afafafaf)         
  us*us = 2234169289 (0x852ab7c9)   UL/us = 1452874783539635691 (0x1429a5eb0000f397)        
                                                                                            
   s    = -18269 (0xffffb8a3)     L-s = -4195666002849038335 (0xc5c60000afafafaf)           
   s* s = 333756361 (0x13e4b7c9)  L/ s = -7718140893307295808 (0x94e3a7c00001201b)          
                                                                                            
  ub    = 163 (0xa3)              UL-ub = -4195745167686238208 (0xc5c5b800afafafaf)         
  ub*ub = 26569 (0x67c9)          UL/ub = 2350833624863004346 (0x209fd6ba0113eca9)          
                                                                                            
   b    = -93 (0xffffffa3)                L-b = -4195744068174610431 (0xc5c5b900afafafaf)   
   b* b = 8649 (0x21c9)                   L/b = -1938405340110362979 (0xe519669d00dd1421)   

gcc output:

     ui = 3318069411 (0xc5c5b8a3)         UL-ui = -5787213829993660416 (0xafafafaf00000000)
  ui*ui = 2382936009 (0x8e08b7c9)   UL/ui = 3815330145 (0xe3695161)
  
      i = -976897885 (0xc5c5b8a3) L-i = -5787213825698693120 (0xafafafb000000000)
   i* i = -1912031287 (0x8e08b7c9)        L/ i = 5924072429 (0x1611a2bed)
  
  us    = 47267 (0xb8a3)          UL-us = -5787213826675638272 (0xafafafafc5c50000)
  us*us = 2234169289 (0x852ab7c9)   UL/us = 267830203885035 (0xf3971429a5eb)
  
   s    = -18269 (0xffffb8a3)     L-s = -5787213826675572736 (0xafafafafc5c60000)
   s* s = 333756361 (0x13e4b7c9)  L/ s = 316777810864064 (0x1201b94e3a7c0)
  
  ub    = 163 (0xa3)              UL-ub = -5787213826675591168 (0xafafafafc5c5b800)
  ub*ub = 26569 (0x67c9)          UL/ub = 77665829736404666 (0x113eca9209fd6ba)
  
   b    = -93 (0xffffffa3)                L-b = -5787213826675590912 (0xafafafafc5c5b900)
   b* b = 8649 (0x21c9)                   L/b = 62228105663178397 (0xdd1421e519669d)




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70401/new/

https://reviews.llvm.org/D70401



More information about the llvm-commits mailing list