1

我正在编译农场的 GCC111 上工作。该机器是 AIX 7.1、POWER7 和 IBM XLC 12.1。我正在尝试使用__rotatel4

$ cat test.cxx
#include <cstdlib>

unsigned int Foo (unsigned int x)
{
  return __rotatel4(x, 4U);
}

编译结果:

$ xlC -O3 -c test.cxx
"test.cxx", line 5.10: 1540-0274 (S) The name lookup for "__rotatel4" did not find a declaration.

根据编译器手册IBM XL C/C++ for AIX, V12.1 (p. 486),内在函数应该可用。这里是原型,没有POWER6那样的限制:

unsigned int __rotatel4 (unsigned int rs, unsigned int shift)

添加-qarch=pwr7和/或-D_XOPEN_SOURCE=600导致相同的错误。我在使用模板编译代码时发现了意外的名称查找错误“1540-0274 (S)”,但它似乎不适用于这里。

如何__rotatel4在程序中使用?


gcc111$ oslevel -s
7100-03-02-1412

gcc111$ xlC -qversion
IBM XL C/C++ for AIX, V12.1 (5765-J02, 5725-C72)
Version: 12.01.0000.0000
4

1 回答 1

2

对于 XL C/C++ V12.1,您需要包括<builtins.h>

$ cat aaa.cpp
#include <cstdlib>

unsigned int Foo (unsigned int x)
{
  return __rotatel4(x, 4U);
}
$ xlC aaa.cpp -c
"aaa.cpp", line 5.10: 1540-0274 (S) The name lookup for "__rotatel4" did not find a declaration.
$ cat aaa.cpp
#include <cstdlib>
#include <builtins.h>

unsigned int Foo (unsigned int x)
{
  return __rotatel4(x, 4U);
}
$ xlC aaa.cpp -c
$

对于即将发布的 16.1 版本(处于测试阶段),您不需要它。(无论有没有它都可以工作。)

于 2018-11-21T16:16:53.963 回答