⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 print-tree.c

📁 GUN开源阻止下的编译器GCC
💻 C
📖 第 1 页 / 共 2 页
字号:
/* Prints out tree in human readable form - GNU C-compiler   Copyright (C) 1990, 1991, 1993, 1994, 1995 Free Software Foundation, Inc.This file is part of GNU CC.GNU CC is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2, or (at your option)any later version.GNU CC is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with GNU CC; see the file COPYING.  If not, write tothe Free Software Foundation, 59 Temple Place - Suite 330,Boston, MA 02111-1307, USA.  */#include "config.h"#include "tree.h"#include <stdio.h>extern char **tree_code_name;extern char *mode_name[];void print_node ();void indent_to ();/* Define the hash table of nodes already seen.   Such nodes are not repeated; brief cross-references are used.  */#define HASH_SIZE 37struct bucket{  tree node;  struct bucket *next;};static struct bucket **table;/* Print the node NODE on standard error, for debugging.   Most nodes referred to by this one are printed recursively   down to a depth of six.  */voiddebug_tree (node)     tree node;{  char *object = (char *) oballoc (0);  table = (struct bucket **) oballoc (HASH_SIZE * sizeof (struct bucket *));  bzero ((char *) table, HASH_SIZE * sizeof (struct bucket *));  print_node (stderr, "", node, 0);  table = 0;  obfree (object);  fprintf (stderr, "\n");}/* Print a node in brief fashion, with just the code, address and name.  */voidprint_node_brief (file, prefix, node, indent)     FILE *file;     char *prefix;     tree node;     int indent;{  char class;  if (node == 0)    return;  class = TREE_CODE_CLASS (TREE_CODE (node));  /* Always print the slot this node is in, and its code, address and     name if any.  */  if (indent > 0)    fprintf (file, " ");  fprintf (file, "%s <%s ", prefix, tree_code_name[(int) TREE_CODE (node)]);  fprintf (file, HOST_PTR_PRINTF, (HOST_WIDE_INT) node);  if (class == 'd')    {      if (DECL_NAME (node))	fprintf (file, " %s", IDENTIFIER_POINTER (DECL_NAME (node)));    }  else if (class == 't')    {      if (TYPE_NAME (node))	{	  if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)	    fprintf (file, " %s", IDENTIFIER_POINTER (TYPE_NAME (node)));	  else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL		   && DECL_NAME (TYPE_NAME (node)))	    fprintf (file, " %s",		     IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node))));	}    }  if (TREE_CODE (node) == IDENTIFIER_NODE)    fprintf (file, " %s", IDENTIFIER_POINTER (node));  /* We might as well always print the value of an integer.  */  if (TREE_CODE (node) == INTEGER_CST)    {      if (TREE_CONSTANT_OVERFLOW (node))	fprintf (file, " overflow");      if (TREE_INT_CST_HIGH (node) == 0)	fprintf (file,#if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT		 " %1u",#else		 " %1lu",#endif		 TREE_INT_CST_LOW (node));      else if (TREE_INT_CST_HIGH (node) == -1	       && TREE_INT_CST_LOW (node) != 0)	fprintf (file,#if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT		 " -%1u",#else		 " -%1lu",#endif		 -TREE_INT_CST_LOW (node));      else	fprintf (file,#if HOST_BITS_PER_WIDE_INT == 64#if HOST_BITS_PER_WIDE_INT != HOST_BITS_PER_INT		 " 0x%lx%016lx",#else		 " 0x%x%016x",#endif#else#if HOST_BITS_PER_WIDE_INT != HOST_BITS_PER_INT		 " 0x%lx%08lx",#else		 " 0x%x%08x",#endif#endif		 TREE_INT_CST_HIGH (node), TREE_INT_CST_LOW (node));    }  if (TREE_CODE (node) == REAL_CST)    {      REAL_VALUE_TYPE d;      if (TREE_OVERFLOW (node))	fprintf (file, " overflow");#if !defined(REAL_IS_NOT_DOUBLE) || defined(REAL_ARITHMETIC)      d = TREE_REAL_CST (node);      if (REAL_VALUE_ISINF (d))	fprintf (file, " Inf");      else if (REAL_VALUE_ISNAN (d))	fprintf (file, " Nan");      else	{	  char string[100];	  REAL_VALUE_TO_DECIMAL (d, "%e", string);	  fprintf (file, " %s", string);	}#else      {	int i;	unsigned char *p = (unsigned char *) &TREE_REAL_CST (node);	fprintf (file, " 0x");	for (i = 0; i < sizeof TREE_REAL_CST (node); i++)	  fprintf (file, "%02x", *p++);	fprintf (file, "");      }#endif    }  fprintf (file, ">");}voidindent_to (file, column)     FILE *file;     int column;{  int i;  /* Since this is the long way, indent to desired column.  */  if (column > 0)    fprintf (file, "\n");  for (i = 0; i < column; i++)    fprintf (file, " ");}/* Print the node NODE in full on file FILE, preceded by PREFIX,   starting in column INDENT.  */voidprint_node (file, prefix, node, indent)     FILE *file;     char *prefix;     tree node;     int indent;{  int hash;  struct bucket *b;  enum machine_mode mode;  char class;  int len;  int first_rtl;  int i;  if (node == 0)    return;  class = TREE_CODE_CLASS (TREE_CODE (node));  /* Don't get too deep in nesting.  If the user wants to see deeper,     it is easy to use the address of a lowest-level node     as an argument in another call to debug_tree.  */  if (indent > 24)    {      print_node_brief (file, prefix, node, indent);      return;    }  if (indent > 8 && (class == 't' || class == 'd'))    {      print_node_brief (file, prefix, node, indent);      return;    }  /* It is unsafe to look at any other filds of an ERROR_MARK node. */  if (TREE_CODE (node) == ERROR_MARK)    {      print_node_brief (file, prefix, node, indent);      return;    }  hash = ((unsigned HOST_WIDE_INT) node) % HASH_SIZE;  /* If node is in the table, just mention its address.  */  for (b = table[hash]; b; b = b->next)    if (b->node == node)      {	print_node_brief (file, prefix, node, indent);	return;      }  /* Add this node to the table.  */  b = (struct bucket *) oballoc (sizeof (struct bucket));  b->node = node;  b->next = table[hash];  table[hash] = b;  /* Indent to the specified column, since this is the long form.  */  indent_to (file, indent);  /* Print the slot this node is in, and its code, and address.  */  fprintf (file, "%s <%s ", prefix, tree_code_name[(int) TREE_CODE (node)]);  fprintf (file, HOST_PTR_PRINTF, (HOST_WIDE_INT) node);  /* Print the name, if any.  */  if (class == 'd')    {      if (DECL_NAME (node))	fprintf (file, " %s", IDENTIFIER_POINTER (DECL_NAME (node)));    }  else if (class == 't')    {      if (TYPE_NAME (node))	{	  if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)	    fprintf (file, " %s", IDENTIFIER_POINTER (TYPE_NAME (node)));	  else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL		   && DECL_NAME (TYPE_NAME (node)))	    fprintf (file, " %s",		     IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node))));	}    }  if (TREE_CODE (node) == IDENTIFIER_NODE)    fprintf (file, " %s", IDENTIFIER_POINTER (node));  if (TREE_CODE (node) == INTEGER_CST)    {      if (indent <= 4)	print_node_brief (file, "type", TREE_TYPE (node), indent + 4);    }  else    {      print_node (file, "type", TREE_TYPE (node), indent + 4);      if (TREE_TYPE (node))	indent_to (file, indent + 3);      print_obstack_name ((char *) node, file, "");      indent_to (file, indent + 3);    }  /* If a permanent object is in the wrong obstack, or the reverse, warn.  */  if (object_permanent_p (node) != TREE_PERMANENT (node))    {      if (TREE_PERMANENT (node))	fputs (" !!permanent object in non-permanent obstack!!", file);      else	fputs (" !!non-permanent object in permanent obstack!!", file);      indent_to (file, indent + 3);    }  if (TREE_SIDE_EFFECTS (node))    fputs (" side-effects", file);  if (TREE_READONLY (node))    fputs (" readonly", file);  if (TREE_CONSTANT (node))    fputs (" constant", file);  if (TREE_ADDRESSABLE (node))    fputs (" addressable", file);  if (TREE_THIS_VOLATILE (node))    fputs (" volatile", file);  if (TREE_UNSIGNED (node))    fputs (" unsigned", file);  if (TREE_ASM_WRITTEN (node))    fputs (" asm_written", file);  if (TREE_USED (node))    fputs (" used", file);  if (TREE_RAISES (node))    fputs (" raises", file);  if (TREE_PERMANENT (node))    fputs (" permanent", file);  if (TREE_PUBLIC (node))    fputs (" public", file);  if (TREE_STATIC (node))    fputs (" static", file);  if (TREE_LANG_FLAG_0 (node))    fputs (" tree_0", file);  if (TREE_LANG_FLAG_1 (node))    fputs (" tree_1", file);  if (TREE_LANG_FLAG_2 (node))    fputs (" tree_2", file);  if (TREE_LANG_FLAG_3 (node))    fputs (" tree_3", file);  if (TREE_LANG_FLAG_4 (node))    fputs (" tree_4", file);  if (TREE_LANG_FLAG_5 (node))    fputs (" tree_5", file);  if (TREE_LANG_FLAG_6 (node))    fputs (" tree_6", file);  /* DECL_ nodes have additional attributes.  */  switch (TREE_CODE_CLASS (TREE_CODE (node)))    {    case 'd':      mode = DECL_MODE (node);      if (DECL_IGNORED_P (node))	fputs (" ignored", file);      if (DECL_ABSTRACT (node))	fputs (" abstract", file);      if (DECL_IN_SYSTEM_HEADER (node))	fputs (" in_system_header", file);      if (DECL_COMMON (node))	fputs (" common", file);      if (DECL_EXTERNAL (node))	fputs (" external", file);      if (DECL_REGISTER (node))	fputs (" regdecl", file);      if (DECL_PACKED (node))	fputs (" packed", file);      if (DECL_NONLOCAL (node))

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -