summaryrefslogtreecommitdiff
path: root/source/backend.c
blob: 52cf46da903efbf180a56c98079a330d90b2d8e7 (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
#include <cloog/ppl/cloog.h>

static int cloog_ppl_count = 0;

/**
 * Allocate and initialize full state.
 */
CloogState *cloog_state_malloc(void)
{
	CloogState *state;

	if (cloog_ppl_count == 0) {
		if (ppl_initialize() < 0)
			return NULL;
	}
	cloog_ppl_count++;

	state = cloog_core_state_malloc();
	state->backend = NULL;
	return state;
}

/**
 * Free state and backend independent parts.
 */
void cloog_state_free(CloogState *state)
{
	cloog_core_state_free(state);

	if (--cloog_ppl_count == 0)
	    ppl_finalize();
}