Preventing the use of floating-point instructions and registers
You can instruct the compiler to prevent the use of floating-point instructions and floating-point registers.
Floating-point computations and linkage
Floating-point computations can be performed by:
- Floating-point instructions, executed by a hardware coprocessor. The resulting code can only be run on processors with Vector Floating Point (VFP) coprocessor hardware.
- Software library functions, through the floating-point library
fplib. This library provides functions that can be called to implement floating-point operations using no additional hardware.
Code that uses hardware floating-point instructions is more compact and offers better performance than code that performs floating-point arithmetic in software. However, hardware floating-point instructions require a VFP coprocessor.
Floating-point linkage controls which registers are used to pass floating-point parameters and return values:
- Software floating-point linkage means that the parameters and return values
for functions are passed using the AArch32 integer registers r0 to r3 and the
stack. The benefits of using software floating-point linkage include:
- Code can run on a processor with or without a VFP coprocessor.
- Code can link against libraries compiled for software floating-point linkage.
- Hardware floating-point linkage uses the VFP coprocessor registers to pass the arguments and return value. The benefit of using hardware floating-point linkage is that it is more efficient than software floating-point linkage, but you must have a VFP coprocessor
Configuring the use of floating-point instructions and registers
When compiling for AArch64 state:
- By default, the compiler uses hardware floating-point instructions and hardware floating-point linkage.
-mcpu=option to prevent the use of both floating-point instructions and floating-point registers:
armclang --target=aarch64-arm-none-eabi -mcpu=cortex-a53+nofp+nosimd test.c
Subsequent use of floating-point data types in this mode is unsupported.
When compiling for AArch32 state:
- When using
--target=arm-arm-none-eabi, the compiler uses hardware floating-point instructions and software floating-point linkage. This corresponds to the option
-mfloat-abi=softoption to use software library functions for floating-point operations and software floating-point linkage:
armclang --target=arm-arm-none-eabi -march=armv8-a -mfloat-abi=soft test.c
-mfloat-abi=hardoption to use hardware floating-point instructions and hardware floating-point linkage:
armclang --target=arm-arm-none-eabi -march=armv8-a -mfloat-abi=hard test.c