Skip to content

Commit

Permalink
Add resolve function for Mod to CS regs
Browse files Browse the repository at this point in the history
  • Loading branch information
Rot127 committed Nov 12, 2023
1 parent 7abaaad commit 55c5644
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
18 changes: 18 additions & 0 deletions handwritten/hexagon_il_c/functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -743,3 +743,21 @@ RZ_IPI RZ_OWN RzILOpEffect *hex_cancel_slot(RZ_BORROW HexPkt *pkt, ut8 slot) {
// return SETG("slot_cancelled", LOGOR(VARG("slot_cancelled"), SHIFTL0(U8(1), U8(slot))));
return EMPTY();
}

RzILOpPure *hex_get_corresponding_cs(RZ_BORROW HexPkt *pkt, const HexOp *Mu) {
rz_return_val_if_fail(Mu && Mu->class == HEX_REG_CLASS_MOD_REGS, NULL);
HexOp cs_reg = { 0 };
if (Mu->op.reg == 0) {
// M0 (C6) return CS0
cs_reg.class = HEX_REG_CLASS_CTR_REGS;
cs_reg.op.reg = 12;
return hex_read_reg(pkt, &cs_reg, true);
} else if (Mu->op.reg == 1) {
// M1 (C7) return CS1
cs_reg.class = HEX_REG_CLASS_CTR_REGS;
cs_reg.op.reg = 13;
return hex_read_reg(pkt, &cs_reg, true);
}
rz_warn_if_reached();
return NULL;
}
1 change: 1 addition & 0 deletions handwritten/hexagon_il_h/declarations.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ RZ_IPI RZ_OWN RzILOpEffect *hex_commit_packet(HexInsnPktBundle *bundle);
RZ_IPI RZ_OWN RzILOpEffect *hex_write_reg(RZ_BORROW HexInsnPktBundle *bundle, const HexOp *op, RzILOpPure *val);
RZ_IPI RZ_OWN RzILOpPure *hex_read_reg(RZ_BORROW HexPkt *pkt, const HexOp *op, bool tmp_reg);
RZ_IPI RZ_OWN RzILOpEffect *hex_cancel_slot(RZ_BORROW HexPkt *pkt, ut8 slot);
RzILOpPure *hex_get_corresponding_cs(RZ_BORROW HexPkt *pkt, const HexOp *Mu);
1 change: 1 addition & 0 deletions handwritten/hexagon_il_h/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#define DEC(val, size) SUB(val, UN(size, 1))
#define HEX_STORE_SLOT_CANCELLED(pkt, slot) hex_cancel_slot(pkt, slot)
#define HEX_FCIRC_ADD(bundle, RxV, offset, mu, CS) hex_fcircadd(bundle, RxV, offset, mu, CS)
#define HEX_GET_CORRESPONDING_CS(pkt, Mu) hex_get_corresponding_cs(pkt, Mu)

#define HEX_IMMUTABLE_REG (~0)
#define HEX_NOT_MASKED 0
2 changes: 1 addition & 1 deletion rzil_compiler

0 comments on commit 55c5644

Please sign in to comment.