__builtin_addcll 和 _addcarry_u64 之间的区别
早上好(或晚上好),
我正在阅读公司中的一些遗留代码,我发现使用了以下内在函数:
_addcarry_u64
但是,我必须将此代码移植到不支持它的平台上。 经过一番研究,我偶然发现了一个 Clang 内置函数,它似乎可以完成完全相同的工作:
__builtin_addcll
它具有相同的参数(顺序不同,但仍然如此),但是,因为几乎没有 文档 即使在 Clang 网站上,我也不知道它们是否真的相同,尤其是因为返回类型或参数顺序不同。
我尝试使用宏来重新映射已使用的参数,但它不起作用(我知道它很脏)。
#define _addcarry_u64(carryIn, src1, src2, carryOut) __builtin_addcll(src1, src2, carryIn, carryOut)
我觉得我必须将它包装在一个函数中才能正常工作(仍然不确定它是否有效)
任何人都可以向我指出文档或任何可以解决我的问题的内容吗?
Good morning (or good evening),
I was reading some legacy code in my company and I found the following intrinsic was used:
_addcarry_u64
However, I have to port this code on a platform that does not support it.
After some research, I stumbled upon a Clang builtin that seemed to do the exact same job:
__builtin_addcll
It has the same arguments (not in the same order but still), however, since there is little to no documentation about it even on Clang website, I have no clue if they truly are the same or not, especially since return types or argument order is not the same.
I tried to use a macro to remap already used arguments however it did not work (I know it's dirty).
#define _addcarry_u64(carryIn, src1, src2, carryOut) __builtin_addcll(src1, src2, carryIn, carryOut)
I feel I will have to wrap it in a function for it to work correctly (still I'm not sure it would work)
Can anyone point me to a documentation or to anything that could solve my problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
_addcarry_u64
是 Intel 为所有 Intel 平台提供的官方内部名称__builtin_addcll
是 Clang 固有的,适用于 Clang 支持的所有平台__builtin_uaddll_overflow
系列是对于 GCC 支持的所有平台,GCC 中的等效项Clang 的签名是
,Intel 版本是
所以你的宏不正确。
_addcarry_u64
添加 2 个数字并返回进位,并且按照 Intel 的规定通过指针返回总和__builtin_addcll
OTOH 直接返回总和,并且执行结果通过指针返回,正如您可以从 Clang 文档链接的等价物是
因此Clang 中
_addcarry_u64
is the official intrinsic name from Intel for all Intel platforms__builtin_addcll
is the intrinsic from Clang for all platforms supported by Clang__builtin_uaddll_overflow
family is the equivalent in GCC for all platforms supported by GCCThe signature for Clang is
and the Intel version is
So your macro is incorrect.
_addcarry_u64
adds 2 number and returns the carry, and the sum is returned via a pointer as stated by Intel__builtin_addcll
OTOH returns the sum directly and the carry out is returned via a pointer as you can see right from your Clang documentation linkSo the equivalent to
in Clang is