[PATCH] D114425: [clang] Add __builtin_bswap128

Craig Topper via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Jan 2 14:23:25 PST 2022


craig.topper added a comment.

In D114425#3216531 <https://reviews.llvm.org/D114425#3216531>, @Quuxplusone wrote:

> In D114425#3216490 <https://reviews.llvm.org/D114425#3216490>, @craig.topper wrote:
>
>> In D114425#3216231 <https://reviews.llvm.org/D114425#3216231>, @philnik wrote:
>>
>>> In D114425#3209794 <https://reviews.llvm.org/D114425#3209794>, @craig.topper wrote:
>>>
>>>> What does the builtin due if __int128 isn't supported? Even though the type isn't legal the builtin can still be called with a narrower type that would be implicitly converted. Does that work correctly?
>>>
>>> Would the correct behavior be to throw an error in that case? Or what exactly do you expect?
>>
>> gcc only defines the builtin if __int128 is a supported type. It doesn't look like it generates an error, it just leaves it as call to an unknown function. I don't know how easy it is to do the same in clang.
>
> The existing code has some lines like `CGM.ErrorUnsupported(E, "__builtin_dwarf_sp_column");` — I would try doing the same kind of thing in the case where `__int128` isn't supported. (But I don't know how to make `__int128` unsupported! Every place I can see `int128` mentioned in the code, it's not conspicuously guarded by any condition.)

I believe it controlled by hasInt128Type() in include/clang/Basic/TargetInfo.h. It should return false for riscv32 or i686 and probably other 32-bit targets.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114425



More information about the cfe-commits mailing list