diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2016-12-18 22:18:00 +0100 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-10-20 22:35:08 +0200 |
| commit | ce5f04a050cbc8bd92f718765616199a7f8c958a (patch) | |
| tree | c88734578207d737e5086bdcdb84c1bf59929f99 | |
| parent | 97e6515a7944b2ed9ec5be4614066632682559d7 (diff) | |
| download | sparse-dev-ce5f04a050cbc8bd92f718765616199a7f8c958a.tar.gz | |
unop: add helper replace_with_unop()
Some simplifications reduce to transforming a binop into an unop.
Add an helper for making this change easier and more readable.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
| -rw-r--r-- | simplify.c | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -470,6 +470,20 @@ static inline int replace_with_value(struct instruction *insn, long long val) return replace_with_pseudo(insn, value_pseudo(val)); } +/// +// replace a binop with an unop +// @insn: the instruction to be replaced +// @op: the instruction's new opcode +// @src: the instruction's new operand +// @return: REPEAT_CSE +static inline int replace_with_unop(struct instruction *insn, int op, pseudo_t src) +{ + insn->opcode = op; + replace_pseudo(insn, &insn->src1, src); + remove_usage(insn->src2, &insn->src2); + return REPEAT_CSE; +} + static inline int def_opcode(pseudo_t p) { if (p->type != PSEUDO_REG) |
