From f506bf342af5994a2b8aa0f005e2a8fbf06b60b5 Mon Sep 17 00:00:00 2001 From: Damien George Date: Mon, 30 May 2022 11:08:54 +1000 Subject: [PATCH] py/bc: Remove unused mp_opcode_format function. This was made redundant by f2040bfc7ee033e48acef9f289790f3b4e6b74e5, which also did not update this function for the change to qstr-opcode encoding, so it does not work correctly anyway. Signed-off-by: Damien George --- py/bc.c | 32 -------------------------------- py/bc.h | 6 ------ tools/mpy-tool.py | 24 ------------------------ 3 files changed, 62 deletions(-) diff --git a/py/bc.c b/py/bc.c index 2c26d74895..e002bca262 100644 --- a/py/bc.c +++ b/py/bc.c @@ -337,35 +337,3 @@ void mp_setup_code_state_native(mp_code_state_native_t *code_state, size_t n_arg mp_setup_code_state_helper((mp_code_state_t *)code_state, n_args, n_kw, args); } #endif - -#if MICROPY_PERSISTENT_CODE_LOAD || MICROPY_PERSISTENT_CODE_SAVE - -// The following table encodes the number of bytes that a specific opcode -// takes up. Some opcodes have an extra byte, defined by MP_BC_MASK_EXTRA_BYTE. -uint mp_opcode_format(const byte *ip, size_t *opcode_size, bool count_var_uint) { - uint f = MP_BC_FORMAT(*ip); - const byte *ip_start = ip; - if (f == MP_BC_FORMAT_QSTR) { - ip += 3; - } else { - int extra_byte = (*ip & MP_BC_MASK_EXTRA_BYTE) == 0; - ip += 1; - if (f == MP_BC_FORMAT_VAR_UINT) { - if (count_var_uint) { - while ((*ip++ & 0x80) != 0) { - } - } - } else if (f == MP_BC_FORMAT_OFFSET) { - if ((*ip & 0x80) == 0) { - ip += 1; - } else { - ip += 2; - } - } - ip += extra_byte; - } - *opcode_size = ip - ip_start; - return f; -} - -#endif // MICROPY_PERSISTENT_CODE_LOAD || MICROPY_PERSISTENT_CODE_SAVE diff --git a/py/bc.h b/py/bc.h index a888164f18..6350eee52e 100644 --- a/py/bc.h +++ b/py/bc.h @@ -292,12 +292,6 @@ const byte *mp_bytecode_print_str(const mp_print_t *print, const byte *ip_start, #define MP_TAGPTR_TAG1(x) ((uintptr_t)(x) & 2) #define MP_TAGPTR_MAKE(ptr, tag) ((void *)((uintptr_t)(ptr) | (tag))) -#if MICROPY_PERSISTENT_CODE_LOAD || MICROPY_PERSISTENT_CODE_SAVE - -uint mp_opcode_format(const byte *ip, size_t *opcode_size, bool count_var_uint); - -#endif - static inline void mp_module_context_alloc_tables(mp_module_context_t *context, size_t n_qstr, size_t n_obj) { #if MICROPY_EMIT_BYTECODE_USES_QSTR_TABLE size_t nq = (n_qstr * sizeof(qstr_short_t) + sizeof(mp_uint_t) - 1) / sizeof(mp_uint_t); diff --git a/tools/mpy-tool.py b/tools/mpy-tool.py index 20ccc87d43..fb18eb8cbd 100755 --- a/tools/mpy-tool.py +++ b/tools/mpy-tool.py @@ -326,30 +326,6 @@ def mp_small_int_fits(i): return -0x2000 <= i <= 0x1FFF -# this function mirrors that in py/bc.c -def mp_opcode_format(bytecode, ip, count_var_uint): - opcode = bytecode[ip] - ip_start = ip - f = (0x000003A4 >> (2 * ((opcode) >> 4))) & 3 - if f == MP_BC_FORMAT_QSTR: - ip += 3 - else: - extra_byte = (opcode & MP_BC_MASK_EXTRA_BYTE) == 0 - ip += 1 - if f == MP_BC_FORMAT_VAR_UINT: - if count_var_uint: - while bytecode[ip] & 0x80 != 0: - ip += 1 - ip += 1 - elif f == MP_BC_FORMAT_OFFSET: - if bytecode[ip] & 0x80 == 0: - ip += 1 - else: - ip += 2 - ip += extra_byte - return f, ip - ip_start - - def mp_opcode_decode(bytecode, ip): opcode = bytecode[ip] ip_start = ip