From 55c56447197574fef1743bc8e0fb165b3ea6e959 Mon Sep 17 00:00:00 2001 From: Rot127 Date: Sun, 12 Nov 2023 15:14:09 -0500 Subject: [PATCH] Add resolve function for Mod to CS regs --- handwritten/hexagon_il_c/functions.c | 18 ++++++++++++++++++ handwritten/hexagon_il_h/declarations.h | 1 + handwritten/hexagon_il_h/macros.h | 1 + rzil_compiler | 2 +- 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/handwritten/hexagon_il_c/functions.c b/handwritten/hexagon_il_c/functions.c index 565ca26a..689cc92a 100644 --- a/handwritten/hexagon_il_c/functions.c +++ b/handwritten/hexagon_il_c/functions.c @@ -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; +} \ No newline at end of file diff --git a/handwritten/hexagon_il_h/declarations.h b/handwritten/hexagon_il_h/declarations.h index 253a897e..2e70c351 100644 --- a/handwritten/hexagon_il_h/declarations.h +++ b/handwritten/hexagon_il_h/declarations.h @@ -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); diff --git a/handwritten/hexagon_il_h/macros.h b/handwritten/hexagon_il_h/macros.h index 1941fa93..9064076a 100644 --- a/handwritten/hexagon_il_h/macros.h +++ b/handwritten/hexagon_il_h/macros.h @@ -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 diff --git a/rzil_compiler b/rzil_compiler index ea83c2dc..d94615d4 160000 --- a/rzil_compiler +++ b/rzil_compiler @@ -1 +1 @@ -Subproject commit ea83c2dc1124b5f7157aef3d2a5285b4bf7534c5 +Subproject commit d94615d4bbe5494de45e1e6b9d1802b51f7a338e