为 arm-linux-gnueabi-g++ 的目标添加预取功能

Add prefetch capability to target of arm-linux-gnueabi-g++

以下代码行是在 Ubuntu 主机上使用 arm-linux-gnueabi-g++-4.7 交叉编译的。 prfm 指令应该为特定行生成,但它不是。

__builtin_prefetch(&some_variable,0,3); 

编译命令为:

arm-linux-gnueabi-g++-4.7 -O0 -S -std=c++11 main.cpp -D some_definition 
cat main.s | grep pr
//Returns null (main.s is all lower case)

这里引用 gcc reference 中与问题相关的一行:

If the target does not support data prefetch, the address expression is evaluated if it includes side effects but no other code is generated and GCC does not issue a warning.

最后一条信息是交叉编译器是使用apt-get install安装的,不是从头安装的。

问题来了:

如何简单地将数据预取支持添加到arm-linux-gnueabi-g++-4.7交叉编译器的目标?

提前致谢

正如@Notlikethat 所建议的那样,使用 -march=armv7-a 编译解决了这个问题。现在汇编输出中有一个pld指令。

$ arm-linux-gnueabi-g++-4.7 -g -O3 -std=c++11 -static -S -march=armv7-a main.cpp -D some_definition
$ cat main.s | grep pld
pld [r0, #0]