1 | /* Print RTL for GNU C Compiler.
|
---|
2 | Copyright (C) 1987, 1988, 1992, 1997, 1998, 1999, 2000, 2002, 2003
|
---|
3 | 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 2, 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 COPYING. If not, write to the Free
|
---|
19 | Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
---|
20 | 02111-1307, USA. */
|
---|
21 |
|
---|
22 |
|
---|
23 | #include "config.h"
|
---|
24 | #include "system.h"
|
---|
25 | #include "rtl.h"
|
---|
26 |
|
---|
27 | /* We don't want the tree code checking code for the access to the
|
---|
28 | DECL_NAME to be included in the gen* programs. */
|
---|
29 | #undef ENABLE_TREE_CHECKING
|
---|
30 | #include "tree.h"
|
---|
31 | #include "real.h"
|
---|
32 | #include "flags.h"
|
---|
33 | #include "hard-reg-set.h"
|
---|
34 | #include "basic-block.h"
|
---|
35 |
|
---|
36 | /* How to print out a register name.
|
---|
37 | We don't use PRINT_REG because some definitions of PRINT_REG
|
---|
38 | don't work here. */
|
---|
39 | #ifndef DEBUG_PRINT_REG
|
---|
40 | #define DEBUG_PRINT_REG(RTX, CODE, FILE) \
|
---|
41 | fprintf ((FILE), "%d %s", REGNO (RTX), reg_names[REGNO (RTX)])
|
---|
42 | #endif
|
---|
43 |
|
---|
44 | /* Array containing all of the register names */
|
---|
45 |
|
---|
46 | #ifdef DEBUG_REGISTER_NAMES
|
---|
47 | static const char * const debug_reg_names[] = DEBUG_REGISTER_NAMES;
|
---|
48 | #define reg_names debug_reg_names
|
---|
49 | #else
|
---|
50 | const char * reg_names[] = REGISTER_NAMES;
|
---|
51 | #endif
|
---|
52 |
|
---|
53 | static FILE *outfile;
|
---|
54 |
|
---|
55 | static int sawclose = 0;
|
---|
56 |
|
---|
57 | static int indent;
|
---|
58 |
|
---|
59 | static void print_rtx PARAMS ((rtx));
|
---|
60 |
|
---|
61 | /* String printed at beginning of each RTL when it is dumped.
|
---|
62 | This string is set to ASM_COMMENT_START when the RTL is dumped in
|
---|
63 | the assembly output file. */
|
---|
64 | const char *print_rtx_head = "";
|
---|
65 |
|
---|
66 | /* Nonzero means suppress output of instruction numbers and line number
|
---|
67 | notes in debugging dumps.
|
---|
68 | This must be defined here so that programs like gencodes can be linked. */
|
---|
69 | int flag_dump_unnumbered = 0;
|
---|
70 |
|
---|
71 | /* Nonzero means use simplified format without flags, modes, etc. */
|
---|
72 | int flag_simple = 0;
|
---|
73 |
|
---|
74 | /* Nonzero if we are dumping graphical description. */
|
---|
75 | int dump_for_graph;
|
---|
76 |
|
---|
77 | /* Nonzero to dump all call_placeholder alternatives. */
|
---|
78 | static int debug_call_placeholder_verbose;
|
---|
79 |
|
---|
80 | void
|
---|
81 | print_mem_expr (outfile, expr)
|
---|
82 | FILE *outfile;
|
---|
83 | tree expr;
|
---|
84 | {
|
---|
85 | if (TREE_CODE (expr) == COMPONENT_REF)
|
---|
86 | {
|
---|
87 | if (TREE_OPERAND (expr, 0))
|
---|
88 | print_mem_expr (outfile, TREE_OPERAND (expr, 0));
|
---|
89 | else
|
---|
90 | fputs (" <variable>", outfile);
|
---|
91 | if (DECL_NAME (TREE_OPERAND (expr, 1)))
|
---|
92 | fprintf (outfile, ".%s",
|
---|
93 | IDENTIFIER_POINTER (DECL_NAME (TREE_OPERAND (expr, 1))));
|
---|
94 | }
|
---|
95 | else if (TREE_CODE (expr) == INDIRECT_REF)
|
---|
96 | {
|
---|
97 | fputs (" (*", outfile);
|
---|
98 | print_mem_expr (outfile, TREE_OPERAND (expr, 0));
|
---|
99 | fputs (")", outfile);
|
---|
100 | }
|
---|
101 | else if (DECL_NAME (expr))
|
---|
102 | fprintf (outfile, " %s", IDENTIFIER_POINTER (DECL_NAME (expr)));
|
---|
103 | else if (TREE_CODE (expr) == RESULT_DECL)
|
---|
104 | fputs (" <result>", outfile);
|
---|
105 | else
|
---|
106 | fputs (" <anonymous>", outfile);
|
---|
107 | }
|
---|
108 |
|
---|
109 | /* Print IN_RTX onto OUTFILE. This is the recursive part of printing. */
|
---|
110 |
|
---|
111 | static void
|
---|
112 | print_rtx (in_rtx)
|
---|
113 | rtx in_rtx;
|
---|
114 | {
|
---|
115 | int i = 0;
|
---|
116 | int j;
|
---|
117 | const char *format_ptr;
|
---|
118 | int is_insn;
|
---|
119 | rtx tem;
|
---|
120 |
|
---|
121 | if (sawclose)
|
---|
122 | {
|
---|
123 | if (flag_simple)
|
---|
124 | fputc (' ', outfile);
|
---|
125 | else
|
---|
126 | fprintf (outfile, "\n%s%*s", print_rtx_head, indent * 2, "");
|
---|
127 | sawclose = 0;
|
---|
128 | }
|
---|
129 |
|
---|
130 | if (in_rtx == 0)
|
---|
131 | {
|
---|
132 | fputs ("(nil)", outfile);
|
---|
133 | sawclose = 1;
|
---|
134 | return;
|
---|
135 | }
|
---|
136 | else if (GET_CODE (in_rtx) > NUM_RTX_CODE)
|
---|
137 | {
|
---|
138 | fprintf (outfile, "(??? bad code %d\n)", GET_CODE (in_rtx));
|
---|
139 | sawclose = 1;
|
---|
140 | return;
|
---|
141 | }
|
---|
142 |
|
---|
143 | is_insn = INSN_P (in_rtx);
|
---|
144 |
|
---|
145 | /* When printing in VCG format we write INSNs, NOTE, LABEL, and BARRIER
|
---|
146 | in separate nodes and therefore have to handle them special here. */
|
---|
147 | if (dump_for_graph
|
---|
148 | && (is_insn || GET_CODE (in_rtx) == NOTE
|
---|
149 | || GET_CODE (in_rtx) == CODE_LABEL || GET_CODE (in_rtx) == BARRIER))
|
---|
150 | {
|
---|
151 | i = 3;
|
---|
152 | indent = 0;
|
---|
153 | }
|
---|
154 | else
|
---|
155 | {
|
---|
156 | /* Print name of expression code. */
|
---|
157 | if (flag_simple && GET_CODE (in_rtx) == CONST_INT)
|
---|
158 | fputc ('(', outfile);
|
---|
159 | else
|
---|
160 | fprintf (outfile, "(%s", GET_RTX_NAME (GET_CODE (in_rtx)));
|
---|
161 |
|
---|
162 | if (! flag_simple)
|
---|
163 | {
|
---|
164 | if (RTX_FLAG (in_rtx, in_struct))
|
---|
165 | fputs ("/s", outfile);
|
---|
166 |
|
---|
167 | if (RTX_FLAG (in_rtx, volatil))
|
---|
168 | fputs ("/v", outfile);
|
---|
169 |
|
---|
170 | if (RTX_FLAG (in_rtx, unchanging))
|
---|
171 | fputs ("/u", outfile);
|
---|
172 |
|
---|
173 | if (RTX_FLAG (in_rtx, integrated))
|
---|
174 | fputs ("/i", outfile);
|
---|
175 |
|
---|
176 | if (RTX_FLAG (in_rtx, frame_related))
|
---|
177 | fputs ("/f", outfile);
|
---|
178 |
|
---|
179 | if (RTX_FLAG (in_rtx, jump))
|
---|
180 | fputs ("/j", outfile);
|
---|
181 |
|
---|
182 | if (RTX_FLAG (in_rtx, call))
|
---|
183 | fputs ("/c", outfile);
|
---|
184 |
|
---|
185 | if (GET_MODE (in_rtx) != VOIDmode)
|
---|
186 | {
|
---|
187 | /* Print REG_NOTE names for EXPR_LIST and INSN_LIST. */
|
---|
188 | if (GET_CODE (in_rtx) == EXPR_LIST
|
---|
189 | || GET_CODE (in_rtx) == INSN_LIST)
|
---|
190 | fprintf (outfile, ":%s",
|
---|
191 | GET_REG_NOTE_NAME (GET_MODE (in_rtx)));
|
---|
192 | else
|
---|
193 | fprintf (outfile, ":%s", GET_MODE_NAME (GET_MODE (in_rtx)));
|
---|
194 | }
|
---|
195 | }
|
---|
196 | }
|
---|
197 |
|
---|
198 | #ifndef GENERATOR_FILE
|
---|
199 | if (GET_CODE (in_rtx) == CONST_DOUBLE && FLOAT_MODE_P (GET_MODE (in_rtx)))
|
---|
200 | i = 5;
|
---|
201 | #endif
|
---|
202 |
|
---|
203 | /* Get the format string and skip the first elements if we have handled
|
---|
204 | them already. */
|
---|
205 | format_ptr = GET_RTX_FORMAT (GET_CODE (in_rtx)) + i;
|
---|
206 | for (; i < GET_RTX_LENGTH (GET_CODE (in_rtx)); i++)
|
---|
207 | switch (*format_ptr++)
|
---|
208 | {
|
---|
209 | const char *str;
|
---|
210 |
|
---|
211 | case 'T':
|
---|
212 | str = XTMPL (in_rtx, i);
|
---|
213 | goto string;
|
---|
214 |
|
---|
215 | case 'S':
|
---|
216 | case 's':
|
---|
217 | str = XSTR (in_rtx, i);
|
---|
218 | string:
|
---|
219 |
|
---|
220 | if (str == 0)
|
---|
221 | fputs (dump_for_graph ? " \\\"\\\"" : " \"\"", outfile);
|
---|
222 | else
|
---|
223 | {
|
---|
224 | if (dump_for_graph)
|
---|
225 | fprintf (outfile, " (\\\"%s\\\")", str);
|
---|
226 | else
|
---|
227 | fprintf (outfile, " (\"%s\")", str);
|
---|
228 | }
|
---|
229 | sawclose = 1;
|
---|
230 | break;
|
---|
231 |
|
---|
232 | /* 0 indicates a field for internal use that should not be printed.
|
---|
233 | An exception is the third field of a NOTE, where it indicates
|
---|
234 | that the field has several different valid contents. */
|
---|
235 | case '0':
|
---|
236 | if (i == 1 && GET_CODE (in_rtx) == REG)
|
---|
237 | {
|
---|
238 | if (REGNO (in_rtx) != ORIGINAL_REGNO (in_rtx))
|
---|
239 | fprintf (outfile, " [%d]", ORIGINAL_REGNO (in_rtx));
|
---|
240 | break;
|
---|
241 | }
|
---|
242 | if (i == 4 && GET_CODE (in_rtx) == NOTE)
|
---|
243 | {
|
---|
244 | switch (NOTE_LINE_NUMBER (in_rtx))
|
---|
245 | {
|
---|
246 | case NOTE_INSN_EH_REGION_BEG:
|
---|
247 | case NOTE_INSN_EH_REGION_END:
|
---|
248 | if (flag_dump_unnumbered)
|
---|
249 | fprintf (outfile, " #");
|
---|
250 | else
|
---|
251 | fprintf (outfile, " %d", NOTE_EH_HANDLER (in_rtx));
|
---|
252 | sawclose = 1;
|
---|
253 | break;
|
---|
254 |
|
---|
255 | case NOTE_INSN_BLOCK_BEG:
|
---|
256 | case NOTE_INSN_BLOCK_END:
|
---|
257 | fprintf (outfile, " ");
|
---|
258 | if (flag_dump_unnumbered)
|
---|
259 | fprintf (outfile, "#");
|
---|
260 | else
|
---|
261 | fprintf (outfile, HOST_PTR_PRINTF,
|
---|
262 | (char *) NOTE_BLOCK (in_rtx));
|
---|
263 | sawclose = 1;
|
---|
264 | break;
|
---|
265 |
|
---|
266 | case NOTE_INSN_BASIC_BLOCK:
|
---|
267 | {
|
---|
268 | basic_block bb = NOTE_BASIC_BLOCK (in_rtx);
|
---|
269 | if (bb != 0)
|
---|
270 | fprintf (outfile, " [bb %d]", bb->index);
|
---|
271 | break;
|
---|
272 | }
|
---|
273 |
|
---|
274 | case NOTE_INSN_EXPECTED_VALUE:
|
---|
275 | indent += 2;
|
---|
276 | if (!sawclose)
|
---|
277 | fprintf (outfile, " ");
|
---|
278 | print_rtx (NOTE_EXPECTED_VALUE (in_rtx));
|
---|
279 | indent -= 2;
|
---|
280 | break;
|
---|
281 |
|
---|
282 | case NOTE_INSN_DELETED_LABEL:
|
---|
283 | if (NOTE_SOURCE_FILE (in_rtx))
|
---|
284 | fprintf (outfile, " (\"%s\")", NOTE_SOURCE_FILE (in_rtx));
|
---|
285 | else
|
---|
286 | fprintf (outfile, " \"\"");
|
---|
287 | break;
|
---|
288 |
|
---|
289 | case NOTE_INSN_PREDICTION:
|
---|
290 | if (NOTE_PREDICTION (in_rtx))
|
---|
291 | fprintf (outfile, " [ %d %d ] ",
|
---|
292 | (int)NOTE_PREDICTION_ALG (in_rtx),
|
---|
293 | (int) NOTE_PREDICTION_FLAGS (in_rtx));
|
---|
294 | else
|
---|
295 | fprintf (outfile, " [ ERROR ]");
|
---|
296 | break;
|
---|
297 |
|
---|
298 | default:
|
---|
299 | {
|
---|
300 | const char * const str = X0STR (in_rtx, i);
|
---|
301 |
|
---|
302 | if (NOTE_LINE_NUMBER (in_rtx) < 0)
|
---|
303 | ;
|
---|
304 | else if (str == 0)
|
---|
305 | fputs (dump_for_graph ? " \\\"\\\"" : " \"\"", outfile);
|
---|
306 | else
|
---|
307 | {
|
---|
308 | if (dump_for_graph)
|
---|
309 | fprintf (outfile, " (\\\"%s\\\")", str);
|
---|
310 | else
|
---|
311 | fprintf (outfile, " (\"%s\")", str);
|
---|
312 | }
|
---|
313 | break;
|
---|
314 | }
|
---|
315 | }
|
---|
316 | }
|
---|
317 | break;
|
---|
318 |
|
---|
319 | case 'e':
|
---|
320 | do_e:
|
---|
321 | indent += 2;
|
---|
322 | if (!sawclose)
|
---|
323 | fprintf (outfile, " ");
|
---|
324 | print_rtx (XEXP (in_rtx, i));
|
---|
325 | indent -= 2;
|
---|
326 | break;
|
---|
327 |
|
---|
328 | case 'E':
|
---|
329 | case 'V':
|
---|
330 | indent += 2;
|
---|
331 | if (sawclose)
|
---|
332 | {
|
---|
333 | fprintf (outfile, "\n%s%*s",
|
---|
334 | print_rtx_head, indent * 2, "");
|
---|
335 | sawclose = 0;
|
---|
336 | }
|
---|
337 | fputs (" [", outfile);
|
---|
338 | if (NULL != XVEC (in_rtx, i))
|
---|
339 | {
|
---|
340 | indent += 2;
|
---|
341 | if (XVECLEN (in_rtx, i))
|
---|
342 | sawclose = 1;
|
---|
343 |
|
---|
344 | for (j = 0; j < XVECLEN (in_rtx, i); j++)
|
---|
345 | print_rtx (XVECEXP (in_rtx, i, j));
|
---|
346 |
|
---|
347 | indent -= 2;
|
---|
348 | }
|
---|
349 | if (sawclose)
|
---|
350 | fprintf (outfile, "\n%s%*s", print_rtx_head, indent * 2, "");
|
---|
351 |
|
---|
352 | fputs ("]", outfile);
|
---|
353 | sawclose = 1;
|
---|
354 | indent -= 2;
|
---|
355 | break;
|
---|
356 |
|
---|
357 | case 'w':
|
---|
358 | if (! flag_simple)
|
---|
359 | fprintf (outfile, " ");
|
---|
360 | fprintf (outfile, HOST_WIDE_INT_PRINT_DEC, XWINT (in_rtx, i));
|
---|
361 | if (! flag_simple)
|
---|
362 | {
|
---|
363 | fprintf (outfile, " [");
|
---|
364 | fprintf (outfile, HOST_WIDE_INT_PRINT_HEX, XWINT (in_rtx, i));
|
---|
365 | fprintf (outfile, "]");
|
---|
366 | }
|
---|
367 | break;
|
---|
368 |
|
---|
369 | case 'i':
|
---|
370 | if (i == 6 && GET_CODE (in_rtx) == NOTE)
|
---|
371 | {
|
---|
372 | /* This field is only used for NOTE_INSN_DELETED_LABEL, and
|
---|
373 | other times often contains garbage from INSN->NOTE death. */
|
---|
374 | if (NOTE_LINE_NUMBER (in_rtx) == NOTE_INSN_DELETED_LABEL)
|
---|
375 | fprintf (outfile, " %d", XINT (in_rtx, i));
|
---|
376 | }
|
---|
377 | else
|
---|
378 | {
|
---|
379 | int value = XINT (in_rtx, i);
|
---|
380 | const char *name;
|
---|
381 |
|
---|
382 | if (GET_CODE (in_rtx) == REG && value < FIRST_PSEUDO_REGISTER)
|
---|
383 | {
|
---|
384 | fputc (' ', outfile);
|
---|
385 | DEBUG_PRINT_REG (in_rtx, 0, outfile);
|
---|
386 | }
|
---|
387 | else if (GET_CODE (in_rtx) == REG
|
---|
388 | && value <= LAST_VIRTUAL_REGISTER)
|
---|
389 | {
|
---|
390 | if (value == VIRTUAL_INCOMING_ARGS_REGNUM)
|
---|
391 | fprintf (outfile, " %d virtual-incoming-args", value);
|
---|
392 | else if (value == VIRTUAL_STACK_VARS_REGNUM)
|
---|
393 | fprintf (outfile, " %d virtual-stack-vars", value);
|
---|
394 | else if (value == VIRTUAL_STACK_DYNAMIC_REGNUM)
|
---|
395 | fprintf (outfile, " %d virtual-stack-dynamic", value);
|
---|
396 | else if (value == VIRTUAL_OUTGOING_ARGS_REGNUM)
|
---|
397 | fprintf (outfile, " %d virtual-outgoing-args", value);
|
---|
398 | else if (value == VIRTUAL_CFA_REGNUM)
|
---|
399 | fprintf (outfile, " %d virtual-cfa", value);
|
---|
400 | else
|
---|
401 | fprintf (outfile, " %d virtual-reg-%d", value,
|
---|
402 | value-FIRST_VIRTUAL_REGISTER);
|
---|
403 | }
|
---|
404 | else if (flag_dump_unnumbered
|
---|
405 | && (is_insn || GET_CODE (in_rtx) == NOTE))
|
---|
406 | fputc ('#', outfile);
|
---|
407 | else
|
---|
408 | fprintf (outfile, " %d", value);
|
---|
409 |
|
---|
410 | if (is_insn && &INSN_CODE (in_rtx) == &XINT (in_rtx, i)
|
---|
411 | && XINT (in_rtx, i) >= 0
|
---|
412 | && (name = get_insn_name (XINT (in_rtx, i))) != NULL)
|
---|
413 | fprintf (outfile, " {%s}", name);
|
---|
414 | sawclose = 0;
|
---|
415 | }
|
---|
416 | break;
|
---|
417 |
|
---|
418 | /* Print NOTE_INSN names rather than integer codes. */
|
---|
419 |
|
---|
420 | case 'n':
|
---|
421 | if (XINT (in_rtx, i) >= (int) NOTE_INSN_BIAS
|
---|
422 | && XINT (in_rtx, i) < (int) NOTE_INSN_MAX)
|
---|
423 | fprintf (outfile, " %s", GET_NOTE_INSN_NAME (XINT (in_rtx, i)));
|
---|
424 | else
|
---|
425 | fprintf (outfile, " %d", XINT (in_rtx, i));
|
---|
426 | sawclose = 0;
|
---|
427 | break;
|
---|
428 |
|
---|
429 | case 'u':
|
---|
430 | if (XEXP (in_rtx, i) != NULL)
|
---|
431 | {
|
---|
432 | rtx sub = XEXP (in_rtx, i);
|
---|
433 | enum rtx_code subc = GET_CODE (sub);
|
---|
434 |
|
---|
435 | if (GET_CODE (in_rtx) == LABEL_REF)
|
---|
436 | {
|
---|
437 | if (subc == NOTE
|
---|
438 | && NOTE_LINE_NUMBER (sub) == NOTE_INSN_DELETED_LABEL)
|
---|
439 | {
|
---|
440 | if (flag_dump_unnumbered)
|
---|
441 | fprintf (outfile, " [# deleted]");
|
---|
442 | else
|
---|
443 | fprintf (outfile, " [%d deleted]", INSN_UID (sub));
|
---|
444 | sawclose = 0;
|
---|
445 | break;
|
---|
446 | }
|
---|
447 |
|
---|
448 | if (subc != CODE_LABEL)
|
---|
449 | goto do_e;
|
---|
450 | }
|
---|
451 |
|
---|
452 | if (flag_dump_unnumbered)
|
---|
453 | fputs (" #", outfile);
|
---|
454 | else
|
---|
455 | fprintf (outfile, " %d", INSN_UID (sub));
|
---|
456 | }
|
---|
457 | else
|
---|
458 | fputs (" 0", outfile);
|
---|
459 | sawclose = 0;
|
---|
460 | break;
|
---|
461 |
|
---|
462 | case 'b':
|
---|
463 | if (XBITMAP (in_rtx, i) == NULL)
|
---|
464 | fputs (" {null}", outfile);
|
---|
465 | else
|
---|
466 | bitmap_print (outfile, XBITMAP (in_rtx, i), " {", "}");
|
---|
467 | sawclose = 0;
|
---|
468 | break;
|
---|
469 |
|
---|
470 | case 't':
|
---|
471 | putc (' ', outfile);
|
---|
472 | fprintf (outfile, HOST_PTR_PRINTF, (char *) XTREE (in_rtx, i));
|
---|
473 | break;
|
---|
474 |
|
---|
475 | case '*':
|
---|
476 | fputs (" Unknown", outfile);
|
---|
477 | sawclose = 0;
|
---|
478 | break;
|
---|
479 |
|
---|
480 | case 'B':
|
---|
481 | if (XBBDEF (in_rtx, i))
|
---|
482 | fprintf (outfile, " %i", XBBDEF (in_rtx, i)->index);
|
---|
483 | break;
|
---|
484 |
|
---|
485 | default:
|
---|
486 | fprintf (stderr,
|
---|
487 | "switch format wrong in rtl.print_rtx(). format was: %c.\n",
|
---|
488 | format_ptr[-1]);
|
---|
489 | abort ();
|
---|
490 | }
|
---|
491 |
|
---|
492 | switch (GET_CODE (in_rtx))
|
---|
493 | {
|
---|
494 | #ifndef GENERATOR_FILE
|
---|
495 | case MEM:
|
---|
496 | fputs (" [", outfile);
|
---|
497 | fprintf (outfile, HOST_WIDE_INT_PRINT_DEC, MEM_ALIAS_SET (in_rtx));
|
---|
498 |
|
---|
499 | if (MEM_EXPR (in_rtx))
|
---|
500 | print_mem_expr (outfile, MEM_EXPR (in_rtx));
|
---|
501 |
|
---|
502 | if (MEM_OFFSET (in_rtx))
|
---|
503 | {
|
---|
504 | fputc ('+', outfile);
|
---|
505 | fprintf (outfile, HOST_WIDE_INT_PRINT_DEC,
|
---|
506 | INTVAL (MEM_OFFSET (in_rtx)));
|
---|
507 | }
|
---|
508 |
|
---|
509 | if (MEM_SIZE (in_rtx))
|
---|
510 | {
|
---|
511 | fputs (" S", outfile);
|
---|
512 | fprintf (outfile, HOST_WIDE_INT_PRINT_DEC,
|
---|
513 | INTVAL (MEM_SIZE (in_rtx)));
|
---|
514 | }
|
---|
515 |
|
---|
516 | if (MEM_ALIGN (in_rtx) != 1)
|
---|
517 | fprintf (outfile, " A%u", MEM_ALIGN (in_rtx));
|
---|
518 |
|
---|
519 | fputc (']', outfile);
|
---|
520 | break;
|
---|
521 |
|
---|
522 | case CONST_DOUBLE:
|
---|
523 | if (FLOAT_MODE_P (GET_MODE (in_rtx)))
|
---|
524 | {
|
---|
525 | char s[60];
|
---|
526 |
|
---|
527 | real_to_decimal (s, CONST_DOUBLE_REAL_VALUE (in_rtx),
|
---|
528 | sizeof (s), 0, 1);
|
---|
529 | fprintf (outfile, " %s", s);
|
---|
530 |
|
---|
531 | real_to_hexadecimal (s, CONST_DOUBLE_REAL_VALUE (in_rtx),
|
---|
532 | sizeof (s), 0, 1);
|
---|
533 | fprintf (outfile, " [%s]", s);
|
---|
534 | }
|
---|
535 | break;
|
---|
536 | #endif
|
---|
537 |
|
---|
538 | case CODE_LABEL:
|
---|
539 | fprintf (outfile, " [%d uses]", LABEL_NUSES (in_rtx));
|
---|
540 | switch (LABEL_KIND (in_rtx))
|
---|
541 | {
|
---|
542 | case LABEL_NORMAL: break;
|
---|
543 | case LABEL_STATIC_ENTRY: fputs (" [entry]", outfile); break;
|
---|
544 | case LABEL_GLOBAL_ENTRY: fputs (" [global entry]", outfile); break;
|
---|
545 | case LABEL_WEAK_ENTRY: fputs (" [weak entry]", outfile); break;
|
---|
546 | default: abort();
|
---|
547 | }
|
---|
548 | break;
|
---|
549 |
|
---|
550 | case CALL_PLACEHOLDER:
|
---|
551 | if (debug_call_placeholder_verbose)
|
---|
552 | {
|
---|
553 | fputs (" (cond [\n (const_string \"normal\") (sequence [", outfile);
|
---|
554 | for (tem = XEXP (in_rtx, 0); tem != 0; tem = NEXT_INSN (tem))
|
---|
555 | {
|
---|
556 | fputs ("\n ", outfile);
|
---|
557 | print_inline_rtx (outfile, tem, 4);
|
---|
558 | }
|
---|
559 |
|
---|
560 | tem = XEXP (in_rtx, 1);
|
---|
561 | if (tem)
|
---|
562 | fputs ("\n ])\n (const_string \"tail_call\") (sequence [",
|
---|
563 | outfile);
|
---|
564 | for (; tem != 0; tem = NEXT_INSN (tem))
|
---|
565 | {
|
---|
566 | fputs ("\n ", outfile);
|
---|
567 | print_inline_rtx (outfile, tem, 4);
|
---|
568 | }
|
---|
569 |
|
---|
570 | tem = XEXP (in_rtx, 2);
|
---|
571 | if (tem)
|
---|
572 | fputs ("\n ])\n (const_string \"tail_recursion\") (sequence [",
|
---|
573 | outfile);
|
---|
574 | for (; tem != 0; tem = NEXT_INSN (tem))
|
---|
575 | {
|
---|
576 | fputs ("\n ", outfile);
|
---|
577 | print_inline_rtx (outfile, tem, 4);
|
---|
578 | }
|
---|
579 |
|
---|
580 | fputs ("\n ])\n ])", outfile);
|
---|
581 | break;
|
---|
582 | }
|
---|
583 |
|
---|
584 | for (tem = XEXP (in_rtx, 0); tem != 0; tem = NEXT_INSN (tem))
|
---|
585 | if (GET_CODE (tem) == CALL_INSN)
|
---|
586 | {
|
---|
587 | fprintf (outfile, " ");
|
---|
588 | print_rtx (tem);
|
---|
589 | break;
|
---|
590 | }
|
---|
591 | break;
|
---|
592 |
|
---|
593 | default:
|
---|
594 | break;
|
---|
595 | }
|
---|
596 |
|
---|
597 | if (dump_for_graph
|
---|
598 | && (is_insn || GET_CODE (in_rtx) == NOTE
|
---|
599 | || GET_CODE (in_rtx) == CODE_LABEL || GET_CODE (in_rtx) == BARRIER))
|
---|
600 | sawclose = 0;
|
---|
601 | else
|
---|
602 | {
|
---|
603 | fputc (')', outfile);
|
---|
604 | sawclose = 1;
|
---|
605 | }
|
---|
606 | }
|
---|
607 |
|
---|
608 | /* Print an rtx on the current line of FILE. Initially indent IND
|
---|
609 | characters. */
|
---|
610 |
|
---|
611 | void
|
---|
612 | print_inline_rtx (outf, x, ind)
|
---|
613 | FILE *outf;
|
---|
614 | rtx x;
|
---|
615 | int ind;
|
---|
616 | {
|
---|
617 | int oldsaw = sawclose;
|
---|
618 | int oldindent = indent;
|
---|
619 |
|
---|
620 | sawclose = 0;
|
---|
621 | indent = ind;
|
---|
622 | outfile = outf;
|
---|
623 | print_rtx (x);
|
---|
624 | sawclose = oldsaw;
|
---|
625 | indent = oldindent;
|
---|
626 | }
|
---|
627 |
|
---|
628 | /* Call this function from the debugger to see what X looks like. */
|
---|
629 |
|
---|
630 | void
|
---|
631 | debug_rtx (x)
|
---|
632 | rtx x;
|
---|
633 | {
|
---|
634 | outfile = stderr;
|
---|
635 | sawclose = 0;
|
---|
636 | print_rtx (x);
|
---|
637 | fprintf (stderr, "\n");
|
---|
638 | }
|
---|
639 |
|
---|
640 | /* Count of rtx's to print with debug_rtx_list.
|
---|
641 | This global exists because gdb user defined commands have no arguments. */
|
---|
642 |
|
---|
643 | int debug_rtx_count = 0; /* 0 is treated as equivalent to 1 */
|
---|
644 |
|
---|
645 | /* Call this function to print list from X on.
|
---|
646 |
|
---|
647 | N is a count of the rtx's to print. Positive values print from the specified
|
---|
648 | rtx on. Negative values print a window around the rtx.
|
---|
649 | EG: -5 prints 2 rtx's on either side (in addition to the specified rtx). */
|
---|
650 |
|
---|
651 | void
|
---|
652 | debug_rtx_list (x, n)
|
---|
653 | rtx x;
|
---|
654 | int n;
|
---|
655 | {
|
---|
656 | int i,count;
|
---|
657 | rtx insn;
|
---|
658 |
|
---|
659 | count = n == 0 ? 1 : n < 0 ? -n : n;
|
---|
660 |
|
---|
661 | /* If we are printing a window, back up to the start. */
|
---|
662 |
|
---|
663 | if (n < 0)
|
---|
664 | for (i = count / 2; i > 0; i--)
|
---|
665 | {
|
---|
666 | if (PREV_INSN (x) == 0)
|
---|
667 | break;
|
---|
668 | x = PREV_INSN (x);
|
---|
669 | }
|
---|
670 |
|
---|
671 | for (i = count, insn = x; i > 0 && insn != 0; i--, insn = NEXT_INSN (insn))
|
---|
672 | {
|
---|
673 | debug_rtx (insn);
|
---|
674 | fprintf (stderr, "\n");
|
---|
675 | }
|
---|
676 | }
|
---|
677 |
|
---|
678 | /* Call this function to print an rtx list from START to END inclusive. */
|
---|
679 |
|
---|
680 | void
|
---|
681 | debug_rtx_range (start, end)
|
---|
682 | rtx start, end;
|
---|
683 | {
|
---|
684 | while (1)
|
---|
685 | {
|
---|
686 | debug_rtx (start);
|
---|
687 | fprintf (stderr, "\n");
|
---|
688 | if (!start || start == end)
|
---|
689 | break;
|
---|
690 | start = NEXT_INSN (start);
|
---|
691 | }
|
---|
692 | }
|
---|
693 |
|
---|
694 | /* Call this function to search an rtx list to find one with insn uid UID,
|
---|
695 | and then call debug_rtx_list to print it, using DEBUG_RTX_COUNT.
|
---|
696 | The found insn is returned to enable further debugging analysis. */
|
---|
697 |
|
---|
698 | rtx
|
---|
699 | debug_rtx_find (x, uid)
|
---|
700 | rtx x;
|
---|
701 | int uid;
|
---|
702 | {
|
---|
703 | while (x != 0 && INSN_UID (x) != uid)
|
---|
704 | x = NEXT_INSN (x);
|
---|
705 | if (x != 0)
|
---|
706 | {
|
---|
707 | debug_rtx_list (x, debug_rtx_count);
|
---|
708 | return x;
|
---|
709 | }
|
---|
710 | else
|
---|
711 | {
|
---|
712 | fprintf (stderr, "insn uid %d not found\n", uid);
|
---|
713 | return 0;
|
---|
714 | }
|
---|
715 | }
|
---|
716 |
|
---|
717 | /* External entry point for printing a chain of insns
|
---|
718 | starting with RTX_FIRST onto file OUTF.
|
---|
719 | A blank line separates insns.
|
---|
720 |
|
---|
721 | If RTX_FIRST is not an insn, then it alone is printed, with no newline. */
|
---|
722 |
|
---|
723 | void
|
---|
724 | print_rtl (outf, rtx_first)
|
---|
725 | FILE *outf;
|
---|
726 | rtx rtx_first;
|
---|
727 | {
|
---|
728 | rtx tmp_rtx;
|
---|
729 |
|
---|
730 | outfile = outf;
|
---|
731 | sawclose = 0;
|
---|
732 |
|
---|
733 | if (rtx_first == 0)
|
---|
734 | {
|
---|
735 | fputs (print_rtx_head, outf);
|
---|
736 | fputs ("(nil)\n", outf);
|
---|
737 | }
|
---|
738 | else
|
---|
739 | switch (GET_CODE (rtx_first))
|
---|
740 | {
|
---|
741 | case INSN:
|
---|
742 | case JUMP_INSN:
|
---|
743 | case CALL_INSN:
|
---|
744 | case NOTE:
|
---|
745 | case CODE_LABEL:
|
---|
746 | case BARRIER:
|
---|
747 | for (tmp_rtx = rtx_first; tmp_rtx != 0; tmp_rtx = NEXT_INSN (tmp_rtx))
|
---|
748 | if (! flag_dump_unnumbered
|
---|
749 | || GET_CODE (tmp_rtx) != NOTE || NOTE_LINE_NUMBER (tmp_rtx) < 0)
|
---|
750 | {
|
---|
751 | fputs (print_rtx_head, outfile);
|
---|
752 | print_rtx (tmp_rtx);
|
---|
753 | fprintf (outfile, "\n");
|
---|
754 | }
|
---|
755 | break;
|
---|
756 |
|
---|
757 | default:
|
---|
758 | fputs (print_rtx_head, outfile);
|
---|
759 | print_rtx (rtx_first);
|
---|
760 | }
|
---|
761 | }
|
---|
762 |
|
---|
763 | /* Like print_rtx, except specify a file. */
|
---|
764 | /* Return nonzero if we actually printed anything. */
|
---|
765 |
|
---|
766 | int
|
---|
767 | print_rtl_single (outf, x)
|
---|
768 | FILE *outf;
|
---|
769 | rtx x;
|
---|
770 | {
|
---|
771 | outfile = outf;
|
---|
772 | sawclose = 0;
|
---|
773 | if (! flag_dump_unnumbered
|
---|
774 | || GET_CODE (x) != NOTE || NOTE_LINE_NUMBER (x) < 0)
|
---|
775 | {
|
---|
776 | fputs (print_rtx_head, outfile);
|
---|
777 | print_rtx (x);
|
---|
778 | putc ('\n', outf);
|
---|
779 | return 1;
|
---|
780 | }
|
---|
781 | return 0;
|
---|
782 | }
|
---|
783 |
|
---|
784 |
|
---|
785 | /* Like print_rtl except without all the detail; for example,
|
---|
786 | if RTX is a CONST_INT then print in decimal format. */
|
---|
787 |
|
---|
788 | void
|
---|
789 | print_simple_rtl (outf, x)
|
---|
790 | FILE *outf;
|
---|
791 | rtx x;
|
---|
792 | {
|
---|
793 | flag_simple = 1;
|
---|
794 | print_rtl (outf, x);
|
---|
795 | flag_simple = 0;
|
---|
796 | }
|
---|