[fpu] have the arch layers set WITH_NO_FPU based on the cpu

This will generally turn off more FPU codegen, even if its using
software fallback unless the project/target/platform selects a cpu that
has FPU support. This also turns off a few blocks of test code and the
upcoming floating point printf if it's not present on the arch.

This may break projects that were compiling for say cortex-m0 but
expected FPU code to be present. If so it should be pretty easy to
override it, but not going to add that yet unless it's necessary.
This commit is contained in:
Travis Geiselbrecht
2025-10-08 23:41:13 -07:00
parent 85e35e1426
commit 5016118509
6 changed files with 35 additions and 23 deletions

View File

@@ -5,7 +5,7 @@
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT
*/
#if ARM_WITH_VFP || ARCH_ARM64 || X86_WITH_FPU || (ARCH_RISCV && RISCV_FPU)
#if !WITH_NO_FP
#include <stdio.h>
#include <inttypes.h>
@@ -20,11 +20,6 @@
#include <kernel/event.h>
#include <platform.h>
extern void float_vfp_arm_instruction_test(void);
extern void float_vfp_thumb_instruction_test(void);
extern void float_neon_arm_instruction_test(void);
extern void float_neon_thumb_instruction_test(void);
#if ARM_WITH_VFP_SP_ONLY
#define FLOAT float
#else
@@ -57,6 +52,11 @@ static int float_thread(void *arg) {
}
#if ARCH_ARM && !ARM_ISA_ARMV7M
extern void float_vfp_arm_instruction_test(void);
extern void float_vfp_thumb_instruction_test(void);
extern void float_neon_arm_instruction_test(void);
extern void float_neon_thumb_instruction_test(void);
static void arm_float_instruction_trap_test(void) {
printf("testing fpu trap\n");
@@ -152,4 +152,4 @@ STATIC_COMMAND_START
STATIC_COMMAND("float_tests", "floating point test", &float_tests)
STATIC_COMMAND_END(float_tests);
#endif // ARM_WITH_VFP || ARCH_ARM64
#endif // !WITH_NO_FP

View File

@@ -18,7 +18,8 @@ GLOBAL_DEFINES += \
ARM_CPU_CORTEX_M0=1 \
ARM_ISA_ARMV6M=1 \
ARM_WITH_THUMB=1 \
USE_BUILTIN_ATOMICS=0
USE_BUILTIN_ATOMICS=0 \
WITH_NO_FP=1
HANDLED_CORE := true
ENABLE_THUMB := true
SUBARCH := arm-m
@@ -28,7 +29,8 @@ GLOBAL_DEFINES += \
ARM_CPU_CORTEX_M0_PLUS=1 \
ARM_ISA_ARMV6M=1 \
ARM_WITH_THUMB=1 \
USE_BUILTIN_ATOMICS=0
USE_BUILTIN_ATOMICS=0 \
WITH_NO_FP=1
HANDLED_CORE := true
ENABLE_THUMB := true
SUBARCH := arm-m
@@ -39,7 +41,8 @@ GLOBAL_DEFINES += \
ARM_ISA_ARMv7=1 \
ARM_ISA_ARMv7M=1 \
ARM_WITH_THUMB=1 \
ARM_WITH_THUMB2=1
ARM_WITH_THUMB2=1 \
WITH_NO_FP=1
HANDLED_CORE := true
ENABLE_THUMB := true
SUBARCH := arm-m
@@ -50,7 +53,8 @@ GLOBAL_DEFINES += \
ARM_ISA_ARMv7=1 \
ARM_ISA_ARMv7M=1 \
ARM_WITH_THUMB=1 \
ARM_WITH_THUMB2=1
ARM_WITH_THUMB2=1 \
WITH_NO_FP=1
HANDLED_CORE := true
ENABLE_THUMB := true
SUBARCH := arm-m
@@ -76,7 +80,8 @@ GLOBAL_DEFINES += \
ARM_ISA_ARMv7M=1 \
ARM_WITH_THUMB=1 \
ARM_WITH_THUMB2=1 \
ARM_WITH_CACHE=1
ARM_WITH_CACHE=1 \
WITH_NO_FP=1
HANDLED_CORE := true
ENABLE_THUMB := true
SUBARCH := arm-m
@@ -102,7 +107,8 @@ GLOBAL_DEFINES += \
ARM_WITH_THUMB2=1 \
ARM_WITH_CACHE=1 \
ARM_WITH_VFP=1 \
ARM_WITH_VFP_SP_ONLY=1
ARM_WITH_VFP_SP_ONLY=1 \
WITH_NO_FP=1
HANDLED_CORE := true
ENABLE_THUMB := true
SUBARCH := arm-m
@@ -135,6 +141,8 @@ ifneq ($(ARM_WITHOUT_VFP_NEON),true)
GLOBAL_DEFINES += \
ARM_WITH_VFP=1 \
ARM_WITH_NEON=1
else
GLOBAL_DEFINES += WITH_NO_FP=1
endif
HANDLED_CORE := true
endif
@@ -160,7 +168,8 @@ GLOBAL_DEFINES += \
ARM_ISA_ARMv7A=1 \
ARM_WITH_THUMB=1 \
ARM_WITH_THUMB2=1 \
ARM_WITH_CACHE=1
ARM_WITH_CACHE=1 \
WITH_NO_FP=1
HANDLED_CORE := true
endif
ifeq ($(ARM_CPU),cortex-a9-neon)
@@ -184,7 +193,8 @@ GLOBAL_DEFINES += \
ARM_ISA_ARMv6=1 \
ARM_WITH_THUMB=1 \
ARM_WITH_CACHE=1 \
ARM_CPU_ARM1136=1
ARM_CPU_ARM1136=1 \
WITH_NO_FP=1
HANDLED_CORE := true
endif
ifeq ($(ARM_CPU),arm1176jzf-s)
@@ -204,8 +214,8 @@ GLOBAL_DEFINES += \
ARM_ISA_ARMv7=1 \
ARM_WITH_VFP=1 \
ARM_WITH_THUMB=1
ENABLE_THUMB := true
HANDLED_CORE := true
ENABLE_THUMB := true
HANDLED_CORE := true
endif
ifeq ($(ARM_CPU),armemu)
# flavor of emulated cpu by the armemu project
@@ -213,7 +223,8 @@ GLOBAL_DEFINES += \
ARM_WITH_CP15=1 \
ARM_ISA_ARMv7=1 \
ARM_ISA_ARMv7A=1 \
ARM_WITH_CACHE=1
ARM_WITH_CACHE=1 \
WITH_NO_FP=1
HANDLED_CORE := true
ENABLE_THUMB := false # armemu doesn't currently support thumb properly
endif

View File

@@ -21,10 +21,13 @@ M68K_CPU ?= 68040 # default to 040
ifeq ($(M68K_CPU),68000)
ARCH_COMPILEFLAGS := -mcpu=68000
GLOBAL_DEFINES += WITH_NO_FP=1
else ifeq ($(M68K_CPU),68010)
ARCH_COMPILEFLAGS := -mcpu=68010
GLOBAL_DEFINES += WITH_NO_FP=1
else ifeq ($(M68K_CPU),68020)
ARCH_COMPILEFLAGS := -mcpu=68020
GLOBAL_DEFINES += WITH_NO_FP=1
else ifeq ($(M68K_CPU),68030)
ARCH_COMPILEFLAGS := -mcpu=68030
else ifeq ($(M68K_CPU),68040)

View File

@@ -135,6 +135,8 @@ endif
ifeq (true,$(call TOBOOL,$(RISCV_FPU)))
GLOBAL_DEFINES += RISCV_FPU=1
else
GLOBAL_DEFINES += WITH_NO_FP=1
endif
# based on a list of optional extensions passed in, collapse the extensions into

View File

@@ -23,8 +23,7 @@ MODULE_DEPS += \
arch/arm/arm-m/systick \
platform/cc13xx/cc13xxware
GLOBAL_COMPILEFLAGS += -DWITH_NO_FP=1
#GLOBAL_COMPILEFLAGS += -DDISABLE_DEBUG_OUTPUT=1
#GLOBAL_DEFINES += DISABLE_DEBUG_OUTPUT=1
include make/module.mk

View File

@@ -1,9 +1,6 @@
MODULES += \
app/lpcboot
GLOBAL_DEFINES += \
WITH_NO_FP=1
# WITH_NO_CLOCK_INIT=1
TARGET := lpclink2