Skip to content
Snippets Groups Projects
Commit 7fe2191c authored by Damien George's avatar Damien George
Browse files

py: Code clean-up in native emitter; improve thumb native calls.

parent 86de21b8
No related branches found
No related tags found
No related merge requests found
...@@ -496,17 +496,14 @@ void asm_thumb_bl_ind(asm_thumb_t *as, void *fun_ptr, uint fun_id, uint reg_temp ...@@ -496,17 +496,14 @@ void asm_thumb_bl_ind(asm_thumb_t *as, void *fun_ptr, uint fun_id, uint reg_temp
asm_thumb_op16(as, 0x4780 | (REG_R9 << 3)); // blx reg asm_thumb_op16(as, 0x4780 | (REG_R9 << 3)); // blx reg
*/ */
if (0) { if (fun_id < 32) {
// load ptr to function into register using immediate, then branch // load ptr to function from table, indexed by fun_id (must be in range 0-31); 4 bytes
// not relocatable
asm_thumb_mov_reg_i32(as, reg_temp, (mp_uint_t)fun_ptr);
asm_thumb_op16(as, OP_BLX(reg_temp));
} else if (1) {
asm_thumb_op16(as, OP_FORMAT_9_10(ASM_THUMB_FORMAT_9_LDR | ASM_THUMB_FORMAT_9_WORD_TRANSFER, reg_temp, REG_R7, fun_id)); asm_thumb_op16(as, OP_FORMAT_9_10(ASM_THUMB_FORMAT_9_LDR | ASM_THUMB_FORMAT_9_WORD_TRANSFER, reg_temp, REG_R7, fun_id));
asm_thumb_op16(as, OP_BLX(reg_temp)); asm_thumb_op16(as, OP_BLX(reg_temp));
} else { } else {
// use SVC // load ptr to function into register using immediate; 6 bytes
asm_thumb_op16(as, OP_SVC(fun_id)); asm_thumb_mov_reg_i32(as, reg_temp, (mp_uint_t)fun_ptr);
asm_thumb_op16(as, OP_BLX(reg_temp));
} }
} }
......
This diff is collapsed.
...@@ -1192,13 +1192,14 @@ NORETURN void mp_native_raise(mp_obj_t o) { ...@@ -1192,13 +1192,14 @@ NORETURN void mp_native_raise(mp_obj_t o) {
nlr_raise(mp_make_raise_obj(o)); nlr_raise(mp_make_raise_obj(o));
} }
// these must correspond to the respective enum // these must correspond to the respective enum in runtime0.h
void *const mp_fun_table[MP_F_NUMBER_OF] = { void *const mp_fun_table[MP_F_NUMBER_OF] = {
mp_convert_obj_to_native, mp_convert_obj_to_native,
mp_convert_native_to_obj, mp_convert_native_to_obj,
mp_load_const_int, mp_load_const_int,
mp_load_const_dec, mp_load_const_dec,
mp_load_const_str, mp_load_const_str,
mp_load_const_bytes,
mp_load_name, mp_load_name,
mp_load_global, mp_load_global,
mp_load_build_class, mp_load_build_class,
...@@ -1225,6 +1226,8 @@ void *const mp_fun_table[MP_F_NUMBER_OF] = { ...@@ -1225,6 +1226,8 @@ void *const mp_fun_table[MP_F_NUMBER_OF] = {
mp_call_method_n_kw, mp_call_method_n_kw,
mp_getiter, mp_getiter,
mp_iternext, mp_iternext,
nlr_push,
nlr_pop,
mp_native_raise, mp_native_raise,
mp_import_name, mp_import_name,
mp_import_from, mp_import_from,
......
...@@ -107,6 +107,7 @@ typedef enum { ...@@ -107,6 +107,7 @@ typedef enum {
MP_F_LOAD_CONST_INT, MP_F_LOAD_CONST_INT,
MP_F_LOAD_CONST_DEC, MP_F_LOAD_CONST_DEC,
MP_F_LOAD_CONST_STR, MP_F_LOAD_CONST_STR,
MP_F_LOAD_CONST_BYTES,
MP_F_LOAD_NAME, MP_F_LOAD_NAME,
MP_F_LOAD_GLOBAL, MP_F_LOAD_GLOBAL,
MP_F_LOAD_BUILD_CLASS, MP_F_LOAD_BUILD_CLASS,
...@@ -133,9 +134,11 @@ typedef enum { ...@@ -133,9 +134,11 @@ typedef enum {
MP_F_CALL_METHOD_N_KW, MP_F_CALL_METHOD_N_KW,
MP_F_GETITER, MP_F_GETITER,
MP_F_ITERNEXT, MP_F_ITERNEXT,
MP_F_NLR_PUSH,
MP_F_NLR_POP,
MP_F_NATIVE_RAISE, MP_F_NATIVE_RAISE,
MP_F_IMPORT_NAME, MP_F_IMPORT_NAME,
MP_F_IMPORT_FROM, // = 31 XXX this is the limit for thumb code... MP_F_IMPORT_FROM,
MP_F_IMPORT_ALL, MP_F_IMPORT_ALL,
#if MICROPY_PY_BUILTINS_SLICE #if MICROPY_PY_BUILTINS_SLICE
MP_F_NEW_SLICE, MP_F_NEW_SLICE,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment