mpy-cross: Set number of registers in nlr_buf_t based on native arch.
Fixes #5059. Done in collaboration with Jim Mussared.
This commit is contained in:
parent
74503107a7
commit
b596638b9b
@ -209,12 +209,16 @@ MP_NOINLINE int main_(int argc, char **argv) {
|
||||
mp_dynamic_compiler.py_builtins_str_unicode = 1;
|
||||
#if defined(__i386__)
|
||||
mp_dynamic_compiler.native_arch = MP_NATIVE_ARCH_X86;
|
||||
mp_dynamic_compiler.nlr_buf_num_regs = MICROPY_NLR_NUM_REGS_X86;
|
||||
#elif defined(__x86_64__)
|
||||
mp_dynamic_compiler.native_arch = MP_NATIVE_ARCH_X64;
|
||||
mp_dynamic_compiler.nlr_buf_num_regs = MAX(MICROPY_NLR_NUM_REGS_X64, MICROPY_NLR_NUM_REGS_X64_WIN);
|
||||
#elif defined(__arm__) && !defined(__thumb2__)
|
||||
mp_dynamic_compiler.native_arch = MP_NATIVE_ARCH_ARMV6;
|
||||
mp_dynamic_compiler.nlr_buf_num_regs = MICROPY_NLR_NUM_REGS_ARM_THUMB_FP;
|
||||
#else
|
||||
mp_dynamic_compiler.native_arch = MP_NATIVE_ARCH_NONE;
|
||||
mp_dynamic_compiler.nlr_buf_num_regs = 0;
|
||||
#endif
|
||||
|
||||
const char *input_file = NULL;
|
||||
@ -271,14 +275,19 @@ MP_NOINLINE int main_(int argc, char **argv) {
|
||||
const char *arch = argv[a] + sizeof("-march=") - 1;
|
||||
if (strcmp(arch, "x86") == 0) {
|
||||
mp_dynamic_compiler.native_arch = MP_NATIVE_ARCH_X86;
|
||||
mp_dynamic_compiler.nlr_buf_num_regs = MICROPY_NLR_NUM_REGS_X86;
|
||||
} else if (strcmp(arch, "x64") == 0) {
|
||||
mp_dynamic_compiler.native_arch = MP_NATIVE_ARCH_X64;
|
||||
mp_dynamic_compiler.nlr_buf_num_regs = MAX(MICROPY_NLR_NUM_REGS_X64, MICROPY_NLR_NUM_REGS_X64_WIN);
|
||||
} else if (strcmp(arch, "armv6") == 0) {
|
||||
mp_dynamic_compiler.native_arch = MP_NATIVE_ARCH_ARMV6;
|
||||
mp_dynamic_compiler.nlr_buf_num_regs = MICROPY_NLR_NUM_REGS_ARM_THUMB_FP;
|
||||
} else if (strcmp(arch, "armv7m") == 0) {
|
||||
mp_dynamic_compiler.native_arch = MP_NATIVE_ARCH_ARMV7M;
|
||||
mp_dynamic_compiler.nlr_buf_num_regs = MICROPY_NLR_NUM_REGS_ARM_THUMB_FP;
|
||||
} else if (strcmp(arch, "xtensa") == 0) {
|
||||
mp_dynamic_compiler.native_arch = MP_NATIVE_ARCH_XTENSA;
|
||||
mp_dynamic_compiler.nlr_buf_num_regs = MICROPY_NLR_NUM_REGS_XTENSA;
|
||||
} else {
|
||||
return usage(argv);
|
||||
}
|
||||
|
@ -81,7 +81,11 @@
|
||||
// (L0-L2 may be in regs instead)
|
||||
|
||||
// Native emitter needs to know the following sizes and offsets of C structs (on the target):
|
||||
#if MICROPY_DYNAMIC_COMPILER
|
||||
#define SIZEOF_NLR_BUF (2 + mp_dynamic_compiler.nlr_buf_num_regs + 1) // the +1 is conservative in case MICROPY_ENABLE_PYSTACK enabled
|
||||
#else
|
||||
#define SIZEOF_NLR_BUF (sizeof(nlr_buf_t) / sizeof(uintptr_t))
|
||||
#endif
|
||||
#define SIZEOF_CODE_STATE (sizeof(mp_code_state_t) / sizeof(uintptr_t))
|
||||
#define OFFSETOF_CODE_STATE_STATE (offsetof(mp_code_state_t, state) / sizeof(uintptr_t))
|
||||
#define OFFSETOF_CODE_STATE_FUN_BC (offsetof(mp_code_state_t, fun_bc) / sizeof(uintptr_t))
|
||||
|
@ -47,6 +47,7 @@ typedef struct mp_dynamic_compiler_t {
|
||||
bool opt_cache_map_lookup_in_bytecode;
|
||||
bool py_builtins_str_unicode;
|
||||
uint8_t native_arch;
|
||||
uint8_t nlr_buf_num_regs;
|
||||
} mp_dynamic_compiler_t;
|
||||
extern mp_dynamic_compiler_t mp_dynamic_compiler;
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user