aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2016-12-17 10:32:48 +0100
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-06-23 15:29:23 +0200
commit5d80f2005f30f4a55e3c0bc6c6e7b8a432bfc395 (patch)
tree2da4d0dc35bc2494ff9f1209b131b3272155297d
parent5c189c40bb2c8fd7f5652f930ddb2869a1d1a9ff (diff)
downloadsparse-dev-5d80f2005f30f4a55e3c0bc6c6e7b8a432bfc395.tar.gz
new helper: def_opcode()
Getting the opcode corresponding to the instruction defining a pseudo *if* the psedudo has such an instruction (PSEUDO_REG) is an common operation in the simplification phase. Add a helper, def_opcode() to make the code a bit easier to read. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--simplify.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/simplify.c b/simplify.c
index e3bc3399..6c05eb04 100644
--- a/simplify.c
+++ b/simplify.c
@@ -370,6 +370,13 @@ static int replace_with_pseudo(struct instruction *insn, pseudo_t pseudo)
return REPEAT_CSE;
}
+static inline int def_opcode(pseudo_t p)
+{
+ if (p->type != PSEUDO_REG)
+ return OP_BADOP;
+ return p->def->opcode;
+}
+
static unsigned int value_size(long long value)
{
value >>= 8;