summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Halbert <halbert@adafruit.com>2019-11-08 13:42:17 -0500
committerGitHub <noreply@github.com>2019-11-08 13:42:17 -0500
commit91156670e9635c9e27a8dcf4d68c757f7b6df38f (patch)
tree4e67e97df370db327d1b4511fa08ef862b279b74
parent147a1bb8603dcfd54d794b6f2d28273c9e227e85 (diff)
parent3439c3619753955b6368fc91acec3e14c76c6dd3 (diff)
Merge pull request #2271 from theacodes/enable-micropython-native
Allow boards to enable the `micropython.native` decorator
-rw-r--r--ports/atmel-samd/boards/winterbloom_sol/mpconfigboard.mk3
-rw-r--r--py/circuitpy_mpconfig.h4
-rw-r--r--py/circuitpy_mpconfig.mk7
-rw-r--r--py/compile.c2
-rw-r--r--py/emitnative.c18
-rw-r--r--py/objfun.c2
6 files changed, 32 insertions, 4 deletions
diff --git a/ports/atmel-samd/boards/winterbloom_sol/mpconfigboard.mk b/ports/atmel-samd/boards/winterbloom_sol/mpconfigboard.mk
index 19917898b..aa94af6a4 100644
--- a/ports/atmel-samd/boards/winterbloom_sol/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/winterbloom_sol/mpconfigboard.mk
@@ -25,3 +25,6 @@ CIRCUITPY_I2CSLAVE = 0
CIRCUITPY_NETWORK = 0
CIRCUITPY_TOUCHIO = 0
CIRCUITPY_PS2IO = 0
+
+# Enable micropython.native
+CIRCUITPY_ENABLE_MPY_NATIVE = 1
diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h
index 2cb617819..b1e7bc05a 100644
--- a/py/circuitpy_mpconfig.h
+++ b/py/circuitpy_mpconfig.h
@@ -56,8 +56,8 @@
#define MICROPY_COMP_MODULE_CONST (1)
#define MICROPY_COMP_TRIPLE_TUPLE_ASSIGN (0)
#define MICROPY_DEBUG_PRINTERS (0)
-#define MICROPY_EMIT_INLINE_THUMB (0)
-#define MICROPY_EMIT_THUMB (0)
+#define MICROPY_EMIT_INLINE_THUMB (CIRCUITPY_ENABLE_MPY_NATIVE)
+#define MICROPY_EMIT_THUMB (CIRCUITPY_ENABLE_MPY_NATIVE)
#define MICROPY_EMIT_X64 (0)
#define MICROPY_ENABLE_DOC_STRING (0)
#define MICROPY_ENABLE_FINALISER (1)
diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk
index ac79d32d0..c1199571b 100644
--- a/py/circuitpy_mpconfig.mk
+++ b/py/circuitpy_mpconfig.mk
@@ -294,3 +294,10 @@ ifndef CIRCUITPY_BITBANG_APA102
CIRCUITPY_BITBANG_APA102 = 0
endif
CFLAGS += -DCIRCUITPY_BITBANG_APA102=$(CIRCUITPY_BITBANG_APA102)
+
+
+# Enabled micropython.native decorator (experimental)
+ifndef CIRCUITPY_ENABLE_MPY_NATIVE
+CIRCUITPY_ENABLE_MPY_NATIVE = 0
+endif
+CFLAGS += -DCIRCUITPY_ENABLE_MPY_NATIVE=$(CIRCUITPY_ENABLE_MPY_NATIVE)
diff --git a/py/compile.c b/py/compile.c
index 1218aa07e..8b17935bd 100644
--- a/py/compile.c
+++ b/py/compile.c
@@ -3207,7 +3207,7 @@ STATIC void compile_scope_inline_asm(compiler_t *comp, scope_t *scope, pass_kind
}
if (pass > MP_PASS_SCOPE) {
mp_int_t bytesize = MP_PARSE_NODE_LEAF_SMALL_INT(pn_arg[0]);
- for (uint j = 1; j < n_args; j++) {
+ for (int j = 1; j < n_args; j++) {
if (!MP_PARSE_NODE_IS_SMALL_INT(pn_arg[j])) {
compile_syntax_error(comp, nodes[i], translate("'data' requires integer arguments"));
return;
diff --git a/py/emitnative.c b/py/emitnative.c
index 67b0025c6..6d23bf097 100644
--- a/py/emitnative.c
+++ b/py/emitnative.c
@@ -58,6 +58,22 @@
#define DEBUG_printf(...) (void)0
#endif
+#ifndef N_X64
+ #define N_X64 (0)
+#endif
+#ifndef N_X86
+ #define N_X86 (0)
+#endif
+#ifndef N_THUMB
+ #define N_THUMB (0)
+#endif
+#ifndef N_ARM
+ #define N_ARM (0)
+#endif
+#ifndef N_XTENSA
+ #define N_XTENSA (0)
+#endif
+
// wrapper around everything in this file
#if N_X64 || N_X86 || N_THUMB || N_ARM || N_XTENSA
@@ -443,10 +459,12 @@ STATIC void emit_native_end_pass(emit_t *emit) {
type_sig |= (emit->local_vtype[i] & 0xf) << (i * 4 + 4);
}
+ #pragma GCC diagnostic ignored "-Wcast-align"
mp_emit_glue_assign_native(emit->scope->raw_code,
emit->do_viper_types ? MP_CODE_NATIVE_VIPER : MP_CODE_NATIVE_PY,
f, f_len, (mp_uint_t*)((byte*)f + emit->const_table_offset),
emit->scope->num_pos_args, emit->scope->scope_flags, type_sig);
+ #pragma GCC diagnostic pop
}
}
diff --git a/py/objfun.c b/py/objfun.c
index b8364815b..7e5899456 100644
--- a/py/objfun.c
+++ b/py/objfun.c
@@ -546,7 +546,7 @@ STATIC mp_uint_t convert_obj_for_inline_asm(mp_obj_t obj) {
STATIC mp_obj_t fun_asm_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
mp_obj_fun_asm_t *self = self_in;
- mp_arg_check_num(n_args, n_kw, self->n_args, self->n_args, false);
+ mp_arg_check_num_kw_array(n_args, n_kw, self->n_args, self->n_args, false);
void *fun = MICROPY_MAKE_POINTER_CALLABLE(self->fun_data);