3 * File name: ir/ir/irphase.c
4 * Purpose: Phase information handling using node indexes.
5 * Author: Sebastian Hack
9 * Copyright: (c) 1998-2006 Universitaet Karlsruhe
10 * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
19 #include "irphase_t.h"
21 phase_t *phase_new(const char *name, ir_graph *irg, size_t data_size, unsigned growth_factor,
22 phase_irn_data_init_t *data_init, void *priv)
26 assert(growth_factor >= 1.0 && "growth factor must greater or equal to 1.0");
28 ph = xmalloc(sizeof(ph[0]));
30 obstack_init(&ph->obst);
33 ph->growth_factor = growth_factor;
34 ph->data_init = data_init;
35 ph->data_size = data_size;
44 void phase_free(phase_t *phase)
46 obstack_free(&phase->obst, NULL);
47 xfree(phase->data_ptr);
50 phase_stat_t *phase_stat(const phase_t *phase, phase_stat_t *stat)
53 memset(stat, 0, sizeof(stat[0]));
55 stat->node_map_bytes = phase->n_data_ptr * sizeof(phase->data_ptr[0]);
56 stat->node_slots = phase->n_data_ptr;
57 for(i = 0, n = phase->n_data_ptr; i < n; ++i) {
58 if(phase->data_ptr[i] != NULL) {
59 stat->node_slots_used++;
60 stat->node_data_bytes += phase->data_size;
63 stat->overall_bytes = stat->node_map_bytes + obstack_memory_used(&((phase_t *)phase)->obst);