Commit 9476fdab authored by Matthias Braun's avatar Matthias Braun
Browse files

rename irnodemap to irnodehashmap

parent fcfd8038
......@@ -19,7 +19,8 @@
/**
* @file
* @brief Performs lowering of perm nodes. Inserts copies to assure register constraints.
* @brief Performs lowering of perm nodes. Inserts copies to assure
* register constraints.
* @author Christian Wuerdig
* @date 14.12.2005
* @version $Id$
......@@ -32,7 +33,7 @@
#include "debug.h"
#include "xmalloc.h"
#include "irnodeset.h"
#include "irnodemap.h"
#include "irnodehashmap.h"
#include "irgmod.h"
#include "iredges_t.h"
#include "irgwalk.h"
......@@ -60,9 +61,9 @@ typedef struct {
/** Environment for constraints. */
typedef struct {
ir_graph *irg;
ir_nodemap_t op_set;
struct obstack obst;
ir_graph *irg;
ir_nodehashmap_t op_set;
struct obstack obst;
} constraint_env_t;
/** Lowering walker environment. */
......@@ -502,7 +503,7 @@ static ir_node *find_copy(ir_node *irn, ir_node *op)
static void gen_assure_different_pattern(ir_node *irn, ir_node *other_different, constraint_env_t *env)
{
ir_nodemap_t *op_set;
ir_nodehashmap_t *op_set;
ir_node *block;
const arch_register_class_t *cls;
ir_node *keep, *cpy;
......@@ -555,13 +556,13 @@ static void gen_assure_different_pattern(ir_node *irn, ir_node *other_different,
sched_add_after(skip_Proj(irn), keep);
/* insert the other different and its copies into the map */
entry = (op_copy_assoc_t*)ir_nodemap_get(op_set, other_different);
entry = (op_copy_assoc_t*)ir_nodehashmap_get(op_set, other_different);
if (! entry) {
entry = OALLOC(&env->obst, op_copy_assoc_t);
entry->cls = cls;
ir_nodeset_init(&entry->copies);
ir_nodemap_insert(op_set, other_different, entry);
ir_nodehashmap_insert(op_set, other_different, entry);
}
/* insert copy */
......@@ -649,11 +650,11 @@ static void assure_constraints_walker(ir_node *block, void *walk_env)
*/
static void melt_copykeeps(constraint_env_t *cenv)
{
ir_nodemap_iterator_t map_iter;
ir_nodemap_entry_t map_entry;
ir_nodehashmap_iterator_t map_iter;
ir_nodehashmap_entry_t map_entry;
/* for all */
foreach_ir_nodemap(&cenv->op_set, map_entry, map_iter) {
foreach_ir_nodehashmap(&cenv->op_set, map_entry, map_iter) {
op_copy_assoc_t *entry = (op_copy_assoc_t*)map_entry.data;
int idx, num_ck;
ir_node *cp;
......@@ -766,14 +767,14 @@ static void melt_copykeeps(constraint_env_t *cenv)
void assure_constraints(ir_graph *irg)
{
constraint_env_t cenv;
ir_nodemap_iterator_t map_iter;
ir_nodemap_entry_t map_entry;
constraint_env_t cenv;
ir_nodehashmap_iterator_t map_iter;
ir_nodehashmap_entry_t map_entry;
FIRM_DBG_REGISTER(dbg_constr, "firm.be.lower.constr");
cenv.irg = irg;
ir_nodemap_init(&cenv.op_set);
ir_nodehashmap_init(&cenv.op_set);
obstack_init(&cenv.obst);
irg_block_walk_graph(irg, NULL, assure_constraints_walker, &cenv);
......@@ -784,7 +785,7 @@ void assure_constraints(ir_graph *irg)
melt_copykeeps(&cenv);
/* for all */
foreach_ir_nodemap(&cenv.op_set, map_entry, map_iter) {
foreach_ir_nodehashmap(&cenv.op_set, map_entry, map_iter) {
op_copy_assoc_t *entry = (op_copy_assoc_t*)map_entry.data;
size_t n = ir_nodeset_size(&entry->copies);
ir_node **nodes = ALLOCAN(ir_node*, n);
......@@ -830,7 +831,7 @@ void assure_constraints(ir_graph *irg)
ir_nodeset_destroy(&entry->copies);
}
ir_nodemap_destroy(&cenv.op_set);
ir_nodehashmap_destroy(&cenv.op_set);
obstack_free(&cenv.obst, NULL);
be_liveness_invalidate(be_get_irg_liveness(irg));
}
......
......@@ -38,7 +38,7 @@
#include "ircons_t.h"
#include "irgmod.h"
#include "irnodeset.h"
#include "irnodemap.h"
#include "irnodehashmap.h"
#include "adt/cpset.h"
#include "bearch.h"
......@@ -67,7 +67,7 @@ typedef struct minibelady_env_t {
create_reload_func create_reload;
create_spill_func create_spill;
spill_info_t *spills;
ir_nodemap_t spill_infos;
ir_nodehashmap_t spill_infos;
be_uses_t *uses; /**< env for the next-use magic */
} minibelady_env_t;
......@@ -100,7 +100,7 @@ static inline spill_info_t *create_spill_info(minibelady_env_t *env, ir_node *st
spill_info->value = state;
spill_info->reloads = NEW_ARR_F(ir_node*, 0);
ir_nodemap_insert(&env->spill_infos, state, spill_info);
ir_nodehashmap_insert(&env->spill_infos, state, spill_info);
//ir_fprintf(stderr, "Insert %+F -> %p\n", state, spill_info);
spill_info->next = env->spills;
......@@ -112,7 +112,7 @@ static inline spill_info_t *create_spill_info(minibelady_env_t *env, ir_node *st
static inline spill_info_t *get_spill_info(minibelady_env_t *env, const ir_node *node)
{
spill_info_t *spill_info
= (spill_info_t*) ir_nodemap_get(&env->spill_infos, node);
= (spill_info_t*) ir_nodehashmap_get(&env->spill_infos, node);
//ir_fprintf(stderr, "Get %+F -> %p\n", node, spill_info);
return spill_info;
}
......@@ -539,7 +539,7 @@ void be_assure_state(ir_graph *irg, const arch_register_t *reg, void *func_env,
env.lv = be_get_irg_liveness(irg);
env.uses = be_begin_uses(irg, env.lv);
env.spills = NULL;
ir_nodemap_init(&env.spill_infos);
ir_nodehashmap_init(&env.spill_infos);
assure_doms(irg);
ir_reserve_resources(irg, IR_RESOURCE_IRN_VISITED | IR_RESOURCE_IRN_LINK);
......@@ -594,7 +594,7 @@ void be_assure_state(ir_graph *irg, const arch_register_t *reg, void *func_env,
/* some nodes might be dead now. */
be_remove_dead_nodes_from_schedule(irg);
ir_nodemap_destroy(&env.spill_infos);
ir_nodehashmap_destroy(&env.spill_infos);
be_end_uses(env.uses);
obstack_free(&env.obst, NULL);
}
......
......@@ -21,23 +21,23 @@
* @file
* @author Matthias Braun
* @date 30.03.2007
* @brief A nodemap. This should be preferred over a simple pset, because it
tries to guarantee deterministic behavior.
* @version $Id$
* @brief A nodemap. This should be preferred over a simple pset, because
* it guarantees deterministic behavior when iterating of the
* hashmap
*/
#include "config.h"
#include "irnodemap.h"
#include "irnodehashmap.h"
#include "irnode_t.h"
#include "hashptr.h"
static ir_nodemap_entry_t null_nodemap_entry = { NULL, NULL };
static ir_nodehashmap_entry_t null_nodehashmap_entry = { NULL, NULL };
#define DO_REHASH
#define HashSet ir_nodemap_t
#define HashSetIterator ir_nodemap_iterator_t
#define ValueType ir_nodemap_entry_t
#define NullValue null_nodemap_entry
#define HashSet ir_nodehashmap_t
#define HashSetIterator ir_nodehashmap_iterator_t
#define ValueType ir_nodehashmap_entry_t
#define NullValue null_nodehashmap_entry
#define KeyType ir_node*
#define ConstKeyType const ir_node*
#define GetKey(value) (value).node
......@@ -50,36 +50,37 @@ static ir_nodemap_entry_t null_nodemap_entry = { NULL, NULL };
#define EntryIsEmpty(value) ((value).node == NULL)
#define EntryIsDeleted(value) ((value).node == (ir_node*)-1)
void ir_nodemap_init_(ir_nodemap_t *self);
#define hashset_init ir_nodemap_init_
#define hashset_init_size ir_nodemap_init_size
#define hashset_destroy ir_nodemap_destroy
ir_nodemap_entry_t *ir_nodemap_insert_(ir_nodemap_t *self, ir_node *node);
#define hashset_insert ir_nodemap_insert_
#define hashset_remove ir_nodemap_remove
ir_nodemap_entry_t *ir_nodemap_find_(const ir_nodemap_t *self,
const ir_node *node);
#define hashset_find ir_nodemap_find_
#define hashset_size ir_nodemap_size
#define hashset_iterator_init ir_nodemap_iterator_init
#define hashset_iterator_next ir_nodemap_iterator_next
#define hashset_remove_iterator ir_nodemap_remove_iterator
void ir_nodehashmap_init_(ir_nodehashmap_t *self);
#define hashset_init ir_nodehashmap_init_
#define hashset_init_size ir_nodehashmap_init_size
#define hashset_destroy ir_nodehashmap_destroy
ir_nodehashmap_entry_t *ir_nodehashmap_insert_(ir_nodehashmap_t *self,
ir_node *node);
#define hashset_insert ir_nodehashmap_insert_
#define hashset_remove ir_nodehashmap_remove
ir_nodehashmap_entry_t *ir_nodehashmap_find_(const ir_nodehashmap_t *self,
const ir_node *node);
#define hashset_find ir_nodehashmap_find_
#define hashset_size ir_nodehashmap_size
#define hashset_iterator_init ir_nodehashmap_iterator_init
#define hashset_iterator_next ir_nodehashmap_iterator_next
#define hashset_remove_iterator ir_nodehashmap_remove_iterator
#include "hashset.c"
void ir_nodemap_init(ir_nodemap_t *nodemap)
void ir_nodehashmap_init(ir_nodehashmap_t *nodehashmap)
{
ir_nodemap_init_size(nodemap, 16);
ir_nodehashmap_init_size(nodehashmap, 16);
}
void *ir_nodemap_get(const ir_nodemap_t *self, const ir_node *node)
void *ir_nodehashmap_get(const ir_nodehashmap_t *self, const ir_node *node)
{
ir_nodemap_entry_t *entry = ir_nodemap_find_(self, node);
ir_nodehashmap_entry_t *entry = ir_nodehashmap_find_(self, node);
return entry->data;
}
void ir_nodemap_insert(ir_nodemap_t *self, ir_node *node, void *data)
void ir_nodehashmap_insert(ir_nodehashmap_t *self, ir_node *node, void *data)
{
ir_nodemap_entry_t *entry = ir_nodemap_insert_(self, node);
entry->data = data;
ir_nodehashmap_entry_t *entry = ir_nodehashmap_insert_(self, node);
entry->data = data;
}
/*
* Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
*
* This file is part of libFirm.
*
* This file may be distributed and/or modified under the terms of the
* GNU General Public License version 2 as published by the Free Software
* Foundation and appearing in the file LICENSE.GPL included in the
* packaging of this file.
*
* Licensees holding valid libFirm Professional Edition licenses may use
* this file in accordance with the libFirm Commercial License.
* Agreement provided with the Software.
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE.
*/
/**
* @file
* @author Matthias Braun
* @date 30.03.2007
* @brief A nodemap. This should be preferred over a simple pset, because it
* tries to guarantee deterministic behavior. (and is faster)
*/
#ifndef _FIRM_IRNODEHASHMAP_H_
#define _FIRM_IRNODEHASHMAP_H_
#include "irnode.h"
typedef struct ir_nodehashmap_entry_t {
ir_node *node;
void *data;
} ir_nodehashmap_entry_t;
#define HashSet ir_nodehashmap_t
#define HashSetIterator ir_nodehashmap_iterator_t
#define ValueType ir_nodehashmap_entry_t
#define DO_REHASH
#include "hashset.h"
#undef DO_REHASH
#undef ValueType
#undef HashSetIterator
#undef HashSet
typedef struct ir_nodehashmap_t ir_nodehashmap_t;
typedef struct ir_nodehashmap_iterator_t ir_nodehashmap_iterator_t;
/**
* Initializes a nodehashmap with default size.
*
* @param nodehashmap Pointer to allocated space for the nodehashmap
*/
void ir_nodehashmap_init(ir_nodehashmap_t *nodehashmap);
/**
* Initializes a nodehashmap
*
* @param nodehashmap Pointer to allocated space for the nodehashmap
* @param expected_elements Number of elements expected in the nodehashmap
* (roughly)
*/
void ir_nodehashmap_init_size(ir_nodehashmap_t *nodehashmap,
size_t expected_elements);
/**
* Destroys a nodehashmap and frees the memory allocated for hashtable. The
* memory of the nodehashmap itself is not freed.
*
* @param nodehashmap Pointer to the nodehashmap
*/
void ir_nodehashmap_destroy(ir_nodehashmap_t *nodehashmap);
/**
* Inserts a node into a nodehashmap.
*
* @param nodehashmap Pointer to the nodehashmap
* @param node node to insert into the nodehashmap
* @param data data to associate with the node
*/
void ir_nodehashmap_insert(ir_nodehashmap_t *nodehashmap, ir_node *node,
void *data);
/**
* Removes a node from a nodehashmap. Does nothing if the nodehashmap doesn't
* contain the node.
*
* @param nodehashmap Pointer to the nodehashmap
* @param node Node to remove from the nodehashmap
*/
void ir_nodehashmap_remove(ir_nodehashmap_t *nodehashmap, const ir_node *node);
/**
* Tests whether a nodehashmap contains a specific node
*
* @param nodehashmap Pointer to the nodehashmap
* @param node The pointer to find
* @returns the associated data of the node or NULL
*/
void *ir_nodehashmap_get(const ir_nodehashmap_t *nodehashmap,
const ir_node *node);
/**
* Returns the number of pointers contained in the nodehashmap
*
* @param nodehashmap Pointer to the nodehashmap
* @returns Number of pointers contained in the nodehashmap
*/
size_t ir_nodehashmap_size(const ir_nodehashmap_t *nodehashmap);
/**
* Initializes a nodehashmap iterator. Sets the iterator before the first
* element in the nodehashmap.
*
* @param iterator Pointer to already allocated iterator memory
* @param nodehashmap Pointer to the nodehashmap
*/
void ir_nodehashmap_iterator_init(ir_nodehashmap_iterator_t *iterator,
const ir_nodehashmap_t *nodehashmap);
/**
* Advances the iterator and returns the current element or NULL if all elements
* in the nodehashmap have been processed.
* @attention It is not allowed to use nodehashmap_insert or nodehashmap_remove
* while iterating over a nodehashmap.
*
* @param iterator Pointer to the nodehashmap iterator.
* @returns Next element in the nodehashmap or NULL
*/
ir_nodehashmap_entry_t ir_nodehashmap_iterator_next(
ir_nodehashmap_iterator_t *iterator);
/**
* Removes the element the iterator currently points to
*
* @param nodehashmap Pointer to the nodehashmap
* @param iterator Pointer to the nodehashmap iterator.
*/
void ir_nodehashmap_remove_iterator(ir_nodehashmap_t *nodehashmap,
const ir_nodehashmap_iterator_t *iterator);
#define foreach_ir_nodehashmap(nodehashmap, entry, iter) \
for (ir_nodehashmap_iterator_init(&iter, nodehashmap), \
entry = ir_nodehashmap_iterator_next(&iter); \
entry.node != NULL; entry = ir_nodehashmap_iterator_next(&iter))
#endif
/*
* Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
*
* This file is part of libFirm.
*
* This file may be distributed and/or modified under the terms of the
* GNU General Public License version 2 as published by the Free Software
* Foundation and appearing in the file LICENSE.GPL included in the
* packaging of this file.
*
* Licensees holding valid libFirm Professional Edition licenses may use
* this file in accordance with the libFirm Commercial License.
* Agreement provided with the Software.
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE.
*/
/**
* @file
* @author Matthias Braun
* @date 30.03.2007
* @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 behavior deterministic are not
* implemented yet...
*/
#ifndef _FIRM_IRNODEMAP_H_
#define _FIRM_IRNODEMAP_H_
#include "irnode.h"
typedef struct ir_nodemap_entry_t {
ir_node *node;
void *data;
} ir_nodemap_entry_t;
#define HashSet ir_nodemap_t
#define HashSetIterator ir_nodemap_iterator_t
#define ValueType ir_nodemap_entry_t
#define DO_REHASH
#include "hashset.h"
#undef DO_REHASH
#undef ValueType
#undef HashSetIterator
#undef HashSet
typedef struct ir_nodemap_t ir_nodemap_t;
typedef struct ir_nodemap_iterator_t ir_nodemap_iterator_t;
/**
* Initializes a nodemap with default size.
*
* @param nodemap Pointer to allocated space for the nodemap
*/
void ir_nodemap_init(ir_nodemap_t *nodemap);
/**
* Initializes a nodemap
*
* @param nodemap Pointer to allocated space for the nodemap
* @param expected_elements Number of elements expected in the nodemap (roughly)
*/
void ir_nodemap_init_size(ir_nodemap_t *nodemap, size_t expected_elements);
/**
* Destroys a nodemap and frees the memory allocated for hashtable. The memory of
* the nodemap itself is not freed.
*
* @param nodemap Pointer to the nodemap
*/
void ir_nodemap_destroy(ir_nodemap_t *nodemap);
/**
* Inserts a node into a nodemap.
*
* @param nodemap Pointer to the 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, ir_node *node, void *data);
/**
* Removes a node from a nodemap. Does nothing if the nodemap doesn't contain
* the node.
*
* @param nodemap Pointer to the nodemap
* @param node Node to remove from the nodemap
*/
void ir_nodemap_remove(ir_nodemap_t *nodemap, const ir_node *node);
/**
* Tests whether a nodemap contains a specific node
*
* @param nodemap Pointer to the nodemap
* @param node The pointer to find
* @returns the associated data of the node or NULL
*/
void *ir_nodemap_get(const ir_nodemap_t *nodemap, const ir_node *node);
/**
* Returns the number of pointers contained in the nodemap
*
* @param nodemap Pointer to the nodemap
* @returns Number of pointers contained in the nodemap
*/
size_t ir_nodemap_size(const ir_nodemap_t *nodemap);
/**
* Initializes a nodemap iterator. Sets the iterator before the first element in
* the nodemap.
*
* @param iterator Pointer to already allocated iterator memory
* @param nodemap Pointer to the nodemap
*/
void ir_nodemap_iterator_init(ir_nodemap_iterator_t *iterator,
const ir_nodemap_t *nodemap);
/**
* Advances the iterator and returns the current element or NULL if all elements
* in the nodemap have been processed.
* @attention It is not allowed to use nodemap_insert or nodemap_remove while
* iterating over a nodemap.
*
* @param iterator Pointer to the nodemap iterator.
* @returns Next element in the nodemap or NULL
*/
ir_nodemap_entry_t ir_nodemap_iterator_next(ir_nodemap_iterator_t *iterator);
/**
* Removes the element the iterator currently points to
*
* @param nodemap Pointer to the nodemap
* @param iterator Pointer to the nodemap iterator.
*/
void ir_nodemap_remove_iterator(ir_nodemap_t *nodemap,
const ir_nodemap_iterator_t *iterator);
#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
......@@ -36,7 +36,7 @@
#include "ircons.h"
#include "irgmod.h"
#include "valueset.h"
#include "irnodemap.h"
#include "irnodehashmap.h"
#include "irnodeset.h"
#include "iredges.h"
#include "iropt_dbg.h"
......@@ -83,7 +83,7 @@ typedef struct pre_env {
char first_iter; /**< non-zero for first iteration */
} pre_env;
static ir_nodemap_t value_map;
static ir_nodehashmap_t value_map;
/** The debug module handle. */
DEBUG_ONLY(static firm_dbg_module_t *dbg;)
......@@ -124,7 +124,7 @@ static ir_node *add(ir_node *e, ir_node *v)
}
}
v = identify_remember(v);
ir_nodemap_insert(&value_map, e, v);
ir_nodehashmap_insert(&value_map, e, v);
return v;
} /* add */
......@@ -138,7 +138,7 @@ static ir_node *add(ir_node *e, ir_node *v)
*/
static ir_node *lookup(ir_node *e)
{
ir_node *value = (ir_node*)ir_nodemap_get(&value_map, e);
ir_node *value = (ir_node*)ir_nodehashmap_get(&value_map, e);
if (value != NULL)
return identify_remember(value);
return NULL;
......@@ -806,7 +806,7 @@ void do_gvn_pre(ir_graph *irg)
edges_deactivate(irg);
new_identities(irg);
ir_nodemap_init(&value_map);
ir_nodehashmap_init(&value_map);
obstack_init(&obst);
a_env.obst = &obst;
......@@ -885,7 +885,7 @@ void do_gvn_pre(ir_graph *irg)
if (bl_info->new_set)
ir_valueset_del(bl_info->new_set);
}
ir_nodemap_destroy(&value_map);
ir_nodehashmap_destroy(&value_map);
obstack_free(&obst, NULL);
/* pin the graph again: This is needed due to the use of set_opt_global_cse(1) */
......
......@@ -38,7 +38,7 @@
#include "irgopt.h"
#include "iropt.h"
#include "iroptimize.h"
#include "irnodemap.h"
#include "irnodehashmap.h"
#include "raw_bitset.h"
#include "debug.h"
#include "error.h"
......@@ -115,8 +115,8 @@ struct block_t {
* Metadata for this pass.
*/
typedef struct ldst_env_t {
struct obstack obst; /**< obstack for temporary data */
ir_nodemap_t adr_map; /**< Map addresses to */
struct obstack obst; /**< obstack for temporary data */
ir_nodehashmap_t adr_map; /**< Map addresses to */
block_t *forward; /**< Inverse post-order list of all blocks Start->End */
block_t *backward; /**< Inverse post-order list of all blocks End->Start */
ir_node *start_bl; /**< start block of the current graph */
......@@ -312,14 +312,14 @@ restart:
goto restart;
}
entry = (address_entry*)ir_nodemap_get(&env.adr_map, adr);
entry = (address_entry*)ir_nodehashmap_get(&env.adr_map, adr);
if (entry == NULL) {
/* new address */
entry = OALLOC(&env.obst, address_entry);
entry->id = env.curr_adr_id++;
ir_nodemap_insert(&env.adr_map, adr, entry);
ir_nodehashmap_insert(&env.adr_map, adr, entry);
DB((dbg, LEVEL_3, "ADDRESS %+F has ID %u\n", adr, entry->id));
#ifdef DEBUG_libfirm
......@@ -2350,7 +2350,7 @@ int opt_ldst(ir_graph *irg)
}
obstack_init(&env.obst);
ir_nodemap_init(&env.adr_map);
ir_nodehashmap_init(&env.adr_map);
env.forward = NULL;