Commit 7ff996c2 authored by Damien George's avatar Damien George
Browse files

py: Convert [u]int to mp_[u]int_t in emit.h and associated .c files.

Towards resolving issue #50.
parent 377b80b6
......@@ -975,12 +975,12 @@ STATIC void close_over_variables_etc(compiler_t *comp, scope_t *this_scope, int
if (id->kind == ID_INFO_KIND_CELL || id->kind == ID_INFO_KIND_FREE) {
for (int j = 0; j < this_scope->id_info_len; j++) {
id_info_t *id2 = &this_scope->id_info[j];
if (id2->kind == ID_INFO_KIND_FREE && id->qstr == id2->qstr) {
if (id2->kind == ID_INFO_KIND_FREE && id->qst == id2->qst) {
#if MICROPY_EMIT_CPYTHON
EMIT_ARG(load_closure, id->qstr, id->local_num);
EMIT_ARG(load_closure, id->qst, id->local_num);
#else
// in Micro Python we load closures using LOAD_FAST
EMIT_ARG(load_fast, id->qstr, id->flags, id->local_num);
EMIT_ARG(load_fast, id->qst, id->flags, id->local_num);
#endif
nfree += 1;
}
......@@ -3446,7 +3446,7 @@ STATIC void compile_scope_compute_things(compiler_t *comp, scope_t *scope) {
scope->num_locals = 0;
for (int i = 0; i < scope->id_info_len; i++) {
id_info_t *id = &scope->id_info[i];
if (scope->kind == SCOPE_CLASS && id->qstr == MP_QSTR___class__) {
if (scope->kind == SCOPE_CLASS && id->qst == MP_QSTR___class__) {
// __class__ is not counted as a local; if it's used then it becomes a ID_INFO_KIND_CELL
continue;
}
......@@ -3491,7 +3491,7 @@ STATIC void compile_scope_compute_things(compiler_t *comp, scope_t *scope) {
if (id->kind == ID_INFO_KIND_CELL || id->kind == ID_INFO_KIND_FREE) {
for (int j = 0; j < scope->id_info_len; j++) {
id_info_t *id2 = &scope->id_info[j];
if (id2->kind == ID_INFO_KIND_FREE && id->qstr == id2->qstr) {
if (id2->kind == ID_INFO_KIND_FREE && id->qst == id2->qst) {
assert(!(id2->flags & ID_FLAG_IS_PARAM)); // free vars should not be params
#if MICROPY_EMIT_CPYTHON
// in CPython the frees are numbered after the cells
......
......@@ -57,84 +57,84 @@ typedef struct _emit_method_table_t {
void (*start_pass)(emit_t *emit, pass_kind_t pass, scope_t *scope);
void (*end_pass)(emit_t *emit);
bool (*last_emit_was_return_value)(emit_t *emit);
void (*adjust_stack_size)(emit_t *emit, int delta);
void (*set_line_number)(emit_t *emit, int line);
void (*adjust_stack_size)(emit_t *emit, mp_int_t delta);
void (*set_line_number)(emit_t *emit, mp_uint_t line);
void (*load_id)(emit_t *emit, qstr qstr);
void (*store_id)(emit_t *emit, qstr qstr);
void (*delete_id)(emit_t *emit, qstr qstr);
void (*load_id)(emit_t *emit, qstr qst);
void (*store_id)(emit_t *emit, qstr qst);
void (*delete_id)(emit_t *emit, qstr qst);
void (*label_assign)(emit_t *emit, uint l);
void (*import_name)(emit_t *emit, qstr qstr);
void (*import_from)(emit_t *emit, qstr qstr);
void (*label_assign)(emit_t *emit, mp_uint_t l);
void (*import_name)(emit_t *emit, qstr qst);
void (*import_from)(emit_t *emit, qstr qst);
void (*import_star)(emit_t *emit);
void (*load_const_tok)(emit_t *emit, mp_token_kind_t tok);
void (*load_const_small_int)(emit_t *emit, mp_int_t arg);
void (*load_const_int)(emit_t *emit, qstr qstr);
void (*load_const_dec)(emit_t *emit, qstr qstr);
void (*load_const_str)(emit_t *emit, qstr qstr, bool bytes);
void (*load_const_int)(emit_t *emit, qstr qst);
void (*load_const_dec)(emit_t *emit, qstr qst);
void (*load_const_str)(emit_t *emit, qstr qst, bool bytes);
void (*load_null)(emit_t *emit);
void (*load_fast)(emit_t *emit, qstr qstr, uint id_flags, int local_num);
void (*load_deref)(emit_t *emit, qstr qstr, int local_num);
void (*load_name)(emit_t *emit, qstr qstr);
void (*load_global)(emit_t *emit, qstr qstr);
void (*load_attr)(emit_t *emit, qstr qstr);
void (*load_method)(emit_t *emit, qstr qstr);
void (*load_fast)(emit_t *emit, qstr qst, mp_uint_t id_flags, mp_uint_t local_num);
void (*load_deref)(emit_t *emit, qstr qst, mp_uint_t local_num);
void (*load_name)(emit_t *emit, qstr qst);
void (*load_global)(emit_t *emit, qstr qst);
void (*load_attr)(emit_t *emit, qstr qst);
void (*load_method)(emit_t *emit, qstr qst);
void (*load_build_class)(emit_t *emit);
void (*load_subscr)(emit_t *emit);
void (*store_fast)(emit_t *emit, qstr qstr, int local_num);
void (*store_deref)(emit_t *emit, qstr qstr, int local_num);
void (*store_name)(emit_t *emit, qstr qstr);
void (*store_global)(emit_t *emit, qstr qstr);
void (*store_attr)(emit_t *emit, qstr qstr);
void (*store_fast)(emit_t *emit, qstr qst, mp_uint_t local_num);
void (*store_deref)(emit_t *emit, qstr qst, mp_uint_t local_num);
void (*store_name)(emit_t *emit, qstr qst);
void (*store_global)(emit_t *emit, qstr qst);
void (*store_attr)(emit_t *emit, qstr qst);
void (*store_subscr)(emit_t *emit);
void (*delete_fast)(emit_t *emit, qstr qstr, int local_num);
void (*delete_deref)(emit_t *emit, qstr qstr, int local_num);
void (*delete_name)(emit_t *emit, qstr qstr);
void (*delete_global)(emit_t *emit, qstr qstr);
void (*delete_attr)(emit_t *emit, qstr qstr);
void (*delete_fast)(emit_t *emit, qstr qst, mp_uint_t local_num);
void (*delete_deref)(emit_t *emit, qstr qst, mp_uint_t local_num);
void (*delete_name)(emit_t *emit, qstr qst);
void (*delete_global)(emit_t *emit, qstr qst);
void (*delete_attr)(emit_t *emit, qstr qst);
void (*delete_subscr)(emit_t *emit);
void (*dup_top)(emit_t *emit);
void (*dup_top_two)(emit_t *emit);
void (*pop_top)(emit_t *emit);
void (*rot_two)(emit_t *emit);
void (*rot_three)(emit_t *emit);
void (*jump)(emit_t *emit, uint label);
void (*pop_jump_if_true)(emit_t *emit, uint label);
void (*pop_jump_if_false)(emit_t *emit, uint label);
void (*jump_if_true_or_pop)(emit_t *emit, uint label);
void (*jump_if_false_or_pop)(emit_t *emit, uint label);
void (*break_loop)(emit_t *emit, uint label, int except_depth);
void (*continue_loop)(emit_t *emit, uint label, int except_depth);
void (*setup_with)(emit_t *emit, uint label);
void (*jump)(emit_t *emit, mp_uint_t label);
void (*pop_jump_if_true)(emit_t *emit, mp_uint_t label);
void (*pop_jump_if_false)(emit_t *emit, mp_uint_t label);
void (*jump_if_true_or_pop)(emit_t *emit, mp_uint_t label);
void (*jump_if_false_or_pop)(emit_t *emit, mp_uint_t label);
void (*break_loop)(emit_t *emit, mp_uint_t label, mp_uint_t except_depth);
void (*continue_loop)(emit_t *emit, mp_uint_t label, mp_uint_t except_depth);
void (*setup_with)(emit_t *emit, mp_uint_t label);
void (*with_cleanup)(emit_t *emit);
void (*setup_except)(emit_t *emit, uint label);
void (*setup_finally)(emit_t *emit, uint label);
void (*setup_except)(emit_t *emit, mp_uint_t label);
void (*setup_finally)(emit_t *emit, mp_uint_t label);
void (*end_finally)(emit_t *emit);
void (*get_iter)(emit_t *emit);
void (*for_iter)(emit_t *emit, uint label);
void (*for_iter)(emit_t *emit, mp_uint_t label);
void (*for_iter_end)(emit_t *emit);
void (*pop_block)(emit_t *emit);
void (*pop_except)(emit_t *emit);
void (*unary_op)(emit_t *emit, mp_unary_op_t op);
void (*binary_op)(emit_t *emit, mp_binary_op_t op);
void (*build_tuple)(emit_t *emit, int n_args);
void (*build_list)(emit_t *emit, int n_args);
void (*list_append)(emit_t *emit, int list_stack_index);
void (*build_map)(emit_t *emit, int n_args);
void (*build_tuple)(emit_t *emit, mp_uint_t n_args);
void (*build_list)(emit_t *emit, mp_uint_t n_args);
void (*list_append)(emit_t *emit, mp_uint_t list_stack_index);
void (*build_map)(emit_t *emit, mp_uint_t n_args);
void (*store_map)(emit_t *emit);
void (*map_add)(emit_t *emit, int map_stack_index);
void (*build_set)(emit_t *emit, int n_args);
void (*set_add)(emit_t *emit, int set_stack_index);
void (*build_slice)(emit_t *emit, int n_args);
void (*unpack_sequence)(emit_t *emit, int n_args);
void (*unpack_ex)(emit_t *emit, int n_left, int n_right);
void (*make_function)(emit_t *emit, scope_t *scope, uint n_pos_defaults, uint n_kw_defaults);
void (*make_closure)(emit_t *emit, scope_t *scope, uint n_closed_over, uint n_pos_defaults, uint n_kw_defaults);
void (*call_function)(emit_t *emit, int n_positional, int n_keyword, uint star_flags);
void (*call_method)(emit_t *emit, int n_positional, int n_keyword, uint star_flags);
void (*map_add)(emit_t *emit, mp_uint_t map_stack_index);
void (*build_set)(emit_t *emit, mp_uint_t n_args);
void (*set_add)(emit_t *emit, mp_uint_t set_stack_index);
void (*build_slice)(emit_t *emit, mp_uint_t n_args);
void (*unpack_sequence)(emit_t *emit, mp_uint_t n_args);
void (*unpack_ex)(emit_t *emit, mp_uint_t n_left, mp_uint_t n_right);
void (*make_function)(emit_t *emit, scope_t *scope, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults);
void (*make_closure)(emit_t *emit, scope_t *scope, mp_uint_t n_closed_over, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults);
void (*call_function)(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags);
void (*call_method)(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags);
void (*return_value)(emit_t *emit);
void (*raise_varargs)(emit_t *emit, int n_args);
void (*raise_varargs)(emit_t *emit, mp_uint_t n_args);
void (*yield_value)(emit_t *emit);
void (*yield_from)(emit_t *emit);
......@@ -146,15 +146,15 @@ typedef struct _emit_method_table_t {
#if MICROPY_EMIT_CPYTHON
// these methods are only needed for emitcpy
void (*load_const_verbatim_str)(emit_t *emit, const char *str);
void (*load_closure)(emit_t *emit, qstr qstr, int local_num);
void (*setup_loop)(emit_t *emit, uint label);
void (*load_closure)(emit_t *emit, qstr qst, mp_uint_t local_num);
void (*setup_loop)(emit_t *emit, mp_uint_t label);
#endif
} emit_method_table_t;
void emit_common_load_id(emit_t *emit, const emit_method_table_t *emit_method_table, scope_t *scope, qstr qstr);
void emit_common_store_id(emit_t *emit, const emit_method_table_t *emit_method_table, scope_t *scope, qstr qstr);
void emit_common_delete_id(emit_t *emit, const emit_method_table_t *emit_method_table, scope_t *scope, qstr qstr);
void emit_common_load_id(emit_t *emit, const emit_method_table_t *emit_method_table, scope_t *scope, qstr qst);
void emit_common_store_id(emit_t *emit, const emit_method_table_t *emit_method_table, scope_t *scope, qstr qst);
void emit_common_delete_id(emit_t *emit, const emit_method_table_t *emit_method_table, scope_t *scope, qstr qst);
extern const emit_method_table_t emit_pass1_method_table;
extern const emit_method_table_t emit_cpython_method_table;
......@@ -165,12 +165,12 @@ extern const emit_method_table_t emit_native_thumb_method_table;
extern const emit_method_table_t emit_native_arm_method_table;
emit_t *emit_pass1_new(void);
emit_t *emit_cpython_new(uint max_num_labels);
emit_t *emit_bc_new(uint max_num_labels);
emit_t *emit_native_x64_new(uint max_num_labels);
emit_t *emit_native_x86_new(uint max_num_labels);
emit_t *emit_native_thumb_new(uint max_num_labels);
emit_t *emit_native_arm_new(uint max_num_labels);
emit_t *emit_cpython_new(mp_uint_t max_num_labels);
emit_t *emit_bc_new(mp_uint_t max_num_labels);
emit_t *emit_native_x64_new(mp_uint_t max_num_labels);
emit_t *emit_native_x86_new(mp_uint_t max_num_labels);
emit_t *emit_native_thumb_new(mp_uint_t max_num_labels);
emit_t *emit_native_arm_new(mp_uint_t max_num_labels);
void emit_pass1_free(emit_t *emit);
void emit_bc_free(emit_t *emit);
......@@ -184,15 +184,14 @@ typedef struct _emit_inline_asm_t emit_inline_asm_t;
typedef struct _emit_inline_asm_method_table_t {
void (*start_pass)(emit_inline_asm_t *emit, pass_kind_t pass, scope_t *scope);
bool (*end_pass)(emit_inline_asm_t *emit);
int (*count_params)(emit_inline_asm_t *emit, int n_params, mp_parse_node_t *pn_params);
void (*label)(emit_inline_asm_t *emit, uint label_num, qstr label_id);
void (*align)(emit_inline_asm_t *emit, uint align);
void (*data)(emit_inline_asm_t *emit, uint bytesize, uint val);
void (*op)(emit_inline_asm_t *emit, qstr op, int n_args, mp_parse_node_t *pn_args);
mp_uint_t (*count_params)(emit_inline_asm_t *emit, mp_uint_t n_params, mp_parse_node_t *pn_params);
void (*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;
extern const emit_inline_asm_method_table_t emit_inline_thumb_method_table;
emit_inline_asm_t *emit_inline_thumb_new(uint max_num_labels);
emit_inline_asm_t *emit_inline_thumb_new(mp_uint_t max_num_labels);
void emit_inline_thumb_free(emit_inline_asm_t *emit);
This diff is collapsed.
......@@ -41,61 +41,61 @@
#define EMIT(fun, ...) (emit_method_table->fun(emit, __VA_ARGS__))
void emit_common_load_id(emit_t *emit, const emit_method_table_t *emit_method_table, scope_t *scope, qstr qstr) {
void emit_common_load_id(emit_t *emit, const emit_method_table_t *emit_method_table, scope_t *scope, qstr qst) {
// assumes pass is greater than 1, ie that all identifiers are defined in the scope
id_info_t *id = scope_find(scope, qstr);
id_info_t *id = scope_find(scope, qst);
assert(id != NULL); // TODO can this ever fail?
// call the emit backend with the correct code
if (id == NULL || id->kind == ID_INFO_KIND_GLOBAL_IMPLICIT) {
EMIT(load_name, qstr);
EMIT(load_name, qst);
} else if (id->kind == ID_INFO_KIND_GLOBAL_EXPLICIT) {
EMIT(load_global, qstr);
EMIT(load_global, qst);
} else if (id->kind == ID_INFO_KIND_LOCAL) {
EMIT(load_fast, qstr, id->flags, id->local_num);
EMIT(load_fast, qst, id->flags, id->local_num);
} else if (id->kind == ID_INFO_KIND_CELL || id->kind == ID_INFO_KIND_FREE) {
EMIT(load_deref, qstr, id->local_num);
EMIT(load_deref, qst, id->local_num);
} else {
assert(0);
}
}
void emit_common_store_id(emit_t *emit, const emit_method_table_t *emit_method_table, scope_t *scope, qstr qstr) {
void emit_common_store_id(emit_t *emit, const emit_method_table_t *emit_method_table, scope_t *scope, qstr qst) {
// assumes pass is greater than 1, ie that all identifiers are defined in the scope
id_info_t *id = scope_find(scope, qstr);
id_info_t *id = scope_find(scope, qst);
assert(id != NULL); // TODO can this ever fail?
// call the emit backend with the correct code
if (id == NULL || id->kind == ID_INFO_KIND_GLOBAL_IMPLICIT) {
EMIT(store_name, qstr);
EMIT(store_name, qst);
} else if (id->kind == ID_INFO_KIND_GLOBAL_EXPLICIT) {
EMIT(store_global, qstr);
EMIT(store_global, qst);
} else if (id->kind == ID_INFO_KIND_LOCAL) {
EMIT(store_fast, qstr, id->local_num);
EMIT(store_fast, qst, id->local_num);
} else if (id->kind == ID_INFO_KIND_CELL || id->kind == ID_INFO_KIND_FREE) {
EMIT(store_deref, qstr, id->local_num);
EMIT(store_deref, qst, id->local_num);
} else {
assert(0);
}
}
void emit_common_delete_id(emit_t *emit, const emit_method_table_t *emit_method_table, scope_t *scope, qstr qstr) {
void emit_common_delete_id(emit_t *emit, const emit_method_table_t *emit_method_table, scope_t *scope, qstr qst) {
// assumes pass is greater than 1, ie that all identifiers are defined in the scope
id_info_t *id = scope_find(scope, qstr);
id_info_t *id = scope_find(scope, qst);
assert(id != NULL); // TODO can this ever fail?
// call the emit backend with the correct code
if (id == NULL || id->kind == ID_INFO_KIND_GLOBAL_IMPLICIT) {
EMIT(delete_name, qstr);
EMIT(delete_name, qst);
} else if (id->kind == ID_INFO_KIND_GLOBAL_EXPLICIT) {
EMIT(delete_global, qstr);
EMIT(delete_global, qst);
} else if (id->kind == ID_INFO_KIND_LOCAL) {
EMIT(delete_fast, qstr, id->local_num);
EMIT(delete_fast, qst, id->local_num);
} else if (id->kind == ID_INFO_KIND_CELL || id->kind == ID_INFO_KIND_FREE) {
EMIT(delete_deref, qstr, id->local_num);
EMIT(delete_deref, qst, id->local_num);
} else {
assert(0);
}
......
This diff is collapsed.
......@@ -56,7 +56,7 @@ struct _emit_inline_asm_t {
uint16_t pass;
uint16_t success;
scope_t *scope;
uint max_num_labels;
mp_uint_t max_num_labels;
qstr *label_lookup;
asm_thumb_t *as;
};
......@@ -70,7 +70,7 @@ void emit_inline_thumb_error(emit_inline_asm_t *emit, const char *fmt, ...) {
va_end(ap);
}
emit_inline_asm_t *emit_inline_thumb_new(uint max_num_labels) {
emit_inline_asm_t *emit_inline_thumb_new(mp_uint_t max_num_labels) {
emit_inline_asm_t *emit = m_new_obj(emit_inline_asm_t);
emit->max_num_labels = max_num_labels;
emit->label_lookup = m_new(qstr, max_num_labels);
......@@ -105,12 +105,12 @@ STATIC bool emit_inline_thumb_end_pass(emit_inline_asm_t *emit) {
return emit->success;
}
STATIC int emit_inline_thumb_count_params(emit_inline_asm_t *emit, int n_params, mp_parse_node_t *pn_params) {
STATIC mp_uint_t emit_inline_thumb_count_params(emit_inline_asm_t *emit, mp_uint_t n_params, mp_parse_node_t *pn_params) {
if (n_params > 4) {
emit_inline_thumb_error(emit, "can only have up to 4 parameters to inline thumb assembly\n");
return 0;
}
for (int i = 0; i < n_params; i++) {
for (mp_uint_t i = 0; i < n_params; i++) {
if (!MP_PARSE_NODE_IS_ID(pn_params[i])) {
emit_inline_thumb_error(emit, "parameter to inline assembler must be an identifier\n");
return 0;
......@@ -124,17 +124,17 @@ STATIC int emit_inline_thumb_count_params(emit_inline_asm_t *emit, int n_params,
return n_params;
}
STATIC void emit_inline_thumb_label(emit_inline_asm_t *emit, uint label_num, qstr label_id) {
STATIC void emit_inline_thumb_label(emit_inline_asm_t *emit, mp_uint_t label_num, qstr label_id) {
assert(label_num < emit->max_num_labels);
emit->label_lookup[label_num] = label_id;
asm_thumb_label_assign(emit->as, label_num);
}
STATIC void emit_inline_thumb_align(emit_inline_asm_t *emit, uint align) {
STATIC void emit_inline_thumb_align(emit_inline_asm_t *emit, mp_uint_t align) {
asm_thumb_align(emit->as, align);
}
STATIC void emit_inline_thumb_data(emit_inline_asm_t *emit, uint bytesize, uint val) {
STATIC void emit_inline_thumb_data(emit_inline_asm_t *emit, mp_uint_t bytesize, mp_uint_t val) {
asm_thumb_data(emit->as, bytesize, val);
}
......@@ -163,11 +163,11 @@ STATIC const reg_name_t reg_name_table[] = {
{15, "pc\0"},
};
STATIC uint get_arg_reg(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn, uint max_reg) {
STATIC mp_uint_t get_arg_reg(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn, mp_uint_t max_reg) {
if (MP_PARSE_NODE_IS_ID(pn)) {
qstr reg_qstr = MP_PARSE_NODE_LEAF_ARG(pn);
const char *reg_str = qstr_str(reg_qstr);
for (uint i = 0; i < MP_ARRAY_SIZE(reg_name_table); i++) {
for (mp_uint_t i = 0; i < MP_ARRAY_SIZE(reg_name_table); i++) {
const reg_name_t *r = &reg_name_table[i];
if (reg_str[0] == r->name[0] && reg_str[1] == r->name[1] && reg_str[2] == r->name[2] && (reg_str[2] == '\0' || reg_str[3] == '\0')) {
if (r->reg > max_reg) {
......@@ -254,7 +254,7 @@ STATIC const cc_name_t cc_name_table[] = {
{THUMB_CC_LE, "le"},
};
STATIC void emit_inline_thumb_op(emit_inline_asm_t *emit, qstr op, int n_args, mp_parse_node_t *pn_args) {
STATIC void emit_inline_thumb_op(emit_inline_asm_t *emit, qstr op, mp_uint_t n_args, mp_parse_node_t *pn_args) {
// TODO perhaps make two tables:
// one_args =
// "b", LAB, asm_thumb_b_n,
......@@ -266,7 +266,7 @@ STATIC void emit_inline_thumb_op(emit_inline_asm_t *emit, qstr op, int n_args, m
// "subs", RLO, RLO, I3, asm_thumb_subs_reg_reg_i3
const char *op_str = qstr_str(op);
uint op_len = strlen(op_str);
mp_uint_t op_len = strlen(op_str);
if (n_args == 0) {
if (strcmp(op_str, "nop") == 0) {
......@@ -285,8 +285,8 @@ STATIC void emit_inline_thumb_op(emit_inline_asm_t *emit, qstr op, int n_args, m
// TODO check that this succeeded, ie branch was within range
asm_thumb_b_n(emit->as, label_num);
} else if (op_str[0] == 'b' && op_len == 3) {
uint cc = -1;
for (uint i = 0; i < MP_ARRAY_SIZE(cc_name_table); i++) {
mp_uint_t cc = -1;
for (mp_uint_t i = 0; i < MP_ARRAY_SIZE(cc_name_table); i++) {
if (op_str[1] == cc_name_table[i].name[0] && op_str[2] == cc_name_table[i].name[1]) {
cc = cc_name_table[i].cc;
}
......@@ -310,14 +310,14 @@ STATIC void emit_inline_thumb_op(emit_inline_asm_t *emit, qstr op, int n_args, m
} else if (n_args == 2) {
if (MP_PARSE_NODE_IS_ID(pn_args[1])) {
// second arg is a register (or should be)
uint op_code;
mp_uint_t op_code;
if (strcmp(op_str, "mov") == 0) {
uint reg_dest = get_arg_reg(emit, op_str, pn_args[0], 15);
uint reg_src = get_arg_reg(emit, op_str, pn_args[1], 15);
mp_uint_t reg_dest = get_arg_reg(emit, op_str, pn_args[0], 15);
mp_uint_t reg_src = get_arg_reg(emit, op_str, pn_args[1], 15);
asm_thumb_mov_reg_reg(emit->as, reg_dest, reg_src);
} else if (strcmp(op_str, "and_") == 0) {
op_code = ASM_THUMB_FORMAT_4_AND;
uint reg_dest, reg_src;
mp_uint_t reg_dest, reg_src;
op_format_4:
reg_dest = get_arg_reg(emit, op_str, pn_args[0], 7);
reg_src = get_arg_reg(emit, op_str, pn_args[1], 7);
......@@ -343,10 +343,10 @@ STATIC void emit_inline_thumb_op(emit_inline_asm_t *emit, qstr op, int n_args, m
}
} else {
// second arg is not a register
uint op_code;
mp_uint_t op_code;
if (strcmp(op_str, "mov") == 0) {
op_code = ASM_THUMB_FORMAT_3_MOV;
uint rlo_dest, i8_src;
mp_uint_t rlo_dest, i8_src;
op_format_3:
rlo_dest = get_arg_reg(emit, op_str, pn_args[0], 7);
i8_src = get_arg_i(emit, op_str, pn_args[1], 0xff);
......@@ -361,23 +361,23 @@ STATIC void emit_inline_thumb_op(emit_inline_asm_t *emit, qstr op, int n_args, m
op_code = ASM_THUMB_FORMAT_3_SUB;
goto op_format_3;
} else if (strcmp(op_str, "movw") == 0) {
uint reg_dest = get_arg_reg(emit, op_str, pn_args[0], 15);
mp_uint_t reg_dest = get_arg_reg(emit, op_str, pn_args[0], 15);
int i_src = get_arg_i(emit, op_str, pn_args[1], 0xffff);
asm_thumb_movw_reg_i16(emit->as, reg_dest, i_src);
} else if (strcmp(op_str, "movt") == 0) {
uint reg_dest = get_arg_reg(emit, op_str, pn_args[0], 15);
mp_uint_t reg_dest = get_arg_reg(emit, op_str, pn_args[0], 15);
int i_src = get_arg_i(emit, op_str, pn_args[1], 0xffff);
asm_thumb_movt_reg_i16(emit->as, reg_dest, i_src);
} else if (strcmp(op_str, "movwt") == 0) {
// this is a convenience instruction
// we clear the MSB since it might be set from extracting the small int value
uint reg_dest = get_arg_reg(emit, op_str, pn_args[0], 15);
mp_uint_t reg_dest = get_arg_reg(emit, op_str, pn_args[0], 15);
int i_src = get_arg_i(emit, op_str, pn_args[1], 0xffffffff);
asm_thumb_movw_reg_i16(emit->as, reg_dest, i_src & 0xffff);
asm_thumb_movt_reg_i16(emit->as, reg_dest, (i_src >> 16) & 0x7fff);
} else if (strcmp(op_str, "ldr") == 0) {
op_code = ASM_THUMB_FORMAT_9_LDR | ASM_THUMB_FORMAT_9_WORD_TRANSFER;
uint rlo_dest, rlo_base, i5;
mp_uint_t rlo_dest, rlo_base, i5;
mp_parse_node_t pn_base, pn_offset;
op_format_9_10:
rlo_dest = get_arg_reg(emit, op_str, pn_args[0], 7);
......@@ -413,10 +413,10 @@ STATIC void emit_inline_thumb_op(emit_inline_asm_t *emit, qstr op, int n_args, m
}
} else if (n_args == 3) {
uint op_code;
mp_uint_t op_code;
if (strcmp(op_str, "add") == 0) {
op_code = ASM_THUMB_FORMAT_2_ADD;
uint rlo_dest, rlo_src;
mp_uint_t rlo_dest, rlo_src;
op_format_2:
rlo_dest = get_arg_reg(emit, op_str, pn_args[0], 7);
rlo_src = get_arg_reg(emit, op_str, pn_args[1], 7);
......
This diff is collapsed.
......@@ -67,13 +67,13 @@ STATIC bool emit_pass1_last_emit_was_return_value(emit_t *emit) {
return false;
}
STATIC void emit_pass1_load_id(emit_t *emit, qstr qstr) {
STATIC void emit_pass1_load_id(emit_t *emit, qstr qst) {
// name adding/lookup
bool added;
id_info_t *id = scope_find_or_add_id(emit->scope, qstr, &added);
id_info_t *id = scope_find_or_add_id(emit->scope, qst, &added);
if (added) {
#if MICROPY_EMIT_CPYTHON
if (qstr == MP_QSTR_super && emit->scope->kind == SCOPE_FUNCTION) {
if (qst == MP_QSTR_super && emit->scope->kind == SCOPE_FUNCTION) {
// special case, super is a global, and also counts as use of __class__
id->kind = ID_INFO_KIND_GLOBAL_EXPLICIT;
id_info_t *id2 = scope_find_local_in_parent(emit->scope, MP_QSTR___class__);
......@@ -87,10 +87,10 @@ STATIC void emit_pass1_load_id(emit_t *emit, qstr qstr) {
} else
#endif
{
id_info_t *id2 = scope_find_local_in_parent(emit->scope, qstr);
id_info_t *id2 = scope_find_local_in_parent(emit->scope, qst);
if (id2 != NULL && (id2->kind == ID_INFO_KIND_LOCAL || id2->kind == ID_INFO_KIND_CELL || id2->kind == ID_INFO_KIND_FREE)) {
id->kind = ID_INFO_KIND_FREE;
scope_close_over_in_parents(emit->scope, qstr);
scope_close_over_in_parents(emit->scope, qst);
} else {
id->kind = ID_INFO_KIND_GLOBAL_IMPLICIT;
}
......@@ -98,10 +98,10 @@ STATIC void emit_pass1_load_id(emit_t *emit, qstr qstr) {
}
}
STATIC id_info_t *get_id_for_modification(scope_t *scope, qstr qstr) {
STATIC id_info_t *get_id_for_modification(scope_t *scope, qstr qst) {
// name adding/lookup
bool added;
id_info_t *id = scope_find_or_add_id(scope, qstr, &added);
id_info_t *id = scope_find_or_add_id(scope, qst, &added);
if (added) {
if (scope->kind == SCOPE_MODULE || scope->kind == SCOPE_CLASS) {
id->kind = ID_INFO_KIND_GLOBAL_IMPLICIT;
......@@ -118,12 +118,12 @@ STATIC id_info_t *get_id_for_modification(scope_t *scope, qstr qstr) {
return id;
}
STATIC void emit_pass1_store_id(emit_t *emit, qstr qstr) {
get_id_for_modification(emit->scope, qstr);
STATIC void emit_pass1_store_id(emit_t *emit, qstr qst) {
get_id_for_modification(emit->scope, qst);
}
STATIC void emit_pass1_delete_id(emit_t *emit, qstr qstr) {
id_info_t *id = get_id_for_modification(emit->scope, qstr);
STATIC void emit_pass1_delete_id(emit_t *emit, qstr qst) {
id_info_t *id = get_id_for_modification(emit->scope, qst);
// this flag is unused
//id->flags |= ID_FLAG_IS_DELETED;
(void)id; // suppress compiler warning
......
......@@ -82,8 +82,8 @@ void scope_free(scope_t *scope) {
m_del(scope_t, scope, 1);
}
id_info_t *scope_find_or_add_id(scope_t *scope, qstr qstr, bool *added) {
id_info_t *id_info = scope_find(scope, qstr);
id_info_t *scope_find_or_add_id(scope_t *scope, qstr qst, bool *added) {
id_info_t *id_info = scope_find(scope, qst);
if (id_info != NULL) {
*added = false;
return id_info;
......@@ -103,33 +103,33 @@ id_info_t *scope_find_or_add_id(scope_t *scope, qstr qstr, bool *added) {
id_info->kind = 0;
id_info->flags = 0;
id_info->local_num = 0;
id_info->qstr = qstr;
id_info->qst = qst;
*added = true;
return id_info;
}
id_info_t *scope_find(scope_t *scope, qstr qstr) {
id_info_t *scope_find(scope_t *scope, qstr qst) {
for (mp_uint_t i = 0; i < scope->id_info_len; i++) {
if (scope->id_info[i].qstr == qstr) {
if (scope->id_info[i].qst == qst) {
return &scope->id_info[i];
}
}
return NULL;
}
id_info_t *scope_find_global(scope_t *scope, qstr qstr) {
id_info_t *scope_find_global(scope_t *scope, qstr qst) {
while (scope->parent != NULL) {
scope = scope->parent;
}
return scope_find(scope, qstr);