]>
Commit | Line | Data |
---|---|---|
4ee9c684 | 1 | /* Pretty formatting of GENERIC trees in C syntax. |
d353bf18 | 2 | Copyright (C) 2001-2015 Free Software Foundation, Inc. |
4ee9c684 | 3 | Adapted from c-pretty-print.c by Diego Novillo <dnovillo@redhat.com> |
4 | ||
5 | This file is part of GCC. | |
6 | ||
7 | GCC is free software; you can redistribute it and/or modify it under | |
8 | the terms of the GNU General Public License as published by the Free | |
8c4c00c1 | 9 | Software Foundation; either version 3, or (at your option) any later |
4ee9c684 | 10 | version. |
11 | ||
12 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY | |
13 | WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 | for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
8c4c00c1 | 18 | along with GCC; see the file COPYING3. If not see |
19 | <http://www.gnu.org/licenses/>. */ | |
4ee9c684 | 20 | |
21 | #include "config.h" | |
22 | #include "system.h" | |
23 | #include "coretypes.h" | |
24 | #include "tm.h" | |
b20a8bb4 | 25 | #include "alias.h" |
26 | #include "symtab.h" | |
4ee9c684 | 27 | #include "tree.h" |
9ed99284 | 28 | #include "stor-layout.h" |
d53441c8 | 29 | #include "hard-reg-set.h" |
30 | #include "function.h" | |
31 | #include "rtl.h" | |
32 | #include "flags.h" | |
d53441c8 | 33 | #include "insn-config.h" |
34 | #include "expmed.h" | |
35 | #include "dojump.h" | |
36 | #include "explow.h" | |
37 | #include "calls.h" | |
38 | #include "emit-rtl.h" | |
39 | #include "varasm.h" | |
40 | #include "stmt.h" | |
9ed99284 | 41 | #include "expr.h" |
ce084dfc | 42 | #include "tree-pretty-print.h" |
bc61cadb | 43 | #include "gimple-expr.h" |
94ea8568 | 44 | #include "predict.h" |
073c1fd5 | 45 | #include "cgraph.h" |
4ee9c684 | 46 | #include "langhooks.h" |
47 | #include "tree-iterator.h" | |
101d9422 | 48 | #include "tree-chrec.h" |
b9ed1410 | 49 | #include "dumpfile.h" |
4992f399 | 50 | #include "value-prof.h" |
e913b5cd | 51 | #include "wide-int-print.h" |
5ef6b660 | 52 | #include "internal-fn.h" |
ca4c3545 | 53 | #include "gomp-constants.h" |
4ee9c684 | 54 | |
55 | /* Local functions, macros and variables. */ | |
b4b34335 | 56 | static const char *op_symbol (const_tree); |
4ee9c684 | 57 | static void pretty_print_string (pretty_printer *, const char*); |
4ee9c684 | 58 | static void newline_and_indent (pretty_printer *, int); |
59 | static void maybe_init_pretty_print (FILE *); | |
b4b34335 | 60 | static void print_struct_decl (pretty_printer *, const_tree, int, int); |
61 | static void do_niy (pretty_printer *, const_tree); | |
4ee9c684 | 62 | |
63 | #define INDENT(SPACE) do { \ | |
baa9d179 | 64 | int i; for (i = 0; i<SPACE; i++) pp_space (pp); } while (0) |
4ee9c684 | 65 | |
baa9d179 | 66 | #define NIY do_niy (pp, node) |
4ee9c684 | 67 | |
baa9d179 | 68 | static pretty_printer *tree_pp; |
4ee9c684 | 69 | |
70 | /* Try to print something for an unknown tree code. */ | |
71 | ||
72 | static void | |
baa9d179 | 73 | do_niy (pretty_printer *pp, const_tree node) |
4ee9c684 | 74 | { |
75 | int i, len; | |
76 | ||
baa9d179 | 77 | pp_string (pp, "<<< Unknown tree: "); |
78 | pp_string (pp, get_tree_code_name (TREE_CODE (node))); | |
4ee9c684 | 79 | |
ce45a448 | 80 | if (EXPR_P (node)) |
4ee9c684 | 81 | { |
c2f47e15 | 82 | len = TREE_OPERAND_LENGTH (node); |
4ee9c684 | 83 | for (i = 0; i < len; ++i) |
84 | { | |
baa9d179 | 85 | newline_and_indent (pp, 2); |
86 | dump_generic_node (pp, TREE_OPERAND (node, i), 2, 0, false); | |
4ee9c684 | 87 | } |
88 | } | |
89 | ||
baa9d179 | 90 | pp_string (pp, " >>>"); |
4ee9c684 | 91 | } |
92 | ||
4726380a | 93 | /* Debugging function to print out a generic expression. */ |
94 | ||
4b987fac | 95 | DEBUG_FUNCTION void |
4ee9c684 | 96 | debug_generic_expr (tree t) |
97 | { | |
4fb5e5ca | 98 | print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS); |
4ee9c684 | 99 | fprintf (stderr, "\n"); |
100 | } | |
101 | ||
4726380a | 102 | /* Debugging function to print out a generic statement. */ |
103 | ||
4b987fac | 104 | DEBUG_FUNCTION void |
4ee9c684 | 105 | debug_generic_stmt (tree t) |
106 | { | |
4fb5e5ca | 107 | print_generic_stmt (stderr, t, TDF_VOPS|TDF_MEMSYMS); |
4ee9c684 | 108 | fprintf (stderr, "\n"); |
109 | } | |
110 | ||
4726380a | 111 | /* Debugging function to print out a chain of trees . */ |
112 | ||
4b987fac | 113 | DEBUG_FUNCTION void |
1e8e9920 | 114 | debug_tree_chain (tree t) |
115 | { | |
431205b7 | 116 | hash_set<tree> seen; |
77c223c3 | 117 | |
4d735392 | 118 | while (t) |
77c223c3 | 119 | { |
120 | print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID); | |
121 | fprintf (stderr, " "); | |
122 | t = TREE_CHAIN (t); | |
431205b7 | 123 | if (seen.add (t)) |
77c223c3 | 124 | { |
125 | fprintf (stderr, "... [cycled back to "); | |
126 | print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID); | |
127 | fprintf (stderr, "]"); | |
128 | break; | |
129 | } | |
130 | } | |
1e8e9920 | 131 | fprintf (stderr, "\n"); |
132 | } | |
133 | ||
4ee9c684 | 134 | /* Prints declaration DECL to the FILE with details specified by FLAGS. */ |
135 | void | |
136 | print_generic_decl (FILE *file, tree decl, int flags) | |
137 | { | |
138 | maybe_init_pretty_print (file); | |
baa9d179 | 139 | print_declaration (tree_pp, decl, 2, flags); |
140 | pp_write_text_to_stream (tree_pp); | |
4ee9c684 | 141 | } |
142 | ||
143 | /* Print tree T, and its successors, on file FILE. FLAGS specifies details | |
b9ed1410 | 144 | to show in the dump. See TDF_* in dumpfile.h. */ |
4ee9c684 | 145 | |
146 | void | |
147 | print_generic_stmt (FILE *file, tree t, int flags) | |
148 | { | |
149 | maybe_init_pretty_print (file); | |
baa9d179 | 150 | dump_generic_node (tree_pp, t, 0, flags, true); |
151 | pp_newline_and_flush (tree_pp); | |
4ee9c684 | 152 | } |
153 | ||
154 | /* Print tree T, and its successors, on file FILE. FLAGS specifies details | |
b9ed1410 | 155 | to show in the dump. See TDF_* in dumpfile.h. The output is indented by |
4ee9c684 | 156 | INDENT spaces. */ |
157 | ||
158 | void | |
159 | print_generic_stmt_indented (FILE *file, tree t, int flags, int indent) | |
160 | { | |
161 | int i; | |
162 | ||
163 | maybe_init_pretty_print (file); | |
4ee9c684 | 164 | |
165 | for (i = 0; i < indent; i++) | |
baa9d179 | 166 | pp_space (tree_pp); |
167 | dump_generic_node (tree_pp, t, indent, flags, true); | |
168 | pp_newline_and_flush (tree_pp); | |
4ee9c684 | 169 | } |
170 | ||
171 | /* Print a single expression T on file FILE. FLAGS specifies details to show | |
b9ed1410 | 172 | in the dump. See TDF_* in dumpfile.h. */ |
4ee9c684 | 173 | |
174 | void | |
175 | print_generic_expr (FILE *file, tree t, int flags) | |
176 | { | |
177 | maybe_init_pretty_print (file); | |
baa9d179 | 178 | dump_generic_node (tree_pp, t, 0, flags, false); |
179 | pp_flush (tree_pp); | |
4ee9c684 | 180 | } |
181 | ||
182 | /* Dump the name of a _DECL node and its DECL_UID if TDF_UID is set | |
183 | in FLAGS. */ | |
184 | ||
185 | static void | |
baa9d179 | 186 | dump_decl_name (pretty_printer *pp, tree node, int flags) |
4ee9c684 | 187 | { |
8c1f2562 | 188 | if (DECL_NAME (node)) |
189 | { | |
190 | if ((flags & TDF_ASMNAME) && DECL_ASSEMBLER_NAME_SET_P (node)) | |
baa9d179 | 191 | pp_tree_identifier (pp, DECL_ASSEMBLER_NAME (node)); |
8c1f2562 | 192 | else |
baa9d179 | 193 | pp_tree_identifier (pp, DECL_NAME (node)); |
8c1f2562 | 194 | } |
195 | if ((flags & TDF_UID) || DECL_NAME (node) == NULL_TREE) | |
4ee9c684 | 196 | { |
8c1f2562 | 197 | if (TREE_CODE (node) == LABEL_DECL && LABEL_DECL_UID (node) != -1) |
baa9d179 | 198 | pp_printf (pp, "L.%d", (int) LABEL_DECL_UID (node)); |
688ff29b | 199 | else if (TREE_CODE (node) == DEBUG_EXPR_DECL) |
00753696 | 200 | { |
201 | if (flags & TDF_NOUID) | |
baa9d179 | 202 | pp_string (pp, "D#xxxx"); |
00753696 | 203 | else |
baa9d179 | 204 | pp_printf (pp, "D#%i", DEBUG_TEMP_UID (node)); |
00753696 | 205 | } |
4d735392 | 206 | else |
e67e5e1f | 207 | { |
8c1f2562 | 208 | char c = TREE_CODE (node) == CONST_DECL ? 'C' : 'D'; |
00753696 | 209 | if (flags & TDF_NOUID) |
baa9d179 | 210 | pp_printf (pp, "%c.xxxx", c); |
00753696 | 211 | else |
baa9d179 | 212 | pp_printf (pp, "%c.%u", c, DECL_UID (node)); |
e67e5e1f | 213 | } |
4ee9c684 | 214 | } |
1a981e1a | 215 | if ((flags & TDF_ALIAS) && DECL_PT_UID (node) != DECL_UID (node)) |
216 | { | |
217 | if (flags & TDF_NOUID) | |
baa9d179 | 218 | pp_printf (pp, "ptD.xxxx"); |
1a981e1a | 219 | else |
baa9d179 | 220 | pp_printf (pp, "ptD.%u", DECL_PT_UID (node)); |
1a981e1a | 221 | } |
4ee9c684 | 222 | } |
223 | ||
a1080ab2 | 224 | /* Like the above, but used for pretty printing function calls. */ |
225 | ||
226 | static void | |
baa9d179 | 227 | dump_function_name (pretty_printer *pp, tree node, int flags) |
a1080ab2 | 228 | { |
d09ef31a | 229 | if (CONVERT_EXPR_P (node)) |
8c1f2562 | 230 | node = TREE_OPERAND (node, 0); |
231 | if (DECL_NAME (node) && (flags & TDF_ASMNAME) == 0) | |
baa9d179 | 232 | pp_string (pp, lang_hooks.decl_printable_name (node, 1)); |
a1080ab2 | 233 | else |
baa9d179 | 234 | dump_decl_name (pp, node, flags); |
a1080ab2 | 235 | } |
236 | ||
baa9d179 | 237 | /* Dump a function declaration. NODE is the FUNCTION_TYPE. PP, SPC and |
d700b485 | 238 | FLAGS are as in dump_generic_node. */ |
239 | ||
240 | static void | |
baa9d179 | 241 | dump_function_declaration (pretty_printer *pp, tree node, |
d700b485 | 242 | int spc, int flags) |
243 | { | |
244 | bool wrote_arg = false; | |
245 | tree arg; | |
246 | ||
baa9d179 | 247 | pp_space (pp); |
248 | pp_left_paren (pp); | |
d700b485 | 249 | |
8eb81823 | 250 | /* Print the argument types. */ |
d700b485 | 251 | arg = TYPE_ARG_TYPES (node); |
8eb81823 | 252 | while (arg && arg != void_list_node && arg != error_mark_node) |
d700b485 | 253 | { |
8eb81823 | 254 | if (wrote_arg) |
d700b485 | 255 | { |
baa9d179 | 256 | pp_comma (pp); |
257 | pp_space (pp); | |
d700b485 | 258 | } |
8eb81823 | 259 | wrote_arg = true; |
baa9d179 | 260 | dump_generic_node (pp, TREE_VALUE (arg), spc, flags, false); |
8eb81823 | 261 | arg = TREE_CHAIN (arg); |
d700b485 | 262 | } |
263 | ||
8eb81823 | 264 | /* Drop the trailing void_type_node if we had any previous argument. */ |
265 | if (arg == void_list_node && !wrote_arg) | |
baa9d179 | 266 | pp_string (pp, "void"); |
8eb81823 | 267 | /* Properly dump vararg function types. */ |
268 | else if (!arg && wrote_arg) | |
baa9d179 | 269 | pp_string (pp, ", ..."); |
8eb81823 | 270 | /* Avoid printing any arg for unprototyped functions. */ |
d700b485 | 271 | |
baa9d179 | 272 | pp_right_paren (pp); |
d700b485 | 273 | } |
274 | ||
9b1a6180 | 275 | /* Dump the domain associated with an array. */ |
276 | ||
277 | static void | |
baa9d179 | 278 | dump_array_domain (pretty_printer *pp, tree domain, int spc, int flags) |
9b1a6180 | 279 | { |
baa9d179 | 280 | pp_left_bracket (pp); |
9b1a6180 | 281 | if (domain) |
282 | { | |
283 | tree min = TYPE_MIN_VALUE (domain); | |
284 | tree max = TYPE_MAX_VALUE (domain); | |
285 | ||
286 | if (min && max | |
287 | && integer_zerop (min) | |
e913b5cd | 288 | && tree_fits_shwi_p (max)) |
baa9d179 | 289 | pp_wide_integer (pp, tree_to_shwi (max) + 1); |
9b1a6180 | 290 | else |
291 | { | |
292 | if (min) | |
baa9d179 | 293 | dump_generic_node (pp, min, spc, flags, false); |
294 | pp_colon (pp); | |
9b1a6180 | 295 | if (max) |
baa9d179 | 296 | dump_generic_node (pp, max, spc, flags, false); |
9b1a6180 | 297 | } |
298 | } | |
299 | else | |
baa9d179 | 300 | pp_string (pp, "<unknown>"); |
301 | pp_right_bracket (pp); | |
9b1a6180 | 302 | } |
303 | ||
55d6e7cd | 304 | |
baa9d179 | 305 | /* Dump OpenMP clause CLAUSE. PP, CLAUSE, SPC and FLAGS are as in |
55d6e7cd | 306 | dump_generic_node. */ |
1e8e9920 | 307 | |
308 | static void | |
baa9d179 | 309 | dump_omp_clause (pretty_printer *pp, tree clause, int spc, int flags) |
1e8e9920 | 310 | { |
311 | const char *name; | |
312 | ||
55d6e7cd | 313 | switch (OMP_CLAUSE_CODE (clause)) |
1e8e9920 | 314 | { |
55d6e7cd | 315 | case OMP_CLAUSE_PRIVATE: |
316 | name = "private"; | |
317 | goto print_remap; | |
318 | case OMP_CLAUSE_SHARED: | |
319 | name = "shared"; | |
320 | goto print_remap; | |
321 | case OMP_CLAUSE_FIRSTPRIVATE: | |
322 | name = "firstprivate"; | |
323 | goto print_remap; | |
324 | case OMP_CLAUSE_LASTPRIVATE: | |
325 | name = "lastprivate"; | |
326 | goto print_remap; | |
327 | case OMP_CLAUSE_COPYIN: | |
328 | name = "copyin"; | |
329 | goto print_remap; | |
330 | case OMP_CLAUSE_COPYPRIVATE: | |
331 | name = "copyprivate"; | |
332 | goto print_remap; | |
3d483a94 | 333 | case OMP_CLAUSE_UNIFORM: |
334 | name = "uniform"; | |
335 | goto print_remap; | |
bc7bff74 | 336 | case OMP_CLAUSE__LOOPTEMP_: |
337 | name = "_looptemp_"; | |
338 | goto print_remap; | |
ca4c3545 | 339 | case OMP_CLAUSE_DEVICE_RESIDENT: |
340 | name = "device_resident"; | |
341 | goto print_remap; | |
342 | case OMP_CLAUSE_USE_DEVICE: | |
343 | name = "use_device"; | |
344 | goto print_remap; | |
55d6e7cd | 345 | print_remap: |
baa9d179 | 346 | pp_string (pp, name); |
347 | pp_left_paren (pp); | |
348 | dump_generic_node (pp, OMP_CLAUSE_DECL (clause), | |
3d483a94 | 349 | spc, flags, false); |
baa9d179 | 350 | pp_right_paren (pp); |
55d6e7cd | 351 | break; |
1e8e9920 | 352 | |
55d6e7cd | 353 | case OMP_CLAUSE_REDUCTION: |
baa9d179 | 354 | pp_string (pp, "reduction("); |
bc7bff74 | 355 | if (OMP_CLAUSE_REDUCTION_CODE (clause) != ERROR_MARK) |
356 | { | |
baa9d179 | 357 | pp_string (pp, |
bc7bff74 | 358 | op_symbol_code (OMP_CLAUSE_REDUCTION_CODE (clause))); |
baa9d179 | 359 | pp_colon (pp); |
bc7bff74 | 360 | } |
baa9d179 | 361 | dump_generic_node (pp, OMP_CLAUSE_DECL (clause), |
bc7bff74 | 362 | spc, flags, false); |
baa9d179 | 363 | pp_right_paren (pp); |
55d6e7cd | 364 | break; |
1e8e9920 | 365 | |
55d6e7cd | 366 | case OMP_CLAUSE_IF: |
baa9d179 | 367 | pp_string (pp, "if("); |
368 | dump_generic_node (pp, OMP_CLAUSE_IF_EXPR (clause), | |
bc7bff74 | 369 | spc, flags, false); |
baa9d179 | 370 | pp_right_paren (pp); |
55d6e7cd | 371 | break; |
1e8e9920 | 372 | |
55d6e7cd | 373 | case OMP_CLAUSE_NUM_THREADS: |
baa9d179 | 374 | pp_string (pp, "num_threads("); |
375 | dump_generic_node (pp, OMP_CLAUSE_NUM_THREADS_EXPR (clause), | |
bc7bff74 | 376 | spc, flags, false); |
baa9d179 | 377 | pp_right_paren (pp); |
55d6e7cd | 378 | break; |
1e8e9920 | 379 | |
40750995 | 380 | case OMP_CLAUSE__CILK_FOR_COUNT_: |
baa9d179 | 381 | pp_string (pp, "_Cilk_for_count_("); |
382 | dump_generic_node (pp, OMP_CLAUSE_OPERAND (clause, 0), | |
40750995 | 383 | spc, flags, false); |
baa9d179 | 384 | pp_right_paren (pp); |
40750995 | 385 | break; |
386 | ||
55d6e7cd | 387 | case OMP_CLAUSE_NOWAIT: |
baa9d179 | 388 | pp_string (pp, "nowait"); |
55d6e7cd | 389 | break; |
390 | case OMP_CLAUSE_ORDERED: | |
baa9d179 | 391 | pp_string (pp, "ordered"); |
55d6e7cd | 392 | break; |
1e8e9920 | 393 | |
55d6e7cd | 394 | case OMP_CLAUSE_DEFAULT: |
baa9d179 | 395 | pp_string (pp, "default("); |
55d6e7cd | 396 | switch (OMP_CLAUSE_DEFAULT_KIND (clause)) |
397 | { | |
fd6481cf | 398 | case OMP_CLAUSE_DEFAULT_UNSPECIFIED: |
399 | break; | |
400 | case OMP_CLAUSE_DEFAULT_SHARED: | |
baa9d179 | 401 | pp_string (pp, "shared"); |
fd6481cf | 402 | break; |
403 | case OMP_CLAUSE_DEFAULT_NONE: | |
baa9d179 | 404 | pp_string (pp, "none"); |
fd6481cf | 405 | break; |
406 | case OMP_CLAUSE_DEFAULT_PRIVATE: | |
baa9d179 | 407 | pp_string (pp, "private"); |
fd6481cf | 408 | break; |
409 | case OMP_CLAUSE_DEFAULT_FIRSTPRIVATE: | |
baa9d179 | 410 | pp_string (pp, "firstprivate"); |
fd6481cf | 411 | break; |
412 | default: | |
413 | gcc_unreachable (); | |
55d6e7cd | 414 | } |
baa9d179 | 415 | pp_right_paren (pp); |
55d6e7cd | 416 | break; |
1e8e9920 | 417 | |
55d6e7cd | 418 | case OMP_CLAUSE_SCHEDULE: |
baa9d179 | 419 | pp_string (pp, "schedule("); |
55d6e7cd | 420 | switch (OMP_CLAUSE_SCHEDULE_KIND (clause)) |
421 | { | |
bc7bff74 | 422 | case OMP_CLAUSE_SCHEDULE_STATIC: |
baa9d179 | 423 | pp_string (pp, "static"); |
bc7bff74 | 424 | break; |
425 | case OMP_CLAUSE_SCHEDULE_DYNAMIC: | |
baa9d179 | 426 | pp_string (pp, "dynamic"); |
bc7bff74 | 427 | break; |
428 | case OMP_CLAUSE_SCHEDULE_GUIDED: | |
baa9d179 | 429 | pp_string (pp, "guided"); |
bc7bff74 | 430 | break; |
431 | case OMP_CLAUSE_SCHEDULE_RUNTIME: | |
baa9d179 | 432 | pp_string (pp, "runtime"); |
bc7bff74 | 433 | break; |
434 | case OMP_CLAUSE_SCHEDULE_AUTO: | |
baa9d179 | 435 | pp_string (pp, "auto"); |
bc7bff74 | 436 | break; |
40750995 | 437 | case OMP_CLAUSE_SCHEDULE_CILKFOR: |
baa9d179 | 438 | pp_string (pp, "cilk-for grain"); |
40750995 | 439 | break; |
bc7bff74 | 440 | default: |
441 | gcc_unreachable (); | |
1e8e9920 | 442 | } |
55d6e7cd | 443 | if (OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause)) |
444 | { | |
baa9d179 | 445 | pp_comma (pp); |
446 | dump_generic_node (pp, OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause), | |
bc7bff74 | 447 | spc, flags, false); |
55d6e7cd | 448 | } |
baa9d179 | 449 | pp_right_paren (pp); |
55d6e7cd | 450 | break; |
451 | ||
fd6481cf | 452 | case OMP_CLAUSE_UNTIED: |
baa9d179 | 453 | pp_string (pp, "untied"); |
fd6481cf | 454 | break; |
455 | ||
456 | case OMP_CLAUSE_COLLAPSE: | |
baa9d179 | 457 | pp_string (pp, "collapse("); |
458 | dump_generic_node (pp, OMP_CLAUSE_COLLAPSE_EXPR (clause), | |
fd6481cf | 459 | spc, flags, false); |
baa9d179 | 460 | pp_right_paren (pp); |
fd6481cf | 461 | break; |
462 | ||
2169f33b | 463 | case OMP_CLAUSE_FINAL: |
baa9d179 | 464 | pp_string (pp, "final("); |
465 | dump_generic_node (pp, OMP_CLAUSE_FINAL_EXPR (clause), | |
bc7bff74 | 466 | spc, flags, false); |
baa9d179 | 467 | pp_right_paren (pp); |
2169f33b | 468 | break; |
469 | ||
470 | case OMP_CLAUSE_MERGEABLE: | |
baa9d179 | 471 | pp_string (pp, "mergeable"); |
2169f33b | 472 | break; |
473 | ||
3d483a94 | 474 | case OMP_CLAUSE_LINEAR: |
baa9d179 | 475 | pp_string (pp, "linear("); |
476 | dump_generic_node (pp, OMP_CLAUSE_DECL (clause), | |
3d483a94 | 477 | spc, flags, false); |
baa9d179 | 478 | pp_colon (pp); |
479 | dump_generic_node (pp, OMP_CLAUSE_LINEAR_STEP (clause), | |
3d483a94 | 480 | spc, flags, false); |
baa9d179 | 481 | pp_right_paren (pp); |
bc7bff74 | 482 | break; |
483 | ||
484 | case OMP_CLAUSE_ALIGNED: | |
baa9d179 | 485 | pp_string (pp, "aligned("); |
486 | dump_generic_node (pp, OMP_CLAUSE_DECL (clause), | |
bc7bff74 | 487 | spc, flags, false); |
488 | if (OMP_CLAUSE_ALIGNED_ALIGNMENT (clause)) | |
489 | { | |
baa9d179 | 490 | pp_colon (pp); |
491 | dump_generic_node (pp, OMP_CLAUSE_ALIGNED_ALIGNMENT (clause), | |
bc7bff74 | 492 | spc, flags, false); |
493 | } | |
baa9d179 | 494 | pp_right_paren (pp); |
bc7bff74 | 495 | break; |
496 | ||
497 | case OMP_CLAUSE_DEPEND: | |
baa9d179 | 498 | pp_string (pp, "depend("); |
bc7bff74 | 499 | switch (OMP_CLAUSE_DEPEND_KIND (clause)) |
500 | { | |
501 | case OMP_CLAUSE_DEPEND_IN: | |
baa9d179 | 502 | pp_string (pp, "in"); |
bc7bff74 | 503 | break; |
504 | case OMP_CLAUSE_DEPEND_OUT: | |
baa9d179 | 505 | pp_string (pp, "out"); |
bc7bff74 | 506 | break; |
507 | case OMP_CLAUSE_DEPEND_INOUT: | |
baa9d179 | 508 | pp_string (pp, "inout"); |
bc7bff74 | 509 | break; |
510 | default: | |
511 | gcc_unreachable (); | |
512 | } | |
baa9d179 | 513 | pp_colon (pp); |
514 | dump_generic_node (pp, OMP_CLAUSE_DECL (clause), | |
bc7bff74 | 515 | spc, flags, false); |
baa9d179 | 516 | pp_right_paren (pp); |
bc7bff74 | 517 | break; |
518 | ||
519 | case OMP_CLAUSE_MAP: | |
baa9d179 | 520 | pp_string (pp, "map("); |
bc7bff74 | 521 | switch (OMP_CLAUSE_MAP_KIND (clause)) |
522 | { | |
ca4c3545 | 523 | case GOMP_MAP_ALLOC: |
524 | case GOMP_MAP_POINTER: | |
baa9d179 | 525 | pp_string (pp, "alloc"); |
bc7bff74 | 526 | break; |
ca4c3545 | 527 | case GOMP_MAP_TO: |
528 | case GOMP_MAP_TO_PSET: | |
baa9d179 | 529 | pp_string (pp, "to"); |
bc7bff74 | 530 | break; |
ca4c3545 | 531 | case GOMP_MAP_FROM: |
baa9d179 | 532 | pp_string (pp, "from"); |
bc7bff74 | 533 | break; |
ca4c3545 | 534 | case GOMP_MAP_TOFROM: |
baa9d179 | 535 | pp_string (pp, "tofrom"); |
bc7bff74 | 536 | break; |
ca4c3545 | 537 | case GOMP_MAP_FORCE_ALLOC: |
538 | pp_string (pp, "force_alloc"); | |
539 | break; | |
540 | case GOMP_MAP_FORCE_TO: | |
541 | pp_string (pp, "force_to"); | |
542 | break; | |
543 | case GOMP_MAP_FORCE_FROM: | |
544 | pp_string (pp, "force_from"); | |
545 | break; | |
546 | case GOMP_MAP_FORCE_TOFROM: | |
547 | pp_string (pp, "force_tofrom"); | |
548 | break; | |
549 | case GOMP_MAP_FORCE_PRESENT: | |
550 | pp_string (pp, "force_present"); | |
551 | break; | |
552 | case GOMP_MAP_FORCE_DEALLOC: | |
553 | pp_string (pp, "force_dealloc"); | |
554 | break; | |
555 | case GOMP_MAP_FORCE_DEVICEPTR: | |
556 | pp_string (pp, "force_deviceptr"); | |
557 | break; | |
bc7bff74 | 558 | default: |
559 | gcc_unreachable (); | |
560 | } | |
baa9d179 | 561 | pp_colon (pp); |
562 | dump_generic_node (pp, OMP_CLAUSE_DECL (clause), | |
bc7bff74 | 563 | spc, flags, false); |
564 | print_clause_size: | |
565 | if (OMP_CLAUSE_SIZE (clause)) | |
566 | { | |
567 | if (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_MAP | |
ca4c3545 | 568 | && OMP_CLAUSE_MAP_KIND (clause) == GOMP_MAP_POINTER) |
baa9d179 | 569 | pp_string (pp, " [pointer assign, bias: "); |
691447ab | 570 | else if (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_MAP |
ca4c3545 | 571 | && OMP_CLAUSE_MAP_KIND (clause) == GOMP_MAP_TO_PSET) |
baa9d179 | 572 | pp_string (pp, " [pointer set, len: "); |
bc7bff74 | 573 | else |
baa9d179 | 574 | pp_string (pp, " [len: "); |
575 | dump_generic_node (pp, OMP_CLAUSE_SIZE (clause), | |
bc7bff74 | 576 | spc, flags, false); |
baa9d179 | 577 | pp_right_bracket (pp); |
bc7bff74 | 578 | } |
baa9d179 | 579 | pp_right_paren (pp); |
bc7bff74 | 580 | break; |
581 | ||
582 | case OMP_CLAUSE_FROM: | |
baa9d179 | 583 | pp_string (pp, "from("); |
584 | dump_generic_node (pp, OMP_CLAUSE_DECL (clause), | |
bc7bff74 | 585 | spc, flags, false); |
586 | goto print_clause_size; | |
587 | ||
588 | case OMP_CLAUSE_TO: | |
baa9d179 | 589 | pp_string (pp, "to("); |
590 | dump_generic_node (pp, OMP_CLAUSE_DECL (clause), | |
bc7bff74 | 591 | spc, flags, false); |
592 | goto print_clause_size; | |
593 | ||
ca4c3545 | 594 | case OMP_CLAUSE__CACHE_: |
595 | pp_string (pp, "("); | |
596 | dump_generic_node (pp, OMP_CLAUSE_DECL (clause), | |
597 | spc, flags, false); | |
598 | goto print_clause_size; | |
599 | ||
bc7bff74 | 600 | case OMP_CLAUSE_NUM_TEAMS: |
baa9d179 | 601 | pp_string (pp, "num_teams("); |
602 | dump_generic_node (pp, OMP_CLAUSE_NUM_TEAMS_EXPR (clause), | |
bc7bff74 | 603 | spc, flags, false); |
baa9d179 | 604 | pp_right_paren (pp); |
bc7bff74 | 605 | break; |
606 | ||
607 | case OMP_CLAUSE_THREAD_LIMIT: | |
baa9d179 | 608 | pp_string (pp, "thread_limit("); |
609 | dump_generic_node (pp, OMP_CLAUSE_THREAD_LIMIT_EXPR (clause), | |
bc7bff74 | 610 | spc, flags, false); |
baa9d179 | 611 | pp_right_paren (pp); |
bc7bff74 | 612 | break; |
613 | ||
614 | case OMP_CLAUSE_DEVICE: | |
baa9d179 | 615 | pp_string (pp, "device("); |
616 | dump_generic_node (pp, OMP_CLAUSE_DEVICE_ID (clause), | |
bc7bff74 | 617 | spc, flags, false); |
baa9d179 | 618 | pp_right_paren (pp); |
bc7bff74 | 619 | break; |
620 | ||
621 | case OMP_CLAUSE_DIST_SCHEDULE: | |
baa9d179 | 622 | pp_string (pp, "dist_schedule(static"); |
bc7bff74 | 623 | if (OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause)) |
624 | { | |
baa9d179 | 625 | pp_comma (pp); |
626 | dump_generic_node (pp, | |
bc7bff74 | 627 | OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause), |
628 | spc, flags, false); | |
629 | } | |
baa9d179 | 630 | pp_right_paren (pp); |
bc7bff74 | 631 | break; |
632 | ||
633 | case OMP_CLAUSE_PROC_BIND: | |
baa9d179 | 634 | pp_string (pp, "proc_bind("); |
bc7bff74 | 635 | switch (OMP_CLAUSE_PROC_BIND_KIND (clause)) |
636 | { | |
637 | case OMP_CLAUSE_PROC_BIND_MASTER: | |
baa9d179 | 638 | pp_string (pp, "master"); |
bc7bff74 | 639 | break; |
640 | case OMP_CLAUSE_PROC_BIND_CLOSE: | |
baa9d179 | 641 | pp_string (pp, "close"); |
bc7bff74 | 642 | break; |
643 | case OMP_CLAUSE_PROC_BIND_SPREAD: | |
baa9d179 | 644 | pp_string (pp, "spread"); |
bc7bff74 | 645 | break; |
646 | default: | |
647 | gcc_unreachable (); | |
648 | } | |
baa9d179 | 649 | pp_right_paren (pp); |
3d483a94 | 650 | break; |
651 | ||
652 | case OMP_CLAUSE_SAFELEN: | |
baa9d179 | 653 | pp_string (pp, "safelen("); |
654 | dump_generic_node (pp, OMP_CLAUSE_SAFELEN_EXPR (clause), | |
3d483a94 | 655 | spc, flags, false); |
baa9d179 | 656 | pp_right_paren (pp); |
bc7bff74 | 657 | break; |
658 | ||
659 | case OMP_CLAUSE_SIMDLEN: | |
baa9d179 | 660 | pp_string (pp, "simdlen("); |
661 | dump_generic_node (pp, OMP_CLAUSE_SIMDLEN_EXPR (clause), | |
bc7bff74 | 662 | spc, flags, false); |
baa9d179 | 663 | pp_right_paren (pp); |
3d483a94 | 664 | break; |
665 | ||
666 | case OMP_CLAUSE__SIMDUID_: | |
baa9d179 | 667 | pp_string (pp, "_simduid_("); |
668 | dump_generic_node (pp, OMP_CLAUSE__SIMDUID__DECL (clause), | |
3d483a94 | 669 | spc, flags, false); |
baa9d179 | 670 | pp_right_paren (pp); |
bc7bff74 | 671 | break; |
672 | ||
ca4c3545 | 673 | case OMP_CLAUSE_GANG: |
674 | pp_string (pp, "gang"); | |
675 | if (OMP_CLAUSE_GANG_EXPR (clause) != NULL_TREE) | |
676 | { | |
677 | pp_string (pp, "(num: "); | |
678 | dump_generic_node (pp, OMP_CLAUSE_GANG_EXPR (clause), | |
679 | spc, flags, false); | |
680 | } | |
681 | if (OMP_CLAUSE_GANG_STATIC_EXPR (clause) != NULL_TREE) | |
682 | { | |
683 | if (OMP_CLAUSE_GANG_EXPR (clause) == NULL_TREE) | |
684 | pp_left_paren (pp); | |
685 | else | |
686 | pp_space (pp); | |
687 | pp_string (pp, "static:"); | |
688 | if (OMP_CLAUSE_GANG_STATIC_EXPR (clause) | |
689 | == integer_minus_one_node) | |
690 | pp_character (pp, '*'); | |
691 | else | |
692 | dump_generic_node (pp, OMP_CLAUSE_GANG_STATIC_EXPR (clause), | |
693 | spc, flags, false); | |
694 | } | |
695 | if (OMP_CLAUSE_GANG_EXPR (clause) != NULL_TREE | |
696 | || OMP_CLAUSE_GANG_STATIC_EXPR (clause) != NULL_TREE) | |
697 | pp_right_paren (pp); | |
698 | break; | |
699 | ||
700 | case OMP_CLAUSE_ASYNC: | |
701 | pp_string (pp, "async"); | |
702 | if (OMP_CLAUSE_ASYNC_EXPR (clause)) | |
703 | { | |
704 | pp_character(pp, '('); | |
705 | dump_generic_node (pp, OMP_CLAUSE_ASYNC_EXPR (clause), | |
706 | spc, flags, false); | |
707 | pp_character(pp, ')'); | |
708 | } | |
709 | break; | |
710 | ||
711 | case OMP_CLAUSE_AUTO: | |
712 | case OMP_CLAUSE_SEQ: | |
713 | pp_string (pp, omp_clause_code_name[OMP_CLAUSE_CODE (clause)]); | |
714 | break; | |
715 | ||
716 | case OMP_CLAUSE_WAIT: | |
717 | pp_string (pp, "wait("); | |
718 | dump_generic_node (pp, OMP_CLAUSE_WAIT_EXPR (clause), | |
719 | spc, flags, false); | |
720 | pp_character(pp, ')'); | |
721 | break; | |
722 | ||
723 | case OMP_CLAUSE_WORKER: | |
724 | pp_string (pp, "worker"); | |
725 | if (OMP_CLAUSE_WORKER_EXPR (clause) != NULL_TREE) | |
726 | { | |
727 | pp_left_paren (pp); | |
728 | dump_generic_node (pp, OMP_CLAUSE_WORKER_EXPR (clause), | |
729 | spc, flags, false); | |
730 | pp_right_paren (pp); | |
731 | } | |
732 | break; | |
733 | ||
734 | case OMP_CLAUSE_VECTOR: | |
735 | pp_string (pp, "vector"); | |
736 | if (OMP_CLAUSE_VECTOR_EXPR (clause) != NULL_TREE) | |
737 | { | |
738 | pp_left_paren (pp); | |
739 | dump_generic_node (pp, OMP_CLAUSE_VECTOR_EXPR (clause), | |
740 | spc, flags, false); | |
741 | pp_right_paren (pp); | |
742 | } | |
743 | break; | |
744 | ||
745 | case OMP_CLAUSE_NUM_GANGS: | |
746 | pp_string (pp, "num_gangs("); | |
747 | dump_generic_node (pp, OMP_CLAUSE_NUM_GANGS_EXPR (clause), | |
748 | spc, flags, false); | |
749 | pp_character (pp, ')'); | |
750 | break; | |
751 | ||
752 | case OMP_CLAUSE_NUM_WORKERS: | |
753 | pp_string (pp, "num_workers("); | |
754 | dump_generic_node (pp, OMP_CLAUSE_NUM_WORKERS_EXPR (clause), | |
755 | spc, flags, false); | |
756 | pp_character (pp, ')'); | |
757 | break; | |
758 | ||
759 | case OMP_CLAUSE_VECTOR_LENGTH: | |
760 | pp_string (pp, "vector_length("); | |
761 | dump_generic_node (pp, OMP_CLAUSE_VECTOR_LENGTH_EXPR (clause), | |
762 | spc, flags, false); | |
763 | pp_character (pp, ')'); | |
764 | break; | |
765 | ||
bc7bff74 | 766 | case OMP_CLAUSE_INBRANCH: |
baa9d179 | 767 | pp_string (pp, "inbranch"); |
bc7bff74 | 768 | break; |
769 | case OMP_CLAUSE_NOTINBRANCH: | |
baa9d179 | 770 | pp_string (pp, "notinbranch"); |
bc7bff74 | 771 | break; |
772 | case OMP_CLAUSE_FOR: | |
baa9d179 | 773 | pp_string (pp, "for"); |
bc7bff74 | 774 | break; |
775 | case OMP_CLAUSE_PARALLEL: | |
baa9d179 | 776 | pp_string (pp, "parallel"); |
bc7bff74 | 777 | break; |
778 | case OMP_CLAUSE_SECTIONS: | |
baa9d179 | 779 | pp_string (pp, "sections"); |
bc7bff74 | 780 | break; |
781 | case OMP_CLAUSE_TASKGROUP: | |
baa9d179 | 782 | pp_string (pp, "taskgroup"); |
3d483a94 | 783 | break; |
ca4c3545 | 784 | case OMP_CLAUSE_INDEPENDENT: |
785 | pp_string (pp, "independent"); | |
786 | break; | |
3d483a94 | 787 | |
55d6e7cd | 788 | default: |
789 | /* Should never happen. */ | |
baa9d179 | 790 | dump_generic_node (pp, clause, spc, flags, false); |
55d6e7cd | 791 | break; |
792 | } | |
793 | } | |
794 | ||
795 | ||
baa9d179 | 796 | /* Dump the list of OpenMP clauses. PP, SPC and FLAGS are as in |
55d6e7cd | 797 | dump_generic_node. */ |
798 | ||
75a70cf9 | 799 | void |
baa9d179 | 800 | dump_omp_clauses (pretty_printer *pp, tree clause, int spc, int flags) |
55d6e7cd | 801 | { |
802 | if (clause == NULL) | |
803 | return; | |
1e8e9920 | 804 | |
baa9d179 | 805 | pp_space (pp); |
55d6e7cd | 806 | while (1) |
807 | { | |
baa9d179 | 808 | dump_omp_clause (pp, clause, spc, flags); |
1e8e9920 | 809 | clause = OMP_CLAUSE_CHAIN (clause); |
810 | if (clause == NULL) | |
811 | return; | |
baa9d179 | 812 | pp_space (pp); |
1e8e9920 | 813 | } |
814 | } | |
815 | ||
55d6e7cd | 816 | |
baa9d179 | 817 | /* Dump location LOC to PP. */ |
7aa082e5 | 818 | |
e522a604 | 819 | void |
baa9d179 | 820 | dump_location (pretty_printer *pp, location_t loc) |
7aa082e5 | 821 | { |
822 | expanded_location xloc = expand_location (loc); | |
823 | ||
baa9d179 | 824 | pp_left_bracket (pp); |
7aa082e5 | 825 | if (xloc.file) |
826 | { | |
baa9d179 | 827 | pp_string (pp, xloc.file); |
828 | pp_string (pp, ":"); | |
7aa082e5 | 829 | } |
baa9d179 | 830 | pp_decimal_int (pp, xloc.line); |
831 | pp_colon (pp); | |
832 | pp_decimal_int (pp, xloc.column); | |
833 | pp_string (pp, "] "); | |
7aa082e5 | 834 | } |
835 | ||
836 | ||
baa9d179 | 837 | /* Dump lexical block BLOCK. PP, SPC and FLAGS are as in |
7aa082e5 | 838 | dump_generic_node. */ |
839 | ||
840 | static void | |
baa9d179 | 841 | dump_block_node (pretty_printer *pp, tree block, int spc, int flags) |
7aa082e5 | 842 | { |
843 | tree t; | |
844 | ||
baa9d179 | 845 | pp_printf (pp, "BLOCK #%d ", BLOCK_NUMBER (block)); |
7aa082e5 | 846 | |
847 | if (flags & TDF_ADDRESS) | |
baa9d179 | 848 | pp_printf (pp, "[%p] ", (void *) block); |
7aa082e5 | 849 | |
850 | if (BLOCK_ABSTRACT (block)) | |
baa9d179 | 851 | pp_string (pp, "[abstract] "); |
7aa082e5 | 852 | |
853 | if (TREE_ASM_WRITTEN (block)) | |
baa9d179 | 854 | pp_string (pp, "[written] "); |
7aa082e5 | 855 | |
856 | if (flags & TDF_SLIM) | |
857 | return; | |
858 | ||
859 | if (BLOCK_SOURCE_LOCATION (block)) | |
baa9d179 | 860 | dump_location (pp, BLOCK_SOURCE_LOCATION (block)); |
7aa082e5 | 861 | |
baa9d179 | 862 | newline_and_indent (pp, spc + 2); |
7aa082e5 | 863 | |
864 | if (BLOCK_SUPERCONTEXT (block)) | |
865 | { | |
baa9d179 | 866 | pp_string (pp, "SUPERCONTEXT: "); |
867 | dump_generic_node (pp, BLOCK_SUPERCONTEXT (block), 0, | |
7aa082e5 | 868 | flags | TDF_SLIM, false); |
baa9d179 | 869 | newline_and_indent (pp, spc + 2); |
7aa082e5 | 870 | } |
871 | ||
872 | if (BLOCK_SUBBLOCKS (block)) | |
873 | { | |
baa9d179 | 874 | pp_string (pp, "SUBBLOCKS: "); |
7aa082e5 | 875 | for (t = BLOCK_SUBBLOCKS (block); t; t = BLOCK_CHAIN (t)) |
876 | { | |
baa9d179 | 877 | dump_generic_node (pp, t, 0, flags | TDF_SLIM, false); |
878 | pp_space (pp); | |
7aa082e5 | 879 | } |
baa9d179 | 880 | newline_and_indent (pp, spc + 2); |
7aa082e5 | 881 | } |
882 | ||
883 | if (BLOCK_CHAIN (block)) | |
884 | { | |
baa9d179 | 885 | pp_string (pp, "SIBLINGS: "); |
7aa082e5 | 886 | for (t = BLOCK_CHAIN (block); t; t = BLOCK_CHAIN (t)) |
887 | { | |
baa9d179 | 888 | dump_generic_node (pp, t, 0, flags | TDF_SLIM, false); |
889 | pp_space (pp); | |
7aa082e5 | 890 | } |
baa9d179 | 891 | newline_and_indent (pp, spc + 2); |
7aa082e5 | 892 | } |
893 | ||
894 | if (BLOCK_VARS (block)) | |
895 | { | |
baa9d179 | 896 | pp_string (pp, "VARS: "); |
7aa082e5 | 897 | for (t = BLOCK_VARS (block); t; t = TREE_CHAIN (t)) |
898 | { | |
baa9d179 | 899 | dump_generic_node (pp, t, 0, flags, false); |
900 | pp_space (pp); | |
7aa082e5 | 901 | } |
baa9d179 | 902 | newline_and_indent (pp, spc + 2); |
7aa082e5 | 903 | } |
904 | ||
f1f41a6c | 905 | if (vec_safe_length (BLOCK_NONLOCALIZED_VARS (block)) > 0) |
7aa082e5 | 906 | { |
907 | unsigned i; | |
f1f41a6c | 908 | vec<tree, va_gc> *nlv = BLOCK_NONLOCALIZED_VARS (block); |
7aa082e5 | 909 | |
baa9d179 | 910 | pp_string (pp, "NONLOCALIZED_VARS: "); |
f1f41a6c | 911 | FOR_EACH_VEC_ELT (*nlv, i, t) |
7aa082e5 | 912 | { |
baa9d179 | 913 | dump_generic_node (pp, t, 0, flags, false); |
914 | pp_space (pp); | |
7aa082e5 | 915 | } |
baa9d179 | 916 | newline_and_indent (pp, spc + 2); |
7aa082e5 | 917 | } |
918 | ||
919 | if (BLOCK_ABSTRACT_ORIGIN (block)) | |
920 | { | |
baa9d179 | 921 | pp_string (pp, "ABSTRACT_ORIGIN: "); |
922 | dump_generic_node (pp, BLOCK_ABSTRACT_ORIGIN (block), 0, | |
7aa082e5 | 923 | flags | TDF_SLIM, false); |
baa9d179 | 924 | newline_and_indent (pp, spc + 2); |
7aa082e5 | 925 | } |
926 | ||
927 | if (BLOCK_FRAGMENT_ORIGIN (block)) | |
928 | { | |
baa9d179 | 929 | pp_string (pp, "FRAGMENT_ORIGIN: "); |
930 | dump_generic_node (pp, BLOCK_FRAGMENT_ORIGIN (block), 0, | |
7aa082e5 | 931 | flags | TDF_SLIM, false); |
baa9d179 | 932 | newline_and_indent (pp, spc + 2); |
7aa082e5 | 933 | } |
934 | ||
935 | if (BLOCK_FRAGMENT_CHAIN (block)) | |
936 | { | |
baa9d179 | 937 | pp_string (pp, "FRAGMENT_CHAIN: "); |
7aa082e5 | 938 | for (t = BLOCK_FRAGMENT_CHAIN (block); t; t = BLOCK_FRAGMENT_CHAIN (t)) |
939 | { | |
baa9d179 | 940 | dump_generic_node (pp, t, 0, flags | TDF_SLIM, false); |
941 | pp_space (pp); | |
7aa082e5 | 942 | } |
baa9d179 | 943 | newline_and_indent (pp, spc + 2); |
7aa082e5 | 944 | } |
945 | } | |
946 | ||
947 | ||
baa9d179 | 948 | /* Dump the node NODE on the pretty_printer PP, SPC spaces of |
46412a37 | 949 | indent. FLAGS specifies details to show in the dump (see TDF_* in |
b9ed1410 | 950 | dumpfile.h). If IS_STMT is true, the object printed is considered |
46412a37 | 951 | to be a statement and it is terminated by ';' if appropriate. */ |
4ee9c684 | 952 | |
953 | int | |
baa9d179 | 954 | dump_generic_node (pretty_printer *pp, tree node, int spc, int flags, |
4ee9c684 | 955 | bool is_stmt) |
956 | { | |
957 | tree type; | |
958 | tree op0, op1; | |
d700b485 | 959 | const char *str; |
4ee9c684 | 960 | bool is_expr; |
79a78f7f | 961 | enum tree_code code; |
4ee9c684 | 962 | |
963 | if (node == NULL_TREE) | |
964 | return spc; | |
965 | ||
75a70cf9 | 966 | is_expr = EXPR_P (node); |
4ee9c684 | 967 | |
22aa74c4 | 968 | if (is_stmt && (flags & TDF_STMTADDR)) |
baa9d179 | 969 | pp_printf (pp, "<&%p> ", (void *)node); |
22aa74c4 | 970 | |
1e8e9920 | 971 | if ((flags & TDF_LINENO) && EXPR_HAS_LOCATION (node)) |
baa9d179 | 972 | dump_location (pp, EXPR_LOCATION (node)); |
4ee9c684 | 973 | |
79a78f7f | 974 | code = TREE_CODE (node); |
975 | switch (code) | |
4ee9c684 | 976 | { |
977 | case ERROR_MARK: | |
baa9d179 | 978 | pp_string (pp, "<<< error >>>"); |
4ee9c684 | 979 | break; |
980 | ||
981 | case IDENTIFIER_NODE: | |
baa9d179 | 982 | pp_tree_identifier (pp, node); |
4ee9c684 | 983 | break; |
984 | ||
985 | case TREE_LIST: | |
986 | while (node && node != error_mark_node) | |
987 | { | |
988 | if (TREE_PURPOSE (node)) | |
989 | { | |
baa9d179 | 990 | dump_generic_node (pp, TREE_PURPOSE (node), spc, flags, false); |
991 | pp_space (pp); | |
4ee9c684 | 992 | } |
baa9d179 | 993 | dump_generic_node (pp, TREE_VALUE (node), spc, flags, false); |
4ee9c684 | 994 | node = TREE_CHAIN (node); |
995 | if (node && TREE_CODE (node) == TREE_LIST) | |
996 | { | |
baa9d179 | 997 | pp_comma (pp); |
998 | pp_space (pp); | |
4ee9c684 | 999 | } |
1000 | } | |
1001 | break; | |
1002 | ||
dce3d064 | 1003 | case TREE_BINFO: |
baa9d179 | 1004 | dump_generic_node (pp, BINFO_TYPE (node), spc, flags, false); |
c6934f8a | 1005 | break; |
dce3d064 | 1006 | |
1007 | case TREE_VEC: | |
1008 | { | |
1009 | size_t i; | |
1010 | if (TREE_VEC_LENGTH (node) > 0) | |
1011 | { | |
1012 | size_t len = TREE_VEC_LENGTH (node); | |
1013 | for (i = 0; i < len - 1; i++) | |
48e1416a | 1014 | { |
baa9d179 | 1015 | dump_generic_node (pp, TREE_VEC_ELT (node, i), spc, flags, |
dce3d064 | 1016 | false); |
baa9d179 | 1017 | pp_comma (pp); |
1018 | pp_space (pp); | |
dce3d064 | 1019 | } |
baa9d179 | 1020 | dump_generic_node (pp, TREE_VEC_ELT (node, len - 1), spc, |
dce3d064 | 1021 | flags, false); |
1022 | } | |
1023 | } | |
4ee9c684 | 1024 | break; |
1025 | ||
4ee9c684 | 1026 | case VOID_TYPE: |
058a1b7a | 1027 | case POINTER_BOUNDS_TYPE: |
4ee9c684 | 1028 | case INTEGER_TYPE: |
1029 | case REAL_TYPE: | |
06f0b99c | 1030 | case FIXED_POINT_TYPE: |
4ee9c684 | 1031 | case COMPLEX_TYPE: |
1032 | case VECTOR_TYPE: | |
1033 | case ENUMERAL_TYPE: | |
1034 | case BOOLEAN_TYPE: | |
4ee9c684 | 1035 | { |
1036 | unsigned int quals = TYPE_QUALS (node); | |
f4e36c33 | 1037 | enum tree_code_class tclass; |
4ee9c684 | 1038 | |
b560fabd | 1039 | if (quals & TYPE_QUAL_ATOMIC) |
baa9d179 | 1040 | pp_string (pp, "atomic "); |
4ee9c684 | 1041 | if (quals & TYPE_QUAL_CONST) |
baa9d179 | 1042 | pp_string (pp, "const "); |
4ee9c684 | 1043 | else if (quals & TYPE_QUAL_VOLATILE) |
baa9d179 | 1044 | pp_string (pp, "volatile "); |
4ee9c684 | 1045 | else if (quals & TYPE_QUAL_RESTRICT) |
baa9d179 | 1046 | pp_string (pp, "restrict "); |
4ee9c684 | 1047 | |
bd1a81f7 | 1048 | if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node))) |
1049 | { | |
baa9d179 | 1050 | pp_string (pp, "<address-space-"); |
1051 | pp_decimal_int (pp, TYPE_ADDR_SPACE (node)); | |
1052 | pp_string (pp, "> "); | |
bd1a81f7 | 1053 | } |
1054 | ||
f4e36c33 | 1055 | tclass = TREE_CODE_CLASS (TREE_CODE (node)); |
4ee9c684 | 1056 | |
f4e36c33 | 1057 | if (tclass == tcc_declaration) |
4ee9c684 | 1058 | { |
1059 | if (DECL_NAME (node)) | |
baa9d179 | 1060 | dump_decl_name (pp, node, flags); |
4ee9c684 | 1061 | else |
baa9d179 | 1062 | pp_string (pp, "<unnamed type decl>"); |
4ee9c684 | 1063 | } |
f4e36c33 | 1064 | else if (tclass == tcc_type) |
4ee9c684 | 1065 | { |
1066 | if (TYPE_NAME (node)) | |
1067 | { | |
1068 | if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE) | |
baa9d179 | 1069 | pp_tree_identifier (pp, TYPE_NAME (node)); |
4ee9c684 | 1070 | else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL |
1071 | && DECL_NAME (TYPE_NAME (node))) | |
baa9d179 | 1072 | dump_decl_name (pp, TYPE_NAME (node), flags); |
4ee9c684 | 1073 | else |
baa9d179 | 1074 | pp_string (pp, "<unnamed type>"); |
5d8f2392 | 1075 | } |
1076 | else if (TREE_CODE (node) == VECTOR_TYPE) | |
1077 | { | |
baa9d179 | 1078 | pp_string (pp, "vector"); |
1079 | pp_left_paren (pp); | |
1080 | pp_wide_integer (pp, TYPE_VECTOR_SUBPARTS (node)); | |
1081 | pp_string (pp, ") "); | |
1082 | dump_generic_node (pp, TREE_TYPE (node), spc, flags, false); | |
4ee9c684 | 1083 | } |
e4e0b898 | 1084 | else if (TREE_CODE (node) == INTEGER_TYPE) |
1085 | { | |
0177b1e3 | 1086 | if (TYPE_PRECISION (node) == CHAR_TYPE_SIZE) |
baa9d179 | 1087 | pp_string (pp, (TYPE_UNSIGNED (node) |
0177b1e3 | 1088 | ? "unsigned char" |
1089 | : "signed char")); | |
1090 | else if (TYPE_PRECISION (node) == SHORT_TYPE_SIZE) | |
baa9d179 | 1091 | pp_string (pp, (TYPE_UNSIGNED (node) |
0177b1e3 | 1092 | ? "unsigned short" |
1093 | : "signed short")); | |
1094 | else if (TYPE_PRECISION (node) == INT_TYPE_SIZE) | |
baa9d179 | 1095 | pp_string (pp, (TYPE_UNSIGNED (node) |
0177b1e3 | 1096 | ? "unsigned int" |
1097 | : "signed int")); | |
1098 | else if (TYPE_PRECISION (node) == LONG_TYPE_SIZE) | |
baa9d179 | 1099 | pp_string (pp, (TYPE_UNSIGNED (node) |
0177b1e3 | 1100 | ? "unsigned long" |
1101 | : "signed long")); | |
1102 | else if (TYPE_PRECISION (node) == LONG_LONG_TYPE_SIZE) | |
baa9d179 | 1103 | pp_string (pp, (TYPE_UNSIGNED (node) |
0177b1e3 | 1104 | ? "unsigned long long" |
1105 | : "signed long long")); | |
1106 | else if (TYPE_PRECISION (node) >= CHAR_TYPE_SIZE | |
69435ea2 | 1107 | && exact_log2 (TYPE_PRECISION (node)) != -1) |
0177b1e3 | 1108 | { |
baa9d179 | 1109 | pp_string (pp, (TYPE_UNSIGNED (node) ? "uint" : "int")); |
1110 | pp_decimal_int (pp, TYPE_PRECISION (node)); | |
1111 | pp_string (pp, "_t"); | |
0177b1e3 | 1112 | } |
1113 | else | |
1114 | { | |
baa9d179 | 1115 | pp_string (pp, (TYPE_UNSIGNED (node) |
0177b1e3 | 1116 | ? "<unnamed-unsigned:" |
1117 | : "<unnamed-signed:")); | |
baa9d179 | 1118 | pp_decimal_int (pp, TYPE_PRECISION (node)); |
1119 | pp_greater (pp); | |
0177b1e3 | 1120 | } |
e4e0b898 | 1121 | } |
c6934f8a | 1122 | else if (TREE_CODE (node) == COMPLEX_TYPE) |
1123 | { | |
baa9d179 | 1124 | pp_string (pp, "__complex__ "); |
1125 | dump_generic_node (pp, TREE_TYPE (node), spc, flags, false); | |
c6934f8a | 1126 | } |
1127 | else if (TREE_CODE (node) == REAL_TYPE) | |
1128 | { | |
baa9d179 | 1129 | pp_string (pp, "<float:"); |
1130 | pp_decimal_int (pp, TYPE_PRECISION (node)); | |
1131 | pp_greater (pp); | |
c6934f8a | 1132 | } |
1133 | else if (TREE_CODE (node) == FIXED_POINT_TYPE) | |
1134 | { | |
baa9d179 | 1135 | pp_string (pp, "<fixed-point-"); |
1136 | pp_string (pp, TYPE_SATURATING (node) ? "sat:" : "nonsat:"); | |
1137 | pp_decimal_int (pp, TYPE_PRECISION (node)); | |
1138 | pp_greater (pp); | |
c6934f8a | 1139 | } |
d91b94e0 | 1140 | else if (TREE_CODE (node) == VOID_TYPE) |
baa9d179 | 1141 | pp_string (pp, "void"); |
4ee9c684 | 1142 | else |
baa9d179 | 1143 | pp_string (pp, "<unnamed type>"); |
4ee9c684 | 1144 | } |
1145 | break; | |
1146 | } | |
1147 | ||
1148 | case POINTER_TYPE: | |
1149 | case REFERENCE_TYPE: | |
1150 | str = (TREE_CODE (node) == POINTER_TYPE ? "*" : "&"); | |
1151 | ||
c6934f8a | 1152 | if (TREE_TYPE (node) == NULL) |
1153 | { | |
baa9d179 | 1154 | pp_string (pp, str); |
1155 | pp_string (pp, "<null type>"); | |
c6934f8a | 1156 | } |
1157 | else if (TREE_CODE (TREE_TYPE (node)) == FUNCTION_TYPE) | |
4ee9c684 | 1158 | { |
1159 | tree fnode = TREE_TYPE (node); | |
d700b485 | 1160 | |
baa9d179 | 1161 | dump_generic_node (pp, TREE_TYPE (fnode), spc, flags, false); |
1162 | pp_space (pp); | |
1163 | pp_left_paren (pp); | |
1164 | pp_string (pp, str); | |
4ee9c684 | 1165 | if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node))) |
baa9d179 | 1166 | dump_decl_name (pp, TYPE_NAME (node), flags); |
12e18540 | 1167 | else if (flags & TDF_NOUID) |
baa9d179 | 1168 | pp_printf (pp, "<Txxxx>"); |
4ee9c684 | 1169 | else |
baa9d179 | 1170 | pp_printf (pp, "<T%x>", TYPE_UID (node)); |
4ee9c684 | 1171 | |
baa9d179 | 1172 | pp_right_paren (pp); |
1173 | dump_function_declaration (pp, fnode, spc, flags); | |
4ee9c684 | 1174 | } |
1175 | else | |
1176 | { | |
1177 | unsigned int quals = TYPE_QUALS (node); | |
1178 | ||
baa9d179 | 1179 | dump_generic_node (pp, TREE_TYPE (node), spc, flags, false); |
1180 | pp_space (pp); | |
1181 | pp_string (pp, str); | |
4ee9c684 | 1182 | |
1183 | if (quals & TYPE_QUAL_CONST) | |
baa9d179 | 1184 | pp_string (pp, " const"); |
d3828421 | 1185 | if (quals & TYPE_QUAL_VOLATILE) |
baa9d179 | 1186 | pp_string (pp, " volatile"); |
d3828421 | 1187 | if (quals & TYPE_QUAL_RESTRICT) |
baa9d179 | 1188 | pp_string (pp, " restrict"); |
90cea464 | 1189 | |
bd1a81f7 | 1190 | if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node))) |
1191 | { | |
baa9d179 | 1192 | pp_string (pp, " <address-space-"); |
1193 | pp_decimal_int (pp, TYPE_ADDR_SPACE (node)); | |
1194 | pp_greater (pp); | |
bd1a81f7 | 1195 | } |
1196 | ||
90cea464 | 1197 | if (TYPE_REF_CAN_ALIAS_ALL (node)) |
baa9d179 | 1198 | pp_string (pp, " {ref-all}"); |
4ee9c684 | 1199 | } |
1200 | break; | |
1201 | ||
1202 | case OFFSET_TYPE: | |
1203 | NIY; | |
1204 | break; | |
1205 | ||
182cf5a9 | 1206 | case MEM_REF: |
1207 | { | |
1208 | if (integer_zerop (TREE_OPERAND (node, 1)) | |
d6f21aeb | 1209 | /* Dump the types of INTEGER_CSTs explicitly, for we can't |
1210 | infer them and MEM_ATTR caching will share MEM_REFs | |
1211 | with differently-typed op0s. */ | |
1212 | && TREE_CODE (TREE_OPERAND (node, 0)) != INTEGER_CST | |
ff2d70df | 1213 | /* Released SSA_NAMES have no TREE_TYPE. */ |
1214 | && TREE_TYPE (TREE_OPERAND (node, 0)) != NULL_TREE | |
182cf5a9 | 1215 | /* Same pointer types, but ignoring POINTER_TYPE vs. |
1216 | REFERENCE_TYPE. */ | |
1217 | && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 0))) | |
1218 | == TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1)))) | |
1219 | && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 0))) | |
1220 | == TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 1)))) | |
1221 | && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 0))) | |
1222 | == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 1)))) | |
182cf5a9 | 1223 | /* Same value types ignoring qualifiers. */ |
1224 | && (TYPE_MAIN_VARIANT (TREE_TYPE (node)) | |
1225 | == TYPE_MAIN_VARIANT | |
62b0a610 | 1226 | (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1))))) |
1227 | && (!(flags & TDF_ALIAS) | |
1228 | || MR_DEPENDENCE_CLIQUE (node) == 0)) | |
182cf5a9 | 1229 | { |
1230 | if (TREE_CODE (TREE_OPERAND (node, 0)) != ADDR_EXPR) | |
1231 | { | |
baa9d179 | 1232 | pp_star (pp); |
1233 | dump_generic_node (pp, TREE_OPERAND (node, 0), | |
182cf5a9 | 1234 | spc, flags, false); |
1235 | } | |
1236 | else | |
baa9d179 | 1237 | dump_generic_node (pp, |
182cf5a9 | 1238 | TREE_OPERAND (TREE_OPERAND (node, 0), 0), |
1239 | spc, flags, false); | |
1240 | } | |
1241 | else | |
1242 | { | |
87b8feeb | 1243 | tree ptype; |
1244 | ||
baa9d179 | 1245 | pp_string (pp, "MEM["); |
1246 | pp_left_paren (pp); | |
87b8feeb | 1247 | ptype = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (node, 1))); |
baa9d179 | 1248 | dump_generic_node (pp, ptype, |
5db1bdc2 | 1249 | spc, flags | TDF_SLIM, false); |
baa9d179 | 1250 | pp_right_paren (pp); |
1251 | dump_generic_node (pp, TREE_OPERAND (node, 0), | |
182cf5a9 | 1252 | spc, flags, false); |
1253 | if (!integer_zerop (TREE_OPERAND (node, 1))) | |
1254 | { | |
baa9d179 | 1255 | pp_string (pp, " + "); |
1256 | dump_generic_node (pp, TREE_OPERAND (node, 1), | |
182cf5a9 | 1257 | spc, flags, false); |
1258 | } | |
62b0a610 | 1259 | if ((flags & TDF_ALIAS) |
1260 | && MR_DEPENDENCE_CLIQUE (node) != 0) | |
1261 | { | |
baa9d179 | 1262 | pp_string (pp, " clique "); |
1263 | pp_unsigned_wide_integer (pp, MR_DEPENDENCE_CLIQUE (node)); | |
1264 | pp_string (pp, " base "); | |
1265 | pp_unsigned_wide_integer (pp, MR_DEPENDENCE_BASE (node)); | |
62b0a610 | 1266 | } |
baa9d179 | 1267 | pp_right_bracket (pp); |
182cf5a9 | 1268 | } |
1269 | break; | |
1270 | } | |
1271 | ||
aed164c3 | 1272 | case TARGET_MEM_REF: |
1273 | { | |
1274 | const char *sep = ""; | |
1275 | tree tmp; | |
1276 | ||
baa9d179 | 1277 | pp_string (pp, "MEM["); |
aed164c3 | 1278 | |
28daba6f | 1279 | if (TREE_CODE (TMR_BASE (node)) == ADDR_EXPR) |
aed164c3 | 1280 | { |
baa9d179 | 1281 | pp_string (pp, sep); |
aed164c3 | 1282 | sep = ", "; |
baa9d179 | 1283 | pp_string (pp, "symbol: "); |
1284 | dump_generic_node (pp, TREE_OPERAND (TMR_BASE (node), 0), | |
e077c79b | 1285 | spc, flags, false); |
aed164c3 | 1286 | } |
28daba6f | 1287 | else |
1288 | { | |
baa9d179 | 1289 | pp_string (pp, sep); |
28daba6f | 1290 | sep = ", "; |
baa9d179 | 1291 | pp_string (pp, "base: "); |
1292 | dump_generic_node (pp, TMR_BASE (node), spc, flags, false); | |
28daba6f | 1293 | } |
1294 | tmp = TMR_INDEX2 (node); | |
aed164c3 | 1295 | if (tmp) |
1296 | { | |
baa9d179 | 1297 | pp_string (pp, sep); |
aed164c3 | 1298 | sep = ", "; |
baa9d179 | 1299 | pp_string (pp, "base: "); |
1300 | dump_generic_node (pp, tmp, spc, flags, false); | |
aed164c3 | 1301 | } |
1302 | tmp = TMR_INDEX (node); | |
1303 | if (tmp) | |
1304 | { | |
baa9d179 | 1305 | pp_string (pp, sep); |
aed164c3 | 1306 | sep = ", "; |
baa9d179 | 1307 | pp_string (pp, "index: "); |
1308 | dump_generic_node (pp, tmp, spc, flags, false); | |
aed164c3 | 1309 | } |
1310 | tmp = TMR_STEP (node); | |
1311 | if (tmp) | |
1312 | { | |
baa9d179 | 1313 | pp_string (pp, sep); |
aed164c3 | 1314 | sep = ", "; |
baa9d179 | 1315 | pp_string (pp, "step: "); |
1316 | dump_generic_node (pp, tmp, spc, flags, false); | |
aed164c3 | 1317 | } |
1318 | tmp = TMR_OFFSET (node); | |
1319 | if (tmp) | |
1320 | { | |
baa9d179 | 1321 | pp_string (pp, sep); |
aed164c3 | 1322 | sep = ", "; |
baa9d179 | 1323 | pp_string (pp, "offset: "); |
1324 | dump_generic_node (pp, tmp, spc, flags, false); | |
aed164c3 | 1325 | } |
baa9d179 | 1326 | pp_right_bracket (pp); |
aed164c3 | 1327 | } |
1328 | break; | |
1329 | ||
4ee9c684 | 1330 | case ARRAY_TYPE: |
1331 | { | |
1332 | tree tmp; | |
1333 | ||
a0cac6f5 | 1334 | /* Print the innermost component type. */ |
1335 | for (tmp = TREE_TYPE (node); TREE_CODE (tmp) == ARRAY_TYPE; | |
1336 | tmp = TREE_TYPE (tmp)) | |
1337 | ; | |
baa9d179 | 1338 | dump_generic_node (pp, tmp, spc, flags, false); |
4ee9c684 | 1339 | |
1340 | /* Print the dimensions. */ | |
9b1a6180 | 1341 | for (tmp = node; TREE_CODE (tmp) == ARRAY_TYPE; tmp = TREE_TYPE (tmp)) |
baa9d179 | 1342 | dump_array_domain (pp, TYPE_DOMAIN (tmp), spc, flags); |
4ee9c684 | 1343 | break; |
1344 | } | |
1345 | ||
4ee9c684 | 1346 | case RECORD_TYPE: |
1347 | case UNION_TYPE: | |
6374121b | 1348 | case QUAL_UNION_TYPE: |
d3828421 | 1349 | { |
1350 | unsigned int quals = TYPE_QUALS (node); | |
1351 | ||
b560fabd | 1352 | if (quals & TYPE_QUAL_ATOMIC) |
baa9d179 | 1353 | pp_string (pp, "atomic "); |
d3828421 | 1354 | if (quals & TYPE_QUAL_CONST) |
baa9d179 | 1355 | pp_string (pp, "const "); |
d3828421 | 1356 | if (quals & TYPE_QUAL_VOLATILE) |
baa9d179 | 1357 | pp_string (pp, "volatile "); |
d3828421 | 1358 | |
1359 | /* Print the name of the structure. */ | |
1360 | if (TREE_CODE (node) == RECORD_TYPE) | |
baa9d179 | 1361 | pp_string (pp, "struct "); |
d3828421 | 1362 | else if (TREE_CODE (node) == UNION_TYPE) |
baa9d179 | 1363 | pp_string (pp, "union "); |
d3828421 | 1364 | |
1365 | if (TYPE_NAME (node)) | |
baa9d179 | 1366 | dump_generic_node (pp, TYPE_NAME (node), spc, flags, false); |
c6934f8a | 1367 | else if (!(flags & TDF_SLIM)) |
1368 | /* FIXME: If we eliminate the 'else' above and attempt | |
1369 | to show the fields for named types, we may get stuck | |
1370 | following a cycle of pointers to structs. The alleged | |
1371 | self-reference check in print_struct_decl will not detect | |
1372 | cycles involving more than one pointer or struct type. */ | |
baa9d179 | 1373 | print_struct_decl (pp, node, spc, flags); |
d3828421 | 1374 | break; |
1375 | } | |
4ee9c684 | 1376 | |
4ee9c684 | 1377 | case LANG_TYPE: |
1378 | NIY; | |
1379 | break; | |
1380 | ||
1381 | case INTEGER_CST: | |
1382 | if (TREE_CODE (TREE_TYPE (node)) == POINTER_TYPE) | |
1383 | { | |
1384 | /* In the case of a pointer, one may want to divide by the | |
1385 | size of the pointed-to type. Unfortunately, this not | |
1386 | straightforward. The C front-end maps expressions | |
1387 | ||
1388 | (int *) 5 | |
1389 | int *p; (p + 5) | |
1390 | ||
1391 | in such a way that the two INTEGER_CST nodes for "5" have | |
1392 | different values but identical types. In the latter | |
1393 | case, the 5 is multiplied by sizeof (int) in c-common.c | |
1394 | (pointer_int_sum) to convert it to a byte address, and | |
1395 | yet the type of the node is left unchanged. Argh. What | |
1396 | is consistent though is that the number value corresponds | |
1397 | to bytes (UNITS) offset. | |
1398 | ||
1399 | NB: Neither of the following divisors can be trivially | |
1400 | used to recover the original literal: | |
1401 | ||
f9ae6f95 | 1402 | TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node))) |
4ee9c684 | 1403 | TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */ |
baa9d179 | 1404 | pp_wide_integer (pp, TREE_INT_CST_LOW (node)); |
1405 | pp_string (pp, "B"); /* pseudo-unit */ | |
4ee9c684 | 1406 | } |
e913b5cd | 1407 | else if (tree_fits_shwi_p (node)) |
baa9d179 | 1408 | pp_wide_integer (pp, tree_to_shwi (node)); |
e913b5cd | 1409 | else if (tree_fits_uhwi_p (node)) |
baa9d179 | 1410 | pp_unsigned_wide_integer (pp, tree_to_uhwi (node)); |
d066d69a | 1411 | else |
4ee9c684 | 1412 | { |
e913b5cd | 1413 | wide_int val = node; |
4ee9c684 | 1414 | |
796b6678 | 1415 | if (wi::neg_p (val, TYPE_SIGN (TREE_TYPE (node)))) |
4ee9c684 | 1416 | { |
baa9d179 | 1417 | pp_minus (pp); |
e913b5cd | 1418 | val = -val; |
4ee9c684 | 1419 | } |
baa9d179 | 1420 | print_hex (val, pp_buffer (pp)->digit_buffer); |
1421 | pp_string (pp, pp_buffer (pp)->digit_buffer); | |
4ee9c684 | 1422 | } |
823f6908 | 1423 | if (TREE_OVERFLOW (node)) |
baa9d179 | 1424 | pp_string (pp, "(OVF)"); |
4ee9c684 | 1425 | break; |
1426 | ||
1427 | case REAL_CST: | |
1428 | /* Code copied from print_node. */ | |
1429 | { | |
1430 | REAL_VALUE_TYPE d; | |
1431 | if (TREE_OVERFLOW (node)) | |
baa9d179 | 1432 | pp_string (pp, " overflow"); |
4ee9c684 | 1433 | |
1434 | #if !defined(REAL_IS_NOT_DOUBLE) || defined(REAL_ARITHMETIC) | |
1435 | d = TREE_REAL_CST (node); | |
1436 | if (REAL_VALUE_ISINF (d)) | |
baa9d179 | 1437 | pp_string (pp, REAL_VALUE_NEGATIVE (d) ? " -Inf" : " Inf"); |
4ee9c684 | 1438 | else if (REAL_VALUE_ISNAN (d)) |
baa9d179 | 1439 | pp_string (pp, " Nan"); |
4ee9c684 | 1440 | else |
1441 | { | |
1442 | char string[100]; | |
1443 | real_to_decimal (string, &d, sizeof (string), 0, 1); | |
baa9d179 | 1444 | pp_string (pp, string); |
4ee9c684 | 1445 | } |
1446 | #else | |
1447 | { | |
1448 | HOST_WIDE_INT i; | |
1449 | unsigned char *p = (unsigned char *) &TREE_REAL_CST (node); | |
baa9d179 | 1450 | pp_string (pp, "0x"); |
4ee9c684 | 1451 | for (i = 0; i < sizeof TREE_REAL_CST (node); i++) |
baa9d179 | 1452 | output_formatted_integer (pp, "%02x", *p++); |
4ee9c684 | 1453 | } |
1454 | #endif | |
1455 | break; | |
1456 | } | |
1457 | ||
06f0b99c | 1458 | case FIXED_CST: |
1459 | { | |
1460 | char string[100]; | |
1461 | fixed_to_decimal (string, TREE_FIXED_CST_PTR (node), sizeof (string)); | |
baa9d179 | 1462 | pp_string (pp, string); |
06f0b99c | 1463 | break; |
1464 | } | |
1465 | ||
4ee9c684 | 1466 | case COMPLEX_CST: |
baa9d179 | 1467 | pp_string (pp, "__complex__ ("); |
1468 | dump_generic_node (pp, TREE_REALPART (node), spc, flags, false); | |
1469 | pp_string (pp, ", "); | |
1470 | dump_generic_node (pp, TREE_IMAGPART (node), spc, flags, false); | |
1471 | pp_right_paren (pp); | |
4ee9c684 | 1472 | break; |
1473 | ||
1474 | case STRING_CST: | |
baa9d179 | 1475 | pp_string (pp, "\""); |
1476 | pretty_print_string (pp, TREE_STRING_POINTER (node)); | |
1477 | pp_string (pp, "\""); | |
4ee9c684 | 1478 | break; |
1479 | ||
1480 | case VECTOR_CST: | |
1481 | { | |
fadf62f4 | 1482 | unsigned i; |
baa9d179 | 1483 | pp_string (pp, "{ "); |
fadf62f4 | 1484 | for (i = 0; i < VECTOR_CST_NELTS (node); ++i) |
4ee9c684 | 1485 | { |
fadf62f4 | 1486 | if (i != 0) |
baa9d179 | 1487 | pp_string (pp, ", "); |
1488 | dump_generic_node (pp, VECTOR_CST_ELT (node, i), | |
fadf62f4 | 1489 | spc, flags, false); |
4ee9c684 | 1490 | } |
baa9d179 | 1491 | pp_string (pp, " }"); |
4ee9c684 | 1492 | } |
1493 | break; | |
1494 | ||
1495 | case FUNCTION_TYPE: | |
c6934f8a | 1496 | case METHOD_TYPE: |
baa9d179 | 1497 | dump_generic_node (pp, TREE_TYPE (node), spc, flags, false); |
1498 | pp_space (pp); | |
c6934f8a | 1499 | if (TREE_CODE (node) == METHOD_TYPE) |
1500 | { | |
1501 | if (TYPE_METHOD_BASETYPE (node)) | |
baa9d179 | 1502 | dump_decl_name (pp, TYPE_NAME (TYPE_METHOD_BASETYPE (node)), |
c6934f8a | 1503 | flags); |
1504 | else | |
baa9d179 | 1505 | pp_string (pp, "<null method basetype>"); |
1506 | pp_colon_colon (pp); | |
c6934f8a | 1507 | } |
1508 | if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node))) | |
baa9d179 | 1509 | dump_decl_name (pp, TYPE_NAME (node), flags); |
12e18540 | 1510 | else if (flags & TDF_NOUID) |
baa9d179 | 1511 | pp_printf (pp, "<Txxxx>"); |
c6934f8a | 1512 | else |
baa9d179 | 1513 | pp_printf (pp, "<T%x>", TYPE_UID (node)); |
1514 | dump_function_declaration (pp, node, spc, flags); | |
4ee9c684 | 1515 | break; |
1516 | ||
1517 | case FUNCTION_DECL: | |
1518 | case CONST_DECL: | |
baa9d179 | 1519 | dump_decl_name (pp, node, flags); |
4ee9c684 | 1520 | break; |
1521 | ||
1522 | case LABEL_DECL: | |
1523 | if (DECL_NAME (node)) | |
baa9d179 | 1524 | dump_decl_name (pp, node, flags); |
4ee9c684 | 1525 | else if (LABEL_DECL_UID (node) != -1) |
baa9d179 | 1526 | pp_printf (pp, "<L%d>", (int) LABEL_DECL_UID (node)); |
4ee9c684 | 1527 | else |
00753696 | 1528 | { |
1529 | if (flags & TDF_NOUID) | |
baa9d179 | 1530 | pp_string (pp, "<D.xxxx>"); |
00753696 | 1531 | else |
baa9d179 | 1532 | pp_printf (pp, "<D.%u>", DECL_UID (node)); |
00753696 | 1533 | } |
4ee9c684 | 1534 | break; |
1535 | ||
1536 | case TYPE_DECL: | |
7bd3dcc4 | 1537 | if (DECL_IS_BUILTIN (node)) |
4ee9c684 | 1538 | { |
1539 | /* Don't print the declaration of built-in types. */ | |
1540 | break; | |
1541 | } | |
1542 | if (DECL_NAME (node)) | |
baa9d179 | 1543 | dump_decl_name (pp, node, flags); |
5db1bdc2 | 1544 | else if (TYPE_NAME (TREE_TYPE (node)) != node) |
4ee9c684 | 1545 | { |
efa75d92 | 1546 | if ((TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE |
1547 | || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE) | |
1548 | && TYPE_METHODS (TREE_TYPE (node))) | |
4ee9c684 | 1549 | { |
1550 | /* The type is a c++ class: all structures have at least | |
0bed3869 | 1551 | 4 methods. */ |
baa9d179 | 1552 | pp_string (pp, "class "); |
1553 | dump_generic_node (pp, TREE_TYPE (node), spc, flags, false); | |
4ee9c684 | 1554 | } |
1555 | else | |
1556 | { | |
baa9d179 | 1557 | pp_string (pp, |
d700b485 | 1558 | (TREE_CODE (TREE_TYPE (node)) == UNION_TYPE |
1559 | ? "union" : "struct ")); | |
baa9d179 | 1560 | dump_generic_node (pp, TREE_TYPE (node), spc, flags, false); |
4ee9c684 | 1561 | } |
1562 | } | |
5db1bdc2 | 1563 | else |
baa9d179 | 1564 | pp_string (pp, "<anon>"); |
4ee9c684 | 1565 | break; |
1566 | ||
1567 | case VAR_DECL: | |
1568 | case PARM_DECL: | |
1569 | case FIELD_DECL: | |
688ff29b | 1570 | case DEBUG_EXPR_DECL: |
4ee9c684 | 1571 | case NAMESPACE_DECL: |
d95140de | 1572 | case NAMELIST_DECL: |
baa9d179 | 1573 | dump_decl_name (pp, node, flags); |
4ee9c684 | 1574 | break; |
1575 | ||
1576 | case RESULT_DECL: | |
baa9d179 | 1577 | pp_string (pp, "<retval>"); |
4ee9c684 | 1578 | break; |
1579 | ||
1580 | case COMPONENT_REF: | |
1581 | op0 = TREE_OPERAND (node, 0); | |
1582 | str = "."; | |
182cf5a9 | 1583 | if (op0 |
1584 | && (TREE_CODE (op0) == INDIRECT_REF | |
1585 | || (TREE_CODE (op0) == MEM_REF | |
1586 | && TREE_CODE (TREE_OPERAND (op0, 0)) != ADDR_EXPR | |
1587 | && integer_zerop (TREE_OPERAND (op0, 1)) | |
d6f21aeb | 1588 | /* Dump the types of INTEGER_CSTs explicitly, for we |
1589 | can't infer them and MEM_ATTR caching will share | |
1590 | MEM_REFs with differently-typed op0s. */ | |
1591 | && TREE_CODE (TREE_OPERAND (op0, 0)) != INTEGER_CST | |
ff2d70df | 1592 | /* Released SSA_NAMES have no TREE_TYPE. */ |
1593 | && TREE_TYPE (TREE_OPERAND (op0, 0)) != NULL_TREE | |
182cf5a9 | 1594 | /* Same pointer types, but ignoring POINTER_TYPE vs. |
1595 | REFERENCE_TYPE. */ | |
1596 | && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 0))) | |
1597 | == TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1)))) | |
1598 | && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 0))) | |
1599 | == TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 1)))) | |
1600 | && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 0))) | |
1601 | == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 1)))) | |
182cf5a9 | 1602 | /* Same value types ignoring qualifiers. */ |
1603 | && (TYPE_MAIN_VARIANT (TREE_TYPE (op0)) | |
1604 | == TYPE_MAIN_VARIANT | |
62b0a610 | 1605 | (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1))))) |
1606 | && MR_DEPENDENCE_CLIQUE (op0) == 0))) | |
4ee9c684 | 1607 | { |
1608 | op0 = TREE_OPERAND (op0, 0); | |
1609 | str = "->"; | |
1610 | } | |
1611 | if (op_prio (op0) < op_prio (node)) | |
baa9d179 | 1612 | pp_left_paren (pp); |
1613 | dump_generic_node (pp, op0, spc, flags, false); | |
4ee9c684 | 1614 | if (op_prio (op0) < op_prio (node)) |
baa9d179 | 1615 | pp_right_paren (pp); |
1616 | pp_string (pp, str); | |
1617 | dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false); | |
f6c33c78 | 1618 | op0 = component_ref_field_offset (node); |
1619 | if (op0 && TREE_CODE (op0) != INTEGER_CST) | |
6374121b | 1620 | { |
baa9d179 | 1621 | pp_string (pp, "{off: "); |
1622 | dump_generic_node (pp, op0, spc, flags, false); | |
1623 | pp_right_brace (pp); | |
6374121b | 1624 | } |
4ee9c684 | 1625 | break; |
1626 | ||
1627 | case BIT_FIELD_REF: | |
baa9d179 | 1628 | pp_string (pp, "BIT_FIELD_REF <"); |
1629 | dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false); | |
1630 | pp_string (pp, ", "); | |
1631 | dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false); | |
1632 | pp_string (pp, ", "); | |
1633 | dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false); | |
1634 | pp_greater (pp); | |
4ee9c684 | 1635 | break; |
1636 | ||
4ee9c684 | 1637 | case ARRAY_REF: |
6374121b | 1638 | case ARRAY_RANGE_REF: |
4ee9c684 | 1639 | op0 = TREE_OPERAND (node, 0); |
1640 | if (op_prio (op0) < op_prio (node)) | |
baa9d179 | 1641 | pp_left_paren (pp); |
1642 | dump_generic_node (pp, op0, spc, flags, false); | |
4ee9c684 | 1643 | if (op_prio (op0) < op_prio (node)) |
baa9d179 | 1644 | pp_right_paren (pp); |
1645 | pp_left_bracket (pp); | |
1646 | dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false); | |
6374121b | 1647 | if (TREE_CODE (node) == ARRAY_RANGE_REF) |
baa9d179 | 1648 | pp_string (pp, " ..."); |
1649 | pp_right_bracket (pp); | |
4ee9c684 | 1650 | |
1267d2b7 | 1651 | op0 = array_ref_low_bound (node); |
1652 | op1 = array_ref_element_size (node); | |
1653 | ||
1654 | if (!integer_zerop (op0) | |
a128a28f | 1655 | || TREE_OPERAND (node, 2) |
1656 | || TREE_OPERAND (node, 3)) | |
6374121b | 1657 | { |
baa9d179 | 1658 | pp_string (pp, "{lb: "); |
1659 | dump_generic_node (pp, op0, spc, flags, false); | |
1660 | pp_string (pp, " sz: "); | |
1661 | dump_generic_node (pp, op1, spc, flags, false); | |
1662 | pp_right_brace (pp); | |
6374121b | 1663 | } |
4ee9c684 | 1664 | break; |
1665 | ||
1666 | case CONSTRUCTOR: | |
1667 | { | |
c75b4594 | 1668 | unsigned HOST_WIDE_INT ix; |
1669 | tree field, val; | |
fe1fdd37 | 1670 | bool is_struct_init = false; |
1671 | bool is_array_init = false; | |
5de9d3ed | 1672 | widest_int curidx; |
baa9d179 | 1673 | pp_left_brace (pp); |
3c25489e | 1674 | if (TREE_CLOBBER_P (node)) |
baa9d179 | 1675 | pp_string (pp, "CLOBBER"); |
3c25489e | 1676 | else if (TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE |
1677 | || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE) | |
fe1fdd37 | 1678 | is_struct_init = true; |
1679 | else if (TREE_CODE (TREE_TYPE (node)) == ARRAY_TYPE | |
1680 | && TYPE_DOMAIN (TREE_TYPE (node)) | |
1681 | && TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node))) | |
1682 | && TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)))) | |
1683 | == INTEGER_CST) | |
1684 | { | |
1685 | tree minv = TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node))); | |
1686 | is_array_init = true; | |
5de9d3ed | 1687 | curidx = wi::to_widest (minv); |
fe1fdd37 | 1688 | } |
c75b4594 | 1689 | FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node), ix, field, val) |
4ee9c684 | 1690 | { |
fe1fdd37 | 1691 | if (field) |
4ee9c684 | 1692 | { |
fe1fdd37 | 1693 | if (is_struct_init) |
1694 | { | |
baa9d179 | 1695 | pp_dot (pp); |
1696 | dump_generic_node (pp, field, spc, flags, false); | |
1697 | pp_equal (pp); | |
fe1fdd37 | 1698 | } |
1699 | else if (is_array_init | |
1700 | && (TREE_CODE (field) != INTEGER_CST | |
5de9d3ed | 1701 | || curidx != wi::to_widest (field))) |
fe1fdd37 | 1702 | { |
baa9d179 | 1703 | pp_left_bracket (pp); |
fe1fdd37 | 1704 | if (TREE_CODE (field) == RANGE_EXPR) |
1705 | { | |
baa9d179 | 1706 | dump_generic_node (pp, TREE_OPERAND (field, 0), spc, |
fe1fdd37 | 1707 | flags, false); |
baa9d179 | 1708 | pp_string (pp, " ... "); |
1709 | dump_generic_node (pp, TREE_OPERAND (field, 1), spc, | |
fe1fdd37 | 1710 | flags, false); |
1711 | if (TREE_CODE (TREE_OPERAND (field, 1)) == INTEGER_CST) | |
5de9d3ed | 1712 | curidx = wi::to_widest (TREE_OPERAND (field, 1)); |
fe1fdd37 | 1713 | } |
1714 | else | |
baa9d179 | 1715 | dump_generic_node (pp, field, spc, flags, false); |
fe1fdd37 | 1716 | if (TREE_CODE (field) == INTEGER_CST) |
5de9d3ed | 1717 | curidx = wi::to_widest (field); |
baa9d179 | 1718 | pp_string (pp, "]="); |
fe1fdd37 | 1719 | } |
4ee9c684 | 1720 | } |
fe1fdd37 | 1721 | if (is_array_init) |
e913b5cd | 1722 | curidx += 1; |
4ee9c684 | 1723 | if (val && TREE_CODE (val) == ADDR_EXPR) |
1724 | if (TREE_CODE (TREE_OPERAND (val, 0)) == FUNCTION_DECL) | |
1725 | val = TREE_OPERAND (val, 0); | |
1726 | if (val && TREE_CODE (val) == FUNCTION_DECL) | |
baa9d179 | 1727 | dump_decl_name (pp, val, flags); |
4ee9c684 | 1728 | else |
baa9d179 | 1729 | dump_generic_node (pp, val, spc, flags, false); |
f1f41a6c | 1730 | if (ix != vec_safe_length (CONSTRUCTOR_ELTS (node)) - 1) |
4ee9c684 | 1731 | { |
baa9d179 | 1732 | pp_comma (pp); |
1733 | pp_space (pp); | |
4ee9c684 | 1734 | } |
1735 | } | |
baa9d179 | 1736 | pp_right_brace (pp); |
4ee9c684 | 1737 | } |
1738 | break; | |
1739 | ||
1740 | case COMPOUND_EXPR: | |
1741 | { | |
1742 | tree *tp; | |
1743 | if (flags & TDF_SLIM) | |
1744 | { | |
baa9d179 | 1745 | pp_string (pp, "<COMPOUND_EXPR>"); |
4ee9c684 | 1746 | break; |
1747 | } | |
1748 | ||
baa9d179 | 1749 | dump_generic_node (pp, TREE_OPERAND (node, 0), |
1e8e9920 | 1750 | spc, flags, !(flags & TDF_SLIM)); |
1751 | if (flags & TDF_SLIM) | |
baa9d179 | 1752 | newline_and_indent (pp, spc); |
4ee9c684 | 1753 | else |
1754 | { | |
baa9d179 | 1755 | pp_comma (pp); |
1756 | pp_space (pp); | |
4ee9c684 | 1757 | } |
1758 | ||
1759 | for (tp = &TREE_OPERAND (node, 1); | |
1760 | TREE_CODE (*tp) == COMPOUND_EXPR; | |
1761 | tp = &TREE_OPERAND (*tp, 1)) | |
1762 | { | |
baa9d179 | 1763 | dump_generic_node (pp, TREE_OPERAND (*tp, 0), |
1e8e9920 | 1764 | spc, flags, !(flags & TDF_SLIM)); |
1765 | if (flags & TDF_SLIM) | |
baa9d179 | 1766 | newline_and_indent (pp, spc); |
4ee9c684 | 1767 | else |
1768 | { | |
baa9d179 | 1769 | pp_comma (pp); |
1770 | pp_space (pp); | |
4ee9c684 | 1771 | } |
1772 | } | |
1773 | ||
baa9d179 | 1774 | dump_generic_node (pp, *tp, spc, flags, !(flags & TDF_SLIM)); |
4ee9c684 | 1775 | } |
1776 | break; | |
1777 | ||
1778 | case STATEMENT_LIST: | |
1779 | { | |
1780 | tree_stmt_iterator si; | |
1781 | bool first = true; | |
b27ac6b5 | 1782 | |
1e8e9920 | 1783 | if (flags & TDF_SLIM) |
4ee9c684 | 1784 | { |
baa9d179 | 1785 | pp_string (pp, "<STATEMENT_LIST>"); |
4ee9c684 | 1786 | break; |
1787 | } | |
1788 | ||
1789 | for (si = tsi_start (node); !tsi_end_p (si); tsi_next (&si)) | |
1790 | { | |
1791 | if (!first) | |
baa9d179 | 1792 | newline_and_indent (pp, spc); |
4ee9c684 | 1793 | else |
1794 | first = false; | |
baa9d179 | 1795 | dump_generic_node (pp, tsi_stmt (si), spc, flags, true); |
4ee9c684 | 1796 | } |
1797 | } | |
1798 | break; | |
1799 | ||
1800 | case MODIFY_EXPR: | |
1801 | case INIT_EXPR: | |
baa9d179 | 1802 | dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, |
35cc02b5 | 1803 | false); |
baa9d179 | 1804 | pp_space (pp); |
1805 | pp_equal (pp); | |
1806 | pp_space (pp); | |
1807 | dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, | |
35cc02b5 | 1808 | false); |
4ee9c684 | 1809 | break; |
1810 | ||
1811 | case TARGET_EXPR: | |
baa9d179 | 1812 | pp_string (pp, "TARGET_EXPR <"); |
1813 | dump_generic_node (pp, TARGET_EXPR_SLOT (node), spc, flags, false); | |
1814 | pp_comma (pp); | |
1815 | pp_space (pp); | |
1816 | dump_generic_node (pp, TARGET_EXPR_INITIAL (node), spc, flags, false); | |
1817 | pp_greater (pp); | |
4ee9c684 | 1818 | break; |
1819 | ||
d700b485 | 1820 | case DECL_EXPR: |
baa9d179 | 1821 | print_declaration (pp, DECL_EXPR_DECL (node), spc, flags); |
d700b485 | 1822 | is_stmt = false; |
1823 | break; | |
1824 | ||
4ee9c684 | 1825 | case COND_EXPR: |
0375a275 | 1826 | if (TREE_TYPE (node) == NULL || TREE_TYPE (node) == void_type_node) |
4ee9c684 | 1827 | { |
baa9d179 | 1828 | pp_string (pp, "if ("); |
1829 | dump_generic_node (pp, COND_EXPR_COND (node), spc, flags, false); | |
1830 | pp_right_paren (pp); | |
4ee9c684 | 1831 | /* The lowered cond_exprs should always be printed in full. */ |
1832 | if (COND_EXPR_THEN (node) | |
49377e21 | 1833 | && (IS_EMPTY_STMT (COND_EXPR_THEN (node)) |
1834 | || TREE_CODE (COND_EXPR_THEN (node)) == GOTO_EXPR) | |
4ee9c684 | 1835 | && COND_EXPR_ELSE (node) |
49377e21 | 1836 | && (IS_EMPTY_STMT (COND_EXPR_ELSE (node)) |
1837 | || TREE_CODE (COND_EXPR_ELSE (node)) == GOTO_EXPR)) | |
4ee9c684 | 1838 | { |
baa9d179 | 1839 | pp_space (pp); |
1840 | dump_generic_node (pp, COND_EXPR_THEN (node), | |
24f116a8 | 1841 | 0, flags, true); |
1842 | if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node))) | |
1843 | { | |
baa9d179 | 1844 | pp_string (pp, " else "); |
1845 | dump_generic_node (pp, COND_EXPR_ELSE (node), | |
24f116a8 | 1846 | 0, flags, true); |
1847 | } | |
4ee9c684 | 1848 | } |
1849 | else if (!(flags & TDF_SLIM)) | |
1850 | { | |
1851 | /* Output COND_EXPR_THEN. */ | |
1852 | if (COND_EXPR_THEN (node)) | |
1853 | { | |
baa9d179 | 1854 | newline_and_indent (pp, spc+2); |
1855 | pp_left_brace (pp); | |
1856 | newline_and_indent (pp, spc+4); | |
1857 | dump_generic_node (pp, COND_EXPR_THEN (node), spc+4, | |
4ee9c684 | 1858 | flags, true); |
baa9d179 | 1859 | newline_and_indent (pp, spc+2); |
1860 | pp_right_brace (pp); | |
4ee9c684 | 1861 | } |
1862 | ||
1863 | /* Output COND_EXPR_ELSE. */ | |
24f116a8 | 1864 | if (COND_EXPR_ELSE (node) |
1865 | && !IS_EMPTY_STMT (COND_EXPR_ELSE (node))) | |
4ee9c684 | 1866 | { |
baa9d179 | 1867 | newline_and_indent (pp, spc); |
1868 | pp_string (pp, "else"); | |
1869 | newline_and_indent (pp, spc+2); | |
1870 | pp_left_brace (pp); | |
1871 | newline_and_indent (pp, spc+4); | |
1872 | dump_generic_node (pp, COND_EXPR_ELSE (node), spc+4, | |
4ee9c684 | 1873 | flags, true); |
baa9d179 | 1874 | newline_and_indent (pp, spc+2); |
1875 | pp_right_brace (pp); | |
4ee9c684 | 1876 | } |
1877 | } | |
1878 | is_expr = false; | |
1879 | } | |
1880 | else | |
1881 | { | |
baa9d179 | 1882 | dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false); |
1883 | pp_space (pp); | |
1884 | pp_question (pp); | |
1885 | pp_space (pp); | |
1886 | dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false); | |
1887 | pp_space (pp); | |
1888 | pp_colon (pp); | |
1889 | pp_space (pp); | |
1890 | dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false); | |
4ee9c684 | 1891 | } |
1892 | break; | |
1893 | ||
1894 | case BIND_EXPR: | |
baa9d179 | 1895 | pp_left_brace (pp); |
4ee9c684 | 1896 | if (!(flags & TDF_SLIM)) |
1897 | { | |
1898 | if (BIND_EXPR_VARS (node)) | |
1899 | { | |
baa9d179 | 1900 | pp_newline (pp); |
4ee9c684 | 1901 | |
1767a056 | 1902 | for (op0 = BIND_EXPR_VARS (node); op0; op0 = DECL_CHAIN (op0)) |
4ee9c684 | 1903 | { |
baa9d179 | 1904 | print_declaration (pp, op0, spc+2, flags); |
1905 | pp_newline (pp); | |
4ee9c684 | 1906 | } |
1907 | } | |
1908 | ||
baa9d179 | 1909 | newline_and_indent (pp, spc+2); |
1910 | dump_generic_node (pp, BIND_EXPR_BODY (node), spc+2, flags, true); | |
1911 | newline_and_indent (pp, spc); | |
1912 | pp_right_brace (pp); | |
4ee9c684 | 1913 | } |
1914 | is_expr = false; | |
1915 | break; | |
1916 | ||
1917 | case CALL_EXPR: | |
5ef6b660 | 1918 | if (CALL_EXPR_FN (node) != NULL_TREE) |
baa9d179 | 1919 | print_call_name (pp, CALL_EXPR_FN (node), flags); |
5ef6b660 | 1920 | else |
baa9d179 | 1921 | pp_string (pp, internal_fn_name (CALL_EXPR_IFN (node))); |
4ee9c684 | 1922 | |
1923 | /* Print parameters. */ | |
baa9d179 | 1924 | pp_space (pp); |
1925 | pp_left_paren (pp); | |
c2f47e15 | 1926 | { |
1927 | tree arg; | |
1928 | call_expr_arg_iterator iter; | |
1929 | FOR_EACH_CALL_EXPR_ARG (arg, iter, node) | |
1930 | { | |
baa9d179 | 1931 | dump_generic_node (pp, arg, spc, flags, false); |
c2f47e15 | 1932 | if (more_call_expr_args_p (&iter)) |
1933 | { | |
baa9d179 | 1934 | pp_comma (pp); |
1935 | pp_space (pp); | |
c2f47e15 | 1936 | } |
1937 | } | |
1938 | } | |
48dc2227 | 1939 | if (CALL_EXPR_VA_ARG_PACK (node)) |
1940 | { | |
1941 | if (call_expr_nargs (node) > 0) | |
1942 | { | |
baa9d179 | 1943 | pp_comma (pp); |
1944 | pp_space (pp); | |
48dc2227 | 1945 | } |
baa9d179 | 1946 | pp_string (pp, "__builtin_va_arg_pack ()"); |
48dc2227 | 1947 | } |
baa9d179 | 1948 | pp_right_paren (pp); |
4ee9c684 | 1949 | |
c2f47e15 | 1950 | op1 = CALL_EXPR_STATIC_CHAIN (node); |
4ee9c684 | 1951 | if (op1) |
1952 | { | |
baa9d179 | 1953 | pp_string (pp, " [static-chain: "); |
1954 | dump_generic_node (pp, op1, spc, flags, false); | |
1955 | pp_right_bracket (pp); | |
4ee9c684 | 1956 | } |
1957 | ||
ea523851 | 1958 | if (CALL_EXPR_RETURN_SLOT_OPT (node)) |
baa9d179 | 1959 | pp_string (pp, " [return slot optimization]"); |
4ee9c684 | 1960 | if (CALL_EXPR_TAILCALL (node)) |
baa9d179 | 1961 | pp_string (pp, " [tail call]"); |
4ee9c684 | 1962 | break; |
1963 | ||
1964 | case WITH_CLEANUP_EXPR: | |
1965 | NIY; | |
1966 | break; | |
1967 | ||
1968 | case CLEANUP_POINT_EXPR: | |
baa9d179 | 1969 | pp_string (pp, "<<cleanup_point "); |
1970 | dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false); | |
1971 | pp_string (pp, ">>"); | |
4ee9c684 | 1972 | break; |
1973 | ||
1974 | case PLACEHOLDER_EXPR: | |
baa9d179 | 1975 | pp_string (pp, "<PLACEHOLDER_EXPR "); |
1976 | dump_generic_node (pp, TREE_TYPE (node), spc, flags, false); | |
1977 | pp_greater (pp); | |
4ee9c684 | 1978 | break; |
1979 | ||
1980 | /* Binary arithmetic and logic expressions. */ | |
4a61a337 | 1981 | case WIDEN_SUM_EXPR: |
1982 | case WIDEN_MULT_EXPR: | |
4ee9c684 | 1983 | case MULT_EXPR: |
96504875 | 1984 | case MULT_HIGHPART_EXPR: |
4ee9c684 | 1985 | case PLUS_EXPR: |
0de36bdb | 1986 | case POINTER_PLUS_EXPR: |
4ee9c684 | 1987 | case MINUS_EXPR: |
1988 | case TRUNC_DIV_EXPR: | |
1989 | case CEIL_DIV_EXPR: | |
1990 | case FLOOR_DIV_EXPR: | |
1991 | case ROUND_DIV_EXPR: | |
1992 | case TRUNC_MOD_EXPR: | |
1993 | case CEIL_MOD_EXPR: | |
1994 | case FLOOR_MOD_EXPR: | |
1995 | case ROUND_MOD_EXPR: | |
1996 | case RDIV_EXPR: | |
1997 | case EXACT_DIV_EXPR: | |
1998 | case LSHIFT_EXPR: | |
1999 | case RSHIFT_EXPR: | |
2000 | case LROTATE_EXPR: | |
2001 | case RROTATE_EXPR: | |
6083c152 | 2002 | case WIDEN_LSHIFT_EXPR: |
4ee9c684 | 2003 | case BIT_IOR_EXPR: |
2004 | case BIT_XOR_EXPR: | |
2005 | case BIT_AND_EXPR: | |
2006 | case TRUTH_ANDIF_EXPR: | |
2007 | case TRUTH_ORIF_EXPR: | |
2008 | case TRUTH_AND_EXPR: | |
2009 | case TRUTH_OR_EXPR: | |
2010 | case TRUTH_XOR_EXPR: | |
2011 | case LT_EXPR: | |
2012 | case LE_EXPR: | |
2013 | case GT_EXPR: | |
2014 | case GE_EXPR: | |
2015 | case EQ_EXPR: | |
2016 | case NE_EXPR: | |
2017 | case UNLT_EXPR: | |
2018 | case UNLE_EXPR: | |
2019 | case UNGT_EXPR: | |
2020 | case UNGE_EXPR: | |
2021 | case UNEQ_EXPR: | |
318a728f | 2022 | case LTGT_EXPR: |
2023 | case ORDERED_EXPR: | |
2024 | case UNORDERED_EXPR: | |
4ee9c684 | 2025 | { |
2026 | const char *op = op_symbol (node); | |
2027 | op0 = TREE_OPERAND (node, 0); | |
2028 | op1 = TREE_OPERAND (node, 1); | |
2029 | ||
2030 | /* When the operands are expressions with less priority, | |
2031 | keep semantics of the tree representation. */ | |
3814cd68 | 2032 | if (op_prio (op0) <= op_prio (node)) |
4ee9c684 | 2033 | { |
baa9d179 | 2034 | pp_left_paren (pp); |
2035 | dump_generic_node (pp, op0, spc, flags, false); | |
2036 | pp_right_paren (pp); | |
4ee9c684 | 2037 | } |
2038 | else | |
baa9d179 | 2039 | dump_generic_node (pp, op0, spc, flags, false); |
4ee9c684 | 2040 | |
baa9d179 | 2041 | pp_space (pp); |
2042 | pp_string (pp, op); | |
2043 | pp_space (pp); | |
4ee9c684 | 2044 | |
2045 | /* When the operands are expressions with less priority, | |
2046 | keep semantics of the tree representation. */ | |
3814cd68 | 2047 | if (op_prio (op1) <= op_prio (node)) |
4ee9c684 | 2048 | { |
baa9d179 | 2049 | pp_left_paren (pp); |
2050 | dump_generic_node (pp, op1, spc, flags, false); | |
2051 | pp_right_paren (pp); | |
4ee9c684 | 2052 | } |
2053 | else | |
baa9d179 | 2054 | dump_generic_node (pp, op1, spc, flags, false); |
4ee9c684 | 2055 | } |
2056 | break; | |
2057 | ||
2058 | /* Unary arithmetic and logic expressions. */ | |
2059 | case NEGATE_EXPR: | |
2060 | case BIT_NOT_EXPR: | |
2061 | case TRUTH_NOT_EXPR: | |
2062 | case ADDR_EXPR: | |
4ee9c684 | 2063 | case PREDECREMENT_EXPR: |
2064 | case PREINCREMENT_EXPR: | |
2065 | case INDIRECT_REF: | |
2066 | if (TREE_CODE (node) == ADDR_EXPR | |
2067 | && (TREE_CODE (TREE_OPERAND (node, 0)) == STRING_CST | |
2068 | || TREE_CODE (TREE_OPERAND (node, 0)) == FUNCTION_DECL)) | |
2069 | ; /* Do not output '&' for strings and function pointers. */ | |
2070 | else | |
baa9d179 | 2071 | pp_string (pp, op_symbol (node)); |
4ee9c684 | 2072 | |
2073 | if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node)) | |
2074 | { | |
baa9d179 | 2075 | pp_left_paren (pp); |
2076 | dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false); | |
2077 | pp_right_paren (pp); | |
4ee9c684 | 2078 | } |
2079 | else | |
baa9d179 | 2080 | dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false); |
4ee9c684 | 2081 | break; |
2082 | ||
2083 | case POSTDECREMENT_EXPR: | |
2084 | case POSTINCREMENT_EXPR: | |
2085 | if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node)) | |
2086 | { | |
baa9d179 | 2087 | pp_left_paren (pp); |
2088 | dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false); | |
2089 | pp_right_paren (pp); | |
4ee9c684 | 2090 | } |
2091 | else | |
baa9d179 | 2092 | dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false); |
2093 | pp_string (pp, op_symbol (node)); | |
4ee9c684 | 2094 | break; |
2095 | ||
2096 | case MIN_EXPR: | |
baa9d179 | 2097 | pp_string (pp, "MIN_EXPR <"); |
2098 | dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false); | |
2099 | pp_string (pp, ", "); | |
2100 | dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false); | |
2101 | pp_greater (pp); | |
4ee9c684 | 2102 | break; |
2103 | ||
2104 | case MAX_EXPR: | |
baa9d179 | 2105 | pp_string (pp, "MAX_EXPR <"); |
2106 | dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false); | |
2107 | pp_string (pp, ", "); | |
2108 | dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false); | |
2109 | pp_greater (pp); | |
4ee9c684 | 2110 | break; |
2111 | ||
2112 | case ABS_EXPR: | |
baa9d179 | 2113 | pp_string (pp, "ABS_EXPR <"); |
2114 | dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false); | |
2115 | pp_greater (pp); | |
4ee9c684 | 2116 | break; |
2117 | ||
4ee9c684 | 2118 | case RANGE_EXPR: |
2119 | NIY; | |
2120 | break; | |
2121 | ||
bd1a81f7 | 2122 | case ADDR_SPACE_CONVERT_EXPR: |
06f0b99c | 2123 | case FIXED_CONVERT_EXPR: |
4ee9c684 | 2124 | case FIX_TRUNC_EXPR: |
4ee9c684 | 2125 | case FLOAT_EXPR: |
72dd6141 | 2126 | CASE_CONVERT: |
4ee9c684 | 2127 | type = TREE_TYPE (node); |
2128 | op0 = TREE_OPERAND (node, 0); | |
2129 | if (type != TREE_TYPE (op0)) | |
2130 | { | |
baa9d179 | 2131 | pp_left_paren (pp); |
2132 | dump_generic_node (pp, type, spc, flags, false); | |
2133 | pp_string (pp, ") "); | |
4ee9c684 | 2134 | } |
2135 | if (op_prio (op0) < op_prio (node)) | |
baa9d179 | 2136 | pp_left_paren (pp); |
2137 | dump_generic_node (pp, op0, spc, flags, false); | |
4ee9c684 | 2138 | if (op_prio (op0) < op_prio (node)) |
baa9d179 | 2139 | pp_right_paren (pp); |
4ee9c684 | 2140 | break; |
2141 | ||
2142 | case VIEW_CONVERT_EXPR: | |
baa9d179 | 2143 | pp_string (pp, "VIEW_CONVERT_EXPR<"); |
2144 | dump_generic_node (pp, TREE_TYPE (node), spc, flags, false); | |
2145 | pp_string (pp, ">("); | |
2146 | dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false); | |
2147 | pp_right_paren (pp); | |
4ee9c684 | 2148 | break; |
2149 | ||
751ff693 | 2150 | case PAREN_EXPR: |
baa9d179 | 2151 | pp_string (pp, "(("); |
2152 | dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false); | |
2153 | pp_string (pp, "))"); | |
751ff693 | 2154 | break; |
2155 | ||
4ee9c684 | 2156 | case NON_LVALUE_EXPR: |
baa9d179 | 2157 | pp_string (pp, "NON_LVALUE_EXPR <"); |
2158 | dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false); | |
2159 | pp_greater (pp); | |
4ee9c684 | 2160 | break; |
2161 | ||
2162 | case SAVE_EXPR: | |
baa9d179 | 2163 | pp_string (pp, "SAVE_EXPR <"); |
2164 | dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false); | |
2165 | pp_greater (pp); | |
4ee9c684 | 2166 | break; |
2167 | ||
4ee9c684 | 2168 | case COMPLEX_EXPR: |
baa9d179 | 2169 | pp_string (pp, "COMPLEX_EXPR <"); |
2170 | dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false); | |
2171 | pp_string (pp, ", "); | |
2172 | dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false); | |
2173 | pp_greater (pp); | |
4ee9c684 | 2174 | break; |
2175 | ||
2176 | case CONJ_EXPR: | |
baa9d179 | 2177 | pp_string (pp, "CONJ_EXPR <"); |
2178 | dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false); | |
2179 | pp_greater (pp); | |
4ee9c684 | 2180 | break; |
2181 | ||
2182 | case REALPART_EXPR: | |
baa9d179 | 2183 | pp_string (pp, "REALPART_EXPR <"); |
2184 | dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false); | |
2185 | pp_greater (pp); | |
4ee9c684 | 2186 | break; |
2187 | ||
2188 | case IMAGPART_EXPR: | |
baa9d179 | 2189 | pp_string (pp, "IMAGPART_EXPR <"); |
2190 | dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false); | |
2191 | pp_greater (pp); | |
4ee9c684 | 2192 | break; |
2193 | ||
2194 | case VA_ARG_EXPR: | |
baa9d179 | 2195 | pp_string (pp, "VA_ARG_EXPR <"); |
2196 | dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false); | |
2197 | pp_greater (pp); | |
4ee9c684 | 2198 | break; |
2199 | ||
2200 | case TRY_FINALLY_EXPR: | |
2201 | case TRY_CATCH_EXPR: | |
baa9d179 | 2202 | pp_string (pp, "try"); |
2203 | newline_and_indent (pp, spc+2); | |
2204 | pp_left_brace (pp); | |
2205 | newline_and_indent (pp, spc+4); | |
2206 | dump_generic_node (pp, TREE_OPERAND (node, 0), spc+4, flags, true); | |
2207 | newline_and_indent (pp, spc+2); | |
2208 | pp_right_brace (pp); | |
2209 | newline_and_indent (pp, spc); | |
2210 | pp_string (pp, | |
4ee9c684 | 2211 | (TREE_CODE (node) == TRY_CATCH_EXPR) ? "catch" : "finally"); |
baa9d179 | 2212 | newline_and_indent (pp, spc+2); |
2213 | pp_left_brace (pp); | |
2214 | newline_and_indent (pp, spc+4); | |
2215 | dump_generic_node (pp, TREE_OPERAND (node, 1), spc+4, flags, true); | |
2216 | newline_and_indent (pp, spc+2); | |
2217 | pp_right_brace (pp); | |
4ee9c684 | 2218 | is_expr = false; |
2219 | break; | |
2220 | ||
2221 | case CATCH_EXPR: | |
baa9d179 | 2222 | pp_string (pp, "catch ("); |
2223 | dump_generic_node (pp, CATCH_TYPES (node), spc+2, flags, false); | |
2224 | pp_right_paren (pp); | |
2225 | newline_and_indent (pp, spc+2); | |
2226 | pp_left_brace (pp); | |
2227 | newline_and_indent (pp, spc+4); | |
2228 | dump_generic_node (pp, CATCH_BODY (node), spc+4, flags, true); | |
2229 | newline_and_indent (pp, spc+2); | |
2230 | pp_right_brace (pp); | |
4ee9c684 | 2231 | is_expr = false; |
2232 | break; | |
2233 | ||
2234 | case EH_FILTER_EXPR: | |
baa9d179 | 2235 | pp_string (pp, "<<<eh_filter ("); |
2236 | dump_generic_node (pp, EH_FILTER_TYPES (node), spc+2, flags, false); | |
2237 | pp_string (pp, ")>>>"); | |
2238 | newline_and_indent (pp, spc+2); | |
2239 | pp_left_brace (pp); | |
2240 | newline_and_indent (pp, spc+4); | |
2241 | dump_generic_node (pp, EH_FILTER_FAILURE (node), spc+4, flags, true); | |
2242 | newline_and_indent (pp, spc+2); | |
2243 | pp_right_brace (pp); | |
4ee9c684 | 2244 | is_expr = false; |
2245 | break; | |
2246 | ||
4ee9c684 | 2247 | case LABEL_EXPR: |
2248 | op0 = TREE_OPERAND (node, 0); | |
2249 | /* If this is for break or continue, don't bother printing it. */ | |
2250 | if (DECL_NAME (op0)) | |
2251 | { | |
2252 | const char *name = IDENTIFIER_POINTER (DECL_NAME (op0)); | |
2253 | if (strcmp (name, "break") == 0 | |
2254 | || strcmp (name, "continue") == 0) | |
2255 | break; | |
2256 | } | |
baa9d179 | 2257 | dump_generic_node (pp, op0, spc, flags, false); |
2258 | pp_colon (pp); | |
4ee9c684 | 2259 | if (DECL_NONLOCAL (op0)) |
baa9d179 | 2260 | pp_string (pp, " [non-local]"); |
4ee9c684 | 2261 | break; |
2262 | ||
4ee9c684 | 2263 | case LOOP_EXPR: |
baa9d179 | 2264 | pp_string (pp, "while (1)"); |
4ee9c684 | 2265 | if (!(flags & TDF_SLIM)) |
2266 | { | |
baa9d179 | 2267 | newline_and_indent (pp, spc+2); |
2268 | pp_left_brace (pp); | |
2269 | newline_and_indent (pp, spc+4); | |
2270 | dump_generic_node (pp, LOOP_EXPR_BODY (node), spc+4, flags, true); | |
2271 | newline_and_indent (pp, spc+2); | |
2272 | pp_right_brace (pp); | |
4ee9c684 | 2273 | } |
2274 | is_expr = false; | |
2275 | break; | |
2276 | ||
4a1849e3 | 2277 | case PREDICT_EXPR: |
baa9d179 | 2278 | pp_string (pp, "// predicted "); |
4a1849e3 | 2279 | if (PREDICT_EXPR_OUTCOME (node)) |
baa9d179 | 2280 | pp_string (pp, "likely by "); |
4a1849e3 | 2281 | else |
baa9d179 | 2282 | pp_string (pp, "unlikely by "); |
2283 | pp_string (pp, predictor_name (PREDICT_EXPR_PREDICTOR (node))); | |
2284 | pp_string (pp, " predictor."); | |
4a1849e3 | 2285 | break; |
2286 | ||
4644b593 | 2287 | case ANNOTATE_EXPR: |
baa9d179 | 2288 | pp_string (pp, "ANNOTATE_EXPR <"); |
2289 | dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false); | |
08f4222b | 2290 | switch ((enum annot_expr_kind) TREE_INT_CST_LOW (TREE_OPERAND (node, 1))) |
4644b593 | 2291 | { |
2292 | case annot_expr_ivdep_kind: | |
baa9d179 | 2293 | pp_string (pp, ", ivdep"); |
eb71996d | 2294 | break; |
2295 | case annot_expr_no_vector_kind: | |
baa9d179 | 2296 | pp_string (pp, ", no-vector"); |
eb71996d | 2297 | break; |
2298 | case annot_expr_vector_kind: | |
baa9d179 | 2299 | pp_string (pp, ", vector"); |
4644b593 | 2300 | break; |
eb71996d | 2301 | default: |
2302 | gcc_unreachable (); | |
4644b593 | 2303 | } |
baa9d179 | 2304 | pp_greater (pp); |
4644b593 | 2305 | break; |
2306 | ||
4ee9c684 | 2307 | case RETURN_EXPR: |
baa9d179 | 2308 | pp_string (pp, "return"); |
4ee9c684 | 2309 | op0 = TREE_OPERAND (node, 0); |
2310 | if (op0) | |
2311 | { | |
baa9d179 | 2312 | pp_space (pp); |
75a70cf9 | 2313 | if (TREE_CODE (op0) == MODIFY_EXPR) |
baa9d179 | 2314 | dump_generic_node (pp, TREE_OPERAND (op0, 1), |
35cc02b5 | 2315 | spc, flags, false); |
4ee9c684 | 2316 | else |
baa9d179 | 2317 | dump_generic_node (pp, op0, spc, flags, false); |
4ee9c684 | 2318 | } |
2319 | break; | |
2320 | ||
2321 | case EXIT_EXPR: | |
baa9d179 | 2322 | pp_string (pp, "if ("); |
2323 | dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false); | |
2324 | pp_string (pp, ") break"); | |
4ee9c684 | 2325 | break; |
2326 | ||
2327 | case SWITCH_EXPR: | |
baa9d179 | 2328 | pp_string (pp, "switch ("); |
2329 | dump_generic_node (pp, SWITCH_COND (node), spc, flags, false); | |
2330 | pp_right_paren (pp); | |
4ee9c684 | 2331 | if (!(flags & TDF_SLIM)) |
2332 | { | |
baa9d179 | 2333 | newline_and_indent (pp, spc+2); |
2334 | pp_left_brace (pp); | |
4ee9c684 | 2335 | if (SWITCH_BODY (node)) |
2336 | { | |
baa9d179 | 2337 | newline_and_indent (pp, spc+4); |
2338 | dump_generic_node (pp, SWITCH_BODY (node), spc+4, flags, | |
1e8e9920 | 2339 | true); |
4ee9c684 | 2340 | } |
2341 | else | |
2342 | { | |
2343 | tree vec = SWITCH_LABELS (node); | |
2344 | size_t i, n = TREE_VEC_LENGTH (vec); | |
2345 | for (i = 0; i < n; ++i) | |
2346 | { | |
2347 | tree elt = TREE_VEC_ELT (vec, i); | |
baa9d179 | 2348 | newline_and_indent (pp, spc+4); |
1e8e9920 | 2349 | if (elt) |
2350 | { | |
baa9d179 | 2351 | dump_generic_node (pp, elt, spc+4, flags, false); |
2352 | pp_string (pp, " goto "); | |
2353 | dump_generic_node (pp, CASE_LABEL (elt), spc+4, | |
1e8e9920 | 2354 | flags, true); |
baa9d179 | 2355 | pp_semicolon (pp); |
1e8e9920 | 2356 | } |
2357 | else | |
baa9d179 | 2358 | pp_string (pp, "case ???: goto ???;"); |
4ee9c684 | 2359 | } |
2360 | } | |
baa9d179 | 2361 | newline_and_indent (pp, spc+2); |
2362 | pp_right_brace (pp); | |
4ee9c684 | 2363 | } |
2364 | is_expr = false; | |
2365 | break; | |
2366 | ||
2367 | case GOTO_EXPR: | |
2368 | op0 = GOTO_DESTINATION (node); | |
ce45a448 | 2369 | if (TREE_CODE (op0) != SSA_NAME && DECL_P (op0) && DECL_NAME (op0)) |
4ee9c684 | 2370 | { |
2371 | const char *name = IDENTIFIER_POINTER (DECL_NAME (op0)); | |
2372 | if (strcmp (name, "break") == 0 | |
2373 | || strcmp (name, "continue") == 0) | |
2374 | { | |
baa9d179 | 2375 | pp_string (pp, name); |
4ee9c684 | 2376 | break; |
2377 | } | |
2378 | } | |
baa9d179 | 2379 | pp_string (pp, "goto "); |
2380 | dump_generic_node (pp, op0, spc, flags, false); | |
4ee9c684 | 2381 | break; |
2382 | ||
4ee9c684 | 2383 | case ASM_EXPR: |
baa9d179 | 2384 | pp_string (pp, "__asm__"); |
4ee9c684 | 2385 | if (ASM_VOLATILE_P (node)) |
baa9d179 | 2386 | pp_string (pp, " __volatile__"); |
2387 | pp_left_paren (pp); | |
2388 | dump_generic_node (pp, ASM_STRING (node), spc, flags, false); | |
2389 | pp_colon (pp); | |
2390 | dump_generic_node (pp, ASM_OUTPUTS (node), spc, flags, false); | |
2391 | pp_colon (pp); | |
2392 | dump_generic_node (pp, ASM_INPUTS (node), spc, flags, false); | |
4ee9c684 | 2393 | if (ASM_CLOBBERS (node)) |
2394 | { | |
baa9d179 | 2395 | pp_colon (pp); |
2396 | dump_generic_node (pp, ASM_CLOBBERS (node), spc, flags, false); | |
4ee9c684 | 2397 | } |
baa9d179 | 2398 | pp_right_paren (pp); |
4ee9c684 | 2399 | break; |
2400 | ||
2401 | case CASE_LABEL_EXPR: | |
2402 | if (CASE_LOW (node) && CASE_HIGH (node)) | |
2403 | { | |
baa9d179 | 2404 | pp_string (pp, "case "); |
2405 | dump_generic_node (pp, CASE_LOW (node), spc, flags, false); | |
2406 | pp_string (pp, " ... "); | |
2407 | dump_generic_node (pp, CASE_HIGH (node), spc, flags, false); | |
4ee9c684 | 2408 | } |
2409 | else if (CASE_LOW (node)) | |
2410 | { | |
baa9d179 | 2411 | pp_string (pp, "case "); |
2412 | dump_generic_node (pp, CASE_LOW (node), spc, flags, false); | |
4ee9c684 | 2413 | } |
2414 | else | |
baa9d179 | 2415 | pp_string (pp, "default"); |
2416 | pp_colon (pp); | |
4ee9c684 | 2417 | break; |
2418 | ||
215e2f1d | 2419 | case OBJ_TYPE_REF: |
baa9d179 | 2420 | pp_string (pp, "OBJ_TYPE_REF("); |
2421 | dump_generic_node (pp, OBJ_TYPE_REF_EXPR (node), spc, flags, false); | |
2422 | pp_semicolon (pp); | |
41154724 | 2423 | if (!(flags & TDF_SLIM) && virtual_method_call_p (node)) |
2424 | { | |
baa9d179 | 2425 | pp_string (pp, "("); |
2426 | dump_generic_node (pp, obj_type_ref_class (node), spc, flags, false); | |
2427 | pp_string (pp, ")"); | |
41154724 | 2428 | } |
baa9d179 | 2429 | dump_generic_node (pp, OBJ_TYPE_REF_OBJECT (node), spc, flags, false); |
2430 | pp_arrow (pp); | |
2431 | dump_generic_node (pp, OBJ_TYPE_REF_TOKEN (node), spc, flags, false); | |
2432 | pp_right_paren (pp); | |
4ee9c684 | 2433 | break; |
2434 | ||
4ee9c684 | 2435 | case SSA_NAME: |
ec11736b | 2436 | if (SSA_NAME_IDENTIFIER (node)) |
baa9d179 | 2437 | dump_generic_node (pp, SSA_NAME_IDENTIFIER (node), |
ec11736b | 2438 | spc, flags, false); |
baa9d179 | 2439 | pp_underscore (pp); |
2440 | pp_decimal_int (pp, SSA_NAME_VERSION (node)); | |
823f6908 | 2441 | if (SSA_NAME_IS_DEFAULT_DEF (node)) |
baa9d179 | 2442 | pp_string (pp, "(D)"); |
2b6719e9 | 2443 | if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node)) |
baa9d179 | 2444 | pp_string (pp, "(ab)"); |
4ee9c684 | 2445 | break; |
2446 | ||
80f06481 | 2447 | case WITH_SIZE_EXPR: |
baa9d179 | 2448 | pp_string (pp, "WITH_SIZE_EXPR <"); |
2449 | dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false); | |
2450 | pp_string (pp, ", "); | |
2451 | dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false); | |
2452 | pp_greater (pp); | |
80f06481 | 2453 | break; |
2454 | ||
88dbf20f | 2455 | case ASSERT_EXPR: |
baa9d179 | 2456 | pp_string (pp, "ASSERT_EXPR <"); |
2457 | dump_generic_node (pp, ASSERT_EXPR_VAR (node), spc, flags, false); | |
2458 | pp_string (pp, ", "); | |
2459 | dump_generic_node (pp, ASSERT_EXPR_COND (node), spc, flags, false); | |
2460 | pp_greater (pp); | |
88dbf20f | 2461 | break; |
2462 | ||
101d9422 | 2463 | case SCEV_KNOWN: |
baa9d179 | 2464 | pp_string (pp, "scev_known"); |
101d9422 | 2465 | break; |
2466 | ||
2467 | case SCEV_NOT_KNOWN: | |
baa9d179 | 2468 | pp_string (pp, "scev_not_known"); |
101d9422 | 2469 | break; |
2470 | ||
2471 | case POLYNOMIAL_CHREC: | |
baa9d179 | 2472 | pp_left_brace (pp); |
2473 | dump_generic_node (pp, CHREC_LEFT (node), spc, flags, false); | |
2474 | pp_string (pp, ", +, "); | |
2475 | dump_generic_node (pp, CHREC_RIGHT (node), spc, flags, false); | |
2476 | pp_string (pp, "}_"); | |
2477 | dump_generic_node (pp, CHREC_VAR (node), spc, flags, false); | |
101d9422 | 2478 | is_stmt = false; |
2479 | break; | |
2480 | ||
b056d812 | 2481 | case REALIGN_LOAD_EXPR: |
baa9d179 | 2482 | pp_string (pp, "REALIGN_LOAD <"); |
2483 | dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false); | |
2484 | pp_string (pp, ", "); | |
2485 | dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false); | |
2486 | pp_string (pp, ", "); | |
2487 | dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false); | |
2488 | pp_greater (pp); | |
b056d812 | 2489 | break; |
48e1416a | 2490 | |
5c4f2f32 | 2491 | case VEC_COND_EXPR: |
baa9d179 | 2492 | pp_string (pp, " VEC_COND_EXPR < "); |
2493 | dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false); | |
2494 | pp_string (pp, " , "); | |
2495 | dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false); | |
2496 | pp_string (pp, " , "); | |
2497 | dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false); | |
2498 | pp_string (pp, " > "); | |
6cf89e04 | 2499 | break; |
2500 | ||
f4803722 | 2501 | case VEC_PERM_EXPR: |
baa9d179 | 2502 | pp_string (pp, " VEC_PERM_EXPR < "); |
2503 | dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false); | |
2504 | pp_string (pp, " , "); | |
2505 | dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false); | |
2506 | pp_string (pp, " , "); | |
2507 | dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false); | |
2508 | pp_string (pp, " > "); | |
5c4f2f32 | 2509 | break; |
2510 | ||
4a61a337 | 2511 | case DOT_PROD_EXPR: |
baa9d179 | 2512 | pp_string (pp, " DOT_PROD_EXPR < "); |
2513 | dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false); | |
2514 | pp_string (pp, ", "); | |
2515 | dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false); | |
2516 | pp_string (pp, ", "); | |
2517 | dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false); | |
2518 | pp_string (pp, " > "); | |
4a61a337 | 2519 | break; |
2520 | ||
00f4f705 | 2521 | case WIDEN_MULT_PLUS_EXPR: |
baa9d179 | 2522 | pp_string (pp, " WIDEN_MULT_PLUS_EXPR < "); |
2523 | dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false); | |
2524 | pp_string (pp, ", "); | |
2525 | dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false); | |
2526 | pp_string (pp, ", "); | |
2527 | dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false); | |
2528 | pp_string (pp, " > "); | |
00f4f705 | 2529 | break; |
2530 | ||
2531 | case WIDEN_MULT_MINUS_EXPR: | |
baa9d179 | 2532 | pp_string (pp, " WIDEN_MULT_MINUS_EXPR < "); |
2533 | dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false); | |
2534 | pp_string (pp, ", "); | |
2535 | dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false); | |
2536 | pp_string (pp, ", "); | |
2537 | dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false); | |
2538 | pp_string (pp, " > "); | |
00f4f705 | 2539 | break; |
2540 | ||
156f51b9 | 2541 | case FMA_EXPR: |
baa9d179 | 2542 | pp_string (pp, " FMA_EXPR < "); |
2543 | dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false); | |
2544 | pp_string (pp, ", "); | |
2545 | dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false); | |
2546 | pp_string (pp, ", "); | |
2547 | dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false); | |
2548 | pp_string (pp, " > "); | |
156f51b9 | 2549 | break; |
2550 | ||
ca4c3545 | 2551 | case OACC_PARALLEL: |
2552 | pp_string (pp, "#pragma acc parallel"); | |
2553 | dump_omp_clauses (pp, OACC_PARALLEL_CLAUSES (node), spc, flags); | |
2554 | goto dump_omp_body; | |
2555 | ||
2556 | case OACC_KERNELS: | |
2557 | pp_string (pp, "#pragma acc kernels"); | |
2558 | dump_omp_clauses (pp, OACC_KERNELS_CLAUSES (node), spc, flags); | |
2559 | goto dump_omp_body; | |
2560 | ||
2561 | case OACC_DATA: | |
2562 | pp_string (pp, "#pragma acc data"); | |
2563 | dump_omp_clauses (pp, OACC_DATA_CLAUSES (node), spc, flags); | |
2564 | goto dump_omp_body; | |
2565 | ||
2566 | case OACC_HOST_DATA: | |
2567 | pp_string (pp, "#pragma acc host_data"); | |
2568 | dump_omp_clauses (pp, OACC_HOST_DATA_CLAUSES (node), spc, flags); | |
2569 | goto dump_omp_body; | |
2570 | ||
2571 | case OACC_DECLARE: | |
2572 | pp_string (pp, "#pragma acc declare"); | |
2573 | dump_omp_clauses (pp, OACC_DECLARE_CLAUSES (node), spc, flags); | |
2574 | break; | |
2575 | ||
2576 | case OACC_UPDATE: | |
2577 | pp_string (pp, "#pragma acc update"); | |
2578 | dump_omp_clauses (pp, OACC_UPDATE_CLAUSES (node), spc, flags); | |
2579 | break; | |
2580 | ||
2581 | case OACC_ENTER_DATA: | |
2582 | pp_string (pp, "#pragma acc enter data"); | |
2583 | dump_omp_clauses (pp, OACC_ENTER_DATA_CLAUSES (node), spc, flags); | |
2584 | break; | |
2585 | ||
2586 | case OACC_EXIT_DATA: | |
2587 | pp_string (pp, "#pragma acc exit data"); | |
2588 | dump_omp_clauses (pp, OACC_EXIT_DATA_CLAUSES (node), spc, flags); | |
2589 | break; | |
2590 | ||
2591 | case OACC_CACHE: | |
2592 | pp_string (pp, "#pragma acc cache"); | |
2593 | dump_omp_clauses (pp, OACC_CACHE_CLAUSES (node), spc, flags); | |
2594 | break; | |
2595 | ||
1e8e9920 | 2596 | case OMP_PARALLEL: |
baa9d179 | 2597 | pp_string (pp, "#pragma omp parallel"); |
2598 | dump_omp_clauses (pp, OMP_PARALLEL_CLAUSES (node), spc, flags); | |
1e8e9920 | 2599 | |
2600 | dump_omp_body: | |
2601 | if (!(flags & TDF_SLIM) && OMP_BODY (node)) | |
2602 | { | |
baa9d179 | 2603 | newline_and_indent (pp, spc + 2); |
2604 | pp_left_brace (pp); | |
2605 | newline_and_indent (pp, spc + 4); | |
2606 | dump_generic_node (pp, OMP_BODY (node), spc + 4, flags, false); | |
2607 | newline_and_indent (pp, spc + 2); | |
2608 | pp_right_brace (pp); | |
1e8e9920 | 2609 | } |
2610 | is_expr = false; | |
2611 | break; | |
2612 | ||
fd6481cf | 2613 | case OMP_TASK: |
baa9d179 | 2614 | pp_string (pp, "#pragma omp task"); |
2615 | dump_omp_clauses (pp, OMP_TASK_CLAUSES (node), spc, flags); | |
fd6481cf | 2616 | goto dump_omp_body; |
2617 | ||
1e8e9920 | 2618 | case OMP_FOR: |
baa9d179 | 2619 | pp_string (pp, "#pragma omp for"); |
3d483a94 | 2620 | goto dump_omp_loop; |
2621 | ||
2622 | case OMP_SIMD: | |
baa9d179 | 2623 | pp_string (pp, "#pragma omp simd"); |
3d483a94 | 2624 | goto dump_omp_loop; |
2625 | ||
f2697631 | 2626 | case CILK_SIMD: |
baa9d179 | 2627 | pp_string (pp, "#pragma simd"); |
f2697631 | 2628 | goto dump_omp_loop; |
2629 | ||
40750995 | 2630 | case CILK_FOR: |
2631 | /* This label points one line after dumping the clauses. | |
2632 | For _Cilk_for the clauses are dumped after the _Cilk_for (...) | |
2633 | parameters are printed out. */ | |
2634 | goto dump_omp_loop_cilk_for; | |
2635 | ||
bc7bff74 | 2636 | case OMP_DISTRIBUTE: |
baa9d179 | 2637 | pp_string (pp, "#pragma omp distribute"); |
bc7bff74 | 2638 | goto dump_omp_loop; |
2639 | ||
ca4c3545 | 2640 | case OACC_LOOP: |
2641 | pp_string (pp, "#pragma acc loop"); | |
2642 | goto dump_omp_loop; | |
2643 | ||
bc7bff74 | 2644 | case OMP_TEAMS: |
baa9d179 | 2645 | pp_string (pp, "#pragma omp teams"); |
2646 | dump_omp_clauses (pp, OMP_TEAMS_CLAUSES (node), spc, flags); | |
bc7bff74 | 2647 | goto dump_omp_body; |
2648 | ||
2649 | case OMP_TARGET_DATA: | |
baa9d179 | 2650 | pp_string (pp, "#pragma omp target data"); |
2651 | dump_omp_clauses (pp, OMP_TARGET_DATA_CLAUSES (node), spc, flags); | |
bc7bff74 | 2652 | goto dump_omp_body; |
2653 | ||
2654 | case OMP_TARGET: | |
baa9d179 | 2655 | pp_string (pp, "#pragma omp target"); |
2656 | dump_omp_clauses (pp, OMP_TARGET_CLAUSES (node), spc, flags); | |
bc7bff74 | 2657 | goto dump_omp_body; |
2658 | ||
2659 | case OMP_TARGET_UPDATE: | |
baa9d179 | 2660 | pp_string (pp, "#pragma omp target update"); |
2661 | dump_omp_clauses (pp, OMP_TARGET_UPDATE_CLAUSES (node), spc, flags); | |
bc7bff74 | 2662 | is_expr = false; |
2663 | break; | |
2664 | ||
3d483a94 | 2665 | dump_omp_loop: |
baa9d179 | 2666 | dump_omp_clauses (pp, OMP_FOR_CLAUSES (node), spc, flags); |
1e8e9920 | 2667 | |
40750995 | 2668 | dump_omp_loop_cilk_for: |
1e8e9920 | 2669 | if (!(flags & TDF_SLIM)) |
2670 | { | |
fd6481cf | 2671 | int i; |
2672 | ||
1e8e9920 | 2673 | if (OMP_FOR_PRE_BODY (node)) |
2674 | { | |
40750995 | 2675 | if (TREE_CODE (node) == CILK_FOR) |
baa9d179 | 2676 | pp_string (pp, " "); |
40750995 | 2677 | else |
baa9d179 | 2678 | newline_and_indent (pp, spc + 2); |
2679 | pp_left_brace (pp); | |
1e8e9920 | 2680 | spc += 4; |
baa9d179 | 2681 | newline_and_indent (pp, spc); |
2682 | dump_generic_node (pp, OMP_FOR_PRE_BODY (node), | |
40750995 | 2683 | spc, flags, false); |
1e8e9920 | 2684 | } |
bc7bff74 | 2685 | if (OMP_FOR_INIT (node)) |
fd6481cf | 2686 | { |
bc7bff74 | 2687 | spc -= 2; |
2688 | for (i = 0; i < TREE_VEC_LENGTH (OMP_FOR_INIT (node)); i++) | |
2689 | { | |
2690 | spc += 2; | |
40750995 | 2691 | if (TREE_CODE (node) != CILK_FOR || OMP_FOR_PRE_BODY (node)) |
baa9d179 | 2692 | newline_and_indent (pp, spc); |
40750995 | 2693 | if (TREE_CODE (node) == CILK_FOR) |
baa9d179 | 2694 | pp_string (pp, "_Cilk_for ("); |
40750995 | 2695 | else |
baa9d179 | 2696 | pp_string (pp, "for ("); |
2697 | dump_generic_node (pp, | |
bc7bff74 | 2698 | TREE_VEC_ELT (OMP_FOR_INIT (node), i), |
2699 | spc, flags, false); | |
baa9d179 | 2700 | pp_string (pp, "; "); |
2701 | dump_generic_node (pp, | |
bc7bff74 | 2702 | TREE_VEC_ELT (OMP_FOR_COND (node), i), |
2703 | spc, flags, false); | |
baa9d179 | 2704 | pp_string (pp, "; "); |
2705 | dump_generic_node (pp, | |
bc7bff74 | 2706 | TREE_VEC_ELT (OMP_FOR_INCR (node), i), |
2707 | spc, flags, false); | |
baa9d179 | 2708 | pp_right_paren (pp); |
bc7bff74 | 2709 | } |
40750995 | 2710 | if (TREE_CODE (node) == CILK_FOR) |
baa9d179 | 2711 | dump_omp_clauses (pp, OMP_FOR_CLAUSES (node), spc, flags); |
fd6481cf | 2712 | } |
1e8e9920 | 2713 | if (OMP_FOR_BODY (node)) |
2714 | { | |
baa9d179 | 2715 | newline_and_indent (pp, spc + 2); |
2716 | pp_left_brace (pp); | |
2717 | newline_and_indent (pp, spc + 4); | |
2718 | dump_generic_node (pp, OMP_FOR_BODY (node), spc + 4, flags, | |
1e8e9920 | 2719 | false); |
baa9d179 | 2720 | newline_and_indent (pp, spc + 2); |
2721 | pp_right_brace (pp); | |
1e8e9920 | 2722 | } |
bc7bff74 | 2723 | if (OMP_FOR_INIT (node)) |
2724 | spc -= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node)) - 2; | |
1e8e9920 | 2725 | if (OMP_FOR_PRE_BODY (node)) |
2726 | { | |
2727 | spc -= 4; | |
baa9d179 | 2728 | newline_and_indent (pp, spc + 2); |
2729 | pp_right_brace (pp); | |
1e8e9920 | 2730 | } |
2731 | } | |
2732 | is_expr = false; | |
2733 | break; | |
2734 | ||
2735 | case OMP_SECTIONS: | |
baa9d179 | 2736 | pp_string (pp, "#pragma omp sections"); |
2737 | dump_omp_clauses (pp, OMP_SECTIONS_CLAUSES (node), spc, flags); | |
1e8e9920 | 2738 | goto dump_omp_body; |
2739 | ||
2740 | case OMP_SECTION: | |
baa9d179 | 2741 | pp_string (pp, "#pragma omp section"); |
1e8e9920 | 2742 | goto dump_omp_body; |
48e1416a | 2743 | |
1e8e9920 | 2744 | case OMP_MASTER: |
baa9d179 | 2745 | pp_string (pp, "#pragma omp master"); |
1e8e9920 | 2746 | goto dump_omp_body; |
2747 | ||
bc7bff74 | 2748 | case OMP_TASKGROUP: |
baa9d179 | 2749 | pp_string (pp, "#pragma omp taskgroup"); |
bc7bff74 | 2750 | goto dump_omp_body; |
2751 | ||
1e8e9920 | 2752 | case OMP_ORDERED: |
baa9d179 | 2753 | pp_string (pp, "#pragma omp ordered"); |
1e8e9920 | 2754 | goto dump_omp_body; |
2755 | ||
2756 | case OMP_CRITICAL: | |
baa9d179 | 2757 | pp_string (pp, "#pragma omp critical"); |
1e8e9920 | 2758 | if (OMP_CRITICAL_NAME (node)) |
2759 | { | |
baa9d179 | 2760 | pp_space (pp); |
2761 | pp_left_paren (pp); | |
2762 | dump_generic_node (pp, OMP_CRITICAL_NAME (node), spc, | |
1e8e9920 | 2763 | flags, false); |
baa9d179 | 2764 | pp_right_paren (pp); |
1e8e9920 | 2765 | } |
2766 | goto dump_omp_body; | |
2767 | ||
2768 | case OMP_ATOMIC: | |
baa9d179 | 2769 | pp_string (pp, "#pragma omp atomic"); |
bc7bff74 | 2770 | if (OMP_ATOMIC_SEQ_CST (node)) |
baa9d179 | 2771 | pp_string (pp, " seq_cst"); |
2772 | newline_and_indent (pp, spc + 2); | |
2773 | dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false); | |
2774 | pp_space (pp); | |
2775 | pp_equal (pp); | |
2776 | pp_space (pp); | |
2777 | dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false); | |
1e8e9920 | 2778 | break; |
2779 | ||
2169f33b | 2780 | case OMP_ATOMIC_READ: |
baa9d179 | 2781 | pp_string (pp, "#pragma omp atomic read"); |
bc7bff74 | 2782 | if (OMP_ATOMIC_SEQ_CST (node)) |
baa9d179 | 2783 | pp_string (pp, " seq_cst"); |
2784 | newline_and_indent (pp, spc + 2); | |
2785 | dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false); | |
2786 | pp_space (pp); | |
2169f33b | 2787 | break; |
2788 | ||
2789 | case OMP_ATOMIC_CAPTURE_OLD: | |
2790 | case OMP_ATOMIC_CAPTURE_NEW: | |
baa9d179 | 2791 | pp_string (pp, "#pragma omp atomic capture"); |
bc7bff74 | 2792 | if (OMP_ATOMIC_SEQ_CST (node)) |
baa9d179 | 2793 | pp_string (pp, " seq_cst"); |
2794 | newline_and_indent (pp, spc + 2); | |
2795 | dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false); | |
2796 | pp_space (pp); | |
2797 | pp_equal (pp); | |
2798 | pp_space (pp); | |
2799 | dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false); | |
2169f33b | 2800 | break; |
2801 | ||
1e8e9920 | 2802 | case OMP_SINGLE: |
baa9d179 | 2803 | pp_string (pp, "#pragma omp single"); |
2804 | dump_omp_clauses (pp, OMP_SINGLE_CLAUSES (node), spc, flags); | |
1e8e9920 | 2805 | goto dump_omp_body; |
2806 | ||
55d6e7cd | 2807 | case OMP_CLAUSE: |
baa9d179 | 2808 | dump_omp_clause (pp, node, spc, flags); |
55d6e7cd | 2809 | is_expr = false; |
2810 | break; | |
2811 | ||
4c0315d0 | 2812 | case TRANSACTION_EXPR: |
2813 | if (TRANSACTION_EXPR_OUTER (node)) | |
baa9d179 | 2814 | pp_string (pp, "__transaction_atomic [[outer]]"); |
4c0315d0 | 2815 | else if (TRANSACTION_EXPR_RELAXED (node)) |
baa9d179 | 2816 | pp_string (pp, "__transaction_relaxed"); |
4c0315d0 | 2817 | else |
baa9d179 | 2818 | pp_string (pp, "__transaction_atomic"); |
4c0315d0 | 2819 | if (!(flags & TDF_SLIM) && TRANSACTION_EXPR_BODY (node)) |
2820 | { | |
baa9d179 | 2821 | newline_and_indent (pp, spc); |
2822 | pp_left_brace (pp); | |
2823 | newline_and_indent (pp, spc + 2); | |
2824 | dump_generic_node (pp, TRANSACTION_EXPR_BODY (node), | |
4c0315d0 | 2825 | spc + 2, flags, false); |
baa9d179 | 2826 | newline_and_indent (pp, spc); |
2827 | pp_right_brace (pp); | |
4c0315d0 | 2828 | } |
2829 | is_expr = false; | |
2830 | break; | |
2831 | ||
ea8f3370 | 2832 | case REDUC_MAX_EXPR: |
baa9d179 | 2833 | pp_string (pp, " REDUC_MAX_EXPR < "); |
2834 | dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false); | |
2835 | pp_string (pp, " > "); | |
ea8f3370 | 2836 | break; |
2837 | ||
2838 | case REDUC_MIN_EXPR: | |
baa9d179 | 2839 | pp_string (pp, " REDUC_MIN_EXPR < "); |
2840 | dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false); | |
2841 | pp_string (pp, " > "); | |
ea8f3370 | 2842 | break; |
2843 | ||
2844 | case REDUC_PLUS_EXPR: | |
baa9d179 | 2845 | pp_string (pp, " REDUC_PLUS_EXPR < "); |
2846 | dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false); | |
2847 | pp_string (pp, " > "); | |
ea8f3370 | 2848 | break; |
2849 | ||
c6c91d61 | 2850 | case VEC_WIDEN_MULT_HI_EXPR: |
c6c91d61 | 2851 | case VEC_WIDEN_MULT_LO_EXPR: |
79a78f7f | 2852 | case VEC_WIDEN_MULT_EVEN_EXPR: |
2853 | case VEC_WIDEN_MULT_ODD_EXPR: | |
6083c152 | 2854 | case VEC_WIDEN_LSHIFT_HI_EXPR: |
6083c152 | 2855 | case VEC_WIDEN_LSHIFT_LO_EXPR: |
baa9d179 | 2856 | pp_space (pp); |
f3d35d4d | 2857 | for (str = get_tree_code_name (code); *str; str++) |
baa9d179 | 2858 | pp_character (pp, TOUPPER (*str)); |
2859 | pp_string (pp, " < "); | |
2860 | dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false); | |
2861 | pp_string (pp, ", "); | |
2862 | dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false); | |
2863 | pp_string (pp, " > "); | |
6083c152 | 2864 | break; |
2865 | ||
c6c91d61 | 2866 | case VEC_UNPACK_HI_EXPR: |
baa9d179 | 2867 | pp_string (pp, " VEC_UNPACK_HI_EXPR < "); |
2868 | dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false); | |
2869 | pp_string (pp, " > "); | |
c6c91d61 | 2870 | break; |
2871 | ||
2872 | case VEC_UNPACK_LO_EXPR: | |
baa9d179 | 2873 | pp_string (pp, " VEC_UNPACK_LO_EXPR < "); |
2874 | dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false); | |
2875 | pp_string (pp, " > "); | |
c6c91d61 | 2876 | break; |
2877 | ||
8aa4e142 | 2878 | case VEC_UNPACK_FLOAT_HI_EXPR: |
baa9d179 | 2879 | pp_string (pp, " VEC_UNPACK_FLOAT_HI_EXPR < "); |
2880 | dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false); | |
2881 | pp_string (pp, " > "); | |
8aa4e142 | 2882 | break; |
2883 | ||
2884 | case VEC_UNPACK_FLOAT_LO_EXPR: | |
baa9d179 | 2885 | pp_string (pp, " VEC_UNPACK_FLOAT_LO_EXPR < "); |
2886 | dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false); | |
2887 | pp_string (pp, " > "); | |
8aa4e142 | 2888 | break; |
2889 | ||
bb8107e7 | 2890 | case VEC_PACK_TRUNC_EXPR: |
baa9d179 | 2891 | pp_string (pp, " VEC_PACK_TRUNC_EXPR < "); |
2892 | dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false); | |
2893 | pp_string (pp, ", "); | |
2894 | dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false); | |
2895 | pp_string (pp, " > "); | |
c6c91d61 | 2896 | break; |
8aa4e142 | 2897 | |
c6c91d61 | 2898 | case VEC_PACK_SAT_EXPR: |
baa9d179 | 2899 | pp_string (pp, " VEC_PACK_SAT_EXPR < "); |
2900 | dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false); | |
2901 | pp_string (pp, ", "); | |
2902 | dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false); | |
2903 | pp_string (pp, " > "); | |
c6c91d61 | 2904 | break; |
8aa4e142 | 2905 | |
2906 | case VEC_PACK_FIX_TRUNC_EXPR: | |
baa9d179 | 2907 | pp_string (pp, " VEC_PACK_FIX_TRUNC_EXPR < "); |
2908 | dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false); | |
2909 | pp_string (pp, ", "); | |
2910 | dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false); | |
2911 | pp_string (pp, " > "); | |
8aa4e142 | 2912 | break; |
2913 | ||
1e8e9920 | 2914 | case BLOCK: |
baa9d179 | 2915 | dump_block_node (pp, node, spc, flags); |
7aa082e5 | 2916 | break; |
1e8e9920 | 2917 | |
d037099f | 2918 | case CILK_SPAWN_STMT: |
baa9d179 | 2919 | pp_string (pp, "_Cilk_spawn "); |
2920 | dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false); | |
d037099f | 2921 | break; |
2922 | ||
2923 | case CILK_SYNC_STMT: | |
baa9d179 | 2924 | pp_string (pp, "_Cilk_sync"); |
d037099f | 2925 | break; |
2926 | ||
4ee9c684 | 2927 | default: |
2928 | NIY; | |
2929 | } | |
2930 | ||
2931 | if (is_stmt && is_expr) | |
baa9d179 | 2932 | pp_semicolon (pp); |
b4c01899 | 2933 | |
4ee9c684 | 2934 | return spc; |
2935 | } | |
2936 | ||
2937 | /* Print the declaration of a variable. */ | |
2938 | ||
75a70cf9 | 2939 | void |
baa9d179 | 2940 | print_declaration (pretty_printer *pp, tree t, int spc, int flags) |
4ee9c684 | 2941 | { |
4ee9c684 | 2942 | INDENT (spc); |
2943 | ||
d95140de | 2944 | if (TREE_CODE(t) == NAMELIST_DECL) |
2945 | { | |
baa9d179 | 2946 | pp_string(pp, "namelist "); |
2947 | dump_decl_name (pp, t, flags); | |
2948 | pp_semicolon (pp); | |
d95140de | 2949 | return; |
2950 | } | |
2951 | ||
d700b485 | 2952 | if (TREE_CODE (t) == TYPE_DECL) |
baa9d179 | 2953 | pp_string (pp, "typedef "); |
d700b485 | 2954 | |
5ded8c6f | 2955 | if (CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_DECL_WRTL) && DECL_REGISTER (t)) |
baa9d179 | 2956 | pp_string (pp, "register "); |
4ee9c684 | 2957 | |
2958 | if (TREE_PUBLIC (t) && DECL_EXTERNAL (t)) | |
baa9d179 | 2959 | pp_string (pp, "extern "); |
4ee9c684 | 2960 | else if (TREE_STATIC (t)) |
baa9d179 | 2961 | pp_string (pp, "static "); |
4ee9c684 | 2962 | |
2963 | /* Print the type and name. */ | |
12e18540 | 2964 | if (TREE_TYPE (t) && TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE) |
4ee9c684 | 2965 | { |
2966 | tree tmp; | |
2967 | ||
2968 | /* Print array's type. */ | |
2969 | tmp = TREE_TYPE (t); | |
2970 | while (TREE_CODE (TREE_TYPE (tmp)) == ARRAY_TYPE) | |
2971 | tmp = TREE_TYPE (tmp); | |
baa9d179 | 2972 | dump_generic_node (pp, TREE_TYPE (tmp), spc, flags, false); |
4ee9c684 | 2973 | |
2974 | /* Print variable's name. */ | |
baa9d179 | 2975 | pp_space (pp); |
2976 | dump_generic_node (pp, t, spc, flags, false); | |
4ee9c684 | 2977 | |
2978 | /* Print the dimensions. */ | |
2979 | tmp = TREE_TYPE (t); | |
2980 | while (TREE_CODE (tmp) == ARRAY_TYPE) | |
2981 | { | |
baa9d179 | 2982 | dump_array_domain (pp, TYPE_DOMAIN (tmp), spc, flags); |
4ee9c684 | 2983 | tmp = TREE_TYPE (tmp); |
2984 | } | |
2985 | } | |
d700b485 | 2986 | else if (TREE_CODE (t) == FUNCTION_DECL) |
2987 | { | |
baa9d179 | 2988 | dump_generic_node (pp, TREE_TYPE (TREE_TYPE (t)), spc, flags, false); |
2989 | pp_space (pp); | |
2990 | dump_decl_name (pp, t, flags); | |
2991 | dump_function_declaration (pp, TREE_TYPE (t), spc, flags); | |
d700b485 | 2992 | } |
4ee9c684 | 2993 | else |
2994 | { | |
2995 | /* Print type declaration. */ | |
baa9d179 | 2996 | dump_generic_node (pp, TREE_TYPE (t), spc, flags, false); |
4ee9c684 | 2997 | |
2998 | /* Print variable's name. */ | |
baa9d179 | 2999 | pp_space (pp); |
3000 | dump_generic_node (pp, t, spc, flags, false); | |
4ee9c684 | 3001 | } |
3002 | ||
fbc51f36 | 3003 | if (TREE_CODE (t) == VAR_DECL && DECL_HARD_REGISTER (t)) |
3004 | { | |
baa9d179 | 3005 | pp_string (pp, " __asm__ "); |
3006 | pp_left_paren (pp); | |
3007 | dump_generic_node (pp, DECL_ASSEMBLER_NAME (t), spc, flags, false); | |
3008 | pp_right_paren (pp); | |
fbc51f36 | 3009 | } |
3010 | ||
f0b5f617 | 3011 | /* The initial value of a function serves to determine whether the function |
4ee9c684 | 3012 | is declared or defined. So the following does not apply to function |
3013 | nodes. */ | |
3014 | if (TREE_CODE (t) != FUNCTION_DECL) | |
3015 | { | |
3016 | /* Print the initial value. */ | |
3017 | if (DECL_INITIAL (t)) | |
3018 | { | |
baa9d179 | 3019 | pp_space (pp); |
3020 | pp_equal (pp); | |
3021 | pp_space (pp); | |
3022 | dump_generic_node (pp, DECL_INITIAL (t), spc, flags, false); | |
4ee9c684 | 3023 | } |
3024 | } | |
3025 | ||
1e8e9920 | 3026 | if (TREE_CODE (t) == VAR_DECL && DECL_HAS_VALUE_EXPR_P (t)) |
3027 | { | |
baa9d179 | 3028 | pp_string (pp, " [value-expr: "); |
3029 | dump_generic_node (pp, DECL_VALUE_EXPR (t), spc, flags, false); | |
3030 | pp_right_bracket (pp); | |
1e8e9920 | 3031 | } |
3032 | ||
baa9d179 | 3033 | pp_semicolon (pp); |
4ee9c684 | 3034 | } |
3035 | ||
3036 | ||
3037 | /* Prints a structure: name, fields, and methods. | |
3038 | FIXME: Still incomplete. */ | |
3039 | ||
3040 | static void | |
baa9d179 | 3041 | print_struct_decl (pretty_printer *pp, const_tree node, int spc, int flags) |
4ee9c684 | 3042 | { |
3043 | /* Print the name of the structure. */ | |
3044 | if (TYPE_NAME (node)) | |
3045 | { | |
3046 | INDENT (spc); | |
3047 | if (TREE_CODE (node) == RECORD_TYPE) | |
baa9d179 | 3048 | pp_string (pp, "struct "); |
6374121b | 3049 | else if ((TREE_CODE (node) == UNION_TYPE |
3050 | || TREE_CODE (node) == QUAL_UNION_TYPE)) | |
baa9d179 | 3051 | pp_string (pp, "union "); |
6374121b | 3052 | |
baa9d179 | 3053 | dump_generic_node (pp, TYPE_NAME (node), spc, 0, false); |
4ee9c684 | 3054 | } |
3055 | ||
3056 | /* Print the contents of the structure. */ | |
baa9d179 | 3057 | pp_newline (pp); |
4ee9c684 | 3058 | INDENT (spc); |
baa9d179 | 3059 | pp_left_brace (pp); |
3060 | pp_newline (pp); | |
4ee9c684 | 3061 | |
3062 | /* Print the fields of the structure. */ | |
3063 | { | |
3064 | tree tmp; | |
3065 | tmp = TYPE_FIELDS (node); | |
3066 | while (tmp) | |
3067 | { | |
3068 | /* Avoid to print recursively the structure. */ | |
3069 | /* FIXME : Not implemented correctly..., | |
3070 | what about the case when we have a cycle in the contain graph? ... | |
3071 | Maybe this could be solved by looking at the scope in which the | |
3072 | structure was declared. */ | |
3073 | if (TREE_TYPE (tmp) != node | |
c6934f8a | 3074 | && (TREE_CODE (TREE_TYPE (tmp)) != POINTER_TYPE |
3075 | || TREE_TYPE (TREE_TYPE (tmp)) != node)) | |
4ee9c684 | 3076 | { |
baa9d179 | 3077 | print_declaration (pp, tmp, spc+2, flags); |
3078 | pp_newline (pp); | |
4ee9c684 | 3079 | } |
1767a056 | 3080 | tmp = DECL_CHAIN (tmp); |
4ee9c684 | 3081 | } |
3082 | } | |
3083 | INDENT (spc); | |
baa9d179 | 3084 | pp_right_brace (pp); |
4ee9c684 | 3085 | } |
3086 | ||
e70f5f27 | 3087 | /* Return the priority of the operator CODE. |
4ee9c684 | 3088 | |
3089 | From lowest to highest precedence with either left-to-right (L-R) | |
3090 | or right-to-left (R-L) associativity]: | |
3091 | ||
3092 | 1 [L-R] , | |
3093 | 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>= | |
3094 | 3 [R-L] ?: | |
3095 | 4 [L-R] || | |
3096 | 5 [L-R] && | |
3097 | 6 [L-R] | | |
3098 | 7 [L-R] ^ | |
3099 | 8 [L-R] & | |
3100 | 9 [L-R] == != | |
3101 | 10 [L-R] < <= > >= | |
3102 | 11 [L-R] << >> | |
3103 | 12 [L-R] + - | |
3104 | 13 [L-R] * / % | |
3105 | 14 [R-L] ! ~ ++ -- + - * & (type) sizeof | |
3106 | 15 [L-R] fn() [] -> . | |
3107 | ||
3108 | unary +, - and * have higher precedence than the corresponding binary | |
3109 | operators. */ | |
3110 | ||
e70f5f27 | 3111 | int |
3112 | op_code_prio (enum tree_code code) | |
4ee9c684 | 3113 | { |
e70f5f27 | 3114 | switch (code) |
4ee9c684 | 3115 | { |
3116 | case TREE_LIST: | |
3117 | case COMPOUND_EXPR: | |
3118 | case BIND_EXPR: | |
3119 | return 1; | |
3120 | ||
3121 | case MODIFY_EXPR: | |
3122 | case INIT_EXPR: | |
3123 | return 2; | |
3124 | ||
3125 | case COND_EXPR: | |
3126 | return 3; | |
3127 | ||
3128 | case TRUTH_OR_EXPR: | |
3129 | case TRUTH_ORIF_EXPR: | |
3130 | return 4; | |
3131 | ||
3132 | case TRUTH_AND_EXPR: | |
3133 | case TRUTH_ANDIF_EXPR: | |
3134 | return 5; | |
3135 | ||
3136 | case BIT_IOR_EXPR: | |
3137 | return 6; | |
3138 | ||
3139 | case BIT_XOR_EXPR: | |
3140 | case TRUTH_XOR_EXPR: | |
3141 | return 7; | |
3142 | ||
3143 | case BIT_AND_EXPR: | |
3144 | return 8; | |
3145 | ||
3146 | case EQ_EXPR: | |
3147 | case NE_EXPR: | |
3148 | return 9; | |
3149 | ||
318a728f | 3150 | case UNLT_EXPR: |
3151 | case UNLE_EXPR: | |
3152 | case UNGT_EXPR: | |
3153 | case UNGE_EXPR: | |
3154 | case UNEQ_EXPR: | |
3155 | case LTGT_EXPR: | |
3156 | case ORDERED_EXPR: | |
3157 | case UNORDERED_EXPR: | |
4ee9c684 | 3158 | case LT_EXPR: |
3159 | case LE_EXPR: | |
3160 | case GT_EXPR: | |
3161 | case GE_EXPR: | |
3162 | return 10; | |
3163 | ||
3164 | case LSHIFT_EXPR: | |
3165 | case RSHIFT_EXPR: | |
3166 | case LROTATE_EXPR: | |
3167 | case RROTATE_EXPR: | |
6083c152 | 3168 | case VEC_WIDEN_LSHIFT_HI_EXPR: |
3169 | case VEC_WIDEN_LSHIFT_LO_EXPR: | |
3170 | case WIDEN_LSHIFT_EXPR: | |
4ee9c684 | 3171 | return 11; |
3172 | ||
4a61a337 | 3173 | case WIDEN_SUM_EXPR: |
4ee9c684 | 3174 | case PLUS_EXPR: |
0de36bdb | 3175 | case POINTER_PLUS_EXPR: |
4ee9c684 | 3176 | case MINUS_EXPR: |
3177 | return 12; | |
3178 | ||
c6c91d61 | 3179 | case VEC_WIDEN_MULT_HI_EXPR: |
3180 | case VEC_WIDEN_MULT_LO_EXPR: | |
4a61a337 | 3181 | case WIDEN_MULT_EXPR: |
3182 | case DOT_PROD_EXPR: | |
00f4f705 | 3183 | case WIDEN_MULT_PLUS_EXPR: |
3184 | case WIDEN_MULT_MINUS_EXPR: | |
4ee9c684 | 3185 | case MULT_EXPR: |
96504875 | 3186 | case MULT_HIGHPART_EXPR: |
4ee9c684 | 3187 | case TRUNC_DIV_EXPR: |
3188 | case CEIL_DIV_EXPR: | |
3189 | case FLOOR_DIV_EXPR: | |
3190 | case ROUND_DIV_EXPR: | |
3191 | case RDIV_EXPR: | |
3192 | case EXACT_DIV_EXPR: | |
3193 | case TRUNC_MOD_EXPR: | |
3194 | case CEIL_MOD_EXPR: | |
3195 | case FLOOR_MOD_EXPR: | |
3196 | case ROUND_MOD_EXPR: | |
156f51b9 | 3197 | case FMA_EXPR: |
4ee9c684 | 3198 | return 13; |
3199 | ||
3200 | case TRUTH_NOT_EXPR: | |
3201 | case BIT_NOT_EXPR: | |
3202 | case POSTINCREMENT_EXPR: | |
3203 | case POSTDECREMENT_EXPR: | |
3204 | case PREINCREMENT_EXPR: | |
3205 | case PREDECREMENT_EXPR: | |
3206 | case NEGATE_EXPR: | |
3207 | case INDIRECT_REF: | |
3208 | case ADDR_EXPR: | |
3209 | case FLOAT_EXPR: | |
72dd6141 | 3210 | CASE_CONVERT: |
4ee9c684 | 3211 | case FIX_TRUNC_EXPR: |
4ee9c684 | 3212 | case TARGET_EXPR: |
3213 | return 14; | |
3214 | ||
3215 | case CALL_EXPR: | |
3216 | case ARRAY_REF: | |
6374121b | 3217 | case ARRAY_RANGE_REF: |
4ee9c684 | 3218 | case COMPONENT_REF: |
3219 | return 15; | |
3220 | ||
3221 | /* Special expressions. */ | |
3222 | case MIN_EXPR: | |
3223 | case MAX_EXPR: | |
3224 | case ABS_EXPR: | |
3225 | case REALPART_EXPR: | |
3226 | case IMAGPART_EXPR: | |
ea8f3370 | 3227 | case REDUC_MAX_EXPR: |
3228 | case REDUC_MIN_EXPR: | |
3229 | case REDUC_PLUS_EXPR: | |
c6c91d61 | 3230 | case VEC_UNPACK_HI_EXPR: |
3231 | case VEC_UNPACK_LO_EXPR: | |
8aa4e142 | 3232 | case VEC_UNPACK_FLOAT_HI_EXPR: |
3233 | case VEC_UNPACK_FLOAT_LO_EXPR: | |
bb8107e7 | 3234 | case VEC_PACK_TRUNC_EXPR: |
c6c91d61 | 3235 | case VEC_PACK_SAT_EXPR: |
4ee9c684 | 3236 | return 16; |
3237 | ||
4ee9c684 | 3238 | default: |
3239 | /* Return an arbitrarily high precedence to avoid surrounding single | |
3240 | VAR_DECLs in ()s. */ | |
3241 | return 9999; | |
3242 | } | |
3243 | } | |
3244 | ||
e70f5f27 | 3245 | /* Return the priority of the operator OP. */ |
3246 | ||
3247 | int | |
3248 | op_prio (const_tree op) | |
3249 | { | |
3250 | enum tree_code code; | |
3251 | ||
3252 | if (op == NULL) | |
3253 | return 9999; | |
3254 | ||
3255 | code = TREE_CODE (op); | |
3256 | if (code == SAVE_EXPR || code == NON_LVALUE_EXPR) | |
3257 | return op_prio (TREE_OPERAND (op, 0)); | |
3258 | ||
3259 | return op_code_prio (code); | |
3260 | } | |
4ee9c684 | 3261 | |
ad4a85ad | 3262 | /* Return the symbol associated with operator CODE. */ |
4ee9c684 | 3263 | |
ad4a85ad | 3264 | const char * |
3265 | op_symbol_code (enum tree_code code) | |
4ee9c684 | 3266 | { |
1e8e9920 | 3267 | switch (code) |
4ee9c684 | 3268 | { |
3269 | case MODIFY_EXPR: | |
3270 | return "="; | |
3271 | ||
3272 | case TRUTH_OR_EXPR: | |
3273 | case TRUTH_ORIF_EXPR: | |
3274 | return "||"; | |
3275 | ||
3276 | case TRUTH_AND_EXPR: | |
3277 | case TRUTH_ANDIF_EXPR: | |
3278 | return "&&"; | |
3279 | ||
3280 | case BIT_IOR_EXPR: | |
3281 | return "|"; | |
3282 | ||
3283 | case TRUTH_XOR_EXPR: | |
3284 | case BIT_XOR_EXPR: | |
3285 | return "^"; | |
3286 | ||
3287 | case ADDR_EXPR: | |
3288 | case BIT_AND_EXPR: | |
3289 | return "&"; | |
3290 | ||
318a728f | 3291 | case ORDERED_EXPR: |
3292 | return "ord"; | |
3293 | case UNORDERED_EXPR: | |
3294 | return "unord"; | |
3295 | ||
4ee9c684 | 3296 | case EQ_EXPR: |
4ee9c684 | 3297 | return "=="; |
318a728f | 3298 | case UNEQ_EXPR: |
3299 | return "u=="; | |
4ee9c684 | 3300 | |
3301 | case NE_EXPR: | |
3302 | return "!="; | |
3303 | ||
3304 | case LT_EXPR: | |
4ee9c684 | 3305 | return "<"; |
318a728f | 3306 | case UNLT_EXPR: |
3307 | return "u<"; | |
4ee9c684 | 3308 | |
3309 | case LE_EXPR: | |
4ee9c684 | 3310 | return "<="; |
318a728f | 3311 | case UNLE_EXPR: |
3312 | return "u<="; | |
4ee9c684 | 3313 | |
3314 | case GT_EXPR: | |
4ee9c684 | 3315 | return ">"; |
318a728f | 3316 | case UNGT_EXPR: |
3317 | return "u>"; | |
4ee9c684 | 3318 | |
3319 | case GE_EXPR: | |
4ee9c684 | 3320 | return ">="; |
318a728f | 3321 | case UNGE_EXPR: |
3322 | return "u>="; | |
3323 | ||
3324 | case LTGT_EXPR: | |
3325 | return "<>"; | |
4ee9c684 | 3326 | |
3327 | case LSHIFT_EXPR: | |
3328 | return "<<"; | |
3329 | ||
3330 | case RSHIFT_EXPR: | |
3331 | return ">>"; | |
3332 | ||
01329d30 | 3333 | case LROTATE_EXPR: |
3334 | return "r<<"; | |
3335 | ||
3336 | case RROTATE_EXPR: | |
3337 | return "r>>"; | |
3338 | ||
6083c152 | 3339 | case WIDEN_LSHIFT_EXPR: |
3340 | return "w<<"; | |
3341 | ||
0de36bdb | 3342 | case POINTER_PLUS_EXPR: |
3343 | return "+"; | |
48e1416a | 3344 | |
4ee9c684 | 3345 | case PLUS_EXPR: |
3346 | return "+"; | |
3347 | ||
ea8f3370 | 3348 | case REDUC_PLUS_EXPR: |
3349 | return "r+"; | |
3350 | ||
4a61a337 | 3351 | case WIDEN_SUM_EXPR: |
3352 | return "w+"; | |
3353 | ||
3354 | case WIDEN_MULT_EXPR: | |
3355 | return "w*"; | |
3356 | ||
96504875 | 3357 | case MULT_HIGHPART_EXPR: |
3358 | return "h*"; | |
3359 | ||
4ee9c684 | 3360 | case NEGATE_EXPR: |
3361 | case MINUS_EXPR: | |
3362 | return "-"; | |
3363 | ||
3364 | case BIT_NOT_EXPR: | |
3365 | return "~"; | |
3366 | ||
3367 | case TRUTH_NOT_EXPR: | |
3368 | return "!"; | |
3369 | ||
3370 | case MULT_EXPR: | |
3371 | case INDIRECT_REF: | |
3372 | return "*"; | |
3373 | ||
3374 | case TRUNC_DIV_EXPR: | |
153536df | 3375 | case RDIV_EXPR: |
3376 | return "/"; | |
3377 | ||
4ee9c684 | 3378 | case CEIL_DIV_EXPR: |
153536df | 3379 | return "/[cl]"; |
3380 | ||
4ee9c684 | 3381 | case FLOOR_DIV_EXPR: |
153536df | 3382 | return "/[fl]"; |
3383 | ||
4ee9c684 | 3384 | case ROUND_DIV_EXPR: |
153536df | 3385 | return "/[rd]"; |
3386 | ||
4ee9c684 | 3387 | case EXACT_DIV_EXPR: |
153536df | 3388 | return "/[ex]"; |
4ee9c684 | 3389 | |
3390 | case TRUNC_MOD_EXPR: | |
153536df | 3391 | return "%"; |
3392 | ||
4ee9c684 | 3393 | case CEIL_MOD_EXPR: |
153536df | 3394 | return "%[cl]"; |
3395 | ||
4ee9c684 | 3396 | case FLOOR_MOD_EXPR: |
153536df | 3397 | return "%[fl]"; |
3398 | ||
4ee9c684 | 3399 | case ROUND_MOD_EXPR: |
153536df | 3400 | return "%[rd]"; |
4ee9c684 | 3401 | |
3402 | case PREDECREMENT_EXPR: | |
3403 | return " --"; | |
3404 | ||
3405 | case PREINCREMENT_EXPR: | |
3406 | return " ++"; | |
3407 | ||
3408 | case POSTDECREMENT_EXPR: | |
3409 | return "-- "; | |
3410 | ||
3411 | case POSTINCREMENT_EXPR: | |
3412 | return "++ "; | |
3413 | ||
1e8e9920 | 3414 | case MAX_EXPR: |
3415 | return "max"; | |
3416 | ||
3417 | case MIN_EXPR: | |
3418 | return "min"; | |
3419 | ||
4ee9c684 | 3420 | default: |
3421 | return "<<< ??? >>>"; | |
3422 | } | |
3423 | } | |
3424 | ||
ad4a85ad | 3425 | /* Return the symbol associated with operator OP. */ |
3426 | ||
1e8e9920 | 3427 | static const char * |
b4b34335 | 3428 | op_symbol (const_tree op) |
1e8e9920 | 3429 | { |
ad4a85ad | 3430 | return op_symbol_code (TREE_CODE (op)); |
1e8e9920 | 3431 | } |
3432 | ||
4437c3fe | 3433 | /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or |
3434 | the gimple_call_fn of a GIMPLE_CALL. */ | |
4ee9c684 | 3435 | |
4437c3fe | 3436 | void |
baa9d179 | 3437 | print_call_name (pretty_printer *pp, tree node, int flags) |
4ee9c684 | 3438 | { |
4437c3fe | 3439 | tree op0 = node; |
4ee9c684 | 3440 | |
3441 | if (TREE_CODE (op0) == NON_LVALUE_EXPR) | |
3442 | op0 = TREE_OPERAND (op0, 0); | |
3443 | ||
4437c3fe | 3444 | again: |
4ee9c684 | 3445 | switch (TREE_CODE (op0)) |
3446 | { | |
3447 | case VAR_DECL: | |
3448 | case PARM_DECL: | |
4437c3fe | 3449 | case FUNCTION_DECL: |
baa9d179 | 3450 | dump_function_name (pp, op0, flags); |
4ee9c684 | 3451 | break; |
3452 | ||
3453 | case ADDR_EXPR: | |
3454 | case INDIRECT_REF: | |
d09ef31a | 3455 | CASE_CONVERT: |
4437c3fe | 3456 | op0 = TREE_OPERAND (op0, 0); |
3457 | goto again; | |
4ee9c684 | 3458 | |
3459 | case COND_EXPR: | |
baa9d179 | 3460 | pp_left_paren (pp); |
3461 | dump_generic_node (pp, TREE_OPERAND (op0, 0), 0, flags, false); | |
3462 | pp_string (pp, ") ? "); | |
3463 | dump_generic_node (pp, TREE_OPERAND (op0, 1), 0, flags, false); | |
3464 | pp_string (pp, " : "); | |
3465 | dump_generic_node (pp, TREE_OPERAND (op0, 2), 0, flags, false); | |
4ee9c684 | 3466 | break; |
3467 | ||
4ee9c684 | 3468 | case ARRAY_REF: |
3469 | if (TREE_CODE (TREE_OPERAND (op0, 0)) == VAR_DECL) | |
baa9d179 | 3470 | dump_function_name (pp, TREE_OPERAND (op0, 0), flags); |
4ee9c684 | 3471 | else |
baa9d179 | 3472 | dump_generic_node (pp, op0, 0, flags, false); |
4ee9c684 | 3473 | break; |
3474 | ||
182cf5a9 | 3475 | case MEM_REF: |
3476 | if (integer_zerop (TREE_OPERAND (op0, 1))) | |
3477 | { | |
3478 | op0 = TREE_OPERAND (op0, 0); | |
3479 | goto again; | |
3480 | } | |
3481 | /* Fallthru. */ | |
2692ac97 | 3482 | case COMPONENT_REF: |
4ee9c684 | 3483 | case SSA_NAME: |
215e2f1d | 3484 | case OBJ_TYPE_REF: |
baa9d179 | 3485 | dump_generic_node (pp, op0, 0, flags, false); |
4ee9c684 | 3486 | break; |
3487 | ||
3488 | default: | |
3489 | NIY; | |
3490 | } | |
3491 | } | |
3492 | ||
3493 | /* Parses the string STR and replaces new-lines by '\n', tabs by '\t', ... */ | |
3494 | ||
3495 | static void | |
baa9d179 | 3496 | pretty_print_string (pretty_printer *pp, const char *str) |
4ee9c684 | 3497 | { |
3498 | if (str == NULL) | |
3499 | return; | |
3500 | ||
3501 | while (*str) | |
3502 | { | |
3503 | switch (str[0]) | |
3504 | { | |
3505 | case '\b': | |
baa9d179 | 3506 | pp_string (pp, "\\b"); |
4ee9c684 | 3507 | break; |
3508 | ||
3509 | case '\f': | |
baa9d179 | 3510 | pp_string (pp, "\\f"); |
4ee9c684 | 3511 | break; |
3512 | ||
3513 | case '\n': | |
baa9d179 | 3514 | pp_string (pp, "\\n"); |
4ee9c684 | 3515 | break; |
3516 | ||
3517 | case '\r': | |
baa9d179 | 3518 | pp_string (pp, "\\r"); |
4ee9c684 | 3519 | break; |
3520 | ||
3521 | case '\t': | |
baa9d179 | 3522 | pp_string (pp, "\\t"); |
4ee9c684 | 3523 | break; |
3524 | ||
3525 | case '\v': | |
baa9d179 | 3526 | pp_string (pp, "\\v"); |
4ee9c684 | 3527 | break; |
3528 | ||
3529 | case '\\': | |
baa9d179 | 3530 | pp_string (pp, "\\\\"); |
4ee9c684 | 3531 | break; |
3532 | ||
3533 | case '\"': | |
baa9d179 | 3534 | pp_string (pp, "\\\""); |
4ee9c684 | 3535 | break; |
3536 | ||
3537 | case '\'': | |
baa9d179 | 3538 | pp_string (pp, "\\'"); |
4ee9c684 | 3539 | break; |
3540 | ||
32a9fcf7 | 3541 | /* No need to handle \0; the loop terminates on \0. */ |
4ee9c684 | 3542 | |
3543 | case '\1': | |
baa9d179 | 3544 | pp_string (pp, "\\1"); |
4ee9c684 | 3545 | break; |
3546 | ||
3547 | case '\2': | |
baa9d179 | 3548 | pp_string (pp, "\\2"); |
4ee9c684 | 3549 | break; |
3550 | ||
3551 | case '\3': | |
baa9d179 | 3552 | pp_string (pp, "\\3"); |
4ee9c684 | 3553 | break; |
3554 | ||
3555 | case '\4': | |
baa9d179 | 3556 | pp_string (pp, "\\4"); |
4ee9c684 | 3557 | break; |
3558 | ||
3559 | case '\5': | |
baa9d179 | 3560 | pp_string (pp, "\\5"); |
4ee9c684 | 3561 | break; |
3562 | ||
3563 | case '\6': | |
baa9d179 | 3564 | pp_string (pp, "\\6"); |
4ee9c684 | 3565 | break; |
3566 | ||
3567 | case '\7': | |
baa9d179 | 3568 | pp_string (pp, "\\7"); |
4ee9c684 | 3569 | break; |
3570 | ||
3571 | default: | |
baa9d179 | 3572 | pp_character (pp, str[0]); |
4ee9c684 | 3573 | break; |
3574 | } | |
3575 | str++; | |
3576 | } | |
3577 | } | |
3578 | ||
3579 | static void | |
3580 | maybe_init_pretty_print (FILE *file) | |
3581 | { | |
baa9d179 | 3582 | if (!tree_pp) |
4ee9c684 | 3583 | { |
baa9d179 | 3584 | tree_pp = new pretty_printer (); |
3585 | pp_needs_newline (tree_pp) = true; | |
3586 | pp_translate_identifiers (tree_pp) = false; | |
4ee9c684 | 3587 | } |
3588 | ||
baa9d179 | 3589 | tree_pp->buffer->stream = file; |
4ee9c684 | 3590 | } |
3591 | ||
3592 | static void | |
baa9d179 | 3593 | newline_and_indent (pretty_printer *pp, int spc) |
4ee9c684 | 3594 | { |
baa9d179 | 3595 | pp_newline (pp); |
4ee9c684 | 3596 | INDENT (spc); |
3597 | } | |
ce084dfc | 3598 | |
3599 | /* Handle a %K format for TEXT. Separate from default_tree_printer so | |
3600 | it can also be used in front ends. | |
3601 | %K: a statement, from which EXPR_LOCATION and TREE_BLOCK will be recorded. | |
3602 | */ | |
3603 | ||
3604 | void | |
3605 | percent_K_format (text_info *text) | |
3606 | { | |
3607 | tree t = va_arg (*text->args_ptr, tree), block; | |
389a9009 | 3608 | text->set_location (0, EXPR_LOCATION (t)); |
ce084dfc | 3609 | gcc_assert (pp_ti_abstract_origin (text) != NULL); |
3610 | block = TREE_BLOCK (t); | |
3611 | *pp_ti_abstract_origin (text) = NULL; | |
a8cae5c5 | 3612 | |
3613 | if (in_lto_p) | |
3614 | { | |
3615 | /* ??? LTO drops all BLOCK_ABSTRACT_ORIGINs apart from those | |
3616 | representing the outermost block of an inlined function. | |
3617 | So walk the BLOCK tree until we hit such a scope. */ | |
3618 | while (block | |
3619 | && TREE_CODE (block) == BLOCK) | |
3620 | { | |
3621 | if (inlined_function_outer_scope_p (block)) | |
3622 | { | |
3623 | *pp_ti_abstract_origin (text) = block; | |
3624 | break; | |
3625 | } | |
3626 | block = BLOCK_SUPERCONTEXT (block); | |
3627 | } | |
3628 | return; | |
3629 | } | |
3630 | ||
ce084dfc | 3631 | while (block |
3632 | && TREE_CODE (block) == BLOCK | |
3633 | && BLOCK_ABSTRACT_ORIGIN (block)) | |
3634 | { | |
3635 | tree ao = BLOCK_ABSTRACT_ORIGIN (block); | |
3636 | ||
3637 | while (TREE_CODE (ao) == BLOCK | |
3638 | && BLOCK_ABSTRACT_ORIGIN (ao) | |
3639 | && BLOCK_ABSTRACT_ORIGIN (ao) != ao) | |
3640 | ao = BLOCK_ABSTRACT_ORIGIN (ao); | |
3641 | ||
3642 | if (TREE_CODE (ao) == FUNCTION_DECL) | |
3643 | { | |
3644 | *pp_ti_abstract_origin (text) = block; | |
3645 | break; | |
3646 | } | |
3647 | block = BLOCK_SUPERCONTEXT (block); | |
3648 | } | |
3649 | } | |
3650 | ||
3651 | /* Print the identifier ID to PRETTY-PRINTER. */ | |
3652 | ||
3653 | void | |
a94db6b0 | 3654 | pp_tree_identifier (pretty_printer *pp, tree id) |
ce084dfc | 3655 | { |
3656 | if (pp_translate_identifiers (pp)) | |
3657 | { | |
3658 | const char *text = identifier_to_locale (IDENTIFIER_POINTER (id)); | |
3659 | pp_append_text (pp, text, text + strlen (text)); | |
3660 | } | |
3661 | else | |
3662 | pp_append_text (pp, IDENTIFIER_POINTER (id), | |
3663 | IDENTIFIER_POINTER (id) + IDENTIFIER_LENGTH (id)); | |
3664 | } | |
7009b7bd | 3665 | |
3666 | /* A helper function that is used to dump function information before the | |
3667 | function dump. */ | |
3668 | ||
3669 | void | |
55b028fe | 3670 | dump_function_header (FILE *dump_file, tree fdecl, int flags) |
7009b7bd | 3671 | { |
3672 | const char *dname, *aname; | |
415d1b9a | 3673 | struct cgraph_node *node = cgraph_node::get (fdecl); |
7009b7bd | 3674 | struct function *fun = DECL_STRUCT_FUNCTION (fdecl); |
3675 | ||
3676 | dname = lang_hooks.decl_printable_name (fdecl, 2); | |
3677 | ||
3678 | if (DECL_ASSEMBLER_NAME_SET_P (fdecl)) | |
3679 | aname = (IDENTIFIER_POINTER | |
3680 | (DECL_ASSEMBLER_NAME (fdecl))); | |
3681 | else | |
3682 | aname = "<unset-asm-name>"; | |
3683 | ||
55b028fe | 3684 | fprintf (dump_file, "\n;; Function %s (%s, funcdef_no=%d", |
3685 | dname, aname, fun->funcdef_no); | |
3686 | if (!(flags & TDF_NOUID)) | |
3687 | fprintf (dump_file, ", decl_uid=%d", DECL_UID (fdecl)); | |
7009b7bd | 3688 | if (node) |
3689 | { | |
50d9ae66 | 3690 | fprintf (dump_file, ", cgraph_uid=%d", node->uid); |
02774f2d | 3691 | fprintf (dump_file, ", symbol_order=%d)%s\n\n", node->order, |
7009b7bd | 3692 | node->frequency == NODE_FREQUENCY_HOT |
3693 | ? " (hot)" | |
3694 | : node->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED | |
3695 | ? " (unlikely executed)" | |
3696 | : node->frequency == NODE_FREQUENCY_EXECUTED_ONCE | |
3697 | ? " (executed once)" | |
3698 | : ""); | |
3699 | } | |
3700 | else | |
55b028fe | 3701 | fprintf (dump_file, ")\n\n"); |
7009b7bd | 3702 | } |
3c59e4a7 | 3703 | |
3704 | /* Dump double_int D to pretty_printer PP. UNS is true | |
3705 | if D is unsigned and false otherwise. */ | |
3706 | void | |
3707 | pp_double_int (pretty_printer *pp, double_int d, bool uns) | |
3708 | { | |
3709 | if (d.fits_shwi ()) | |
3710 | pp_wide_integer (pp, d.low); | |
3711 | else if (d.fits_uhwi ()) | |
3712 | pp_unsigned_wide_integer (pp, d.low); | |
3713 | else | |
3714 | { | |
3715 | unsigned HOST_WIDE_INT low = d.low; | |
3716 | HOST_WIDE_INT high = d.high; | |
3717 | if (!uns && d.is_negative ()) | |
0cf78115 | 3718 | { |
3719 | pp_minus (pp); | |
3720 | high = ~high + !low; | |
3721 | low = -low; | |
3722 | } | |
3c59e4a7 | 3723 | /* Would "%x%0*x" or "%x%*0x" get zero-padding on all |
0cf78115 | 3724 | systems? */ |
3c59e4a7 | 3725 | sprintf (pp_buffer (pp)->digit_buffer, |
0cf78115 | 3726 | HOST_WIDE_INT_PRINT_DOUBLE_HEX, |
3727 | (unsigned HOST_WIDE_INT) high, low); | |
3c59e4a7 | 3728 | pp_string (pp, pp_buffer (pp)->digit_buffer); |
3729 | } | |
3730 | } |