Merge pull request #2380 from tannewt/gcc9_fixes_from_mp

Incorporate GCC9 fixes from upstream
This commit is contained in:
Dan Halbert 2019-12-12 14:46:52 -05:00 committed by GitHub
commit f1404638f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 31 additions and 9 deletions

View File

@ -1440,6 +1440,15 @@ typedef double mp_float_t;
#define MP_UNLIKELY(x) __builtin_expect((x), 0)
#endif
// To annotate that code is unreachable
#ifndef MP_UNREACHABLE
#if defined(__GNUC__)
#define MP_UNREACHABLE __builtin_unreachable();
#else
#define MP_UNREACHABLE for (;;);
#endif
#endif
#ifndef MP_HTOBE16
#if MP_ENDIANNESS_LITTLE
# define MP_HTOBE16(x) ((uint16_t)( (((x) & 0xff) << 8) | (((x) >> 8) & 0xff) ))

View File

@ -54,7 +54,14 @@
#endif
#elif defined(__thumb2__) || defined(__thumb__) || defined(__arm__)
#define MICROPY_NLR_THUMB (1)
#define MICROPY_NLR_NUM_REGS (10)
#if defined(__SOFTFP__)
#define MICROPY_NLR_NUM_REGS (10)
#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)
#endif
#elif defined(__xtensa__)
#define MICROPY_NLR_XTENSA (1)
#define MICROPY_NLR_NUM_REGS (10)

View File

@ -63,6 +63,11 @@ __attribute__((naked)) unsigned int nlr_push(nlr_buf_t *nlr) {
"str r10, [r0, #36] \n" // store r10 into nlr_buf
"str r11, [r0, #40] \n" // store r11 into nlr_buf
"str r13, [r0, #44] \n" // store r13=sp into nlr_buf
#if MICROPY_NLR_NUM_REGS == 16
"vstr d8, [r0, #48] \n" // store s16-s17 into nlr_buf
"vstr d9, [r0, #56] \n" // store s18-s19 into nlr_buf
"vstr d10, [r0, #64] \n" // store s20-s21 into nlr_buf
#endif
"str lr, [r0, #8] \n" // store lr into nlr_buf
#endif
@ -118,6 +123,11 @@ NORETURN void nlr_jump(void *val) {
"ldr r10, [r0, #36] \n" // load r10 from nlr_buf
"ldr r11, [r0, #40] \n" // load r11 from nlr_buf
"ldr r13, [r0, #44] \n" // load r13=sp from nlr_buf
#if MICROPY_NLR_NUM_REGS == 16
"vldr d8, [r0, #48] \n" // load s16-s17 from nlr_buf
"vldr d9, [r0, #56] \n" // load s18-s19 from nlr_buf
"vldr d10, [r0, #64] \n" // load s20-s21 from nlr_buf
#endif
"ldr lr, [r0, #8] \n" // load lr from nlr_buf
#endif
"movs r0, #1 \n" // return 1, non-local return
@ -127,11 +137,7 @@ NORETURN void nlr_jump(void *val) {
: // clobbered registers
);
#if defined(__GNUC__)
__builtin_unreachable();
#else
for (;;); // needed to silence compiler warning
#endif
MP_UNREACHABLE
}
#endif // MICROPY_NLR_THUMB

View File

@ -108,7 +108,7 @@ NORETURN void nlr_jump(void *val) {
: // clobbered registers
);
for (;;); // needed to silence compiler warning
MP_UNREACHABLE
}
#endif // MICROPY_NLR_X64

View File

@ -100,7 +100,7 @@ NORETURN void nlr_jump(void *val) {
: // clobbered registers
);
for (;;); // needed to silence compiler warning
MP_UNREACHABLE
}
#endif // MICROPY_NLR_X86

View File

@ -77,7 +77,7 @@ NORETURN void nlr_jump(void *val) {
: // clobbered registers
);
for (;;); // needed to silence compiler warning
MP_UNREACHABLE
}
#endif // MICROPY_NLR_XTENSA