From b51e7e9d01a696cdfefada2e374db51752d1b803 Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Thu, 19 Aug 2021 17:49:33 +1000 Subject: [PATCH] stm32: Disable computed goto on constrained boards. Saves ~1kiB. Add comment to this effect to mpconfig.h. Signed-off-by: Jim Mussared --- ports/stm32/boards/B_L072Z_LRWAN1/mpconfigboard.h | 1 + ports/stm32/boards/NUCLEO_F091RC/mpconfigboard.h | 1 + ports/stm32/boards/NUCLEO_L073RZ/mpconfigboard.h | 1 + ports/stm32/mpconfigport.h | 2 ++ py/mpconfig.h | 3 ++- 5 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ports/stm32/boards/B_L072Z_LRWAN1/mpconfigboard.h b/ports/stm32/boards/B_L072Z_LRWAN1/mpconfigboard.h index 08ded0e03e..dfcca72afb 100644 --- a/ports/stm32/boards/B_L072Z_LRWAN1/mpconfigboard.h +++ b/ports/stm32/boards/B_L072Z_LRWAN1/mpconfigboard.h @@ -7,6 +7,7 @@ #define MICROPY_EMIT_THUMB (0) #define MICROPY_EMIT_INLINE_THUMB (0) +#define MICROPY_OPT_COMPUTED_GOTO (0) #define MICROPY_PY_BUILTINS_COMPLEX (0) #define MICROPY_PY_GENERATOR_PEND_THROW (0) #define MICROPY_PY_MATH (0) diff --git a/ports/stm32/boards/NUCLEO_F091RC/mpconfigboard.h b/ports/stm32/boards/NUCLEO_F091RC/mpconfigboard.h index 7333dcd0c1..a0bff59961 100644 --- a/ports/stm32/boards/NUCLEO_F091RC/mpconfigboard.h +++ b/ports/stm32/boards/NUCLEO_F091RC/mpconfigboard.h @@ -3,6 +3,7 @@ #define MICROPY_EMIT_THUMB (0) #define MICROPY_EMIT_INLINE_THUMB (0) +#define MICROPY_OPT_COMPUTED_GOTO (0) #define MICROPY_PY_USOCKET (0) #define MICROPY_PY_NETWORK (0) #define MICROPY_PY_STM (0) diff --git a/ports/stm32/boards/NUCLEO_L073RZ/mpconfigboard.h b/ports/stm32/boards/NUCLEO_L073RZ/mpconfigboard.h index 331fc95cae..c8c809eb48 100644 --- a/ports/stm32/boards/NUCLEO_L073RZ/mpconfigboard.h +++ b/ports/stm32/boards/NUCLEO_L073RZ/mpconfigboard.h @@ -7,6 +7,7 @@ #define MICROPY_EMIT_THUMB (0) #define MICROPY_EMIT_INLINE_THUMB (0) +#define MICROPY_OPT_COMPUTED_GOTO (0) #define MICROPY_PY_BUILTINS_COMPLEX (0) #define MICROPY_PY_GENERATOR_PEND_THROW (0) #define MICROPY_PY_MATH (0) diff --git a/ports/stm32/mpconfigport.h b/ports/stm32/mpconfigport.h index fc84171b2e..6f97377d9b 100644 --- a/ports/stm32/mpconfigport.h +++ b/ports/stm32/mpconfigport.h @@ -56,7 +56,9 @@ #define MICROPY_COMP_RETURN_IF_EXPR (1) // optimisations +#ifndef MICROPY_OPT_COMPUTED_GOTO #define MICROPY_OPT_COMPUTED_GOTO (1) +#endif #define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE (0) #define MICROPY_OPT_MPZ_BITWISE (1) #define MICROPY_OPT_MATH_FACTORIAL (1) diff --git a/py/mpconfig.h b/py/mpconfig.h index 2e83c90c55..db2aec3bf4 100644 --- a/py/mpconfig.h +++ b/py/mpconfig.h @@ -483,7 +483,8 @@ /* Optimisations */ // Whether to use computed gotos in the VM, or a switch -// Computed gotos are roughly 10% faster, and increase VM code size by a little +// Computed gotos are roughly 10% faster, and increase VM code size by a little, +// e.g. ~1kiB on Cortex M4. // Note: enabling this will use the gcc-specific extensions of ranged designated // initialisers and addresses of labels, which are not part of the C99 standard. #ifndef MICROPY_OPT_COMPUTED_GOTO