[PATCH 1/2] add an helper to test the value of a pseudo against zero

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Testing the value of a pseudo against zero is relatively
common but it needs to test the type of the pseudo before
testing the value itself.

Add 2 small helpers for this: is_zero() & is_nonzero().

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 linearize.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/linearize.h b/linearize.h
index 79c0c09b5..741141070 100644
--- a/linearize.h
+++ b/linearize.h
@@ -45,6 +45,17 @@ extern struct pseudo void_pseudo;
 
 #define VOID (&void_pseudo)
 
+static inline bool is_zero(pseudo_t pseudo)
+{
+	return pseudo->type == PSEUDO_VAL && pseudo->value == 0;
+}
+
+static inline bool is_nonzero(pseudo_t pseudo)
+{
+	return pseudo->type == PSEUDO_VAL && pseudo->value != 0;
+}
+
+
 struct multijmp {
 	struct basic_block *target;
 	long long begin, end;
-- 
2.16.2

--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux