aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/simplify.c
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-08-11 14:42:08 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-08-22 09:25:34 +0200
commitbea53a10f6db02d7253fa9f05390bc4caad14628 (patch)
treef5af753adf8072f36846e12e8dfcb85b69319c4a /simplify.c
parentbb6d1415822f539e44b825f180a063b917c07612 (diff)
downloadsparse-dev-bea53a10f6db02d7253fa9f05390bc4caad14628.tar.gz
document simplify_mask_or() & simplify_mask_or_and()
These function are relatively complex and will be even more. Add minimal documentation to them. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'simplify.c')
-rw-r--r--simplify.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/simplify.c b/simplify.c
index b9671dbf..a5bed73f 100644
--- a/simplify.c
+++ b/simplify.c
@@ -577,6 +577,17 @@ undef:
return NULL;
}
+///
+// Simplifications
+// ^^^^^^^^^^^^^^^
+
+///
+// try to simplify OP(OR(AND(x, M'), b), K)
+// @insn: the 'masking' instruction
+// @mask: the mask associated to @insn (M)
+// @ora: one of the OR's operands
+// @orb: the other OR's operand
+// @return: 0 if no changes have been made, one or more REPEAT_* flags otherwise.
static int simplify_mask_or_and(struct instruction *insn, unsigned long long mask,
pseudo_t ora, pseudo_t orb)
{
@@ -596,6 +607,16 @@ static int simplify_mask_or_and(struct instruction *insn, unsigned long long mas
return replace_pseudo(insn, &insn->src1, orb);
}
+///
+// try to simplify OP(OR(a, b), K)
+// @insn: the 'masking' instruction
+// @mask: the mask associated to @insn (M):
+// @or: the OR instruction
+// @return: 0 if no changes have been made, one or more REPEAT_* flags otherwise.
+//
+// For the @mask (M):
+// * if OP(x, K) == AND(x, M), @mask M is K
+// * if OP(x, K) == LSR(x, S), @mask M is (-1 << S)
static int simplify_mask_or(struct instruction *insn, unsigned long long mask, struct instruction *or)
{
pseudo_t src1 = or->src1;