summaryrefslogtreecommitdiffstatshomepage
path: root/py/emitnative.c
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2024-03-07 11:38:27 +1100
committerDamien George <damien@micropython.org>2024-06-21 16:21:27 +1000
commit9dbc787ce8dda9df39eb68c03de144155b2253f0 (patch)
treef05e960eb7f1bc173570c2bca0901524ed813407 /py/emitnative.c
parente2ae03e97963c2d338752bc4cbe8bd87981014fb (diff)
downloadmicropython-9dbc787ce8dda9df39eb68c03de144155b2253f0.tar.gz
micropython-9dbc787ce8dda9df39eb68c03de144155b2253f0.zip
py/emitndebug: Add native debug emitter.
This emitter prints out pseudo-machine instructions, instead of the usual output of the native emitter. It can be enabled on any port via `MICROPY_EMIT_NATIVE_DEBUG` (make sure other native emitters are disabled) but the easiest way to use it is with mpy-cross: $ mpy-cross -march=debug file.py Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'py/emitnative.c')
-rw-r--r--py/emitnative.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/py/emitnative.c b/py/emitnative.c
index 99e5a24c1b..9d3f698b25 100644
--- a/py/emitnative.c
+++ b/py/emitnative.c
@@ -59,7 +59,7 @@
#endif
// wrapper around everything in this file
-#if N_X64 || N_X86 || N_THUMB || N_ARM || N_XTENSA || N_XTENSAWIN || N_RV32
+#if N_X64 || N_X86 || N_THUMB || N_ARM || N_XTENSA || N_XTENSAWIN || N_RV32 || N_DEBUG
// C stack layout for native functions:
// 0: nlr_buf_t [optional]
@@ -348,6 +348,8 @@ static void emit_native_mov_reg_state_addr(emit_t *emit, int reg_dest, int local
static void emit_native_mov_reg_qstr(emit_t *emit, int arg_reg, qstr qst) {
#if MICROPY_PERSISTENT_CODE_SAVE
ASM_LOAD16_REG_REG_OFFSET(emit->as, arg_reg, REG_QSTR_TABLE, mp_emit_common_use_qstr(emit->emit_common, qst));
+ #elif defined(ASM_MOV_REG_QSTR)
+ ASM_MOV_REG_QSTR(emit->as, arg_reg, qst);
#else
ASM_MOV_REG_IMM(emit->as, arg_reg, qst);
#endif
@@ -2604,6 +2606,8 @@ static void emit_native_binary_op(emit_t *emit, mp_binary_op_t op) {
default:
break;
}
+ #elif N_DEBUG
+ asm_debug_setcc_reg_reg_reg(emit->as, op_idx, REG_RET, REG_ARG_2, reg_rhs);
#else
#error not implemented
#endif