From a48cdb57b29d1942b9949ad518d4348d1db7cdbd Mon Sep 17 00:00:00 2001
From: Damien George <damien.p.george@gmail.com>
Date: Wed, 18 Sep 2019 13:39:01 +1000
Subject: [PATCH] py/nlr.h: Factor out constants to specific macros.

---
 py/nlr.h | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/py/nlr.h b/py/nlr.h
index 8ce5cf0f4c..3e4b31d92b 100644
--- a/py/nlr.h
+++ b/py/nlr.h
@@ -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
@@ -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"