Add macros to use a pdeq as a stack
[libfirm] / ir / adt / bitset_std.h
index 7183e87..8d94b2f 100644 (file)
@@ -8,30 +8,30 @@ typedef unsigned int bitset_unit_t;
 /**
  * Units needed for a given highest bit.
  * This implementation always allocates units in a multiple of 16 bytes.
- * @param highest_bit The highest bit that should be storable.
+ * @param size The size of the bitset in bits.
  * @return The number of units needed.
  */
-#define _bitset_units(highest_bit) (round_up2(highest_bit, BS_UNIT_SIZE_BITS) / BS_UNIT_SIZE_BITS)
+#define _bitset_units(size) (round_up2(size, BS_UNIT_SIZE_BITS) / BS_UNIT_SIZE_BITS)
 
 /**
  * Compute the size in bytes needed for a bitseti, overall.
  * This also include the size for the bitset data structure.
  * This implementation computes the size in wat, that the bitset units
  * can be aligned to 16 bytes.
- * @param highest_bit The highest bit that shall be storable.
+ * @param size The size of the bitset in bits.
  * @return The overall amount of bytes needed for that bitset.
  */
-#define _bitset_overall_size(bitset_base_size,highest_bit) \
-       (bitset_base_size + _bitset_units(highest_bit) * BS_UNIT_SIZE)
+#define _bitset_overall_size(bitset_base_size,size) \
+       (bitset_base_size + _bitset_units(size) * BS_UNIT_SIZE)
 
 /**
  * calculate the pointer to the data space of the bitset.
  * @param data The base address of the allocated memory
  * @param bitset_base_size The size of the basical bitset data structure
- * which hast to be taken into account.
- * @param hightest_bit The highest bit that will occur in the bitset.
+ * which has to be taken into account.
+ * @param size The size of the bitset in bits.
  */
-#define _bitset_data_ptr(data,bitset_base_size,highest_bit) \
+#define _bitset_data_ptr(data,bitset_base_size,size) \
        ((bitset_unit_t *) ((char *) data + bitset_base_size))
 
 
@@ -64,6 +64,12 @@ typedef unsigned int bitset_unit_t;
  */
 #define _bitset_inside_flip(unit_ptr,bit) (*unit_ptr) ^= ~(1 << (bit))
 
+/**
+ * Flip a whole unit.
+ * @param unit_ptr The pointer to the unit.
+ */
+#define _bitset_inside_flip_unit(unit_ptr) (*unit_ptr) = ~(*unit_ptr)
+
 /**
  * Count the number of leading zeroes in a unit.
  * @param unit A pointer to the unit.