aboutsummaryrefslogtreecommitdiff
path: root/py/emit.h
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2016-12-09 17:03:33 +1100
committerDamien George <damien.p.george@gmail.com>2016-12-09 17:07:38 +1100
commitf76b1bfa9f59fcfa03837c6934ad51d2db3ff4a3 (patch)
treedd4882552d3fa3335c7e7f32f218231d967361fa /py/emit.h
parentad297a1950c74c35c90dd655ae9a69d33ed28dc0 (diff)
py: Add inline Xtensa assembler.
This patch adds the MICROPY_EMIT_INLINE_XTENSA option, which, when enabled, allows the @micropython.asm_xtensa decorator to be used. The following opcodes are currently supported (ax is a register, a0-a15): ret_n() callx0(ax) j(label) jx(ax) beqz(ax, label) bnez(ax, label) mov(ax, ay) movi(ax, imm) # imm can be full 32-bit, uses l32r if needed and_(ax, ay, az) or_(ax, ay, az) xor(ax, ay, az) add(ax, ay, az) sub(ax, ay, az) mull(ax, ay, az) l8ui(ax, ay, imm) l16ui(ax, ay, imm) l32i(ax, ay, imm) s8i(ax, ay, imm) s16i(ax, ay, imm) s32i(ax, ay, imm) l16si(ax, ay, imm) addi(ax, ay, imm) ball(ax, ay, label) bany(ax, ay, label) bbc(ax, ay, label) bbs(ax, ay, label) beq(ax, ay, label) bge(ax, ay, label) bgeu(ax, ay, label) blt(ax, ay, label) bnall(ax, ay, label) bne(ax, ay, label) bnone(ax, ay, label) Upon entry to the assembly function the registers a0, a12, a13, a14 are pushed to the stack and the stack pointer (a1) decreased by 16. Upon exit, these registers and the stack pointer are restored, and ret.n is executed to return to the caller (caller address is in a0). Note that the ABI for the Xtensa emitters is non-windowing.
Diffstat (limited to 'py/emit.h')
-rw-r--r--py/emit.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/py/emit.h b/py/emit.h
index 122df8e7d..6080b83c4 100644
--- a/py/emit.h
+++ b/py/emit.h
@@ -272,9 +272,13 @@ typedef struct _emit_inline_asm_method_table_t {
} emit_inline_asm_method_table_t;
extern const emit_inline_asm_method_table_t emit_inline_thumb_method_table;
+extern const emit_inline_asm_method_table_t emit_inline_xtensa_method_table;
emit_inline_asm_t *emit_inline_thumb_new(mp_uint_t max_num_labels);
+emit_inline_asm_t *emit_inline_xtensa_new(mp_uint_t max_num_labels);
+
void emit_inline_thumb_free(emit_inline_asm_t *emit);
+void emit_inline_xtensa_free(emit_inline_asm_t *emit);
#if MICROPY_WARNINGS
void mp_emitter_warning(pass_kind_t pass, const char *msg);