Skip to content

Commit

Permalink
py/nlr.h: Factor out constants to specific macros.
Browse files Browse the repository at this point in the history
  • Loading branch information
dpgeorge committed Sep 26, 2019
1 parent 02db91a commit a48cdb5
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions py/nlr.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@

#include "py/mpconfig.h"

#define MICROPY_NLR_NUM_REGS_X86 (6)
#define MICROPY_NLR_NUM_REGS_X64 (8)
#define MICROPY_NLR_NUM_REGS_X64_WIN (10)
#define MICROPY_NLR_NUM_REGS_ARM_THUMB (10)
#define MICROPY_NLR_NUM_REGS_ARM_THUMB_FP (10 + 6)
#define MICROPY_NLR_NUM_REGS_XTENSA (10)

// If MICROPY_NLR_SETJMP is not enabled then auto-detect the machine arch
#if !MICROPY_NLR_SETJMP
// A lot of nlr-related things need different treatment on Windows
Expand All @@ -44,27 +51,27 @@
#endif
#if defined(__i386__)
#define MICROPY_NLR_X86 (1)
#define MICROPY_NLR_NUM_REGS (6)
#define MICROPY_NLR_NUM_REGS (MICROPY_NLR_NUM_REGS_X86)
#elif defined(__x86_64__)
#define MICROPY_NLR_X64 (1)
#if MICROPY_NLR_OS_WINDOWS
#define MICROPY_NLR_NUM_REGS (10)
#define MICROPY_NLR_NUM_REGS (MICROPY_NLR_NUM_REGS_X64_WIN)
#else
#define MICROPY_NLR_NUM_REGS (8)
#define MICROPY_NLR_NUM_REGS (MICROPY_NLR_NUM_REGS_X64)
#endif
#elif defined(__thumb2__) || defined(__thumb__) || defined(__arm__)
#define MICROPY_NLR_THUMB (1)
#if defined(__SOFTFP__)
#define MICROPY_NLR_NUM_REGS (10)
#define MICROPY_NLR_NUM_REGS (MICROPY_NLR_NUM_REGS_ARM_THUMB)
#else
// With hardware FP registers s16-s31 are callee save so in principle
// should be saved and restored by the NLR code. gcc only uses s16-s21
// so only save/restore those as an optimisation.
#define MICROPY_NLR_NUM_REGS (10 + 6)
#define MICROPY_NLR_NUM_REGS (MICROPY_NLR_NUM_REGS_ARM_THUMB_FP)
#endif
#elif defined(__xtensa__)
#define MICROPY_NLR_XTENSA (1)
#define MICROPY_NLR_NUM_REGS (10)
#define MICROPY_NLR_NUM_REGS (MICROPY_NLR_NUM_REGS_XTENSA)
#else
#define MICROPY_NLR_SETJMP (1)
//#warning "No native NLR support for this arch, using setjmp implementation"
Expand Down

0 comments on commit a48cdb5

Please sign in to comment.