added a callback function to check whether a given entity is a allocation call
[libfirm] / ir / adt / pset.h
index 9a42d1b..6c6e4c0 100644 (file)
@@ -1,17 +1,33 @@
 /*
- * Project:     libFIRM
- * File name:   ir/adt/pset.h
- * Purpose:     Declarations for pset.
- * Author:      Markus Armbruster
- * Modified by:
- * Created:     1999 by getting from fiasco
- * CVS-ID:      $Id$
- * Copyright:   (c) 1995, 1996 Markus Armbruster
- * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
+ * Copyright (C) 1995-2007 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.
  */
 
-#ifndef _PSET_H
-#define _PSET_H
+/**
+ * @file
+ * @brief      optimized version of set for sets containing only pointers
+ *             (deprecated)
+ * @author     Markus Armbruster
+ * @version    $Id$
+ * @note       This code has been deprecated. Use pset_new or cpset for new
+ *             code.
+ */
+#ifndef FIRM_ADT_PSET_H
+#define FIRM_ADT_PSET_H
 
 #include <stddef.h>
 
  */
 int pset_default_ptr_cmp(const void *x, const void *y);
 
-/*
- * Define some convenience macros using the predefined hash function.
- */
-#define pset_insert_ptr(set,key) pset_insert(set, key, HASH_PTR(key))
-#define pset_hinsert_ptr(set,key) pset_hinsert(set, key, HASH_PTR(key))
-#define pset_remove_ptr(set,key) pset_remove(set, key, HASH_PTR(key))
-#define pset_find_ptr(set,key) pset_find(set, key, HASH_PTR(key))
-#define pset_new_ptr(slots) new_pset(pset_default_ptr_cmp, slots)
-#define pset_new_ptr_default() pset_new_ptr(64)
-
 /**
  * The abstract type of a pset (Set of pointers).
  *
  * This kind of sets stores only pointer to elements, the elements itself
- * must be stored somewere else.
+ * must be stored somewhere else.
  *
  * @see set
  */
 typedef struct pset pset;
 
+/*
+ * Define some convenience macros using the predefined hash function.
+ */
+#define pset_insert_ptr(set,key)  pset_insert(set, key, HASH_PTR(key))
+#define pset_hinsert_ptr(set,key) pset_hinsert(set, key, HASH_PTR(key))
+#define pset_remove_ptr(set,key)  pset_remove(set, key, HASH_PTR(key))
+#define pset_find_ptr(set,key)    pset_find(set, key, HASH_PTR(key))
+#define pset_new_ptr(slots)       new_pset(pset_default_ptr_cmp, slots)
+#define pset_new_ptr_default()    pset_new_ptr(64)
+
 /** The entry of a pset, representing an element pointer in the set and it's meta-information */
 typedef struct {
   unsigned hash;
@@ -114,7 +130,7 @@ void *pset_find (pset *pset, const void *key, unsigned hash);
  * @return a pointer to the inserted element
  *
  * @note
- *    It is not possible to insert on element more than once. If a element
+ *    It is not possible to insert an element more than once. If an element
  *    that should be inserted is already in the set, this functions does
  *    nothing but returning its already existing set_entry.
 
@@ -131,7 +147,7 @@ void *pset_insert (pset *pset, const void *key, unsigned hash);
  * @return a pointer to the pset_entry of the inserted element
  *
  * @note
- *    It is not possible to insert on element more than once. If a element
+ *    It is not possible to insert an element more than once. If an element
  *    that should be inserted is already in the pset, this functions does
  *    nothing but returning its pset_entry.
  */
@@ -140,8 +156,8 @@ pset_entry *pset_hinsert (pset *pset, const void *key, unsigned hash);
 /**
  * Removes an element from a pset.
  *
- * @param pset  the pset to insert in
- * @param key   a pointer to the element to be inserted
+ * @param pset  the pset to delete in
+ * @param key   a pointer to the element to be deleted
  * @param hash  the hash-value of the element
  *
  * @return
@@ -149,6 +165,7 @@ pset_entry *pset_hinsert (pset *pset, const void *key, unsigned hash);
  *
  * @remark
  *    The current implementation did not allow to remove non-existing elements.
+ *    @@@ so, does it do now?
  *    Further, it is allowed to remove elements during an iteration
  *    including the current one.
  */
@@ -182,6 +199,23 @@ void *pset_next (pset *pset);
  */
 void pset_break (pset *pset);
 
+/**
+ * Iterates oven an pset.
+ *
+ * @param pset   the pset
+ * @param entry  the iterator
+ */
+#define foreach_pset(pset, entry) for (entry = pset_first(pset); entry; entry = pset_next(pset))
+
+/**
+ * Inserts all elements of the pointer set src into
+ * the set target (union).
+ *
+ * @param target  the target set, will contain the union
+ * @param src     a set, will not be changed
+ */
+void pset_insert_pset_ptr(pset *target, pset *src);
+
 #define new_pset(cmp, slots) (PSET_TRACE (new_pset) ((cmp), (slots)))
 #define pset_find(pset, key, hash) \
   _pset_search ((pset), (key), (hash), _pset_find)