简体   繁体   English

iPhone Thumb和VFP

[英]iPhone Thumb & VFP

How do 'compile for Thumb' and VFP code relate to each other? “为Thumb编译”和VFP代码如何相互关联?

on the iPhone 2G/3G, i know that the Thumb instructionset doesn't include floatingpoint calculations (on the 3GS, Thumb2 aparently has..). 在iPhone 2G / 3G上,我知道Thumb指令集不包含浮点计算(在3GS上,Thumb2显然具有..)。 So what happens, if one compiles for thumb, but uses VFP code for floatingpoint calculations? 那么,如果有人为拇指编译而使用VFP代码进行浮点计算会发生什么呢?

i know that's pretty indepth - but probably someone here knows...c 我知道这很深入-但也许这里有人知道... c

I'm not sure what you mean by "use VFP code". 我不确定“使用VFP代码”是什么意思。 Do you mean floating-point code, which may get compiled to run on VFP, or do you mean actual VFP assembly instructions? 您是指浮点代码,可以将其编译为在VFP上运行,还是您是指实际的VFP汇编指令?

If you compile in thumb mode and use floating point, a function call will be made for each floating point operation in your code. 如果以拇指模式编译并使用浮点,则将对代码中的每个浮点操作进行函数调用。 These function calls (they'll have names like __muldf3vfp ) switch the mode to ARM, move the data into the floating point registers, perform the operation, move the data back to integer registers, and return. 这些函数调用(它们的名称类似于__muldf3vfp )将模式切换到ARM,将数据移至浮点寄存器,执行操作,将数据移回整数寄存器,然后返回。 That's a lot of work for something that's only one instruction if you compile in ARM mode, so don't use thumb in float-intensive code. 如果您在ARM模式下进行编译,那么对于只有一条指令的某些事情来说,这是很多工作,因此不要在浮点型代码中使用thumb。

If you try to use VFP assembly instructions in thumb mode, you'll just get an assembler error. 如果尝试在拇指模式下使用VFP汇编指令,则只会出现汇编错误。

As you noted, the 3GS supports thumb2, which does have access to the VFP and NEON registers, so this situation doesn't apply. 正如你提到的,3GS支持的Thumb2,里面确实有访问VFP和NEON寄存器,所以这种情况并不适用。

Also note that the switch between thumb and ARM compilation can be done per source file, so you can compile most of your project in thumb and use ARM for a few routines that do a lot of floating-point, for example. 还要注意,可以在每个源文件之间进行thumb和ARM编译之间的切换,因此您可以使用thumb编译大多数项目,并将ARM用于一些执行大量浮点运算的例程。 If you want to write assembly code, you can switch between ARM and thumb per function. 如果要编写汇编代码,则可以按功能在ARM和Thumb之间切换。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM