[llvm-dev] Correct way to pass int128 from LLVM to C++ function (MSVC)

Reid Kleckner via llvm-dev llvm-dev at lists.llvm.org
Wed Dec 21 13:13:54 PST 2016


On Wed, Dec 21, 2016 at 11:18 AM, Stefan de Bruijn <stefan at nubilosoft.com>
wrote:

> Thanks for the quick reply. Yes, passing it as int128* is a workaround
> that obviously works. Still, that leaves me with the return values. Or are
> you suggesting that I rewrite
>
>
>
> int128 Modify(int128& tmp) { … }
>
>
>
> to
>
>
>
> void Modify(int128& result, int128& tmp) { … }
>
>
>
> Obviously that will work, it just feels… dirty and wrong… :-)
>

Eh, you're just doing what LLVM would do on your behalf. It will open some
optimizations but block others. =/


> I’ve also attempted to bit-cast i128’s to <2 x i64> in LLVM. The ABI
> problems are pretty much the same. At a first glance, it seems to me like
> this problem is more general, namely: for all structures larger than 8
> bytes.
>

My tests show that we translate __m128i to <2 x i64>, and that we are ABI
compatible with MSVC when passing __m128i values, so this should actually
work. Behind the scenes LLVM will pass these values indirectly by pointer.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161221/7121ab07/attachment.html>


More information about the llvm-dev mailing list