(linenum→info "unix/slp.c:2238")

gcc/4.2.2/gcc/print-tree.c

    1: /* Prints out tree in human readable form - GCC
    2:    Copyright (C) 1990, 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
    3:    2001, 2002, 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
    4: 
    5: This file is part of GCC.
    6: 
    7: GCC is free software; you can redistribute it and/or modify it under
    8: the terms of the GNU General Public License as published by the Free
    9: Software Foundation; either version 3, or (at your option) any later
   10: version.
   11: 
   12: GCC is distributed in the hope that it will be useful, but WITHOUT ANY
   13: WARRANTY; without even the implied warranty of MERCHANTABILITY or
   14: FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   15: for more details.
   16: 
   17: You should have received a copy of the GNU General Public License
   18: along with GCC; see the file COPYING3.  If not see
   19: <http://www.gnu.org/licenses/>.  */
   20: 
   21: 
   22: #include "config.h"
   23: #include "system.h"
   24: #include "coretypes.h"
   25: #include "tm.h"
   26: #include "tree.h"
   27: #include "real.h"
   28: #include "ggc.h"
   29: #include "langhooks.h"
   30: #include "tree-iterator.h"
   31: 
   32: /* Define the hash table of nodes already seen.
   33:    Such nodes are not repeated; brief cross-references are used.  */
   34: 
   35: #define HASH_SIZE 37
   36: 
   37: struct bucket
   38: {
   39:   tree node;
   40:   struct bucket *next;
   41: };
Permalink to this note guest: gcc/4.2.2/gcc/print-tree.c:37-41 on Thu Jan 17 08:55:50 +0900 2008

リスト構造: 要素に木構造を持つ by M.I

42: 43: static struct bucket **table; 44: 45: /* Print the node NODE on standard error, for debugging. 46: Most nodes referred to by this one are printed recursively 47: down to a depth of six. */ 48: 49: void 50: debug_tree (tree node) 51: { 52: table = XCNEWVEC (struct bucket *, HASH_SIZE); 53: print_node (stderr, "", node, 0); 54: free (table); 55: table = 0; 56: putc ('\n', stderr); 57: } 58: 59: /* Print PREFIX and ADDR to FILE. */ 60: void 61: dump_addr (FILE *file, const char *prefix, void *addr) 62: { 63: if (flag_dump_noaddr || flag_dump_unnumbered) 64: fprintf (file, "%s#", prefix); 65: else 66: fprintf (file, "%s%p", prefix, addr); 67: } 68: 69: /* Print a node in brief fashion, with just the code, address and name. */ 70: 71: void 72: print_node_brief (FILE *file, const char *prefix, tree node, int indent) 73: { 74: enum tree_code_class class; 75: 76: if (node == 0) 77: return; 78: 79: class = TREE_CODE_CLASS (TREE_CODE (node)); 80: 81: /* Always print the slot this node is in, and its code, address and 82: name if any. */ 83: if (indent > 0) 84: fprintf (file, " "); 85: fprintf (file, "%s <%s", prefix, tree_code_name[(int) TREE_CODE (node)]); 86: dump_addr (file, " ", node); 87: 88: if (class == tcc_declaration) 89: { 90: if (DECL_NAME (node)) 91: fprintf (file, " %s", IDENTIFIER_POINTER (DECL_NAME (node))); 92: else if (TREE_CODE (node) == LABEL_DECL 93: && LABEL_DECL_UID (node) != -1) 94: fprintf (file, " L." HOST_WIDE_INT_PRINT_DEC, LABEL_DECL_UID (node)); 95: else 96: fprintf (file, " %c.%u", TREE_CODE (node) == CONST_DECL ? 'C' : 'D', 97: DECL_UID (node)); 98: } 99: else if (class == tcc_type) 100: { 101: if (TYPE_NAME (node)) 102: { 103: if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE) 104: fprintf (file, " %s", IDENTIFIER_POINTER (TYPE_NAME (node))); 105: else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL 106: && DECL_NAME (TYPE_NAME (node))) 107: fprintf (file, " %s", 108: IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node)))); 109: } 110: } 111: if (TREE_CODE (node) == IDENTIFIER_NODE) 112: fprintf (file, " %s", IDENTIFIER_POINTER (node)); 113: 114: /* We might as well always print the value of an integer or real. */ 115: if (TREE_CODE (node) == INTEGER_CST) 116: { 117: if (TREE_CONSTANT_OVERFLOW (node)) 118: fprintf (file, " overflow"); 119: 120: fprintf (file, " "); 121: if (TREE_INT_CST_HIGH (node) == 0) 122: fprintf (file, HOST_WIDE_INT_PRINT_UNSIGNED, TREE_INT_CST_LOW (node)); 123: else if (TREE_INT_CST_HIGH (node) == -1 124: && TREE_INT_CST_LOW (node) != 0) 125: fprintf (file, "-" HOST_WIDE_INT_PRINT_UNSIGNED, 126: -TREE_INT_CST_LOW (node)); 127: else 128: fprintf (file, HOST_WIDE_INT_PRINT_DOUBLE_HEX, 129: TREE_INT_CST_HIGH (node), TREE_INT_CST_LOW (node)); 130: } 131: if (TREE_CODE (node) == REAL_CST) 132: { 133: REAL_VALUE_TYPE d; 134: 135: if (TREE_OVERFLOW (node)) 136: fprintf (file, " overflow"); 137: 138: d = TREE_REAL_CST (node); 139: if (REAL_VALUE_ISINF (d)) 140: fprintf (file, REAL_VALUE_NEGATIVE (d) ? " -Inf" : " Inf"); 141: else if (REAL_VALUE_ISNAN (d)) 142: fprintf (file, " Nan"); 143: else 144: { 145: char string[60]; 146: real_to_decimal (string, &d, sizeof (string), 0, 1); 147: fprintf (file, " %s", string); 148: } 149: } 150: 151: fprintf (file, ">"); 152: } 153: 154: void 155: indent_to (FILE *file, int column) 156: { 157: int i; 158: 159: /* Since this is the long way, indent to desired column. */ 160: if (column > 0) 161: fprintf (file, "\n"); 162: for (i = 0; i < column; i++) 163: fprintf (file, " "); 164: } 165: ^L 166: /* Print the node NODE in full on file FILE, preceded by PREFIX, 167: starting in column INDENT. */ 168: 169: void 170: print_node (FILE *file, const char *prefix, tree node, int indent) 171: { 172: int hash; 173: struct bucket *b; 174: enum machine_mode mode; 175: enum tree_code_class class; 176: int len; 177: int i; 178: expanded_location xloc; 179: enum tree_code code; 180: 181: if (node == 0) 182: return; 183: 184: code = TREE_CODE (node); 185: class = TREE_CODE_CLASS (code); 186: 187: /* Don't get too deep in nesting. If the user wants to see deeper, 188: it is easy to use the address of a lowest-level node 189: as an argument in another call to debug_tree. */ 190: 191: if (indent > 24) 192: { 193: print_node_brief (file, prefix, node, indent); 194: return; 195: } 196: 197: if (indent > 8 && (class == tcc_type || class == tcc_declaration)) 198: { 199: print_node_brief (file, prefix, node, indent); 200: return; 201: } 202: 203: /* It is unsafe to look at any other fields of an ERROR_MARK node. */ 204: if (TREE_CODE (node) == ERROR_MARK) 205: { 206: print_node_brief (file, prefix, node, indent); 207: return; 208: } 209: 210: hash = ((unsigned long) node) % HASH_SIZE; 211: 212: /* If node is in the table, just mention its address. */ 213: for (b = table[hash]; b; b = b->next) 214: if (b->node == node) 215: { 216: print_node_brief (file, prefix, node, indent); 217: return; 218: } 219: 220: /* Add this node to the table. */ 221: b = XNEW (struct bucket); 222: b->node = node; 223: b->next = table[hash]; 224: table[hash] = b; 225: 226: /* Indent to the specified column, since this is the long form. */ 227: indent_to (file, indent); 228: 229: /* Print the slot this node is in, and its code, and address. */ 230: fprintf (file, "%s <%s", prefix, tree_code_name[(int) TREE_CODE (node)]); 231: dump_addr (file, " ", node); 232: 233: /* Print the name, if any. */ 234: if (class == tcc_declaration) 235: { 236: if (DECL_NAME (node)) 237: fprintf (file, " %s", IDENTIFIER_POINTER (DECL_NAME (node))); 238: else if (TREE_CODE (node) == LABEL_DECL 239: && LABEL_DECL_UID (node) != -1) 240: fprintf (file, " L." HOST_WIDE_INT_PRINT_DEC, LABEL_DECL_UID (node)); 241: else 242: fprintf (file, " %c.%u", TREE_CODE (node) == CONST_DECL ? 'C' : 'D', 243: DECL_UID (node)); 244: } 245: else if (class == tcc_type) 246: { 247: if (TYPE_NAME (node)) 248: { 249: if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE) 250: fprintf (file, " %s", IDENTIFIER_POINTER (TYPE_NAME (node))); 251: else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL 252: && DECL_NAME (TYPE_NAME (node))) 253: fprintf (file, " %s", 254: IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node)))); 255: } 256: } 257: if (TREE_CODE (node) == IDENTIFIER_NODE) 258: fprintf (file, " %s", IDENTIFIER_POINTER (node)); 259: 260: if (TREE_CODE (node) == INTEGER_CST) 261: { 262: if (indent <= 4) 263: print_node_brief (file, "type", TREE_TYPE (node), indent + 4); 264: } 265: else 266: { 267: print_node (file, "type", TREE_TYPE (node), indent + 4); 268: if (TREE_TYPE (node)) 269: indent_to (file, indent + 3); 270: } 271: 272: if (!TYPE_P (node) && TREE_SIDE_EFFECTS (node)) 273: fputs (" side-effects", file); 274: 275: if (TYPE_P (node) ? TYPE_READONLY (node) : TREE_READONLY (node)) 276: fputs (" readonly", file); 277: if (!TYPE_P (node) && TREE_CONSTANT (node)) 278: fputs (" constant", file); 279: else if (TYPE_P (node) && TYPE_SIZES_GIMPLIFIED (node)) 280: fputs (" sizes-gimplified", file); 281: 282: if (TREE_INVARIANT (node)) 283: fputs (" invariant", file); 284: if (TREE_ADDRESSABLE (node)) 285: fputs (" addressable", file); 286: if (TREE_THIS_VOLATILE (node)) 287: fputs (" volatile", file); 288: if (TREE_ASM_WRITTEN (node)) 289: fputs (" asm_written", file); 290: if (TREE_USED (node)) 291: fputs (" used", file); 292: if (TREE_NOTHROW (node)) 293: fputs (TYPE_P (node) ? " align-ok" : " nothrow", file); 294: if (TREE_PUBLIC (node)) 295: fputs (" public", file); 296: if (TREE_PRIVATE (node)) 297: fputs (" private", file); 298: if (TREE_PROTECTED (node)) 299: fputs (" protected", file); 300: if (TREE_STATIC (node)) 301: fputs (" static", file); 302: if (TREE_DEPRECATED (node)) 303: fputs (" deprecated", file); 304: if (TREE_VISITED (node)) 305: fputs (" visited", file); 306: if (TREE_LANG_FLAG_0 (node)) 307: fputs (" tree_0", file); 308: if (TREE_LANG_FLAG_1 (node)) 309: fputs (" tree_1", file); 310: if (TREE_LANG_FLAG_2 (node)) 311: fputs (" tree_2", file); 312: if (TREE_LANG_FLAG_3 (node)) 313: fputs (" tree_3", file); 314: if (TREE_LANG_FLAG_4 (node)) 315: fputs (" tree_4", file); 316: if (TREE_LANG_FLAG_5 (node)) 317: fputs (" tree_5", file); 318: if (TREE_LANG_FLAG_6 (node)) 319: fputs (" tree_6", file); 320: 321: /* DECL_ nodes have additional attributes. */ 322: 323: switch (TREE_CODE_CLASS (TREE_CODE (node))) 324: { 325: case tcc_declaration: 326: if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON)) 327: { 328: if (DECL_UNSIGNED (node)) 329: fputs (" unsigned", file); 330: if (DECL_IGNORED_P (node)) 331: fputs (" ignored", file); 332: if (DECL_ABSTRACT (node)) 333: fputs (" abstract", file); 334: if (DECL_EXTERNAL (node)) 335: fputs (" external", file); 336: if (DECL_NONLOCAL (node)) 337: fputs (" nonlocal", file); 338: } 339: if (CODE_CONTAINS_STRUCT (code, TS_DECL_WITH_VIS)) 340: { 341: if (DECL_WEAK (node)) 342: fputs (" weak", file); 343: if (DECL_IN_SYSTEM_HEADER (node)) 344: fputs (" in_system_header", file); 345: } 346: if (CODE_CONTAINS_STRUCT (code, TS_DECL_WRTL) 347: && TREE_CODE (node) != LABEL_DECL 348: && TREE_CODE (node) != FUNCTION_DECL 349: && DECL_REGISTER (node)) 350: fputs (" regdecl", file); 351: 352: if (TREE_CODE (node) == TYPE_DECL && TYPE_DECL_SUPPRESS_DEBUG (node)) 353: fputs (" suppress-debug", file); 354: 355: if (TREE_CODE (node) == FUNCTION_DECL && DECL_INLINE (node)) 356: fputs (DECL_DECLARED_INLINE_P (node) ? " inline" : " autoinline", file); 357: if (TREE_CODE (node) == FUNCTION_DECL && DECL_BUILT_IN (node)) 358: fputs (" built-in", file); 359: if (TREE_CODE (node) == FUNCTION_DECL && DECL_NO_STATIC_CHAIN (node)) 360: fputs (" no-static-chain", file); 361: 362: if (TREE_CODE (node) == FIELD_DECL && DECL_PACKED (node)) 363: fputs (" packed", file); 364: if (TREE_CODE (node) == FIELD_DECL && DECL_BIT_FIELD (node)) 365: fputs (" bit-field", file); 366: if (TREE_CODE (node) == FIELD_DECL && DECL_NONADDRESSABLE_P (node)) 367: fputs (" nonaddressable", file); 368: 369: if (TREE_CODE (node) == LABEL_DECL && DECL_ERROR_ISSUED (node)) 370: fputs (" error-issued", file); 371: 372: if (TREE_CODE (node) == VAR_DECL && DECL_IN_TEXT_SECTION (node)) 373: fputs (" in-text-section", file); 374: if (TREE_CODE (node) == VAR_DECL && DECL_COMMON (node)) 375: fputs (" common", file); 376: if (TREE_CODE (node) == VAR_DECL && DECL_THREAD_LOCAL_P (node)) 377: { 378: enum tls_model kind = DECL_TLS_MODEL (node); 379: switch (kind) 380: { 381: case TLS_MODEL_GLOBAL_DYNAMIC: 382: fputs (" tls-global-dynamic", file); 383: break; 384: case TLS_MODEL_LOCAL_DYNAMIC: 385: fputs (" tls-local-dynamic", file); 386: break; 387: case TLS_MODEL_INITIAL_EXEC: 388: fputs (" tls-initial-exec", file); 389: break; 390: case TLS_MODEL_LOCAL_EXEC: 391: fputs (" tls-local-exec", file); 392: break; 393: default: 394: gcc_unreachable (); 395: } 396: } 397: 398: if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON)) 399: { 400: if (DECL_VIRTUAL_P (node)) 401: fputs (" virtual", file); 402: if (DECL_PRESERVE_P (node)) 403: fputs (" preserve", file); 404: if (DECL_LANG_FLAG_0 (node)) 405: fputs (" decl_0", file); 406: if (DECL_LANG_FLAG_1 (node)) 407: fputs (" decl_1", file); 408: if (DECL_LANG_FLAG_2 (node)) 409: fputs (" decl_2", file); 410: if (DECL_LANG_FLAG_3 (node)) 411: fputs (" decl_3", file); 412: if (DECL_LANG_FLAG_4 (node)) 413: fputs (" decl_4", file); 414: if (DECL_LANG_FLAG_5 (node)) 415: fputs (" decl_5", file); 416: if (DECL_LANG_FLAG_6 (node)) 417: fputs (" decl_6", file); 418: if (DECL_LANG_FLAG_7 (node)) 419: fputs (" decl_7", file); 420: 421: mode = DECL_MODE (node); 422: fprintf (file, " %s", GET_MODE_NAME (mode)); 423: } 424: 425: if (CODE_CONTAINS_STRUCT (code, TS_DECL_WITH_VIS) && DECL_DEFER_OUTPUT (node)) 426: fputs (" defer-output", file); 427: 428: 429: xloc = expand_location (DECL_SOURCE_LOCATION (node)); 430: fprintf (file, " file %s line %d", xloc.file, xloc.line); 431: 432: if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON)) 433: { 434: print_node (file, "size", DECL_SIZE (node), indent + 4); 435: print_node (file, "unit size", DECL_SIZE_UNIT (node), indent + 4); 436: 437: if (TREE_CODE (node) != FUNCTION_DECL 438: || DECL_INLINE (node) || DECL_BUILT_IN (node)) 439: indent_to (file, indent + 3); 440: 441: if (TREE_CODE (node) != FUNCTION_DECL) 442: { 443: if (DECL_USER_ALIGN (node)) 444: fprintf (file, " user"); 445: 446: fprintf (file, " align %d", DECL_ALIGN (node)); 447: if (TREE_CODE (node) == FIELD_DECL) 448: fprintf (file, " offset_align " HOST_WIDE_INT_PRINT_UNSIGNED, 449: DECL_OFFSET_ALIGN (node)); 450: } 451: else if (DECL_BUILT_IN (node)) 452: { 453: if (DECL_BUILT_IN_CLASS (node) == BUILT_IN_MD) 454: fprintf (file, " built-in BUILT_IN_MD %d", DECL_FUNCTION_CODE (node)); 455: else 456: fprintf (file, " built-in %s:%s", 457: built_in_class_names[(int) DECL_BUILT_IN_CLASS (node)], 458: built_in_names[(int) DECL_FUNCTION_CODE (node)]); 459: } 460: 461: if (DECL_POINTER_ALIAS_SET_KNOWN_P (node)) 462: fprintf (file, " alias set " HOST_WIDE_INT_PRINT_DEC, 463: DECL_POINTER_ALIAS_SET (node)); 464: } 465: if (TREE_CODE (node) == FIELD_DECL) 466: { 467: print_node (file, "offset", DECL_FIELD_OFFSET (node), indent + 4); 468: print_node (file, "bit offset", DECL_FIELD_BIT_OFFSET (node), 469: indent + 4); 470: if (DECL_BIT_FIELD_TYPE (node)) 471: print_node (file, "bit_field_type", DECL_BIT_FIELD_TYPE (node), 472: indent + 4); 473: } 474: 475: print_node_brief (file, "context", DECL_CONTEXT (node), indent + 4); 476: 477: if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON)) 478: { 479: print_node_brief (file, "attributes", 480: DECL_ATTRIBUTES (node), indent + 4); 481: print_node_brief (file, "initial", DECL_INITIAL (node), indent + 4); 482: } 483: if (CODE_CONTAINS_STRUCT (code, TS_DECL_WRTL)) 484: { 485: print_node_brief (file, "abstract_origin", 486: DECL_ABSTRACT_ORIGIN (node), indent + 4); 487: } 488: if (CODE_CONTAINS_STRUCT (code, TS_DECL_NON_COMMON)) 489: { 490: print_node (file, "arguments", DECL_ARGUMENT_FLD (node), indent + 4); 491: print_node (file, "result", DECL_RESULT_FLD (node), indent + 4); 492: } 493: 494: lang_hooks.print_decl (file, node, indent); 495: 496: if (DECL_RTL_SET_P (node)) 497: { 498: indent_to (file, indent + 4); 499: print_rtl (file, DECL_RTL (node)); 500: } 501: 502: if (TREE_CODE (node) == PARM_DECL) 503: { 504: print_node (file, "arg-type", DECL_ARG_TYPE (node), indent + 4); 505: 506: if (DECL_INCOMING_RTL (node) != 0) 507: { 508: indent_to (file, indent + 4); 509: fprintf (file, "incoming-rtl "); 510: print_rtl (file, DECL_INCOMING_RTL (node)); 511: } 512: } 513: else if (TREE_CODE (node) == FUNCTION_DECL 514: && DECL_STRUCT_FUNCTION (node) != 0) 515: { 516: indent_to (file, indent + 4); 517: dump_addr (file, "saved-insns ", DECL_STRUCT_FUNCTION (node)); 518: } 519: 520: if ((TREE_CODE (node) == VAR_DECL || TREE_CODE (node) == PARM_DECL) 521: && DECL_HAS_VALUE_EXPR_P (node)) 522: print_node (file, "value-expr", DECL_VALUE_EXPR (node), indent + 4); 523: 524: if (TREE_CODE (node) == STRUCT_FIELD_TAG) 525: { 526: fprintf (file, " sft size " HOST_WIDE_INT_PRINT_DEC, 527: SFT_SIZE (node)); 528: fprintf (file, " sft offset " HOST_WIDE_INT_PRINT_DEC, 529: SFT_OFFSET (node)); 530: print_node_brief (file, "parent var", SFT_PARENT_VAR (node), 531: indent + 4); 532: } 533: /* Print the decl chain only if decl is at second level. */ 534: if (indent == 4) 535: print_node (file, "chain", TREE_CHAIN (node), indent + 4); 536: else 537: print_node_brief (file, "chain", TREE_CHAIN (node), indent + 4); 538: break; 539: 540: case tcc_type: 541: if (TYPE_UNSIGNED (node)) 542: fputs (" unsigned", file); 543: 544: /* The no-force-blk flag is used for different things in 545: different types. */ 546: if ((TREE_CODE (node) == RECORD_TYPE 547: || TREE_CODE (node) == UNION_TYPE