Convenience macros for node bitmaps
authorSebastian Hack <hack@ipd.info.uni-karlsruhe.de>
Wed, 10 May 2006 16:34:59 +0000 (16:34 +0000)
committerSebastian Hack <hack@ipd.info.uni-karlsruhe.de>
Wed, 10 May 2006 16:34:59 +0000 (16:34 +0000)
[r7720]

ir/ir/irbitset.h [new file with mode: 0644]

diff --git a/ir/ir/irbitset.h b/ir/ir/irbitset.h
new file mode 100644 (file)
index 0000000..3ff2add
--- /dev/null
@@ -0,0 +1,34 @@
+
+/**
+ * Some convenience macros for node bitmaps.
+ * @author Sebastian Hack
+ * @date   10.05.2006
+ */
+
+#ifndef __FIRM_IRBITSET_H
+#define __FIRM_IRBITSET_H
+
+#include "bitset.h"
+
+#define bitset_irg_malloc(irg)                bitset_malloc(get_irg_last_idx(irg))
+#define bitset_irg_obstack_alloc(obst, irg)   bitset_obstac_alloc(obst, get_irg_last_idx(irg))
+#define bitset_add_irn(bs, irn)               bitset_set((bs), get_irn_idx(irn))
+#define bitset_remv_irn(bs, irn)              bitset_clear((bs), get_irn_idx(irn))
+#define bitset_contains_irn(bs, irn)          bitset_is_set((bs), get_irn_idx(irn))
+
+
+/* Internal use. */
+#define _bsfe_get_irn(irg, elm) (elm == -1 ? NULL : get_idx_irn((irg), (unsigned) elm))
+
+/**
+ * Iterate over a bitset containing node indexes.
+ * @param irg The graph the nodes are in.
+ * @param bs  The bitset containing the indexes.
+ * @param elm A loop variable for the bitset (must be of type bitset_pos_t).
+ * @param irn An ir_node * which is set to the current node.
+ */
+#define bitset_foreach_irn(irg, bs, elm, irn) \
+       for(elm = bitset_next_set(bs, 0), irn = _bsfe_get_irn(irg, elm); elm != -1; elm = bitset_next_set(bs, elm + 1), irn = _bsfe_get_irn(irg, elm))
+
+
+#endif /* __FIRM_IRBITSET_H */