我试图在PPC64-LE上编译源文件。我正在使用xlC编译器,编译失败。 GCC接受该计划,所以我不确定问题的原因是什么。
这是命令行:
$ xlc test-p8.c -qarch=pwr8 -qaltivec -o test-p8.exe
这是编译错误:
"test-p8.c", line 113.52: 1506-324 (S) "int" cannot be converted to "vector unsigned int".
"test-p8.c", line 120.15: 1506-068 (S) Operation between types "vector unsigned int" and "int" is not allowed.
"test-p8.c", line 121.15: 1506-068 (S) Operation between types "vector unsigned int" and "int" is not allowed.
"test-p8.c", line 122.15: 1506-068 (S) Operation between types "vector unsigned int" and "int" is not allowed.
"test-p8.c", line 123.15: 1506-068 (S) Operation between types "vector unsigned int" and "int" is not allowed.
"test-p8.c", line 124.15: 1506-068 (S) Operation between types "vector unsigned int" and "int" is not allowed.
"test-p8.c", line 125.15: 1506-068 (S) Operation between types "vector unsigned int" and "int" is not allowed.
"test-p8.c", line 126.15: 1506-068 (S) Operation between types "vector unsigned int" and "int" is not allowed.
"test-p8.c", line 127.15: 1506-068 (S) Operation between types "vector unsigned int" and "int" is not allowed.
"test-p8.c", line 128.15: 1506-068 (S) Operation between types "vector unsigned int" and "int" is not allowed.
"test-p8.c", line 130.15: 1506-068 (S) Operation between types "vector unsigned int" and "int" is not allowed.
这是源文件的相关部分。源文件是another problem的简化大小写,它是available on GitHub。
$ cat -n test-p8.c
...
12 typedef unsigned char uint8_t;
13 typedef unsigned long long uint64_t;
14 typedef vector unsigned char uint8x16_p8;
15 typedef vector unsigned int uint64x2_p8;
...
76 __attribute__((aligned(16)))
77 uint8_t ks[176] = {
78 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x9, 0xcf, 0x4f, 0x3c,
...
89 };
...
113 uint64x2_p8 block = (uint64x2_p8)vec_vsx_ld(0U, (const uint8_t*)plain);
...
118 block = vec_xor(block, (uint64x2_p8)vec_ld(0U, (const uint8_t*)ks));
...
120 block = __builtin_crypto_vcipher(block, (uint64x2_p8)vec_ld( 16U, (const uint8_t*)ks));
121 block = __builtin_crypto_vcipher(block, (uint64x2_p8)vec_ld( 32U, (const uint8_t*)ks));
122 block = __builtin_crypto_vcipher(block, (uint64x2_p8)vec_ld( 48U, (const uint8_t*)ks));
123 block = __builtin_crypto_vcipher(block, (uint64x2_p8)vec_ld( 64U, (const uint8_t*)ks));
124 block = __builtin_crypto_vcipher(block, (uint64x2_p8)vec_ld( 80U, (const uint8_t*)ks));
125 block = __builtin_crypto_vcipher(block, (uint64x2_p8)vec_ld( 96U, (const uint8_t*)ks));
126 block = __builtin_crypto_vcipher(block, (uint64x2_p8)vec_ld(112U, (const uint8_t*)ks));
127 block = __builtin_crypto_vcipher(block, (uint64x2_p8)vec_ld(128U, (const uint8_t*)ks));
128 block = __builtin_crypto_vcipher(block, (uint64x2_p8)vec_ld(144U, (const uint8_t*)ks));
129
130 block = __builtin_crypto_vcipherlast(block, (uint64x2_p8)vec_ld(160U, (const uint8_t*)ks));
__builtin_crypto_vcipher
是内置的GCC,IBM声明xlC supports it。
第118行与上面显示的所有其他行类似,但它不会触发警告或错误。
问题是什么,我该如何解决?
答案 0 :(得分:2)
在PPC64-LE上,我们花了很多精力来统一GCC和XL之间的矢量内置接口。两个团队共同努力为ABI文档添加一致的界面。你可以在这里找到它:
ABI的新vcipher函数是vec_cipher_be,xlC支持。
请注意,新功能的部分原因是某些旧GCC加密函数接受的类型会产生字节序问题。
答案 1 :(得分:1)
redbook you linked to是关于IBM Power Systems处理器的性能优化和调优技术,包括IBM POWER8"并且不是特定于编译器的。它包含有关POWER8上编译器支持的信息,包括XLC和GCC编译器。
在红皮书的第7.3.1页第149页(如果您使用PDF页面推进器,第171页),请说明以下支持:
vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long, vector unsigned long long)
vector unsigned char __vcipher (vector unsigned char, vector unsigned char)
如果您正在使用GCC进行编译,则应使用__builtin_crypto_vcipher
,如果您正在使用XLC进行编译,则应使用__vcipher
。
答案 2 :(得分:0)
Operation between types "vector unsigned int" and "int" is not allowed
我想我跟踪了这一点。 xlC不知道函数__builtin_crypto_vcipher
,因此编译器假定函数接受int
作为参数或返回int
(我不知道函数是哪一个)时刻)。我相信等效的GCC消息是关于遗漏声明并假设int
返回。
稍后,未知函数采用向量而不是int:
__builtin_crypto_vcipher(block, ...)
或者,它为向量指定int
:
block = __builtin_crypto_vcipher(...)
当我切换到xlC内置__vcipher
时,问题就消失了。
我不知道为什么文档声明xlC接受GCC内置的。