diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-11-26 23:20:47 +0100 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-11-27 17:27:07 +0100 |
commit | 9e6eaf742cb4a66da9f9a15195420e43633c8fe6 (patch) | |
tree | da0118a20bf9c3e557cc6ae5d9816488975ec8d8 | |
parent | c60a5e93310bbba8bf15c2a717061f41481e22d8 (diff) | |
download | sparse-9e6eaf742cb4a66da9f9a15195420e43633c8fe6.tar.gz |
add helper replace_binop()
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>
-rw-r--r-- | simplify.c | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -498,6 +498,23 @@ static inline int replace_binop_value(struct instruction *insn, int op, long lon } /// +// 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 static inline int replace_opcode(struct instruction *insn, int op) |