X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fana%2Firtypeinfo.c;h=52d9c1cf0d100c9b036f8e483bd8a1e0dfbd352a;hb=a5c272c2d733edf1a253163ad1bbc77bfd62c4d1;hp=eba6da0133f5351df6032da9a5f58d16f0e34ae1;hpb=4a8e1e93a0641224e54ab8c5d1b84b57da944472;p=libfirm diff --git a/ir/ana/irtypeinfo.c b/ir/ana/irtypeinfo.c index eba6da013..52d9c1cf0 100644 --- a/ir/ana/irtypeinfo.c +++ b/ir/ana/irtypeinfo.c @@ -1,30 +1,40 @@ -/** +/* + * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved. * - * @file irtypeinfo.c + * This file is part of libFirm. * - * Project: libFIRM - * File name: ir/ana/irtypeinfo.c - * Purpose: Data structure to hold type information for nodes. - * Author: Goetz Lindenmaier - * Modified by: - * Created: 28.8.2003 - * CVS-ID: $Id$ - * Copyright: (c) 2003 Universität Karlsruhe - * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE. + * 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. * - * Data structure to hold type information for nodes. + * Licensees holding valid libFirm Professional Edition licenses may use + * this file in accordance with the libFirm Commercial License. + * Agreement provided with the Software. * - * This module defines a field "type" of type "type *" for each ir node. - * It defines a flag for irgraphs to mark whether the type info of the - * graph is valid. Further it defines an auxiliary type "initial_type". + * 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 + * @brief Data structure to hold type information for nodes. + * @author Goetz Lindenmaier + * @date 28.8.2003 + * @version $Id$ + * @summary + * Data structure to hold type information for nodes. * - * The module defines a map that contains pairs (irnode, type). If an irnode - * is not in the map it is assumed to be initialized, i.e., the initialization - * requires no compute time. As firm nodes can not be freed and reallocated - * pointers for nodes are unique (until a call of dead_node_elimination). + * This module defines a field "type" of type "type *" for each ir node. + * It defines a flag for irgraphs to mark whether the type info of the + * graph is valid. Further it defines an auxiliary type "initial_type". * + * The module defines a map that contains pairs (irnode, type). If an irnode + * is not in the map it is assumed to be initialized, i.e., the initialization + * requires no compute time. As firm nodes can not be freed and reallocated + * pointers for nodes are unique (until a call of dead_node_elimination). */ - #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -50,7 +60,7 @@ static pmap *type_node_map = NULL; * variable is set by init_irtypeinfo. The type is freed by * free_irtypeinfo. */ -type *initial_type = NULL; +ir_type *initial_type = NULL; /* ------------ Initializing this module. ----------------------------- */ @@ -60,7 +70,7 @@ type *initial_type = NULL; * in the order of MIN(, #irnodes). */ void init_irtypeinfo(void) { - int i; + int i, n; if (!initial_type) initial_type = new_type_class(new_id_from_str("initial_type")); @@ -69,26 +79,28 @@ void init_irtypeinfo(void) { if (type_node_map) pmap_destroy(type_node_map); type_node_map = pmap_create(); - for (i = 0; i < get_irp_n_irgs(); ++i) + n = get_irp_n_irgs(); + for (i = 0; i < n; ++i) set_irg_typeinfo_state(get_irp_irg(i), ir_typeinfo_none); } void free_irtypeinfo(void) { - int i; + int i, n; if (initial_type) { free_type(initial_type); initial_type = NULL; - } else - assert(0 && "call init_type_info before freeing"); + } + //else assert(0 && "call init_type_info before freeing"); if (type_node_map) { pmap_destroy(type_node_map); type_node_map = NULL; - } else - assert(0 && "call init_type_info before freeing"); + } + //else assert(0 && "call init_type_info before freeing"); - for (i = 0; i < get_irp_n_irgs(); ++i) + n = get_irp_n_irgs(); + for (i = 0; i < n; ++i) set_irg_typeinfo_state(get_irp_irg(i), ir_typeinfo_none); } @@ -135,18 +147,20 @@ void set_irp_typeinfo_inconsistent(void) { * ir_typeinfo_consistent or ir_typeinfo_inconsistent. They * assume current_ir_graph set properly. */ -type *get_irn_typeinfo_type(ir_node *n) { - type *res = initial_type; - assert(get_irg_typeinfo_state(current_ir_graph) == ir_typeinfo_consistent || - get_irg_typeinfo_state(current_ir_graph) == ir_typeinfo_inconsistent ); +ir_type *get_irn_typeinfo_type(ir_node *n) { + ir_type *res = initial_type; + pmap_entry *entry; + assert(get_irg_typeinfo_state(get_irn_irg(n)) == ir_typeinfo_consistent || + get_irg_typeinfo_state(get_irn_irg(n)) == ir_typeinfo_inconsistent ); - if (pmap_contains(type_node_map, (void *)n)) - res = (type *) pmap_get(type_node_map, (void *)n); + entry = pmap_find(type_node_map, n); + if (entry) + res = entry->value; return res; } -void set_irn_typeinfo_type(ir_node *n, type *tp) { +void set_irn_typeinfo_type(ir_node *n, ir_type *tp) { assert(get_irg_typeinfo_state(current_ir_graph) == ir_typeinfo_consistent || get_irg_typeinfo_state(current_ir_graph) == ir_typeinfo_inconsistent );