2

我正在尝试在 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.

这是源文件的相关部分。源文件是另一个问题的简化案例,它可以在 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 支持它

第 118 行与上面显示的所有其他行一样,但它不会触发警告或错误。

有什么问题,我该如何解决?

4

3 回答 3

2

在 PPC64-LE 上,在统一 GCC 和 XL 之间的矢量内置接口方面付出了很多努力。两个团队共同致力于为 ABI 文档添加一致的界面。你可以在这里找到它:

文件格式_

作为 ABI 一部分的新 vcipher 函数是 xlC 支持的 vec_cipher_be。

请注意,新函数的部分原因是一些旧 GCC 加密函数接受的类型会存在字节顺序问题。

于 2017-09-07T19:50:02.333 回答
1

您链接到的红皮书是关于“包括 IBM POWER8 在内的 IBM Power Systems 处理器的性能优化和调优技术”,并不是特定于编译器的。它包括有关 POWER8 上的编译器支持的信息,包括 XLC 和 GCC 编译器。

在红皮书第 149 页的第 7.3.1 节(如果您使用 PDF 页面推进器,则为第 171 页),声明了以下支持:

  • 海湾合作委员会vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long, vector unsigned long long)
  • XL C/C++vector unsigned char __vcipher (vector unsigned char, vector unsigned char)

如果你使用 GCC 编译,你应该使用__builtin_crypto_vcipher.,如果你使用 XLC 编译,你应该使用__vcipher.

于 2017-09-07T17:55:01.323 回答
0

Operation between types "vector unsigned int" and "int" is not allowed

我想我追踪到了这个。xlC 不知道 function __builtin_crypto_vcipher,因此编译器假定该函数接受int's 作为参数或返回 an int(我现在不确定哪个)。我相信等效的 GCC 消息是关于缺少声明并假设int返回。

稍后,未知函数采用向量而不是 int:

__builtin_crypto_vcipher(block, ...)

或者,它将一个分配int给一个向量:

block = __builtin_crypto_vcipher(...)

当我切换到 xlC 的内置__vcipher时,问题就消失了。

我不知道为什么文档状态 xlC 接受 GCC 内置的。

于 2017-09-07T13:13:12.637 回答