26 #ifndef MICROPY_INCLUDED_PY_ASMXTENSA_H 27 #define MICROPY_INCLUDED_PY_ASMXTENSA_H 39 #define ASM_XTENSA_REG_A0 (0) 40 #define ASM_XTENSA_REG_A1 (1) 41 #define ASM_XTENSA_REG_A2 (2) 42 #define ASM_XTENSA_REG_A3 (3) 43 #define ASM_XTENSA_REG_A4 (4) 44 #define ASM_XTENSA_REG_A5 (5) 45 #define ASM_XTENSA_REG_A6 (6) 46 #define ASM_XTENSA_REG_A7 (7) 47 #define ASM_XTENSA_REG_A8 (8) 48 #define ASM_XTENSA_REG_A9 (9) 49 #define ASM_XTENSA_REG_A10 (10) 50 #define ASM_XTENSA_REG_A11 (11) 51 #define ASM_XTENSA_REG_A12 (12) 52 #define ASM_XTENSA_REG_A13 (13) 53 #define ASM_XTENSA_REG_A14 (14) 54 #define ASM_XTENSA_REG_A15 (15) 57 #define ASM_XTENSA_CCZ_EQ (0) 58 #define ASM_XTENSA_CCZ_NE (1) 61 #define ASM_XTENSA_CC_NONE (0) 62 #define ASM_XTENSA_CC_EQ (1) 63 #define ASM_XTENSA_CC_LT (2) 64 #define ASM_XTENSA_CC_LTU (3) 65 #define ASM_XTENSA_CC_ALL (4) 66 #define ASM_XTENSA_CC_BC (5) 67 #define ASM_XTENSA_CC_ANY (8) 68 #define ASM_XTENSA_CC_NE (9) 69 #define ASM_XTENSA_CC_GE (10) 70 #define ASM_XTENSA_CC_GEU (11) 71 #define ASM_XTENSA_CC_NALL (12) 72 #define ASM_XTENSA_CC_BS (13) 75 #define ASM_XTENSA_ENCODE_RRR(op0, op1, op2, r, s, t) \ 76 ((((uint32_t)op2) << 20) | (((uint32_t)op1) << 16) | ((r) << 12) | ((s) << 8) | ((t) << 4) | (op0)) 77 #define ASM_XTENSA_ENCODE_RRI4(op0, op1, r, s, t, imm4) \ 78 (((imm4) << 20) | ((op1) << 16) | ((r) << 12) | ((s) << 8) | ((t) << 4) | (op0)) 79 #define ASM_XTENSA_ENCODE_RRI8(op0, r, s, t, imm8) \ 80 ((((uint32_t)imm8) << 16) | ((r) << 12) | ((s) << 8) | ((t) << 4) | (op0)) 81 #define ASM_XTENSA_ENCODE_RI16(op0, t, imm16) \ 82 (((imm16) << 8) | ((t) << 4) | (op0)) 83 #define ASM_XTENSA_ENCODE_RSR(op0, op1, op2, rs, t) \ 84 (((op2) << 20) | ((op1) << 16) | ((rs) << 8) | ((t) << 4) | (op0)) 85 #define ASM_XTENSA_ENCODE_CALL(op0, n, offset) \ 86 (((offset) << 6) | ((n) << 4) | (op0)) 87 #define ASM_XTENSA_ENCODE_CALLX(op0, op1, op2, r, s, m, n) \ 88 ((((uint32_t)op2) << 20) | (((uint32_t)op1) << 16) | ((r) << 12) | ((s) << 8) | ((m) << 6) | ((n) << 4) | (op0)) 89 #define ASM_XTENSA_ENCODE_BRI8(op0, r, s, m, n, imm8) \ 90 (((imm8) << 16) | ((r) << 12) | ((s) << 8) | ((m) << 6) | ((n) << 4) | (op0)) 91 #define ASM_XTENSA_ENCODE_BRI12(op0, s, m, n, imm12) \ 92 (((imm12) << 12) | ((s) << 8) | ((m) << 6) | ((n) << 4) | (op0)) 93 #define ASM_XTENSA_ENCODE_RRRN(op0, r, s, t) \ 94 (((r) << 12) | ((s) << 8) | ((t) << 4) | (op0)) 95 #define ASM_XTENSA_ENCODE_RI7(op0, s, imm7) \ 96 ((((imm7) & 0xf) << 12) | ((s) << 8) | ((imm7) & 0x70) | (op0)) 120 static inline void asm_xtensa_op_addi(
asm_xtensa_t *as,
uint reg_dest,
uint reg_src,
int imm8) {
176 static inline void asm_xtensa_op_movi_n(
asm_xtensa_t *as,
uint reg_dest,
int imm4) {
188 static inline void asm_xtensa_op_ret_n(
asm_xtensa_t *as) {
247 #define ASM_WORD_SIZE (4) 249 #define REG_RET ASM_XTENSA_REG_A2 250 #define REG_ARG_1 ASM_XTENSA_REG_A2 251 #define REG_ARG_2 ASM_XTENSA_REG_A3 252 #define REG_ARG_3 ASM_XTENSA_REG_A4 253 #define REG_ARG_4 ASM_XTENSA_REG_A5 254 #define REG_ARG_5 ASM_XTENSA_REG_A6 256 #define REG_TEMP0 ASM_XTENSA_REG_A2 257 #define REG_TEMP1 ASM_XTENSA_REG_A3 258 #define REG_TEMP2 ASM_XTENSA_REG_A4 260 #define REG_LOCAL_1 ASM_XTENSA_REG_A12 261 #define REG_LOCAL_2 ASM_XTENSA_REG_A13 262 #define REG_LOCAL_3 ASM_XTENSA_REG_A14 263 #define REG_LOCAL_NUM (3) 265 #define ASM_T asm_xtensa_t 266 #define ASM_END_PASS asm_xtensa_end_pass 267 #define ASM_ENTRY asm_xtensa_entry 268 #define ASM_EXIT asm_xtensa_exit 270 #define ASM_JUMP asm_xtensa_j_label 271 #define ASM_JUMP_IF_REG_ZERO(as, reg, label) \ 272 asm_xtensa_bccz_reg_label(as, ASM_XTENSA_CCZ_EQ, reg, label) 273 #define ASM_JUMP_IF_REG_NONZERO(as, reg, label) \ 274 asm_xtensa_bccz_reg_label(as, ASM_XTENSA_CCZ_NE, reg, label) 275 #define ASM_JUMP_IF_REG_EQ(as, reg1, reg2, label) \ 276 asm_xtensa_bcc_reg_reg_label(as, ASM_XTENSA_CC_EQ, reg1, reg2, label) 277 #define ASM_CALL_IND(as, ptr, idx) \ 279 asm_xtensa_mov_reg_i32(as, ASM_XTENSA_REG_A0, (uint32_t)ptr); \ 280 asm_xtensa_op_callx0(as, ASM_XTENSA_REG_A0); \ 283 #define ASM_MOV_REG_TO_LOCAL(as, reg, local_num) asm_xtensa_mov_local_reg(as, (local_num), (reg)) 284 #define ASM_MOV_IMM_TO_REG(as, imm, reg) asm_xtensa_mov_reg_i32(as, (reg), (imm)) 285 #define ASM_MOV_ALIGNED_IMM_TO_REG(as, imm, reg) asm_xtensa_mov_reg_i32(as, (reg), (imm)) 286 #define ASM_MOV_IMM_TO_LOCAL_USING(as, imm, local_num, reg_temp) \ 288 asm_xtensa_mov_reg_i32(as, (reg_temp), (imm)); \ 289 asm_xtensa_mov_local_reg(as, (local_num), (reg_temp)); \ 291 #define ASM_MOV_LOCAL_TO_REG(as, local_num, reg) asm_xtensa_mov_reg_local(as, (reg), (local_num)) 292 #define ASM_MOV_REG_REG(as, reg_dest, reg_src) asm_xtensa_op_mov_n((as), (reg_dest), (reg_src)) 293 #define ASM_MOV_LOCAL_ADDR_TO_REG(as, local_num, reg) asm_xtensa_mov_reg_local_addr(as, (reg), (local_num)) 295 #define ASM_LSL_REG_REG(as, reg_dest, reg_shift) \ 297 asm_xtensa_op_ssl((as), (reg_shift)); \ 298 asm_xtensa_op_sll((as), (reg_dest), (reg_dest)); \ 300 #define ASM_ASR_REG_REG(as, reg_dest, reg_shift) \ 302 asm_xtensa_op_ssr((as), (reg_shift)); \ 303 asm_xtensa_op_sra((as), (reg_dest), (reg_dest)); \ 305 #define ASM_OR_REG_REG(as, reg_dest, reg_src) asm_xtensa_op_or((as), (reg_dest), (reg_dest), (reg_src)) 306 #define ASM_XOR_REG_REG(as, reg_dest, reg_src) asm_xtensa_op_xor((as), (reg_dest), (reg_dest), (reg_src)) 307 #define ASM_AND_REG_REG(as, reg_dest, reg_src) asm_xtensa_op_and((as), (reg_dest), (reg_dest), (reg_src)) 308 #define ASM_ADD_REG_REG(as, reg_dest, reg_src) asm_xtensa_op_add((as), (reg_dest), (reg_dest), (reg_src)) 309 #define ASM_SUB_REG_REG(as, reg_dest, reg_src) asm_xtensa_op_sub((as), (reg_dest), (reg_dest), (reg_src)) 310 #define ASM_MUL_REG_REG(as, reg_dest, reg_src) asm_xtensa_op_mull((as), (reg_dest), (reg_dest), (reg_src)) 312 #define ASM_LOAD_REG_REG_OFFSET(as, reg_dest, reg_base, word_offset) asm_xtensa_op_l32i_n((as), (reg_dest), (reg_base), (word_offset)) 313 #define ASM_LOAD8_REG_REG(as, reg_dest, reg_base) asm_xtensa_op_l8ui((as), (reg_dest), (reg_base), 0) 314 #define ASM_LOAD16_REG_REG(as, reg_dest, reg_base) asm_xtensa_op_l16ui((as), (reg_dest), (reg_base), 0) 315 #define ASM_LOAD32_REG_REG(as, reg_dest, reg_base) asm_xtensa_op_l32i_n((as), (reg_dest), (reg_base), 0) 317 #define ASM_STORE_REG_REG_OFFSET(as, reg_dest, reg_base, word_offset) asm_xtensa_op_s32i_n((as), (reg_dest), (reg_base), (word_offset)) 318 #define ASM_STORE8_REG_REG(as, reg_src, reg_base) asm_xtensa_op_s8i((as), (reg_src), (reg_base), 0) 319 #define ASM_STORE16_REG_REG(as, reg_src, reg_base) asm_xtensa_op_s16i((as), (reg_src), (reg_base), 0) 320 #define ASM_STORE32_REG_REG(as, reg_src, reg_base) asm_xtensa_op_s32i_n((as), (reg_src), (reg_base), 0) 322 #endif // GENERIC_ASM_API 324 #endif // MICROPY_INCLUDED_PY_ASMXTENSA_H #define ASM_XTENSA_ENCODE_CALLX(op0, op1, op2, r, s, m, n)
#define ASM_XTENSA_ENCODE_BRI12(op0, s, m, n, imm12)
void asm_xtensa_end_pass(asm_xtensa_t *as)
void asm_xtensa_j_label(asm_xtensa_t *as, uint label)
#define ASM_XTENSA_ENCODE_CALL(op0, n, offset)
void asm_xtensa_bccz_reg_label(asm_xtensa_t *as, uint cond, uint reg, uint label)
void asm_xtensa_mov_reg_local(asm_xtensa_t *as, uint reg_dest, int local_num)
void asm_xtensa_op16(asm_xtensa_t *as, uint16_t op)
void asm_xtensa_op24(asm_xtensa_t *as, uint32_t op)
void asm_xtensa_mov_local_reg(asm_xtensa_t *as, int local_num, uint reg_src)
void asm_xtensa_entry(asm_xtensa_t *as, int num_locals)
void asm_xtensa_setcc_reg_reg_reg(asm_xtensa_t *as, uint cond, uint reg_dest, uint reg_src1, uint reg_src2)
struct _asm_xtensa_t asm_xtensa_t
#define ASM_XTENSA_ENCODE_RRRN(op0, r, s, t)
void asm_xtensa_exit(asm_xtensa_t *as)
#define ASM_XTENSA_ENCODE_RRR(op0, op1, op2, r, s, t)
#define ASM_XTENSA_ENCODE_RRI8(op0, r, s, t, imm8)
void asm_xtensa_mov_reg_i32(asm_xtensa_t *as, uint reg_dest, uint32_t i32)
#define ASM_XTENSA_ENCODE_RI16(op0, t, imm16)
void asm_xtensa_mov_reg_local_addr(asm_xtensa_t *as, uint reg_dest, int local_num)
void asm_xtensa_bcc_reg_reg_label(asm_xtensa_t *as, uint cond, uint reg1, uint reg2, uint label)
#define ASM_XTENSA_ENCODE_RI7(op0, s, imm7)