X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fir%2Firnodemap.h;h=69ec94b1640f71c977d206708abca604adb9022e;hb=2ece936daec565575739be72f568a241207a5083;hp=1072bca6520cbfee29e2a69105c4af899d910c27;hpb=ec03ce6682fbd1601daff6c9623ba1c413aea446;p=libfirm diff --git a/ir/ir/irnodemap.h b/ir/ir/irnodemap.h index 1072bca65..69ec94b16 100644 --- a/ir/ir/irnodemap.h +++ b/ir/ir/irnodemap.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved. + * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved. * * This file is part of libFirm. * @@ -21,21 +21,20 @@ * @file * @author Matthias Braun * @date 30.03.2007 - * @brief A nodemap. This should be prefered over a simple pset, because it + * @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