| 1 | /* Pretty formatting of GIMPLE statements and expressions. |
| 2 | Copyright (C) 2001-2025 Free Software Foundation, Inc. |
| 3 | Contributed by Aldy Hernandez <[email protected]> and |
| 4 | Diego Novillo <[email protected]> |
| 5 | |
| 6 | This file is part of GCC. |
| 7 | |
| 8 | GCC is free software; you can redistribute it and/or modify it under |
| 9 | the terms of the GNU General Public License as published by the Free |
| 10 | Software Foundation; either version 3, or (at your option) any later |
| 11 | version. |
| 12 | |
| 13 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY |
| 14 | WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 15 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 16 | for more details. |
| 17 | |
| 18 | You should have received a copy of the GNU General Public License |
| 19 | along with GCC; see the file COPYING3. If not see |
| 20 | <http://www.gnu.org/licenses/>. */ |
| 21 | |
| 22 | #include "config.h" |
| 23 | #include "system.h" |
| 24 | #include "coretypes.h" |
| 25 | #include "dumpfile.h" |
| 26 | #include "backend.h" |
| 27 | #include "tree.h" |
| 28 | #include "gimple.h" |
| 29 | #include "gimple-predict.h" |
| 30 | #include "ssa.h" |
| 31 | #include "cgraph.h" |
| 32 | #include "gimple-pretty-print.h" |
| 33 | #include "value-range-pretty-print.h" |
| 34 | #include "internal-fn.h" |
| 35 | #include "tree-eh.h" |
| 36 | #include "gimple-iterator.h" |
| 37 | #include "tree-cfg.h" |
| 38 | #include "dumpfile.h" /* for dump_flags */ |
| 39 | #include "value-prof.h" |
| 40 | #include "trans-mem.h" |
| 41 | #include "cfganal.h" |
| 42 | #include "stringpool.h" |
| 43 | #include "attribs.h" |
| 44 | #include "asan.h" |
| 45 | #include "cfgloop.h" |
| 46 | #include "gimple-range.h" |
| 47 | |
| 48 | /* Disable warnings about quoting issues in the pp_xxx calls below |
| 49 | that (intentionally) don't follow GCC diagnostic conventions. */ |
| 50 | #if __GNUC__ >= 10 |
| 51 | # pragma GCC diagnostic push |
| 52 | # pragma GCC diagnostic ignored "-Wformat-diag" |
| 53 | #endif |
| 54 | |
| 55 | #define INDENT(SPACE) \ |
| 56 | do { int i; for (i = 0; i < SPACE; i++) pp_space (pp); } while (0) |
| 57 | |
| 58 | #define GIMPLE_NIY do_niy (pp,gs) |
| 59 | |
| 60 | /* Try to print on PP a default message for the unrecognized |
| 61 | gimple statement GS. */ |
| 62 | |
| 63 | static void |
| 64 | do_niy (pretty_printer *pp, const gimple *gs) |
| 65 | { |
| 66 | pp_printf (pp, "<<< Unknown GIMPLE statement: %s >>>\n", |
| 67 | gimple_code_name[(int) gimple_code (gs)]); |
| 68 | } |
| 69 | |
| 70 | |
| 71 | /* Emit a newline and SPC indentation spaces to PP. */ |
| 72 | |
| 73 | static void |
| 74 | newline_and_indent (pretty_printer *pp, int spc) |
| 75 | { |
| 76 | pp_newline (pp); |
| 77 | INDENT (spc); |
| 78 | } |
| 79 | |
| 80 | |
| 81 | /* Print the GIMPLE statement GS on stderr. */ |
| 82 | |
| 83 | DEBUG_FUNCTION void |
| 84 | debug_gimple_stmt (gimple *gs) |
| 85 | { |
| 86 | print_gimple_stmt (stderr, gs, 0, TDF_VOPS|TDF_MEMSYMS); |
| 87 | } |
| 88 | |
| 89 | |
| 90 | /* Return formatted string of a VALUE probability |
| 91 | (biased by REG_BR_PROB_BASE). Returned string is allocated |
| 92 | by xstrdup_for_dump. */ |
| 93 | |
| 94 | static const char * |
| 95 | dump_profile (profile_count &count) |
| 96 | { |
| 97 | char *buf = NULL; |
| 98 | if (!count.initialized_p ()) |
| 99 | return ""; |
| 100 | if (count.ipa_p ()) |
| 101 | buf = xasprintf ("[count: %" PRId64 "]", |
| 102 | count.to_gcov_type ()); |
| 103 | else if (count.initialized_p ()) |
| 104 | buf = xasprintf ("[local count: %" PRId64 "]", |
| 105 | count.to_gcov_type ()); |
| 106 | |
| 107 | const char *ret = xstrdup_for_dump (buf); |
| 108 | free (buf); |
| 109 | |
| 110 | return ret; |
| 111 | } |
| 112 | |
| 113 | /* Return formatted string of a VALUE probability |
| 114 | (biased by REG_BR_PROB_BASE). Returned string is allocated |
| 115 | by xstrdup_for_dump. */ |
| 116 | |
| 117 | static const char * |
| 118 | dump_probability (profile_probability probability) |
| 119 | { |
| 120 | float minimum = 0.01f; |
| 121 | float fvalue = -1; |
| 122 | |
| 123 | if (probability.initialized_p ()) |
| 124 | { |
| 125 | fvalue = probability.to_reg_br_prob_base () * 100.0f / REG_BR_PROB_BASE; |
| 126 | if (fvalue < minimum && probability.to_reg_br_prob_base ()) |
| 127 | fvalue = minimum; |
| 128 | } |
| 129 | |
| 130 | char *buf; |
| 131 | if (probability.initialized_p ()) |
| 132 | buf = xasprintf ("[%.2f%%]", fvalue); |
| 133 | else |
| 134 | buf = xasprintf ("[INV]"); |
| 135 | |
| 136 | const char *ret = xstrdup_for_dump (buf); |
| 137 | free (buf); |
| 138 | |
| 139 | return ret; |
| 140 | } |
| 141 | |
| 142 | /* Dump E probability to PP. */ |
| 143 | |
| 144 | static void |
| 145 | dump_edge_probability (pretty_printer *pp, edge e) |
| 146 | { |
| 147 | pp_scalar (pp, " %s", dump_probability (e->probability)); |
| 148 | } |
| 149 | |
| 150 | /* Print GIMPLE statement G to FILE using SPC indentation spaces and |
| 151 | FLAGS as in pp_gimple_stmt_1. */ |
| 152 | |
| 153 | void |
| 154 | print_gimple_stmt (FILE *file, gimple *g, int spc, dump_flags_t flags) |
| 155 | { |
| 156 | pretty_printer pp; |
| 157 | pp_needs_newline (&pp) = true; |
| 158 | pp.set_output_stream (file); |
| 159 | pp_gimple_stmt_1 (&pp, g, spc, flags); |
| 160 | pp_newline_and_flush (&pp); |
| 161 | } |
| 162 | |
| 163 | DEBUG_FUNCTION void |
| 164 | debug (gimple &ref) |
| 165 | { |
| 166 | print_gimple_stmt (stderr, &ref, 0, TDF_NONE); |
| 167 | } |
| 168 | |
| 169 | DEBUG_FUNCTION void |
| 170 | debug (gimple *ptr) |
| 171 | { |
| 172 | if (ptr) |
| 173 | debug (*ptr); |
| 174 | else |
| 175 | fprintf (stderr, "<nil>\n"); |
| 176 | } |
| 177 | |
| 178 | |
| 179 | /* Print GIMPLE statement G to FILE using SPC indentation spaces and |
| 180 | FLAGS as in pp_gimple_stmt_1. Print only the right-hand side |
| 181 | of the statement. */ |
| 182 | |
| 183 | void |
| 184 | print_gimple_expr (FILE *file, gimple *g, int spc, dump_flags_t flags) |
| 185 | { |
| 186 | flags |= TDF_RHS_ONLY; |
| 187 | pretty_printer pp; |
| 188 | pp_needs_newline (&pp) = true; |
| 189 | pp.set_output_stream (file); |
| 190 | pp_gimple_stmt_1 (&pp, g, spc, flags); |
| 191 | pp_flush (&pp); |
| 192 | } |
| 193 | |
| 194 | |
| 195 | /* Print the GIMPLE sequence SEQ on PP using SPC indentation |
| 196 | spaces and FLAGS as in pp_gimple_stmt_1. |
| 197 | The caller is responsible for calling pp_flush on PP to finalize |
| 198 | the pretty printer. */ |
| 199 | |
| 200 | static void |
| 201 | dump_gimple_seq (pretty_printer *pp, gimple_seq seq, int spc, |
| 202 | dump_flags_t flags) |
| 203 | { |
| 204 | gimple_stmt_iterator i; |
| 205 | |
| 206 | for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i)) |
| 207 | { |
| 208 | gimple *gs = gsi_stmt (i); |
| 209 | INDENT (spc); |
| 210 | pp_gimple_stmt_1 (pp, gs, spc, flags); |
| 211 | if (!gsi_one_before_end_p (i)) |
| 212 | pp_newline (pp); |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | |
| 217 | /* Print GIMPLE sequence SEQ to FILE using SPC indentation spaces and |
| 218 | FLAGS as in pp_gimple_stmt_1. */ |
| 219 | |
| 220 | void |
| 221 | print_gimple_seq (FILE *file, gimple_seq seq, int spc, dump_flags_t flags) |
| 222 | { |
| 223 | pretty_printer pp; |
| 224 | pp_needs_newline (&pp) = true; |
| 225 | pp.set_output_stream (file); |
| 226 | dump_gimple_seq (&pp, seq, spc, flags); |
| 227 | pp_newline_and_flush (&pp); |
| 228 | } |
| 229 | |
| 230 | |
| 231 | /* Print the GIMPLE sequence SEQ on stderr. */ |
| 232 | |
| 233 | DEBUG_FUNCTION void |
| 234 | debug_gimple_seq (gimple_seq seq) |
| 235 | { |
| 236 | print_gimple_seq (stderr, seq, 0, TDF_VOPS|TDF_MEMSYMS); |
| 237 | } |
| 238 | |
| 239 | |
| 240 | /* A simple helper to pretty-print some of the gimple tuples in the printf |
| 241 | style. The format modifiers are preceded by '%' and are: |
| 242 | 'G' - outputs a string corresponding to the code of the given gimple, |
| 243 | 'S' - outputs a gimple_seq with indent of spc + 2, |
| 244 | 'T' - outputs the tree t, |
| 245 | 'd' - outputs an int as a decimal, |
| 246 | 's' - outputs a string, |
| 247 | 'n' - outputs a newline, |
| 248 | 'x' - outputs an int as hexadecimal, |
| 249 | '+' - increases indent by 2 then outputs a newline, |
| 250 | '-' - decreases indent by 2 then outputs a newline. */ |
| 251 | |
| 252 | static void |
| 253 | dump_gimple_fmt (pretty_printer *pp, int spc, dump_flags_t flags, |
| 254 | const char *fmt, ...) |
| 255 | { |
| 256 | va_list args; |
| 257 | const char *c; |
| 258 | const char *tmp; |
| 259 | |
| 260 | va_start (args, fmt); |
| 261 | for (c = fmt; *c; c++) |
| 262 | { |
| 263 | if (*c == '%') |
| 264 | { |
| 265 | gimple_seq seq; |
| 266 | tree t; |
| 267 | gimple *g; |
| 268 | switch (*++c) |
| 269 | { |
| 270 | case 'G': |
| 271 | g = va_arg (args, gimple *); |
| 272 | tmp = gimple_code_name[gimple_code (g)]; |
| 273 | pp_string (pp, tmp); |
| 274 | break; |
| 275 | |
| 276 | case 'S': |
| 277 | seq = va_arg (args, gimple_seq); |
| 278 | pp_newline (pp); |
| 279 | dump_gimple_seq (pp, seq, spc + 2, flags); |
| 280 | newline_and_indent (pp, spc); |
| 281 | break; |
| 282 | |
| 283 | case 'T': |
| 284 | t = va_arg (args, tree); |
| 285 | if (t == NULL_TREE) |
| 286 | pp_string (pp, "NULL"); |
| 287 | else |
| 288 | dump_generic_node (pp, t, spc, flags, false); |
| 289 | break; |
| 290 | |
| 291 | case 'd': |
| 292 | pp_decimal_int (pp, va_arg (args, int)); |
| 293 | break; |
| 294 | |
| 295 | case 's': |
| 296 | pp_string (pp, va_arg (args, char *)); |
| 297 | break; |
| 298 | |
| 299 | case 'n': |
| 300 | newline_and_indent (pp, spc); |
| 301 | break; |
| 302 | |
| 303 | case 'x': |
| 304 | pp_scalar (pp, "%x", va_arg (args, int)); |
| 305 | break; |
| 306 | |
| 307 | case '+': |
| 308 | spc += 2; |
| 309 | newline_and_indent (pp, spc); |
| 310 | break; |
| 311 | |
| 312 | case '-': |
| 313 | spc -= 2; |
| 314 | newline_and_indent (pp, spc); |
| 315 | break; |
| 316 | |
| 317 | default: |
| 318 | gcc_unreachable (); |
| 319 | } |
| 320 | } |
| 321 | else |
| 322 | pp_character (pp, *c); |
| 323 | } |
| 324 | va_end (args); |
| 325 | } |
| 326 | |
| 327 | |
| 328 | /* Helper for dump_gimple_assign. Print the unary RHS of the |
| 329 | assignment GS. PP, SPC and FLAGS are as in pp_gimple_stmt_1. */ |
| 330 | |
| 331 | static void |
| 332 | dump_unary_rhs (pretty_printer *pp, const gassign *gs, int spc, |
| 333 | dump_flags_t flags) |
| 334 | { |
| 335 | enum tree_code rhs_code = gimple_assign_rhs_code (gs); |
| 336 | tree lhs = gimple_assign_lhs (gs); |
| 337 | tree rhs = gimple_assign_rhs1 (gs); |
| 338 | |
| 339 | switch (rhs_code) |
| 340 | { |
| 341 | case VIEW_CONVERT_EXPR: |
| 342 | dump_generic_node (pp, rhs, spc, flags, false); |
| 343 | break; |
| 344 | |
| 345 | case FIXED_CONVERT_EXPR: |
| 346 | case ADDR_SPACE_CONVERT_EXPR: |
| 347 | case FIX_TRUNC_EXPR: |
| 348 | case FLOAT_EXPR: |
| 349 | CASE_CONVERT: |
| 350 | pp_left_paren (pp); |
| 351 | dump_generic_node (pp, TREE_TYPE (lhs), spc, flags, false); |
| 352 | pp_string (pp, ") "); |
| 353 | if (op_prio (rhs) < op_code_prio (rhs_code)) |
| 354 | { |
| 355 | pp_left_paren (pp); |
| 356 | dump_generic_node (pp, rhs, spc, flags, false); |
| 357 | pp_right_paren (pp); |
| 358 | } |
| 359 | else |
| 360 | dump_generic_node (pp, rhs, spc, flags, false); |
| 361 | break; |
| 362 | |
| 363 | case PAREN_EXPR: |
| 364 | pp_string (pp, "(("); |
| 365 | dump_generic_node (pp, rhs, spc, flags, false); |
| 366 | pp_string (pp, "))"); |
| 367 | break; |
| 368 | |
| 369 | case ABS_EXPR: |
| 370 | case ABSU_EXPR: |
| 371 | if (flags & TDF_GIMPLE) |
| 372 | { |
| 373 | pp_string (pp, |
| 374 | rhs_code == ABS_EXPR ? "__ABS " : "__ABSU "); |
| 375 | dump_generic_node (pp, rhs, spc, flags, false); |
| 376 | } |
| 377 | else |
| 378 | { |
| 379 | pp_string (pp, |
| 380 | rhs_code == ABS_EXPR ? "ABS_EXPR <" : "ABSU_EXPR <"); |
| 381 | dump_generic_node (pp, rhs, spc, flags, false); |
| 382 | pp_greater (pp); |
| 383 | } |
| 384 | break; |
| 385 | |
| 386 | default: |
| 387 | if (TREE_CODE_CLASS (rhs_code) == tcc_declaration |
| 388 | || TREE_CODE_CLASS (rhs_code) == tcc_constant |
| 389 | || TREE_CODE_CLASS (rhs_code) == tcc_reference |
| 390 | || rhs_code == SSA_NAME |
| 391 | || rhs_code == ADDR_EXPR |
| 392 | || rhs_code == CONSTRUCTOR) |
| 393 | { |
| 394 | dump_generic_node (pp, rhs, spc, flags, false); |
| 395 | break; |
| 396 | } |
| 397 | else if (rhs_code == BIT_NOT_EXPR) |
| 398 | pp_complement (pp); |
| 399 | else if (rhs_code == TRUTH_NOT_EXPR) |
| 400 | pp_exclamation (pp); |
| 401 | else if (rhs_code == NEGATE_EXPR) |
| 402 | pp_minus (pp); |
| 403 | else |
| 404 | { |
| 405 | pp_left_bracket (pp); |
| 406 | pp_string (pp, get_tree_code_name (rhs_code)); |
| 407 | pp_string (pp, "] "); |
| 408 | } |
| 409 | |
| 410 | if (op_prio (rhs) < op_code_prio (rhs_code)) |
| 411 | { |
| 412 | pp_left_paren (pp); |
| 413 | dump_generic_node (pp, rhs, spc, flags, false); |
| 414 | pp_right_paren (pp); |
| 415 | } |
| 416 | else |
| 417 | dump_generic_node (pp, rhs, spc, flags, false); |
| 418 | break; |
| 419 | } |
| 420 | } |
| 421 | |
| 422 | |
| 423 | /* Helper for dump_gimple_assign. Print the binary RHS of the |
| 424 | assignment GS. PP, SPC and FLAGS are as in pp_gimple_stmt_1. */ |
| 425 | |
| 426 | static void |
| 427 | dump_binary_rhs (pretty_printer *pp, const gassign *gs, int spc, |
| 428 | dump_flags_t flags) |
| 429 | { |
| 430 | const char *p; |
| 431 | enum tree_code code = gimple_assign_rhs_code (gs); |
| 432 | switch (code) |
| 433 | { |
| 434 | case MIN_EXPR: |
| 435 | case MAX_EXPR: |
| 436 | if (flags & TDF_GIMPLE) |
| 437 | { |
| 438 | pp_string (pp, code == MIN_EXPR ? "__MIN (" : "__MAX ("); |
| 439 | dump_generic_node (pp, gimple_assign_rhs1 (gs), spc, flags, |
| 440 | false); |
| 441 | pp_string (pp, ", "); |
| 442 | dump_generic_node (pp, gimple_assign_rhs2 (gs), spc, flags, |
| 443 | false); |
| 444 | pp_string (pp, ")"); |
| 445 | break; |
| 446 | } |
| 447 | else |
| 448 | { |
| 449 | gcc_fallthrough (); |
| 450 | } |
| 451 | case COMPLEX_EXPR: |
| 452 | case VEC_WIDEN_MULT_HI_EXPR: |
| 453 | case VEC_WIDEN_MULT_LO_EXPR: |
| 454 | case VEC_WIDEN_MULT_EVEN_EXPR: |
| 455 | case VEC_WIDEN_MULT_ODD_EXPR: |
| 456 | case VEC_PACK_TRUNC_EXPR: |
| 457 | case VEC_PACK_SAT_EXPR: |
| 458 | case VEC_PACK_FIX_TRUNC_EXPR: |
| 459 | case VEC_PACK_FLOAT_EXPR: |
| 460 | case VEC_WIDEN_LSHIFT_HI_EXPR: |
| 461 | case VEC_WIDEN_LSHIFT_LO_EXPR: |
| 462 | case VEC_SERIES_EXPR: |
| 463 | for (p = get_tree_code_name (code); *p; p++) |
| 464 | pp_character (pp, TOUPPER (*p)); |
| 465 | pp_string (pp, " <"); |
| 466 | dump_generic_node (pp, gimple_assign_rhs1 (gs), spc, flags, false); |
| 467 | pp_string (pp, ", "); |
| 468 | dump_generic_node (pp, gimple_assign_rhs2 (gs), spc, flags, false); |
| 469 | pp_greater (pp); |
| 470 | break; |
| 471 | |
| 472 | default: |
| 473 | if (op_prio (gimple_assign_rhs1 (gs)) <= op_code_prio (code)) |
| 474 | { |
| 475 | pp_left_paren (pp); |
| 476 | dump_generic_node (pp, gimple_assign_rhs1 (gs), spc, flags, |
| 477 | false); |
| 478 | pp_right_paren (pp); |
| 479 | } |
| 480 | else |
| 481 | dump_generic_node (pp, gimple_assign_rhs1 (gs), spc, flags, false); |
| 482 | pp_space (pp); |
| 483 | pp_string (pp, op_symbol_code (gimple_assign_rhs_code (gs), flags)); |
| 484 | pp_space (pp); |
| 485 | if (op_prio (gimple_assign_rhs2 (gs)) <= op_code_prio (code)) |
| 486 | { |
| 487 | pp_left_paren (pp); |
| 488 | dump_generic_node (pp, gimple_assign_rhs2 (gs), spc, flags, |
| 489 | false); |
| 490 | pp_right_paren (pp); |
| 491 | } |
| 492 | else |
| 493 | dump_generic_node (pp, gimple_assign_rhs2 (gs), spc, flags, false); |
| 494 | } |
| 495 | } |
| 496 | |
| 497 | /* Helper for dump_gimple_assign. Print the ternary RHS of the |
| 498 | assignment GS. PP, SPC and FLAGS are as in pp_gimple_stmt_1. */ |
| 499 | |
| 500 | static void |
| 501 | dump_ternary_rhs (pretty_printer *pp, const gassign *gs, int spc, |
| 502 | dump_flags_t flags) |
| 503 | { |
| 504 | const char *p; |
| 505 | enum tree_code code = gimple_assign_rhs_code (gs); |
| 506 | switch (code) |
| 507 | { |
| 508 | case WIDEN_MULT_PLUS_EXPR: |
| 509 | case WIDEN_MULT_MINUS_EXPR: |
| 510 | for (p = get_tree_code_name (code); *p; p++) |
| 511 | pp_character (pp, TOUPPER (*p)); |
| 512 | pp_string (pp, " <"); |
| 513 | dump_generic_node (pp, gimple_assign_rhs1 (gs), spc, flags, false); |
| 514 | pp_string (pp, ", "); |
| 515 | dump_generic_node (pp, gimple_assign_rhs2 (gs), spc, flags, false); |
| 516 | pp_string (pp, ", "); |
| 517 | dump_generic_node (pp, gimple_assign_rhs3 (gs), spc, flags, false); |
| 518 | pp_greater (pp); |
| 519 | break; |
| 520 | |
| 521 | case DOT_PROD_EXPR: |
| 522 | pp_string (pp, "DOT_PROD_EXPR <"); |
| 523 | dump_generic_node (pp, gimple_assign_rhs1 (gs), spc, flags, false); |
| 524 | pp_string (pp, ", "); |
| 525 | dump_generic_node (pp, gimple_assign_rhs2 (gs), spc, flags, false); |
| 526 | pp_string (pp, ", "); |
| 527 | dump_generic_node (pp, gimple_assign_rhs3 (gs), spc, flags, false); |
| 528 | pp_greater (pp); |
| 529 | break; |
| 530 | |
| 531 | case SAD_EXPR: |
| 532 | pp_string (pp, "SAD_EXPR <"); |
| 533 | dump_generic_node (pp, gimple_assign_rhs1 (gs), spc, flags, false); |
| 534 | pp_string (pp, ", "); |
| 535 | dump_generic_node (pp, gimple_assign_rhs2 (gs), spc, flags, false); |
| 536 | pp_string (pp, ", "); |
| 537 | dump_generic_node (pp, gimple_assign_rhs3 (gs), spc, flags, false); |
| 538 | pp_greater (pp); |
| 539 | break; |
| 540 | |
| 541 | case VEC_PERM_EXPR: |
| 542 | if (flags & TDF_GIMPLE) |
| 543 | pp_string (pp, "__VEC_PERM ("); |
| 544 | else |
| 545 | pp_string (pp, "VEC_PERM_EXPR <"); |
| 546 | dump_generic_node (pp, gimple_assign_rhs1 (gs), spc, flags, false); |
| 547 | pp_string (pp, ", "); |
| 548 | dump_generic_node (pp, gimple_assign_rhs2 (gs), spc, flags, false); |
| 549 | pp_string (pp, ", "); |
| 550 | dump_generic_node (pp, gimple_assign_rhs3 (gs), spc, flags, false); |
| 551 | if (flags & TDF_GIMPLE) |
| 552 | pp_right_paren (pp); |
| 553 | else |
| 554 | pp_greater (pp); |
| 555 | break; |
| 556 | |
| 557 | case REALIGN_LOAD_EXPR: |
| 558 | pp_string (pp, "REALIGN_LOAD <"); |
| 559 | dump_generic_node (pp, gimple_assign_rhs1 (gs), spc, flags, false); |
| 560 | pp_string (pp, ", "); |
| 561 | dump_generic_node (pp, gimple_assign_rhs2 (gs), spc, flags, false); |
| 562 | pp_string (pp, ", "); |
| 563 | dump_generic_node (pp, gimple_assign_rhs3 (gs), spc, flags, false); |
| 564 | pp_greater (pp); |
| 565 | break; |
| 566 | |
| 567 | case COND_EXPR: |
| 568 | dump_generic_node (pp, gimple_assign_rhs1 (gs), spc, flags, false); |
| 569 | pp_string (pp, " ? "); |
| 570 | dump_generic_node (pp, gimple_assign_rhs2 (gs), spc, flags, false); |
| 571 | pp_string (pp, " : "); |
| 572 | dump_generic_node (pp, gimple_assign_rhs3 (gs), spc, flags, false); |
| 573 | break; |
| 574 | |
| 575 | case VEC_COND_EXPR: |
| 576 | pp_string (pp, "VEC_COND_EXPR <"); |
| 577 | dump_generic_node (pp, gimple_assign_rhs1 (gs), spc, flags, false); |
| 578 | pp_string (pp, ", "); |
| 579 | dump_generic_node (pp, gimple_assign_rhs2 (gs), spc, flags, false); |
| 580 | pp_string (pp, ", "); |
| 581 | dump_generic_node (pp, gimple_assign_rhs3 (gs), spc, flags, false); |
| 582 | pp_greater (pp); |
| 583 | break; |
| 584 | |
| 585 | case BIT_INSERT_EXPR: |
| 586 | if (flags & TDF_GIMPLE) |
| 587 | { |
| 588 | pp_string (pp, "__BIT_INSERT ("); |
| 589 | dump_generic_node (pp, gimple_assign_rhs1 (gs), spc, |
| 590 | flags | TDF_SLIM, false); |
| 591 | pp_string (pp, ", "); |
| 592 | dump_generic_node (pp, gimple_assign_rhs2 (gs), spc, |
| 593 | flags | TDF_SLIM, false); |
| 594 | pp_string (pp, ", "); |
| 595 | dump_generic_node (pp, gimple_assign_rhs3 (gs), spc, |
| 596 | flags | TDF_SLIM, false); |
| 597 | pp_right_paren (pp); |
| 598 | } |
| 599 | else |
| 600 | { |
| 601 | pp_string (pp, "BIT_INSERT_EXPR <"); |
| 602 | dump_generic_node (pp, gimple_assign_rhs1 (gs), |
| 603 | spc, flags, false); |
| 604 | pp_string (pp, ", "); |
| 605 | dump_generic_node (pp, gimple_assign_rhs2 (gs), |
| 606 | spc, flags, false); |
| 607 | pp_string (pp, ", "); |
| 608 | dump_generic_node (pp, gimple_assign_rhs3 (gs), |
| 609 | spc, flags, false); |
| 610 | if (INTEGRAL_TYPE_P (TREE_TYPE (gimple_assign_rhs2 (gs)))) |
| 611 | { |
| 612 | pp_string (pp, " ("); |
| 613 | pp_decimal_int (pp, TYPE_PRECISION |
| 614 | (TREE_TYPE (gimple_assign_rhs2 (gs)))); |
| 615 | pp_string (pp, " bits)"); |
| 616 | } |
| 617 | pp_greater (pp); |
| 618 | } |
| 619 | break; |
| 620 | |
| 621 | default: |
| 622 | gcc_unreachable (); |
| 623 | } |
| 624 | } |
| 625 | |
| 626 | |
| 627 | /* Dump the gimple assignment GS. PP, SPC and FLAGS are as in |
| 628 | pp_gimple_stmt_1. */ |
| 629 | |
| 630 | static void |
| 631 | dump_gimple_assign (pretty_printer *pp, const gassign *gs, int spc, |
| 632 | dump_flags_t flags) |
| 633 | { |
| 634 | if (flags & TDF_RAW) |
| 635 | { |
| 636 | tree arg1 = NULL; |
| 637 | tree arg2 = NULL; |
| 638 | tree arg3 = NULL; |
| 639 | switch (gimple_num_ops (gs)) |
| 640 | { |
| 641 | case 4: |
| 642 | arg3 = gimple_assign_rhs3 (gs); |
| 643 | /* FALLTHRU */ |
| 644 | case 3: |
| 645 | arg2 = gimple_assign_rhs2 (gs); |
| 646 | /* FALLTHRU */ |
| 647 | case 2: |
| 648 | arg1 = gimple_assign_rhs1 (gs); |
| 649 | break; |
| 650 | default: |
| 651 | gcc_unreachable (); |
| 652 | } |
| 653 | |
| 654 | dump_gimple_fmt (pp, spc, flags, "%G <%s, %T, %T, %T, %T>", gs, |
| 655 | get_tree_code_name (gimple_assign_rhs_code (gs)), |
| 656 | gimple_assign_lhs (gs), arg1, arg2, arg3); |
| 657 | } |
| 658 | else |
| 659 | { |
| 660 | if (!(flags & TDF_RHS_ONLY)) |
| 661 | { |
| 662 | dump_generic_node (pp, gimple_assign_lhs (gs), spc, flags, false); |
| 663 | pp_space (pp); |
| 664 | pp_equal (pp); |
| 665 | |
| 666 | if (gimple_assign_nontemporal_move_p (gs)) |
| 667 | pp_string (pp, "{nt}"); |
| 668 | |
| 669 | if (gimple_has_volatile_ops (gs)) |
| 670 | pp_string (pp, "{v}"); |
| 671 | |
| 672 | pp_space (pp); |
| 673 | } |
| 674 | |
| 675 | if (gimple_num_ops (gs) == 2) |
| 676 | dump_unary_rhs (pp, gs, spc, |
| 677 | ((flags & TDF_GIMPLE) |
| 678 | && gimple_assign_rhs_class (gs) != GIMPLE_SINGLE_RHS) |
| 679 | ? (flags | TDF_GIMPLE_VAL) : flags); |
| 680 | else if (gimple_num_ops (gs) == 3) |
| 681 | dump_binary_rhs (pp, gs, spc, |
| 682 | (flags & TDF_GIMPLE) |
| 683 | ? (flags | TDF_GIMPLE_VAL) : flags); |
| 684 | else if (gimple_num_ops (gs) == 4) |
| 685 | dump_ternary_rhs (pp, gs, spc, |
| 686 | (flags & TDF_GIMPLE) |
| 687 | ? (flags | TDF_GIMPLE_VAL) : flags); |
| 688 | else |
| 689 | gcc_unreachable (); |
| 690 | if (!(flags & TDF_RHS_ONLY)) |
| 691 | pp_semicolon (pp); |
| 692 | } |
| 693 | } |
| 694 | |
| 695 | |
| 696 | /* Dump the return statement GS. PP, SPC and FLAGS are as in |
| 697 | pp_gimple_stmt_1. */ |
| 698 | |
| 699 | static void |
| 700 | dump_gimple_return (pretty_printer *pp, const greturn *gs, int spc, |
| 701 | dump_flags_t flags) |
| 702 | { |
| 703 | tree t; |
| 704 | |
| 705 | t = gimple_return_retval (gs); |
| 706 | if (flags & TDF_RAW) |
| 707 | dump_gimple_fmt (pp, spc, flags, "%G <%T>", gs, t); |
| 708 | else |
| 709 | { |
| 710 | pp_string (pp, "return"); |
| 711 | if (t) |
| 712 | { |
| 713 | pp_space (pp); |
| 714 | dump_generic_node (pp, t, spc, flags, false); |
| 715 | } |
| 716 | pp_semicolon (pp); |
| 717 | } |
| 718 | } |
| 719 | |
| 720 | |
| 721 | /* Dump the call arguments for a gimple call. PP, FLAGS are as in |
| 722 | dump_gimple_call. */ |
| 723 | |
| 724 | static void |
| 725 | dump_gimple_call_args (pretty_printer *pp, const gcall *gs, |
| 726 | dump_flags_t flags) |
| 727 | { |
| 728 | size_t i = 0; |
| 729 | |
| 730 | /* Pretty print first arg to certain internal fns. */ |
| 731 | if (gimple_call_internal_p (gs)) |
| 732 | { |
| 733 | const char *const *enums = NULL; |
| 734 | unsigned limit = 0; |
| 735 | |
| 736 | switch (gimple_call_internal_fn (gs)) |
| 737 | { |
| 738 | case IFN_UNIQUE: |
| 739 | #define DEF(X) #X |
| 740 | static const char *const unique_args[] = {IFN_UNIQUE_CODES}; |
| 741 | #undef DEF |
| 742 | enums = unique_args; |
| 743 | |
| 744 | limit = ARRAY_SIZE (unique_args); |
| 745 | break; |
| 746 | |
| 747 | case IFN_GOACC_LOOP: |
| 748 | #define DEF(X) #X |
| 749 | static const char *const loop_args[] = {IFN_GOACC_LOOP_CODES}; |
| 750 | #undef DEF |
| 751 | enums = loop_args; |
| 752 | limit = ARRAY_SIZE (loop_args); |
| 753 | break; |
| 754 | |
| 755 | case IFN_GOACC_REDUCTION: |
| 756 | #define DEF(X) #X |
| 757 | static const char *const reduction_args[] |
| 758 | = {IFN_GOACC_REDUCTION_CODES}; |
| 759 | #undef DEF |
| 760 | enums = reduction_args; |
| 761 | limit = ARRAY_SIZE (reduction_args); |
| 762 | break; |
| 763 | |
| 764 | case IFN_HWASAN_MARK: |
| 765 | case IFN_ASAN_MARK: |
| 766 | #define DEF(X) #X |
| 767 | static const char *const asan_mark_args[] = {IFN_ASAN_MARK_FLAGS}; |
| 768 | #undef DEF |
| 769 | enums = asan_mark_args; |
| 770 | limit = ARRAY_SIZE (asan_mark_args); |
| 771 | break; |
| 772 | |
| 773 | default: |
| 774 | break; |
| 775 | } |
| 776 | if (limit) |
| 777 | { |
| 778 | tree arg0 = gimple_call_arg (gs, 0); |
| 779 | HOST_WIDE_INT v; |
| 780 | |
| 781 | if (TREE_CODE (arg0) == INTEGER_CST |
| 782 | && tree_fits_shwi_p (arg0) |
| 783 | && (v = tree_to_shwi (arg0)) >= 0 && v < limit) |
| 784 | { |
| 785 | i++; |
| 786 | pp_string (pp, enums[v]); |
| 787 | } |
| 788 | } |
| 789 | } |
| 790 | |
| 791 | for (; i < gimple_call_num_args (gs); i++) |
| 792 | { |
| 793 | if (i) |
| 794 | pp_string (pp, ", "); |
| 795 | dump_generic_node (pp, gimple_call_arg (gs, i), 0, flags, false); |
| 796 | } |
| 797 | |
| 798 | if (gimple_call_va_arg_pack_p (gs)) |
| 799 | { |
| 800 | if (i) |
| 801 | pp_string (pp, ", "); |
| 802 | |
| 803 | pp_string (pp, "__builtin_va_arg_pack ()"); |
| 804 | } |
| 805 | } |
| 806 | |
| 807 | /* Dump the points-to solution *PT to PP. */ |
| 808 | |
| 809 | static void |
| 810 | pp_points_to_solution (pretty_printer *pp, const pt_solution *pt) |
| 811 | { |
| 812 | if (pt->anything) |
| 813 | { |
| 814 | pp_string (pp, "anything "); |
| 815 | return; |
| 816 | } |
| 817 | if (pt->nonlocal) |
| 818 | pp_string (pp, "nonlocal "); |
| 819 | if (pt->escaped) |
| 820 | pp_string (pp, "escaped "); |
| 821 | if (pt->ipa_escaped) |
| 822 | pp_string (pp, "unit-escaped "); |
| 823 | if (pt->null) |
| 824 | pp_string (pp, "null "); |
| 825 | if (pt->const_pool) |
| 826 | pp_string (pp, "const-pool "); |
| 827 | if (pt->vars |
| 828 | && !bitmap_empty_p (pt->vars)) |
| 829 | { |
| 830 | bitmap_iterator bi; |
| 831 | unsigned i; |
| 832 | pp_string (pp, "{ "); |
| 833 | EXECUTE_IF_SET_IN_BITMAP (pt->vars, 0, i, bi) |
| 834 | { |
| 835 | pp_string (pp, "D."); |
| 836 | pp_decimal_int (pp, i); |
| 837 | pp_space (pp); |
| 838 | } |
| 839 | pp_right_brace (pp); |
| 840 | if (pt->vars_contains_nonlocal |
| 841 | || pt->vars_contains_escaped |
| 842 | || pt->vars_contains_escaped_heap |
| 843 | || pt->vars_contains_restrict |
| 844 | || pt->vars_contains_interposable) |
| 845 | { |
| 846 | const char *comma = ""; |
| 847 | pp_string (pp, " ("); |
| 848 | if (pt->vars_contains_nonlocal) |
| 849 | { |
| 850 | pp_string (pp, "nonlocal"); |
| 851 | comma = ", "; |
| 852 | } |
| 853 | if (pt->vars_contains_escaped) |
| 854 | { |
| 855 | pp_string (pp, comma); |
| 856 | pp_string (pp, "escaped"); |
| 857 | comma = ", "; |
| 858 | } |
| 859 | if (pt->vars_contains_escaped_heap) |
| 860 | { |
| 861 | pp_string (pp, comma); |
| 862 | pp_string (pp, "escaped heap"); |
| 863 | comma = ", "; |
| 864 | } |
| 865 | if (pt->vars_contains_restrict) |
| 866 | { |
| 867 | pp_string (pp, comma); |
| 868 | pp_string (pp, "restrict"); |
| 869 | comma = ", "; |
| 870 | } |
| 871 | if (pt->vars_contains_interposable) |
| 872 | { |
| 873 | pp_string (pp, comma); |
| 874 | pp_string (pp, "interposable"); |
| 875 | } |
| 876 | pp_string (pp, ")"); |
| 877 | } |
| 878 | |
| 879 | } |
| 880 | } |
| 881 | |
| 882 | /* Dump the call statement GS. PP, SPC and FLAGS are as in |
| 883 | pp_gimple_stmt_1. */ |
| 884 | |
| 885 | static void |
| 886 | dump_gimple_call (pretty_printer *pp, const gcall *gs, int spc, |
| 887 | dump_flags_t flags) |
| 888 | { |
| 889 | tree lhs = gimple_call_lhs (gs); |
| 890 | tree fn = gimple_call_fn (gs); |
| 891 | |
| 892 | if (flags & TDF_ALIAS) |
| 893 | { |
| 894 | const pt_solution *pt; |
| 895 | pt = gimple_call_use_set (gs); |
| 896 | if (!pt_solution_empty_p (pt)) |
| 897 | { |
| 898 | pp_string (pp, "# USE = "); |
| 899 | pp_points_to_solution (pp, pt); |
| 900 | newline_and_indent (pp, spc); |
| 901 | } |
| 902 | pt = gimple_call_clobber_set (gs); |
| 903 | if (!pt_solution_empty_p (pt)) |
| 904 | { |
| 905 | pp_string (pp, "# CLB = "); |
| 906 | pp_points_to_solution (pp, pt); |
| 907 | newline_and_indent (pp, spc); |
| 908 | } |
| 909 | } |
| 910 | |
| 911 | if (flags & TDF_RAW) |
| 912 | { |
| 913 | if (gimple_call_internal_p (gs)) |
| 914 | dump_gimple_fmt (pp, spc, flags, "%G <.%s, %T", gs, |
| 915 | internal_fn_name (gimple_call_internal_fn (gs)), lhs); |
| 916 | else |
| 917 | dump_gimple_fmt (pp, spc, flags, "%G <%T, %T", gs, fn, lhs); |
| 918 | if (gimple_call_num_args (gs) > 0) |
| 919 | { |
| 920 | pp_string (pp, ", "); |
| 921 | dump_gimple_call_args (pp, gs, flags); |
| 922 | } |
| 923 | pp_greater (pp); |
| 924 | } |
| 925 | else |
| 926 | { |
| 927 | if (lhs && !(flags & TDF_RHS_ONLY)) |
| 928 | { |
| 929 | dump_generic_node (pp, lhs, spc, flags, false); |
| 930 | pp_string (pp, " ="); |
| 931 | |
| 932 | if (gimple_has_volatile_ops (gs)) |
| 933 | pp_string (pp, "{v}"); |
| 934 | |
| 935 | pp_space (pp); |
| 936 | } |
| 937 | if (gimple_call_internal_p (gs)) |
| 938 | { |
| 939 | pp_dot (pp); |
| 940 | pp_string (pp, internal_fn_name (gimple_call_internal_fn (gs))); |
| 941 | } |
| 942 | else |
| 943 | print_call_name (pp, fn, flags); |
| 944 | pp_string (pp, " ("); |
| 945 | dump_gimple_call_args (pp, gs, flags); |
| 946 | pp_right_paren (pp); |
| 947 | if (!(flags & TDF_RHS_ONLY)) |
| 948 | pp_semicolon (pp); |
| 949 | } |
| 950 | |
| 951 | if (gimple_call_chain (gs)) |
| 952 | { |
| 953 | pp_string (pp, " [static-chain: "); |
| 954 | dump_generic_node (pp, gimple_call_chain (gs), spc, flags, false); |
| 955 | pp_right_bracket (pp); |
| 956 | } |
| 957 | |
| 958 | if (gimple_call_return_slot_opt_p (gs)) |
| 959 | pp_string (pp, " [return slot optimization]"); |
| 960 | if (gimple_call_tail_p (gs)) |
| 961 | pp_string (pp, " [tail call]"); |
| 962 | if (gimple_call_must_tail_p (gs)) |
| 963 | pp_string (pp, " [must tail call]"); |
| 964 | |
| 965 | if (fn == NULL) |
| 966 | return; |
| 967 | |
| 968 | /* Dump the arguments of _ITM_beginTransaction sanely. */ |
| 969 | if (TREE_CODE (fn) == ADDR_EXPR) |
| 970 | fn = TREE_OPERAND (fn, 0); |
| 971 | if (TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn)) |
| 972 | pp_string (pp, " [tm-clone]"); |
| 973 | if (TREE_CODE (fn) == FUNCTION_DECL |
| 974 | && fndecl_built_in_p (fn, BUILT_IN_TM_START) |
| 975 | && gimple_call_num_args (gs) > 0) |
| 976 | { |
| 977 | tree t = gimple_call_arg (gs, 0); |
| 978 | unsigned HOST_WIDE_INT props; |
| 979 | gcc_assert (TREE_CODE (t) == INTEGER_CST); |
| 980 | |
| 981 | pp_string (pp, " [ "); |
| 982 | |
| 983 | /* Get the transaction code properties. */ |
| 984 | props = TREE_INT_CST_LOW (t); |
| 985 | |
| 986 | if (props & PR_INSTRUMENTEDCODE) |
| 987 | pp_string (pp, "instrumentedCode "); |
| 988 | if (props & PR_UNINSTRUMENTEDCODE) |
| 989 | pp_string (pp, "uninstrumentedCode "); |
| 990 | if (props & PR_HASNOXMMUPDATE) |
| 991 | pp_string (pp, "hasNoXMMUpdate "); |
| 992 | if (props & PR_HASNOABORT) |
| 993 | pp_string (pp, "hasNoAbort "); |
| 994 | if (props & PR_HASNOIRREVOCABLE) |
| 995 | pp_string (pp, "hasNoIrrevocable "); |
| 996 | if (props & PR_DOESGOIRREVOCABLE) |
| 997 | pp_string (pp, "doesGoIrrevocable "); |
| 998 | if (props & PR_HASNOSIMPLEREADS) |
| 999 | pp_string (pp, "hasNoSimpleReads "); |
| 1000 | if (props & PR_AWBARRIERSOMITTED) |
| 1001 | pp_string (pp, "awBarriersOmitted "); |
| 1002 | if (props & PR_RARBARRIERSOMITTED) |
| 1003 | pp_string (pp, "RaRBarriersOmitted "); |
| 1004 | if (props & PR_UNDOLOGCODE) |
| 1005 | pp_string (pp, "undoLogCode "); |
| 1006 | if (props & PR_PREFERUNINSTRUMENTED) |
| 1007 | pp_string (pp, "preferUninstrumented "); |
| 1008 | if (props & PR_EXCEPTIONBLOCK) |
| 1009 | pp_string (pp, "exceptionBlock "); |
| 1010 | if (props & PR_HASELSE) |
| 1011 | pp_string (pp, "hasElse "); |
| 1012 | if (props & PR_READONLY) |
| 1013 | pp_string (pp, "readOnly "); |
| 1014 | |
| 1015 | pp_right_bracket (pp); |
| 1016 | } |
| 1017 | } |
| 1018 | |
| 1019 | |
| 1020 | /* Dump the switch statement GS. PP, SPC and FLAGS are as in |
| 1021 | pp_gimple_stmt_1. */ |
| 1022 | |
| 1023 | static void |
| 1024 | dump_gimple_switch (pretty_printer *pp, const gswitch *gs, int spc, |
| 1025 | dump_flags_t flags) |
| 1026 | { |
| 1027 | unsigned int i; |
| 1028 | |
| 1029 | GIMPLE_CHECK (gs, GIMPLE_SWITCH); |
| 1030 | if (flags & TDF_RAW) |
| 1031 | dump_gimple_fmt (pp, spc, flags, "%G <%T, ", gs, |
| 1032 | gimple_switch_index (gs)); |
| 1033 | else |
| 1034 | { |
| 1035 | pp_string (pp, "switch ("); |
| 1036 | dump_generic_node (pp, gimple_switch_index (gs), spc, flags, true); |
| 1037 | if (flags & TDF_GIMPLE) |
| 1038 | pp_string (pp, ") {"); |
| 1039 | else |
| 1040 | pp_string (pp, ") <"); |
| 1041 | } |
| 1042 | |
| 1043 | for (i = 0; i < gimple_switch_num_labels (gs); i++) |
| 1044 | { |
| 1045 | tree case_label = gimple_switch_label (gs, i); |
| 1046 | gcc_checking_assert (case_label != NULL_TREE); |
| 1047 | dump_generic_node (pp, case_label, spc, flags, false); |
| 1048 | pp_space (pp); |
| 1049 | tree label = CASE_LABEL (case_label); |
| 1050 | dump_generic_node (pp, label, spc, flags, false); |
| 1051 | |
| 1052 | if (cfun && cfun->cfg) |
| 1053 | { |
| 1054 | basic_block dest = label_to_block (cfun, label); |
| 1055 | if (dest) |
| 1056 | { |
| 1057 | edge label_edge = find_edge (gimple_bb (gs), dest); |
| 1058 | if (label_edge && !(flags & TDF_GIMPLE)) |
| 1059 | dump_edge_probability (pp, label_edge); |
| 1060 | } |
| 1061 | } |
| 1062 | |
| 1063 | if (i < gimple_switch_num_labels (gs) - 1) |
| 1064 | { |
| 1065 | if (flags & TDF_GIMPLE) |
| 1066 | pp_string (pp, "; "); |
| 1067 | else |
| 1068 | pp_string (pp, ", "); |
| 1069 | } |
| 1070 | } |
| 1071 | if (flags & TDF_GIMPLE) |
| 1072 | pp_string (pp, "; }"); |
| 1073 | else |
| 1074 | pp_greater (pp); |
| 1075 | } |
| 1076 | |
| 1077 | |
| 1078 | /* Dump the gimple conditional GS. PP, SPC and FLAGS are as in |
| 1079 | pp_gimple_stmt_1. */ |
| 1080 | |
| 1081 | static void |
| 1082 | dump_gimple_cond (pretty_printer *pp, const gcond *gs, int spc, |
| 1083 | dump_flags_t flags) |
| 1084 | { |
| 1085 | if (flags & TDF_RAW) |
| 1086 | dump_gimple_fmt (pp, spc, flags, "%G <%s, %T, %T, %T, %T>", gs, |
| 1087 | get_tree_code_name (gimple_cond_code (gs)), |
| 1088 | gimple_cond_lhs (gs), gimple_cond_rhs (gs), |
| 1089 | gimple_cond_true_label (gs), gimple_cond_false_label (gs)); |
| 1090 | else |
| 1091 | { |
| 1092 | if (!(flags & TDF_RHS_ONLY)) |
| 1093 | pp_string (pp, "if ("); |
| 1094 | dump_generic_node (pp, gimple_cond_lhs (gs), spc, |
| 1095 | flags | ((flags & TDF_GIMPLE) ? TDF_GIMPLE_VAL : TDF_NONE), |
| 1096 | false); |
| 1097 | pp_space (pp); |
| 1098 | pp_string (pp, op_symbol_code (gimple_cond_code (gs), flags)); |
| 1099 | pp_space (pp); |
| 1100 | dump_generic_node (pp, gimple_cond_rhs (gs), spc, |
| 1101 | flags | ((flags & TDF_GIMPLE) ? TDF_GIMPLE_VAL : TDF_NONE), |
| 1102 | false); |
| 1103 | if (!(flags & TDF_RHS_ONLY)) |
| 1104 | { |
| 1105 | edge_iterator ei; |
| 1106 | edge e, true_edge = NULL, false_edge = NULL; |
| 1107 | basic_block bb = gimple_bb (gs); |
| 1108 | |
| 1109 | if (bb) |
| 1110 | { |
| 1111 | FOR_EACH_EDGE (e, ei, bb->succs) |
| 1112 | { |
| 1113 | if (e->flags & EDGE_TRUE_VALUE) |
| 1114 | true_edge = e; |
| 1115 | else if (e->flags & EDGE_FALSE_VALUE) |
| 1116 | false_edge = e; |
| 1117 | } |
| 1118 | } |
| 1119 | |
| 1120 | bool has_edge_info = true_edge != NULL && false_edge != NULL; |
| 1121 | |
| 1122 | pp_right_paren (pp); |
| 1123 | |
| 1124 | if (gimple_cond_true_label (gs)) |
| 1125 | { |
| 1126 | pp_string (pp, " goto "); |
| 1127 | dump_generic_node (pp, gimple_cond_true_label (gs), |
| 1128 | spc, flags, false); |
| 1129 | if (has_edge_info && !(flags & TDF_GIMPLE)) |
| 1130 | dump_edge_probability (pp, true_edge); |
| 1131 | pp_semicolon (pp); |
| 1132 | } |
| 1133 | if (gimple_cond_false_label (gs)) |
| 1134 | { |
| 1135 | pp_string (pp, " else goto "); |
| 1136 | dump_generic_node (pp, gimple_cond_false_label (gs), |
| 1137 | spc, flags, false); |
| 1138 | if (has_edge_info && !(flags & TDF_GIMPLE)) |
| 1139 | dump_edge_probability (pp, false_edge); |
| 1140 | |
| 1141 | pp_semicolon (pp); |
| 1142 | } |
| 1143 | } |
| 1144 | } |
| 1145 | } |
| 1146 | |
| 1147 | |
| 1148 | /* Dump a GIMPLE_LABEL tuple on the pretty_printer PP, SPC |
| 1149 | spaces of indent. FLAGS specifies details to show in the dump (see |
| 1150 | TDF_* in dumpfils.h). */ |
| 1151 | |
| 1152 | static void |
| 1153 | dump_gimple_label (pretty_printer *pp, const glabel *gs, int spc, |
| 1154 | dump_flags_t flags) |
| 1155 | { |
| 1156 | tree label = gimple_label_label (gs); |
| 1157 | if (flags & TDF_RAW) |
| 1158 | dump_gimple_fmt (pp, spc, flags, "%G <%T>", gs, label); |
| 1159 | else |
| 1160 | { |
| 1161 | dump_generic_node (pp, label, spc, flags, false); |
| 1162 | pp_colon (pp); |
| 1163 | } |
| 1164 | if (flags & TDF_GIMPLE) |
| 1165 | return; |
| 1166 | if (DECL_NONLOCAL (label)) |
| 1167 | pp_string (pp, " [non-local]"); |
| 1168 | if ((flags & TDF_EH) && EH_LANDING_PAD_NR (label)) |
| 1169 | pp_printf (pp, " [LP %d]", EH_LANDING_PAD_NR (label)); |
| 1170 | } |
| 1171 | |
| 1172 | /* Dump a GIMPLE_GOTO tuple on the pretty_printer PP, SPC |
| 1173 | spaces of indent. FLAGS specifies details to show in the dump (see |
| 1174 | TDF_* in dumpfile.h). */ |
| 1175 | |
| 1176 | static void |
| 1177 | dump_gimple_goto (pretty_printer *pp, const ggoto *gs, int spc, |
| 1178 | dump_flags_t flags) |
| 1179 | { |
| 1180 | tree label = gimple_goto_dest (gs); |
| 1181 | if (flags & TDF_RAW) |
| 1182 | dump_gimple_fmt (pp, spc, flags, "%G <%T>", gs, label); |
| 1183 | else |
| 1184 | dump_gimple_fmt (pp, spc, flags, "goto %T;", label); |
| 1185 | } |
| 1186 | |
| 1187 | |
| 1188 | /* Dump a GIMPLE_BIND tuple on the pretty_printer PP, SPC |
| 1189 | spaces of indent. FLAGS specifies details to show in the dump (see |
| 1190 | TDF_* in dumpfile.h). */ |
| 1191 | |
| 1192 | static void |
| 1193 | dump_gimple_bind (pretty_printer *pp, const gbind *gs, int spc, |
| 1194 | dump_flags_t flags) |
| 1195 | { |
| 1196 | if (flags & TDF_RAW) |
| 1197 | dump_gimple_fmt (pp, spc, flags, "%G <", gs); |
| 1198 | else |
| 1199 | pp_left_brace (pp); |
| 1200 | if (!(flags & TDF_SLIM)) |
| 1201 | { |
| 1202 | tree var; |
| 1203 | |
| 1204 | for (var = gimple_bind_vars (gs); var; var = DECL_CHAIN (var)) |
| 1205 | { |
| 1206 | newline_and_indent (pp, 2); |
| 1207 | print_declaration (pp, var, spc, flags); |
| 1208 | } |
| 1209 | if (gimple_bind_vars (gs)) |
| 1210 | pp_newline (pp); |
| 1211 | } |
| 1212 | pp_newline (pp); |
| 1213 | dump_gimple_seq (pp, gimple_bind_body (gs), spc + 2, flags); |
| 1214 | newline_and_indent (pp, spc); |
| 1215 | if (flags & TDF_RAW) |
| 1216 | pp_greater (pp); |
| 1217 | else |
| 1218 | pp_right_brace (pp); |
| 1219 | } |
| 1220 | |
| 1221 | |
| 1222 | /* Dump a GIMPLE_TRY tuple on the pretty_printer PP, SPC spaces of |
| 1223 | indent. FLAGS specifies details to show in the dump (see TDF_* in |
| 1224 | dumpfile.h). */ |
| 1225 | |
| 1226 | static void |
| 1227 | dump_gimple_try (pretty_printer *pp, const gtry *gs, int spc, |
| 1228 | dump_flags_t flags) |
| 1229 | { |
| 1230 | if (flags & TDF_RAW) |
| 1231 | { |
| 1232 | const char *type; |
| 1233 | if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH) |
| 1234 | type = "GIMPLE_TRY_CATCH"; |
| 1235 | else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY) |
| 1236 | type = "GIMPLE_TRY_FINALLY"; |
| 1237 | else |
| 1238 | type = "UNKNOWN GIMPLE_TRY"; |
| 1239 | dump_gimple_fmt (pp, spc, flags, |
| 1240 | "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs, type, |
| 1241 | gimple_try_eval (gs), gimple_try_cleanup (gs)); |
| 1242 | } |
| 1243 | else |
| 1244 | { |
| 1245 | pp_string (pp, "try"); |
| 1246 | newline_and_indent (pp, spc + 2); |
| 1247 | pp_left_brace (pp); |
| 1248 | pp_newline (pp); |
| 1249 | |
| 1250 | dump_gimple_seq (pp, gimple_try_eval (gs), spc + 4, flags); |
| 1251 | newline_and_indent (pp, spc + 2); |
| 1252 | pp_right_brace (pp); |
| 1253 | |
| 1254 | gimple_seq seq = gimple_try_cleanup (gs); |
| 1255 | |
| 1256 | if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH) |
| 1257 | { |
| 1258 | newline_and_indent (pp, spc); |
| 1259 | pp_string (pp, "catch"); |
| 1260 | newline_and_indent (pp, spc + 2); |
| 1261 | pp_left_brace (pp); |
| 1262 | } |
| 1263 | else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY) |
| 1264 | { |
| 1265 | newline_and_indent (pp, spc); |
| 1266 | pp_string (pp, "finally"); |
| 1267 | newline_and_indent (pp, spc + 2); |
| 1268 | pp_left_brace (pp); |
| 1269 | |
| 1270 | if (seq && is_a <geh_else *> (gimple_seq_first_stmt (seq)) |
| 1271 | && gimple_seq_nondebug_singleton_p (seq)) |
| 1272 | { |
| 1273 | geh_else *stmt = as_a <geh_else *> (gimple_seq_first_stmt (seq)); |
| 1274 | seq = gimple_eh_else_n_body (stmt); |
| 1275 | pp_newline (pp); |
| 1276 | dump_gimple_seq (pp, seq, spc + 4, flags); |
| 1277 | newline_and_indent (pp, spc + 2); |
| 1278 | pp_right_brace (pp); |
| 1279 | seq = gimple_eh_else_e_body (stmt); |
| 1280 | newline_and_indent (pp, spc); |
| 1281 | pp_string (pp, "else"); |
| 1282 | newline_and_indent (pp, spc + 2); |
| 1283 | pp_left_brace (pp); |
| 1284 | } |
| 1285 | } |
| 1286 | else |
| 1287 | pp_string (pp, " <UNKNOWN GIMPLE_TRY> {"); |
| 1288 | |
| 1289 | pp_newline (pp); |
| 1290 | dump_gimple_seq (pp, seq, spc + 4, flags); |
| 1291 | newline_and_indent (pp, spc + 2); |
| 1292 | pp_right_brace (pp); |
| 1293 | } |
| 1294 | } |
| 1295 | |
| 1296 | |
| 1297 | /* Dump a GIMPLE_CATCH tuple on the pretty_printer PP, SPC spaces of |
| 1298 | indent. FLAGS specifies details to show in the dump (see TDF_* in |
| 1299 | dumpfile.h). */ |
| 1300 | |
| 1301 | static void |
| 1302 | dump_gimple_catch (pretty_printer *pp, const gcatch *gs, int spc, |
| 1303 | dump_flags_t flags) |
| 1304 | { |
| 1305 | if (flags & TDF_RAW) |
| 1306 | dump_gimple_fmt (pp, spc, flags, "%G <%T, %+CATCH <%S>%->", gs, |
| 1307 | gimple_catch_types (gs), gimple_catch_handler (gs)); |
| 1308 | else |
| 1309 | dump_gimple_fmt (pp, spc, flags, "catch (%T)%+{%S}", |
| 1310 | gimple_catch_types (gs), gimple_catch_handler (gs)); |
| 1311 | } |
| 1312 | |
| 1313 | |
| 1314 | /* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer PP, SPC spaces of |
| 1315 | indent. FLAGS specifies details to show in the dump (see TDF_* in |
| 1316 | dumpfile.h). */ |
| 1317 | |
| 1318 | static void |
| 1319 | dump_gimple_eh_filter (pretty_printer *pp, const geh_filter *gs, int spc, |
| 1320 | dump_flags_t flags) |
| 1321 | { |
| 1322 | if (flags & TDF_RAW) |
| 1323 | dump_gimple_fmt (pp, spc, flags, "%G <%T, %+FAILURE <%S>%->", gs, |
| 1324 | gimple_eh_filter_types (gs), |
| 1325 | gimple_eh_filter_failure (gs)); |
| 1326 | else |
| 1327 | dump_gimple_fmt (pp, spc, flags, "<<<eh_filter (%T)>>>%+{%+%S%-}", |
| 1328 | gimple_eh_filter_types (gs), |
| 1329 | gimple_eh_filter_failure (gs)); |
| 1330 | } |
| 1331 | |
| 1332 | |
| 1333 | /* Dump a GIMPLE_EH_MUST_NOT_THROW tuple. */ |
| 1334 | |
| 1335 | static void |
| 1336 | dump_gimple_eh_must_not_throw (pretty_printer *pp, |
| 1337 | const geh_mnt *gs, int spc, dump_flags_t flags) |
| 1338 | { |
| 1339 | if (flags & TDF_RAW) |
| 1340 | dump_gimple_fmt (pp, spc, flags, "%G <%T>", gs, |
| 1341 | gimple_eh_must_not_throw_fndecl (gs)); |
| 1342 | else |
| 1343 | dump_gimple_fmt (pp, spc, flags, "<<<eh_must_not_throw (%T)>>>", |
| 1344 | gimple_eh_must_not_throw_fndecl (gs)); |
| 1345 | } |
| 1346 | |
| 1347 | |
| 1348 | /* Dump a GIMPLE_EH_ELSE tuple on the pretty_printer PP, SPC spaces of |
| 1349 | indent. FLAGS specifies details to show in the dump (see TDF_* in |
| 1350 | dumpfile.h). */ |
| 1351 | |
| 1352 | static void |
| 1353 | dump_gimple_eh_else (pretty_printer *pp, const geh_else *gs, int spc, |
| 1354 | dump_flags_t flags) |
| 1355 | { |
| 1356 | if (flags & TDF_RAW) |
| 1357 | dump_gimple_fmt (pp, spc, flags, |
| 1358 | "%G <%+N_BODY <%S>%nE_BODY <%S>%->", gs, |
| 1359 | gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs)); |
| 1360 | else |
| 1361 | dump_gimple_fmt (pp, spc, flags, |
| 1362 | "<<<if_normal_exit>>>%+{%S}%-<<<else_eh_exit>>>%+{%S}", |
| 1363 | gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs)); |
| 1364 | } |
| 1365 | |
| 1366 | |
| 1367 | /* Dump a GIMPLE_RESX tuple on the pretty_printer PP, SPC spaces of |
| 1368 | indent. FLAGS specifies details to show in the dump (see TDF_* in |
| 1369 | dumpfile.h). */ |
| 1370 | |
| 1371 | static void |
| 1372 | dump_gimple_resx (pretty_printer *pp, const gresx *gs, int spc, |
| 1373 | dump_flags_t flags) |
| 1374 | { |
| 1375 | if (flags & TDF_RAW) |
| 1376 | dump_gimple_fmt (pp, spc, flags, "%G <%d>", gs, |
| 1377 | gimple_resx_region (gs)); |
| 1378 | else |
| 1379 | dump_gimple_fmt (pp, spc, flags, "resx %d", gimple_resx_region (gs)); |
| 1380 | } |
| 1381 | |
| 1382 | /* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer PP. */ |
| 1383 | |
| 1384 | static void |
| 1385 | dump_gimple_eh_dispatch (pretty_printer *pp, const geh_dispatch *gs, |
| 1386 | int spc, dump_flags_t flags) |
| 1387 | { |
| 1388 | if (flags & TDF_RAW) |
| 1389 | dump_gimple_fmt (pp, spc, flags, "%G <%d>", gs, |
| 1390 | gimple_eh_dispatch_region (gs)); |
| 1391 | else |
| 1392 | dump_gimple_fmt (pp, spc, flags, "eh_dispatch %d", |
| 1393 | gimple_eh_dispatch_region (gs)); |
| 1394 | } |
| 1395 | |
| 1396 | /* Dump a GIMPLE_DEBUG tuple on the pretty_printer PP, SPC spaces |
| 1397 | of indent. FLAGS specifies details to show in the dump (see TDF_* |
| 1398 | in dumpfile.h). */ |
| 1399 | |
| 1400 | static void |
| 1401 | dump_gimple_debug (pretty_printer *pp, const gdebug *gs, int spc, |
| 1402 | dump_flags_t flags) |
| 1403 | { |
| 1404 | switch (gs->subcode) |
| 1405 | { |
| 1406 | case GIMPLE_DEBUG_BIND: |
| 1407 | if (flags & TDF_RAW) |
| 1408 | dump_gimple_fmt (pp, spc, flags, "%G BIND <%T, %T>", gs, |
| 1409 | gimple_debug_bind_get_var (gs), |
| 1410 | gimple_debug_bind_get_value (gs)); |
| 1411 | else |
| 1412 | dump_gimple_fmt (pp, spc, flags, "# DEBUG %T => %T", |
| 1413 | gimple_debug_bind_get_var (gs), |
| 1414 | gimple_debug_bind_get_value (gs)); |
| 1415 | break; |
| 1416 | |
| 1417 | case GIMPLE_DEBUG_SOURCE_BIND: |
| 1418 | if (flags & TDF_RAW) |
| 1419 | dump_gimple_fmt (pp, spc, flags, "%G SRCBIND <%T, %T>", gs, |
| 1420 | gimple_debug_source_bind_get_var (gs), |
| 1421 | gimple_debug_source_bind_get_value (gs)); |
| 1422 | else |
| 1423 | dump_gimple_fmt (pp, spc, flags, "# DEBUG %T s=> %T", |
| 1424 | gimple_debug_source_bind_get_var (gs), |
| 1425 | gimple_debug_source_bind_get_value (gs)); |
| 1426 | break; |
| 1427 | |
| 1428 | case GIMPLE_DEBUG_BEGIN_STMT: |
| 1429 | if (flags & TDF_RAW) |
| 1430 | dump_gimple_fmt (pp, spc, flags, "%G BEGIN_STMT", gs); |
| 1431 | else |
| 1432 | dump_gimple_fmt (pp, spc, flags, "# DEBUG BEGIN_STMT"); |
| 1433 | break; |
| 1434 | |
| 1435 | case GIMPLE_DEBUG_INLINE_ENTRY: |
| 1436 | if (flags & TDF_RAW) |
| 1437 | dump_gimple_fmt (pp, spc, flags, "%G INLINE_ENTRY %T", gs, |
| 1438 | gimple_block (gs) |
| 1439 | ? block_ultimate_origin (gimple_block (gs)) |
| 1440 | : NULL_TREE); |
| 1441 | else |
| 1442 | dump_gimple_fmt (pp, spc, flags, "# DEBUG INLINE_ENTRY %T", |
| 1443 | gimple_block (gs) |
| 1444 | ? block_ultimate_origin (gimple_block (gs)) |
| 1445 | : NULL_TREE); |
| 1446 | break; |
| 1447 | |
| 1448 | default: |
| 1449 | gcc_unreachable (); |
| 1450 | } |
| 1451 | } |
| 1452 | |
| 1453 | /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer PP. */ |
| 1454 | static void |
| 1455 | dump_gimple_omp_for (pretty_printer *pp, const gomp_for *gs, int spc, |
| 1456 | dump_flags_t flags) |
| 1457 | { |
| 1458 | size_t i; |
| 1459 | |
| 1460 | if (flags & TDF_RAW) |
| 1461 | { |
| 1462 | const char *kind; |
| 1463 | switch (gimple_omp_for_kind (gs)) |
| 1464 | { |
| 1465 | case GF_OMP_FOR_KIND_FOR: |
| 1466 | kind = ""; |
| 1467 | break; |
| 1468 | case GF_OMP_FOR_KIND_DISTRIBUTE: |
| 1469 | kind = " distribute"; |
| 1470 | break; |
| 1471 | case GF_OMP_FOR_KIND_TASKLOOP: |
| 1472 | kind = " taskloop"; |
| 1473 | break; |
| 1474 | case GF_OMP_FOR_KIND_OACC_LOOP: |
| 1475 | kind = " oacc_loop"; |
| 1476 | break; |
| 1477 | case GF_OMP_FOR_KIND_SIMD: |
| 1478 | kind = " simd"; |
| 1479 | break; |
| 1480 | default: |
| 1481 | gcc_unreachable (); |
| 1482 | } |
| 1483 | dump_gimple_fmt (pp, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs, |
| 1484 | kind, gimple_omp_body (gs)); |
| 1485 | dump_omp_clauses (pp, gimple_omp_for_clauses (gs), spc, flags); |
| 1486 | dump_gimple_fmt (pp, spc, flags, " >,"); |
| 1487 | for (i = 0; i < gimple_omp_for_collapse (gs); i++) |
| 1488 | dump_gimple_fmt (pp, spc, flags, |
| 1489 | "%+%T, %T, %T, %s, %T,%n", |
| 1490 | gimple_omp_for_index (gs, i), |
| 1491 | gimple_omp_for_initial (gs, i), |
| 1492 | gimple_omp_for_final (gs, i), |
| 1493 | get_tree_code_name (gimple_omp_for_cond (gs, i)), |
| 1494 | gimple_omp_for_incr (gs, i)); |
| 1495 | dump_gimple_fmt (pp, spc, flags, "PRE_BODY <%S>%->", |
| 1496 | gimple_omp_for_pre_body (gs)); |
| 1497 | } |
| 1498 | else |
| 1499 | { |
| 1500 | switch (gimple_omp_for_kind (gs)) |
| 1501 | { |
| 1502 | case GF_OMP_FOR_KIND_FOR: |
| 1503 | pp_string (pp, "#pragma omp for"); |
| 1504 | break; |
| 1505 | case GF_OMP_FOR_KIND_DISTRIBUTE: |
| 1506 | pp_string (pp, "#pragma omp distribute"); |
| 1507 | break; |
| 1508 | case GF_OMP_FOR_KIND_TASKLOOP: |
| 1509 | pp_string (pp, "#pragma omp taskloop"); |
| 1510 | break; |
| 1511 | case GF_OMP_FOR_KIND_OACC_LOOP: |
| 1512 | pp_string (pp, "#pragma acc loop"); |
| 1513 | break; |
| 1514 | case GF_OMP_FOR_KIND_SIMD: |
| 1515 | pp_string (pp, "#pragma omp simd"); |
| 1516 | break; |
| 1517 | default: |
| 1518 | gcc_unreachable (); |
| 1519 | } |
| 1520 | dump_omp_clauses (pp, gimple_omp_for_clauses (gs), spc, flags); |
| 1521 | for (i = 0; i < gimple_omp_for_collapse (gs); i++) |
| 1522 | { |
| 1523 | if (i) |
| 1524 | spc += 2; |
| 1525 | newline_and_indent (pp, spc); |
| 1526 | pp_string (pp, "for ("); |
| 1527 | dump_generic_node (pp, gimple_omp_for_index (gs, i), spc, |
| 1528 | flags, false); |
| 1529 | pp_string (pp, " = "); |
| 1530 | tree init = gimple_omp_for_initial (gs, i); |
| 1531 | if (TREE_CODE (init) != TREE_VEC) |
| 1532 | dump_generic_node (pp, init, spc, flags, false); |
| 1533 | else |
| 1534 | dump_omp_loop_non_rect_expr (pp, init, spc, flags); |
| 1535 | pp_string (pp, "; "); |
| 1536 | |
| 1537 | dump_generic_node (pp, gimple_omp_for_index (gs, i), spc, |
| 1538 | flags, false); |
| 1539 | pp_space (pp); |
| 1540 | switch (gimple_omp_for_cond (gs, i)) |
| 1541 | { |
| 1542 | case LT_EXPR: |
| 1543 | pp_less (pp); |
| 1544 | break; |
| 1545 | case GT_EXPR: |
| 1546 | pp_greater (pp); |
| 1547 | break; |
| 1548 | case LE_EXPR: |
| 1549 | pp_less_equal (pp); |
| 1550 | break; |
| 1551 | case GE_EXPR: |
| 1552 | pp_greater_equal (pp); |
| 1553 | break; |
| 1554 | case NE_EXPR: |
| 1555 | pp_string (pp, "!="); |
| 1556 | break; |
| 1557 | default: |
| 1558 | gcc_unreachable (); |
| 1559 | } |
| 1560 | pp_space (pp); |
| 1561 | tree cond = gimple_omp_for_final (gs, i); |
| 1562 | if (TREE_CODE (cond) != TREE_VEC) |
| 1563 | dump_generic_node (pp, cond, spc, flags, false); |
| 1564 | else |
| 1565 | dump_omp_loop_non_rect_expr (pp, cond, spc, flags); |
| 1566 | pp_string (pp, "; "); |
| 1567 | |
| 1568 | dump_generic_node (pp, gimple_omp_for_index (gs, i), spc, |
| 1569 | flags, false); |
| 1570 | pp_string (pp, " = "); |
| 1571 | dump_generic_node (pp, gimple_omp_for_incr (gs, i), spc, |
| 1572 | flags, false); |
| 1573 | pp_right_paren (pp); |
| 1574 | } |
| 1575 | |
| 1576 | if (!gimple_seq_empty_p (gimple_omp_body (gs))) |
| 1577 | { |
| 1578 | newline_and_indent (pp, spc + 2); |
| 1579 | pp_left_brace (pp); |
| 1580 | pp_newline (pp); |
| 1581 | dump_gimple_seq (pp, gimple_omp_body (gs), spc + 4, flags); |
| 1582 | newline_and_indent (pp, spc + 2); |
| 1583 | pp_right_brace (pp); |
| 1584 | } |
| 1585 | } |
| 1586 | } |
| 1587 | |
| 1588 | /* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer PP. */ |
| 1589 | |
| 1590 | static void |
| 1591 | dump_gimple_omp_continue (pretty_printer *pp, const gomp_continue *gs, |
| 1592 | int spc, dump_flags_t flags) |
| 1593 | { |
| 1594 | if (flags & TDF_RAW) |
| 1595 | { |
| 1596 | dump_gimple_fmt (pp, spc, flags, "%G <%T, %T>", gs, |
| 1597 | gimple_omp_continue_control_def (gs), |
| 1598 | gimple_omp_continue_control_use (gs)); |
| 1599 | } |
| 1600 | else |
| 1601 | { |
| 1602 | pp_string (pp, "#pragma omp continue ("); |
| 1603 | dump_generic_node (pp, gimple_omp_continue_control_def (gs), |
| 1604 | spc, flags, false); |
| 1605 | pp_comma (pp); |
| 1606 | pp_space (pp); |
| 1607 | dump_generic_node (pp, gimple_omp_continue_control_use (gs), |
| 1608 | spc, flags, false); |
| 1609 | pp_right_paren (pp); |
| 1610 | } |
| 1611 | } |
| 1612 | |
| 1613 | /* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer PP. */ |
| 1614 | |
| 1615 | static void |
| 1616 | dump_gimple_omp_single (pretty_printer *pp, const gomp_single *gs, |
| 1617 | int spc, dump_flags_t flags) |
| 1618 | { |
| 1619 | if (flags & TDF_RAW) |
| 1620 | { |
| 1621 | dump_gimple_fmt (pp, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs, |
| 1622 | gimple_omp_body (gs)); |
| 1623 | dump_omp_clauses (pp, gimple_omp_single_clauses (gs), spc, flags); |
| 1624 | dump_gimple_fmt (pp, spc, flags, " >"); |
| 1625 | } |
| 1626 | else |
| 1627 | { |
| 1628 | pp_string (pp, "#pragma omp single"); |
| 1629 | dump_omp_clauses (pp, gimple_omp_single_clauses (gs), spc, flags); |
| 1630 | if (!gimple_seq_empty_p (gimple_omp_body (gs))) |
| 1631 | { |
| 1632 | newline_and_indent (pp, spc + 2); |
| 1633 | pp_left_brace (pp); |
| 1634 | pp_newline (pp); |
| 1635 | dump_gimple_seq (pp, gimple_omp_body (gs), spc + 4, flags); |
| 1636 | newline_and_indent (pp, spc + 2); |
| 1637 | pp_right_brace (pp); |
| 1638 | } |
| 1639 | } |
| 1640 | } |
| 1641 | |
| 1642 | /* Dump a GIMPLE_OMP_TASKGROUP tuple on the pretty_printer PP. */ |
| 1643 | |
| 1644 | static void |
| 1645 | dump_gimple_omp_taskgroup (pretty_printer *pp, const gimple *gs, |
| 1646 | int spc, dump_flags_t flags) |
| 1647 | { |
| 1648 | if (flags & TDF_RAW) |
| 1649 | { |
| 1650 | dump_gimple_fmt (pp, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs, |
| 1651 | gimple_omp_body (gs)); |
| 1652 | dump_omp_clauses (pp, gimple_omp_taskgroup_clauses (gs), spc, flags); |
| 1653 | dump_gimple_fmt (pp, spc, flags, " >"); |
| 1654 | } |
| 1655 | else |
| 1656 | { |
| 1657 | pp_string (pp, "#pragma omp taskgroup"); |
| 1658 | dump_omp_clauses (pp, gimple_omp_taskgroup_clauses (gs), spc, flags); |
| 1659 | if (!gimple_seq_empty_p (gimple_omp_body (gs))) |
| 1660 | { |
| 1661 | newline_and_indent (pp, spc + 2); |
| 1662 | pp_left_brace (pp); |
| 1663 | pp_newline (pp); |
| 1664 | dump_gimple_seq (pp, gimple_omp_body (gs), spc + 4, flags); |
| 1665 | newline_and_indent (pp, spc + 2); |
| 1666 | pp_right_brace (pp); |
| 1667 | } |
| 1668 | } |
| 1669 | } |
| 1670 | |
| 1671 | /* Dump a GIMPLE_OMP_MASKED tuple on the pretty_printer PP. */ |
| 1672 | |
| 1673 | static void |
| 1674 | dump_gimple_omp_masked (pretty_printer *pp, const gimple *gs, |
| 1675 | int spc, dump_flags_t flags) |
| 1676 | { |
| 1677 | if (flags & TDF_RAW) |
| 1678 | { |
| 1679 | dump_gimple_fmt (pp, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs, |
| 1680 | gimple_omp_body (gs)); |
| 1681 | dump_omp_clauses (pp, gimple_omp_masked_clauses (gs), spc, flags); |
| 1682 | dump_gimple_fmt (pp, spc, flags, " >"); |
| 1683 | } |
| 1684 | else |
| 1685 | { |
| 1686 | pp_string (pp, "#pragma omp masked"); |
| 1687 | dump_omp_clauses (pp, gimple_omp_masked_clauses (gs), spc, flags); |
| 1688 | if (!gimple_seq_empty_p (gimple_omp_body (gs))) |
| 1689 | { |
| 1690 | newline_and_indent (pp, spc + 2); |
| 1691 | pp_left_brace (pp); |
| 1692 | pp_newline (pp); |
| 1693 | dump_gimple_seq (pp, gimple_omp_body (gs), spc + 4, flags); |
| 1694 | newline_and_indent (pp, spc + 2); |
| 1695 | pp_right_brace (pp); |
| 1696 | } |
| 1697 | } |
| 1698 | } |
| 1699 | |
| 1700 | /* Dump a GIMPLE_OMP_SCOPE tuple on the pretty_printer PP. */ |
| 1701 | |
| 1702 | static void |
| 1703 | dump_gimple_omp_scope (pretty_printer *pp, const gimple *gs, |
| 1704 | int spc, dump_flags_t flags) |
| 1705 | { |
| 1706 | if (flags & TDF_RAW) |
| 1707 | { |
| 1708 | dump_gimple_fmt (pp, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs, |
| 1709 | gimple_omp_body (gs)); |
| 1710 | dump_omp_clauses (pp, gimple_omp_scope_clauses (gs), spc, flags); |
| 1711 | dump_gimple_fmt (pp, spc, flags, " >"); |
| 1712 | } |
| 1713 | else |
| 1714 | { |
| 1715 | pp_string (pp, "#pragma omp scope"); |
| 1716 | dump_omp_clauses (pp, gimple_omp_scope_clauses (gs), spc, flags); |
| 1717 | if (!gimple_seq_empty_p (gimple_omp_body (gs))) |
| 1718 | { |
| 1719 | newline_and_indent (pp, spc + 2); |
| 1720 | pp_left_brace (pp); |
| 1721 | pp_newline (pp); |
| 1722 | dump_gimple_seq (pp, gimple_omp_body (gs), spc + 4, flags); |
| 1723 | newline_and_indent (pp, spc + 2); |
| 1724 | pp_right_brace (pp); |
| 1725 | } |
| 1726 | } |
| 1727 | } |
| 1728 | |
| 1729 | /* Dump a GIMPLE_OMP_DISPATCH tuple on the pretty_printer BUFFER. */ |
| 1730 | |
| 1731 | static void |
| 1732 | dump_gimple_omp_dispatch (pretty_printer *buffer, const gimple *gs, int spc, |
| 1733 | dump_flags_t flags) |
| 1734 | { |
| 1735 | if (flags & TDF_RAW) |
| 1736 | { |
| 1737 | dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs, |
| 1738 | gimple_omp_body (gs)); |
| 1739 | dump_omp_clauses (buffer, gimple_omp_dispatch_clauses (gs), spc, flags); |
| 1740 | dump_gimple_fmt (buffer, spc, flags, " >"); |
| 1741 | } |
| 1742 | else |
| 1743 | { |
| 1744 | pp_string (buffer, "#pragma omp dispatch"); |
| 1745 | dump_omp_clauses (buffer, gimple_omp_dispatch_clauses (gs), spc, flags); |
| 1746 | if (!gimple_seq_empty_p (gimple_omp_body (gs))) |
| 1747 | { |
| 1748 | newline_and_indent (buffer, spc + 2); |
| 1749 | pp_left_brace (buffer); |
| 1750 | pp_newline (buffer); |
| 1751 | dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags); |
| 1752 | newline_and_indent (buffer, spc + 2); |
| 1753 | pp_right_brace (buffer); |
| 1754 | } |
| 1755 | } |
| 1756 | } |
| 1757 | |
| 1758 | /* Dump a GIMPLE_OMP_INTEROP tuple on the pretty_printer BUFFER. */ |
| 1759 | |
| 1760 | static void |
| 1761 | dump_gimple_omp_interop (pretty_printer *buffer, const gimple *gs, int spc, |
| 1762 | dump_flags_t flags) |
| 1763 | { |
| 1764 | if (flags & TDF_RAW) |
| 1765 | { |
| 1766 | dump_gimple_fmt (buffer, spc, flags, "%G <CLAUSES <", gs); |
| 1767 | dump_omp_clauses (buffer, gimple_omp_interop_clauses (gs), spc, flags); |
| 1768 | dump_gimple_fmt (buffer, spc, flags, " >"); |
| 1769 | } |
| 1770 | else |
| 1771 | { |
| 1772 | pp_string (buffer, "#pragma omp interop"); |
| 1773 | dump_omp_clauses (buffer, gimple_omp_interop_clauses (gs), spc, flags); |
| 1774 | } |
| 1775 | } |
| 1776 | |
| 1777 | /* Dump a GIMPLE_OMP_TARGET tuple on the pretty_printer PP. */ |
| 1778 | |
| 1779 | static void |
| 1780 | dump_gimple_omp_target (pretty_printer *pp, const gomp_target *gs, |
| 1781 | int spc, dump_flags_t flags) |
| 1782 | { |
| 1783 | const char *kind; |
| 1784 | switch (gimple_omp_target_kind (gs)) |
| 1785 | { |
| 1786 | case GF_OMP_TARGET_KIND_REGION: |
| 1787 | kind = ""; |
| 1788 | break; |
| 1789 | case GF_OMP_TARGET_KIND_DATA: |
| 1790 | kind = " data"; |
| 1791 | break; |
| 1792 | case GF_OMP_TARGET_KIND_UPDATE: |
| 1793 | kind = " update"; |
| 1794 | break; |
| 1795 | case GF_OMP_TARGET_KIND_ENTER_DATA: |
| 1796 | kind = " enter data"; |
| 1797 | break; |
| 1798 | case GF_OMP_TARGET_KIND_EXIT_DATA: |
| 1799 | kind = " exit data"; |
| 1800 | break; |
| 1801 | case GF_OMP_TARGET_KIND_OACC_KERNELS: |
| 1802 | kind = " oacc_kernels"; |
| 1803 | break; |
| 1804 | case GF_OMP_TARGET_KIND_OACC_PARALLEL: |
| 1805 | kind = " oacc_parallel"; |
| 1806 | break; |
| 1807 | case GF_OMP_TARGET_KIND_OACC_SERIAL: |
| 1808 | kind = " oacc_serial"; |
| 1809 | break; |
| 1810 | case GF_OMP_TARGET_KIND_OACC_DATA: |
| 1811 | kind = " oacc_data"; |
| 1812 | break; |
| 1813 | case GF_OMP_TARGET_KIND_OACC_UPDATE: |
| 1814 | kind = " oacc_update"; |
| 1815 | break; |
| 1816 | case GF_OMP_TARGET_KIND_OACC_ENTER_DATA: |
| 1817 | kind = " oacc_enter_data"; |
| 1818 | break; |
| 1819 | case GF_OMP_TARGET_KIND_OACC_EXIT_DATA: |
| 1820 | kind = " oacc_exit_data"; |
| 1821 | break; |
| 1822 | case GF_OMP_TARGET_KIND_OACC_DECLARE: |
| 1823 | kind = " oacc_declare"; |
| 1824 | break; |
| 1825 | case GF_OMP_TARGET_KIND_OACC_HOST_DATA: |
| 1826 | kind = " oacc_host_data"; |
| 1827 | break; |
| 1828 | case GF_OMP_TARGET_KIND_OACC_PARALLEL_KERNELS_PARALLELIZED: |
| 1829 | kind = " oacc_parallel_kernels_parallelized"; |
| 1830 | break; |
| 1831 | case GF_OMP_TARGET_KIND_OACC_PARALLEL_KERNELS_GANG_SINGLE: |
| 1832 | kind = " oacc_parallel_kernels_gang_single"; |
| 1833 | break; |
| 1834 | case GF_OMP_TARGET_KIND_OACC_DATA_KERNELS: |
| 1835 | kind = " oacc_data_kernels"; |
| 1836 | break; |
| 1837 | default: |
| 1838 | gcc_unreachable (); |
| 1839 | } |
| 1840 | if (flags & TDF_RAW) |
| 1841 | { |
| 1842 | dump_gimple_fmt (pp, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs, |
| 1843 | kind, gimple_omp_body (gs)); |
| 1844 | dump_omp_clauses (pp, gimple_omp_target_clauses (gs), spc, flags); |
| 1845 | dump_gimple_fmt (pp, spc, flags, " >, %T, %T%n>", |
| 1846 | gimple_omp_target_child_fn (gs), |
| 1847 | gimple_omp_target_data_arg (gs)); |
| 1848 | } |
| 1849 | else |
| 1850 | { |
| 1851 | pp_string (pp, "#pragma omp target"); |
| 1852 | pp_string (pp, kind); |
| 1853 | dump_omp_clauses (pp, gimple_omp_target_clauses (gs), spc, flags); |
| 1854 | if (gimple_omp_target_child_fn (gs)) |
| 1855 | { |
| 1856 | pp_string (pp, " [child fn: "); |
| 1857 | dump_generic_node (pp, gimple_omp_target_child_fn (gs), |
| 1858 | spc, flags, false); |
| 1859 | pp_string (pp, " ("); |
| 1860 | if (gimple_omp_target_data_arg (gs)) |
| 1861 | dump_generic_node (pp, gimple_omp_target_data_arg (gs), |
| 1862 | spc, flags, false); |
| 1863 | else |
| 1864 | pp_string (pp, "???"); |
| 1865 | pp_string (pp, ")]"); |
| 1866 | } |
| 1867 | gimple_seq body = gimple_omp_body (gs); |
| 1868 | if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND) |
| 1869 | { |
| 1870 | newline_and_indent (pp, spc + 2); |
| 1871 | pp_left_brace (pp); |
| 1872 | pp_newline (pp); |
| 1873 | dump_gimple_seq (pp, body, spc + 4, flags); |
| 1874 | newline_and_indent (pp, spc + 2); |
| 1875 | pp_right_brace (pp); |
| 1876 | } |
| 1877 | else if (body) |
| 1878 | { |
| 1879 | pp_newline (pp); |
| 1880 | dump_gimple_seq (pp, body, spc + 2, flags); |
| 1881 | } |
| 1882 | } |
| 1883 | } |
| 1884 | |
| 1885 | /* Dump a GIMPLE_OMP_TEAMS tuple on the pretty_printer PP. */ |
| 1886 | |
| 1887 | static void |
| 1888 | dump_gimple_omp_teams (pretty_printer *pp, const gomp_teams *gs, int spc, |
| 1889 | dump_flags_t flags) |
| 1890 | { |
| 1891 | if (flags & TDF_RAW) |
| 1892 | { |
| 1893 | dump_gimple_fmt (pp, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs, |
| 1894 | gimple_omp_body (gs)); |
| 1895 | dump_omp_clauses (pp, gimple_omp_teams_clauses (gs), spc, flags); |
| 1896 | dump_gimple_fmt (pp, spc, flags, " >"); |
| 1897 | } |
| 1898 | else |
| 1899 | { |
| 1900 | pp_string (pp, "#pragma omp teams"); |
| 1901 | dump_omp_clauses (pp, gimple_omp_teams_clauses (gs), spc, flags); |
| 1902 | if (!gimple_seq_empty_p (gimple_omp_body (gs))) |
| 1903 | { |
| 1904 | newline_and_indent (pp, spc + 2); |
| 1905 | pp_character (pp, '{'); |
| 1906 | pp_newline (pp); |
| 1907 | dump_gimple_seq (pp, gimple_omp_body (gs), spc + 4, flags); |
| 1908 | newline_and_indent (pp, spc + 2); |
| 1909 | pp_character (pp, '}'); |
| 1910 | } |
| 1911 | } |
| 1912 | } |
| 1913 | |
| 1914 | /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer PP. */ |
| 1915 | |
| 1916 | static void |
| 1917 | dump_gimple_omp_sections (pretty_printer *pp, const gomp_sections *gs, |
| 1918 | int spc, dump_flags_t flags) |
| 1919 | { |
| 1920 | if (flags & TDF_RAW) |
| 1921 | { |
| 1922 | dump_gimple_fmt (pp, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs, |
| 1923 | gimple_omp_body (gs)); |
| 1924 | dump_omp_clauses (pp, gimple_omp_sections_clauses (gs), spc, flags); |
| 1925 | dump_gimple_fmt (pp, spc, flags, " >"); |
| 1926 | } |
| 1927 | else |
| 1928 | { |
| 1929 | pp_string (pp, "#pragma omp sections"); |
| 1930 | if (gimple_omp_sections_control (gs)) |
| 1931 | { |
| 1932 | pp_string (pp, " <"); |
| 1933 | dump_generic_node (pp, gimple_omp_sections_control (gs), spc, |
| 1934 | flags, false); |
| 1935 | pp_greater (pp); |
| 1936 | } |
| 1937 | dump_omp_clauses (pp, gimple_omp_sections_clauses (gs), spc, flags); |
| 1938 | if (!gimple_seq_empty_p (gimple_omp_body (gs))) |
| 1939 | { |
| 1940 | newline_and_indent (pp, spc + 2); |
| 1941 | pp_left_brace (pp); |
| 1942 | pp_newline (pp); |
| 1943 | dump_gimple_seq (pp, gimple_omp_body (gs), spc + 4, flags); |
| 1944 | newline_and_indent (pp, spc + 2); |
| 1945 | pp_right_brace (pp); |
| 1946 | } |
| 1947 | } |
| 1948 | } |
| 1949 | |
| 1950 | /* Dump a GIMPLE_OMP_{MASTER,ORDERED,SECTION,STRUCTURED_BLOCK} tuple on the |
| 1951 | pretty_printer PP. */ |
| 1952 | |
| 1953 | static void |
| 1954 | dump_gimple_omp_block (pretty_printer *pp, const gimple *gs, int spc, |
| 1955 | dump_flags_t flags) |
| 1956 | { |
| 1957 | if (flags & TDF_RAW) |
| 1958 | dump_gimple_fmt (pp, spc, flags, "%G <%+BODY <%S> >", gs, |
| 1959 | gimple_omp_body (gs)); |
| 1960 | else |
| 1961 | { |
| 1962 | switch (gimple_code (gs)) |
| 1963 | { |
| 1964 | case GIMPLE_OMP_MASTER: |
| 1965 | pp_string (pp, "#pragma omp master"); |
| 1966 | break; |
| 1967 | case GIMPLE_OMP_SECTION: |
| 1968 | pp_string (pp, "#pragma omp section"); |
| 1969 | break; |
| 1970 | case GIMPLE_OMP_STRUCTURED_BLOCK: |
| 1971 | pp_string (pp, "#pragma omp __structured_block"); |
| 1972 | break; |
| 1973 | default: |
| 1974 | gcc_unreachable (); |
| 1975 | } |
| 1976 | if (!gimple_seq_empty_p (gimple_omp_body (gs))) |
| 1977 | { |
| 1978 | newline_and_indent (pp, spc + 2); |
| 1979 | pp_left_brace (pp); |
| 1980 | pp_newline (pp); |
| 1981 | dump_gimple_seq (pp, gimple_omp_body (gs), spc + 4, flags); |
| 1982 | newline_and_indent (pp, spc + 2); |
| 1983 | pp_right_brace (pp); |
| 1984 | } |
| 1985 | } |
| 1986 | } |
| 1987 | |
| 1988 | /* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer PP. */ |
| 1989 | |
| 1990 | static void |
| 1991 | dump_gimple_omp_critical (pretty_printer *pp, const gomp_critical *gs, |
| 1992 | int spc, dump_flags_t flags) |
| 1993 | { |
| 1994 | if (flags & TDF_RAW) |
| 1995 | dump_gimple_fmt (pp, spc, flags, "%G <%+BODY <%S> >", gs, |
| 1996 | gimple_omp_body (gs)); |
| 1997 | else |
| 1998 | { |
| 1999 | pp_string (pp, "#pragma omp critical"); |
| 2000 | if (gimple_omp_critical_name (gs)) |
| 2001 | { |
| 2002 | pp_string (pp, " ("); |
| 2003 | dump_generic_node (pp, gimple_omp_critical_name (gs), spc, |
| 2004 | flags, false); |
| 2005 | pp_right_paren (pp); |
| 2006 | } |
| 2007 | dump_omp_clauses (pp, gimple_omp_critical_clauses (gs), spc, flags); |
| 2008 | if (!gimple_seq_empty_p (gimple_omp_body (gs))) |
| 2009 | { |
| 2010 | newline_and_indent (pp, spc + 2); |
| 2011 | pp_left_brace (pp); |
| 2012 | pp_newline (pp); |
| 2013 | dump_gimple_seq (pp, gimple_omp_body (gs), spc + 4, flags); |
| 2014 | newline_and_indent (pp, spc + 2); |
| 2015 | pp_right_brace (pp); |
| 2016 | } |
| 2017 | } |
| 2018 | } |
| 2019 | |
| 2020 | /* Dump a GIMPLE_OMP_ORDERED tuple on the pretty_printer PP. */ |
| 2021 | |
| 2022 | static void |
| 2023 | dump_gimple_omp_ordered (pretty_printer *pp, const gomp_ordered *gs, |
| 2024 | int spc, dump_flags_t flags) |
| 2025 | { |
| 2026 | if (flags & TDF_RAW) |
| 2027 | dump_gimple_fmt (pp, spc, flags, "%G <%+BODY <%S> >", gs, |
| 2028 | gimple_omp_body (gs)); |
| 2029 | else |
| 2030 | { |
| 2031 | pp_string (pp, "#pragma omp ordered"); |
| 2032 | dump_omp_clauses (pp, gimple_omp_ordered_clauses (gs), spc, flags); |
| 2033 | if (!gimple_seq_empty_p (gimple_omp_body (gs))) |
| 2034 | { |
| 2035 | newline_and_indent (pp, spc + 2); |
| 2036 | pp_left_brace (pp); |
| 2037 | pp_newline (pp); |
| 2038 | dump_gimple_seq (pp, gimple_omp_body (gs), spc + 4, flags); |
| 2039 | newline_and_indent (pp, spc + 2); |
| 2040 | pp_right_brace (pp); |
| 2041 | } |
| 2042 | } |
| 2043 | } |
| 2044 | |
| 2045 | /* Dump a GIMPLE_OMP_SCAN tuple on the pretty_printer PP. */ |
| 2046 | |
| 2047 | static void |
| 2048 | dump_gimple_omp_scan (pretty_printer *pp, const gomp_scan *gs, |
| 2049 | int spc, dump_flags_t flags) |
| 2050 | { |
| 2051 | if (flags & TDF_RAW) |
| 2052 | dump_gimple_fmt (pp, spc, flags, "%G <%+BODY <%S> >", gs, |
| 2053 | gimple_omp_body (gs)); |
| 2054 | else |
| 2055 | { |
| 2056 | if (gimple_omp_scan_clauses (gs)) |
| 2057 | { |
| 2058 | pp_string (pp, "#pragma omp scan"); |
| 2059 | dump_omp_clauses (pp, gimple_omp_scan_clauses (gs), spc, flags); |
| 2060 | } |
| 2061 | if (!gimple_seq_empty_p (gimple_omp_body (gs))) |
| 2062 | { |
| 2063 | newline_and_indent (pp, spc + 2); |
| 2064 | pp_left_brace (pp); |
| 2065 | pp_newline (pp); |
| 2066 | dump_gimple_seq (pp, gimple_omp_body (gs), spc + 4, flags); |
| 2067 | newline_and_indent (pp, spc + 2); |
| 2068 | pp_right_brace (pp); |
| 2069 | } |
| 2070 | } |
| 2071 | } |
| 2072 | |
| 2073 | /* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer PP. */ |
| 2074 | |
| 2075 | static void |
| 2076 | dump_gimple_omp_return (pretty_printer *pp, const gimple *gs, int spc, |
| 2077 | dump_flags_t flags) |
| 2078 | { |
| 2079 | if (flags & TDF_RAW) |
| 2080 | { |
| 2081 | dump_gimple_fmt (pp, spc, flags, "%G <nowait=%d", gs, |
| 2082 | (int) gimple_omp_return_nowait_p (gs)); |
| 2083 | if (gimple_omp_return_lhs (gs)) |
| 2084 | dump_gimple_fmt (pp, spc, flags, ", lhs=%T>", |
| 2085 | gimple_omp_return_lhs (gs)); |
| 2086 | else |
| 2087 | dump_gimple_fmt (pp, spc, flags, ">"); |
| 2088 | } |
| 2089 | else |
| 2090 | { |
| 2091 | pp_string (pp, "#pragma omp return"); |
| 2092 | if (gimple_omp_return_nowait_p (gs)) |
| 2093 | pp_string (pp, "(nowait)"); |
| 2094 | if (gimple_omp_return_lhs (gs)) |
| 2095 | { |
| 2096 | pp_string (pp, " (set "); |
| 2097 | dump_generic_node (pp, gimple_omp_return_lhs (gs), |
| 2098 | spc, flags, false); |
| 2099 | pp_character (pp, ')'); |
| 2100 | } |
| 2101 | } |
| 2102 | } |
| 2103 | |
| 2104 | /* Dump a GIMPLE_ASSUME tuple on the pretty_printer PP. */ |
| 2105 | |
| 2106 | static void |
| 2107 | dump_gimple_assume (pretty_printer *pp, const gimple *gs, |
| 2108 | int spc, dump_flags_t flags) |
| 2109 | { |
| 2110 | if (flags & TDF_RAW) |
| 2111 | dump_gimple_fmt (pp, spc, flags, |
| 2112 | "%G [GUARD=%T] <%+BODY <%S> >", |
| 2113 | gs, gimple_assume_guard (gs), |
| 2114 | gimple_assume_body (gs)); |
| 2115 | else |
| 2116 | { |
| 2117 | pp_string (pp, "[[assume ("); |
| 2118 | dump_generic_node (pp, gimple_assume_guard (gs), spc, flags, false); |
| 2119 | pp_string (pp, ")]]"); |
| 2120 | newline_and_indent (pp, spc + 2); |
| 2121 | pp_left_brace (pp); |
| 2122 | pp_newline (pp); |
| 2123 | dump_gimple_seq (pp, gimple_assume_body (gs), spc + 4, flags); |
| 2124 | newline_and_indent (pp, spc + 2); |
| 2125 | pp_right_brace (pp); |
| 2126 | } |
| 2127 | } |
| 2128 | |
| 2129 | /* Dump a GIMPLE_TRANSACTION tuple on the pretty_printer PP. */ |
| 2130 | |
| 2131 | static void |
| 2132 | dump_gimple_transaction (pretty_printer *pp, const gtransaction *gs, |
| 2133 | int spc, dump_flags_t flags) |
| 2134 | { |
| 2135 | unsigned subcode = gimple_transaction_subcode (gs); |
| 2136 | |
| 2137 | if (flags & TDF_RAW) |
| 2138 | { |
| 2139 | dump_gimple_fmt (pp, spc, flags, |
| 2140 | "%G [SUBCODE=%x,NORM=%T,UNINST=%T,OVER=%T] " |
| 2141 | "<%+BODY <%S> >", |
| 2142 | gs, subcode, gimple_transaction_label_norm (gs), |
| 2143 | gimple_transaction_label_uninst (gs), |
| 2144 | gimple_transaction_label_over (gs), |
| 2145 | gimple_transaction_body (gs)); |
| 2146 | } |
| 2147 | else |
| 2148 | { |
| 2149 | if (subcode & GTMA_IS_OUTER) |
| 2150 | pp_string (pp, "__transaction_atomic [[outer]]"); |
| 2151 | else if (subcode & GTMA_IS_RELAXED) |
| 2152 | pp_string (pp, "__transaction_relaxed"); |
| 2153 | else |
| 2154 | pp_string (pp, "__transaction_atomic"); |
| 2155 | subcode &= ~GTMA_DECLARATION_MASK; |
| 2156 | |
| 2157 | if (gimple_transaction_body (gs)) |
| 2158 | { |
| 2159 | newline_and_indent (pp, spc + 2); |
| 2160 | pp_left_brace (pp); |
| 2161 | pp_newline (pp); |
| 2162 | dump_gimple_seq (pp, gimple_transaction_body (gs), |
| 2163 | spc + 4, flags); |
| 2164 | newline_and_indent (pp, spc + 2); |
| 2165 | pp_right_brace (pp); |
| 2166 | } |
| 2167 | else |
| 2168 | { |
| 2169 | pp_string (pp, " //"); |
| 2170 | if (gimple_transaction_label_norm (gs)) |
| 2171 | { |
| 2172 | pp_string (pp, " NORM="); |
| 2173 | dump_generic_node (pp, gimple_transaction_label_norm (gs), |
| 2174 | spc, flags, false); |
| 2175 | } |
| 2176 | if (gimple_transaction_label_uninst (gs)) |
| 2177 | { |
| 2178 | pp_string (pp, " UNINST="); |
| 2179 | dump_generic_node (pp, gimple_transaction_label_uninst (gs), |
| 2180 | spc, flags, false); |
| 2181 | } |
| 2182 | if (gimple_transaction_label_over (gs)) |
| 2183 | { |
| 2184 | pp_string (pp, " OVER="); |
| 2185 | dump_generic_node (pp, gimple_transaction_label_over (gs), |
| 2186 | spc, flags, false); |
| 2187 | } |
| 2188 | if (subcode) |
| 2189 | { |
| 2190 | pp_string (pp, " SUBCODE=[ "); |
| 2191 | if (subcode & GTMA_HAVE_ABORT) |
| 2192 | { |
| 2193 | pp_string (pp, "GTMA_HAVE_ABORT "); |
| 2194 | subcode &= ~GTMA_HAVE_ABORT; |
| 2195 | } |
| 2196 | if (subcode & GTMA_HAVE_LOAD) |
| 2197 | { |
| 2198 | pp_string (pp, "GTMA_HAVE_LOAD "); |
| 2199 | subcode &= ~GTMA_HAVE_LOAD; |
| 2200 | } |
| 2201 | if (subcode & GTMA_HAVE_STORE) |
| 2202 | { |
| 2203 | pp_string (pp, "GTMA_HAVE_STORE "); |
| 2204 | subcode &= ~GTMA_HAVE_STORE; |
| 2205 | } |
| 2206 | if (subcode & GTMA_MAY_ENTER_IRREVOCABLE) |
| 2207 | { |
| 2208 | pp_string (pp, "GTMA_MAY_ENTER_IRREVOCABLE "); |
| 2209 | subcode &= ~GTMA_MAY_ENTER_IRREVOCABLE; |
| 2210 | } |
| 2211 | if (subcode & GTMA_DOES_GO_IRREVOCABLE) |
| 2212 | { |
| 2213 | pp_string (pp, "GTMA_DOES_GO_IRREVOCABLE "); |
| 2214 | subcode &= ~GTMA_DOES_GO_IRREVOCABLE; |
| 2215 | } |
| 2216 | if (subcode & GTMA_HAS_NO_INSTRUMENTATION) |
| 2217 | { |
| 2218 | pp_string (pp, "GTMA_HAS_NO_INSTRUMENTATION "); |
| 2219 | subcode &= ~GTMA_HAS_NO_INSTRUMENTATION; |
| 2220 | } |
| 2221 | if (subcode) |
| 2222 | pp_printf (pp, "0x%x ", subcode); |
| 2223 | pp_right_bracket (pp); |
| 2224 | } |
| 2225 | } |
| 2226 | } |
| 2227 | } |
| 2228 | |
| 2229 | /* Dump a GIMPLE_ASM tuple on the pretty_printer PP, SPC spaces of |
| 2230 | indent. FLAGS specifies details to show in the dump (see TDF_* in |
| 2231 | dumpfile.h). */ |
| 2232 | |
| 2233 | static void |
| 2234 | dump_gimple_asm (pretty_printer *pp, const gasm *gs, int spc, |
| 2235 | dump_flags_t flags) |
| 2236 | { |
| 2237 | unsigned int i, n, f, fields; |
| 2238 | |
| 2239 | if (flags & TDF_RAW) |
| 2240 | { |
| 2241 | dump_gimple_fmt (pp, spc, flags, "%G <%+STRING <%n%s%n>", gs, |
| 2242 | gimple_asm_string (gs)); |
| 2243 | |
| 2244 | n = gimple_asm_noutputs (gs); |
| 2245 | if (n) |
| 2246 | { |
| 2247 | newline_and_indent (pp, spc + 2); |
| 2248 | pp_string (pp, "OUTPUT: "); |
| 2249 | for (i = 0; i < n; i++) |
| 2250 | { |
| 2251 | dump_generic_node (pp, gimple_asm_output_op (gs, i), |
| 2252 | spc, flags, false); |
| 2253 | if (i < n - 1) |
| 2254 | pp_string (pp, ", "); |
| 2255 | } |
| 2256 | } |
| 2257 | |
| 2258 | n = gimple_asm_ninputs (gs); |
| 2259 | if (n) |
| 2260 | { |
| 2261 | newline_and_indent (pp, spc + 2); |
| 2262 | pp_string (pp, "INPUT: "); |
| 2263 | for (i = 0; i < n; i++) |
| 2264 | { |
| 2265 | dump_generic_node (pp, gimple_asm_input_op (gs, i), |
| 2266 | spc, flags, false); |
| 2267 | if (i < n - 1) |
| 2268 | pp_string (pp, ", "); |
| 2269 | } |
| 2270 | } |
| 2271 | |
| 2272 | n = gimple_asm_nclobbers (gs); |
| 2273 | if (n) |
| 2274 | { |
| 2275 | newline_and_indent (pp, spc + 2); |
| 2276 | pp_string (pp, "CLOBBER: "); |
| 2277 | for (i = 0; i < n; i++) |
| 2278 | { |
| 2279 | dump_generic_node (pp, gimple_asm_clobber_op (gs, i), |
| 2280 | spc, flags, false); |
| 2281 | if (i < n - 1) |
| 2282 | pp_string (pp, ", "); |
| 2283 | } |
| 2284 | } |
| 2285 | |
| 2286 | n = gimple_asm_nlabels (gs); |
| 2287 | if (n) |
| 2288 | { |
| 2289 | newline_and_indent (pp, spc + 2); |
| 2290 | pp_string (pp, "LABEL: "); |
| 2291 | for (i = 0; i < n; i++) |
| 2292 | { |
| 2293 | dump_generic_node (pp, gimple_asm_label_op (gs, i), |
| 2294 | spc, flags, false); |
| 2295 | if (i < n - 1) |
| 2296 | pp_string (pp, ", "); |
| 2297 | } |
| 2298 | } |
| 2299 | |
| 2300 | newline_and_indent (pp, spc); |
| 2301 | pp_greater (pp); |
| 2302 | } |
| 2303 | else |
| 2304 | { |
| 2305 | pp_string (pp, "__asm__"); |
| 2306 | if (gimple_asm_volatile_p (gs)) |
| 2307 | pp_string (pp, " __volatile__"); |
| 2308 | if (gimple_asm_inline_p (gs)) |
| 2309 | pp_string (pp, " __inline__"); |
| 2310 | if (gimple_asm_nlabels (gs)) |
| 2311 | pp_string (pp, " goto"); |
| 2312 | pp_string (pp, "(\""); |
| 2313 | pp_string (pp, gimple_asm_string (gs)); |
| 2314 | pp_string (pp, "\""); |
| 2315 | |
| 2316 | if (gimple_asm_nlabels (gs)) |
| 2317 | fields = 4; |
| 2318 | else if (gimple_asm_nclobbers (gs)) |
| 2319 | fields = 3; |
| 2320 | else if (gimple_asm_ninputs (gs)) |
| 2321 | fields = 2; |
| 2322 | else if (gimple_asm_noutputs (gs)) |
| 2323 | fields = 1; |
| 2324 | else |
| 2325 | fields = 0; |
| 2326 | |
| 2327 | for (f = 0; f < fields; ++f) |
| 2328 | { |
| 2329 | pp_string (pp, " : "); |
| 2330 | |
| 2331 | switch (f) |
| 2332 | { |
| 2333 | case 0: |
| 2334 | n = gimple_asm_noutputs (gs); |
| 2335 | for (i = 0; i < n; i++) |
| 2336 | { |
| 2337 | dump_generic_node (pp, gimple_asm_output_op (gs, i), |
| 2338 | spc, flags, false); |
| 2339 | if (i < n - 1) |
| 2340 | pp_string (pp, ", "); |
| 2341 | } |
| 2342 | break; |
| 2343 | |
| 2344 | case 1: |
| 2345 | n = gimple_asm_ninputs (gs); |
| 2346 | for (i = 0; i < n; i++) |
| 2347 | { |
| 2348 | dump_generic_node (pp, gimple_asm_input_op (gs, i), |
| 2349 | spc, flags, false); |
| 2350 | if (i < n - 1) |
| 2351 | pp_string (pp, ", "); |
| 2352 | } |
| 2353 | break; |
| 2354 | |
| 2355 | case 2: |
| 2356 | n = gimple_asm_nclobbers (gs); |
| 2357 | for (i = 0; i < n; i++) |
| 2358 | { |
| 2359 | dump_generic_node (pp, gimple_asm_clobber_op (gs, i), |
| 2360 | spc, flags, false); |
| 2361 | if (i < n - 1) |
| 2362 | pp_string (pp, ", "); |
| 2363 | } |
| 2364 | break; |
| 2365 | |
| 2366 | case 3: |
| 2367 | n = gimple_asm_nlabels (gs); |
| 2368 | for (i = 0; i < n; i++) |
| 2369 | { |
| 2370 | dump_generic_node (pp, gimple_asm_label_op (gs, i), |
| 2371 | spc, flags, false); |
| 2372 | if (i < n - 1) |
| 2373 | pp_string (pp, ", "); |
| 2374 | } |
| 2375 | break; |
| 2376 | |
| 2377 | default: |
| 2378 | gcc_unreachable (); |
| 2379 | } |
| 2380 | } |
| 2381 | |
| 2382 | pp_string (pp, ");"); |
| 2383 | } |
| 2384 | } |
| 2385 | |
| 2386 | /* Dump ptr_info and range_info for NODE on pretty_printer PP with |
| 2387 | SPC spaces of indent. */ |
| 2388 | |
| 2389 | static void |
| 2390 | dump_ssaname_info (pretty_printer *pp, tree node, int spc) |
| 2391 | { |
| 2392 | if (TREE_CODE (node) != SSA_NAME) |
| 2393 | return; |
| 2394 | |
| 2395 | if (POINTER_TYPE_P (TREE_TYPE (node)) |
| 2396 | && SSA_NAME_PTR_INFO (node)) |
| 2397 | { |
| 2398 | unsigned int align, misalign; |
| 2399 | struct ptr_info_def *pi = SSA_NAME_PTR_INFO (node); |
| 2400 | pp_string (pp, "# PT = "); |
| 2401 | pp_points_to_solution (pp, &pi->pt); |
| 2402 | newline_and_indent (pp, spc); |
| 2403 | if (get_ptr_info_alignment (pi, &align, &misalign)) |
| 2404 | { |
| 2405 | pp_printf (pp, "# ALIGN = %u, MISALIGN = %u", align, misalign); |
| 2406 | newline_and_indent (pp, spc); |
| 2407 | } |
| 2408 | } |
| 2409 | |
| 2410 | if (!POINTER_TYPE_P (TREE_TYPE (node)) |
| 2411 | && SSA_NAME_RANGE_INFO (node)) |
| 2412 | { |
| 2413 | value_range r (TREE_TYPE (node)); |
| 2414 | get_global_range_query ()->range_of_expr (r, node); |
| 2415 | pp_string (pp, "# RANGE "); |
| 2416 | pp_vrange (pp, &r); |
| 2417 | newline_and_indent (pp, spc); |
| 2418 | } |
| 2419 | } |
| 2420 | |
| 2421 | /* As dump_ssaname_info, but dump to FILE. */ |
| 2422 | |
| 2423 | void |
| 2424 | dump_ssaname_info_to_file (FILE *file, tree node, int spc) |
| 2425 | { |
| 2426 | pretty_printer pp; |
| 2427 | pp_needs_newline (&pp) = true; |
| 2428 | pp.set_output_stream (file); |
| 2429 | dump_ssaname_info (&pp, node, spc); |
| 2430 | pp_flush (&pp); |
| 2431 | } |
| 2432 | |
| 2433 | /* Dump a PHI node PHI. PP, SPC and FLAGS are as in pp_gimple_stmt_1. |
| 2434 | The caller is responsible for calling pp_flush on PP to finalize |
| 2435 | pretty printer. If COMMENT is true, print this after #. */ |
| 2436 | |
| 2437 | static void |
| 2438 | dump_gimple_phi (pretty_printer *pp, const gphi *phi, int spc, bool comment, |
| 2439 | dump_flags_t flags) |
| 2440 | { |
| 2441 | size_t i; |
| 2442 | tree lhs = gimple_phi_result (phi); |
| 2443 | |
| 2444 | if (flags & TDF_ALIAS) |
| 2445 | dump_ssaname_info (pp, lhs, spc); |
| 2446 | |
| 2447 | if (comment) |
| 2448 | pp_string (pp, "# "); |
| 2449 | |
| 2450 | if (flags & TDF_RAW) |
| 2451 | dump_gimple_fmt (pp, spc, flags, "%G <%T, ", phi, |
| 2452 | gimple_phi_result (phi)); |
| 2453 | else |
| 2454 | { |
| 2455 | dump_generic_node (pp, lhs, spc, flags, false); |
| 2456 | if (flags & TDF_GIMPLE) |
| 2457 | pp_string (pp, " = __PHI ("); |
| 2458 | else |
| 2459 | pp_string (pp, " = PHI <"); |
| 2460 | } |
| 2461 | for (i = 0; i < gimple_phi_num_args (phi); i++) |
| 2462 | { |
| 2463 | if ((flags & TDF_LINENO) && gimple_phi_arg_has_location (phi, i)) |
| 2464 | dump_location (pp, gimple_phi_arg_location (phi, i)); |
| 2465 | basic_block src = gimple_phi_arg_edge (phi, i)->src; |
| 2466 | if (flags & TDF_GIMPLE) |
| 2467 | { |
| 2468 | pp_string (pp, "__BB"); |
| 2469 | pp_decimal_int (pp, src->index); |
| 2470 | pp_string (pp, ": "); |
| 2471 | } |
| 2472 | dump_generic_node (pp, gimple_phi_arg_def (phi, i), spc, flags, |
| 2473 | false); |
| 2474 | if (! (flags & TDF_GIMPLE)) |
| 2475 | { |
| 2476 | pp_left_paren (pp); |
| 2477 | pp_decimal_int (pp, src->index); |
| 2478 | pp_right_paren (pp); |
| 2479 | } |
| 2480 | if (i < gimple_phi_num_args (phi) - 1) |
| 2481 | pp_string (pp, ", "); |
| 2482 | } |
| 2483 | if (flags & TDF_GIMPLE) |
| 2484 | pp_string (pp, ");"); |
| 2485 | else |
| 2486 | pp_greater (pp); |
| 2487 | } |
| 2488 | |
| 2489 | |
| 2490 | /* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer PP, SPC spaces |
| 2491 | of indent. FLAGS specifies details to show in the dump (see TDF_* in |
| 2492 | dumpfile.h). */ |
| 2493 | |
| 2494 | static void |
| 2495 | dump_gimple_omp_parallel (pretty_printer *pp, const gomp_parallel *gs, |
| 2496 | int spc, dump_flags_t flags) |
| 2497 | { |
| 2498 | if (flags & TDF_RAW) |
| 2499 | { |
| 2500 | dump_gimple_fmt (pp, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs, |
| 2501 | gimple_omp_body (gs)); |
| 2502 | dump_omp_clauses (pp, gimple_omp_parallel_clauses (gs), spc, flags); |
| 2503 | dump_gimple_fmt (pp, spc, flags, " >, %T, %T%n>", |
| 2504 | gimple_omp_parallel_child_fn (gs), |
| 2505 | gimple_omp_parallel_data_arg (gs)); |
| 2506 | } |
| 2507 | else |
| 2508 | { |
| 2509 | gimple_seq body; |
| 2510 | pp_string (pp, "#pragma omp parallel"); |
| 2511 | dump_omp_clauses (pp, gimple_omp_parallel_clauses (gs), spc, flags); |
| 2512 | if (gimple_omp_parallel_child_fn (gs)) |
| 2513 | { |
| 2514 | pp_string (pp, " [child fn: "); |
| 2515 | dump_generic_node (pp, gimple_omp_parallel_child_fn (gs), |
| 2516 | spc, flags, false); |
| 2517 | pp_string (pp, " ("); |
| 2518 | if (gimple_omp_parallel_data_arg (gs)) |
| 2519 | dump_generic_node (pp, gimple_omp_parallel_data_arg (gs), |
| 2520 | spc, flags, false); |
| 2521 | else |
| 2522 | pp_string (pp, "???"); |
| 2523 | pp_string (pp, ")]"); |
| 2524 | } |
| 2525 | body = gimple_omp_body (gs); |
| 2526 | if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND) |
| 2527 | { |
| 2528 | newline_and_indent (pp, spc + 2); |
| 2529 | pp_left_brace (pp); |
| 2530 | pp_newline (pp); |
| 2531 | dump_gimple_seq (pp, body, spc + 4, flags); |
| 2532 | newline_and_indent (pp, spc + 2); |
| 2533 | pp_right_brace (pp); |
| 2534 | } |
| 2535 | else if (body) |
| 2536 | { |
| 2537 | pp_newline (pp); |
| 2538 | dump_gimple_seq (pp, body, spc + 2, flags); |
| 2539 | } |
| 2540 | } |
| 2541 | } |
| 2542 | |
| 2543 | |
| 2544 | /* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer PP, SPC spaces |
| 2545 | of indent. FLAGS specifies details to show in the dump (see TDF_* in |
| 2546 | dumpfile.h). */ |
| 2547 | |
| 2548 | static void |
| 2549 | dump_gimple_omp_task (pretty_printer *pp, const gomp_task *gs, int spc, |
| 2550 | dump_flags_t flags) |
| 2551 | { |
| 2552 | if (flags & TDF_RAW) |
| 2553 | { |
| 2554 | dump_gimple_fmt (pp, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs, |
| 2555 | gimple_omp_body (gs)); |
| 2556 | dump_omp_clauses (pp, gimple_omp_task_clauses (gs), spc, flags); |
| 2557 | dump_gimple_fmt (pp, spc, flags, " >, %T, %T, %T, %T, %T%n>", |
| 2558 | gimple_omp_task_child_fn (gs), |
| 2559 | gimple_omp_task_data_arg (gs), |
| 2560 | gimple_omp_task_copy_fn (gs), |
| 2561 | gimple_omp_task_arg_size (gs), |
| 2562 | gimple_omp_task_arg_size (gs)); |
| 2563 | } |
| 2564 | else |
| 2565 | { |
| 2566 | gimple_seq body; |
| 2567 | if (gimple_omp_task_taskloop_p (gs)) |
| 2568 | pp_string (pp, "#pragma omp taskloop"); |
| 2569 | else if (gimple_omp_task_taskwait_p (gs)) |
| 2570 | pp_string (pp, "#pragma omp taskwait"); |
| 2571 | else |
| 2572 | pp_string (pp, "#pragma omp task"); |
| 2573 | dump_omp_clauses (pp, gimple_omp_task_clauses (gs), spc, flags); |
| 2574 | if (gimple_omp_task_child_fn (gs)) |
| 2575 | { |
| 2576 | pp_string (pp, " [child fn: "); |
| 2577 | dump_generic_node (pp, gimple_omp_task_child_fn (gs), |
| 2578 | spc, flags, false); |
| 2579 | pp_string (pp, " ("); |
| 2580 | if (gimple_omp_task_data_arg (gs)) |
| 2581 | dump_generic_node (pp, gimple_omp_task_data_arg (gs), |
| 2582 | spc, flags, false); |
| 2583 | else |
| 2584 | pp_string (pp, "???"); |
| 2585 | pp_string (pp, ")]"); |
| 2586 | } |
| 2587 | body = gimple_omp_body (gs); |
| 2588 | if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND) |
| 2589 | { |
| 2590 | newline_and_indent (pp, spc + 2); |
| 2591 | pp_left_brace (pp); |
| 2592 | pp_newline (pp); |
| 2593 | dump_gimple_seq (pp, body, spc + 4, flags); |
| 2594 | newline_and_indent (pp, spc + 2); |
| 2595 | pp_right_brace (pp); |
| 2596 | } |
| 2597 | else if (body) |
| 2598 | { |
| 2599 | pp_newline (pp); |
| 2600 | dump_gimple_seq (pp, body, spc + 2, flags); |
| 2601 | } |
| 2602 | } |
| 2603 | } |
| 2604 | |
| 2605 | |
| 2606 | /* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer PP, SPC |
| 2607 | spaces of indent. FLAGS specifies details to show in the dump (see TDF_* |
| 2608 | in dumpfile.h). */ |
| 2609 | |
| 2610 | static void |
| 2611 | dump_gimple_omp_atomic_load (pretty_printer *pp, const gomp_atomic_load *gs, |
| 2612 | int spc, dump_flags_t flags) |
| 2613 | { |
| 2614 | if (flags & TDF_RAW) |
| 2615 | { |
| 2616 | dump_gimple_fmt (pp, spc, flags, "%G <%T, %T>", gs, |
| 2617 | gimple_omp_atomic_load_lhs (gs), |
| 2618 | gimple_omp_atomic_load_rhs (gs)); |
| 2619 | } |
| 2620 | else |
| 2621 | { |
| 2622 | pp_string (pp, "#pragma omp atomic_load"); |
| 2623 | dump_omp_atomic_memory_order (pp, |
| 2624 | gimple_omp_atomic_memory_order (gs)); |
| 2625 | if (gimple_omp_atomic_need_value_p (gs)) |
| 2626 | pp_string (pp, " [needed]"); |
| 2627 | if (gimple_omp_atomic_weak_p (gs)) |
| 2628 | pp_string (pp, " [weak]"); |
| 2629 | newline_and_indent (pp, spc + 2); |
| 2630 | dump_generic_node (pp, gimple_omp_atomic_load_lhs (gs), |
| 2631 | spc, flags, false); |
| 2632 | pp_space (pp); |
| 2633 | pp_equal (pp); |
| 2634 | pp_space (pp); |
| 2635 | pp_star (pp); |
| 2636 | dump_generic_node (pp, gimple_omp_atomic_load_rhs (gs), |
| 2637 | spc, flags, false); |
| 2638 | } |
| 2639 | } |
| 2640 | |
| 2641 | /* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer PP, SPC |
| 2642 | spaces of indent. FLAGS specifies details to show in the dump (see TDF_* |
| 2643 | in dumpfile.h). */ |
| 2644 | |
| 2645 | static void |
| 2646 | dump_gimple_omp_atomic_store (pretty_printer *pp, |
| 2647 | const gomp_atomic_store *gs, int spc, |
| 2648 | dump_flags_t flags) |
| 2649 | { |
| 2650 | if (flags & TDF_RAW) |
| 2651 | { |
| 2652 | dump_gimple_fmt (pp, spc, flags, "%G <%T>", gs, |
| 2653 | gimple_omp_atomic_store_val (gs)); |
| 2654 | } |
| 2655 | else |
| 2656 | { |
| 2657 | pp_string (pp, "#pragma omp atomic_store"); |
| 2658 | dump_omp_atomic_memory_order (pp, |
| 2659 | gimple_omp_atomic_memory_order (gs)); |
| 2660 | pp_space (pp); |
| 2661 | if (gimple_omp_atomic_need_value_p (gs)) |
| 2662 | pp_string (pp, "[needed] "); |
| 2663 | if (gimple_omp_atomic_weak_p (gs)) |
| 2664 | pp_string (pp, "[weak] "); |
| 2665 | pp_left_paren (pp); |
| 2666 | dump_generic_node (pp, gimple_omp_atomic_store_val (gs), |
| 2667 | spc, flags, false); |
| 2668 | pp_right_paren (pp); |
| 2669 | } |
| 2670 | } |
| 2671 | |
| 2672 | |
| 2673 | /* Dump all the memory operands for statement GS. PP, SPC and |
| 2674 | FLAGS are as in pp_gimple_stmt_1. */ |
| 2675 | |
| 2676 | static void |
| 2677 | dump_gimple_mem_ops (pretty_printer *pp, const gimple *gs, int spc, |
| 2678 | dump_flags_t flags) |
| 2679 | { |
| 2680 | tree vdef = gimple_vdef (gs); |
| 2681 | tree vuse = gimple_vuse (gs); |
| 2682 | |
| 2683 | if (vdef != NULL_TREE) |
| 2684 | { |
| 2685 | pp_string (pp, "# "); |
| 2686 | dump_generic_node (pp, vdef, spc + 2, flags, false); |
| 2687 | pp_string (pp, " = VDEF <"); |
| 2688 | dump_generic_node (pp, vuse, spc + 2, flags, false); |
| 2689 | pp_greater (pp); |
| 2690 | newline_and_indent (pp, spc); |
| 2691 | } |
| 2692 | else if (vuse != NULL_TREE) |
| 2693 | { |
| 2694 | pp_string (pp, "# VUSE <"); |
| 2695 | dump_generic_node (pp, vuse, spc + 2, flags, false); |
| 2696 | pp_greater (pp); |
| 2697 | newline_and_indent (pp, spc); |
| 2698 | } |
| 2699 | } |
| 2700 | |
| 2701 | |
| 2702 | /* Print the gimple statement GS on the pretty printer PP, SPC |
| 2703 | spaces of indent. FLAGS specifies details to show in the dump (see |
| 2704 | TDF_* in dumpfile.h). The caller is responsible for calling |
| 2705 | pp_flush on PP to finalize the pretty printer. */ |
| 2706 | |
| 2707 | void |
| 2708 | pp_gimple_stmt_1 (pretty_printer *pp, const gimple *gs, int spc, |
| 2709 | dump_flags_t flags) |
| 2710 | { |
| 2711 | if (!gs) |
| 2712 | return; |
| 2713 | |
| 2714 | if (flags & TDF_STMTADDR) |
| 2715 | pp_printf (pp, "<&%p> ", (const void *) gs); |
| 2716 | |
| 2717 | if ((flags & TDF_LINENO) && gimple_has_location (gs)) |
| 2718 | dump_location (pp, gimple_location (gs)); |
| 2719 | |
| 2720 | if (flags & TDF_EH) |
| 2721 | { |
| 2722 | int lp_nr = lookup_stmt_eh_lp (gs); |
| 2723 | if (lp_nr > 0) |
| 2724 | pp_printf (pp, "[LP %d] ", lp_nr); |
| 2725 | else if (lp_nr < 0) |
| 2726 | pp_printf (pp, "[MNT %d] ", -lp_nr); |
| 2727 | } |
| 2728 | |
| 2729 | if ((flags & (TDF_VOPS|TDF_MEMSYMS)) |
| 2730 | && gimple_has_mem_ops (gs)) |
| 2731 | dump_gimple_mem_ops (pp, gs, spc, flags); |
| 2732 | |
| 2733 | if (gimple_has_lhs (gs) |
| 2734 | && (flags & TDF_ALIAS)) |
| 2735 | dump_ssaname_info (pp, gimple_get_lhs (gs), spc); |
| 2736 | |
| 2737 | switch (gimple_code (gs)) |
| 2738 | { |
| 2739 | case GIMPLE_ASM: |
| 2740 | dump_gimple_asm (pp, as_a <const gasm *> (gs), spc, flags); |
| 2741 | break; |
| 2742 | |
| 2743 | case GIMPLE_ASSIGN: |
| 2744 | dump_gimple_assign (pp, as_a <const gassign *> (gs), spc, flags); |
| 2745 | break; |
| 2746 | |
| 2747 | case GIMPLE_BIND: |
| 2748 | dump_gimple_bind (pp, as_a <const gbind *> (gs), spc, flags); |
| 2749 | break; |
| 2750 | |
| 2751 | case GIMPLE_CALL: |
| 2752 | dump_gimple_call (pp, as_a <const gcall *> (gs), spc, flags); |
| 2753 | break; |
| 2754 | |
| 2755 | case GIMPLE_COND: |
| 2756 | dump_gimple_cond (pp, as_a <const gcond *> (gs), spc, flags); |
| 2757 | break; |
| 2758 | |
| 2759 | case GIMPLE_LABEL: |
| 2760 | dump_gimple_label (pp, as_a <const glabel *> (gs), spc, flags); |
| 2761 | break; |
| 2762 | |
| 2763 | case GIMPLE_GOTO: |
| 2764 | dump_gimple_goto (pp, as_a <const ggoto *> (gs), spc, flags); |
| 2765 | break; |
| 2766 | |
| 2767 | case GIMPLE_NOP: |
| 2768 | pp_string (pp, "GIMPLE_NOP"); |
| 2769 | break; |
| 2770 | |
| 2771 | case GIMPLE_RETURN: |
| 2772 | dump_gimple_return (pp, as_a <const greturn *> (gs), spc, flags); |
| 2773 | break; |
| 2774 | |
| 2775 | case GIMPLE_SWITCH: |
| 2776 | dump_gimple_switch (pp, as_a <const gswitch *> (gs), spc, flags); |
| 2777 | break; |
| 2778 | |
| 2779 | case GIMPLE_TRY: |
| 2780 | dump_gimple_try (pp, as_a <const gtry *> (gs), spc, flags); |
| 2781 | break; |
| 2782 | |
| 2783 | case GIMPLE_PHI: |
| 2784 | dump_gimple_phi (pp, as_a <const gphi *> (gs), spc, false, flags); |
| 2785 | break; |
| 2786 | |
| 2787 | case GIMPLE_OMP_PARALLEL: |
| 2788 | dump_gimple_omp_parallel (pp, as_a <const gomp_parallel *> (gs), spc, |
| 2789 | flags); |
| 2790 | break; |
| 2791 | |
| 2792 | case GIMPLE_OMP_TASK: |
| 2793 | dump_gimple_omp_task (pp, as_a <const gomp_task *> (gs), spc, flags); |
| 2794 | break; |
| 2795 | |
| 2796 | case GIMPLE_OMP_ATOMIC_LOAD: |
| 2797 | dump_gimple_omp_atomic_load (pp, as_a <const gomp_atomic_load *> (gs), |
| 2798 | spc, flags); |
| 2799 | break; |
| 2800 | |
| 2801 | case GIMPLE_OMP_ATOMIC_STORE: |
| 2802 | dump_gimple_omp_atomic_store (pp, |
| 2803 | as_a <const gomp_atomic_store *> (gs), |
| 2804 | spc, flags); |
| 2805 | break; |
| 2806 | |
| 2807 | case GIMPLE_OMP_FOR: |
| 2808 | dump_gimple_omp_for (pp, as_a <const gomp_for *> (gs), spc, flags); |
| 2809 | break; |
| 2810 | |
| 2811 | case GIMPLE_OMP_CONTINUE: |
| 2812 | dump_gimple_omp_continue (pp, as_a <const gomp_continue *> (gs), spc, |
| 2813 | flags); |
| 2814 | break; |
| 2815 | |
| 2816 | case GIMPLE_OMP_SINGLE: |
| 2817 | dump_gimple_omp_single (pp, as_a <const gomp_single *> (gs), spc, |
| 2818 | flags); |
| 2819 | break; |
| 2820 | |
| 2821 | case GIMPLE_OMP_TARGET: |
| 2822 | dump_gimple_omp_target (pp, as_a <const gomp_target *> (gs), spc, |
| 2823 | flags); |
| 2824 | break; |
| 2825 | |
| 2826 | case GIMPLE_OMP_TEAMS: |
| 2827 | dump_gimple_omp_teams (pp, as_a <const gomp_teams *> (gs), spc, |
| 2828 | flags); |
| 2829 | break; |
| 2830 | |
| 2831 | case GIMPLE_OMP_RETURN: |
| 2832 | dump_gimple_omp_return (pp, gs, spc, flags); |
| 2833 | break; |
| 2834 | |
| 2835 | case GIMPLE_OMP_SECTIONS: |
| 2836 | dump_gimple_omp_sections (pp, as_a <const gomp_sections *> (gs), |
| 2837 | spc, flags); |
| 2838 | break; |
| 2839 | |
| 2840 | case GIMPLE_OMP_SECTIONS_SWITCH: |
| 2841 | pp_string (pp, "GIMPLE_SECTIONS_SWITCH"); |
| 2842 | break; |
| 2843 | |
| 2844 | case GIMPLE_OMP_TASKGROUP: |
| 2845 | dump_gimple_omp_taskgroup (pp, gs, spc, flags); |
| 2846 | break; |
| 2847 | |
| 2848 | case GIMPLE_OMP_MASKED: |
| 2849 | dump_gimple_omp_masked (pp, gs, spc, flags); |
| 2850 | break; |
| 2851 | |
| 2852 | case GIMPLE_OMP_SCOPE: |
| 2853 | dump_gimple_omp_scope (pp, gs, spc, flags); |
| 2854 | break; |
| 2855 | |
| 2856 | case GIMPLE_OMP_DISPATCH: |
| 2857 | dump_gimple_omp_dispatch(pp, gs, spc, flags); |
| 2858 | break; |
| 2859 | |
| 2860 | case GIMPLE_OMP_INTEROP: |
| 2861 | dump_gimple_omp_interop (pp, gs, spc, flags); |
| 2862 | break; |
| 2863 | |
| 2864 | case GIMPLE_OMP_MASTER: |
| 2865 | case GIMPLE_OMP_SECTION: |
| 2866 | case GIMPLE_OMP_STRUCTURED_BLOCK: |
| 2867 | dump_gimple_omp_block (pp, gs, spc, flags); |
| 2868 | break; |
| 2869 | |
| 2870 | case GIMPLE_OMP_ORDERED: |
| 2871 | dump_gimple_omp_ordered (pp, as_a <const gomp_ordered *> (gs), spc, |
| 2872 | flags); |
| 2873 | break; |
| 2874 | |
| 2875 | case GIMPLE_OMP_SCAN: |
| 2876 | dump_gimple_omp_scan (pp, as_a <const gomp_scan *> (gs), spc, |
| 2877 | flags); |
| 2878 | break; |
| 2879 | |
| 2880 | case GIMPLE_OMP_CRITICAL: |
| 2881 | dump_gimple_omp_critical (pp, as_a <const gomp_critical *> (gs), spc, |
| 2882 | flags); |
| 2883 | break; |
| 2884 | |
| 2885 | case GIMPLE_CATCH: |
| 2886 | dump_gimple_catch (pp, as_a <const gcatch *> (gs), spc, flags); |
| 2887 | break; |
| 2888 | |
| 2889 | case GIMPLE_EH_FILTER: |
| 2890 | dump_gimple_eh_filter (pp, as_a <const geh_filter *> (gs), spc, |
| 2891 | flags); |
| 2892 | break; |
| 2893 | |
| 2894 | case GIMPLE_EH_MUST_NOT_THROW: |
| 2895 | dump_gimple_eh_must_not_throw (pp, |
| 2896 | as_a <const geh_mnt *> (gs), |
| 2897 | spc, flags); |
| 2898 | break; |
| 2899 | |
| 2900 | case GIMPLE_EH_ELSE: |
| 2901 | dump_gimple_eh_else (pp, as_a <const geh_else *> (gs), spc, flags); |
| 2902 | break; |
| 2903 | |
| 2904 | case GIMPLE_RESX: |
| 2905 | dump_gimple_resx (pp, as_a <const gresx *> (gs), spc, flags); |
| 2906 | break; |
| 2907 | |
| 2908 | case GIMPLE_EH_DISPATCH: |
| 2909 | dump_gimple_eh_dispatch (pp, as_a <const geh_dispatch *> (gs), spc, |
| 2910 | flags); |
| 2911 | break; |
| 2912 | |
| 2913 | case GIMPLE_DEBUG: |
| 2914 | dump_gimple_debug (pp, as_a <const gdebug *> (gs), spc, flags); |
| 2915 | break; |
| 2916 | |
| 2917 | case GIMPLE_PREDICT: |
| 2918 | pp_string (pp, "// predicted "); |
| 2919 | if (gimple_predict_outcome (gs)) |
| 2920 | pp_string (pp, "likely by "); |
| 2921 | else |
| 2922 | pp_string (pp, "unlikely by "); |
| 2923 | pp_string (pp, predictor_name (gimple_predict_predictor (gs))); |
| 2924 | pp_string (pp, " predictor."); |
| 2925 | break; |
| 2926 | |
| 2927 | case GIMPLE_ASSUME: |
| 2928 | dump_gimple_assume (pp, gs, spc, flags); |
| 2929 | break; |
| 2930 | |
| 2931 | case GIMPLE_TRANSACTION: |
| 2932 | dump_gimple_transaction (pp, as_a <const gtransaction *> (gs), spc, |
| 2933 | flags); |
| 2934 | break; |
| 2935 | |
| 2936 | default: |
| 2937 | GIMPLE_NIY; |
| 2938 | } |
| 2939 | } |
| 2940 | |
| 2941 | |
| 2942 | /* Dumps header of basic block BB to OUTF indented by INDENT |
| 2943 | spaces and details described by flags. */ |
| 2944 | |
| 2945 | static void |
| 2946 | dump_gimple_bb_header (FILE *outf, basic_block bb, int indent, |
| 2947 | dump_flags_t flags) |
| 2948 | { |
| 2949 | if (flags & TDF_BLOCKS) |
| 2950 | { |
| 2951 | if (flags & TDF_LINENO) |
| 2952 | { |
| 2953 | gimple_stmt_iterator gsi; |
| 2954 | |
| 2955 | fputs (";; ", outf); |
| 2956 | |
| 2957 | for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) |
| 2958 | if (!is_gimple_debug (gsi_stmt (gsi)) |
| 2959 | && get_lineno (gsi_stmt (gsi)) != UNKNOWN_LOCATION) |
| 2960 | { |
| 2961 | fprintf (outf, "%*sstarting at line %d", |
| 2962 | indent, "", get_lineno (gsi_stmt (gsi))); |
| 2963 | break; |
| 2964 | } |
| 2965 | fputc ('\n', outf); |
| 2966 | } |
| 2967 | } |
| 2968 | else |
| 2969 | { |
| 2970 | if (flags & TDF_GIMPLE) |
| 2971 | { |
| 2972 | fprintf (outf, "%*s__BB(%d", indent, "", bb->index); |
| 2973 | if (bb->loop_father->header == bb) |
| 2974 | fprintf (outf, ",loop_header(%d)", bb->loop_father->num); |
| 2975 | if (bb->count.initialized_p ()) |
| 2976 | fprintf (outf, ",%s(%" PRIu64 ")", |
| 2977 | profile_quality_as_string (bb->count.quality ()), |
| 2978 | bb->count.value ()); |
| 2979 | fprintf (outf, "):\n"); |
| 2980 | } |
| 2981 | else |
| 2982 | fprintf (outf, "%*s<bb %d> %s:\n", |
| 2983 | indent, "", bb->index, dump_profile (bb->count)); |
| 2984 | } |
| 2985 | } |
| 2986 | |
| 2987 | |
| 2988 | /* Dumps end of basic block BB to PP indented by INDENT |
| 2989 | spaces. */ |
| 2990 | |
| 2991 | static void |
| 2992 | dump_gimple_bb_footer (FILE *outf ATTRIBUTE_UNUSED, |
| 2993 | basic_block bb ATTRIBUTE_UNUSED, |
| 2994 | int indent ATTRIBUTE_UNUSED, |
| 2995 | dump_flags_t flags ATTRIBUTE_UNUSED) |
| 2996 | { |
| 2997 | /* There is currently no GIMPLE-specific basic block info to dump. */ |
| 2998 | return; |
| 2999 | } |
| 3000 | |
| 3001 | |
| 3002 | /* Dump PHI nodes of basic block BB to PP with details described |
| 3003 | by FLAGS and indented by INDENT spaces. */ |
| 3004 | |
| 3005 | static void |
| 3006 | dump_phi_nodes (pretty_printer *pp, basic_block bb, int indent, |
| 3007 | dump_flags_t flags) |
| 3008 | { |
| 3009 | gphi_iterator i; |
| 3010 | |
| 3011 | for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i)) |
| 3012 | { |
| 3013 | gphi *phi = i.phi (); |
| 3014 | if (!virtual_operand_p (gimple_phi_result (phi)) || (flags & TDF_VOPS)) |
| 3015 | { |
| 3016 | INDENT (indent); |
| 3017 | dump_gimple_phi (pp, phi, indent, |
| 3018 | (flags & TDF_GIMPLE) ? false : true, flags); |
| 3019 | pp_newline (pp); |
| 3020 | } |
| 3021 | } |
| 3022 | } |
| 3023 | |
| 3024 | |
| 3025 | /* Dump jump to basic block BB that is represented implicitly in the cfg |
| 3026 | to PP. */ |
| 3027 | |
| 3028 | static void |
| 3029 | pp_cfg_jump (pretty_printer *pp, edge e, dump_flags_t flags) |
| 3030 | { |
| 3031 | if (flags & TDF_GIMPLE) |
| 3032 | { |
| 3033 | pp_string (pp, "goto __BB"); |
| 3034 | pp_decimal_int (pp, e->dest->index); |
| 3035 | if (e->probability.initialized_p ()) |
| 3036 | { |
| 3037 | pp_string (pp, "("); |
| 3038 | pp_string (pp, |
| 3039 | profile_quality_as_string (e->probability.quality ())); |
| 3040 | pp_string (pp, "("); |
| 3041 | pp_decimal_int (pp, e->probability.value ()); |
| 3042 | pp_string (pp, "))"); |
| 3043 | } |
| 3044 | pp_semicolon (pp); |
| 3045 | } |
| 3046 | else |
| 3047 | { |
| 3048 | pp_string (pp, "goto <bb "); |
| 3049 | pp_decimal_int (pp, e->dest->index); |
| 3050 | pp_greater (pp); |
| 3051 | pp_semicolon (pp); |
| 3052 | |
| 3053 | dump_edge_probability (pp, e); |
| 3054 | } |
| 3055 | } |
| 3056 | |
| 3057 | |
| 3058 | /* Dump edges represented implicitly in basic block BB to PP, indented |
| 3059 | by INDENT spaces, with details given by FLAGS. */ |
| 3060 | |
| 3061 | static void |
| 3062 | dump_implicit_edges (pretty_printer *pp, basic_block bb, int indent, |
| 3063 | dump_flags_t flags) |
| 3064 | { |
| 3065 | edge e; |
| 3066 | |
| 3067 | if (safe_is_a <gcond *> (*gsi_last_bb (bb))) |
| 3068 | { |
| 3069 | edge true_edge, false_edge; |
| 3070 | |
| 3071 | /* When we are emitting the code or changing CFG, it is possible that |
| 3072 | the edges are not yet created. When we are using debug_bb in such |
| 3073 | a situation, we do not want it to crash. */ |
| 3074 | if (EDGE_COUNT (bb->succs) != 2) |
| 3075 | return; |
| 3076 | extract_true_false_edges_from_block (bb, &true_edge, &false_edge); |
| 3077 | |
| 3078 | INDENT (indent + 2); |
| 3079 | pp_cfg_jump (pp, true_edge, flags); |
| 3080 | newline_and_indent (pp, indent); |
| 3081 | pp_string (pp, "else"); |
| 3082 | newline_and_indent (pp, indent + 2); |
| 3083 | pp_cfg_jump (pp, false_edge, flags); |
| 3084 | pp_newline (pp); |
| 3085 | return; |
| 3086 | } |
| 3087 | |
| 3088 | /* If there is a fallthru edge, we may need to add an artificial |
| 3089 | goto to the dump. */ |
| 3090 | e = find_fallthru_edge (bb->succs); |
| 3091 | |
| 3092 | if (e && (e->dest != bb->next_bb || (flags & TDF_GIMPLE))) |
| 3093 | { |
| 3094 | INDENT (indent); |
| 3095 | |
| 3096 | if ((flags & TDF_LINENO) |
| 3097 | && e->goto_locus != UNKNOWN_LOCATION) |
| 3098 | dump_location (pp, e->goto_locus); |
| 3099 | |
| 3100 | pp_cfg_jump (pp, e, flags); |
| 3101 | pp_newline (pp); |
| 3102 | } |
| 3103 | } |
| 3104 | |
| 3105 | |
| 3106 | /* Dumps basic block BB to PP with details described by FLAGS and |
| 3107 | indented by INDENT spaces. */ |
| 3108 | |
| 3109 | static void |
| 3110 | gimple_dump_bb_buff (pretty_printer *pp, basic_block bb, int indent, |
| 3111 | dump_flags_t flags) |
| 3112 | { |
| 3113 | gimple_stmt_iterator gsi; |
| 3114 | gimple *stmt; |
| 3115 | int label_indent = indent - 2; |
| 3116 | |
| 3117 | if (label_indent < 0) |
| 3118 | label_indent = 0; |
| 3119 | |
| 3120 | dump_phi_nodes (pp, bb, indent, flags); |
| 3121 | |
| 3122 | for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) |
| 3123 | { |
| 3124 | int curr_indent; |
| 3125 | |
| 3126 | stmt = gsi_stmt (gsi); |
| 3127 | |
| 3128 | curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent; |
| 3129 | |
| 3130 | INDENT (curr_indent); |
| 3131 | pp_gimple_stmt_1 (pp, stmt, curr_indent, flags); |
| 3132 | pp_newline_and_flush (pp); |
| 3133 | gcc_checking_assert (DECL_STRUCT_FUNCTION (current_function_decl)); |
| 3134 | dump_histograms_for_stmt (DECL_STRUCT_FUNCTION (current_function_decl), |
| 3135 | pp_buffer (pp)->m_stream, stmt); |
| 3136 | } |
| 3137 | |
| 3138 | dump_implicit_edges (pp, bb, indent, flags); |
| 3139 | pp_flush (pp); |
| 3140 | } |
| 3141 | |
| 3142 | |
| 3143 | /* Dumps basic block BB to FILE with details described by FLAGS and |
| 3144 | indented by INDENT spaces. */ |
| 3145 | |
| 3146 | void |
| 3147 | gimple_dump_bb (FILE *file, basic_block bb, int indent, dump_flags_t flags) |
| 3148 | { |
| 3149 | dump_gimple_bb_header (file, bb, indent, flags); |
| 3150 | if (bb->index >= NUM_FIXED_BLOCKS) |
| 3151 | { |
| 3152 | pretty_printer pp; |
| 3153 | pp_needs_newline (&pp) = true; |
| 3154 | pp.set_output_stream (file); |
| 3155 | gimple_dump_bb_buff (&pp, bb, indent, flags); |
| 3156 | } |
| 3157 | dump_gimple_bb_footer (file, bb, indent, flags); |
| 3158 | } |
| 3159 | |
| 3160 | /* Dumps basic block BB to pretty-printer PP with default dump flags and |
| 3161 | no indentation, for use as a label of a DOT graph record-node. |
| 3162 | ??? Should just use gimple_dump_bb_buff here, except that value profiling |
| 3163 | histogram dumping doesn't know about pretty-printers. */ |
| 3164 | |
| 3165 | void |
| 3166 | gimple_dump_bb_for_graph (pretty_printer *pp, basic_block bb) |
| 3167 | { |
| 3168 | pp_printf (pp, "<bb %d>:\n", bb->index); |
| 3169 | pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true); |
| 3170 | |
| 3171 | for (gphi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi); |
| 3172 | gsi_next (&gsi)) |
| 3173 | { |
| 3174 | gphi *phi = gsi.phi (); |
| 3175 | if (!virtual_operand_p (gimple_phi_result (phi)) |
| 3176 | || (dump_flags & TDF_VOPS)) |
| 3177 | { |
| 3178 | pp_bar (pp); |
| 3179 | pp_write_text_to_stream (pp); |
| 3180 | pp_string (pp, "# "); |
| 3181 | pp_gimple_stmt_1 (pp, phi, 0, dump_flags); |
| 3182 | pp_newline (pp); |
| 3183 | pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true); |
| 3184 | } |
| 3185 | } |
| 3186 | |
| 3187 | for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi); |
| 3188 | gsi_next (&gsi)) |
| 3189 | { |
| 3190 | gimple *stmt = gsi_stmt (gsi); |
| 3191 | pp_bar (pp); |
| 3192 | pp_write_text_to_stream (pp); |
| 3193 | pp_gimple_stmt_1 (pp, stmt, 0, dump_flags); |
| 3194 | pp_newline (pp); |
| 3195 | pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true); |
| 3196 | } |
| 3197 | dump_implicit_edges (pp, bb, 0, dump_flags); |
| 3198 | pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true); |
| 3199 | } |
| 3200 | |
| 3201 | #if __GNUC__ >= 10 |
| 3202 | # pragma GCC diagnostic pop |
| 3203 | #endif |