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