add rbitsets_have_common function
authorMatthias Braun <matze@braunis.de>
Tue, 11 Aug 2009 11:45:18 +0000 (11:45 +0000)
committerMatthias Braun <matze@braunis.de>
Tue, 11 Aug 2009 11:45:18 +0000 (11:45 +0000)
[r26325]

include/libfirm/adt/raw_bitset.h

index 5f81b1b..e08f4ba 100644 (file)
@@ -348,6 +348,26 @@ static inline int rbitset_equal(const unsigned *bitset1,
        return memcmp(bitset1, bitset2, BITSET_SIZE_BYTES(size)) == 0;
 }
 
+/**
+ * Tests wether 2 bitsets wether at least 1 bit is set in both.
+ *
+ * @param bitset1  the first bitset
+ * @param bitset2  the second bitset
+ * @param size     size of both bitsets
+ */
+static inline int rbitsets_have_common(const unsigned *bitset1,
+                                       const unsigned *bitset2, size_t size)
+{
+       unsigned i;
+       unsigned n = BITSET_SIZE_ELEMS(size);
+
+       for (i = 0; i < n; ++i) {
+               if ((bitset1[i] & bitset2[i]) != 0)
+                       return 1;
+       }
+       return 0;
+}
+
 /**
  * Copy a raw bitset into another.
  *