comparison gcc/print-rtl.c @ 55:77e2b8dfacca gcc-4.4.5

update it from 4.4.3 to 4.5.0
author ryoma <e075725@ie.u-ryukyu.ac.jp>
date Fri, 12 Feb 2010 23:39:51 +0900
parents a06113de4d67
children b7f97abdc517
comparison
equal deleted inserted replaced
52:c156f1bd5cd9 55:77e2b8dfacca
1 /* Print RTL for GCC. 1 /* Print RTL for GCC.
2 Copyright (C) 1987, 1988, 1992, 1997, 1998, 1999, 2000, 2002, 2003, 2 Copyright (C) 1987, 1988, 1992, 1997, 1998, 1999, 2000, 2002, 2003,
3 2004, 2005, 2007, 2008 3 2004, 2005, 2007, 2008, 2009
4 Free Software Foundation, Inc. 4 Free Software Foundation, Inc.
5 5
6 This file is part of GCC. 6 This file is part of GCC.
7 7
8 GCC is free software; you can redistribute it and/or modify it under 8 GCC is free software; you can redistribute it and/or modify it under
38 #include "tree.h" 38 #include "tree.h"
39 #include "real.h" 39 #include "real.h"
40 #include "flags.h" 40 #include "flags.h"
41 #include "hard-reg-set.h" 41 #include "hard-reg-set.h"
42 #include "basic-block.h" 42 #include "basic-block.h"
43 #include "diagnostic.h"
44 #include "cselib.h"
45 #include "tree-pass.h"
43 #endif 46 #endif
44 47
45 static FILE *outfile; 48 static FILE *outfile;
46 49
47 static int sawclose = 0; 50 static int sawclose = 0;
58 /* Nonzero means suppress output of instruction numbers 61 /* Nonzero means suppress output of instruction numbers
59 in debugging dumps. 62 in debugging dumps.
60 This must be defined here so that programs like gencodes can be linked. */ 63 This must be defined here so that programs like gencodes can be linked. */
61 int flag_dump_unnumbered = 0; 64 int flag_dump_unnumbered = 0;
62 65
66 /* Nonzero means suppress output of instruction numbers for previous
67 and next insns in debugging dumps.
68 This must be defined here so that programs like gencodes can be linked. */
69 int flag_dump_unnumbered_links = 0;
70
63 /* Nonzero means use simplified format without flags, modes, etc. */ 71 /* Nonzero means use simplified format without flags, modes, etc. */
64 int flag_simple = 0; 72 int flag_simple = 0;
65 73
66 /* Nonzero if we are dumping graphical description. */ 74 /* Nonzero if we are dumping graphical description. */
67 int dump_for_graph; 75 int dump_for_graph;
68 76
69 #ifndef GENERATOR_FILE 77 #ifndef GENERATOR_FILE
70 static void
71 print_decl_name (FILE *outfile, const_tree node)
72 {
73 if (DECL_NAME (node))
74 fputs (IDENTIFIER_POINTER (DECL_NAME (node)), outfile);
75 else
76 {
77 if (TREE_CODE (node) == LABEL_DECL && LABEL_DECL_UID (node) != -1)
78 fprintf (outfile, "L.%d", (int) LABEL_DECL_UID (node));
79 else
80 {
81 char c = TREE_CODE (node) == CONST_DECL ? 'C' : 'D';
82 fprintf (outfile, "%c.%u", c, DECL_UID (node));
83 }
84 }
85 }
86
87 void 78 void
88 print_mem_expr (FILE *outfile, const_tree expr) 79 print_mem_expr (FILE *outfile, const_tree expr)
89 { 80 {
90 if (TREE_CODE (expr) == COMPONENT_REF) 81 fputc (' ', outfile);
91 { 82 print_generic_expr (outfile, CONST_CAST_TREE (expr), dump_flags);
92 if (TREE_OPERAND (expr, 0))
93 print_mem_expr (outfile, TREE_OPERAND (expr, 0));
94 else
95 fputs (" <variable>", outfile);
96 fputc ('.', outfile);
97 print_decl_name (outfile, TREE_OPERAND (expr, 1));
98 }
99 else if (TREE_CODE (expr) == INDIRECT_REF)
100 {
101 fputs (" (*", outfile);
102 print_mem_expr (outfile, TREE_OPERAND (expr, 0));
103 fputs (")", outfile);
104 }
105 else if (TREE_CODE (expr) == ALIGN_INDIRECT_REF)
106 {
107 fputs (" (A*", outfile);
108 print_mem_expr (outfile, TREE_OPERAND (expr, 0));
109 fputs (")", outfile);
110 }
111 else if (TREE_CODE (expr) == MISALIGNED_INDIRECT_REF)
112 {
113 fputs (" (M*", outfile);
114 print_mem_expr (outfile, TREE_OPERAND (expr, 0));
115 fputs (")", outfile);
116 }
117 else if (TREE_CODE (expr) == RESULT_DECL)
118 fputs (" <result>", outfile);
119 else
120 {
121 fputc (' ', outfile);
122 print_decl_name (outfile, expr);
123 }
124 } 83 }
125 #endif 84 #endif
126 85
127 /* Print IN_RTX onto OUTFILE. This is the recursive part of printing. */ 86 /* Print IN_RTX onto OUTFILE. This is the recursive part of printing. */
128 87
149 sawclose = 1; 108 sawclose = 1;
150 return; 109 return;
151 } 110 }
152 else if (GET_CODE (in_rtx) > NUM_RTX_CODE) 111 else if (GET_CODE (in_rtx) > NUM_RTX_CODE)
153 { 112 {
154 fprintf (outfile, "(??? bad code %d\n)", GET_CODE (in_rtx)); 113 fprintf (outfile, "(??? bad code %d\n%s%*s)", GET_CODE (in_rtx),
114 print_rtx_head, indent * 2, "");
155 sawclose = 1; 115 sawclose = 1;
156 return; 116 return;
157 } 117 }
158 118
159 is_insn = INSN_P (in_rtx); 119 is_insn = INSN_P (in_rtx);
168 indent = 0; 128 indent = 0;
169 } 129 }
170 else 130 else
171 { 131 {
172 /* Print name of expression code. */ 132 /* Print name of expression code. */
173 if (flag_simple && GET_CODE (in_rtx) == CONST_INT) 133 if (flag_simple && CONST_INT_P (in_rtx))
174 fputc ('(', outfile); 134 fputc ('(', outfile);
175 else 135 else
176 fprintf (outfile, "(%s", GET_RTX_NAME (GET_CODE (in_rtx))); 136 fprintf (outfile, "(%s", GET_RTX_NAME (GET_CODE (in_rtx)));
177 137
178 if (! flag_simple) 138 if (! flag_simple)
197 157
198 if (RTX_FLAG (in_rtx, return_val)) 158 if (RTX_FLAG (in_rtx, return_val))
199 fputs ("/i", outfile); 159 fputs ("/i", outfile);
200 160
201 /* Print REG_NOTE names for EXPR_LIST and INSN_LIST. */ 161 /* Print REG_NOTE names for EXPR_LIST and INSN_LIST. */
202 if (GET_CODE (in_rtx) == EXPR_LIST 162 if ((GET_CODE (in_rtx) == EXPR_LIST
203 || GET_CODE (in_rtx) == INSN_LIST) 163 || GET_CODE (in_rtx) == INSN_LIST)
164 && (int)GET_MODE (in_rtx) < REG_NOTE_MAX)
204 fprintf (outfile, ":%s", 165 fprintf (outfile, ":%s",
205 GET_REG_NOTE_NAME (GET_MODE (in_rtx))); 166 GET_REG_NOTE_NAME (GET_MODE (in_rtx)));
206 167
207 /* For other rtl, print the mode if it's not VOID. */ 168 /* For other rtl, print the mode if it's not VOID. */
208 else if (GET_MODE (in_rtx) != VOIDmode) 169 else if (GET_MODE (in_rtx) != VOIDmode)
209 fprintf (outfile, ":%s", GET_MODE_NAME (GET_MODE (in_rtx))); 170 fprintf (outfile, ":%s", GET_MODE_NAME (GET_MODE (in_rtx)));
171
172 #ifndef GENERATOR_FILE
173 if (GET_CODE (in_rtx) == VAR_LOCATION)
174 {
175 if (TREE_CODE (PAT_VAR_LOCATION_DECL (in_rtx)) == STRING_CST)
176 fputs (" <debug string placeholder>", outfile);
177 else
178 print_mem_expr (outfile, PAT_VAR_LOCATION_DECL (in_rtx));
179 fputc (' ', outfile);
180 print_rtx (PAT_VAR_LOCATION_LOC (in_rtx));
181 if (PAT_VAR_LOCATION_STATUS (in_rtx)
182 == VAR_INIT_STATUS_UNINITIALIZED)
183 fprintf (outfile, " [uninit]");
184 sawclose = 1;
185 i = GET_RTX_LENGTH (VAR_LOCATION);
186 }
187 #endif
210 } 188 }
211 } 189 }
212 190
213 #ifndef GENERATOR_FILE 191 #ifndef GENERATOR_FILE
214 if (GET_CODE (in_rtx) == CONST_DOUBLE && FLOAT_MODE_P (GET_MODE (in_rtx))) 192 if (GET_CODE (in_rtx) == CONST_DOUBLE && FLOAT_MODE_P (GET_MODE (in_rtx)))
262 } 240 }
263 else if (i == 2 && GET_CODE (in_rtx) == SYMBOL_REF) 241 else if (i == 2 && GET_CODE (in_rtx) == SYMBOL_REF)
264 { 242 {
265 tree decl = SYMBOL_REF_DECL (in_rtx); 243 tree decl = SYMBOL_REF_DECL (in_rtx);
266 if (decl) 244 if (decl)
267 print_node_brief (outfile, "", decl, 0); 245 print_node_brief (outfile, "", decl, dump_flags);
268 } 246 }
269 #endif 247 #endif
270 else if (i == 4 && NOTE_P (in_rtx)) 248 else if (i == 4 && NOTE_P (in_rtx))
271 { 249 {
272 switch (NOTE_KIND (in_rtx)) 250 switch (NOTE_KIND (in_rtx))
315 if (bb != 0) 293 if (bb != 0)
316 fprintf (outfile, " [bb %d]", bb->index); 294 fprintf (outfile, " [bb %d]", bb->index);
317 #endif 295 #endif
318 break; 296 break;
319 } 297 }
320 298
321 case NOTE_INSN_VAR_LOCATION: 299 case NOTE_INSN_VAR_LOCATION:
322 #ifndef GENERATOR_FILE 300 #ifndef GENERATOR_FILE
323 fprintf (outfile, " ("); 301 fputc (' ', outfile);
324 print_mem_expr (outfile, NOTE_VAR_LOCATION_DECL (in_rtx)); 302 print_rtx (NOTE_VAR_LOCATION (in_rtx));
325 fprintf (outfile, " ");
326 print_rtx (NOTE_VAR_LOCATION_LOC (in_rtx));
327 if (NOTE_VAR_LOCATION_STATUS (in_rtx) ==
328 VAR_INIT_STATUS_UNINITIALIZED)
329 fprintf (outfile, " [uninit]");
330 fprintf (outfile, ")");
331 #endif 303 #endif
332 break; 304 break;
333 305
334 default: 306 default:
335 break; 307 break;
336 } 308 }
337 } 309 }
338 else if (i == 9 && JUMP_P (in_rtx) && XEXP (in_rtx, i) != NULL) 310 else if (i == 8 && JUMP_P (in_rtx) && JUMP_LABEL (in_rtx) != NULL)
339 /* Output the JUMP_LABEL reference. */ 311 /* Output the JUMP_LABEL reference. */
340 fprintf (outfile, "\n -> %d", INSN_UID (XEXP (in_rtx, i))); 312 fprintf (outfile, "\n%s%*s -> %d", print_rtx_head, indent * 2, "",
313 INSN_UID (JUMP_LABEL (in_rtx)));
314 else if (i == 0 && GET_CODE (in_rtx) == VALUE)
315 {
316 #ifndef GENERATOR_FILE
317 cselib_val *val = CSELIB_VAL_PTR (in_rtx);
318
319 fprintf (outfile, " %i", val->value);
320 dump_addr (outfile, " @", in_rtx);
321 dump_addr (outfile, "/", (void*)val);
322 #endif
323 }
324 else if (i == 0 && GET_CODE (in_rtx) == DEBUG_EXPR)
325 {
326 #ifndef GENERATOR_FILE
327 fprintf (outfile, " D#%i",
328 DEBUG_TEMP_UID (DEBUG_EXPR_TREE_DECL (in_rtx)));
329 #endif
330 }
341 break; 331 break;
342 332
343 case 'e': 333 case 'e':
344 do_e: 334 do_e:
345 indent += 2; 335 indent += 2;
394 /* Pretty-print insn locators. Ignore scoping as it is mostly 384 /* Pretty-print insn locators. Ignore scoping as it is mostly
395 redundant with line number information and do not print anything 385 redundant with line number information and do not print anything
396 when there is no location information available. */ 386 when there is no location information available. */
397 if (INSN_LOCATOR (in_rtx) && insn_file (in_rtx)) 387 if (INSN_LOCATOR (in_rtx) && insn_file (in_rtx))
398 fprintf(outfile, " %s:%i", insn_file (in_rtx), insn_line (in_rtx)); 388 fprintf(outfile, " %s:%i", insn_file (in_rtx), insn_line (in_rtx));
389 #endif
390 }
391 else if (i == 6 && GET_CODE (in_rtx) == ASM_OPERANDS)
392 {
393 #ifndef GENERATOR_FILE
394 fprintf (outfile, " %s:%i",
395 locator_file (ASM_OPERANDS_SOURCE_LOCATION (in_rtx)),
396 locator_line (ASM_OPERANDS_SOURCE_LOCATION (in_rtx)));
397 #endif
398 }
399 else if (i == 1 && GET_CODE (in_rtx) == ASM_INPUT)
400 {
401 #ifndef GENERATOR_FILE
402 fprintf (outfile, " %s:%i",
403 locator_file (ASM_INPUT_SOURCE_LOCATION (in_rtx)),
404 locator_line (ASM_INPUT_SOURCE_LOCATION (in_rtx)));
399 #endif 405 #endif
400 } 406 }
401 else if (i == 6 && NOTE_P (in_rtx)) 407 else if (i == 6 && NOTE_P (in_rtx))
402 { 408 {
403 /* This field is only used for NOTE_INSN_DELETED_LABEL, and 409 /* This field is only used for NOTE_INSN_DELETED_LABEL, and
491 497
492 if (subc != CODE_LABEL) 498 if (subc != CODE_LABEL)
493 goto do_e; 499 goto do_e;
494 } 500 }
495 501
496 if (flag_dump_unnumbered) 502 if (flag_dump_unnumbered
503 || (flag_dump_unnumbered_links && (i == 1 || i == 2)
504 && (INSN_P (in_rtx) || NOTE_P (in_rtx)
505 || LABEL_P (in_rtx) || BARRIER_P (in_rtx))))
497 fputs (" #", outfile); 506 fputs (" #", outfile);
498 else 507 else
499 fprintf (outfile, " %d", INSN_UID (sub)); 508 fprintf (outfile, " %d", INSN_UID (sub));
500 } 509 }
501 else 510 else
553 fprintf (outfile, " S" HOST_WIDE_INT_PRINT_DEC, 562 fprintf (outfile, " S" HOST_WIDE_INT_PRINT_DEC,
554 INTVAL (MEM_SIZE (in_rtx))); 563 INTVAL (MEM_SIZE (in_rtx)));
555 564
556 if (MEM_ALIGN (in_rtx) != 1) 565 if (MEM_ALIGN (in_rtx) != 1)
557 fprintf (outfile, " A%u", MEM_ALIGN (in_rtx)); 566 fprintf (outfile, " A%u", MEM_ALIGN (in_rtx));
567
568 if (!ADDR_SPACE_GENERIC_P (MEM_ADDR_SPACE (in_rtx)))
569 fprintf (outfile, " AS%u", MEM_ADDR_SPACE (in_rtx));
558 570
559 fputc (']', outfile); 571 fputc (']', outfile);
560 break; 572 break;
561 573
562 case CONST_DOUBLE: 574 case CONST_DOUBLE: