X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fir%2Firphase.c;h=362d0bc22e772939472c52baa998abfe415dda81;hb=e1397b01aceb38b6bb62c319007146af3b922f39;hp=135a6c8db50bfe515f9f641c797fc276f2e470a8;hpb=1bebdda91969b4d0d295d01886b66ec47e4b8cc4;p=libfirm diff --git a/ir/ir/irphase.c b/ir/ir/irphase.c index 135a6c8db..362d0bc22 100644 --- a/ir/ir/irphase.c +++ b/ir/ir/irphase.c @@ -1,38 +1,90 @@ /* - * Project: libFIRM - * File name: ir/ir/irphase.c - * Purpose: Phase information handling using node indexes. - * Author: Sebastian Hack - * Modified by: - * Created: - * SVN-ID: $Id$ - * Copyright: (c) 1998-2006 Universitaet Karlsruhe - * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE. + * 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. */ -#ifdef HAVE_CONFIG_H +/** + * @file + * @brief Phase information handling using node indexes. + * @author Sebastian Hack + * @version $Id$ + * @summary + * A phase contains a link to private data for each node in an ir graph. + * A phase is independent from the globally visible link field of ir nodes. + */ #include "config.h" -#endif #include "array.h" +#include "util.h" #include "irnode_t.h" +#include "irgraph_t.h" #include "irphase_t.h" -ir_phase *phase_init(ir_phase *ph, const char *name, ir_graph *irg, unsigned growth_factor, phase_irn_data_init_t *data_init, void *priv) +void *phase_irn_init_default(ir_phase *ph, const ir_node *irn, void *old) +{ + (void) ph; + (void) irn; + (void) old; + return NULL; +} + +ir_phase *init_irg_phase(ir_graph *irg, ir_phase_id id, size_t size, phase_irn_init *data_init) { - assert(growth_factor >= 256 && "growth factor must greater or equal to 256/256"); - assert(data_init && "You must provide a data constructor"); + ir_phase *ph; + + size = MAX(sizeof(*ph), size); + assert(id != PHASE_NOT_IRG_MANAGED && id < PHASE_LAST); + assert(irg->phases[id] == NULL && "you cannot overwrite another irg managed phase"); + ph = xmalloc(size); + memset(ph, 0, size); obstack_init(&ph->obst); + ph->id = id; + ph->growth_factor = PHASE_DEFAULT_GROWTH; + ph->data_init = data_init; + ph->irg = irg; + ph->n_data_ptr = 0; + ph->data_ptr = NULL; + + irg->phases[id] = ph; - ph->name = name; + return ph; +} + +void free_irg_phase(ir_graph *irg, ir_phase_id id) +{ + ir_phase *ph = get_irg_phase(irg, id); + phase_free(ph); + xfree(ph); + irg->phases[id] = NULL; +} + +ir_phase *phase_init(ir_phase *ph, const char *name, ir_graph *irg, unsigned growth_factor, phase_irn_init *data_init, void *priv) +{ + obstack_init(&ph->obst); + + (void) name; + ph->id = PHASE_NOT_IRG_MANAGED; ph->growth_factor = growth_factor; ph->data_init = data_init; ph->irg = irg; ph->n_data_ptr = 0; ph->data_ptr = NULL; ph->priv = priv; - return ph; } @@ -88,7 +140,7 @@ void phase_reinit_block_irn_data(ir_phase *phase, ir_node *block) } } -ir_node *phase_get_first_node(ir_phase *phase) { +ir_node *phase_get_first_node(const ir_phase *phase) { unsigned i; for (i = 0; i < phase->n_data_ptr; ++i) @@ -98,7 +150,7 @@ ir_node *phase_get_first_node(ir_phase *phase) { return NULL; } -ir_node *phase_get_next_node(ir_phase *phase, ir_node *start) { +ir_node *phase_get_next_node(const ir_phase *phase, ir_node *start) { unsigned i; for (i = get_irn_idx(start) + 1; i < phase->n_data_ptr; ++i)