fix
[libfirm] / ir / ir / irnodeset.c
1 /*
2  * Copyright (C) 1995-2007 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
6  * This file may be distributed and/or modified under the terms of the
7  * GNU General Public License version 2 as published by the Free Software
8  * Foundation and appearing in the file LICENSE.GPL included in the
9  * packaging of this file.
10  *
11  * Licensees holding valid libFirm Professional Edition licenses may use
12  * this file in accordance with the libFirm Commercial License.
13  * Agreement provided with the Software.
14  *
15  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE.
18  */
19
20 /**
21  * @file
22  * @author    Matthias Braun
23  * @date      30.03.2007
24  * @brief     A nodeset. This should be prefered over a simple pset, because it
25               tries to guarantee deterministic behavior.
26  * @version   $Id$
27  */
28 #include "config.h"
29
30 #include "irnodeset.h"
31 #include "irnode_t.h"
32 #include "hashptr.h"
33
34 #define DO_REHASH
35 #define ID_HASH
36 #define HashSet                   ir_nodeset_t
37 #define HashSetIterator           ir_nodeset_iterator_t
38 #define ValueType                 ir_node*
39 #define NullValue                 NULL
40 #define DeletedValue              ((ir_node*)-1)
41 #ifdef DEBUG_libfirm
42 #define Hash(this,value)          (value)->node_nr
43 #else
44 #define Hash(this,value)          HASH_PTR(value)
45 #endif
46 #define KeysEqual(this,key1,key2) (key1) == (key2)
47 #define SetRangeEmpty(ptr,size)   memset(ptr, 0, (size) * sizeof((ptr)[0]))
48
49 #define hashset_init            ir_nodeset_init
50 #define hashset_init_size       ir_nodeset_init_size
51 #define hashset_destroy         ir_nodeset_destroy
52 #define hashset_insert          ir_nodeset_insert
53 #define hashset_remove          ir_nodeset_remove
54 #define hashset_find            _ir_nodeset_find
55 #define hashset_size            ir_nodeset_size
56 #define hashset_iterator_init   ir_nodeset_iterator_init
57 #define hashset_iterator_next   ir_nodeset_iterator_next
58 #define hashset_remove_iterator ir_nodeset_remove_iterator
59
60 #include "hashset.c"
61
62 int ir_nodeset_contains(const ir_nodeset_t *this, const ir_node *node)
63 {
64         return _ir_nodeset_find(this, node) != NULL;
65 }