arch: arm: aarch32: Add half-precision floating-point configs
This commit adds the half-precision (16-bit) floating-point configurations to the ARM AArch32 architectures. Enabling CONFIG_FP16 has the effect of specifying `-mfp16-format` option (in case of GCC) which allows using the half-precision floating point types such as `__fp16` and `_Float16`. Note that this configuration can be used regardless of whether a hardware FPU is available or supports half-precision operations. When an FP16-capable FPU is not available, the compiler will automatically provide the software emulations. Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
This commit is contained in:
parent
74b9a607b4
commit
41fd6e003c
2 changed files with 41 additions and 0 deletions
|
@ -260,6 +260,37 @@ config FP_SOFTABI
|
|||
|
||||
endchoice
|
||||
|
||||
config FP16
|
||||
bool "Half-precision floating point support"
|
||||
default y
|
||||
help
|
||||
This option enables the half-precision (16-bit) floating point support
|
||||
via the `__fp16` (both IEEE and ARM alternative formats) and the
|
||||
`_Float16` (IEEE format only) types.
|
||||
|
||||
choice
|
||||
prompt "FP16 format"
|
||||
default FP16_IEEE
|
||||
depends on FP16
|
||||
|
||||
config FP16_IEEE
|
||||
bool "FP16 IEEE format"
|
||||
help
|
||||
This option selects the IEEE 754-2008 format for FP16. This format can
|
||||
represent normalized values in the range of 2^(-14) to 65504. There are
|
||||
11 bits of significand precision, approximately 3 decimal digits.
|
||||
|
||||
config FP16_ALT
|
||||
bool "FP16 ARM alternative format"
|
||||
help
|
||||
This option selects the ARM alternative format for FP16. This
|
||||
representation is similar to the IEEE 754-2008 format, but does not
|
||||
support infinites or NaNs. Instead, the range of exponents is extended,
|
||||
so that this format can represent normalized values in the range of
|
||||
2^(-14) to 131008.
|
||||
|
||||
endchoice
|
||||
|
||||
rsource "cortex_m/Kconfig"
|
||||
rsource "cortex_a_r/Kconfig"
|
||||
|
||||
|
|
|
@ -38,3 +38,13 @@ if(CONFIG_FPU)
|
|||
list(APPEND TOOLCHAIN_LD_FLAGS -mfloat-abi=hard)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CONFIG_FP16)
|
||||
if (CONFIG_FP16_IEEE)
|
||||
list(APPEND TOOLCHAIN_C_FLAGS -mfp16-format=ieee)
|
||||
list(APPEND TOOLCHAIN_LD_FLAGS -mfp16-format=ieee)
|
||||
elseif(CONFIG_FP16_ALT)
|
||||
list(APPEND TOOLCHAIN_C_FLAGS -mfp16-format=alternative)
|
||||
list(APPEND TOOLCHAIN_LD_FLAGS -mfp16-format=alternative)
|
||||
endif()
|
||||
endif()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue