summaryrefslogtreecommitdiffhomepage
path: root/ir/be/beutil.h
blob: 3a86603a44e8a627c15fecf8aab4c565cca0936d (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
/*
 * This file is part of libFirm.
 * Copyright (C) 2012 University of Karlsruhe.
 */

/**
 * @file
 * @brief       Contains some useful function for the backend.
 * @author      Sebastian Hack
 */
#ifndef FIRM_BE_BEUTIL_H
#define FIRM_BE_BEUTIL_H

#include "entity_t.h"
#include "firm_types.h"
#include "irprog_t.h"

#include "be_types.h"

/**
 * Returns an array (an ARR_F) of the programs blocks in reverse postorder
 * (note: caller has to free the memory with DEL_ARR_F after use;
 *  of course you can use ARR_LEN on the array too.)
 */
ir_node **be_get_cfgpostorder(ir_graph *irg);

static inline bool is_tls_entity(const ir_entity *const ent)
{
	return get_entity_owner(ent) == get_tls_type();
}

/**
 * Insert a Perm which permutes all (non-ignore) live values of a given register class
 * before a certain instruction.
 * @param lv        Liveness Information.
 * @param irn       The node to insert the Perm before.
 * @return          The Perm or NULL if nothing was live before @p irn.
 */
ir_node *insert_Perm_before(ir_graph *irg, const arch_register_class_t *cls,
						   ir_node *irn);

/**
 * Removes dead nodes from schedule
 * @param irg  the graph
 */
void be_remove_dead_nodes_from_schedule(ir_graph *irg);

/**
 * Keep the given node alive, if it has no users, by adding a be_Keep.
 *
 * @param node  The node to kept alive.
 */
void be_keep_if_unused(ir_node *node);

#endif