annotate gcc/print-rtl.c @ 115:4cb7a319550d

fix c-parser.c
author mir3636
date Tue, 28 Nov 2017 19:31:15 +0900
parents 04ced10e8804
children 84e7813d76e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 /* Print RTL for GCC.
111
kono
parents: 67
diff changeset
2 Copyright (C) 1987-2017 Free Software Foundation, Inc.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 This file is part of GCC.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 GCC is free software; you can redistribute it and/or modify it under
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 the terms of the GNU General Public License as published by the Free
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 Software Foundation; either version 3, or (at your option) any later
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 version.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 for more details.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 along with GCC; see the file COPYING3. If not see
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 <http://www.gnu.org/licenses/>. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 /* This file is compiled twice: once for the generator programs,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 once for the compiler. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 #ifdef GENERATOR_FILE
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 #include "bconfig.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 #else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 #include "config.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 #endif
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
27
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 #include "system.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 #include "coretypes.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 #include "tm.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 #include "rtl.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
32
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 /* These headers all define things which are not available in
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 generator programs. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 #ifndef GENERATOR_FILE
111
kono
parents: 67
diff changeset
36 #include "alias.h"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 #include "tree.h"
111
kono
parents: 67
diff changeset
38 #include "basic-block.h"
kono
parents: 67
diff changeset
39 #include "cfg.h"
kono
parents: 67
diff changeset
40 #include "print-tree.h"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 #include "flags.h"
111
kono
parents: 67
diff changeset
42 #include "predict.h"
kono
parents: 67
diff changeset
43 #include "function.h"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 #include "basic-block.h"
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
45 #include "diagnostic.h"
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
46 #include "tree-pretty-print.h"
111
kono
parents: 67
diff changeset
47 #include "alloc-pool.h"
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
48 #include "cselib.h"
111
kono
parents: 67
diff changeset
49 #include "dumpfile.h" /* for dump_flags */
kono
parents: 67
diff changeset
50 #include "dwarf2out.h"
kono
parents: 67
diff changeset
51 #include "pretty-print.h"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 #endif
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
53
111
kono
parents: 67
diff changeset
54 #include "print-rtl.h"
kono
parents: 67
diff changeset
55 #include "rtl-iter.h"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
56
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 /* String printed at beginning of each RTL when it is dumped.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 This string is set to ASM_COMMENT_START when the RTL is dumped in
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 the assembly output file. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 const char *print_rtx_head = "";
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
61
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
62 #ifdef GENERATOR_FILE
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
63 /* These are defined from the .opt file when not used in generator
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
64 programs. */
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
65
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
66 /* Nonzero means suppress output of instruction numbers
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 in debugging dumps.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 This must be defined here so that programs like gencodes can be linked. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 int flag_dump_unnumbered = 0;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
70
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
71 /* Nonzero means suppress output of instruction numbers for previous
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
72 and next insns in debugging dumps.
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
73 This must be defined here so that programs like gencodes can be linked. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
74 int flag_dump_unnumbered_links = 0;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
75 #endif
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
76
111
kono
parents: 67
diff changeset
77 /* Constructor for rtx_writer. */
kono
parents: 67
diff changeset
78
kono
parents: 67
diff changeset
79 rtx_writer::rtx_writer (FILE *outf, int ind, bool simple, bool compact,
kono
parents: 67
diff changeset
80 rtx_reuse_manager *reuse_manager)
kono
parents: 67
diff changeset
81 : m_outfile (outf), m_sawclose (0), m_indent (ind),
kono
parents: 67
diff changeset
82 m_in_call_function_usage (false), m_simple (simple), m_compact (compact),
kono
parents: 67
diff changeset
83 m_rtx_reuse_manager (reuse_manager)
kono
parents: 67
diff changeset
84 {
kono
parents: 67
diff changeset
85 }
kono
parents: 67
diff changeset
86
kono
parents: 67
diff changeset
87 #ifndef GENERATOR_FILE
kono
parents: 67
diff changeset
88
kono
parents: 67
diff changeset
89 /* rtx_reuse_manager's ctor. */
kono
parents: 67
diff changeset
90
kono
parents: 67
diff changeset
91 rtx_reuse_manager::rtx_reuse_manager ()
kono
parents: 67
diff changeset
92 : m_next_id (0)
kono
parents: 67
diff changeset
93 {
kono
parents: 67
diff changeset
94 }
kono
parents: 67
diff changeset
95
kono
parents: 67
diff changeset
96 /* Determine if X is of a kind suitable for dumping via reuse_rtx. */
kono
parents: 67
diff changeset
97
kono
parents: 67
diff changeset
98 static bool
kono
parents: 67
diff changeset
99 uses_rtx_reuse_p (const_rtx x)
kono
parents: 67
diff changeset
100 {
kono
parents: 67
diff changeset
101 if (x == NULL)
kono
parents: 67
diff changeset
102 return false;
kono
parents: 67
diff changeset
103
kono
parents: 67
diff changeset
104 switch (GET_CODE (x))
kono
parents: 67
diff changeset
105 {
kono
parents: 67
diff changeset
106 case DEBUG_EXPR:
kono
parents: 67
diff changeset
107 case VALUE:
kono
parents: 67
diff changeset
108 case SCRATCH:
kono
parents: 67
diff changeset
109 return true;
kono
parents: 67
diff changeset
110
kono
parents: 67
diff changeset
111 /* We don't use reuse_rtx for consts. */
kono
parents: 67
diff changeset
112 CASE_CONST_UNIQUE:
kono
parents: 67
diff changeset
113 default:
kono
parents: 67
diff changeset
114 return false;
kono
parents: 67
diff changeset
115 }
kono
parents: 67
diff changeset
116 }
kono
parents: 67
diff changeset
117
kono
parents: 67
diff changeset
118 /* Traverse X and its descendents, determining if we see any rtx more than
kono
parents: 67
diff changeset
119 once. Any rtx suitable for "reuse_rtx" that is seen more than once is
kono
parents: 67
diff changeset
120 assigned an ID. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
121
111
kono
parents: 67
diff changeset
122 void
kono
parents: 67
diff changeset
123 rtx_reuse_manager::preprocess (const_rtx x)
kono
parents: 67
diff changeset
124 {
kono
parents: 67
diff changeset
125 subrtx_iterator::array_type array;
kono
parents: 67
diff changeset
126 FOR_EACH_SUBRTX (iter, array, x, NONCONST)
kono
parents: 67
diff changeset
127 if (uses_rtx_reuse_p (*iter))
kono
parents: 67
diff changeset
128 {
kono
parents: 67
diff changeset
129 if (int *count = m_rtx_occurrence_count.get (*iter))
kono
parents: 67
diff changeset
130 {
kono
parents: 67
diff changeset
131 if (*(count++) == 1)
kono
parents: 67
diff changeset
132 m_rtx_reuse_ids.put (*iter, m_next_id++);
kono
parents: 67
diff changeset
133 }
kono
parents: 67
diff changeset
134 else
kono
parents: 67
diff changeset
135 m_rtx_occurrence_count.put (*iter, 1);
kono
parents: 67
diff changeset
136 }
kono
parents: 67
diff changeset
137 }
kono
parents: 67
diff changeset
138
kono
parents: 67
diff changeset
139 /* Return true iff X has been assigned a reuse ID. If it has,
kono
parents: 67
diff changeset
140 and OUT is non-NULL, then write the reuse ID to *OUT. */
kono
parents: 67
diff changeset
141
kono
parents: 67
diff changeset
142 bool
kono
parents: 67
diff changeset
143 rtx_reuse_manager::has_reuse_id (const_rtx x, int *out)
kono
parents: 67
diff changeset
144 {
kono
parents: 67
diff changeset
145 int *id = m_rtx_reuse_ids.get (x);
kono
parents: 67
diff changeset
146 if (id)
kono
parents: 67
diff changeset
147 {
kono
parents: 67
diff changeset
148 if (out)
kono
parents: 67
diff changeset
149 *out = *id;
kono
parents: 67
diff changeset
150 return true;
kono
parents: 67
diff changeset
151 }
kono
parents: 67
diff changeset
152 else
kono
parents: 67
diff changeset
153 return false;
kono
parents: 67
diff changeset
154 }
kono
parents: 67
diff changeset
155
kono
parents: 67
diff changeset
156 /* Determine if set_seen_def has been called for the given reuse ID. */
kono
parents: 67
diff changeset
157
kono
parents: 67
diff changeset
158 bool
kono
parents: 67
diff changeset
159 rtx_reuse_manager::seen_def_p (int reuse_id)
kono
parents: 67
diff changeset
160 {
kono
parents: 67
diff changeset
161 return bitmap_bit_p (m_defs_seen, reuse_id);
kono
parents: 67
diff changeset
162 }
kono
parents: 67
diff changeset
163
kono
parents: 67
diff changeset
164 /* Record that the definition of the given reuse ID has been seen. */
kono
parents: 67
diff changeset
165
kono
parents: 67
diff changeset
166 void
kono
parents: 67
diff changeset
167 rtx_reuse_manager::set_seen_def (int reuse_id)
kono
parents: 67
diff changeset
168 {
kono
parents: 67
diff changeset
169 bitmap_set_bit (m_defs_seen, reuse_id);
kono
parents: 67
diff changeset
170 }
kono
parents: 67
diff changeset
171
kono
parents: 67
diff changeset
172 #endif /* #ifndef GENERATOR_FILE */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
173
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
174 #ifndef GENERATOR_FILE
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
175 void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
176 print_mem_expr (FILE *outfile, const_tree expr)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
177 {
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
178 fputc (' ', outfile);
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
179 print_generic_expr (outfile, CONST_CAST_TREE (expr), dump_flags);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
180 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
181 #endif
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
182
111
kono
parents: 67
diff changeset
183 /* Subroutine of print_rtx_operand for handling code '0'.
kono
parents: 67
diff changeset
184 0 indicates a field for internal use that should not be printed.
kono
parents: 67
diff changeset
185 However there are various special cases, such as the third field
kono
parents: 67
diff changeset
186 of a NOTE, where it indicates that the field has several different
kono
parents: 67
diff changeset
187 valid contents. */
kono
parents: 67
diff changeset
188
kono
parents: 67
diff changeset
189 void
kono
parents: 67
diff changeset
190 rtx_writer::print_rtx_operand_code_0 (const_rtx in_rtx ATTRIBUTE_UNUSED,
kono
parents: 67
diff changeset
191 int idx ATTRIBUTE_UNUSED)
kono
parents: 67
diff changeset
192 {
kono
parents: 67
diff changeset
193 #ifndef GENERATOR_FILE
kono
parents: 67
diff changeset
194 if (idx == 1 && GET_CODE (in_rtx) == SYMBOL_REF)
kono
parents: 67
diff changeset
195 {
kono
parents: 67
diff changeset
196 int flags = SYMBOL_REF_FLAGS (in_rtx);
kono
parents: 67
diff changeset
197 if (flags)
kono
parents: 67
diff changeset
198 fprintf (m_outfile, " [flags %#x]", flags);
kono
parents: 67
diff changeset
199 tree decl = SYMBOL_REF_DECL (in_rtx);
kono
parents: 67
diff changeset
200 if (decl)
kono
parents: 67
diff changeset
201 print_node_brief (m_outfile, "", decl, dump_flags);
kono
parents: 67
diff changeset
202 }
kono
parents: 67
diff changeset
203 else if (idx == 3 && NOTE_P (in_rtx))
kono
parents: 67
diff changeset
204 {
kono
parents: 67
diff changeset
205 switch (NOTE_KIND (in_rtx))
kono
parents: 67
diff changeset
206 {
kono
parents: 67
diff changeset
207 case NOTE_INSN_EH_REGION_BEG:
kono
parents: 67
diff changeset
208 case NOTE_INSN_EH_REGION_END:
kono
parents: 67
diff changeset
209 if (flag_dump_unnumbered)
kono
parents: 67
diff changeset
210 fprintf (m_outfile, " #");
kono
parents: 67
diff changeset
211 else
kono
parents: 67
diff changeset
212 fprintf (m_outfile, " %d", NOTE_EH_HANDLER (in_rtx));
kono
parents: 67
diff changeset
213 m_sawclose = 1;
kono
parents: 67
diff changeset
214 break;
kono
parents: 67
diff changeset
215
kono
parents: 67
diff changeset
216 case NOTE_INSN_BLOCK_BEG:
kono
parents: 67
diff changeset
217 case NOTE_INSN_BLOCK_END:
kono
parents: 67
diff changeset
218 dump_addr (m_outfile, " ", NOTE_BLOCK (in_rtx));
kono
parents: 67
diff changeset
219 m_sawclose = 1;
kono
parents: 67
diff changeset
220 break;
kono
parents: 67
diff changeset
221
kono
parents: 67
diff changeset
222 case NOTE_INSN_BASIC_BLOCK:
kono
parents: 67
diff changeset
223 {
kono
parents: 67
diff changeset
224 basic_block bb = NOTE_BASIC_BLOCK (in_rtx);
kono
parents: 67
diff changeset
225 if (bb != 0)
kono
parents: 67
diff changeset
226 fprintf (m_outfile, " [bb %d]", bb->index);
kono
parents: 67
diff changeset
227 break;
kono
parents: 67
diff changeset
228 }
kono
parents: 67
diff changeset
229
kono
parents: 67
diff changeset
230 case NOTE_INSN_DELETED_LABEL:
kono
parents: 67
diff changeset
231 case NOTE_INSN_DELETED_DEBUG_LABEL:
kono
parents: 67
diff changeset
232 {
kono
parents: 67
diff changeset
233 const char *label = NOTE_DELETED_LABEL_NAME (in_rtx);
kono
parents: 67
diff changeset
234 if (label)
kono
parents: 67
diff changeset
235 fprintf (m_outfile, " (\"%s\")", label);
kono
parents: 67
diff changeset
236 else
kono
parents: 67
diff changeset
237 fprintf (m_outfile, " \"\"");
kono
parents: 67
diff changeset
238 }
kono
parents: 67
diff changeset
239 break;
kono
parents: 67
diff changeset
240
kono
parents: 67
diff changeset
241 case NOTE_INSN_SWITCH_TEXT_SECTIONS:
kono
parents: 67
diff changeset
242 {
kono
parents: 67
diff changeset
243 basic_block bb = NOTE_BASIC_BLOCK (in_rtx);
kono
parents: 67
diff changeset
244 if (bb != 0)
kono
parents: 67
diff changeset
245 fprintf (m_outfile, " [bb %d]", bb->index);
kono
parents: 67
diff changeset
246 break;
kono
parents: 67
diff changeset
247 }
kono
parents: 67
diff changeset
248
kono
parents: 67
diff changeset
249 case NOTE_INSN_VAR_LOCATION:
kono
parents: 67
diff changeset
250 case NOTE_INSN_CALL_ARG_LOCATION:
kono
parents: 67
diff changeset
251 fputc (' ', m_outfile);
kono
parents: 67
diff changeset
252 print_rtx (NOTE_VAR_LOCATION (in_rtx));
kono
parents: 67
diff changeset
253 break;
kono
parents: 67
diff changeset
254
kono
parents: 67
diff changeset
255 case NOTE_INSN_CFI:
kono
parents: 67
diff changeset
256 fputc ('\n', m_outfile);
kono
parents: 67
diff changeset
257 output_cfi_directive (m_outfile, NOTE_CFI (in_rtx));
kono
parents: 67
diff changeset
258 fputc ('\t', m_outfile);
kono
parents: 67
diff changeset
259 break;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
260
111
kono
parents: 67
diff changeset
261 default:
kono
parents: 67
diff changeset
262 break;
kono
parents: 67
diff changeset
263 }
kono
parents: 67
diff changeset
264 }
kono
parents: 67
diff changeset
265 else if (idx == 7 && JUMP_P (in_rtx) && JUMP_LABEL (in_rtx) != NULL
kono
parents: 67
diff changeset
266 && !m_compact)
kono
parents: 67
diff changeset
267 {
kono
parents: 67
diff changeset
268 /* Output the JUMP_LABEL reference. */
kono
parents: 67
diff changeset
269 fprintf (m_outfile, "\n%s%*s -> ", print_rtx_head, m_indent * 2, "");
kono
parents: 67
diff changeset
270 if (GET_CODE (JUMP_LABEL (in_rtx)) == RETURN)
kono
parents: 67
diff changeset
271 fprintf (m_outfile, "return");
kono
parents: 67
diff changeset
272 else if (GET_CODE (JUMP_LABEL (in_rtx)) == SIMPLE_RETURN)
kono
parents: 67
diff changeset
273 fprintf (m_outfile, "simple_return");
kono
parents: 67
diff changeset
274 else
kono
parents: 67
diff changeset
275 fprintf (m_outfile, "%d", INSN_UID (JUMP_LABEL (in_rtx)));
kono
parents: 67
diff changeset
276 }
kono
parents: 67
diff changeset
277 else if (idx == 0 && GET_CODE (in_rtx) == VALUE)
kono
parents: 67
diff changeset
278 {
kono
parents: 67
diff changeset
279 cselib_val *val = CSELIB_VAL_PTR (in_rtx);
kono
parents: 67
diff changeset
280
kono
parents: 67
diff changeset
281 fprintf (m_outfile, " %u:%u", val->uid, val->hash);
kono
parents: 67
diff changeset
282 dump_addr (m_outfile, " @", in_rtx);
kono
parents: 67
diff changeset
283 dump_addr (m_outfile, "/", (void*)val);
kono
parents: 67
diff changeset
284 }
kono
parents: 67
diff changeset
285 else if (idx == 0 && GET_CODE (in_rtx) == DEBUG_EXPR)
kono
parents: 67
diff changeset
286 {
kono
parents: 67
diff changeset
287 fprintf (m_outfile, " D#%i",
kono
parents: 67
diff changeset
288 DEBUG_TEMP_UID (DEBUG_EXPR_TREE_DECL (in_rtx)));
kono
parents: 67
diff changeset
289 }
kono
parents: 67
diff changeset
290 else if (idx == 0 && GET_CODE (in_rtx) == ENTRY_VALUE)
kono
parents: 67
diff changeset
291 {
kono
parents: 67
diff changeset
292 m_indent += 2;
kono
parents: 67
diff changeset
293 if (!m_sawclose)
kono
parents: 67
diff changeset
294 fprintf (m_outfile, " ");
kono
parents: 67
diff changeset
295 print_rtx (ENTRY_VALUE_EXP (in_rtx));
kono
parents: 67
diff changeset
296 m_indent -= 2;
kono
parents: 67
diff changeset
297 }
kono
parents: 67
diff changeset
298 #endif
kono
parents: 67
diff changeset
299 }
kono
parents: 67
diff changeset
300
kono
parents: 67
diff changeset
301 /* Subroutine of print_rtx_operand for handling code 'e'.
kono
parents: 67
diff changeset
302 Also called by print_rtx_operand_code_u for handling code 'u'
kono
parents: 67
diff changeset
303 for LABEL_REFs when they don't reference a CODE_LABEL. */
kono
parents: 67
diff changeset
304
kono
parents: 67
diff changeset
305 void
kono
parents: 67
diff changeset
306 rtx_writer::print_rtx_operand_code_e (const_rtx in_rtx, int idx)
kono
parents: 67
diff changeset
307 {
kono
parents: 67
diff changeset
308 m_indent += 2;
kono
parents: 67
diff changeset
309 if (idx == 6 && INSN_P (in_rtx))
kono
parents: 67
diff changeset
310 /* Put REG_NOTES on their own line. */
kono
parents: 67
diff changeset
311 fprintf (m_outfile, "\n%s%*s",
kono
parents: 67
diff changeset
312 print_rtx_head, m_indent * 2, "");
kono
parents: 67
diff changeset
313 if (!m_sawclose)
kono
parents: 67
diff changeset
314 fprintf (m_outfile, " ");
kono
parents: 67
diff changeset
315 if (idx == 7 && CALL_P (in_rtx))
kono
parents: 67
diff changeset
316 {
kono
parents: 67
diff changeset
317 m_in_call_function_usage = true;
kono
parents: 67
diff changeset
318 print_rtx (XEXP (in_rtx, idx));
kono
parents: 67
diff changeset
319 m_in_call_function_usage = false;
kono
parents: 67
diff changeset
320 }
kono
parents: 67
diff changeset
321 else
kono
parents: 67
diff changeset
322 print_rtx (XEXP (in_rtx, idx));
kono
parents: 67
diff changeset
323 m_indent -= 2;
kono
parents: 67
diff changeset
324 }
kono
parents: 67
diff changeset
325
kono
parents: 67
diff changeset
326 /* Subroutine of print_rtx_operand for handling codes 'E' and 'V'. */
kono
parents: 67
diff changeset
327
kono
parents: 67
diff changeset
328 void
kono
parents: 67
diff changeset
329 rtx_writer::print_rtx_operand_codes_E_and_V (const_rtx in_rtx, int idx)
kono
parents: 67
diff changeset
330 {
kono
parents: 67
diff changeset
331 m_indent += 2;
kono
parents: 67
diff changeset
332 if (m_sawclose)
kono
parents: 67
diff changeset
333 {
kono
parents: 67
diff changeset
334 fprintf (m_outfile, "\n%s%*s",
kono
parents: 67
diff changeset
335 print_rtx_head, m_indent * 2, "");
kono
parents: 67
diff changeset
336 m_sawclose = 0;
kono
parents: 67
diff changeset
337 }
kono
parents: 67
diff changeset
338 fputs (" [", m_outfile);
kono
parents: 67
diff changeset
339 if (NULL != XVEC (in_rtx, idx))
kono
parents: 67
diff changeset
340 {
kono
parents: 67
diff changeset
341 m_indent += 2;
kono
parents: 67
diff changeset
342 if (XVECLEN (in_rtx, idx))
kono
parents: 67
diff changeset
343 m_sawclose = 1;
kono
parents: 67
diff changeset
344
kono
parents: 67
diff changeset
345 for (int j = 0; j < XVECLEN (in_rtx, idx); j++)
kono
parents: 67
diff changeset
346 print_rtx (XVECEXP (in_rtx, idx, j));
kono
parents: 67
diff changeset
347
kono
parents: 67
diff changeset
348 m_indent -= 2;
kono
parents: 67
diff changeset
349 }
kono
parents: 67
diff changeset
350 if (m_sawclose)
kono
parents: 67
diff changeset
351 fprintf (m_outfile, "\n%s%*s", print_rtx_head, m_indent * 2, "");
kono
parents: 67
diff changeset
352
kono
parents: 67
diff changeset
353 fputs ("]", m_outfile);
kono
parents: 67
diff changeset
354 m_sawclose = 1;
kono
parents: 67
diff changeset
355 m_indent -= 2;
kono
parents: 67
diff changeset
356 }
kono
parents: 67
diff changeset
357
kono
parents: 67
diff changeset
358 /* Subroutine of print_rtx_operand for handling code 'i'. */
kono
parents: 67
diff changeset
359
kono
parents: 67
diff changeset
360 void
kono
parents: 67
diff changeset
361 rtx_writer::print_rtx_operand_code_i (const_rtx in_rtx, int idx)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
362 {
111
kono
parents: 67
diff changeset
363 if (idx == 4 && INSN_P (in_rtx))
kono
parents: 67
diff changeset
364 {
kono
parents: 67
diff changeset
365 #ifndef GENERATOR_FILE
kono
parents: 67
diff changeset
366 const rtx_insn *in_insn = as_a <const rtx_insn *> (in_rtx);
kono
parents: 67
diff changeset
367
kono
parents: 67
diff changeset
368 /* Pretty-print insn locations. Ignore scoping as it is mostly
kono
parents: 67
diff changeset
369 redundant with line number information and do not print anything
kono
parents: 67
diff changeset
370 when there is no location information available. */
kono
parents: 67
diff changeset
371 if (INSN_HAS_LOCATION (in_insn))
kono
parents: 67
diff changeset
372 {
kono
parents: 67
diff changeset
373 expanded_location xloc = insn_location (in_insn);
kono
parents: 67
diff changeset
374 fprintf (m_outfile, " \"%s\":%i", xloc.file, xloc.line);
kono
parents: 67
diff changeset
375 }
kono
parents: 67
diff changeset
376 #endif
kono
parents: 67
diff changeset
377 }
kono
parents: 67
diff changeset
378 else if (idx == 6 && GET_CODE (in_rtx) == ASM_OPERANDS)
kono
parents: 67
diff changeset
379 {
kono
parents: 67
diff changeset
380 #ifndef GENERATOR_FILE
kono
parents: 67
diff changeset
381 if (ASM_OPERANDS_SOURCE_LOCATION (in_rtx) != UNKNOWN_LOCATION)
kono
parents: 67
diff changeset
382 fprintf (m_outfile, " %s:%i",
kono
parents: 67
diff changeset
383 LOCATION_FILE (ASM_OPERANDS_SOURCE_LOCATION (in_rtx)),
kono
parents: 67
diff changeset
384 LOCATION_LINE (ASM_OPERANDS_SOURCE_LOCATION (in_rtx)));
kono
parents: 67
diff changeset
385 #endif
kono
parents: 67
diff changeset
386 }
kono
parents: 67
diff changeset
387 else if (idx == 1 && GET_CODE (in_rtx) == ASM_INPUT)
kono
parents: 67
diff changeset
388 {
kono
parents: 67
diff changeset
389 #ifndef GENERATOR_FILE
kono
parents: 67
diff changeset
390 if (ASM_INPUT_SOURCE_LOCATION (in_rtx) != UNKNOWN_LOCATION)
kono
parents: 67
diff changeset
391 fprintf (m_outfile, " %s:%i",
kono
parents: 67
diff changeset
392 LOCATION_FILE (ASM_INPUT_SOURCE_LOCATION (in_rtx)),
kono
parents: 67
diff changeset
393 LOCATION_LINE (ASM_INPUT_SOURCE_LOCATION (in_rtx)));
kono
parents: 67
diff changeset
394 #endif
kono
parents: 67
diff changeset
395 }
kono
parents: 67
diff changeset
396 else if (idx == 5 && NOTE_P (in_rtx))
kono
parents: 67
diff changeset
397 {
kono
parents: 67
diff changeset
398 /* This field is only used for NOTE_INSN_DELETED_LABEL, and
kono
parents: 67
diff changeset
399 other times often contains garbage from INSN->NOTE death. */
kono
parents: 67
diff changeset
400 if (NOTE_KIND (in_rtx) == NOTE_INSN_DELETED_LABEL
kono
parents: 67
diff changeset
401 || NOTE_KIND (in_rtx) == NOTE_INSN_DELETED_DEBUG_LABEL)
kono
parents: 67
diff changeset
402 fprintf (m_outfile, " %d", XINT (in_rtx, idx));
kono
parents: 67
diff changeset
403 }
kono
parents: 67
diff changeset
404 #if !defined(GENERATOR_FILE) && NUM_UNSPECV_VALUES > 0
kono
parents: 67
diff changeset
405 else if (idx == 1
kono
parents: 67
diff changeset
406 && GET_CODE (in_rtx) == UNSPEC_VOLATILE
kono
parents: 67
diff changeset
407 && XINT (in_rtx, 1) >= 0
kono
parents: 67
diff changeset
408 && XINT (in_rtx, 1) < NUM_UNSPECV_VALUES)
kono
parents: 67
diff changeset
409 fprintf (m_outfile, " %s", unspecv_strings[XINT (in_rtx, 1)]);
kono
parents: 67
diff changeset
410 #endif
kono
parents: 67
diff changeset
411 #if !defined(GENERATOR_FILE) && NUM_UNSPEC_VALUES > 0
kono
parents: 67
diff changeset
412 else if (idx == 1
kono
parents: 67
diff changeset
413 && (GET_CODE (in_rtx) == UNSPEC
kono
parents: 67
diff changeset
414 || GET_CODE (in_rtx) == UNSPEC_VOLATILE)
kono
parents: 67
diff changeset
415 && XINT (in_rtx, 1) >= 0
kono
parents: 67
diff changeset
416 && XINT (in_rtx, 1) < NUM_UNSPEC_VALUES)
kono
parents: 67
diff changeset
417 fprintf (m_outfile, " %s", unspec_strings[XINT (in_rtx, 1)]);
kono
parents: 67
diff changeset
418 #endif
kono
parents: 67
diff changeset
419 else
kono
parents: 67
diff changeset
420 {
kono
parents: 67
diff changeset
421 int value = XINT (in_rtx, idx);
kono
parents: 67
diff changeset
422 const char *name;
kono
parents: 67
diff changeset
423 int is_insn = INSN_P (in_rtx);
kono
parents: 67
diff changeset
424
kono
parents: 67
diff changeset
425 /* Don't print INSN_CODEs in compact mode. */
kono
parents: 67
diff changeset
426 if (m_compact && is_insn && &INSN_CODE (in_rtx) == &XINT (in_rtx, idx))
kono
parents: 67
diff changeset
427 {
kono
parents: 67
diff changeset
428 m_sawclose = 0;
kono
parents: 67
diff changeset
429 return;
kono
parents: 67
diff changeset
430 }
kono
parents: 67
diff changeset
431
kono
parents: 67
diff changeset
432 if (flag_dump_unnumbered
kono
parents: 67
diff changeset
433 && (is_insn || NOTE_P (in_rtx)))
kono
parents: 67
diff changeset
434 fputc ('#', m_outfile);
kono
parents: 67
diff changeset
435 else
kono
parents: 67
diff changeset
436 fprintf (m_outfile, " %d", value);
kono
parents: 67
diff changeset
437
kono
parents: 67
diff changeset
438 if (is_insn && &INSN_CODE (in_rtx) == &XINT (in_rtx, idx)
kono
parents: 67
diff changeset
439 && XINT (in_rtx, idx) >= 0
kono
parents: 67
diff changeset
440 && (name = get_insn_name (XINT (in_rtx, idx))) != NULL)
kono
parents: 67
diff changeset
441 fprintf (m_outfile, " {%s}", name);
kono
parents: 67
diff changeset
442 m_sawclose = 0;
kono
parents: 67
diff changeset
443 }
kono
parents: 67
diff changeset
444 }
kono
parents: 67
diff changeset
445
kono
parents: 67
diff changeset
446 /* Subroutine of print_rtx_operand for handling code 'r'. */
kono
parents: 67
diff changeset
447
kono
parents: 67
diff changeset
448 void
kono
parents: 67
diff changeset
449 rtx_writer::print_rtx_operand_code_r (const_rtx in_rtx)
kono
parents: 67
diff changeset
450 {
kono
parents: 67
diff changeset
451 int is_insn = INSN_P (in_rtx);
kono
parents: 67
diff changeset
452 unsigned int regno = REGNO (in_rtx);
kono
parents: 67
diff changeset
453
kono
parents: 67
diff changeset
454 #ifndef GENERATOR_FILE
kono
parents: 67
diff changeset
455 /* For hard registers and virtuals, always print the
kono
parents: 67
diff changeset
456 regno, except in compact mode. */
kono
parents: 67
diff changeset
457 if (regno <= LAST_VIRTUAL_REGISTER && !m_compact)
kono
parents: 67
diff changeset
458 fprintf (m_outfile, " %d", regno);
kono
parents: 67
diff changeset
459 if (regno < FIRST_PSEUDO_REGISTER)
kono
parents: 67
diff changeset
460 fprintf (m_outfile, " %s", reg_names[regno]);
kono
parents: 67
diff changeset
461 else if (regno <= LAST_VIRTUAL_REGISTER)
kono
parents: 67
diff changeset
462 {
kono
parents: 67
diff changeset
463 if (regno == VIRTUAL_INCOMING_ARGS_REGNUM)
kono
parents: 67
diff changeset
464 fprintf (m_outfile, " virtual-incoming-args");
kono
parents: 67
diff changeset
465 else if (regno == VIRTUAL_STACK_VARS_REGNUM)
kono
parents: 67
diff changeset
466 fprintf (m_outfile, " virtual-stack-vars");
kono
parents: 67
diff changeset
467 else if (regno == VIRTUAL_STACK_DYNAMIC_REGNUM)
kono
parents: 67
diff changeset
468 fprintf (m_outfile, " virtual-stack-dynamic");
kono
parents: 67
diff changeset
469 else if (regno == VIRTUAL_OUTGOING_ARGS_REGNUM)
kono
parents: 67
diff changeset
470 fprintf (m_outfile, " virtual-outgoing-args");
kono
parents: 67
diff changeset
471 else if (regno == VIRTUAL_CFA_REGNUM)
kono
parents: 67
diff changeset
472 fprintf (m_outfile, " virtual-cfa");
kono
parents: 67
diff changeset
473 else if (regno == VIRTUAL_PREFERRED_STACK_BOUNDARY_REGNUM)
kono
parents: 67
diff changeset
474 fprintf (m_outfile, " virtual-preferred-stack-boundary");
kono
parents: 67
diff changeset
475 else
kono
parents: 67
diff changeset
476 fprintf (m_outfile, " virtual-reg-%d", regno-FIRST_VIRTUAL_REGISTER);
kono
parents: 67
diff changeset
477 }
kono
parents: 67
diff changeset
478 else
kono
parents: 67
diff changeset
479 #endif
kono
parents: 67
diff changeset
480 if (flag_dump_unnumbered && is_insn)
kono
parents: 67
diff changeset
481 fputc ('#', m_outfile);
kono
parents: 67
diff changeset
482 else if (m_compact)
kono
parents: 67
diff changeset
483 {
kono
parents: 67
diff changeset
484 /* In compact mode, print pseudos with '< and '>' wrapping the regno,
kono
parents: 67
diff changeset
485 offseting it by (LAST_VIRTUAL_REGISTER + 1), so that the
kono
parents: 67
diff changeset
486 first non-virtual pseudo is dumped as "<0>". */
kono
parents: 67
diff changeset
487 gcc_assert (regno > LAST_VIRTUAL_REGISTER);
kono
parents: 67
diff changeset
488 fprintf (m_outfile, " <%d>", regno - (LAST_VIRTUAL_REGISTER + 1));
kono
parents: 67
diff changeset
489 }
kono
parents: 67
diff changeset
490 else
kono
parents: 67
diff changeset
491 fprintf (m_outfile, " %d", regno);
kono
parents: 67
diff changeset
492
kono
parents: 67
diff changeset
493 #ifndef GENERATOR_FILE
kono
parents: 67
diff changeset
494 if (REG_ATTRS (in_rtx))
kono
parents: 67
diff changeset
495 {
kono
parents: 67
diff changeset
496 fputs (" [", m_outfile);
kono
parents: 67
diff changeset
497 if (regno != ORIGINAL_REGNO (in_rtx))
kono
parents: 67
diff changeset
498 fprintf (m_outfile, "orig:%i", ORIGINAL_REGNO (in_rtx));
kono
parents: 67
diff changeset
499 if (REG_EXPR (in_rtx))
kono
parents: 67
diff changeset
500 print_mem_expr (m_outfile, REG_EXPR (in_rtx));
kono
parents: 67
diff changeset
501
kono
parents: 67
diff changeset
502 if (REG_OFFSET (in_rtx))
kono
parents: 67
diff changeset
503 fprintf (m_outfile, "+" HOST_WIDE_INT_PRINT_DEC,
kono
parents: 67
diff changeset
504 REG_OFFSET (in_rtx));
kono
parents: 67
diff changeset
505 fputs (" ]", m_outfile);
kono
parents: 67
diff changeset
506 }
kono
parents: 67
diff changeset
507 if (regno != ORIGINAL_REGNO (in_rtx))
kono
parents: 67
diff changeset
508 fprintf (m_outfile, " [%d]", ORIGINAL_REGNO (in_rtx));
kono
parents: 67
diff changeset
509 #endif
kono
parents: 67
diff changeset
510 }
kono
parents: 67
diff changeset
511
kono
parents: 67
diff changeset
512 /* Subroutine of print_rtx_operand for handling code 'u'. */
kono
parents: 67
diff changeset
513
kono
parents: 67
diff changeset
514 void
kono
parents: 67
diff changeset
515 rtx_writer::print_rtx_operand_code_u (const_rtx in_rtx, int idx)
kono
parents: 67
diff changeset
516 {
kono
parents: 67
diff changeset
517 /* Don't print insn UIDs for PREV/NEXT_INSN in compact mode. */
kono
parents: 67
diff changeset
518 if (m_compact && INSN_CHAIN_CODE_P (GET_CODE (in_rtx)) && idx < 2)
kono
parents: 67
diff changeset
519 return;
kono
parents: 67
diff changeset
520
kono
parents: 67
diff changeset
521 if (XEXP (in_rtx, idx) != NULL)
kono
parents: 67
diff changeset
522 {
kono
parents: 67
diff changeset
523 rtx sub = XEXP (in_rtx, idx);
kono
parents: 67
diff changeset
524 enum rtx_code subc = GET_CODE (sub);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
525
111
kono
parents: 67
diff changeset
526 if (GET_CODE (in_rtx) == LABEL_REF)
kono
parents: 67
diff changeset
527 {
kono
parents: 67
diff changeset
528 if (subc == NOTE
kono
parents: 67
diff changeset
529 && NOTE_KIND (sub) == NOTE_INSN_DELETED_LABEL)
kono
parents: 67
diff changeset
530 {
kono
parents: 67
diff changeset
531 if (flag_dump_unnumbered)
kono
parents: 67
diff changeset
532 fprintf (m_outfile, " [# deleted]");
kono
parents: 67
diff changeset
533 else
kono
parents: 67
diff changeset
534 fprintf (m_outfile, " [%d deleted]", INSN_UID (sub));
kono
parents: 67
diff changeset
535 m_sawclose = 0;
kono
parents: 67
diff changeset
536 return;
kono
parents: 67
diff changeset
537 }
kono
parents: 67
diff changeset
538
kono
parents: 67
diff changeset
539 if (subc != CODE_LABEL)
kono
parents: 67
diff changeset
540 {
kono
parents: 67
diff changeset
541 print_rtx_operand_code_e (in_rtx, idx);
kono
parents: 67
diff changeset
542 return;
kono
parents: 67
diff changeset
543 }
kono
parents: 67
diff changeset
544 }
kono
parents: 67
diff changeset
545
kono
parents: 67
diff changeset
546 if (flag_dump_unnumbered
kono
parents: 67
diff changeset
547 || (flag_dump_unnumbered_links && idx <= 1
kono
parents: 67
diff changeset
548 && (INSN_P (in_rtx) || NOTE_P (in_rtx)
kono
parents: 67
diff changeset
549 || LABEL_P (in_rtx) || BARRIER_P (in_rtx))))
kono
parents: 67
diff changeset
550 fputs (" #", m_outfile);
kono
parents: 67
diff changeset
551 else
kono
parents: 67
diff changeset
552 fprintf (m_outfile, " %d", INSN_UID (sub));
kono
parents: 67
diff changeset
553 }
kono
parents: 67
diff changeset
554 else
kono
parents: 67
diff changeset
555 fputs (" 0", m_outfile);
kono
parents: 67
diff changeset
556 m_sawclose = 0;
kono
parents: 67
diff changeset
557 }
kono
parents: 67
diff changeset
558
kono
parents: 67
diff changeset
559 /* Subroutine of print_rtx. Print operand IDX of IN_RTX. */
kono
parents: 67
diff changeset
560
kono
parents: 67
diff changeset
561 void
kono
parents: 67
diff changeset
562 rtx_writer::print_rtx_operand (const_rtx in_rtx, int idx)
kono
parents: 67
diff changeset
563 {
kono
parents: 67
diff changeset
564 const char *format_ptr = GET_RTX_FORMAT (GET_CODE (in_rtx));
kono
parents: 67
diff changeset
565
kono
parents: 67
diff changeset
566 switch (format_ptr[idx])
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
567 {
111
kono
parents: 67
diff changeset
568 const char *str;
kono
parents: 67
diff changeset
569
kono
parents: 67
diff changeset
570 case 'T':
kono
parents: 67
diff changeset
571 str = XTMPL (in_rtx, idx);
kono
parents: 67
diff changeset
572 goto string;
kono
parents: 67
diff changeset
573
kono
parents: 67
diff changeset
574 case 'S':
kono
parents: 67
diff changeset
575 case 's':
kono
parents: 67
diff changeset
576 str = XSTR (in_rtx, idx);
kono
parents: 67
diff changeset
577 string:
kono
parents: 67
diff changeset
578
kono
parents: 67
diff changeset
579 if (str == 0)
kono
parents: 67
diff changeset
580 fputs (" (nil)", m_outfile);
kono
parents: 67
diff changeset
581 else
kono
parents: 67
diff changeset
582 fprintf (m_outfile, " (\"%s\")", str);
kono
parents: 67
diff changeset
583 m_sawclose = 1;
kono
parents: 67
diff changeset
584 break;
kono
parents: 67
diff changeset
585
kono
parents: 67
diff changeset
586 case '0':
kono
parents: 67
diff changeset
587 print_rtx_operand_code_0 (in_rtx, idx);
kono
parents: 67
diff changeset
588 break;
kono
parents: 67
diff changeset
589
kono
parents: 67
diff changeset
590 case 'e':
kono
parents: 67
diff changeset
591 print_rtx_operand_code_e (in_rtx, idx);
kono
parents: 67
diff changeset
592 break;
kono
parents: 67
diff changeset
593
kono
parents: 67
diff changeset
594 case 'E':
kono
parents: 67
diff changeset
595 case 'V':
kono
parents: 67
diff changeset
596 print_rtx_operand_codes_E_and_V (in_rtx, idx);
kono
parents: 67
diff changeset
597 break;
kono
parents: 67
diff changeset
598
kono
parents: 67
diff changeset
599 case 'w':
kono
parents: 67
diff changeset
600 if (! m_simple)
kono
parents: 67
diff changeset
601 fprintf (m_outfile, " ");
kono
parents: 67
diff changeset
602 fprintf (m_outfile, HOST_WIDE_INT_PRINT_DEC, XWINT (in_rtx, idx));
kono
parents: 67
diff changeset
603 if (! m_simple && !m_compact)
kono
parents: 67
diff changeset
604 fprintf (m_outfile, " [" HOST_WIDE_INT_PRINT_HEX "]",
kono
parents: 67
diff changeset
605 (unsigned HOST_WIDE_INT) XWINT (in_rtx, idx));
kono
parents: 67
diff changeset
606 break;
kono
parents: 67
diff changeset
607
kono
parents: 67
diff changeset
608 case 'i':
kono
parents: 67
diff changeset
609 print_rtx_operand_code_i (in_rtx, idx);
kono
parents: 67
diff changeset
610 break;
kono
parents: 67
diff changeset
611
kono
parents: 67
diff changeset
612 case 'r':
kono
parents: 67
diff changeset
613 print_rtx_operand_code_r (in_rtx);
kono
parents: 67
diff changeset
614 break;
kono
parents: 67
diff changeset
615
kono
parents: 67
diff changeset
616 /* Print NOTE_INSN names rather than integer codes. */
kono
parents: 67
diff changeset
617
kono
parents: 67
diff changeset
618 case 'n':
kono
parents: 67
diff changeset
619 fprintf (m_outfile, " %s", GET_NOTE_INSN_NAME (XINT (in_rtx, idx)));
kono
parents: 67
diff changeset
620 m_sawclose = 0;
kono
parents: 67
diff changeset
621 break;
kono
parents: 67
diff changeset
622
kono
parents: 67
diff changeset
623 case 'u':
kono
parents: 67
diff changeset
624 print_rtx_operand_code_u (in_rtx, idx);
kono
parents: 67
diff changeset
625 break;
kono
parents: 67
diff changeset
626
kono
parents: 67
diff changeset
627 case 't':
kono
parents: 67
diff changeset
628 #ifndef GENERATOR_FILE
kono
parents: 67
diff changeset
629 if (idx == 0 && GET_CODE (in_rtx) == DEBUG_IMPLICIT_PTR)
kono
parents: 67
diff changeset
630 print_mem_expr (m_outfile, DEBUG_IMPLICIT_PTR_DECL (in_rtx));
kono
parents: 67
diff changeset
631 else if (idx == 0 && GET_CODE (in_rtx) == DEBUG_PARAMETER_REF)
kono
parents: 67
diff changeset
632 print_mem_expr (m_outfile, DEBUG_PARAMETER_REF_DECL (in_rtx));
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
633 else
111
kono
parents: 67
diff changeset
634 dump_addr (m_outfile, " ", XTREE (in_rtx, idx));
kono
parents: 67
diff changeset
635 #endif
kono
parents: 67
diff changeset
636 break;
kono
parents: 67
diff changeset
637
kono
parents: 67
diff changeset
638 case '*':
kono
parents: 67
diff changeset
639 fputs (" Unknown", m_outfile);
kono
parents: 67
diff changeset
640 m_sawclose = 0;
kono
parents: 67
diff changeset
641 break;
kono
parents: 67
diff changeset
642
kono
parents: 67
diff changeset
643 case 'B':
kono
parents: 67
diff changeset
644 /* Don't print basic block ids in compact mode. */
kono
parents: 67
diff changeset
645 if (m_compact)
kono
parents: 67
diff changeset
646 break;
kono
parents: 67
diff changeset
647 #ifndef GENERATOR_FILE
kono
parents: 67
diff changeset
648 if (XBBDEF (in_rtx, idx))
kono
parents: 67
diff changeset
649 fprintf (m_outfile, " %i", XBBDEF (in_rtx, idx)->index);
kono
parents: 67
diff changeset
650 #endif
kono
parents: 67
diff changeset
651 break;
kono
parents: 67
diff changeset
652
kono
parents: 67
diff changeset
653 default:
kono
parents: 67
diff changeset
654 gcc_unreachable ();
kono
parents: 67
diff changeset
655 }
kono
parents: 67
diff changeset
656 }
kono
parents: 67
diff changeset
657
kono
parents: 67
diff changeset
658 /* Subroutine of rtx_writer::print_rtx.
kono
parents: 67
diff changeset
659 In compact mode, determine if operand IDX of IN_RTX is interesting
kono
parents: 67
diff changeset
660 to dump, or (if in a trailing position) it can be omitted. */
kono
parents: 67
diff changeset
661
kono
parents: 67
diff changeset
662 bool
kono
parents: 67
diff changeset
663 rtx_writer::operand_has_default_value_p (const_rtx in_rtx, int idx)
kono
parents: 67
diff changeset
664 {
kono
parents: 67
diff changeset
665 const char *format_ptr = GET_RTX_FORMAT (GET_CODE (in_rtx));
kono
parents: 67
diff changeset
666
kono
parents: 67
diff changeset
667 switch (format_ptr[idx])
kono
parents: 67
diff changeset
668 {
kono
parents: 67
diff changeset
669 case 'e':
kono
parents: 67
diff changeset
670 case 'u':
kono
parents: 67
diff changeset
671 return XEXP (in_rtx, idx) == NULL_RTX;
kono
parents: 67
diff changeset
672
kono
parents: 67
diff changeset
673 case 's':
kono
parents: 67
diff changeset
674 return XSTR (in_rtx, idx) == NULL;
kono
parents: 67
diff changeset
675
kono
parents: 67
diff changeset
676 case '0':
kono
parents: 67
diff changeset
677 switch (GET_CODE (in_rtx))
kono
parents: 67
diff changeset
678 {
kono
parents: 67
diff changeset
679 case JUMP_INSN:
kono
parents: 67
diff changeset
680 /* JUMP_LABELs are always omitted in compact mode, so treat
kono
parents: 67
diff changeset
681 any value here as omittable, so that earlier operands can
kono
parents: 67
diff changeset
682 potentially be omitted also. */
kono
parents: 67
diff changeset
683 return m_compact;
kono
parents: 67
diff changeset
684
kono
parents: 67
diff changeset
685 default:
kono
parents: 67
diff changeset
686 return false;
kono
parents: 67
diff changeset
687
kono
parents: 67
diff changeset
688 }
kono
parents: 67
diff changeset
689
kono
parents: 67
diff changeset
690 default:
kono
parents: 67
diff changeset
691 return false;
kono
parents: 67
diff changeset
692 }
kono
parents: 67
diff changeset
693 }
kono
parents: 67
diff changeset
694
kono
parents: 67
diff changeset
695 /* Print IN_RTX onto m_outfile. This is the recursive part of printing. */
kono
parents: 67
diff changeset
696
kono
parents: 67
diff changeset
697 void
kono
parents: 67
diff changeset
698 rtx_writer::print_rtx (const_rtx in_rtx)
kono
parents: 67
diff changeset
699 {
kono
parents: 67
diff changeset
700 int idx = 0;
kono
parents: 67
diff changeset
701
kono
parents: 67
diff changeset
702 if (m_sawclose)
kono
parents: 67
diff changeset
703 {
kono
parents: 67
diff changeset
704 if (m_simple)
kono
parents: 67
diff changeset
705 fputc (' ', m_outfile);
kono
parents: 67
diff changeset
706 else
kono
parents: 67
diff changeset
707 fprintf (m_outfile, "\n%s%*s", print_rtx_head, m_indent * 2, "");
kono
parents: 67
diff changeset
708 m_sawclose = 0;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
709 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
710
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
711 if (in_rtx == 0)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
712 {
111
kono
parents: 67
diff changeset
713 fputs ("(nil)", m_outfile);
kono
parents: 67
diff changeset
714 m_sawclose = 1;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
715 return;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
716 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
717 else if (GET_CODE (in_rtx) > NUM_RTX_CODE)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
718 {
111
kono
parents: 67
diff changeset
719 fprintf (m_outfile, "(??? bad code %d\n%s%*s)", GET_CODE (in_rtx),
kono
parents: 67
diff changeset
720 print_rtx_head, m_indent * 2, "");
kono
parents: 67
diff changeset
721 m_sawclose = 1;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
722 return;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
723 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
724
111
kono
parents: 67
diff changeset
725 fputc ('(', m_outfile);
kono
parents: 67
diff changeset
726
kono
parents: 67
diff changeset
727 /* Print name of expression code. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
728
111
kono
parents: 67
diff changeset
729 /* Handle reuse. */
kono
parents: 67
diff changeset
730 #ifndef GENERATOR_FILE
kono
parents: 67
diff changeset
731 if (m_rtx_reuse_manager)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
732 {
111
kono
parents: 67
diff changeset
733 int reuse_id;
kono
parents: 67
diff changeset
734 if (m_rtx_reuse_manager->has_reuse_id (in_rtx, &reuse_id))
kono
parents: 67
diff changeset
735 {
kono
parents: 67
diff changeset
736 /* Have we already seen the defn of this rtx? */
kono
parents: 67
diff changeset
737 if (m_rtx_reuse_manager->seen_def_p (reuse_id))
kono
parents: 67
diff changeset
738 {
kono
parents: 67
diff changeset
739 fprintf (m_outfile, "reuse_rtx %i)", reuse_id);
kono
parents: 67
diff changeset
740 m_sawclose = 1;
kono
parents: 67
diff changeset
741 return;
kono
parents: 67
diff changeset
742 }
kono
parents: 67
diff changeset
743 else
kono
parents: 67
diff changeset
744 {
kono
parents: 67
diff changeset
745 /* First time we've seen this reused-rtx. */
kono
parents: 67
diff changeset
746 fprintf (m_outfile, "%i|", reuse_id);
kono
parents: 67
diff changeset
747 m_rtx_reuse_manager->set_seen_def (reuse_id);
kono
parents: 67
diff changeset
748 }
kono
parents: 67
diff changeset
749 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
750 }
111
kono
parents: 67
diff changeset
751 #endif /* #ifndef GENERATOR_FILE */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
752
111
kono
parents: 67
diff changeset
753 /* In compact mode, prefix the code of insns with "c",
kono
parents: 67
diff changeset
754 giving "cinsn", "cnote" etc. */
kono
parents: 67
diff changeset
755 if (m_compact && is_a <const rtx_insn *, const struct rtx_def> (in_rtx))
kono
parents: 67
diff changeset
756 {
kono
parents: 67
diff changeset
757 /* "ccode_label" is slightly awkward, so special-case it as
kono
parents: 67
diff changeset
758 just "clabel". */
kono
parents: 67
diff changeset
759 rtx_code code = GET_CODE (in_rtx);
kono
parents: 67
diff changeset
760 if (code == CODE_LABEL)
kono
parents: 67
diff changeset
761 fprintf (m_outfile, "clabel");
kono
parents: 67
diff changeset
762 else
kono
parents: 67
diff changeset
763 fprintf (m_outfile, "c%s", GET_RTX_NAME (code));
kono
parents: 67
diff changeset
764 }
kono
parents: 67
diff changeset
765 else if (m_simple && CONST_INT_P (in_rtx))
kono
parents: 67
diff changeset
766 ; /* no code. */
kono
parents: 67
diff changeset
767 else
kono
parents: 67
diff changeset
768 fprintf (m_outfile, "%s", GET_RTX_NAME (GET_CODE (in_rtx)));
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
769
111
kono
parents: 67
diff changeset
770 if (! m_simple)
kono
parents: 67
diff changeset
771 {
kono
parents: 67
diff changeset
772 if (RTX_FLAG (in_rtx, in_struct))
kono
parents: 67
diff changeset
773 fputs ("/s", m_outfile);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
774
111
kono
parents: 67
diff changeset
775 if (RTX_FLAG (in_rtx, volatil))
kono
parents: 67
diff changeset
776 fputs ("/v", m_outfile);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
777
111
kono
parents: 67
diff changeset
778 if (RTX_FLAG (in_rtx, unchanging))
kono
parents: 67
diff changeset
779 fputs ("/u", m_outfile);
kono
parents: 67
diff changeset
780
kono
parents: 67
diff changeset
781 if (RTX_FLAG (in_rtx, frame_related))
kono
parents: 67
diff changeset
782 fputs ("/f", m_outfile);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
783
111
kono
parents: 67
diff changeset
784 if (RTX_FLAG (in_rtx, jump))
kono
parents: 67
diff changeset
785 fputs ("/j", m_outfile);
kono
parents: 67
diff changeset
786
kono
parents: 67
diff changeset
787 if (RTX_FLAG (in_rtx, call))
kono
parents: 67
diff changeset
788 fputs ("/c", m_outfile);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
789
111
kono
parents: 67
diff changeset
790 if (RTX_FLAG (in_rtx, return_val))
kono
parents: 67
diff changeset
791 fputs ("/i", m_outfile);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
792
111
kono
parents: 67
diff changeset
793 /* Print REG_NOTE names for EXPR_LIST and INSN_LIST. */
kono
parents: 67
diff changeset
794 if ((GET_CODE (in_rtx) == EXPR_LIST
kono
parents: 67
diff changeset
795 || GET_CODE (in_rtx) == INSN_LIST
kono
parents: 67
diff changeset
796 || GET_CODE (in_rtx) == INT_LIST)
kono
parents: 67
diff changeset
797 && (int)GET_MODE (in_rtx) < REG_NOTE_MAX
kono
parents: 67
diff changeset
798 && !m_in_call_function_usage)
kono
parents: 67
diff changeset
799 fprintf (m_outfile, ":%s",
kono
parents: 67
diff changeset
800 GET_REG_NOTE_NAME (GET_MODE (in_rtx)));
kono
parents: 67
diff changeset
801
kono
parents: 67
diff changeset
802 /* For other rtl, print the mode if it's not VOID. */
kono
parents: 67
diff changeset
803 else if (GET_MODE (in_rtx) != VOIDmode)
kono
parents: 67
diff changeset
804 fprintf (m_outfile, ":%s", GET_MODE_NAME (GET_MODE (in_rtx)));
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
805
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
806 #ifndef GENERATOR_FILE
111
kono
parents: 67
diff changeset
807 if (GET_CODE (in_rtx) == VAR_LOCATION)
kono
parents: 67
diff changeset
808 {
kono
parents: 67
diff changeset
809 if (TREE_CODE (PAT_VAR_LOCATION_DECL (in_rtx)) == STRING_CST)
kono
parents: 67
diff changeset
810 fputs (" <debug string placeholder>", m_outfile);
kono
parents: 67
diff changeset
811 else
kono
parents: 67
diff changeset
812 print_mem_expr (m_outfile, PAT_VAR_LOCATION_DECL (in_rtx));
kono
parents: 67
diff changeset
813 fputc (' ', m_outfile);
kono
parents: 67
diff changeset
814 print_rtx (PAT_VAR_LOCATION_LOC (in_rtx));
kono
parents: 67
diff changeset
815 if (PAT_VAR_LOCATION_STATUS (in_rtx)
kono
parents: 67
diff changeset
816 == VAR_INIT_STATUS_UNINITIALIZED)
kono
parents: 67
diff changeset
817 fprintf (m_outfile, " [uninit]");
kono
parents: 67
diff changeset
818 m_sawclose = 1;
kono
parents: 67
diff changeset
819 idx = GET_RTX_LENGTH (VAR_LOCATION);
kono
parents: 67
diff changeset
820 }
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
821 #endif
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
822 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
823
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
824 #ifndef GENERATOR_FILE
111
kono
parents: 67
diff changeset
825 if (CONST_DOUBLE_AS_FLOAT_P (in_rtx))
kono
parents: 67
diff changeset
826 idx = 5;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
827 #endif
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
828
111
kono
parents: 67
diff changeset
829 /* For insns, print the INSN_UID. */
kono
parents: 67
diff changeset
830 if (INSN_CHAIN_CODE_P (GET_CODE (in_rtx)))
kono
parents: 67
diff changeset
831 {
kono
parents: 67
diff changeset
832 if (flag_dump_unnumbered)
kono
parents: 67
diff changeset
833 fprintf (m_outfile, " #");
kono
parents: 67
diff changeset
834 else
kono
parents: 67
diff changeset
835 fprintf (m_outfile, " %d", INSN_UID (in_rtx));
kono
parents: 67
diff changeset
836 }
kono
parents: 67
diff changeset
837
kono
parents: 67
diff changeset
838 /* Determine which is the final operand to print.
kono
parents: 67
diff changeset
839 In compact mode, skip trailing operands that have the default values
kono
parents: 67
diff changeset
840 e.g. trailing "(nil)" values. */
kono
parents: 67
diff changeset
841 int limit = GET_RTX_LENGTH (GET_CODE (in_rtx));
kono
parents: 67
diff changeset
842 if (m_compact)
kono
parents: 67
diff changeset
843 while (limit > idx && operand_has_default_value_p (in_rtx, limit - 1))
kono
parents: 67
diff changeset
844 limit--;
kono
parents: 67
diff changeset
845
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
846 /* Get the format string and skip the first elements if we have handled
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
847 them already. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
848
111
kono
parents: 67
diff changeset
849 for (; idx < limit; idx++)
kono
parents: 67
diff changeset
850 print_rtx_operand (in_rtx, idx);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
851
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
852 switch (GET_CODE (in_rtx))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
853 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
854 #ifndef GENERATOR_FILE
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
855 case MEM:
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
856 if (__builtin_expect (final_insns_dump_p, false))
111
kono
parents: 67
diff changeset
857 fprintf (m_outfile, " [");
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
858 else
111
kono
parents: 67
diff changeset
859 fprintf (m_outfile, " [" HOST_WIDE_INT_PRINT_DEC,
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
860 (HOST_WIDE_INT) MEM_ALIAS_SET (in_rtx));
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
861
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
862 if (MEM_EXPR (in_rtx))
111
kono
parents: 67
diff changeset
863 print_mem_expr (m_outfile, MEM_EXPR (in_rtx));
kono
parents: 67
diff changeset
864 else
kono
parents: 67
diff changeset
865 fputc (' ', m_outfile);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
866
111
kono
parents: 67
diff changeset
867 if (MEM_OFFSET_KNOWN_P (in_rtx))
kono
parents: 67
diff changeset
868 fprintf (m_outfile, "+" HOST_WIDE_INT_PRINT_DEC, MEM_OFFSET (in_rtx));
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
869
111
kono
parents: 67
diff changeset
870 if (MEM_SIZE_KNOWN_P (in_rtx))
kono
parents: 67
diff changeset
871 fprintf (m_outfile, " S" HOST_WIDE_INT_PRINT_DEC, MEM_SIZE (in_rtx));
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
872
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
873 if (MEM_ALIGN (in_rtx) != 1)
111
kono
parents: 67
diff changeset
874 fprintf (m_outfile, " A%u", MEM_ALIGN (in_rtx));
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
875
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
876 if (!ADDR_SPACE_GENERIC_P (MEM_ADDR_SPACE (in_rtx)))
111
kono
parents: 67
diff changeset
877 fprintf (m_outfile, " AS%u", MEM_ADDR_SPACE (in_rtx));
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
878
111
kono
parents: 67
diff changeset
879 fputc (']', m_outfile);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
880 break;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
881
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
882 case CONST_DOUBLE:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
883 if (FLOAT_MODE_P (GET_MODE (in_rtx)))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
884 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
885 char s[60];
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
886
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
887 real_to_decimal (s, CONST_DOUBLE_REAL_VALUE (in_rtx),
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
888 sizeof (s), 0, 1);
111
kono
parents: 67
diff changeset
889 fprintf (m_outfile, " %s", s);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
890
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
891 real_to_hexadecimal (s, CONST_DOUBLE_REAL_VALUE (in_rtx),
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
892 sizeof (s), 0, 1);
111
kono
parents: 67
diff changeset
893 fprintf (m_outfile, " [%s]", s);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
894 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
895 break;
111
kono
parents: 67
diff changeset
896
kono
parents: 67
diff changeset
897 case CONST_WIDE_INT:
kono
parents: 67
diff changeset
898 fprintf (m_outfile, " ");
kono
parents: 67
diff changeset
899 cwi_output_hex (m_outfile, in_rtx);
kono
parents: 67
diff changeset
900 break;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
901 #endif
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
902
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
903 case CODE_LABEL:
111
kono
parents: 67
diff changeset
904 if (!m_compact)
kono
parents: 67
diff changeset
905 fprintf (m_outfile, " [%d uses]", LABEL_NUSES (in_rtx));
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
906 switch (LABEL_KIND (in_rtx))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
907 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
908 case LABEL_NORMAL: break;
111
kono
parents: 67
diff changeset
909 case LABEL_STATIC_ENTRY: fputs (" [entry]", m_outfile); break;
kono
parents: 67
diff changeset
910 case LABEL_GLOBAL_ENTRY: fputs (" [global entry]", m_outfile); break;
kono
parents: 67
diff changeset
911 case LABEL_WEAK_ENTRY: fputs (" [weak entry]", m_outfile); break;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
912 default: gcc_unreachable ();
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
913 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
914 break;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
915
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
916 default:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
917 break;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
918 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
919
111
kono
parents: 67
diff changeset
920 fputc (')', m_outfile);
kono
parents: 67
diff changeset
921 m_sawclose = 1;
kono
parents: 67
diff changeset
922 }
kono
parents: 67
diff changeset
923
kono
parents: 67
diff changeset
924 /* Emit a closing parenthesis and newline. */
kono
parents: 67
diff changeset
925
kono
parents: 67
diff changeset
926 void
kono
parents: 67
diff changeset
927 rtx_writer::finish_directive ()
kono
parents: 67
diff changeset
928 {
kono
parents: 67
diff changeset
929 fprintf (m_outfile, ")\n");
kono
parents: 67
diff changeset
930 m_sawclose = 0;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
931 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
932
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
933 /* Print an rtx on the current line of FILE. Initially indent IND
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
934 characters. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
935
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
936 void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
937 print_inline_rtx (FILE *outf, const_rtx x, int ind)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
938 {
111
kono
parents: 67
diff changeset
939 rtx_writer w (outf, ind, false, false, NULL);
kono
parents: 67
diff changeset
940 w.print_rtx (x);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
941 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
942
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
943 /* Call this function from the debugger to see what X looks like. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
944
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
945 DEBUG_FUNCTION void
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
946 debug_rtx (const_rtx x)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
947 {
111
kono
parents: 67
diff changeset
948 rtx_writer w (stderr, 0, false, false, NULL);
kono
parents: 67
diff changeset
949 w.print_rtx (x);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
950 fprintf (stderr, "\n");
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
951 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
952
111
kono
parents: 67
diff changeset
953 /* Dump rtx REF. */
kono
parents: 67
diff changeset
954
kono
parents: 67
diff changeset
955 DEBUG_FUNCTION void
kono
parents: 67
diff changeset
956 debug (const rtx_def &ref)
kono
parents: 67
diff changeset
957 {
kono
parents: 67
diff changeset
958 debug_rtx (&ref);
kono
parents: 67
diff changeset
959 }
kono
parents: 67
diff changeset
960
kono
parents: 67
diff changeset
961 DEBUG_FUNCTION void
kono
parents: 67
diff changeset
962 debug (const rtx_def *ptr)
kono
parents: 67
diff changeset
963 {
kono
parents: 67
diff changeset
964 if (ptr)
kono
parents: 67
diff changeset
965 debug (*ptr);
kono
parents: 67
diff changeset
966 else
kono
parents: 67
diff changeset
967 fprintf (stderr, "<nil>\n");
kono
parents: 67
diff changeset
968 }
kono
parents: 67
diff changeset
969
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
970 /* Count of rtx's to print with debug_rtx_list.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
971 This global exists because gdb user defined commands have no arguments. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
972
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
973 DEBUG_VARIABLE int debug_rtx_count = 0; /* 0 is treated as equivalent to 1 */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
974
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
975 /* Call this function to print list from X on.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
976
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
977 N is a count of the rtx's to print. Positive values print from the specified
111
kono
parents: 67
diff changeset
978 rtx_insn on. Negative values print a window around the rtx_insn.
kono
parents: 67
diff changeset
979 EG: -5 prints 2 rtx_insn's on either side (in addition to the specified
kono
parents: 67
diff changeset
980 rtx_insn). */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
981
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
982 DEBUG_FUNCTION void
111
kono
parents: 67
diff changeset
983 debug_rtx_list (const rtx_insn *x, int n)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
984 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
985 int i,count;
111
kono
parents: 67
diff changeset
986 const rtx_insn *insn;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
987
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
988 count = n == 0 ? 1 : n < 0 ? -n : n;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
989
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
990 /* If we are printing a window, back up to the start. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
991
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
992 if (n < 0)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
993 for (i = count / 2; i > 0; i--)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
994 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
995 if (PREV_INSN (x) == 0)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
996 break;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
997 x = PREV_INSN (x);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
998 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
999
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1000 for (i = count, insn = x; i > 0 && insn != 0; i--, insn = NEXT_INSN (insn))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1001 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1002 debug_rtx (insn);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1003 fprintf (stderr, "\n");
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1004 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1005 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1006
111
kono
parents: 67
diff changeset
1007 /* Call this function to print an rtx_insn list from START to END
kono
parents: 67
diff changeset
1008 inclusive. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1009
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1010 DEBUG_FUNCTION void
111
kono
parents: 67
diff changeset
1011 debug_rtx_range (const rtx_insn *start, const rtx_insn *end)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1012 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1013 while (1)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1014 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1015 debug_rtx (start);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1016 fprintf (stderr, "\n");
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1017 if (!start || start == end)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1018 break;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1019 start = NEXT_INSN (start);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1020 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1021 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1022
111
kono
parents: 67
diff changeset
1023 /* Call this function to search an rtx_insn list to find one with insn uid UID,
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1024 and then call debug_rtx_list to print it, using DEBUG_RTX_COUNT.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1025 The found insn is returned to enable further debugging analysis. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1026
111
kono
parents: 67
diff changeset
1027 DEBUG_FUNCTION const rtx_insn *
kono
parents: 67
diff changeset
1028 debug_rtx_find (const rtx_insn *x, int uid)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1029 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1030 while (x != 0 && INSN_UID (x) != uid)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1031 x = NEXT_INSN (x);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1032 if (x != 0)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1033 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1034 debug_rtx_list (x, debug_rtx_count);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1035 return x;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1036 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1037 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1038 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1039 fprintf (stderr, "insn uid %d not found\n", uid);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1040 return 0;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1041 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1042 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1043
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1044 /* External entry point for printing a chain of insns
111
kono
parents: 67
diff changeset
1045 starting with RTX_FIRST.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1046 A blank line separates insns.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1047
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1048 If RTX_FIRST is not an insn, then it alone is printed, with no newline. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1049
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1050 void
111
kono
parents: 67
diff changeset
1051 rtx_writer::print_rtl (const_rtx rtx_first)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1052 {
111
kono
parents: 67
diff changeset
1053 const rtx_insn *tmp_rtx;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1054
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1055 if (rtx_first == 0)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1056 {
111
kono
parents: 67
diff changeset
1057 fputs (print_rtx_head, m_outfile);
kono
parents: 67
diff changeset
1058 fputs ("(nil)\n", m_outfile);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1059 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1060 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1061 switch (GET_CODE (rtx_first))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1062 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1063 case INSN:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1064 case JUMP_INSN:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1065 case CALL_INSN:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1066 case NOTE:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1067 case CODE_LABEL:
111
kono
parents: 67
diff changeset
1068 case JUMP_TABLE_DATA:
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1069 case BARRIER:
111
kono
parents: 67
diff changeset
1070 for (tmp_rtx = as_a <const rtx_insn *> (rtx_first);
kono
parents: 67
diff changeset
1071 tmp_rtx != 0;
kono
parents: 67
diff changeset
1072 tmp_rtx = NEXT_INSN (tmp_rtx))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1073 {
111
kono
parents: 67
diff changeset
1074 fputs (print_rtx_head, m_outfile);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1075 print_rtx (tmp_rtx);
111
kono
parents: 67
diff changeset
1076 fprintf (m_outfile, "\n");
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1077 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1078 break;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1079
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1080 default:
111
kono
parents: 67
diff changeset
1081 fputs (print_rtx_head, m_outfile);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1082 print_rtx (rtx_first);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1083 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1084 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1085
111
kono
parents: 67
diff changeset
1086 /* External entry point for printing a chain of insns
kono
parents: 67
diff changeset
1087 starting with RTX_FIRST onto file OUTF.
kono
parents: 67
diff changeset
1088 A blank line separates insns.
kono
parents: 67
diff changeset
1089
kono
parents: 67
diff changeset
1090 If RTX_FIRST is not an insn, then it alone is printed, with no newline. */
kono
parents: 67
diff changeset
1091
kono
parents: 67
diff changeset
1092 void
kono
parents: 67
diff changeset
1093 print_rtl (FILE *outf, const_rtx rtx_first)
kono
parents: 67
diff changeset
1094 {
kono
parents: 67
diff changeset
1095 rtx_writer w (outf, 0, false, false, NULL);
kono
parents: 67
diff changeset
1096 w.print_rtl (rtx_first);
kono
parents: 67
diff changeset
1097 }
kono
parents: 67
diff changeset
1098
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1099 /* Like print_rtx, except specify a file. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1100 /* Return nonzero if we actually printed anything. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1101
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1102 int
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1103 print_rtl_single (FILE *outf, const_rtx x)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1104 {
111
kono
parents: 67
diff changeset
1105 rtx_writer w (outf, 0, false, false, NULL);
kono
parents: 67
diff changeset
1106 return w.print_rtl_single_with_indent (x, 0);
kono
parents: 67
diff changeset
1107 }
kono
parents: 67
diff changeset
1108
kono
parents: 67
diff changeset
1109 /* Like print_rtl_single, except specify an indentation. */
kono
parents: 67
diff changeset
1110
kono
parents: 67
diff changeset
1111 int
kono
parents: 67
diff changeset
1112 rtx_writer::print_rtl_single_with_indent (const_rtx x, int ind)
kono
parents: 67
diff changeset
1113 {
kono
parents: 67
diff changeset
1114 char *s_indent = (char *) alloca ((size_t) ind + 1);
kono
parents: 67
diff changeset
1115 memset ((void *) s_indent, ' ', (size_t) ind);
kono
parents: 67
diff changeset
1116 s_indent[ind] = '\0';
kono
parents: 67
diff changeset
1117 fputs (s_indent, m_outfile);
kono
parents: 67
diff changeset
1118 fputs (print_rtx_head, m_outfile);
kono
parents: 67
diff changeset
1119
kono
parents: 67
diff changeset
1120 int old_indent = m_indent;
kono
parents: 67
diff changeset
1121 m_indent = ind;
kono
parents: 67
diff changeset
1122 m_sawclose = 0;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1123 print_rtx (x);
111
kono
parents: 67
diff changeset
1124 putc ('\n', m_outfile);
kono
parents: 67
diff changeset
1125 m_indent = old_indent;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1126 return 1;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1127 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1128
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1129
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1130 /* Like print_rtl except without all the detail; for example,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1131 if RTX is a CONST_INT then print in decimal format. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1132
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1133 void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1134 print_simple_rtl (FILE *outf, const_rtx x)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1135 {
111
kono
parents: 67
diff changeset
1136 rtx_writer w (outf, 0, true, false, NULL);
kono
parents: 67
diff changeset
1137 w.print_rtl (x);
kono
parents: 67
diff changeset
1138 }
kono
parents: 67
diff changeset
1139
kono
parents: 67
diff changeset
1140 /* Print the elements of VEC to FILE. */
kono
parents: 67
diff changeset
1141
kono
parents: 67
diff changeset
1142 void
kono
parents: 67
diff changeset
1143 print_rtx_insn_vec (FILE *file, const vec<rtx_insn *> &vec)
kono
parents: 67
diff changeset
1144 {
kono
parents: 67
diff changeset
1145 fputc('{', file);
kono
parents: 67
diff changeset
1146
kono
parents: 67
diff changeset
1147 unsigned int len = vec.length ();
kono
parents: 67
diff changeset
1148 for (unsigned int i = 0; i < len; i++)
kono
parents: 67
diff changeset
1149 {
kono
parents: 67
diff changeset
1150 print_rtl (file, vec[i]);
kono
parents: 67
diff changeset
1151 if (i < len - 1)
kono
parents: 67
diff changeset
1152 fputs (", ", file);
kono
parents: 67
diff changeset
1153 }
kono
parents: 67
diff changeset
1154
kono
parents: 67
diff changeset
1155 fputc ('}', file);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1156 }
111
kono
parents: 67
diff changeset
1157
kono
parents: 67
diff changeset
1158 #ifndef GENERATOR_FILE
kono
parents: 67
diff changeset
1159 /* The functions below try to print RTL in a form resembling assembler
kono
parents: 67
diff changeset
1160 mnemonics. Because this form is more concise than the "traditional" form
kono
parents: 67
diff changeset
1161 of RTL printing in Lisp-style, the form printed by this file is called
kono
parents: 67
diff changeset
1162 "slim". RTL dumps in slim format can be obtained by appending the "-slim"
kono
parents: 67
diff changeset
1163 option to -fdump-rtl-<pass>. Control flow graph output as a DOT file is
kono
parents: 67
diff changeset
1164 always printed in slim form.
kono
parents: 67
diff changeset
1165
kono
parents: 67
diff changeset
1166 The normal interface to the functionality provided in this pretty-printer
kono
parents: 67
diff changeset
1167 is through the dump_*_slim functions to print to a stream, or via the
kono
parents: 67
diff changeset
1168 print_*_slim functions to print into a user's pretty-printer.
kono
parents: 67
diff changeset
1169
kono
parents: 67
diff changeset
1170 It is also possible to obtain a string for a single pattern as a string
kono
parents: 67
diff changeset
1171 pointer, via str_pattern_slim, but this usage is discouraged. */
kono
parents: 67
diff changeset
1172
kono
parents: 67
diff changeset
1173 /* For insns we print patterns, and for some patterns we print insns... */
kono
parents: 67
diff changeset
1174 static void print_insn_with_notes (pretty_printer *, const rtx_insn *);
kono
parents: 67
diff changeset
1175
kono
parents: 67
diff changeset
1176 /* This recognizes rtx'en classified as expressions. These are always
kono
parents: 67
diff changeset
1177 represent some action on values or results of other expression, that
kono
parents: 67
diff changeset
1178 may be stored in objects representing values. */
kono
parents: 67
diff changeset
1179
kono
parents: 67
diff changeset
1180 static void
kono
parents: 67
diff changeset
1181 print_exp (pretty_printer *pp, const_rtx x, int verbose)
kono
parents: 67
diff changeset
1182 {
kono
parents: 67
diff changeset
1183 const char *st[4];
kono
parents: 67
diff changeset
1184 const char *fun;
kono
parents: 67
diff changeset
1185 rtx op[4];
kono
parents: 67
diff changeset
1186 int i;
kono
parents: 67
diff changeset
1187
kono
parents: 67
diff changeset
1188 fun = (char *) 0;
kono
parents: 67
diff changeset
1189 for (i = 0; i < 4; i++)
kono
parents: 67
diff changeset
1190 {
kono
parents: 67
diff changeset
1191 st[i] = (char *) 0;
kono
parents: 67
diff changeset
1192 op[i] = NULL_RTX;
kono
parents: 67
diff changeset
1193 }
kono
parents: 67
diff changeset
1194
kono
parents: 67
diff changeset
1195 switch (GET_CODE (x))
kono
parents: 67
diff changeset
1196 {
kono
parents: 67
diff changeset
1197 case PLUS:
kono
parents: 67
diff changeset
1198 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1199 if (CONST_INT_P (XEXP (x, 1))
kono
parents: 67
diff changeset
1200 && INTVAL (XEXP (x, 1)) < 0)
kono
parents: 67
diff changeset
1201 {
kono
parents: 67
diff changeset
1202 st[1] = "-";
kono
parents: 67
diff changeset
1203 op[1] = GEN_INT (-INTVAL (XEXP (x, 1)));
kono
parents: 67
diff changeset
1204 }
kono
parents: 67
diff changeset
1205 else
kono
parents: 67
diff changeset
1206 {
kono
parents: 67
diff changeset
1207 st[1] = "+";
kono
parents: 67
diff changeset
1208 op[1] = XEXP (x, 1);
kono
parents: 67
diff changeset
1209 }
kono
parents: 67
diff changeset
1210 break;
kono
parents: 67
diff changeset
1211 case LO_SUM:
kono
parents: 67
diff changeset
1212 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1213 st[1] = "+low(";
kono
parents: 67
diff changeset
1214 op[1] = XEXP (x, 1);
kono
parents: 67
diff changeset
1215 st[2] = ")";
kono
parents: 67
diff changeset
1216 break;
kono
parents: 67
diff changeset
1217 case MINUS:
kono
parents: 67
diff changeset
1218 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1219 st[1] = "-";
kono
parents: 67
diff changeset
1220 op[1] = XEXP (x, 1);
kono
parents: 67
diff changeset
1221 break;
kono
parents: 67
diff changeset
1222 case COMPARE:
kono
parents: 67
diff changeset
1223 fun = "cmp";
kono
parents: 67
diff changeset
1224 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1225 op[1] = XEXP (x, 1);
kono
parents: 67
diff changeset
1226 break;
kono
parents: 67
diff changeset
1227 case NEG:
kono
parents: 67
diff changeset
1228 st[0] = "-";
kono
parents: 67
diff changeset
1229 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1230 break;
kono
parents: 67
diff changeset
1231 case FMA:
kono
parents: 67
diff changeset
1232 st[0] = "{";
kono
parents: 67
diff changeset
1233 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1234 st[1] = "*";
kono
parents: 67
diff changeset
1235 op[1] = XEXP (x, 1);
kono
parents: 67
diff changeset
1236 st[2] = "+";
kono
parents: 67
diff changeset
1237 op[2] = XEXP (x, 2);
kono
parents: 67
diff changeset
1238 st[3] = "}";
kono
parents: 67
diff changeset
1239 break;
kono
parents: 67
diff changeset
1240 case MULT:
kono
parents: 67
diff changeset
1241 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1242 st[1] = "*";
kono
parents: 67
diff changeset
1243 op[1] = XEXP (x, 1);
kono
parents: 67
diff changeset
1244 break;
kono
parents: 67
diff changeset
1245 case DIV:
kono
parents: 67
diff changeset
1246 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1247 st[1] = "/";
kono
parents: 67
diff changeset
1248 op[1] = XEXP (x, 1);
kono
parents: 67
diff changeset
1249 break;
kono
parents: 67
diff changeset
1250 case UDIV:
kono
parents: 67
diff changeset
1251 fun = "udiv";
kono
parents: 67
diff changeset
1252 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1253 op[1] = XEXP (x, 1);
kono
parents: 67
diff changeset
1254 break;
kono
parents: 67
diff changeset
1255 case MOD:
kono
parents: 67
diff changeset
1256 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1257 st[1] = "%";
kono
parents: 67
diff changeset
1258 op[1] = XEXP (x, 1);
kono
parents: 67
diff changeset
1259 break;
kono
parents: 67
diff changeset
1260 case UMOD:
kono
parents: 67
diff changeset
1261 fun = "umod";
kono
parents: 67
diff changeset
1262 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1263 op[1] = XEXP (x, 1);
kono
parents: 67
diff changeset
1264 break;
kono
parents: 67
diff changeset
1265 case SMIN:
kono
parents: 67
diff changeset
1266 fun = "smin";
kono
parents: 67
diff changeset
1267 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1268 op[1] = XEXP (x, 1);
kono
parents: 67
diff changeset
1269 break;
kono
parents: 67
diff changeset
1270 case SMAX:
kono
parents: 67
diff changeset
1271 fun = "smax";
kono
parents: 67
diff changeset
1272 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1273 op[1] = XEXP (x, 1);
kono
parents: 67
diff changeset
1274 break;
kono
parents: 67
diff changeset
1275 case UMIN:
kono
parents: 67
diff changeset
1276 fun = "umin";
kono
parents: 67
diff changeset
1277 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1278 op[1] = XEXP (x, 1);
kono
parents: 67
diff changeset
1279 break;
kono
parents: 67
diff changeset
1280 case UMAX:
kono
parents: 67
diff changeset
1281 fun = "umax";
kono
parents: 67
diff changeset
1282 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1283 op[1] = XEXP (x, 1);
kono
parents: 67
diff changeset
1284 break;
kono
parents: 67
diff changeset
1285 case NOT:
kono
parents: 67
diff changeset
1286 st[0] = "~";
kono
parents: 67
diff changeset
1287 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1288 break;
kono
parents: 67
diff changeset
1289 case AND:
kono
parents: 67
diff changeset
1290 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1291 st[1] = "&";
kono
parents: 67
diff changeset
1292 op[1] = XEXP (x, 1);
kono
parents: 67
diff changeset
1293 break;
kono
parents: 67
diff changeset
1294 case IOR:
kono
parents: 67
diff changeset
1295 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1296 st[1] = "|";
kono
parents: 67
diff changeset
1297 op[1] = XEXP (x, 1);
kono
parents: 67
diff changeset
1298 break;
kono
parents: 67
diff changeset
1299 case XOR:
kono
parents: 67
diff changeset
1300 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1301 st[1] = "^";
kono
parents: 67
diff changeset
1302 op[1] = XEXP (x, 1);
kono
parents: 67
diff changeset
1303 break;
kono
parents: 67
diff changeset
1304 case ASHIFT:
kono
parents: 67
diff changeset
1305 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1306 st[1] = "<<";
kono
parents: 67
diff changeset
1307 op[1] = XEXP (x, 1);
kono
parents: 67
diff changeset
1308 break;
kono
parents: 67
diff changeset
1309 case LSHIFTRT:
kono
parents: 67
diff changeset
1310 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1311 st[1] = " 0>>";
kono
parents: 67
diff changeset
1312 op[1] = XEXP (x, 1);
kono
parents: 67
diff changeset
1313 break;
kono
parents: 67
diff changeset
1314 case ASHIFTRT:
kono
parents: 67
diff changeset
1315 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1316 st[1] = ">>";
kono
parents: 67
diff changeset
1317 op[1] = XEXP (x, 1);
kono
parents: 67
diff changeset
1318 break;
kono
parents: 67
diff changeset
1319 case ROTATE:
kono
parents: 67
diff changeset
1320 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1321 st[1] = "<-<";
kono
parents: 67
diff changeset
1322 op[1] = XEXP (x, 1);
kono
parents: 67
diff changeset
1323 break;
kono
parents: 67
diff changeset
1324 case ROTATERT:
kono
parents: 67
diff changeset
1325 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1326 st[1] = ">->";
kono
parents: 67
diff changeset
1327 op[1] = XEXP (x, 1);
kono
parents: 67
diff changeset
1328 break;
kono
parents: 67
diff changeset
1329 case NE:
kono
parents: 67
diff changeset
1330 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1331 st[1] = "!=";
kono
parents: 67
diff changeset
1332 op[1] = XEXP (x, 1);
kono
parents: 67
diff changeset
1333 break;
kono
parents: 67
diff changeset
1334 case EQ:
kono
parents: 67
diff changeset
1335 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1336 st[1] = "==";
kono
parents: 67
diff changeset
1337 op[1] = XEXP (x, 1);
kono
parents: 67
diff changeset
1338 break;
kono
parents: 67
diff changeset
1339 case GE:
kono
parents: 67
diff changeset
1340 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1341 st[1] = ">=";
kono
parents: 67
diff changeset
1342 op[1] = XEXP (x, 1);
kono
parents: 67
diff changeset
1343 break;
kono
parents: 67
diff changeset
1344 case GT:
kono
parents: 67
diff changeset
1345 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1346 st[1] = ">";
kono
parents: 67
diff changeset
1347 op[1] = XEXP (x, 1);
kono
parents: 67
diff changeset
1348 break;
kono
parents: 67
diff changeset
1349 case LE:
kono
parents: 67
diff changeset
1350 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1351 st[1] = "<=";
kono
parents: 67
diff changeset
1352 op[1] = XEXP (x, 1);
kono
parents: 67
diff changeset
1353 break;
kono
parents: 67
diff changeset
1354 case LT:
kono
parents: 67
diff changeset
1355 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1356 st[1] = "<";
kono
parents: 67
diff changeset
1357 op[1] = XEXP (x, 1);
kono
parents: 67
diff changeset
1358 break;
kono
parents: 67
diff changeset
1359 case SIGN_EXTRACT:
kono
parents: 67
diff changeset
1360 fun = (verbose) ? "sign_extract" : "sxt";
kono
parents: 67
diff changeset
1361 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1362 op[1] = XEXP (x, 1);
kono
parents: 67
diff changeset
1363 op[2] = XEXP (x, 2);
kono
parents: 67
diff changeset
1364 break;
kono
parents: 67
diff changeset
1365 case ZERO_EXTRACT:
kono
parents: 67
diff changeset
1366 fun = (verbose) ? "zero_extract" : "zxt";
kono
parents: 67
diff changeset
1367 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1368 op[1] = XEXP (x, 1);
kono
parents: 67
diff changeset
1369 op[2] = XEXP (x, 2);
kono
parents: 67
diff changeset
1370 break;
kono
parents: 67
diff changeset
1371 case SIGN_EXTEND:
kono
parents: 67
diff changeset
1372 fun = (verbose) ? "sign_extend" : "sxn";
kono
parents: 67
diff changeset
1373 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1374 break;
kono
parents: 67
diff changeset
1375 case ZERO_EXTEND:
kono
parents: 67
diff changeset
1376 fun = (verbose) ? "zero_extend" : "zxn";
kono
parents: 67
diff changeset
1377 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1378 break;
kono
parents: 67
diff changeset
1379 case FLOAT_EXTEND:
kono
parents: 67
diff changeset
1380 fun = (verbose) ? "float_extend" : "fxn";
kono
parents: 67
diff changeset
1381 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1382 break;
kono
parents: 67
diff changeset
1383 case TRUNCATE:
kono
parents: 67
diff changeset
1384 fun = (verbose) ? "trunc" : "trn";
kono
parents: 67
diff changeset
1385 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1386 break;
kono
parents: 67
diff changeset
1387 case FLOAT_TRUNCATE:
kono
parents: 67
diff changeset
1388 fun = (verbose) ? "float_trunc" : "ftr";
kono
parents: 67
diff changeset
1389 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1390 break;
kono
parents: 67
diff changeset
1391 case FLOAT:
kono
parents: 67
diff changeset
1392 fun = (verbose) ? "float" : "flt";
kono
parents: 67
diff changeset
1393 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1394 break;
kono
parents: 67
diff changeset
1395 case UNSIGNED_FLOAT:
kono
parents: 67
diff changeset
1396 fun = (verbose) ? "uns_float" : "ufl";
kono
parents: 67
diff changeset
1397 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1398 break;
kono
parents: 67
diff changeset
1399 case FIX:
kono
parents: 67
diff changeset
1400 fun = "fix";
kono
parents: 67
diff changeset
1401 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1402 break;
kono
parents: 67
diff changeset
1403 case UNSIGNED_FIX:
kono
parents: 67
diff changeset
1404 fun = (verbose) ? "uns_fix" : "ufx";
kono
parents: 67
diff changeset
1405 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1406 break;
kono
parents: 67
diff changeset
1407 case PRE_DEC:
kono
parents: 67
diff changeset
1408 st[0] = "--";
kono
parents: 67
diff changeset
1409 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1410 break;
kono
parents: 67
diff changeset
1411 case PRE_INC:
kono
parents: 67
diff changeset
1412 st[0] = "++";
kono
parents: 67
diff changeset
1413 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1414 break;
kono
parents: 67
diff changeset
1415 case POST_DEC:
kono
parents: 67
diff changeset
1416 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1417 st[1] = "--";
kono
parents: 67
diff changeset
1418 break;
kono
parents: 67
diff changeset
1419 case POST_INC:
kono
parents: 67
diff changeset
1420 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1421 st[1] = "++";
kono
parents: 67
diff changeset
1422 break;
kono
parents: 67
diff changeset
1423 case PRE_MODIFY:
kono
parents: 67
diff changeset
1424 st[0] = "pre ";
kono
parents: 67
diff changeset
1425 op[0] = XEXP (XEXP (x, 1), 0);
kono
parents: 67
diff changeset
1426 st[1] = "+=";
kono
parents: 67
diff changeset
1427 op[1] = XEXP (XEXP (x, 1), 1);
kono
parents: 67
diff changeset
1428 break;
kono
parents: 67
diff changeset
1429 case POST_MODIFY:
kono
parents: 67
diff changeset
1430 st[0] = "post ";
kono
parents: 67
diff changeset
1431 op[0] = XEXP (XEXP (x, 1), 0);
kono
parents: 67
diff changeset
1432 st[1] = "+=";
kono
parents: 67
diff changeset
1433 op[1] = XEXP (XEXP (x, 1), 1);
kono
parents: 67
diff changeset
1434 break;
kono
parents: 67
diff changeset
1435 case CALL:
kono
parents: 67
diff changeset
1436 st[0] = "call ";
kono
parents: 67
diff changeset
1437 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1438 if (verbose)
kono
parents: 67
diff changeset
1439 {
kono
parents: 67
diff changeset
1440 st[1] = " argc:";
kono
parents: 67
diff changeset
1441 op[1] = XEXP (x, 1);
kono
parents: 67
diff changeset
1442 }
kono
parents: 67
diff changeset
1443 break;
kono
parents: 67
diff changeset
1444 case IF_THEN_ELSE:
kono
parents: 67
diff changeset
1445 st[0] = "{(";
kono
parents: 67
diff changeset
1446 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1447 st[1] = ")?";
kono
parents: 67
diff changeset
1448 op[1] = XEXP (x, 1);
kono
parents: 67
diff changeset
1449 st[2] = ":";
kono
parents: 67
diff changeset
1450 op[2] = XEXP (x, 2);
kono
parents: 67
diff changeset
1451 st[3] = "}";
kono
parents: 67
diff changeset
1452 break;
kono
parents: 67
diff changeset
1453 case TRAP_IF:
kono
parents: 67
diff changeset
1454 fun = "trap_if";
kono
parents: 67
diff changeset
1455 op[0] = TRAP_CONDITION (x);
kono
parents: 67
diff changeset
1456 break;
kono
parents: 67
diff changeset
1457 case PREFETCH:
kono
parents: 67
diff changeset
1458 fun = "prefetch";
kono
parents: 67
diff changeset
1459 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1460 op[1] = XEXP (x, 1);
kono
parents: 67
diff changeset
1461 op[2] = XEXP (x, 2);
kono
parents: 67
diff changeset
1462 break;
kono
parents: 67
diff changeset
1463 case UNSPEC:
kono
parents: 67
diff changeset
1464 case UNSPEC_VOLATILE:
kono
parents: 67
diff changeset
1465 {
kono
parents: 67
diff changeset
1466 pp_string (pp, "unspec");
kono
parents: 67
diff changeset
1467 if (GET_CODE (x) == UNSPEC_VOLATILE)
kono
parents: 67
diff changeset
1468 pp_string (pp, "/v");
kono
parents: 67
diff changeset
1469 pp_left_bracket (pp);
kono
parents: 67
diff changeset
1470 for (i = 0; i < XVECLEN (x, 0); i++)
kono
parents: 67
diff changeset
1471 {
kono
parents: 67
diff changeset
1472 if (i != 0)
kono
parents: 67
diff changeset
1473 pp_comma (pp);
kono
parents: 67
diff changeset
1474 print_pattern (pp, XVECEXP (x, 0, i), verbose);
kono
parents: 67
diff changeset
1475 }
kono
parents: 67
diff changeset
1476 pp_string (pp, "] ");
kono
parents: 67
diff changeset
1477 pp_decimal_int (pp, XINT (x, 1));
kono
parents: 67
diff changeset
1478 }
kono
parents: 67
diff changeset
1479 break;
kono
parents: 67
diff changeset
1480 default:
kono
parents: 67
diff changeset
1481 {
kono
parents: 67
diff changeset
1482 /* Most unhandled codes can be printed as pseudo-functions. */
kono
parents: 67
diff changeset
1483 if (GET_RTX_CLASS (GET_CODE (x)) == RTX_UNARY)
kono
parents: 67
diff changeset
1484 {
kono
parents: 67
diff changeset
1485 fun = GET_RTX_NAME (GET_CODE (x));
kono
parents: 67
diff changeset
1486 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1487 }
kono
parents: 67
diff changeset
1488 else if (GET_RTX_CLASS (GET_CODE (x)) == RTX_COMPARE
kono
parents: 67
diff changeset
1489 || GET_RTX_CLASS (GET_CODE (x)) == RTX_COMM_COMPARE
kono
parents: 67
diff changeset
1490 || GET_RTX_CLASS (GET_CODE (x)) == RTX_BIN_ARITH
kono
parents: 67
diff changeset
1491 || GET_RTX_CLASS (GET_CODE (x)) == RTX_COMM_ARITH)
kono
parents: 67
diff changeset
1492 {
kono
parents: 67
diff changeset
1493 fun = GET_RTX_NAME (GET_CODE (x));
kono
parents: 67
diff changeset
1494 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1495 op[1] = XEXP (x, 1);
kono
parents: 67
diff changeset
1496 }
kono
parents: 67
diff changeset
1497 else if (GET_RTX_CLASS (GET_CODE (x)) == RTX_TERNARY)
kono
parents: 67
diff changeset
1498 {
kono
parents: 67
diff changeset
1499 fun = GET_RTX_NAME (GET_CODE (x));
kono
parents: 67
diff changeset
1500 op[0] = XEXP (x, 0);
kono
parents: 67
diff changeset
1501 op[1] = XEXP (x, 1);
kono
parents: 67
diff changeset
1502 op[2] = XEXP (x, 2);
kono
parents: 67
diff changeset
1503 }
kono
parents: 67
diff changeset
1504 else
kono
parents: 67
diff changeset
1505 /* Give up, just print the RTX name. */
kono
parents: 67
diff changeset
1506 st[0] = GET_RTX_NAME (GET_CODE (x));
kono
parents: 67
diff changeset
1507 }
kono
parents: 67
diff changeset
1508 break;
kono
parents: 67
diff changeset
1509 }
kono
parents: 67
diff changeset
1510
kono
parents: 67
diff changeset
1511 /* Print this as a function? */
kono
parents: 67
diff changeset
1512 if (fun)
kono
parents: 67
diff changeset
1513 {
kono
parents: 67
diff changeset
1514 pp_string (pp, fun);
kono
parents: 67
diff changeset
1515 pp_left_paren (pp);
kono
parents: 67
diff changeset
1516 }
kono
parents: 67
diff changeset
1517
kono
parents: 67
diff changeset
1518 for (i = 0; i < 4; i++)
kono
parents: 67
diff changeset
1519 {
kono
parents: 67
diff changeset
1520 if (st[i])
kono
parents: 67
diff changeset
1521 pp_string (pp, st[i]);
kono
parents: 67
diff changeset
1522
kono
parents: 67
diff changeset
1523 if (op[i])
kono
parents: 67
diff changeset
1524 {
kono
parents: 67
diff changeset
1525 if (fun && i != 0)
kono
parents: 67
diff changeset
1526 pp_comma (pp);
kono
parents: 67
diff changeset
1527 print_value (pp, op[i], verbose);
kono
parents: 67
diff changeset
1528 }
kono
parents: 67
diff changeset
1529 }
kono
parents: 67
diff changeset
1530
kono
parents: 67
diff changeset
1531 if (fun)
kono
parents: 67
diff changeset
1532 pp_right_paren (pp);
kono
parents: 67
diff changeset
1533 } /* print_exp */
kono
parents: 67
diff changeset
1534
kono
parents: 67
diff changeset
1535 /* Prints rtxes, I customarily classified as values. They're constants,
kono
parents: 67
diff changeset
1536 registers, labels, symbols and memory accesses. */
kono
parents: 67
diff changeset
1537
kono
parents: 67
diff changeset
1538 void
kono
parents: 67
diff changeset
1539 print_value (pretty_printer *pp, const_rtx x, int verbose)
kono
parents: 67
diff changeset
1540 {
kono
parents: 67
diff changeset
1541 char tmp[1024];
kono
parents: 67
diff changeset
1542
kono
parents: 67
diff changeset
1543 if (!x)
kono
parents: 67
diff changeset
1544 {
kono
parents: 67
diff changeset
1545 pp_string (pp, "(nil)");
kono
parents: 67
diff changeset
1546 return;
kono
parents: 67
diff changeset
1547 }
kono
parents: 67
diff changeset
1548 switch (GET_CODE (x))
kono
parents: 67
diff changeset
1549 {
kono
parents: 67
diff changeset
1550 case CONST_INT:
kono
parents: 67
diff changeset
1551 pp_scalar (pp, HOST_WIDE_INT_PRINT_HEX,
kono
parents: 67
diff changeset
1552 (unsigned HOST_WIDE_INT) INTVAL (x));
kono
parents: 67
diff changeset
1553 break;
kono
parents: 67
diff changeset
1554
kono
parents: 67
diff changeset
1555 case CONST_WIDE_INT:
kono
parents: 67
diff changeset
1556 {
kono
parents: 67
diff changeset
1557 const char *sep = "<";
kono
parents: 67
diff changeset
1558 int i;
kono
parents: 67
diff changeset
1559 for (i = CONST_WIDE_INT_NUNITS (x) - 1; i >= 0; i--)
kono
parents: 67
diff changeset
1560 {
kono
parents: 67
diff changeset
1561 pp_string (pp, sep);
kono
parents: 67
diff changeset
1562 sep = ",";
kono
parents: 67
diff changeset
1563 sprintf (tmp, HOST_WIDE_INT_PRINT_HEX,
kono
parents: 67
diff changeset
1564 (unsigned HOST_WIDE_INT) CONST_WIDE_INT_ELT (x, i));
kono
parents: 67
diff changeset
1565 pp_string (pp, tmp);
kono
parents: 67
diff changeset
1566 }
kono
parents: 67
diff changeset
1567 pp_greater (pp);
kono
parents: 67
diff changeset
1568 }
kono
parents: 67
diff changeset
1569 break;
kono
parents: 67
diff changeset
1570
kono
parents: 67
diff changeset
1571 case CONST_DOUBLE:
kono
parents: 67
diff changeset
1572 if (FLOAT_MODE_P (GET_MODE (x)))
kono
parents: 67
diff changeset
1573 {
kono
parents: 67
diff changeset
1574 real_to_decimal (tmp, CONST_DOUBLE_REAL_VALUE (x),
kono
parents: 67
diff changeset
1575 sizeof (tmp), 0, 1);
kono
parents: 67
diff changeset
1576 pp_string (pp, tmp);
kono
parents: 67
diff changeset
1577 }
kono
parents: 67
diff changeset
1578 else
kono
parents: 67
diff changeset
1579 pp_printf (pp, "<%wx,%wx>",
kono
parents: 67
diff changeset
1580 (unsigned HOST_WIDE_INT) CONST_DOUBLE_LOW (x),
kono
parents: 67
diff changeset
1581 (unsigned HOST_WIDE_INT) CONST_DOUBLE_HIGH (x));
kono
parents: 67
diff changeset
1582 break;
kono
parents: 67
diff changeset
1583 case CONST_FIXED:
kono
parents: 67
diff changeset
1584 fixed_to_decimal (tmp, CONST_FIXED_VALUE (x), sizeof (tmp));
kono
parents: 67
diff changeset
1585 pp_string (pp, tmp);
kono
parents: 67
diff changeset
1586 break;
kono
parents: 67
diff changeset
1587 case CONST_STRING:
kono
parents: 67
diff changeset
1588 pp_printf (pp, "\"%s\"", XSTR (x, 0));
kono
parents: 67
diff changeset
1589 break;
kono
parents: 67
diff changeset
1590 case SYMBOL_REF:
kono
parents: 67
diff changeset
1591 pp_printf (pp, "`%s'", XSTR (x, 0));
kono
parents: 67
diff changeset
1592 break;
kono
parents: 67
diff changeset
1593 case LABEL_REF:
kono
parents: 67
diff changeset
1594 pp_printf (pp, "L%d", INSN_UID (label_ref_label (x)));
kono
parents: 67
diff changeset
1595 break;
kono
parents: 67
diff changeset
1596 case CONST:
kono
parents: 67
diff changeset
1597 case HIGH:
kono
parents: 67
diff changeset
1598 case STRICT_LOW_PART:
kono
parents: 67
diff changeset
1599 pp_printf (pp, "%s(", GET_RTX_NAME (GET_CODE (x)));
kono
parents: 67
diff changeset
1600 print_value (pp, XEXP (x, 0), verbose);
kono
parents: 67
diff changeset
1601 pp_right_paren (pp);
kono
parents: 67
diff changeset
1602 break;
kono
parents: 67
diff changeset
1603 case REG:
kono
parents: 67
diff changeset
1604 if (REGNO (x) < FIRST_PSEUDO_REGISTER)
kono
parents: 67
diff changeset
1605 {
kono
parents: 67
diff changeset
1606 if (ISDIGIT (reg_names[REGNO (x)][0]))
kono
parents: 67
diff changeset
1607 pp_modulo (pp);
kono
parents: 67
diff changeset
1608 pp_string (pp, reg_names[REGNO (x)]);
kono
parents: 67
diff changeset
1609 }
kono
parents: 67
diff changeset
1610 else
kono
parents: 67
diff changeset
1611 pp_printf (pp, "r%d", REGNO (x));
kono
parents: 67
diff changeset
1612 if (verbose)
kono
parents: 67
diff changeset
1613 pp_printf (pp, ":%s", GET_MODE_NAME (GET_MODE (x)));
kono
parents: 67
diff changeset
1614 break;
kono
parents: 67
diff changeset
1615 case SUBREG:
kono
parents: 67
diff changeset
1616 print_value (pp, SUBREG_REG (x), verbose);
kono
parents: 67
diff changeset
1617 pp_printf (pp, "#%d", SUBREG_BYTE (x));
kono
parents: 67
diff changeset
1618 break;
kono
parents: 67
diff changeset
1619 case SCRATCH:
kono
parents: 67
diff changeset
1620 case CC0:
kono
parents: 67
diff changeset
1621 case PC:
kono
parents: 67
diff changeset
1622 pp_string (pp, GET_RTX_NAME (GET_CODE (x)));
kono
parents: 67
diff changeset
1623 break;
kono
parents: 67
diff changeset
1624 case MEM:
kono
parents: 67
diff changeset
1625 pp_left_bracket (pp);
kono
parents: 67
diff changeset
1626 print_value (pp, XEXP (x, 0), verbose);
kono
parents: 67
diff changeset
1627 pp_right_bracket (pp);
kono
parents: 67
diff changeset
1628 break;
kono
parents: 67
diff changeset
1629 case DEBUG_EXPR:
kono
parents: 67
diff changeset
1630 pp_printf (pp, "D#%i", DEBUG_TEMP_UID (DEBUG_EXPR_TREE_DECL (x)));
kono
parents: 67
diff changeset
1631 break;
kono
parents: 67
diff changeset
1632 default:
kono
parents: 67
diff changeset
1633 print_exp (pp, x, verbose);
kono
parents: 67
diff changeset
1634 break;
kono
parents: 67
diff changeset
1635 }
kono
parents: 67
diff changeset
1636 } /* print_value */
kono
parents: 67
diff changeset
1637
kono
parents: 67
diff changeset
1638 /* The next step in insn detalization, its pattern recognition. */
kono
parents: 67
diff changeset
1639
kono
parents: 67
diff changeset
1640 void
kono
parents: 67
diff changeset
1641 print_pattern (pretty_printer *pp, const_rtx x, int verbose)
kono
parents: 67
diff changeset
1642 {
kono
parents: 67
diff changeset
1643 if (! x)
kono
parents: 67
diff changeset
1644 {
kono
parents: 67
diff changeset
1645 pp_string (pp, "(nil)");
kono
parents: 67
diff changeset
1646 return;
kono
parents: 67
diff changeset
1647 }
kono
parents: 67
diff changeset
1648
kono
parents: 67
diff changeset
1649 switch (GET_CODE (x))
kono
parents: 67
diff changeset
1650 {
kono
parents: 67
diff changeset
1651 case SET:
kono
parents: 67
diff changeset
1652 print_value (pp, SET_DEST (x), verbose);
kono
parents: 67
diff changeset
1653 pp_equal (pp);
kono
parents: 67
diff changeset
1654 print_value (pp, SET_SRC (x), verbose);
kono
parents: 67
diff changeset
1655 break;
kono
parents: 67
diff changeset
1656 case RETURN:
kono
parents: 67
diff changeset
1657 case SIMPLE_RETURN:
kono
parents: 67
diff changeset
1658 case EH_RETURN:
kono
parents: 67
diff changeset
1659 pp_string (pp, GET_RTX_NAME (GET_CODE (x)));
kono
parents: 67
diff changeset
1660 break;
kono
parents: 67
diff changeset
1661 case CALL:
kono
parents: 67
diff changeset
1662 print_exp (pp, x, verbose);
kono
parents: 67
diff changeset
1663 break;
kono
parents: 67
diff changeset
1664 case CLOBBER:
kono
parents: 67
diff changeset
1665 case USE:
kono
parents: 67
diff changeset
1666 pp_printf (pp, "%s ", GET_RTX_NAME (GET_CODE (x)));
kono
parents: 67
diff changeset
1667 print_value (pp, XEXP (x, 0), verbose);
kono
parents: 67
diff changeset
1668 break;
kono
parents: 67
diff changeset
1669 case VAR_LOCATION:
kono
parents: 67
diff changeset
1670 pp_string (pp, "loc ");
kono
parents: 67
diff changeset
1671 print_value (pp, PAT_VAR_LOCATION_LOC (x), verbose);
kono
parents: 67
diff changeset
1672 break;
kono
parents: 67
diff changeset
1673 case COND_EXEC:
kono
parents: 67
diff changeset
1674 pp_left_paren (pp);
kono
parents: 67
diff changeset
1675 if (GET_CODE (COND_EXEC_TEST (x)) == NE
kono
parents: 67
diff changeset
1676 && XEXP (COND_EXEC_TEST (x), 1) == const0_rtx)
kono
parents: 67
diff changeset
1677 print_value (pp, XEXP (COND_EXEC_TEST (x), 0), verbose);
kono
parents: 67
diff changeset
1678 else if (GET_CODE (COND_EXEC_TEST (x)) == EQ
kono
parents: 67
diff changeset
1679 && XEXP (COND_EXEC_TEST (x), 1) == const0_rtx)
kono
parents: 67
diff changeset
1680 {
kono
parents: 67
diff changeset
1681 pp_exclamation (pp);
kono
parents: 67
diff changeset
1682 print_value (pp, XEXP (COND_EXEC_TEST (x), 0), verbose);
kono
parents: 67
diff changeset
1683 }
kono
parents: 67
diff changeset
1684 else
kono
parents: 67
diff changeset
1685 print_value (pp, COND_EXEC_TEST (x), verbose);
kono
parents: 67
diff changeset
1686 pp_string (pp, ") ");
kono
parents: 67
diff changeset
1687 print_pattern (pp, COND_EXEC_CODE (x), verbose);
kono
parents: 67
diff changeset
1688 break;
kono
parents: 67
diff changeset
1689 case PARALLEL:
kono
parents: 67
diff changeset
1690 {
kono
parents: 67
diff changeset
1691 int i;
kono
parents: 67
diff changeset
1692
kono
parents: 67
diff changeset
1693 pp_left_brace (pp);
kono
parents: 67
diff changeset
1694 for (i = 0; i < XVECLEN (x, 0); i++)
kono
parents: 67
diff changeset
1695 {
kono
parents: 67
diff changeset
1696 print_pattern (pp, XVECEXP (x, 0, i), verbose);
kono
parents: 67
diff changeset
1697 pp_semicolon (pp);
kono
parents: 67
diff changeset
1698 }
kono
parents: 67
diff changeset
1699 pp_right_brace (pp);
kono
parents: 67
diff changeset
1700 }
kono
parents: 67
diff changeset
1701 break;
kono
parents: 67
diff changeset
1702 case SEQUENCE:
kono
parents: 67
diff changeset
1703 {
kono
parents: 67
diff changeset
1704 const rtx_sequence *seq = as_a <const rtx_sequence *> (x);
kono
parents: 67
diff changeset
1705 pp_string (pp, "sequence{");
kono
parents: 67
diff changeset
1706 if (INSN_P (seq->element (0)))
kono
parents: 67
diff changeset
1707 {
kono
parents: 67
diff changeset
1708 /* Print the sequence insns indented. */
kono
parents: 67
diff changeset
1709 const char * save_print_rtx_head = print_rtx_head;
kono
parents: 67
diff changeset
1710 char indented_print_rtx_head[32];
kono
parents: 67
diff changeset
1711
kono
parents: 67
diff changeset
1712 pp_newline (pp);
kono
parents: 67
diff changeset
1713 gcc_assert (strlen (print_rtx_head) < sizeof (indented_print_rtx_head) - 4);
kono
parents: 67
diff changeset
1714 snprintf (indented_print_rtx_head,
kono
parents: 67
diff changeset
1715 sizeof (indented_print_rtx_head),
kono
parents: 67
diff changeset
1716 "%s ", print_rtx_head);
kono
parents: 67
diff changeset
1717 print_rtx_head = indented_print_rtx_head;
kono
parents: 67
diff changeset
1718 for (int i = 0; i < seq->len (); i++)
kono
parents: 67
diff changeset
1719 print_insn_with_notes (pp, seq->insn (i));
kono
parents: 67
diff changeset
1720 pp_printf (pp, "%s ", save_print_rtx_head);
kono
parents: 67
diff changeset
1721 print_rtx_head = save_print_rtx_head;
kono
parents: 67
diff changeset
1722 }
kono
parents: 67
diff changeset
1723 else
kono
parents: 67
diff changeset
1724 {
kono
parents: 67
diff changeset
1725 for (int i = 0; i < seq->len (); i++)
kono
parents: 67
diff changeset
1726 {
kono
parents: 67
diff changeset
1727 print_pattern (pp, seq->element (i), verbose);
kono
parents: 67
diff changeset
1728 pp_semicolon (pp);
kono
parents: 67
diff changeset
1729 }
kono
parents: 67
diff changeset
1730 }
kono
parents: 67
diff changeset
1731 pp_right_brace (pp);
kono
parents: 67
diff changeset
1732 }
kono
parents: 67
diff changeset
1733 break;
kono
parents: 67
diff changeset
1734 case ASM_INPUT:
kono
parents: 67
diff changeset
1735 pp_printf (pp, "asm {%s}", XSTR (x, 0));
kono
parents: 67
diff changeset
1736 break;
kono
parents: 67
diff changeset
1737 case ADDR_VEC:
kono
parents: 67
diff changeset
1738 for (int i = 0; i < XVECLEN (x, 0); i++)
kono
parents: 67
diff changeset
1739 {
kono
parents: 67
diff changeset
1740 print_value (pp, XVECEXP (x, 0, i), verbose);
kono
parents: 67
diff changeset
1741 pp_semicolon (pp);
kono
parents: 67
diff changeset
1742 }
kono
parents: 67
diff changeset
1743 break;
kono
parents: 67
diff changeset
1744 case ADDR_DIFF_VEC:
kono
parents: 67
diff changeset
1745 for (int i = 0; i < XVECLEN (x, 1); i++)
kono
parents: 67
diff changeset
1746 {
kono
parents: 67
diff changeset
1747 print_value (pp, XVECEXP (x, 1, i), verbose);
kono
parents: 67
diff changeset
1748 pp_semicolon (pp);
kono
parents: 67
diff changeset
1749 }
kono
parents: 67
diff changeset
1750 break;
kono
parents: 67
diff changeset
1751 case TRAP_IF:
kono
parents: 67
diff changeset
1752 pp_string (pp, "trap_if ");
kono
parents: 67
diff changeset
1753 print_value (pp, TRAP_CONDITION (x), verbose);
kono
parents: 67
diff changeset
1754 break;
kono
parents: 67
diff changeset
1755 case UNSPEC:
kono
parents: 67
diff changeset
1756 case UNSPEC_VOLATILE:
kono
parents: 67
diff changeset
1757 /* Fallthru -- leave UNSPECs to print_exp. */
kono
parents: 67
diff changeset
1758 default:
kono
parents: 67
diff changeset
1759 print_value (pp, x, verbose);
kono
parents: 67
diff changeset
1760 }
kono
parents: 67
diff changeset
1761 } /* print_pattern */
kono
parents: 67
diff changeset
1762
kono
parents: 67
diff changeset
1763 /* This is the main function in slim rtl visualization mechanism.
kono
parents: 67
diff changeset
1764
kono
parents: 67
diff changeset
1765 X is an insn, to be printed into PP.
kono
parents: 67
diff changeset
1766
kono
parents: 67
diff changeset
1767 This function tries to print it properly in human-readable form,
kono
parents: 67
diff changeset
1768 resembling assembler mnemonics (instead of the older Lisp-style
kono
parents: 67
diff changeset
1769 form).
kono
parents: 67
diff changeset
1770
kono
parents: 67
diff changeset
1771 If VERBOSE is TRUE, insns are printed with more complete (but
kono
parents: 67
diff changeset
1772 longer) pattern names and with extra information, and prefixed
kono
parents: 67
diff changeset
1773 with their INSN_UIDs. */
kono
parents: 67
diff changeset
1774
kono
parents: 67
diff changeset
1775 void
kono
parents: 67
diff changeset
1776 print_insn (pretty_printer *pp, const rtx_insn *x, int verbose)
kono
parents: 67
diff changeset
1777 {
kono
parents: 67
diff changeset
1778 if (verbose)
kono
parents: 67
diff changeset
1779 {
kono
parents: 67
diff changeset
1780 /* Blech, pretty-print can't print integers with a specified width. */
kono
parents: 67
diff changeset
1781 char uid_prefix[32];
kono
parents: 67
diff changeset
1782 snprintf (uid_prefix, sizeof uid_prefix, " %4d: ", INSN_UID (x));
kono
parents: 67
diff changeset
1783 pp_string (pp, uid_prefix);
kono
parents: 67
diff changeset
1784 }
kono
parents: 67
diff changeset
1785
kono
parents: 67
diff changeset
1786 switch (GET_CODE (x))
kono
parents: 67
diff changeset
1787 {
kono
parents: 67
diff changeset
1788 case INSN:
kono
parents: 67
diff changeset
1789 print_pattern (pp, PATTERN (x), verbose);
kono
parents: 67
diff changeset
1790 break;
kono
parents: 67
diff changeset
1791
kono
parents: 67
diff changeset
1792 case DEBUG_INSN:
kono
parents: 67
diff changeset
1793 {
kono
parents: 67
diff changeset
1794 const char *name = "?";
kono
parents: 67
diff changeset
1795 char idbuf[32];
kono
parents: 67
diff changeset
1796
kono
parents: 67
diff changeset
1797 if (DECL_P (INSN_VAR_LOCATION_DECL (x)))
kono
parents: 67
diff changeset
1798 {
kono
parents: 67
diff changeset
1799 tree id = DECL_NAME (INSN_VAR_LOCATION_DECL (x));
kono
parents: 67
diff changeset
1800 if (id)
kono
parents: 67
diff changeset
1801 name = IDENTIFIER_POINTER (id);
kono
parents: 67
diff changeset
1802 else if (TREE_CODE (INSN_VAR_LOCATION_DECL (x))
kono
parents: 67
diff changeset
1803 == DEBUG_EXPR_DECL)
kono
parents: 67
diff changeset
1804 {
kono
parents: 67
diff changeset
1805 sprintf (idbuf, "D#%i",
kono
parents: 67
diff changeset
1806 DEBUG_TEMP_UID (INSN_VAR_LOCATION_DECL (x)));
kono
parents: 67
diff changeset
1807 name = idbuf;
kono
parents: 67
diff changeset
1808 }
kono
parents: 67
diff changeset
1809 else
kono
parents: 67
diff changeset
1810 {
kono
parents: 67
diff changeset
1811 sprintf (idbuf, "D.%i",
kono
parents: 67
diff changeset
1812 DECL_UID (INSN_VAR_LOCATION_DECL (x)));
kono
parents: 67
diff changeset
1813 name = idbuf;
kono
parents: 67
diff changeset
1814 }
kono
parents: 67
diff changeset
1815 }
kono
parents: 67
diff changeset
1816 pp_printf (pp, "debug %s => ", name);
kono
parents: 67
diff changeset
1817 if (VAR_LOC_UNKNOWN_P (INSN_VAR_LOCATION_LOC (x)))
kono
parents: 67
diff changeset
1818 pp_string (pp, "optimized away");
kono
parents: 67
diff changeset
1819 else
kono
parents: 67
diff changeset
1820 print_pattern (pp, INSN_VAR_LOCATION_LOC (x), verbose);
kono
parents: 67
diff changeset
1821 }
kono
parents: 67
diff changeset
1822 break;
kono
parents: 67
diff changeset
1823
kono
parents: 67
diff changeset
1824 case JUMP_INSN:
kono
parents: 67
diff changeset
1825 print_pattern (pp, PATTERN (x), verbose);
kono
parents: 67
diff changeset
1826 break;
kono
parents: 67
diff changeset
1827 case CALL_INSN:
kono
parents: 67
diff changeset
1828 if (GET_CODE (PATTERN (x)) == PARALLEL)
kono
parents: 67
diff changeset
1829 print_pattern (pp, XVECEXP (PATTERN (x), 0, 0), verbose);
kono
parents: 67
diff changeset
1830 else
kono
parents: 67
diff changeset
1831 print_pattern (pp, PATTERN (x), verbose);
kono
parents: 67
diff changeset
1832 break;
kono
parents: 67
diff changeset
1833 case CODE_LABEL:
kono
parents: 67
diff changeset
1834 pp_printf (pp, "L%d:", INSN_UID (x));
kono
parents: 67
diff changeset
1835 break;
kono
parents: 67
diff changeset
1836 case JUMP_TABLE_DATA:
kono
parents: 67
diff changeset
1837 pp_string (pp, "jump_table_data{\n");
kono
parents: 67
diff changeset
1838 print_pattern (pp, PATTERN (x), verbose);
kono
parents: 67
diff changeset
1839 pp_right_brace (pp);
kono
parents: 67
diff changeset
1840 break;
kono
parents: 67
diff changeset
1841 case BARRIER:
kono
parents: 67
diff changeset
1842 pp_string (pp, "barrier");
kono
parents: 67
diff changeset
1843 break;
kono
parents: 67
diff changeset
1844 case NOTE:
kono
parents: 67
diff changeset
1845 {
kono
parents: 67
diff changeset
1846 pp_string (pp, GET_NOTE_INSN_NAME (NOTE_KIND (x)));
kono
parents: 67
diff changeset
1847 switch (NOTE_KIND (x))
kono
parents: 67
diff changeset
1848 {
kono
parents: 67
diff changeset
1849 case NOTE_INSN_EH_REGION_BEG:
kono
parents: 67
diff changeset
1850 case NOTE_INSN_EH_REGION_END:
kono
parents: 67
diff changeset
1851 pp_printf (pp, " %d", NOTE_EH_HANDLER (x));
kono
parents: 67
diff changeset
1852 break;
kono
parents: 67
diff changeset
1853
kono
parents: 67
diff changeset
1854 case NOTE_INSN_BLOCK_BEG:
kono
parents: 67
diff changeset
1855 case NOTE_INSN_BLOCK_END:
kono
parents: 67
diff changeset
1856 pp_printf (pp, " %d", BLOCK_NUMBER (NOTE_BLOCK (x)));
kono
parents: 67
diff changeset
1857 break;
kono
parents: 67
diff changeset
1858
kono
parents: 67
diff changeset
1859 case NOTE_INSN_BASIC_BLOCK:
kono
parents: 67
diff changeset
1860 pp_printf (pp, " %d", NOTE_BASIC_BLOCK (x)->index);
kono
parents: 67
diff changeset
1861 break;
kono
parents: 67
diff changeset
1862
kono
parents: 67
diff changeset
1863 case NOTE_INSN_DELETED_LABEL:
kono
parents: 67
diff changeset
1864 case NOTE_INSN_DELETED_DEBUG_LABEL:
kono
parents: 67
diff changeset
1865 {
kono
parents: 67
diff changeset
1866 const char *label = NOTE_DELETED_LABEL_NAME (x);
kono
parents: 67
diff changeset
1867 if (label == NULL)
kono
parents: 67
diff changeset
1868 label = "";
kono
parents: 67
diff changeset
1869 pp_printf (pp, " (\"%s\")", label);
kono
parents: 67
diff changeset
1870 }
kono
parents: 67
diff changeset
1871 break;
kono
parents: 67
diff changeset
1872
kono
parents: 67
diff changeset
1873 case NOTE_INSN_VAR_LOCATION:
kono
parents: 67
diff changeset
1874 case NOTE_INSN_CALL_ARG_LOCATION:
kono
parents: 67
diff changeset
1875 pp_left_brace (pp);
kono
parents: 67
diff changeset
1876 print_pattern (pp, NOTE_VAR_LOCATION (x), verbose);
kono
parents: 67
diff changeset
1877 pp_right_brace (pp);
kono
parents: 67
diff changeset
1878 break;
kono
parents: 67
diff changeset
1879
kono
parents: 67
diff changeset
1880 default:
kono
parents: 67
diff changeset
1881 break;
kono
parents: 67
diff changeset
1882 }
kono
parents: 67
diff changeset
1883 break;
kono
parents: 67
diff changeset
1884 }
kono
parents: 67
diff changeset
1885 default:
kono
parents: 67
diff changeset
1886 gcc_unreachable ();
kono
parents: 67
diff changeset
1887 }
kono
parents: 67
diff changeset
1888 } /* print_insn */
kono
parents: 67
diff changeset
1889
kono
parents: 67
diff changeset
1890 /* Pretty-print a slim dump of X (an insn) to PP, including any register
kono
parents: 67
diff changeset
1891 note attached to the instruction. */
kono
parents: 67
diff changeset
1892
kono
parents: 67
diff changeset
1893 static void
kono
parents: 67
diff changeset
1894 print_insn_with_notes (pretty_printer *pp, const rtx_insn *x)
kono
parents: 67
diff changeset
1895 {
kono
parents: 67
diff changeset
1896 pp_string (pp, print_rtx_head);
kono
parents: 67
diff changeset
1897 print_insn (pp, x, 1);
kono
parents: 67
diff changeset
1898 pp_newline (pp);
kono
parents: 67
diff changeset
1899 if (INSN_P (x) && REG_NOTES (x))
kono
parents: 67
diff changeset
1900 for (rtx note = REG_NOTES (x); note; note = XEXP (note, 1))
kono
parents: 67
diff changeset
1901 {
kono
parents: 67
diff changeset
1902 pp_printf (pp, "%s %s ", print_rtx_head,
kono
parents: 67
diff changeset
1903 GET_REG_NOTE_NAME (REG_NOTE_KIND (note)));
kono
parents: 67
diff changeset
1904 if (GET_CODE (note) == INT_LIST)
kono
parents: 67
diff changeset
1905 pp_printf (pp, "%d", XINT (note, 0));
kono
parents: 67
diff changeset
1906 else
kono
parents: 67
diff changeset
1907 print_pattern (pp, XEXP (note, 0), 1);
kono
parents: 67
diff changeset
1908 pp_newline (pp);
kono
parents: 67
diff changeset
1909 }
kono
parents: 67
diff changeset
1910 }
kono
parents: 67
diff changeset
1911
kono
parents: 67
diff changeset
1912 /* Print X, an RTL value node, to file F in slim format. Include
kono
parents: 67
diff changeset
1913 additional information if VERBOSE is nonzero.
kono
parents: 67
diff changeset
1914
kono
parents: 67
diff changeset
1915 Value nodes are constants, registers, labels, symbols and
kono
parents: 67
diff changeset
1916 memory. */
kono
parents: 67
diff changeset
1917
kono
parents: 67
diff changeset
1918 void
kono
parents: 67
diff changeset
1919 dump_value_slim (FILE *f, const_rtx x, int verbose)
kono
parents: 67
diff changeset
1920 {
kono
parents: 67
diff changeset
1921 pretty_printer rtl_slim_pp;
kono
parents: 67
diff changeset
1922 rtl_slim_pp.buffer->stream = f;
kono
parents: 67
diff changeset
1923 print_value (&rtl_slim_pp, x, verbose);
kono
parents: 67
diff changeset
1924 pp_flush (&rtl_slim_pp);
kono
parents: 67
diff changeset
1925 }
kono
parents: 67
diff changeset
1926
kono
parents: 67
diff changeset
1927 /* Emit a slim dump of X (an insn) to the file F, including any register
kono
parents: 67
diff changeset
1928 note attached to the instruction. */
kono
parents: 67
diff changeset
1929 void
kono
parents: 67
diff changeset
1930 dump_insn_slim (FILE *f, const rtx_insn *x)
kono
parents: 67
diff changeset
1931 {
kono
parents: 67
diff changeset
1932 pretty_printer rtl_slim_pp;
kono
parents: 67
diff changeset
1933 rtl_slim_pp.buffer->stream = f;
kono
parents: 67
diff changeset
1934 print_insn_with_notes (&rtl_slim_pp, x);
kono
parents: 67
diff changeset
1935 pp_flush (&rtl_slim_pp);
kono
parents: 67
diff changeset
1936 }
kono
parents: 67
diff changeset
1937
kono
parents: 67
diff changeset
1938 /* Same as above, but stop at LAST or when COUNT == 0.
kono
parents: 67
diff changeset
1939 If COUNT < 0 it will stop only at LAST or NULL rtx. */
kono
parents: 67
diff changeset
1940
kono
parents: 67
diff changeset
1941 void
kono
parents: 67
diff changeset
1942 dump_rtl_slim (FILE *f, const rtx_insn *first, const rtx_insn *last,
kono
parents: 67
diff changeset
1943 int count, int flags ATTRIBUTE_UNUSED)
kono
parents: 67
diff changeset
1944 {
kono
parents: 67
diff changeset
1945 const rtx_insn *insn, *tail;
kono
parents: 67
diff changeset
1946 pretty_printer rtl_slim_pp;
kono
parents: 67
diff changeset
1947 rtl_slim_pp.buffer->stream = f;
kono
parents: 67
diff changeset
1948
kono
parents: 67
diff changeset
1949 tail = last ? NEXT_INSN (last) : NULL;
kono
parents: 67
diff changeset
1950 for (insn = first;
kono
parents: 67
diff changeset
1951 (insn != NULL) && (insn != tail) && (count != 0);
kono
parents: 67
diff changeset
1952 insn = NEXT_INSN (insn))
kono
parents: 67
diff changeset
1953 {
kono
parents: 67
diff changeset
1954 print_insn_with_notes (&rtl_slim_pp, insn);
kono
parents: 67
diff changeset
1955 if (count > 0)
kono
parents: 67
diff changeset
1956 count--;
kono
parents: 67
diff changeset
1957 }
kono
parents: 67
diff changeset
1958
kono
parents: 67
diff changeset
1959 pp_flush (&rtl_slim_pp);
kono
parents: 67
diff changeset
1960 }
kono
parents: 67
diff changeset
1961
kono
parents: 67
diff changeset
1962 /* Dumps basic block BB to pretty-printer PP in slim form and without and
kono
parents: 67
diff changeset
1963 no indentation, for use as a label of a DOT graph record-node. */
kono
parents: 67
diff changeset
1964
kono
parents: 67
diff changeset
1965 void
kono
parents: 67
diff changeset
1966 rtl_dump_bb_for_graph (pretty_printer *pp, basic_block bb)
kono
parents: 67
diff changeset
1967 {
kono
parents: 67
diff changeset
1968 rtx_insn *insn;
kono
parents: 67
diff changeset
1969 bool first = true;
kono
parents: 67
diff changeset
1970
kono
parents: 67
diff changeset
1971 /* TODO: inter-bb stuff. */
kono
parents: 67
diff changeset
1972 FOR_BB_INSNS (bb, insn)
kono
parents: 67
diff changeset
1973 {
kono
parents: 67
diff changeset
1974 if (! first)
kono
parents: 67
diff changeset
1975 {
kono
parents: 67
diff changeset
1976 pp_bar (pp);
kono
parents: 67
diff changeset
1977 pp_write_text_to_stream (pp);
kono
parents: 67
diff changeset
1978 }
kono
parents: 67
diff changeset
1979 first = false;
kono
parents: 67
diff changeset
1980 print_insn_with_notes (pp, insn);
kono
parents: 67
diff changeset
1981 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
kono
parents: 67
diff changeset
1982 }
kono
parents: 67
diff changeset
1983 }
kono
parents: 67
diff changeset
1984
kono
parents: 67
diff changeset
1985 /* Pretty-print pattern X of some insn in non-verbose mode.
kono
parents: 67
diff changeset
1986 Return a string pointer to the pretty-printer buffer.
kono
parents: 67
diff changeset
1987
kono
parents: 67
diff changeset
1988 This function is only exported exists only to accommodate some older users
kono
parents: 67
diff changeset
1989 of the slim RTL pretty printers. Please do not use it for new code. */
kono
parents: 67
diff changeset
1990
kono
parents: 67
diff changeset
1991 const char *
kono
parents: 67
diff changeset
1992 str_pattern_slim (const_rtx x)
kono
parents: 67
diff changeset
1993 {
kono
parents: 67
diff changeset
1994 pretty_printer rtl_slim_pp;
kono
parents: 67
diff changeset
1995 print_pattern (&rtl_slim_pp, x, 0);
kono
parents: 67
diff changeset
1996 return ggc_strdup (pp_formatted_text (&rtl_slim_pp));
kono
parents: 67
diff changeset
1997 }
kono
parents: 67
diff changeset
1998
kono
parents: 67
diff changeset
1999 /* Emit a slim dump of X (an insn) to stderr. */
kono
parents: 67
diff changeset
2000 extern void debug_insn_slim (const rtx_insn *);
kono
parents: 67
diff changeset
2001 DEBUG_FUNCTION void
kono
parents: 67
diff changeset
2002 debug_insn_slim (const rtx_insn *x)
kono
parents: 67
diff changeset
2003 {
kono
parents: 67
diff changeset
2004 dump_insn_slim (stderr, x);
kono
parents: 67
diff changeset
2005 }
kono
parents: 67
diff changeset
2006
kono
parents: 67
diff changeset
2007 /* Same as above, but using dump_rtl_slim. */
kono
parents: 67
diff changeset
2008 extern void debug_rtl_slim (FILE *, const rtx_insn *, const rtx_insn *,
kono
parents: 67
diff changeset
2009 int, int);
kono
parents: 67
diff changeset
2010 DEBUG_FUNCTION void
kono
parents: 67
diff changeset
2011 debug_rtl_slim (const rtx_insn *first, const rtx_insn *last, int count,
kono
parents: 67
diff changeset
2012 int flags)
kono
parents: 67
diff changeset
2013 {
kono
parents: 67
diff changeset
2014 dump_rtl_slim (stderr, first, last, count, flags);
kono
parents: 67
diff changeset
2015 }
kono
parents: 67
diff changeset
2016
kono
parents: 67
diff changeset
2017 extern void debug_bb_slim (basic_block);
kono
parents: 67
diff changeset
2018 DEBUG_FUNCTION void
kono
parents: 67
diff changeset
2019 debug_bb_slim (basic_block bb)
kono
parents: 67
diff changeset
2020 {
kono
parents: 67
diff changeset
2021 dump_bb (stderr, bb, 0, TDF_SLIM | TDF_BLOCKS);
kono
parents: 67
diff changeset
2022 }
kono
parents: 67
diff changeset
2023
kono
parents: 67
diff changeset
2024 extern void debug_bb_n_slim (int);
kono
parents: 67
diff changeset
2025 DEBUG_FUNCTION void
kono
parents: 67
diff changeset
2026 debug_bb_n_slim (int n)
kono
parents: 67
diff changeset
2027 {
kono
parents: 67
diff changeset
2028 basic_block bb = BASIC_BLOCK_FOR_FN (cfun, n);
kono
parents: 67
diff changeset
2029 debug_bb_slim (bb);
kono
parents: 67
diff changeset
2030 }
kono
parents: 67
diff changeset
2031
kono
parents: 67
diff changeset
2032 #endif