firm_ycomp.c 16.6 KB
Newer Older
Christian Würdig's avatar
Christian Würdig committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*
 * Copyright (C) 1995-2007 University of Karlsruhe.  All right reserved.
 *
 * This file is part of libFirm.
 *
 * This file may be distributed and/or modified under the terms of the
 * GNU General Public License version 2 as published by the Free Software
 * Foundation and appearing in the file LICENSE.GPL included in the
 * packaging of this file.
 *
 * Licensees holding valid libFirm Professional Edition licenses may use
 * this file in accordance with the libFirm Commercial License.
 * Agreement provided with the Software.
 *
 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE.
 */

Christian Würdig's avatar
Christian Würdig committed
20
21
22
23
24
25
26
27
28
29
/*
 * Project:     libFIRM
 * File name:   ir/debug/firm_ycomp.c
 * Purpose:     Connect firm to ycomp
 * Author:      Christian Wuerdig
 * Modified by:
 * Created:     16.11.2006
 * CVS-ID:      $Id$
 * Copyright:   (c) 2001-2006 Universitt Karlsruhe
 */
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif /* HAVE_CONFIG_H */

#include "assert.h"
#include "irhooks.h"
#include "firmnet.h"
#include "irnode.h"
#include "irgraph.h"
#include "irprintf.h"
#include "irprog.h"
#include "iredges.h"
#include "pset.h"
#include "obst.h"
44
#include "firmnet.h"
45
46

#define SEND_BUF_SIZE 256
Christian Würdig's avatar
Christian Würdig committed
47
48
49
#define HASH_EDGE(edge) \
	((get_irn_node_nr((edge)->src) << 17)          | \
	((get_irn_node_nr((edge)->tgt) & 0xEFFF) << 2) | \
Michael Beck's avatar
Michael Beck committed
50
	((edge)->pos & 0x3))
51
52
53
54

typedef struct _exchange_node_outs_assoc_t {
	int     n_out_edges;
	ir_node *irn;
55
	ir_node *nw;
56
57
} exchange_node_outs_assoc_t;

Christian Würdig's avatar
Christian Würdig committed
58
59
60
61
62
63
typedef struct _ycomp_edge_t {
	ir_node *src;
	ir_node *tgt;
	int     pos;
} ycomp_edge_t;

64
65
66
67
68
69
70
enum _firm_ycomp_node_realizer_values {
	NODE_REALIZER_NORMAL,
	NODE_REALIZER_PROJ,
	NODE_REALIZER_BLOCK,
	NODE_REALIZER_MEM,
	NODE_REALIZER_PHI,
	NODE_REALIZER_STARTEND,
71
72
	NODE_REALIZER_IRG,
	NODE_REALIZER_ID,
73
74
75
76
77
78
79
	NODE_REALIZER_LAST
};

typedef struct _firm_ycomp_node_realizer_t {
	unsigned   id;
	const char *linecolor;
	const char *fillcolor;
80
	const char *textcolor;
81
82
83
84
	const char *shape;
} firm_ycomp_node_realizer_t;

static firm_ycomp_node_realizer_t node_realizer[NODE_REALIZER_LAST] = {
85
86
87
88
89
90
91
92
	{ NODE_REALIZER_NORMAL,   "black", "white",    "black", "box" },
	{ NODE_REALIZER_PROJ,     "black", "yellow",   "black", "box" },
	{ NODE_REALIZER_BLOCK,    "black", "yellow",   "white", "box" },
	{ NODE_REALIZER_MEM,      "black", "blue",     "black", "box" },
	{ NODE_REALIZER_PHI,      "black", "green",    "black", "box" },
	{ NODE_REALIZER_STARTEND, "black", "blue",     "black", "box" },
	{ NODE_REALIZER_IRG,      "black", "white",    "white", "box" },
	{ NODE_REALIZER_ID,       "black", "darkgrey", "black", "box" },
93
94
95
96
97
98
99
100
101
102
103
104
105
};

enum _firm_ycomp_edge_realizer_values {
	EDGE_REALIZER_DATA,
	EDGE_REALIZER_MEM,
	EDGE_REALIZER_DEP,
	EDGE_REALIZER_CFG,
	EDGE_REALIZER_LAST
};

typedef struct _firm_ycomp_edge_realizer_t {
	unsigned   id;
	const char *linecolor;
106
	const char *textcolor;
107
108
109
110
111
	unsigned   thickness;
	const char *style;
} firm_ycomp_edge_realizer_t;

static firm_ycomp_edge_realizer_t edge_realizer[EDGE_REALIZER_LAST] = {
112
113
114
115
	{ EDGE_REALIZER_DATA, "black", "black", 1, "continuous" },
	{ EDGE_REALIZER_MEM,  "blue",  "black", 1, "continuous" },
	{ EDGE_REALIZER_DEP,  "green", "black", 1, "continuous" },
	{ EDGE_REALIZER_CFG,  "red",   "black", 1, "continuous" },
116
117
118
119
120
121
};

typedef struct _firm_ycomp_dbg_t {
	int            fd;
	int            has_data;
	pset           *exchanged_nodes;
Christian Würdig's avatar
Christian Würdig committed
122
	pset           *edges;
123
	unsigned       in_dead_node_elim : 1;
124
125
	struct obstack obst;
	hook_entry_t   hook_new_irn;
126
	hook_entry_t   hook_new_irg;
127
128
	hook_entry_t   hook_set_edge;
	hook_entry_t   hook_exchange;
129
130
	hook_entry_t   hook_into_id;
	hook_entry_t   hook_dead_node;
131
132
133
134
} firm_ycomp_dbg_t;

static firm_ycomp_dbg_t yy_dbg;

Christian Würdig's avatar
Christian Würdig committed
135
136
137
138
139
140
141
static int cmp_edges(const void *a, const void *b) {
	ycomp_edge_t *e1 = (ycomp_edge_t *)a;
	ycomp_edge_t *e2 = (ycomp_edge_t *)b;

	return (e1->src != e2->src) || (e1->tgt != e2->tgt) || (e1->pos != e2->pos);
}

142
static int cmp_nodes(const void *a, const void *b) {
Christian Würdig's avatar
Christian Würdig committed
143
144
	exchange_node_outs_assoc_t *n1 = (exchange_node_outs_assoc_t *)a;
	exchange_node_outs_assoc_t *n2 = (exchange_node_outs_assoc_t *)b;
145
146
147
148

	return n1->irn != n2->irn;
}

149
static INLINE void send_cmd(firm_ycomp_dbg_t *dbg, const char *buf) {
150
151
152
	ssize_t res, len;

	len = strlen(buf);
153
	res = firmnet_send(dbg->fd, (const void *)buf, len);
154
155
156
	assert(res == len);
}

157
static void wait_for_sync(firm_ycomp_dbg_t *dbg) {
158
	char buf[6];
159
160
	firmnet_recv(dbg->fd, buf, 6, 5);
}
161

162
163
164
165
static void show_and_sync(firm_ycomp_dbg_t *dbg) {
	send_cmd(dbg, "show\n");
	send_cmd(dbg, "sync\n");
	wait_for_sync(dbg);
166
167
}

168
169
170
171
/**
 * Register the edge and node realizer in yComp.
 */
static void firm_ycomp_debug_init_realizer(firm_ycomp_dbg_t *dbg) {
172
173
174
175
	int  i;
	char buf[SEND_BUF_SIZE];

	for (i = 0; i < NODE_REALIZER_LAST; ++i) {
176
		snprintf(buf, sizeof(buf), "addNodeRealizer \"%u\" \"%s\" \"%s\" \"%s\" \"%s\"\n",
177
178
179
			node_realizer[i].id,
			node_realizer[i].linecolor,
			node_realizer[i].fillcolor,
180
			node_realizer[i].textcolor,
181
			node_realizer[i].shape);
182
		send_cmd(dbg, buf);
183
184
185
	}

	for (i = 0; i < EDGE_REALIZER_LAST; ++i) {
186
		snprintf(buf, sizeof(buf), "addEdgeRealizer \"%u\" \"%s\" \"%s\" \"%u\" \"%s\"\n",
187
188
			edge_realizer[i].id,
			edge_realizer[i].linecolor,
189
			edge_realizer[i].textcolor,
190
191
			edge_realizer[i].thickness,
			edge_realizer[i].style);
192
		send_cmd(dbg, buf);
193
194
195
	}
}

196
197
198
/**
 * Retrieve the appropriate realizer for given node.
 */
199
200
static INLINE unsigned get_node_realizer(ir_node *node) {
	unsigned realizer;
201
	ir_opcode opc = get_irn_opcode(node);
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226

	switch (opc) {
		case iro_Block:
			realizer = NODE_REALIZER_BLOCK;
			break;
		case iro_Phi:
			realizer = NODE_REALIZER_PHI;
			break;
		case iro_Proj:
			if (get_irn_mode(node) == mode_M)
				realizer = NODE_REALIZER_MEM;
			else
				realizer = NODE_REALIZER_PROJ;
			break;
		case iro_Start:
		case iro_End:
			realizer = NODE_REALIZER_STARTEND;
			break;
		default:
			realizer = NODE_REALIZER_NORMAL;
	};

	return realizer;
}

227
228
229
/**
 * Retrieve the appropriate realizer for given edge.
 */
230
231
static INLINE unsigned get_edge_realizer(ir_node *src, ir_node *tgt) {
	unsigned realizer;
232
	ir_mode  *tgt_mode, *src_mode;
233

234
235
	if (is_Block(tgt) || is_Block(src))
		return EDGE_REALIZER_CFG;
236

237
238
	tgt_mode = get_irn_mode(tgt);
	src_mode = is_Block(src) ? NULL : get_irn_mode(src);
239

240
	if (tgt_mode == mode_M || (src_mode == mode_M && tgt_mode == mode_T))
241
		realizer = EDGE_REALIZER_MEM;
242
	else if (tgt_mode == mode_X)
243
244
245
246
247
248
249
		realizer = EDGE_REALIZER_CFG;
	else
		realizer = EDGE_REALIZER_DATA;

	return realizer;
}

250
/**
251
 * Hook: Add new nodes, resp. new blocks in yComp and add input edges.
252
 */
253
static void firm_ycomp_debug_new_node(void *context, ir_graph *graph, ir_node *node) {
Christian Würdig's avatar
Christian Würdig committed
254
	firm_ycomp_dbg_t *dbg = context;
255
256
257
	char             buf[SEND_BUF_SIZE];
	int              i;
	unsigned         src_idx;
258

259
	if (get_const_code_irg() == graph || dbg->in_dead_node_elim)
260
261
		return;

262
	src_idx       = get_irn_node_nr(node);
Christian Würdig's avatar
Christian Würdig committed
263
	dbg->has_data = 1;
264

265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
	if (is_Block(node)) {
		/* add block (subgraph) */
		ir_snprintf(buf, sizeof(buf), "addSubgraphNode \"%d\" \"%d\" \"%u\" \"%+F\"\n",
			0,                     /* parent id */
			get_irn_node_nr(node), /* graph id */
			NODE_REALIZER_BLOCK,   /* realizer id */
			node);                 /* label */
	}
	else {
		/* add node */
		ir_snprintf(buf, sizeof(buf), "addNode \"%d\" \"%u\" \"%u\" \"%+F\"\n",
			get_irn_node_nr(get_nodes_block(node)), /* parent id */
			src_idx,                                /* node id */
			get_node_realizer(node),                /* realizer id */
			node);                                  /* label */
	}
	send_cmd(dbg, buf);
282
283
284

	/* add edges */
	for (i = get_irn_arity(node) - 1; i >= 0; --i) {
Christian Würdig's avatar
Christian Würdig committed
285
286
287
		ir_node      *pred   = get_irn_n(node, i);
		unsigned     tgt_idx = get_irn_node_nr(pred);
		ycomp_edge_t key, *entry;
288
289
290
291
292
293
294

		ir_snprintf(buf, sizeof(buf), "addEdge \"n%un%up%d\" \"%u\" \"%u\" \"%u\" \"%d\"\n",
			src_idx, tgt_idx, i,            /* edge id */
			src_idx,                        /* source node id */
			tgt_idx,                        /* target node id */
			get_edge_realizer(node, pred),  /* realizer id */
			i);                             /* title */
295
		send_cmd(dbg, buf);
Christian Würdig's avatar
Christian Würdig committed
296
297
298
299
300
301
302
303
304
305
306
307
308

		/* insert edge */
		key.src = node;
		key.tgt = pred;
		key.pos = i;
		entry   = pset_find(dbg->edges, &key, HASH_EDGE(&key));
		if (! entry) {
			entry = obstack_alloc(&dbg->obst, sizeof(*entry));
			entry->src = node;
			entry->tgt = pred;
			entry->pos = i;
			pset_insert(dbg->edges, entry, HASH_EDGE(entry));
		}
309
310
	}

311
	show_and_sync(dbg);
312
313
}

314
315
316
/**
 * Clear the old irg if it has some data and create a new one.
 */
317
static void firm_ycomp_debug_new_irg(void *context, ir_graph *irg, ir_entity *ent) {
318
319
320
	firm_ycomp_dbg_t *dbg = context;
	char             buf[SEND_BUF_SIZE];

321
	if (yy_dbg.has_data) {
322
		send_cmd(dbg, "deleteGraph\n");
323
//		send_cmd(dbg, "show\n");
324
	}
325
326
327
328
329
330
331
	dbg->has_data = 0;

	ir_snprintf(buf, sizeof(buf), "addSubgraphNode \"-1\" \"0\" \"%u\" \"%s\"\n",
		NODE_REALIZER_IRG, get_entity_name(ent));
	send_cmd(dbg, buf);
	send_cmd(dbg, "sync\n");
	wait_for_sync(dbg);
332
333
}

334
/**
335
 * Hook: Handle set_irn_n calls.
336
337
338
 * - set new Block      OR
 * - remove old edge and add new one
 */
339
static void firm_ycomp_debug_set_edge(void *context, ir_node *src, int pos, ir_node *tgt, ir_node *old_tgt) {
340
341
342
	firm_ycomp_dbg_t           *dbg   = context;
	exchange_node_outs_assoc_t *entry = NULL;
	exchange_node_outs_assoc_t key;
Christian Würdig's avatar
Christian Würdig committed
343
	ycomp_edge_t               *old_edge, *new_edge, edge_key;
344
	char                       buf[SEND_BUF_SIZE];
345
	unsigned                   src_idx, tgt_idx;
346

347
348
349
	if (dbg->in_dead_node_elim)
		return;

350
351
	src_idx = get_irn_node_nr(src);
	tgt_idx = get_irn_node_nr(tgt);
352
353
354
355
356
357
358
359

	/* set_irn_n with pos -1 means: node moves to new block  */
	if (pos < 0) {
		if (tgt != old_tgt) {
			snprintf(buf, sizeof(buf), "moveNode \"%d\" \"%d\"\n", src_idx, tgt_idx);
			send_cmd(dbg, buf);
			show_and_sync(dbg);
		}
360
		return;
361
	}
362

Christian Würdig's avatar
Christian Würdig committed
363
364
365
366
367
368
369
370
371
372
373
	/* check if the new edge exists */
	edge_key.src = src;
	edge_key.tgt = tgt;
	edge_key.pos = pos;
	new_edge     = pset_find(dbg->edges, &edge_key, HASH_EDGE(&edge_key));

	/* if the new edge already exists and the old target is the new target -> ignore */
	if (new_edge && tgt == old_tgt)
		return;

	/* check if the old edge exists */
374
375
	if (old_tgt) {
		int old_tgt_idx = get_irn_node_nr(old_tgt);
Christian Würdig's avatar
Christian Würdig committed
376

377
378
379
380
		edge_key.src = src;
		edge_key.tgt = old_tgt;
		edge_key.pos = pos;
		old_edge     = pset_find(dbg->edges, &edge_key, HASH_EDGE(&edge_key));
381

382
383
384
		/* check if old target is marked for exchange */
		key.irn = old_tgt;
		entry   = pset_find(dbg->exchanged_nodes, &key, HASH_PTR(old_tgt));
385

386
387
388
389
390
391
392
393
394
395
396
		if (entry) {
			/* we are called from exchange() */
			entry->n_out_edges--;
		}

		/* delete the old edge if it exists */
		if (old_edge) {
			snprintf(buf, sizeof(buf), "deleteEdge \"n%un%up%d\"\n", src_idx, old_tgt_idx, pos);
			send_cmd(dbg, buf);
			pset_remove(dbg->edges, old_edge, HASH_EDGE(old_edge));
		}
Christian Würdig's avatar
Christian Würdig committed
397
	}
398

Christian Würdig's avatar
Christian Würdig committed
399
400
401
402
403
404
405
406
	if (! new_edge) {
		/* add the new edge if it doesn't exist */
		snprintf(buf, sizeof(buf), "addEdge \"n%un%up%d\" \"%u\" \"%u\" \"%u\" \"%d\"\n",
			src_idx, tgt_idx, pos,          /* edge id */
			src_idx,                        /* source node id */
			tgt_idx,                        /* target node id */
			get_edge_realizer(src, tgt),    /* realizer id */
			pos);                           /* title */
407
		send_cmd(dbg, buf);
Christian Würdig's avatar
Christian Würdig committed
408
409
410
411
412
413
414
415

		/* insert the new edge */
		new_edge      = obstack_alloc(&dbg->obst, sizeof(*new_edge));
		new_edge->src = src;
		new_edge->tgt = tgt;
		new_edge->pos = pos;
		pset_insert(dbg->edges, new_edge, HASH_EDGE(new_edge));
	}
416
417
418

	/* show and sync if all edges are rerouted or if it's a normal set_irn_n */
	if (! entry || entry->n_out_edges == 0) {
419
		show_and_sync(dbg);
420
421
422
	}
}

423
/**
424
 * Hook: Put nodes, about to be exchanged into a set.
425
 */
426
427
428
429
static void firm_ycomp_debug_exchange(void *context, ir_node *old_node, ir_node *new_node) {
	firm_ycomp_dbg_t           *dbg = context;
	exchange_node_outs_assoc_t key, *entry;

430
431
	/* put nodes, which are about to be exchanged into a set */

432
433
434
435
	key.irn = old_node;
	entry   = pset_find(dbg->exchanged_nodes, &key, HASH_PTR(old_node));
	if (entry) {
		entry->n_out_edges = get_irn_n_edges(old_node);
436
		entry->nw          = new_node;
437
438
439
440
	}
	else {
		entry              = obstack_alloc(&dbg->obst, sizeof(*entry));
		entry->irn         = old_node;
441
		entry->nw          = new_node;
442
443
444
445
446
		entry->n_out_edges = get_irn_n_edges(old_node);
		pset_insert(dbg->exchanged_nodes, entry, HASH_PTR(old_node));
	}
}

447
/**
448
 * Hook: Remove all old in edges, turn node into id node, add new input edge.
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
 */
static void firm_ycomp_debug_turn_into_id(void *context, ir_node *old_node) {
	firm_ycomp_dbg_t           *dbg = context;
	exchange_node_outs_assoc_t key, *entry;
	int                        i;
	char                       buf[SEND_BUF_SIZE];
	unsigned                   src_idx, tgt_idx;
	ycomp_edge_t               edge_key, *new_edge;

	key.irn = old_node;
	entry   = pset_find(dbg->exchanged_nodes, &key, HASH_PTR(old_node));

	assert(entry != NULL && "Exchange entry missing");

	src_idx = get_irn_node_nr(old_node);
	tgt_idx = get_irn_node_nr(entry->nw);

	/* remove all old edges */
	for (i = get_irn_arity(old_node) - 1; i >= 0; --i) {
		ycomp_edge_t *old_edge;
		unsigned     old_tgt_idx;

		/* check if the old edge exists */
		edge_key.src = old_node;
		edge_key.tgt = get_irn_n(old_node, i);
		edge_key.pos = i;
		old_edge     = pset_find(dbg->edges, &edge_key, HASH_EDGE(&edge_key));

		old_tgt_idx  = get_irn_node_nr(edge_key.tgt);

		/* remove the old edge */
		if (old_edge) {
			snprintf(buf, sizeof(buf), "deleteEdge \"n%un%up%d\"\n", src_idx, old_tgt_idx, i);
			send_cmd(dbg, buf);
			pset_remove(dbg->edges, old_edge, HASH_EDGE(old_edge));
		}
	}

	/* change the old node into an id node */
	snprintf(buf, sizeof(buf), "changeNode \"%ld\" \"%u\"\n", get_irn_node_nr(old_node), NODE_REALIZER_ID);
	send_cmd(dbg, buf);

	/* add new Id input */
	snprintf(buf, sizeof(buf), "addEdge \"n%un%up%d\" \"%u\" \"%u\" \"%u\" \"%d\"\n",
		src_idx, tgt_idx, 0,                       /* edge id */
		src_idx,                                   /* source node id */
		tgt_idx,                                   /* target node id */
		get_edge_realizer(old_node, entry->nw),    /* realizer id */
		0);                                        /* title */
	send_cmd(dbg, buf);

	/* go */
	show_and_sync(dbg);

	/* add the new edge to our pset */
	new_edge = obstack_alloc(&dbg->obst, sizeof(*new_edge));
	new_edge->src = old_node;
	new_edge->tgt = entry->nw;
	new_edge->pos = 0;
	pset_insert(dbg->edges, new_edge, HASH_EDGE(new_edge));
}

/**
512
 * Hook: Just mark start/end of dead node elimination.
513
514
515
516
517
518
519
520
521
 */
static void firm_ycomp_debug_dead_node_elim(void *context, ir_graph *irg, int start) {
	firm_ycomp_dbg_t *dbg  = context;
	dbg->in_dead_node_elim = start != 0;
}

/**
 * Establish connection to yComp and register all hooks.
 */
522
void firm_init_ycomp_debugger(const char *host, unsigned port) {
523
524
525
526
527
528
529
530
	static int init_once = 0;

	if (init_once)
		return;

	memset(&yy_dbg, 0, sizeof(yy_dbg));
	yy_dbg.fd = -1;

531
	fprintf(stderr, "connecting to %s:%u\n", host, port);
532
533
534
535
	yy_dbg.fd = firmnet_connect_tcp(host, port);

	if (yy_dbg.fd > -1) {
		/* We could establish a connection to ycomp -> register hooks */
536
		firm_ycomp_debug_init_realizer(&yy_dbg);
537
		yy_dbg.exchanged_nodes = new_pset(cmp_nodes, 20);
Christian Würdig's avatar
Christian Würdig committed
538
		yy_dbg.edges           = new_pset(cmp_edges, 20);
539
540
		obstack_init(&yy_dbg.obst);

541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
#define REGISTER_HOOK(ycomp_hook, firm_hook, func)     \
	do {                                               \
		yy_dbg.ycomp_hook.context           = &yy_dbg; \
		yy_dbg.ycomp_hook.hook._##firm_hook = func;    \
		register_hook(firm_hook, &yy_dbg.ycomp_hook);  \
	} while(0)

		REGISTER_HOOK(hook_new_irn,   hook_new_node,       firm_ycomp_debug_new_node);
		REGISTER_HOOK(hook_new_irg,   hook_new_graph,      firm_ycomp_debug_new_irg);
		REGISTER_HOOK(hook_set_edge,  hook_set_irn_n,      firm_ycomp_debug_set_edge);
		REGISTER_HOOK(hook_exchange,  hook_replace,        firm_ycomp_debug_exchange);
		REGISTER_HOOK(hook_into_id,   hook_turn_into_id,   firm_ycomp_debug_turn_into_id);
		REGISTER_HOOK(hook_dead_node, hook_dead_node_elim, firm_ycomp_debug_dead_node_elim);

#undef REGISTER_HOOK
556
557
558
559
560
	}

	init_once = 1;
}

561
562
563
/**
 * Close connection to yComp, unregister all hooks and free memory.
 */
564
565
void firm_finish_ycomp_debugger(void) {
	if (yy_dbg.fd > -1) {
566
		/* close connection */
567
		firmnet_close_socket(yy_dbg.fd);
568
569
570
571
572
573
574
575
576
577
578
		yy_dbg.fd = -1;

		/* unregister all hooks */
		unregister_hook(hook_new_graph,      &yy_dbg.hook_new_irg);
		unregister_hook(hook_new_node,       &yy_dbg.hook_new_irn);
		unregister_hook(hook_set_irn_n,      &yy_dbg.hook_set_edge);
		unregister_hook(hook_replace,        &yy_dbg.hook_exchange);
		unregister_hook(hook_dead_node_elim, &yy_dbg.hook_dead_node);
		unregister_hook(hook_turn_into_id,   &yy_dbg.hook_into_id);

		/* clear sets */
579
		del_pset(yy_dbg.exchanged_nodes);
Christian Würdig's avatar
Christian Würdig committed
580
		del_pset(yy_dbg.edges);
581
582

		/* free data obstack */
583
584
585
		obstack_free(&yy_dbg.obst, NULL);
	}
}