Skip to content

Commit

Permalink
xtensa cs: refactor xtensa_esil.c
Browse files Browse the repository at this point in the history
  • Loading branch information
imbillow committed Oct 11, 2024
1 parent c02292f commit b270fce
Show file tree
Hide file tree
Showing 4 changed files with 914 additions and 1 deletion.
25 changes: 25 additions & 0 deletions librz/arch/isa/xtensa/xtensa.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,30 @@ bool xtensa_fini(void *user);
bool xtensa_open(XtensaContext *ctx, const char *cpu, bool big_endian);
bool xtensa_disassemble(XtensaContext *self, const ut8 *buf, int len, ut64 addr);
void xtensa_disassemble_fini(XtensaContext *self);
void xtensa_analyze_op_esil(XtensaContext *ctx, RzAnalysisOp *op);

static inline cs_xtensa_op_mem *xtensa_op_mem(cs_insn *insn, unsigned int index) {
cs_xtensa_op *op = &insn->detail->xtensa.operands[index];
rz_warn_if_fail(op->type == XTENSA_OP_MEM);
return &op->mem;
}

static inline xtensa_reg xtensa_op_reg(cs_insn *insn, unsigned int index) {
cs_xtensa_op *op = &insn->detail->xtensa.operands[index];
rz_warn_if_fail(op->type == XTENSA_OP_REG);
return op->reg;
}

static inline int32_t xtensa_op_imm(cs_insn *insn, unsigned int index) {
cs_xtensa_op *op = &insn->detail->xtensa.operands[index];
rz_warn_if_fail(op->type == XTENSA_OP_IMM);
return op->imm;
}

static inline int32_t xtensa_op_l32r(cs_insn *insn, unsigned int index) {
cs_xtensa_op *op = &insn->detail->xtensa.operands[index];
rz_warn_if_fail(op->type == XTENSA_OP_L32R);
return op->imm;
}

#endif // RIZIN_XTENSA_H
Loading

0 comments on commit b270fce

Please sign in to comment.