硬浮动要求在GCC某些功能 [英] Hard float calls for some functions in GCC

查看:204
本文介绍了硬浮动要求在GCC某些功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个Android NDK的项目,但我猜它适用于GCC一般为ARM。

This is for an Android NDK project, but I'm guessing it applies to GCC in general for ARM.

我知道,在Android NDK使用柔软的浮动,以保持与ARMv5的兼容性,但它发生,我认为编译的ARMv7的库,我们的项目的时候,所有的调用内部的库可以使用硬浮动,并且只能使用柔软的持股量调用其他库,但我不知道,如果它甚至可以告诉编译器要做到这一点。我的感觉是,它不是,但我希望有人可能知道一个办法做到这一点。

I know that the Android NDK uses soft float to maintain compatibility with ARMv5, but it occurs to me that when compiling an ARMv7 library for our project, all calls internal to the library could use hard float, and only use soft float for calls to other libraries, but I'm not sure if it's even possible to tell the compiler to do this. My feeling is that it's not, but I'm hoping that someone might know a way to do it.

(作为附带说明 - 如果这是可能与锵在NDK或者锵只是做到这一点,它会是不错的就知道了)

(As a side note - if this is possible with Clang in the NDK or if Clang just does this, it'd be good to know)

一些背景:这是一个基于物理的图书馆正与NDK编译,所以沉重的使用浮点数的,我期待成为可能的优化

Some background: it's a physics based library being compiled with the NDK, so heavy on the use of floating point, and I'm looking into possible optimisations.

编辑:思考它,它只能确定一个函数是否是外部链接时,而硬/软浮动影响编译器,所以我猜测,如果这是可能的,我需要手动指定硬浮动应该使用这样的编译器会知道的功能。

thinking about it, it could only determine whether or not a function was external at link time, whereas hard/soft float affects the compiler, so I'm guessing that if this is possible, I'd need to manually specify the functions where hard float should be used so the compiler would know.

推荐答案

更新: NDK R9B增加了对图书馆建设与-mhard浮支持。请参见 NDK的页面

Update: NDK r9b added support for building libraries with -mhard-float. See the NDK page.

(原来的答复如下。)

有没有简单的方法来做到这一点。编译器需要知道每个方法是什么调用约定使用,而且也没有软FP属性。您可以编写(或生成)包装函数调用约定之间转换,但这是尴尬和愤怒的。

There's no easy way to do it. The compiler would need to know per-method what calling conventions to use, and there's no "soft fp" attribute. You could write (or generate) wrapper functions that convert between calling conventions, but that's awkward and annoying.

如果您有使用浮动,但不具有采取浮动作为参数的任何功能,并且不调用了外部函数,把浮动(如libc中的效用函数)库 - 本质上是一个黑色的盒子,似乎没有一个外部观察者使用浮动在所有 - 。那么你应该能够建立与硬FP

If you have a library that uses float, but doesn't have any functions that take float as arguments, and doesn't call out to external functions that take float (e.g. libc utility functions) -- essentially a black box that doesn't appear to an external viewer to use float at all -- then you should be able to build with "hard fp".

这篇关于硬浮动要求在GCC某些功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆