instrument.c 939 Bytes
Newer Older
Michael Beck's avatar
Michael Beck committed
1
2
/*
 * This file is part of libFirm.
3
 * Copyright (C) 2012 University of Karlsruhe.
Michael Beck's avatar
Michael Beck committed
4
5
6
7
8
9
10
11
 */

/**
 * @file
 * @brief   Instrumentation of graphs.
 * @date    14.4.2008
 * @author  Michael Beck
 */
Matthias Braun's avatar
Matthias Braun committed
12
13
#include <stdbool.h>

Michael Beck's avatar
Michael Beck committed
14
#include "instrument.h"
Matthias Braun's avatar
Matthias Braun committed
15
#include "ircons.h"
16
#include "iredges_t.h"
Matthias Braun's avatar
Matthias Braun committed
17
#include "irgraph_t.h"
Michael Beck's avatar
Michael Beck committed
18

19
20
void instrument_initcall(ir_graph *irg, ir_entity *ent)
{
21
	assure_edges(irg);
Michael Beck's avatar
Michael Beck committed
22
23

	/* place the call */
24
	ir_node *const start_block = get_irg_start_block(irg);
25
	ir_node *const adr         = new_r_Address(irg, ent);
26
	ir_node *const initial_mem = get_irg_initial_mem(irg);
27
	ir_node *const call        = new_r_Call(start_block, initial_mem, adr, 0,
Matthias Braun's avatar
Matthias Braun committed
28
	                                        NULL, get_entity_type(ent));
29
	ir_node *const new_mem     = new_r_Proj(call, mode_M, pn_Call_M);
Michael Beck's avatar
Michael Beck committed
30

31
	edges_reroute_except(initial_mem, new_mem, call);
Michael Beck's avatar
Michael Beck committed
32
33
34
	/* beware: reroute routes anchor edges also, revert this */
	set_irg_initial_mem(irg, initial_mem);
}