From c39093d801b8fb50c9af48902e9bb5faa9ab1e8b Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 12 Aug 2015 23:31:19 +0100 Subject: [PATCH] py: In native ARM emitter, load r7 with table earlier in func prelude. r7 may be needed to set up code state, so it must be loaded before the set-up function is called. --- py/emitnative.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/py/emitnative.c b/py/emitnative.c index 2a521c229c..af7fbc5510 100644 --- a/py/emitnative.c +++ b/py/emitnative.c @@ -693,6 +693,13 @@ STATIC void emit_native_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scop } ASM_ENTRY(emit->as, num_locals); + // TODO don't load r7 if we don't need it + #if N_THUMB + asm_thumb_mov_reg_i32(emit->as, ASM_THUMB_REG_R7, (mp_uint_t)mp_fun_table); + #elif N_ARM + asm_arm_mov_reg_i32(emit->as, ASM_ARM_REG_R7, (mp_uint_t)mp_fun_table); + #endif + #if N_X86 for (int i = 0; i < scope->num_pos_args; i++) { if (i == 0) { @@ -730,6 +737,13 @@ STATIC void emit_native_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scop // allocate space on C-stack for code_state structure, which includes state ASM_ENTRY(emit->as, STATE_START + emit->n_state); + // TODO don't load r7 if we don't need it + #if N_THUMB + asm_thumb_mov_reg_i32(emit->as, ASM_THUMB_REG_R7, (mp_uint_t)mp_fun_table); + #elif N_ARM + asm_arm_mov_reg_i32(emit->as, ASM_ARM_REG_R7, (mp_uint_t)mp_fun_table); + #endif + // prepare incoming arguments for call to mp_setup_code_state #if N_X86 asm_x86_mov_arg_to_r32(emit->as, 0, REG_ARG_2); @@ -796,15 +810,6 @@ STATIC void emit_native_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scop } } - #if N_THUMB - // TODO don't load r7 if we don't need it - asm_thumb_mov_reg_i32(emit->as, ASM_THUMB_REG_R7, (mp_uint_t)mp_fun_table); - #endif - - #if N_ARM - // TODO don't load r7 if we don't need it - asm_arm_mov_reg_i32(emit->as, ASM_ARM_REG_R7, (mp_uint_t)mp_fun_table); - #endif } STATIC void emit_native_end_pass(emit_t *emit) {