我正在对Apple Clang进行测试,而且我遇到了过去没有遇到过的错误。代码如下,如果缺少_mm_set_epi64x
内在函数,它将替换它。
#if defined(__clang__)
# define GCC_INLINE inline
# define GCC_INLINE_ATTRIB __attribute__((__gnu_inline__, __always_inline__))
#elif (GCC_VERSION >= 30300) || defined(__INTEL_COMPILER)
# define GCC_INLINE __inline
# define GCC_INLINE_ATTRIB __attribute__((__gnu_inline__, __always_inline__, __artificial__))
#else
# define GCC_INLINE inline
# define GCC_INLINE_ATTRIB
# endif
...
GCC_INLINE __m128i GCC_INLINE_ATTRIB
MM_SET_EPI64X(const word64 a, const word64 b)
{
const word64 t[2] = {b,a}; __m128i r;
asm ("movdqu %1, %0" : "=x"(r) : "m"(t));
return r;
}
错误是:
c++ -DNDEBUG -g2 -O2 -c sha.cpp
In file included from sha.cpp:24:
./cpu.h:689:39: error: cannot compile this unexpected cast lvalue yet
asm ("movdqu %1, %0" : "=x"(r) : "m"(t));
Apple Clang版本是:
$ c++ --version
Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin13.4.0
Thread model: posix
根据Clang Bug 20201,问题已经解决。我对20201错误的问题是:
由于(4),我必须尝试修复它。由于(2)和(3),我不知道如何解决它。
问题是什么,我该如何解决?
答案 0 :(得分:1)
好的,随机猜测时间,但似乎有效...在相关的错误报告中,有this posting说:
这是通过从非类rvalues中删除cv限定符的工作来解决的。
这告诉我内部结构中有一些const
属性,所以像这样:
word64 a1 = a, b1 = b;
word64 t[2] = {b1,a1};
可能会工作,因为通过复制到明确声明的非const
变量,可以防止const
和a
b
的传播被阻止。这已被确认为由OP工作,因此他们的最终解决方案将在此呈现给后人:
GCC_INLINE __m128i GCC_INLINE_ATTRIB
MM_SET_EPI64X(const word64 a, const word64 b)
{
#if defined(__clang__)
word64 t1 = a, t2 = b;
const word64 t[2] = {t2,t1}; __m128i r;
asm ("movdqu %1, %0" : "=x"(r) : "m"(t));
return r;
#else
const word64 t[2] = {b,a}; __m128i r;
asm ("movdqu %1, %0" : "=x"(r) : "m"(t));
return r;
#endif
}