Difference between revisions of "GCC floating-point options"

From SEGGER Wiki
Jump to: navigation, search
m
m
 
Line 9: Line 9:
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
| soft || Full software floating-point. <br /> The compiler will not generate any FPU instructions and the ''-mfpu='' option is ignored. <br /> Function calls are generated by passing floating-point arguments in integer registers.
+
| soft || Full software floating-point. <br /> The compiler will not generate any FPU instructions and the ''-mfpu='' option is ignored. <br /> Function calls are generated by passing floating-point arguments in integer registers.
 
|-
 
|-
| softfp || Hardware floating-point using the soft floating-point ABI. <br /> The compiler will generate FPU instructions according to the ''-mfpu='' option. <br /> Function calls are generated by passing floating-point arguments in integer registers. <br /> This means ''soft'' and ''softfp'' can be intermixed.
+
| softfp || Hardware floating-point using the soft floating-point ABI. <br /> The compiler will generate FPU instructions according to the ''-mfpu='' option. <br /> Function calls are generated by passing floating-point arguments in integer registers. <br /> This means ''soft'' and ''softfp'' may be intermixed.
 
|-
 
|-
| hard || Full hardware floating point. <br /> The compiler will generate FPU instructions according to the ''-mfpu='' option. <br /> Function calls are generated by passing floating-point arguments in FPU registers.
+
| hard || Full hardware floating-point. <br /> The compiler will generate FPU instructions according to the ''-mfpu='' option. <br /> Function calls are generated by passing floating-point arguments in FPU registers. <br / > This means ''hard'' and ''softfp'' cannot be intermixed; neither can ''hard'' and ''soft''.
 
|}
 
|}
The hard-float and soft-float ABIs are not link-compatible: You must compile your entire program using the same ABI and link with a compatible set of libraries. <br /> The ''-mfloat-abi'' option is invalid with AArch64 targets, which always use hardware floating-point instructions and hardware floating-point linkage. <br /> ''-msoft-float'' is equivalent to ''-mfloat-abi=soft''. <br /> ''-mhard-float'' is equivalent to ''-mfloat-abi=hard''.
+
The ''-mfloat-abi='' option is invalid when compiling for AArch64 targets, for which the compiler will always generate FPU instructions and will always pass floating-point arguments in FPU registers. <br /> ''-msoft-float'' is equivalent to ''-mfloat-abi=soft''. <br /> ''-mhard-float'' is equivalent to ''-mfloat-abi=hard''.
 
|-
 
|-
 
| style="vertical-align: top;" | -mfpu=<value> <br /> ''(-mfp=<value>)'' <br /> ''(-mfpe=<value>)''
 
| style="vertical-align: top;" | -mfpu=<value> <br /> ''(-mfp=<value>)'' <br /> ''(-mfpe=<value>)''
Line 55: Line 55:
 
| colspan="2" | ''etc.''
 
| colspan="2" | ''etc.''
 
|}
 
|}
The ''-mfpu='' is ignored when ''-mfloat-abi=soft'' is specified or when compiling for AArch64 targets <br /> ''-mfp='' and ''-mfpe='' are synonyms for ''-mfpu=''.
+
The ''-mfpu='' option is ignored when ''-mfloat-abi=soft'' is specified, or when compiling for AArch64 targets <br /> ''-mfp='' and ''-mfpe='' are synonyms for ''-mfpu=''.
 
|}
 
|}
   

Latest revision as of 15:54, 30 March 2020

The GNU C Compiler produces binaries with several options in regards to floating-point operations:

Compiler flag Description
-mfloat-abi=<value>
(-mhard-float)
(-msoft-float)
Specifies which floating-point ABI to use. Permissible values are:
soft Full software floating-point.
The compiler will not generate any FPU instructions and the -mfpu= option is ignored.
Function calls are generated by passing floating-point arguments in integer registers.
softfp Hardware floating-point using the soft floating-point ABI.
The compiler will generate FPU instructions according to the -mfpu= option.
Function calls are generated by passing floating-point arguments in integer registers.
This means soft and softfp may be intermixed.
hard Full hardware floating-point.
The compiler will generate FPU instructions according to the -mfpu= option.
Function calls are generated by passing floating-point arguments in FPU registers.
This means hard and softfp cannot be intermixed; neither can hard and soft.

The -mfloat-abi= option is invalid when compiling for AArch64 targets, for which the compiler will always generate FPU instructions and will always pass floating-point arguments in FPU registers.
-msoft-float is equivalent to -mfloat-abi=soft.
-mhard-float is equivalent to -mfloat-abi=hard.

-mfpu=<value>
(-mfp=<value>)
(-mfpe=<value>)
Specifies the available floating-point hardware on the target. Permissible values include:
none Prevents the compiler from using hardware-based floating-point functions.
vfpv3 Enables the ARMv7 VFPv3 floating-point extension.
vfpv3-d16 Enables the ARMv7 VFPv3-D16 floating-point extension.
vfpv3-fp16 Enables the ARMv7 VFPv3 floating-point extension, including the optional half-precision extensions.
vfpv3-d16-fp16 Enables the ARMv7 VFPv3-D16 floating-point extension, including the optional half-precision extensions.
neon Enables the ARMv7 VFPv3 floating-point extension and the Advanced SIMD extension.
neon-fp16 Enables the ARMv7 VFPv3 floating-point extension, including the optional half-precision extensions, and the Advanced SIMD extension.
vfpv4 Enables the ARMv7 VFPv4 floating-point extension.
vfpv4-d16 Enables the ARMv7 VFPv4-D16 floating-point extension.
neon-vfpv4 Enables the ARMv7 VFPv4 floating-point extension and the Advanced SIMD extension.
fpv4-sp-d16 Enables the ARMv7 FPv4-SP-D16 floating-point extension.
fpv5-d16 Enables the ARMv7 FPv5-D16 floating-point extension.
fpv5-sp-d16 Enables the ARMv7 FPv5-SP-D16 floating-point extension.
fp-armv8 Enables the ARMv8 floating-point extension.
neon-fp-armv8 Enables the ARMv8 floating-point extension and the Advanced SIMD extensions.
crypto-neon-fp-armv8 Enables the ARMv8 floating-point extension, the cryptographic extension and the Advanced SIMD extension.
etc.

The -mfpu= option is ignored when -mfloat-abi=soft is specified, or when compiling for AArch64 targets
-mfp= and -mfpe= are synonyms for -mfpu=.

embOS for GCC typically is shipped with distinct sets of libraries for each floating-point ABI. While there is no immediate effect on embOS itself, this allows for compalibity with all applications and third-party libraries customers may utilize.