OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.2.2/] [gcc/] [print-rtl.c] - Blame information for rev 363

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.