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