@@ -497,6 +497,23 @@ static inline int replace_binop_value(struct instruction *insn, int op, long lon
return REPEAT_CSE;
}
+///
+// replace binop's opcode and values
+// @insn: the instruction to be replaced
+// @op: the instruction's new opcode
+// @return: REPEAT_CSE
+static inline int replace_binop(struct instruction *insn, int op, pseudo_t *pa, pseudo_t a, pseudo_t *pb, pseudo_t b)
+{
+ pseudo_t olda = *pa;
+ pseudo_t oldb = *pb;
+ insn->opcode = op;
+ use_pseudo(insn, a, pa);
+ use_pseudo(insn, b, pb);
+ remove_usage(olda, pa);
+ remove_usage(oldb, pb);
+ return REPEAT_CSE;
+}
+
///
// replace the opcode of an instruction
// @return: REPEAT_CSE
Add an helper to replace a binop OP(a, b) and taking care to drop the usage of the previous operands. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> --- simplify.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)