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, phase_irn_data_init_t *data_init)
25 assert(growth_factor >= 1.0 && "growth factor must greater or equal to 1.0");
27 ph = xmalloc(sizeof(ph[0]));
29 obstack_init(&ph->obst);
32 ph->growth_factor = growth_factor;
33 ph->data_init = data_init;
34 ph->data_size = data_size;
42 void phase_free(phase_t *phase)
44 obstack_free(&phase->obst, NULL);
45 xfree(phase->data_ptr);
48 phase_stat_t *phase_stat(const phase_t *phase, phase_stat_t *stat)
51 memset(stat, 0, sizeof(stat[0]));
53 stat->node_map_bytes = phase->n_data_ptr * sizeof(phase->data_ptr[0]);
54 stat->node_slots = phase->n_data_ptr;
55 for(i = 0, n = phase->n_data_ptr; i < n; ++i) {
56 if(phase->data_ptr[i] != NULL) {
57 stat->node_slots_used++;
58 stat->node_data_bytes += phase->data_size;
61 stat->overall_bytes = stat->node_map_bytes + obstack_memory_used(&phase->obst);