Implemented floating point lowering to Calls into a soft float library.
[libfirm] / ir / ir / irnodemap.h
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 nodemap. This should be preferred over a simple pset, because it
25  *            tries to guarantee deterministic behavior. (and is faster)
26  * @version   $Id$
27  * @note      Actually the bits to make the behavior deterministic are not
28  *            implemented yet...
29  */
30 #ifndef _FIRM_IRNODEMAP_H_
31 #define _FIRM_IRNODEMAP_H_
32
33 #include "irnode.h"
34
35 typedef struct ir_nodemap_entry_t {
36         ir_node *node;
37         void    *data;
38 } ir_nodemap_entry_t;
39
40 #define HashSet          ir_nodemap_t
41 #define HashSetIterator  ir_nodemap_iterator_t
42 #define ValueType        ir_nodemap_entry_t
43 #define DO_REHASH
44 #include "hashset.h"
45 #undef DO_REHASH
46 #undef ValueType
47 #undef HashSetIterator
48 #undef HashSet
49
50 typedef struct ir_nodemap_t           ir_nodemap_t;
51 typedef struct ir_nodemap_iterator_t  ir_nodemap_iterator_t;
52
53 /**
54  * Initializes a nodemap with default size.
55  *
56  * @param nodemap      Pointer to allocated space for the nodemap
57  */
58 void ir_nodemap_init(ir_nodemap_t *nodemap);
59
60 /**
61  * Initializes a nodemap
62  *
63  * @param nodemap             Pointer to allocated space for the nodemap
64  * @param expected_elements   Number of elements expected in the nodemap (roughly)
65  */
66 void ir_nodemap_init_size(ir_nodemap_t *nodemap, size_t expected_elements);
67
68 /**
69  * Destroys a nodemap and frees the memory allocated for hashtable. The memory of
70  * the nodemap itself is not freed.
71  *
72  * @param nodemap   Pointer to the nodemap
73  */
74 void ir_nodemap_destroy(ir_nodemap_t *nodemap);
75
76 /**
77  * Inserts a node into a nodemap.
78  *
79  * @param nodemap   Pointer to the nodemap
80  * @param node      node to insert into the nodemap
81  * @param data      data to associate with the node
82  */
83 void ir_nodemap_insert(ir_nodemap_t *nodemap, ir_node *node, void *data);
84
85 /**
86  * Removes a node from a nodemap. Does nothing if the nodemap doesn't contain
87  * the node.
88  *
89  * @param nodemap  Pointer to the nodemap
90  * @param node     Node to remove from the nodemap
91  */
92 void ir_nodemap_remove(ir_nodemap_t *nodemap, const ir_node *node);
93
94 /**
95  * Tests whether a nodemap contains a specific node
96  *
97  * @param nodemap   Pointer to the nodemap
98  * @param node      The pointer to find
99  * @returns         the associated data of the node or NULL
100  */
101 void *ir_nodemap_get(const ir_nodemap_t *nodemap, const ir_node *node);
102
103 /**
104  * Returns the number of pointers contained in the nodemap
105  *
106  * @param nodemap   Pointer to the nodemap
107  * @returns       Number of pointers contained in the nodemap
108  */
109 size_t ir_nodemap_size(const ir_nodemap_t *nodemap);
110
111 /**
112  * Initializes a nodemap iterator. Sets the iterator before the first element in
113  * the nodemap.
114  *
115  * @param iterator   Pointer to already allocated iterator memory
116  * @param nodemap       Pointer to the nodemap
117  */
118 void ir_nodemap_iterator_init(ir_nodemap_iterator_t *iterator,
119                               const ir_nodemap_t *nodemap);
120
121 /**
122  * Advances the iterator and returns the current element or NULL if all elements
123  * in the nodemap have been processed.
124  * @attention It is not allowed to use nodemap_insert or nodemap_remove while
125  *            iterating over a nodemap.
126  *
127  * @param iterator  Pointer to the nodemap iterator.
128  * @returns         Next element in the nodemap or NULL
129  */
130 ir_nodemap_entry_t ir_nodemap_iterator_next(ir_nodemap_iterator_t *iterator);
131
132 /**
133  * Removes the element the iterator currently points to
134  *
135  * @param nodemap   Pointer to the nodemap
136  * @param iterator  Pointer to the nodemap iterator.
137  */
138 void ir_nodemap_remove_iterator(ir_nodemap_t *nodemap,
139                                 const ir_nodemap_iterator_t *iterator);
140
141 #define foreach_ir_nodemap(nodemap, entry, iter) \
142         for (ir_nodemap_iterator_init(&iter, nodemap), \
143                 entry = ir_nodemap_iterator_next(&iter);    \
144                 entry.node != NULL; entry = ir_nodemap_iterator_next(&iter))
145
146 #endif