summaryrefslogtreecommitdiff
path: root/cloog-core/source/isl/backend.c
blob: 6ddb9f9adcd567014c90a5bd8983724cf4b919fa (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
#include <cloog/isl/cloog.h>

/**
 * Allocate and initialize full state.
 */
CloogState *cloog_state_malloc(void)
{
	return cloog_isl_state_malloc(NULL);
}

/**
 * Allocate and initialize full state for isl backend.
 */
CloogState *cloog_isl_state_malloc(struct isl_ctx *ctx)
{
	CloogState *state;
	int allocated = !ctx;

	state = cloog_core_state_malloc();
	if (!ctx)
		ctx = isl_ctx_alloc();
	state->backend = isl_alloc_type(ctx, CloogBackend);
	state->backend->ctx = ctx;
	state->backend->ctx_allocated = allocated;
	return state;
}

/**
 * Free state and backend independent parts.
 */
void cloog_state_free(CloogState *state)
{
	if (state->backend->ctx_allocated)
		isl_ctx_free(state->backend->ctx);
	free(state->backend);
	cloog_core_state_free(state);
}