summaryrefslogtreecommitdiff
path: root/cloog-0.17.0/source/state.c
blob: 7f3fff8494852e677affea4d3a650c4973d9287e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <stdlib.h>
#include "../include/cloog/cloog.h"

/**
 * Allocate state and initialize backend independent part.
 */
CloogState *cloog_core_state_malloc(void)
{
  CloogState *state;

  state = (CloogState *)malloc(sizeof(CloogState));
  if (!state) 
    cloog_die("memory overflow.\n");

  state->backend = NULL;

  cloog_int_init(state->zero);
  cloog_int_set_si(state->zero, 0);
  cloog_int_init(state->one);
  cloog_int_set_si(state->one, 1);
  cloog_int_init(state->negone);
  cloog_int_set_si(state->negone, -1);

  state->block_allocated = 0;
  state->block_freed = 0;
  state->block_max = 0;

  state->domain_allocated = 0;
  state->domain_freed = 0;
  state->domain_max = 0;

  state->loop_allocated = 0;
  state->loop_freed = 0;
  state->loop_max = 0;

  state->statement_allocated = 0;
  state->statement_freed = 0;
  state->statement_max = 0;

  return state;
}

/**
 * Free state.
 */
void cloog_core_state_free(CloogState *state)
{
  cloog_int_clear(state->zero);
  cloog_int_clear(state->one);
  cloog_int_clear(state->negone);
  free(state);
}