Controls floating-point code generation.
-fp keyword
The choices for keyword are:
none | off
No floating point code generation.
soft[ware]
Use software libraries to perform floating-point operations. This is the default.
hard[ware]
Use the processor's built-in floating-point capabilities to perform floating-point operations.
dpfp
Use the processor's double-precision floating-point capabilities on the e500v2 processor.
spfp
Use software libraries for floating-point operations that use the double data type and use the e500 SPE-EFPU floating-point capabilities for other floating-point operations.
spfp_only
Use to have the compiler consider double and long double data types as floating point. This option is only supported for e200 (Zen or VLE) and e500v1 processors that support SPFP APU.
fmadd
Equivalent to -fp hard -fp_contract.
When using the -fp spfp_only option, the size of a double data type changes to a floating point data type, if you have existing code that is expecting to find certain bits at certain locations of the exponent or significand, then you will have to change that code to expect 4 byte doubles. Your code can make a test as shown in Example Test Code .
if (sizeof(double) == 4) { ... } else { ... }
The e500 and VLE library project files have targets and pre-built libraries (with SP in the name) that support this feature. Ensure you pick the right libraries to include in a project that supports this feature else you may call a function with a 8 byte double parameter and only pass a 4 byte double argument. The linker will report with a warning if you mix up the libraries - make sure you have linker warnings enabled.
If you have a library that doesn't use floating point, try setting it to none for the floating point model by using the -fp none option. Libaries with none floating point do not cause a warning when added to projects using another floating point model.
The sample code in Sample Code assumes that you are using the -fp spfp_only option and have included SP libraries. Your existing code makes a call to a MSL math function and a user defined function that takes a double argument and returns a double data type.
#include <math.h> extern double my_func(double); extern double d1, d2; void main() { d1 = pow(d2, 2.0); d2 = my_func(d1); }
Following can be observed while executing the sample code in Sample Code :