| |||
Home > Producing
Code to Run on a VFP System > Use of --fpu option | |||
The following guidelines can be used to help you select the most suitable floating-point build options to use for your application.
If all of your floating-point processing is done in ARM state code and none is done in Thumb state code then:
Build your ARM code with ‑‑fpu
vfpv2 (if you are using VFP9-S, VFP10 rev1 or VFP11) or
with ‑‑fpu vfpv1 (to RVDS 2.1 only) if you are
using VFP10 rev 0.
Build your Thumb code with ‑‑fpu none.
This ensures that no floating-point operations take place in Thumb
code.
If your application will be carrying out floating-point operations in both Thumb and ARM state code, then there are a number of choices as to which options you should use.
Compiling a file using the --fpu
vfpv2 switch will generate ARM code for functions that contain
floating-point operations regardless of whether the file is being
compiled for ARM or Thumb. This is because Thumb code cannot contain
VFP instructions or access VFP registers. If the file is being compiled
for Thumb any functions within the file that do not use floating-point
will be compiled as Thumb code.
Compiling a file using the --fpu softvfp+vfpv2 switch
means that all functions are compiled to use software floating-point
linkage. This means that floating-point arguments are passed to
(and returned from) functions in integer registers. Thumb code functions
that contain floating-point operations are compiled as Thumb (unlike ‑‑fpu
vfpv2) but will call library functions to carry out the
floating-point operations in ARM code.
The choice of options that provides the best code size/performance
depends upon the code being compiled. For example there is a trade-off
between compiling --fpu softvfp+vfpv2 (as opposed to --fpu
vfpv2) to obtain Thumb code and the corresponding inclusion
of library code. It is best to experiment with different options
to find the combination which provides the required code size/performance
attributes.
If software floating-point linkage is being used both the
calling function and the called function must either be compiled
using --fpu softvfp+vfpv2 or declared using the __softfp keyword.
The __softfp keyword allows software floating-point
linkage to be specified on a function by function basis rather than
across the whole file as is the case with --fpu softvfp+vfpv2.
See the description of __softfp in the RVDS Compilers and Libraries Guide for more information.
VFP is directly accessible from both the ARM and Thumb-2 instruction
set on ARMv7 processors with VFPv3 such as Cortex-A8. This allows
you to use Thumb-2 for your entire program, without needing to switch
to ARM state to perform VFP operations. To do this, build your
code with thumb ‑‑fpu vfpv3. Alternatively,
you can build your code for ARM only with arm ‑‑fpu vfpv3.
To build code that is compatible with other code that specifies
software floating-point linkage, use ‑‑fpu softvfp+vfpv3 instead
of ‑‑fpu vfpv3.