Allow boards to enable the `micropython.native` decorator

Adds the `CIRCUITPY_ENABLE_MPY_NATIVE` for `mpconfigboard.mk` that enables
the `micropython.native` decorator.
This commit is contained in:
Thea Flowers 2019-10-29 10:11:19 -07:00
parent 01bf932169
commit c7195c4bc5
No known key found for this signature in database
GPG Key ID: 3CA6321E8CACD921
6 changed files with 33 additions and 3 deletions

View File

@ -25,3 +25,6 @@ CIRCUITPY_I2CSLAVE = 0
CIRCUITPY_NETWORK = 0
CIRCUITPY_TOUCHIO = 0
CIRCUITPY_PS2IO = 0
# Enable micropython.native
CIRCUITPY_ENABLE_MPY_NATIVE = 1

View File

@ -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)

View File

@ -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)

View File

@ -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;

View File

@ -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
}
}

View File

@ -546,7 +546,9 @@ 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;
#pragma GCC diagnostic ignored "-Wint-conversion"
mp_arg_check_num(n_args, n_kw, self->n_args, self->n_args, false);
#pragma GCC diagnostic pop
void *fun = MICROPY_MAKE_POINTER_CALLABLE(self->fun_data);