[llvm-dev] [compiler-rt] Support 128 bits soft-floating point without int128_t support

Kito Cheng via llvm-dev llvm-dev at lists.llvm.org
Wed Jan 31 00:04:23 PST 2018


Hi Alex:

> As a point of information, it would be useful to know if there are any major drawbacks or challenges to adding __int128_t support to GCC for RV32.

Short summary is it seems possible to support that on rv32-gcc, but
need take some time and discuss to other RISC-V gcc maintainer and
related people.


Provide some result from my experimentation with gcc last few days.:

For code gen part:
Need some code to enable __int128_t support on this target, and update
related opcode expansion method on backend.
so the code gen part seems not too hard.

For libgcc part:
Lacks of 128 bits integer support for 32 bits target, we need
implement int128_t functions manually (or doing some hack to make
libgcc generate those functions).

Function list, it's extract from rv64's libgcc :
__absvti2
__addvti3
__negti2
__negvti2
__subvti3

__ashlti3
__ashrti3
__lshrti3

__cmpti2
__ucmpti2

__clrsbti2
__clzti2
__ctzti2
__ffsti2

__divti3
__modti3
__multi3
__mulvti3
__udivti3
__umodti3

__parityti2
__popcountti2

On Tue, Jan 30, 2018 at 10:39 PM, Alex Bradbury via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> On 30 January 2018 at 14:12, Kito Cheng via llvm-dev
> <llvm-dev at lists.llvm.org> wrote:
>> Hi all:
>>
>> I'm porting RISC-V[1] for compiler-rt recently, and I've got a problem
>> when adding soft float routine for rv32, RISC-V ABI required 128 bits
>> bits for long double, but it's implemented by int128_t, however rv32
>> don't support __int128_t.
>>
>> Of cause, it not hard thing to support __int128_t by overriding
>> TargetInfo::hasInt128Type for LLVM, but its will cause some ABI
>> incompatible with GCC, because GCC don't support __int128_t for 32
>> bits target.
>>
>> So I guess I've few option here:
>>
>> 1. Implement 128 bits soft-float with int64_t.
>> 2. Add an option to force enable int128_t support during building
>> compiler-rt for rv32.
>>
>> Any other suggestion?
>
> As a point of information, it would be useful to know if there are any
> major drawbacks or challenges to adding __int128_t support to GCC for
> RV32. Looking at Clang, it seems (by my reading) that Wasm32 is the
> only 32-bit target supporting __int128_t (though x86-64 with 32-bit
> ABI and Mips64 with 32-bit ABI also support it). Given that `long
> double` is 128 bits on both RV32 and RV64, __int128_t wouldn't be the
> only 128-bit type.
>
> Best,
>
> Alex
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev


More information about the llvm-dev mailing list