irgraph: Use get_irg_obstack() instead of accessing irg->obst directly.
[libfirm] / ir / ir / irnodeset.c
1 /*
2  * Copyright (C) 1995-2008 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 preferred over a simple pset, because it
25               tries to guarantee deterministic behavior.
26  */
27 #include "config.h"
28
29 #include "irnodeset.h"
30 #include "irnode_t.h"
31 #include "hashptr.h"
32
33 #define DO_REHASH
34 #define ID_HASH
35 #define HashSet                   ir_nodeset_t
36 #define HashSetIterator           ir_nodeset_iterator_t
37 #define ValueType                 ir_node*
38 #define NullValue                 NULL
39 #define DeletedValue              ((ir_node*)-1)
40 #define Hash(this,key)            ((unsigned)((key)->node_nr))
41 #define KeysEqual(this,key1,key2) (key1) == (key2)
42 #define SetRangeEmpty(ptr,size)   memset(ptr, 0, (size) * sizeof((ptr)[0]))
43
44 void ir_nodeset_init_(ir_nodeset_t *self);
45 #define hashset_init            ir_nodeset_init_
46 #define hashset_init_size       ir_nodeset_init_size
47 #define hashset_destroy         ir_nodeset_destroy
48 #define hashset_insert          ir_nodeset_insert
49 #define hashset_remove          ir_nodeset_remove
50 #define hashset_find            ir_nodeset_contains
51 #define hashset_size            ir_nodeset_size
52 #define hashset_iterator_init   ir_nodeset_iterator_init
53 #define hashset_iterator_next   ir_nodeset_iterator_next
54 #define hashset_remove_iterator ir_nodeset_remove_iterator
55
56 #include "hashset.c.inl"
57
58 void ir_nodeset_init(ir_nodeset_t *nodeset)
59 {
60         ir_nodeset_init_size(nodeset, 16);
61 }