projects
/
libfirm
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
removed depency of bool type and stdbool.h (not C89)
[libfirm]
/
ir
/
adt
/
bitset_std.h
diff --git
a/ir/adt/bitset_std.h
b/ir/adt/bitset_std.h
index
e1fa6eb
..
49edee2
100644
(file)
--- a/
ir/adt/bitset_std.h
+++ b/
ir/adt/bitset_std.h
@@
-1,33
+1,47
@@
+/** Use ordinary ints as unit types. */
+typedef unsigned int bitset_unit_t;
+
+#define BITSET_UNIT_FMT "%0x"
+#define BITSET_UNIT_ALL_ONE ((unsigned int) -1)
+
/**
* Units needed for a given highest bit.
* This implementation always allocates units in a multiple of 16 bytes.
/**
* 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.
*/
* @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.
/**
* 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.
*/
* @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
/**
* 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 has
t
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) \
- ((unsigned long *) ((char *) data + bitset_base_size))
+#define _bitset_data_ptr(data,bitset_base_size,size) \
+ ((bitset_unit_t *) ((char *) data + bitset_base_size))
+
+/**
+ * Clear some units from a certain address on.
+ * @param addr The address from where to clear.
+ * @param n The number of units to set to 0.
+ */
+#define _bitset_inside_clear_units(addr,n) \
+ memset(addr, 0, n * BS_UNIT_SIZE)
/**
* Set a bit in a unit.
/**
* Set a bit in a unit.
@@
-63,11
+77,11
@@
* @param unit A pointer to the unit.
* @return The Number of leading zeroes.
*/
* @param unit A pointer to the unit.
* @return The Number of leading zeroes.
*/
-#define _bitset_inside_ntz(unit_ptr) _
std_bitset
_inside_ntz(unit_ptr)
-static INLINE
int _std_bitset_ntz(unsigned long
*unit_ptr)
+#define _bitset_inside_ntz(unit_ptr) _
bitset_std
_inside_ntz(unit_ptr)
+static INLINE
bitset_pos_t _bitset_std_inside_ntz(bitset_unit_t
*unit_ptr)
{
unsigned long data = *unit_ptr;
{
unsigned long data = *unit_ptr;
- return 32 - nlz(~data & (data - 1));
+ return 32 -
(bitset_pos_t)
nlz(~data & (data - 1));
}
/**
}
/**
@@
-85,7
+99,7
@@
static INLINE int _std_bitset_ntz(unsigned long *unit_ptr)
* @return 1, if the bit is set, 0 otherise.
*/
#define _bitset_inside_is_set(unit_ptr,bit) \
* @return 1, if the bit is set, 0 otherise.
*/
#define _bitset_inside_is_set(unit_ptr,bit) \
-
(((*unit_ptr) & (1 << (bit))) != NULL
)
+
(((*unit_ptr) & (1 << (bit))) != 0
)
/**
* count the number of bits set in a unit.
/**
* count the number of bits set in a unit.
@@
-100,8
+114,3
@@
static INLINE int _std_bitset_ntz(unsigned long *unit_ptr)
#define _bitset_inside_binop_andnot(tgt,src) ((*tgt) &= ~(*src))
#define _bitset_inside_binop_or(tgt,src) ((*tgt) |= (*src))
#define _bitset_inside_binop_xor(tgt,src) ((*tgt) ^= (*src))
#define _bitset_inside_binop_andnot(tgt,src) ((*tgt) &= ~(*src))
#define _bitset_inside_binop_or(tgt,src) ((*tgt) |= (*src))
#define _bitset_inside_binop_xor(tgt,src) ((*tgt) ^= (*src))
-
-#define _bitset_inside_binop_with_zero_and(tgt) ((*tgt) &= 0UL)
-#define _bitset_inside_binop_with_zero_andnot(tgt) ((*tgt) &= ~0UL)
-#define _bitset_inside_binop_with_zero_or(tgt) ((*tgt) |= 0UL)
-#define _bitset_inside_binop_with_zero_xor(tgt) ((*tgt) ^= 0UL)