Recently, I was asked about software/hardware floating point support on i.MX6. There are some great articles on the freescale community already but lacks of introduction. This document shares some basic knowledge on it.
VFP is ARM's "Vector Floating Point" unit. SIMD operations can be better performed on several FPU extensions provided by ARM (NEON as in Cortex-A8 and Cortex-A9) [1]. To test if hardware floating support on freescale's toolchain, I used a simple application below:
$ cat haha.c
#include <stdio.h>;
int main()
{
float a = 0.3f, b=1.2f;
printf("%f\n", a * b);
return 0;
}
Compile it as below, and got the hardware floating point enabled.
$ arm-linux-gcc -march=armv7-a -mfpu=neon -mfloat-abi=hard -o haha haha.c
This can be checked by readelf. If Tag_ABI_VFP_args[2] shows VFP, it is hard floating. Otherwise, soft floating.
$ arm-linux-readelf -A haha
Attribute Section: aeabi
File Attributes
Tag_CPU_name: "7-A"
Tag_CPU_arch: v7
Tag_CPU_arch_profile: Application
Tag_ARM_ISA_use: Yes
Tag_THUMB_ISA_use: Thumb-2
Tag_FP_arch: VFPv3
Tag_ABI_PCS_wchar_t: 4
Tag_ABI_FP_denormal: Needed
Tag_ABI_FP_exceptions: Needed
Tag_ABI_FP_number_model: IEEE 754
Tag_ABI_align_needed: 8-byte
Tag_ABI_align_preserved: 8-byte, except leaf SP
Tag_ABI_enum_size: int
Tag_ABI_HardFP_use: SP and DP
Tag_ABI_VFP_args: VFP registers
Tag_DIV_use: Not allowed
Compared to the one by not specifying floating, compiler use soft floating by default,
$ arm-linux-gcc -o haha_soft haha.c
And readelf won't have Tag_ABI_VFP_args.
$ arm-linux-readelf -A haha_soft
Attribute Section: aeabi
File Attributes
Tag_CPU_name: "ARM10TDMI"
Tag_CPU_arch: v5T
Tag_ARM_ISA_use: Yes
Tag_THUMB_ISA_use: Thumb-1
Tag_ABI_PCS_wchar_t: 4
Tag_ABI_FP_denormal: Needed
Tag_ABI_FP_exceptions: Needed
Tag_ABI_FP_number_model: IEEE 754
Tag_ABI_align8_needed: Yes
Tag_ABI_align8_preserved: Yes, except leaf SP
Tag_ABI_enum_size: int
Tag_unknown_44: 1 (0x1)
[1]: https://wiki.debian.org/ArmHardFloatPort/VfpComparison
[2]: For more detail on the Tag expression, check http://infocenter.arm.com/help/topic/com.arm.doc.ihi0045d/IHI0045D_ABI_addenda.pdf