开发者

iPhone Thumb & VFP

How do 'compile for Thumb' and VFP code relate to each other?

on the iPhone 2G/3G, i know that the T开发者_运维百科humb instructionset doesn't include floatingpoint calculations (on the 3GS, Thumb2 aparently has..). So what happens, if one compiles for thumb, but uses VFP code for floatingpoint calculations?

i know that's pretty indepth - but probably someone here knows...c


I'm not sure what you mean by "use VFP code". Do you mean floating-point code, which may get compiled to run on VFP, or do you mean actual VFP assembly instructions?

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. 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.

If you try to use VFP assembly instructions in thumb mode, you'll just get an assembler error.

As you noted, the 3GS supports thumb2, which does have access to the VFP and NEON registers, so this situation doesn't apply.

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. If you want to write assembly code, you can switch between ARM and thumb per function.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜