summaryrefslogtreecommitdiffhomepage
path: root/ir/be/beuses.h
blob: 31e90ef93be75a3415041854b1b8d778bee3096b (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
53
54
55
56
57
58
59
60
61
62
/*
 * This file is part of libFirm.
 * Copyright (C) 2012 University of Karlsruhe.
 */

/**
 * @file
 * @brief       Methods to compute when a value will be used again.
 * @author      Sebastian Hack, Matthias Braun
 * @date        27.06.2005
 */
#ifndef FIRM_BE_BEUSES_H
#define FIRM_BE_BEUSES_H

#include <stdbool.h>
#include "firm_types.h"
#include "belive.h"

/**
 * Describes a use of a value.
 */
typedef struct be_next_use_t {
	unsigned       time;
	unsigned       outermost_loop;
	/* point of the next use is at the beginning of this node. */
	const ir_node *before;
} be_next_use_t;

#define USES_INFINITY  10000000
#define USES_PENDING   9999999

static inline bool USES_IS_INFINITE(unsigned time)
{
	return time >= USES_INFINITY;
}

static inline bool USES_IS_PENDING(unsigned time)
{
	return time == USES_PENDING;
}

typedef struct be_uses_t be_uses_t;

be_next_use_t be_get_next_use(be_uses_t *uses, ir_node *from,
                              const ir_node *def, bool skip_from_uses);

/**
 * Creates a new uses environment for a graph.
 *
 * @param irg  the graph
 * @param lv   liveness information for the graph
 */
be_uses_t *be_begin_uses(ir_graph *irg, const be_lv_t *lv);

/**
 * Destroys the given uses environment.
 *
 * @param uses  the environment
 */
void be_end_uses(be_uses_t *uses);

#endif