190075Sobrien/* Tree-dumping functionality for intermediate representation.
2169689Skan   Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
390075Sobrien   Written by Mark Mitchell <mark@codesourcery.com>
490075Sobrien
590075SobrienThis file is part of GCC.
690075Sobrien
790075SobrienGCC is free software; you can redistribute it and/or modify it under
890075Sobrienthe terms of the GNU General Public License as published by the Free
990075SobrienSoftware Foundation; either version 2, or (at your option) any later
1090075Sobrienversion.
1190075Sobrien
1290075SobrienGCC is distributed in the hope that it will be useful, but WITHOUT ANY
1390075SobrienWARRANTY; without even the implied warranty of MERCHANTABILITY or
1490075SobrienFITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1590075Sobrienfor more details.
1690075Sobrien
1790075SobrienYou should have received a copy of the GNU General Public License
1890075Sobrienalong with GCC; see the file COPYING.  If not, write to the Free
19169689SkanSoftware Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
20169689Skan02110-1301, USA.  */
2190075Sobrien
2290075Sobrien#ifndef GCC_TREE_DUMP_H
2390075Sobrien#define GCC_TREE_DUMP_H
2490075Sobrien
25169689Skan#include "splay-tree.h"
26169689Skan#include "tree-pass.h"
27169689Skan
28169689Skantypedef struct dump_info *dump_info_p;
29169689Skan
3090075Sobrien/* Flags used with queue functions.  */
3190075Sobrien#define DUMP_NONE     0
3290075Sobrien#define DUMP_BINFO    1
3390075Sobrien
3490075Sobrien/* Information about a node to be dumped.  */
3590075Sobrien
3690075Sobrientypedef struct dump_node_info
3790075Sobrien{
3890075Sobrien  /* The index for the node.  */
3990075Sobrien  unsigned int index;
4090075Sobrien  /* Nonzero if the node is a binfo.  */
4190075Sobrien  unsigned int binfo_p : 1;
4290075Sobrien} *dump_node_info_p;
4390075Sobrien
4490075Sobrien/* A dump_queue is a link in the queue of things to be dumped.  */
4590075Sobrien
4690075Sobrientypedef struct dump_queue
4790075Sobrien{
4890075Sobrien  /* The queued tree node.  */
4990075Sobrien  splay_tree_node node;
5090075Sobrien  /* The next node in the queue.  */
5190075Sobrien  struct dump_queue *next;
5290075Sobrien} *dump_queue_p;
5390075Sobrien
54117395Skan/* A dump_info gives information about how we should perform the dump
5590075Sobrien   and about the current state of the dump.  */
5690075Sobrien
5790075Sobrienstruct dump_info
5890075Sobrien{
5990075Sobrien  /* The stream on which to dump the information.  */
6090075Sobrien  FILE *stream;
6190075Sobrien  /* The original node.  */
6290075Sobrien  tree node;
6390075Sobrien  /* User flags.  */
6490075Sobrien  int flags;
6590075Sobrien  /* The next unused node index.  */
6690075Sobrien  unsigned int index;
6790075Sobrien  /* The next column.  */
6890075Sobrien  unsigned int column;
6990075Sobrien  /* The first node in the queue of nodes to be written out.  */
7090075Sobrien  dump_queue_p queue;
7190075Sobrien  /* The last node in the queue.  */
7290075Sobrien  dump_queue_p queue_end;
7390075Sobrien  /* Free queue nodes.  */
7490075Sobrien  dump_queue_p free_list;
75117395Skan  /* The tree nodes which we have already written out.  The
7690075Sobrien     keys are the addresses of the nodes; the values are the integer
7790075Sobrien     indices we assigned them.  */
7890075Sobrien  splay_tree nodes;
7990075Sobrien};
8090075Sobrien
8190075Sobrien/* Dump the CHILD and its children.  */
8290075Sobrien#define dump_child(field, child) \
8390075Sobrien  queue_and_dump_index (di, field, child, DUMP_NONE)
8490075Sobrien
85132718Skanextern void dump_pointer (dump_info_p, const char *, void *);
86132718Skanextern void dump_int (dump_info_p, const char *, int);
87132718Skanextern void dump_string (dump_info_p, const char *);
88169689Skanextern void dump_string_field (dump_info_p, const char *, const char *);
89132718Skanextern void dump_stmt (dump_info_p, tree);
90132718Skanextern void queue_and_dump_index (dump_info_p, const char *, tree, int);
91132718Skanextern void queue_and_dump_type (dump_info_p, tree);
92169689Skanextern void dump_function (enum tree_dump_index, tree);
93169689Skanextern void dump_function_to_file (tree, FILE *, int);
94169689Skanextern void debug_function (tree, int);
95169689Skanextern int dump_flag (dump_info_p, int, tree);
9690075Sobrien
97169689Skanextern unsigned int dump_register (const char *, const char *, const char *,
98169689Skan				   int, int);
99169689Skan
100169689Skan
10190075Sobrien#endif /* ! GCC_TREE_DUMP_H */
102