summaryrefslogtreecommitdiff
path: root/regnaive.h
blob: 65730fe4fa03454970353e1aff49dbc1f6d0d30f (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
#include "stack-man.h"
#include "simplex86.h"

typedef struct reg_alloc_t reg_alloc_t;
typedef struct reg_pool_t reg_pool_t;

#define MAX_REGISTERS (16)
#define MAX_SPILLS    (16)

struct reg_pool_t
{
    int         n_registers;
    reg_t       registers[MAX_REGISTERS];
};

struct reg_alloc_t
{
    const reg_pool_t *	pool;
    int			allocated[MAX_REGISTERS];
    int			clobbered[MAX_REGISTERS];
    int			failed;
};

void
reg_alloc_init (reg_alloc_t *ra,
		const reg_pool_t *reg_pool);

/* This resurrects a register that has been freed, but is known
 * to still contain a useful value.
 */
reg_t
reg_alloc_alloc_preserve (reg_alloc_t *ra, reg_t reg);

reg_t
reg_alloc_alloc (reg_alloc_t *ra);

void
reg_alloc_free (reg_alloc_t *ra, reg_t reg);

int
reg_alloc_failed (reg_alloc_t *ra);

int
reg_alloc_clobbered (reg_alloc_t *ra, reg_t reg);