make cpset, pset_new API private
authorMatthias Braun <matthias.braun@kit.edu>
Mon, 16 Jul 2012 13:22:51 +0000 (15:22 +0200)
committerMatthias Braun <matthias.braun@kit.edu>
Mon, 16 Jul 2012 13:50:27 +0000 (15:50 +0200)
include/libfirm/adt/cpset.h [deleted file]
include/libfirm/adt/hashset.h [deleted file]
include/libfirm/adt/pset_new.h [deleted file]
ir/adt/cpset.h [new file with mode: 0644]
ir/adt/hashset.h [new file with mode: 0644]
ir/adt/pset_new.h [new file with mode: 0644]
ir/be/bestate.c

diff --git a/include/libfirm/adt/cpset.h b/include/libfirm/adt/cpset.h
deleted file mode 100644 (file)
index b13fea0..0000000
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @date    16.03.2007
- * @brief   a set of pointers with a custom compare function
- * @author  Matthias Braun
- */
-#ifndef FIRM_ADT_CPSET_H
-#define FIRM_ADT_CPSET_H
-
-#include "../begin.h"
-
-/**
- * @ingroup adt
- * @defgroup Pointer Set (custom Compare)
- * A pointer set with user-definable compare function
- * @{
- */
-
-/**
- * The type of a cpset compare function.
- *
- * @param p1   pointer to an element
- * @param p2   pointer to another element
- *
- * @return  1 if the elements are identically, zero else
- */
-typedef int (*cpset_cmp_function) (const void *p1, const void *p2);
-
-/**
- * The type of a cpset hash function.
- */
-typedef unsigned (*cpset_hash_function) (const void *obj);
-
-/** @cond PRIVATE */
-
-#define HashSet          cpset_t
-#define HashSetIterator  cpset_iterator_t
-#define HashSetEntry     cpset_hashset_entry_t
-#define ValueType        void*
-#define ADDITIONAL_DATA  cpset_cmp_function cmp_function; cpset_hash_function hash_function;
-#include "hashset.h"
-#undef ADDITIONAL_DATA
-#undef ValueType
-#undef HashSetEntry
-#undef HashSetIterator
-#undef HashSet
-
-/** @endcond */
-
-/** a pointer set with custom compare function */
-typedef struct cpset_t          cpset_t;
-/** iterator over a pointer set with custom compare function
- * @see #cpset_t */
-typedef struct cpset_iterator_t cpset_iterator_t;
-
-/**
- * Initializes a cpset
- *
- * @param cpset           Pointer to allocated space for the cpset
- * @param hash_function   The hash function to use
- * @param cmp_function    The compare function to use
- */
-FIRM_API void cpset_init(cpset_t *cpset, cpset_hash_function hash_function,
-                cpset_cmp_function cmp_function);
-
-/**
- * Initializes a cpset
- *
- * @param cpset              Pointer to allocated space for the cpset
- * @param hash_function      The hash function to use
- * @param cmp_function       The compare function to use
- * @param expected_elements  Number of elements expected in the cpset (roughly)
- */
-FIRM_API void cpset_init_size(cpset_t *cpset, cpset_hash_function hash_function,
-                     cpset_cmp_function cmp_function,
-                     size_t expected_elements);
-
-/**
- * Destroys a cpset and frees the memory allocated for hashtable. The memory of
- * the cpset itself is not freed.
- *
- * @param cpset   Pointer to the cpset
- */
-FIRM_API void cpset_destroy(cpset_t *cpset);
-
-/**
- * Inserts an element into a cpset.
- *
- * @param cpset   Pointer to the cpset
- * @param obj     Element to insert into the cpset
- * @returns       The element itself or a pointer to an existing element
- */
-FIRM_API void* cpset_insert(cpset_t *cpset, void *obj);
-
-/**
- * Removes an element from a cpset. Does nothing if the cpset doesn't contain the
- * element.
- *
- * @param cpset   Pointer to the cpset
- * @param obj     Pointer to remove from the cpset
- */
-FIRM_API void cpset_remove(cpset_t *cpset, const void *obj);
-
-/**
- * Tests whether a cpset contains a pointer
- *
- * @param cpset   Pointer to the cpset
- * @param obj     The pointer to find
- * @returns       An equivalent object to @p obj or NULL
- */
-FIRM_API void *cpset_find(const cpset_t *cpset, const void *obj);
-
-/**
- * Returns the number of pointers contained in the cpset
- *
- * @param cpset   Pointer to the cpset
- * @returns       Number of pointers contained in the cpset
- */
-FIRM_API size_t cpset_size(const cpset_t *cpset);
-
-/**
- * Initializes a cpset iterator. Sets the iterator before the first element in
- * the cpset.
- *
- * @param iterator   Pointer to already allocated iterator memory
- * @param cpset       Pointer to the cpset
- */
-FIRM_API void cpset_iterator_init(cpset_iterator_t *iterator, const cpset_t *cpset);
-
-/**
- * Advances the iterator and returns the current element or NULL if all elements
- * in the cpset have been processed.
- * @attention It is not allowed to use cpset_insert or cpset_remove while
- *            iterating over a cpset.
- *
- * @param iterator  Pointer to the cpset iterator.
- * @returns         Next element in the cpset or NULL
- */
-FIRM_API void *cpset_iterator_next(cpset_iterator_t *iterator);
-
-/**
- * Removed the element the iterator currently points to
- *
- * @param cpset     Pointer to the cpset
- * @param iterator  Pointer to the cpset iterator.
- */
-FIRM_API void cpset_remove_iterator(cpset_t *cpset, const cpset_iterator_t *iterator);
-
-/** @} */
-
-#include "../end.h"
-
-#endif
diff --git a/include/libfirm/adt/hashset.h b/include/libfirm/adt/hashset.h
deleted file mode 100644 (file)
index 2d95a36..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @date    16.03.2007
- * @brief   Generic hashset functions
- * @author  Matthias Braun
- *
- * You have to specialize this header by defining HashSet, HashSetIterator and
- * ValueType
- */
-#ifdef HashSet
-
-#include <stdlib.h>
-
-#ifdef DO_REHASH
-#define HashSetEntry ValueType
-#else
-typedef struct HashSetEntry {
-       ValueType data;
-       unsigned hash;
-} HashSetEntry;
-#endif
-
-struct HashSet {
-       HashSetEntry *entries;
-       size_t num_buckets;
-       size_t enlarge_threshold;
-       size_t shrink_threshold;
-       size_t num_elements;
-       size_t num_deleted;
-       int consider_shrink;
-#ifndef NDEBUG
-       unsigned entries_version;
-#endif
-#ifdef ADDITIONAL_DATA
-       ADDITIONAL_DATA
-#endif
-};
-
-#ifndef NO_ITERATOR
-struct HashSetIterator {
-       HashSetEntry *current_bucket;
-       HashSetEntry *end;
-#ifndef NDEBUG
-       const struct HashSet *set;
-       unsigned entries_version;
-#endif
-};
-#endif
-
-#ifdef DO_REHASH
-#undef HashSetEntry
-#endif
-
-#endif
diff --git a/include/libfirm/adt/pset_new.h b/include/libfirm/adt/pset_new.h
deleted file mode 100644 (file)
index a5314ab..0000000
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @date    17.03.2007
- * @brief   hashset containing pointers
- * @author  Matthias Braun
- *
- * @note This has been named pset_new_new for now until all code has been
- *       changed to use this instead of the old deprecated pset_new functions!
- *       This version performs better than pset in terms of speed and memory
- *       usage and allows multiple iterators over the set
- */
-#ifndef FIRM_ADT_PSET_NEW_H
-#define FIRM_ADT_PSET_NEW_H
-
-#include "../begin.h"
-
-/** @cond PRIVATE */
-
-#define HashSet          pset_new_t
-#define HashSetIterator  pset_new_iterator_t
-#define ValueType        void*
-#define DO_REHASH
-#include "hashset.h"
-#undef DO_REHASH
-#undef HashSet
-#undef HashSetIterator
-#undef ValueType
-
-/** @endcond */
-
-/** a pointer (hash)set */
-typedef struct pset_new_t           pset_new_t;
-/** iterator over a pointer set.
- * @see #pset_new_t */
-typedef struct pset_new_iterator_t  pset_new_iterator_t;
-
-/**
- * Initializes a pset_new
- *
- * @param pset_new   Pointer to allocated space for the pset_new
- */
-FIRM_API void pset_new_init(pset_new_t *pset_new);
-
-/**
- * Initializes a pset_new
- *
- * @param pset_new            Pointer to allocated space for the pset_new
- * @param expected_elements   Number of elements expected in the pset_new (roughly)
- */
-FIRM_API void pset_new_init_size(pset_new_t *pset_new, size_t expected_elements);
-
-/**
- * Destroys a pset_new and frees the memory allocated for hashtable. The memory of
- * the pset_new itself is not freed.
- *
- * @param pset_new   Pointer to the pset_new
- */
-FIRM_API void pset_new_destroy(pset_new_t *pset_new);
-
-/**
- * Inserts an element into a pset_new.
- *
- * @param pset_new   Pointer to the pset_new
- * @param ptr    Pointer to insert into the pset_new
- * @returns      1 if the pointer was inserted, 0 if it was already there
- */
-FIRM_API int pset_new_insert(pset_new_t *pset_new, void *ptr);
-
-/**
- * Removes an element from a pset_new. Does nothing if the pset_new doesn't contain the
- * element.
- *
- * @param pset_new   Pointer to the pset_new
- * @param ptr    Pointer to remove from the pset_new
- */
-FIRM_API void pset_new_remove(pset_new_t *pset_new, const void *ptr);
-
-/**
- * Tests whether a pset_new contains a pointer
- *
- * @param pset_new   Pointer to the pset_new
- * @param ptr    The pointer to test
- * @returns      1 @p pset_new contains the @p ptr, 0 otherwise
- */
-FIRM_API int pset_new_contains(const pset_new_t *pset_new, const void *ptr);
-
-/**
- * Returns the number of pointers contained in the pset_new
- *
- * @param pset_new   Pointer to the pset_new
- * @returns      Number of pointers contained in the pset_new
- */
-FIRM_API size_t pset_new_size(const pset_new_t *pset_new);
-
-/**
- * Initializes a pset_new iterator. Sets the iterator before the first element in
- * the pset_new.
- *
- * @param iterator   Pointer to already allocated iterator memory
- * @param pset_new       Pointer to the pset_new
- */
-FIRM_API void pset_new_iterator_init(pset_new_iterator_t *iterator, const pset_new_t *pset_new);
-
-/**
- * Advances the iterator and returns the current element or NULL if all elements
- * in the pset_new have been processed.
- * @attention It is not allowed to use pset_new_insert or pset_new_remove while
- *            iterating over a pset_new; pset_new_remove_iter is allowed.
- *
- * @param iterator  Pointer to the pset_new iterator.
- * @returns         Next element in the pset_new or NULL
- */
-FIRM_API void* pset_new_iterator_next(pset_new_iterator_t *iterator);
-
-/**
- * Removes the element that the iterator currently points to from the hashset.
- *
- * @param pset_new      Pointer to the pset_new
- * @param iterator  Pointer to the iterator
- */
-FIRM_API void pset_new_remove_iterator(pset_new_t *pset_new, const pset_new_iterator_t *iterator);
-
-/**
- * Convenience macro for iterating over a pset_new.
- */
-#define foreach_pset_new(pset_new, type, ptr, iter)    \
-       for(pset_new_iterator_init(&iter, pset_new), \
-               ptr = (type) pset_new_iterator_next(&iter);     \
-               ptr != NULL; ptr = (type) pset_new_iterator_next(&iter))
-
-#include "../end.h"
-
-#endif
diff --git a/ir/adt/cpset.h b/ir/adt/cpset.h
new file mode 100644 (file)
index 0000000..0450cab
--- /dev/null
@@ -0,0 +1,168 @@
+/*
+ * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @date    16.03.2007
+ * @brief   a set of pointers with a custom compare function
+ * @author  Matthias Braun
+ */
+#ifndef FIRM_ADT_CPSET_H
+#define FIRM_ADT_CPSET_H
+
+/**
+ * @ingroup adt
+ * @defgroup Pointer Set (custom Compare)
+ * A pointer set with user-definable compare function
+ * @{
+ */
+
+/**
+ * The type of a cpset compare function.
+ *
+ * @param p1   pointer to an element
+ * @param p2   pointer to another element
+ *
+ * @return  1 if the elements are identically, zero else
+ */
+typedef int (*cpset_cmp_function) (const void *p1, const void *p2);
+
+/**
+ * The type of a cpset hash function.
+ */
+typedef unsigned (*cpset_hash_function) (const void *obj);
+
+/** @cond PRIVATE */
+
+#define HashSet          cpset_t
+#define HashSetIterator  cpset_iterator_t
+#define HashSetEntry     cpset_hashset_entry_t
+#define ValueType        void*
+#define ADDITIONAL_DATA  cpset_cmp_function cmp_function; cpset_hash_function hash_function;
+#include "hashset.h"
+#undef ADDITIONAL_DATA
+#undef ValueType
+#undef HashSetEntry
+#undef HashSetIterator
+#undef HashSet
+
+/** @endcond */
+
+/** a pointer set with custom compare function */
+typedef struct cpset_t          cpset_t;
+/** iterator over a pointer set with custom compare function
+ * @see #cpset_t */
+typedef struct cpset_iterator_t cpset_iterator_t;
+
+/**
+ * Initializes a cpset
+ *
+ * @param cpset           Pointer to allocated space for the cpset
+ * @param hash_function   The hash function to use
+ * @param cmp_function    The compare function to use
+ */
+void cpset_init(cpset_t *cpset, cpset_hash_function hash_function,
+                cpset_cmp_function cmp_function);
+
+/**
+ * Initializes a cpset
+ *
+ * @param cpset              Pointer to allocated space for the cpset
+ * @param hash_function      The hash function to use
+ * @param cmp_function       The compare function to use
+ * @param expected_elements  Number of elements expected in the cpset (roughly)
+ */
+void cpset_init_size(cpset_t *cpset, cpset_hash_function hash_function,
+                     cpset_cmp_function cmp_function,
+                     size_t expected_elements);
+
+/**
+ * Destroys a cpset and frees the memory allocated for hashtable. The memory of
+ * the cpset itself is not freed.
+ *
+ * @param cpset   Pointer to the cpset
+ */
+void cpset_destroy(cpset_t *cpset);
+
+/**
+ * Inserts an element into a cpset.
+ *
+ * @param cpset   Pointer to the cpset
+ * @param obj     Element to insert into the cpset
+ * @returns       The element itself or a pointer to an existing element
+ */
+void* cpset_insert(cpset_t *cpset, void *obj);
+
+/**
+ * Removes an element from a cpset. Does nothing if the cpset doesn't contain the
+ * element.
+ *
+ * @param cpset   Pointer to the cpset
+ * @param obj     Pointer to remove from the cpset
+ */
+void cpset_remove(cpset_t *cpset, const void *obj);
+
+/**
+ * Tests whether a cpset contains a pointer
+ *
+ * @param cpset   Pointer to the cpset
+ * @param obj     The pointer to find
+ * @returns       An equivalent object to @p obj or NULL
+ */
+void *cpset_find(const cpset_t *cpset, const void *obj);
+
+/**
+ * Returns the number of pointers contained in the cpset
+ *
+ * @param cpset   Pointer to the cpset
+ * @returns       Number of pointers contained in the cpset
+ */
+size_t cpset_size(const cpset_t *cpset);
+
+/**
+ * Initializes a cpset iterator. Sets the iterator before the first element in
+ * the cpset.
+ *
+ * @param iterator   Pointer to already allocated iterator memory
+ * @param cpset       Pointer to the cpset
+ */
+void cpset_iterator_init(cpset_iterator_t *iterator, const cpset_t *cpset);
+
+/**
+ * Advances the iterator and returns the current element or NULL if all elements
+ * in the cpset have been processed.
+ * @attention It is not allowed to use cpset_insert or cpset_remove while
+ *            iterating over a cpset.
+ *
+ * @param iterator  Pointer to the cpset iterator.
+ * @returns         Next element in the cpset or NULL
+ */
+void *cpset_iterator_next(cpset_iterator_t *iterator);
+
+/**
+ * Removed the element the iterator currently points to
+ *
+ * @param cpset     Pointer to the cpset
+ * @param iterator  Pointer to the cpset iterator.
+ */
+void cpset_remove_iterator(cpset_t *cpset, const cpset_iterator_t *iterator);
+
+/** @} */
+
+#endif
diff --git a/ir/adt/hashset.h b/ir/adt/hashset.h
new file mode 100644 (file)
index 0000000..2d95a36
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @date    16.03.2007
+ * @brief   Generic hashset functions
+ * @author  Matthias Braun
+ *
+ * You have to specialize this header by defining HashSet, HashSetIterator and
+ * ValueType
+ */
+#ifdef HashSet
+
+#include <stdlib.h>
+
+#ifdef DO_REHASH
+#define HashSetEntry ValueType
+#else
+typedef struct HashSetEntry {
+       ValueType data;
+       unsigned hash;
+} HashSetEntry;
+#endif
+
+struct HashSet {
+       HashSetEntry *entries;
+       size_t num_buckets;
+       size_t enlarge_threshold;
+       size_t shrink_threshold;
+       size_t num_elements;
+       size_t num_deleted;
+       int consider_shrink;
+#ifndef NDEBUG
+       unsigned entries_version;
+#endif
+#ifdef ADDITIONAL_DATA
+       ADDITIONAL_DATA
+#endif
+};
+
+#ifndef NO_ITERATOR
+struct HashSetIterator {
+       HashSetEntry *current_bucket;
+       HashSetEntry *end;
+#ifndef NDEBUG
+       const struct HashSet *set;
+       unsigned entries_version;
+#endif
+};
+#endif
+
+#ifdef DO_REHASH
+#undef HashSetEntry
+#endif
+
+#endif
diff --git a/ir/adt/pset_new.h b/ir/adt/pset_new.h
new file mode 100644 (file)
index 0000000..4de77f8
--- /dev/null
@@ -0,0 +1,148 @@
+/*
+ * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @date    17.03.2007
+ * @brief   hashset containing pointers
+ * @author  Matthias Braun
+ *
+ * @note This has been named pset_new_new for now until all code has been
+ *       changed to use this instead of the old deprecated pset_new functions!
+ *       This version performs better than pset in terms of speed and memory
+ *       usage and allows multiple iterators over the set
+ */
+#ifndef FIRM_ADT_PSET_NEW_H
+#define FIRM_ADT_PSET_NEW_H
+
+/** @cond PRIVATE */
+
+#define HashSet          pset_new_t
+#define HashSetIterator  pset_new_iterator_t
+#define ValueType        void*
+#define DO_REHASH
+#include "hashset.h"
+#undef DO_REHASH
+#undef HashSet
+#undef HashSetIterator
+#undef ValueType
+
+/** @endcond */
+
+/** a pointer (hash)set */
+typedef struct pset_new_t           pset_new_t;
+/** iterator over a pointer set.
+ * @see #pset_new_t */
+typedef struct pset_new_iterator_t  pset_new_iterator_t;
+
+/**
+ * Initializes a pset_new
+ *
+ * @param pset_new   Pointer to allocated space for the pset_new
+ */
+void pset_new_init(pset_new_t *pset_new);
+
+/**
+ * Initializes a pset_new
+ *
+ * @param pset_new            Pointer to allocated space for the pset_new
+ * @param expected_elements   Number of elements expected in the pset_new (roughly)
+ */
+void pset_new_init_size(pset_new_t *pset_new, size_t expected_elements);
+
+/**
+ * Destroys a pset_new and frees the memory allocated for hashtable. The memory of
+ * the pset_new itself is not freed.
+ *
+ * @param pset_new   Pointer to the pset_new
+ */
+void pset_new_destroy(pset_new_t *pset_new);
+
+/**
+ * Inserts an element into a pset_new.
+ *
+ * @param pset_new   Pointer to the pset_new
+ * @param ptr    Pointer to insert into the pset_new
+ * @returns      1 if the pointer was inserted, 0 if it was already there
+ */
+int pset_new_insert(pset_new_t *pset_new, void *ptr);
+
+/**
+ * Removes an element from a pset_new. Does nothing if the pset_new doesn't contain the
+ * element.
+ *
+ * @param pset_new   Pointer to the pset_new
+ * @param ptr    Pointer to remove from the pset_new
+ */
+void pset_new_remove(pset_new_t *pset_new, const void *ptr);
+
+/**
+ * Tests whether a pset_new contains a pointer
+ *
+ * @param pset_new   Pointer to the pset_new
+ * @param ptr    The pointer to test
+ * @returns      1 @p pset_new contains the @p ptr, 0 otherwise
+ */
+int pset_new_contains(const pset_new_t *pset_new, const void *ptr);
+
+/**
+ * Returns the number of pointers contained in the pset_new
+ *
+ * @param pset_new   Pointer to the pset_new
+ * @returns      Number of pointers contained in the pset_new
+ */
+size_t pset_new_size(const pset_new_t *pset_new);
+
+/**
+ * Initializes a pset_new iterator. Sets the iterator before the first element in
+ * the pset_new.
+ *
+ * @param iterator   Pointer to already allocated iterator memory
+ * @param pset_new       Pointer to the pset_new
+ */
+void pset_new_iterator_init(pset_new_iterator_t *iterator, const pset_new_t *pset_new);
+
+/**
+ * Advances the iterator and returns the current element or NULL if all elements
+ * in the pset_new have been processed.
+ * @attention It is not allowed to use pset_new_insert or pset_new_remove while
+ *            iterating over a pset_new; pset_new_remove_iter is allowed.
+ *
+ * @param iterator  Pointer to the pset_new iterator.
+ * @returns         Next element in the pset_new or NULL
+ */
+void* pset_new_iterator_next(pset_new_iterator_t *iterator);
+
+/**
+ * Removes the element that the iterator currently points to from the hashset.
+ *
+ * @param pset_new      Pointer to the pset_new
+ * @param iterator  Pointer to the iterator
+ */
+void pset_new_remove_iterator(pset_new_t *pset_new, const pset_new_iterator_t *iterator);
+
+/**
+ * Convenience macro for iterating over a pset_new.
+ */
+#define foreach_pset_new(pset_new, type, ptr, iter)    \
+       for(pset_new_iterator_init(&iter, pset_new), \
+               ptr = (type) pset_new_iterator_next(&iter);     \
+               ptr != NULL; ptr = (type) pset_new_iterator_next(&iter))
+
+#endif
index e609532..a7c1b82 100644 (file)
@@ -38,7 +38,7 @@
 #include "irgmod.h"
 #include "irnodeset.h"
 #include "irnodehashmap.h"
-#include "adt/cpset.h"
+#include "cpset.h"
 
 #include "bearch.h"
 #include "beuses.h"