X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fir%2Firnodemap.h;h=69ec94b1640f71c977d206708abca604adb9022e;hb=41eca21e7add2e4f30f14c46600a23839852b3fc;hp=b0cc076d3e6729dd0928a732acafc4f120bd7b0b;hpb=86e591b1f6ec4a47f7ae14216582f45274a2fd46;p=libfirm diff --git a/ir/ir/irnodemap.h b/ir/ir/irnodemap.h index b0cc076d3..69ec94b16 100644 --- a/ir/ir/irnodemap.h +++ b/ir/ir/irnodemap.h @@ -24,18 +24,17 @@ * @brief A nodemap. This should be preferred over a simple pset, because it * tries to guarantee deterministic behavior. (and is faster) * @version $Id$ - * @note Actually the bits to make the behaviour deterministic are not + * @note Actually the bits to make the behavior deterministic are not * implemented yet... */ #ifndef _FIRM_IRNODEMAP_H_ #define _FIRM_IRNODEMAP_H_ #include "irnode.h" -#include "xmalloc.h" typedef struct ir_nodemap_entry_t { - const ir_node *node; - void *data; + ir_node *node; + void *data; } ir_nodemap_entry_t; #define HashSet ir_nodemap_t @@ -81,7 +80,7 @@ void ir_nodemap_destroy(ir_nodemap_t *nodemap); * @param node node to insert into the nodemap * @param data data to associate with the node */ -void ir_nodemap_insert(ir_nodemap_t *nodemap, const ir_node *node, void *data); +void ir_nodemap_insert(ir_nodemap_t *nodemap, ir_node *node, void *data); /** * Removes a node from a nodemap. Does nothing if the nodemap doesn't contain @@ -97,7 +96,7 @@ void ir_nodemap_remove(ir_nodemap_t *nodemap, const ir_node *node); * * @param nodemap Pointer to the nodemap * @param node The pointer to find - * @returns 1 if nodemap contains the node, 0 else + * @returns the associated data of the node or NULL */ void *ir_nodemap_get(const ir_nodemap_t *nodemap, const ir_node *node); @@ -109,7 +108,6 @@ void *ir_nodemap_get(const ir_nodemap_t *nodemap, const ir_node *node); */ size_t ir_nodemap_size(const ir_nodemap_t *nodemap); -#if 0 /** * Initializes a nodemap iterator. Sets the iterator before the first element in * the nodemap. @@ -129,7 +127,7 @@ void ir_nodemap_iterator_init(ir_nodemap_iterator_t *iterator, * @param iterator Pointer to the nodemap iterator. * @returns Next element in the nodemap or NULL */ -ir_node *ir_nodemap_iterator_next(ir_nodemap_iterator_t *iterator); +ir_nodemap_entry_t ir_nodemap_iterator_next(ir_nodemap_iterator_t *iterator); /** * Removes the element the iterator currently points to @@ -139,6 +137,10 @@ ir_node *ir_nodemap_iterator_next(ir_nodemap_iterator_t *iterator); */ void ir_nodemap_remove_iterator(ir_nodemap_t *nodemap, const ir_nodemap_iterator_t *iterator); -#endif + +#define foreach_ir_nodemap(nodemap, entry, iter) \ + for (ir_nodemap_iterator_init(&iter, nodemap), \ + entry = ir_nodemap_iterator_next(&iter); \ + entry.node != NULL; entry = ir_nodemap_iterator_next(&iter)) #endif