summaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
Diffstat (limited to 'py')
-rw-r--r--py/asmrv32.h8
-rw-r--r--py/modsys.c10
2 files changed, 13 insertions, 5 deletions
diff --git a/py/asmrv32.h b/py/asmrv32.h
index 4456e6119..6f709daa1 100644
--- a/py/asmrv32.h
+++ b/py/asmrv32.h
@@ -709,11 +709,11 @@ static inline void asm_rv32_opcode_xori(asm_rv32_t *state, mp_uint_t rd, mp_uint
asm_rv32_emit_word_opcode(state, RV32_ENCODE_TYPE_I(0x13, 0x04, rd, rs, immediate));
}
+#define MICROPY_RV32_EXTENSIONS \
+ (MICROPY_EMIT_RV32_ZBA ? RV32_EXT_ZBA : 0)
+
static inline uint8_t asm_rv32_allowed_extensions(void) {
- uint8_t extensions = 0;
- #if MICROPY_EMIT_RV32_ZBA
- extensions |= RV32_EXT_ZBA;
- #endif
+ uint8_t extensions = MICROPY_RV32_EXTENSIONS;
#if MICROPY_DYNAMIC_COMPILER
if (mp_dynamic_compiler.backend_options != NULL) {
extensions |= ((asm_rv32_backend_options_t *)mp_dynamic_compiler.backend_options)->allowed_extensions;
diff --git a/py/modsys.c b/py/modsys.c
index ef6273fc8..3dae92681 100644
--- a/py/modsys.c
+++ b/py/modsys.c
@@ -85,8 +85,16 @@ static const MP_DEFINE_STR_OBJ(mp_sys_implementation_machine_obj, MICROPY_BANNER
MP_ROM_PTR(&mp_sys_implementation_machine_obj)
#if MICROPY_PERSISTENT_CODE_LOAD
+// Note: Adding architecture flags to _mpy will break if the flags information
+// takes up more bits than what is available in a small-int value.
+#if MICROPY_EMIT_RV32
+#include "py/asmrv32.h"
+#define MPY_FILE_ARCH_FLAGS (MICROPY_RV32_EXTENSIONS << 16)
+#else
+#define MPY_FILE_ARCH_FLAGS (0)
+#endif
#define SYS_IMPLEMENTATION_ELEMS__MPY \
- , MP_ROM_INT(MPY_FILE_HEADER_INT)
+ , MP_ROM_INT(MPY_FILE_HEADER_INT | MPY_FILE_ARCH_FLAGS)
#else
#define SYS_IMPLEMENTATION_ELEMS__MPY
#endif