From dd53b12193dca4800ab207170fcc883142dd0f22 Mon Sep 17 00:00:00 2001 From: Damien George Date: Fri, 9 Dec 2016 20:54:54 +1100 Subject: [PATCH] py/emitinline: Move inline-asm align and data methods to compiler. These are generic methods that don't depend on the architecture and so can be handled directly by the compiler. --- py/compile.c | 7 +++++-- py/emit.h | 2 -- py/emitinlinethumb.c | 10 ---------- py/emitinlinextensa.c | 10 ---------- 4 files changed, 5 insertions(+), 24 deletions(-) diff --git a/py/compile.c b/py/compile.c index 6c9b6abfe6..f98b783b58 100644 --- a/py/compile.c +++ b/py/compile.c @@ -34,6 +34,7 @@ #include "py/emit.h" #include "py/compile.h" #include "py/runtime.h" +#include "py/asmbase.h" #if MICROPY_ENABLE_COMPILER @@ -3224,7 +3225,8 @@ STATIC void compile_scope_inline_asm(compiler_t *comp, scope_t *scope, pass_kind return; } if (pass > MP_PASS_SCOPE) { - EMIT_INLINE_ASM_ARG(align, MP_PARSE_NODE_LEAF_SMALL_INT(pn_arg[0])); + mp_asm_base_align((mp_asm_base_t*)comp->emit_inline_asm, + MP_PARSE_NODE_LEAF_SMALL_INT(pn_arg[0])); } } else if (op == MP_QSTR_data) { if (!(n_args >= 2 && MP_PARSE_NODE_IS_SMALL_INT(pn_arg[0]))) { @@ -3238,7 +3240,8 @@ STATIC void compile_scope_inline_asm(compiler_t *comp, scope_t *scope, pass_kind compile_syntax_error(comp, nodes[i], "'data' requires integer arguments"); return; } - EMIT_INLINE_ASM_ARG(data, bytesize, MP_PARSE_NODE_LEAF_SMALL_INT(pn_arg[j])); + mp_asm_base_data((mp_asm_base_t*)comp->emit_inline_asm, + bytesize, MP_PARSE_NODE_LEAF_SMALL_INT(pn_arg[j])); } } } else { diff --git a/py/emit.h b/py/emit.h index 6080b83c40..41cb2162d7 100644 --- a/py/emit.h +++ b/py/emit.h @@ -266,8 +266,6 @@ typedef struct _emit_inline_asm_method_table_t { void (*end_pass)(emit_inline_asm_t *emit, mp_uint_t type_sig); mp_uint_t (*count_params)(emit_inline_asm_t *emit, mp_uint_t n_params, mp_parse_node_t *pn_params); bool (*label)(emit_inline_asm_t *emit, mp_uint_t label_num, qstr label_id); - void (*align)(emit_inline_asm_t *emit, mp_uint_t align); - void (*data)(emit_inline_asm_t *emit, mp_uint_t bytesize, mp_uint_t val); void (*op)(emit_inline_asm_t *emit, qstr op, mp_uint_t n_args, mp_parse_node_t *pn_args); } emit_inline_asm_method_table_t; diff --git a/py/emitinlinethumb.c b/py/emitinlinethumb.c index 1373e173dc..24ba3fa343 100644 --- a/py/emitinlinethumb.c +++ b/py/emitinlinethumb.c @@ -130,14 +130,6 @@ STATIC bool emit_inline_thumb_label(emit_inline_asm_t *emit, mp_uint_t label_num return true; } -STATIC void emit_inline_thumb_align(emit_inline_asm_t *emit, mp_uint_t align) { - mp_asm_base_align(&emit->as.base, align); -} - -STATIC void emit_inline_thumb_data(emit_inline_asm_t *emit, mp_uint_t bytesize, mp_uint_t val) { - mp_asm_base_data(&emit->as.base, bytesize, val); -} - typedef struct _reg_name_t { byte reg; byte name[3]; } reg_name_t; STATIC const reg_name_t reg_name_table[] = { {0, "r0\0"}, @@ -823,8 +815,6 @@ const emit_inline_asm_method_table_t emit_inline_thumb_method_table = { emit_inline_thumb_end_pass, emit_inline_thumb_count_params, emit_inline_thumb_label, - emit_inline_thumb_align, - emit_inline_thumb_data, emit_inline_thumb_op, }; diff --git a/py/emitinlinextensa.c b/py/emitinlinextensa.c index 284624e45b..38a8629e1f 100644 --- a/py/emitinlinextensa.c +++ b/py/emitinlinextensa.c @@ -123,14 +123,6 @@ STATIC bool emit_inline_xtensa_label(emit_inline_asm_t *emit, mp_uint_t label_nu return true; } -STATIC void emit_inline_xtensa_align(emit_inline_asm_t *emit, mp_uint_t align) { - mp_asm_base_align(&emit->as.base, align); -} - -STATIC void emit_inline_xtensa_data(emit_inline_asm_t *emit, mp_uint_t bytesize, mp_uint_t val) { - mp_asm_base_data(&emit->as.base, bytesize, val); -} - typedef struct _reg_name_t { byte reg; byte name[3]; } reg_name_t; STATIC const reg_name_t reg_name_table[] = { {0, "a0\0"}, @@ -355,8 +347,6 @@ const emit_inline_asm_method_table_t emit_inline_xtensa_method_table = { emit_inline_xtensa_end_pass, emit_inline_xtensa_count_params, emit_inline_xtensa_label, - emit_inline_xtensa_align, - emit_inline_xtensa_data, emit_inline_xtensa_op, };