gcc/gcc/print-rtl.c
Jeff Law 9870475ca0 c-lex.c: Include <stdlib.h> and <string.h>/<strings.h>.
/
	* c-lex.c: Include <stdlib.h> and <string.h>/<strings.h>.  Add
	prototype for `handle_sysv_pragma', and make it static.  Add
	parentheses around assignment used as truth value.
	* combine.c (combine_instructions): Protect variable `prev' with
	macro HAVE_cc0.
	(can_combine_p): Protect variable `link' with AUTO_INC_DEC.
	(extract_left_shift): Add parentheses around operand of &.
	(merge_outer_ops): Avoid an empty body in an else-statement.
	(gen_rtx_combine): Remove unused variable `i'.
	* sparc/gmon-sol2.c: Include <fcntl.h>.  Make return type of
        function monstartup `void'.  Likewise for internal_mcount.  Add
        `static void' prototype for moncontrol.  Reconcile sprintf format
        vs. args.
	* sparc/sparc.c: Include <stdlib.h> and <string.h>/<strings.h>.
	Make return type of function_arg_slotno explicitly `int'.
	(reg_unused_after): Add	parentheses around assignment used as
	truth value.
	(save_regs): Add explicit braces to avoid ambiguous `else'.
	(function_arg_slotno): Add parentheses around && within ||.
	(function_arg_pass_by_reference): Likewise.
	(sparc_flat_output_function_prologue): Reconcile fprintf format
	vs. args.
	* svr4.h (ASM_OUTPUT_LIMITED_STRING): Add parentheses around
	assignment used as truth value.
	* cplus-dem.c: Include <stdlib.h>.
	(demangle_signature): Avoid an empty body in an else-statement.
	(do_type): Remove unused variable `lvl'.
	* cppexp.c: Don't have <stdlib.h> depend on MULTIBYTE_CHARS.
	Include <string.h>/<strings.h>.
	(cpp_lex): Remove unused variable `namelen'.
	(cpp_lex): Explicitly declare `num_chars' as an int.
	* cpplib.c: Avoid duplicate inclusion of <stdlib.h>, include
	<unistd.h> instead.  Explicitly declare is_system_include
	returning int.
	(make_assertion): Remove unused variable `kt'.
	(cpp_expand_to_buffer): Hide variable `obuf'.
	(output_line_command): Remove unused variables, `line_end',
	`line_cmd_buf' and `len'.
	(macarg): Remove unused variable `arg_start'.
	(special_symbol): Remove unused variable `i'.  Add parentheses
	around assignment used as truth value.
	(do_include):  Remove unused variables `pcfname' and `retried',
	hide `pcf' and `pcfbuflimit'.
	(do_line): Remove unused variable `i'.
	(finclude): Hide variable `missing_newline'.
	(cpp_handle_options): Remove unused variable `j'.
	(read_token_list): Remove unused variable `eofp'.
	(cpp_error_with_line): Remove unused variable `i'.
	(cpp_warning_with_line): Likewise.
	(cpp_pedwarn_with_line): Explicitly declare `column' as int.
	(cpp_error_from_errno): Remove unused variable `i'.
	* cse.c (invalidate): Add parentheses around assignment used as
	truth value.
	(find_best_addr): Move declaration of variable `our_cost' inside
	the conditional macro where its used.
	(fold_rtx): Avoid an empty body in an if-statement.
	(cse_insn): Wrap variables  `this_insn_cc0_mode' and
	`this_insn_cc0' in macro HAVE_cc0.
	* dwarf2out.c: Include <stdlib.h> and <string.h>/<string.h>.
	(ASM_OUTPUT_DWARF_DATA8):  Reconcile format vs. args in fprintf's.
	(output_uleb128): Likewise.
	(output_sleb128): Likewise.
	(output_cfi): Likewise.
	(output_call_frame_info): Remove unused variables `j', `fde_size'
	and `fde_pad'.
	(comp_unit_has_inlines): Hide declaration as per rest of file.
	(size_of_line_prolog): Correct typo in prototype.
	(add_arange): Likewise.
	(output_aranges): Likewise.
	(add_name_and_src_coords_attributes): Likewise.
	(gen_array_type_die): Likewise.
	(gen_inlined_subroutine_die): Likewise.
	(equate_decl_number_to_die): Remove unused variable `i'.
	(print_die): Reconcile format vs. args in fprintf's.
	(print_dwarf_line_table): Likewise.
	(output_die): Likewise.
	(output_line_info): Likewise.
	(add_subscript_info): Avoid an empty body in an else-statement.
	(gen_subprogram_die): Remove unused variable `fp_loc'.
	* dwarfout.c: Explicitly declare `next_pubname_number' as int.
	Protect `ordering_attribute' prototype with USE_ORDERING_ATTRIBUTE
	macro.  Protect `src_coords_attribute' prototype with
	DWARF_DECL_COORDINATES macro.  Hide `output_entry_point_die'
	prototype as in the rest of the file.  Likewise for
	`output_pointer_type_die' and `output_reference_type_die'.  Remove
	prototype for `type_of_for_scope'.
	(output_unsigned_leb128): Reconcile format vs. args in fprintf.
	(type_attribute): Add explicit braces to avoid ambiguous `else'.
	* final.c: Include <stdlib.h> and <string.h>/<strings.h>.
	(shorten_branches): Protect declaration of tmp_length with
	SHORTEN_WITH_ADJUST_INSN_LENGTH and ADJUST_INSN_LENGTH macros.
	(profile_function): Protect declaration of `sval' and `cxt'
	variables with appropriate macros.
	(final_scan_insn): Likewise for `note' variable.  Add explicit
	braces to avoid empty body in an if-statement.
	(output_asm_insn): Move variable `i' inside macro conditional
	where it is used.  Add parentheses around assignment used as truth
	value.
	(asm_fprintf) Likewise, likewise.
	* fix-header.c (main): Remove unused variable `done'.  Protect
	declaration of `i' with FIXPROTO_IGNORE_LIST.
	* pexecute.c: Include <unistd.h>.  Prototype `my_strerror'.
	* print-rtl.c (print_inline_rtx): Explicitly declare the parameter
	`ind'.
	* profile.c: Include <string.h>/<strings.h>.
	(instrument_arcs): Remove unused variables `note', `inverted',
	`zero' and `neg_one'.
	(branch_prob): Avoid empty body in an if-statement.
	* regclass.c: Include <stdlib.h>.
	(reg_alternate_class): Explicitly declare parameter `regno'.
	* regmove.c (regmove_optimize): Remove unused variable `p'.  Add
	parentheses around assignment used as truth value.
	(find_matches):  Remove unused variables `output_operand' and
	`matching_operand'.
	(fixup_match_1): Remove statement with no effect: "if (0) ;".
	* scan.c (sstring_append): Explicitly declare `count' as int.
	(scan_string): Explicitly declare parameter `init' as int.
	* sched.c: Include <stdlib.h>.
	(BLOCKAGE_RANGE): Add parentheses around arithmetic in operand of |.
	(rank_for_schedule): Add parentheses around assignment used as
	truth value.
	(schedule_block): Likewise.
	(regno_use_in): Likewise.
	(schedule_insns): Remove unused variable `i'.
	* toplev.c: Include <stdlib.h> and <string.h>/<strings.h>.
	(v_message_with_decl): Remove unused variable `n'.
	(botch): Explicitly declare parameter `s' as char *.
	(main): Add parentheses around assignment used as truth value.
	* tree.c (make_node): Protect the variable `kind' with the
	GATHER_STATISTICS macro.
	(real_value_from_int_cst): Move variable `e' inside conditional
	macro area where it is used.
	(tree_last): Add parentheses around assignment used as truth value.
	(build1): Protect the variable `kind' with the GATHER_STATISTICS
	macro.
	(print_obstack_statistics): Reconcile format vs. args in fprintf.
	Protect variables `i', `total_nodes', and `total_bytes' with the
	GATHER_STATISTICS macro.
Lots more -W -Wall warnings disappear.

From-SVN: r17517
1998-01-27 15:11:54 -07:00

367 lines
8.1 KiB
C

/* Print RTL for GNU C Compiler.
Copyright (C) 1987, 1988, 1992, 1997 Free Software Foundation, Inc.
This file is part of GNU CC.
GNU CC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU CC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU CC; see the file COPYING. If not, write to
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include "config.h"
#include <ctype.h>
#include <stdio.h>
#include "rtl.h"
/* How to print out a register name.
We don't use PRINT_REG because some definitions of PRINT_REG
don't work here. */
#ifndef DEBUG_PRINT_REG
#define DEBUG_PRINT_REG(RTX, CODE, FILE) \
fprintf ((FILE), "%d %s", REGNO (RTX), reg_names[REGNO (RTX)])
#endif
/* Array containing all of the register names */
#ifdef DEBUG_REGISTER_NAMES
static char *reg_names[] = DEBUG_REGISTER_NAMES;
#else
static char *reg_names[] = REGISTER_NAMES;
#endif
static FILE *outfile;
char spaces[] = " ";
static int sawclose = 0;
static int indent;
/* Names for patterns. Non-zero only when linked with insn-output.c. */
extern char **insn_name_ptr;
/* Print IN_RTX onto OUTFILE. This is the recursive part of printing. */
static void
print_rtx (in_rtx)
register rtx in_rtx;
{
register int i, j;
register char *format_ptr;
register int is_insn;
if (sawclose)
{
fprintf (outfile, "\n%s",
(spaces + (sizeof spaces - 1 - indent * 2)));
sawclose = 0;
}
if (in_rtx == 0)
{
fprintf (outfile, "(nil)");
sawclose = 1;
return;
}
/* print name of expression code */
fprintf (outfile, "(%s", GET_RTX_NAME (GET_CODE (in_rtx)));
if (in_rtx->in_struct)
fprintf (outfile, "/s");
if (in_rtx->volatil)
fprintf (outfile, "/v");
if (in_rtx->unchanging)
fprintf (outfile, "/u");
if (in_rtx->integrated)
fprintf (outfile, "/i");
if (GET_MODE (in_rtx) != VOIDmode)
{
/* Print REG_NOTE names for EXPR_LIST and INSN_LIST. */
if (GET_CODE (in_rtx) == EXPR_LIST || GET_CODE (in_rtx) == INSN_LIST)
fprintf (outfile, ":%s", GET_REG_NOTE_NAME (GET_MODE (in_rtx)));
else
fprintf (outfile, ":%s", GET_MODE_NAME (GET_MODE (in_rtx)));
}
is_insn = (GET_RTX_CLASS (GET_CODE (in_rtx)) == 'i');
format_ptr = GET_RTX_FORMAT (GET_CODE (in_rtx));
for (i = 0; i < GET_RTX_LENGTH (GET_CODE (in_rtx)); i++)
switch (*format_ptr++)
{
case 'S':
case 's':
if (i == 3 && GET_CODE (in_rtx) == NOTE
&& (NOTE_LINE_NUMBER (in_rtx) == NOTE_INSN_EH_REGION_BEG
|| NOTE_LINE_NUMBER (in_rtx) == NOTE_INSN_EH_REGION_END))
{
fprintf (outfile, " %d", NOTE_BLOCK_NUMBER (in_rtx));
sawclose = 1;
break;
}
if (XSTR (in_rtx, i) == 0)
fprintf (outfile, " \"\"");
else
fprintf (outfile, " (\"%s\")", XSTR (in_rtx, i));
sawclose = 1;
break;
/* 0 indicates a field for internal use that should not be printed. */
case '0':
break;
case 'e':
indent += 2;
if (!sawclose)
fprintf (outfile, " ");
print_rtx (XEXP (in_rtx, i));
indent -= 2;
break;
case 'E':
case 'V':
indent += 2;
if (sawclose)
{
fprintf (outfile, "\n%s",
(spaces + (sizeof spaces - 1 - indent * 2)));
sawclose = 0;
}
fprintf (outfile, "[ ");
if (NULL != XVEC (in_rtx, i))
{
indent += 2;
if (XVECLEN (in_rtx, i))
sawclose = 1;
for (j = 0; j < XVECLEN (in_rtx, i); j++)
print_rtx (XVECEXP (in_rtx, i, j));
indent -= 2;
}
if (sawclose)
fprintf (outfile, "\n%s",
(spaces + (sizeof spaces - 1 - indent * 2)));
fprintf (outfile, "] ");
sawclose = 1;
indent -= 2;
break;
case 'w':
fprintf (outfile, " ");
fprintf (outfile, HOST_WIDE_INT_PRINT_DEC, XWINT (in_rtx, i));
break;
case 'i':
{
register int value = XINT (in_rtx, i);
if (GET_CODE (in_rtx) == REG && value < FIRST_PSEUDO_REGISTER)
{
fputc (' ', outfile);
DEBUG_PRINT_REG (in_rtx, 0, outfile);
}
else
fprintf (outfile, " %d", value);
}
if (is_insn && &INSN_CODE (in_rtx) == &XINT (in_rtx, i)
&& insn_name_ptr
&& XINT (in_rtx, i) >= 0)
fprintf (outfile, " {%s}", insn_name_ptr[XINT (in_rtx, i)]);
sawclose = 0;
break;
/* Print NOTE_INSN names rather than integer codes. */
case 'n':
if (XINT (in_rtx, i) <= 0)
fprintf (outfile, " %s", GET_NOTE_INSN_NAME (XINT (in_rtx, i)));
else
fprintf (outfile, " %d", XINT (in_rtx, i));
sawclose = 0;
break;
case 'u':
if (XEXP (in_rtx, i) != NULL)
fprintf (outfile, " %d", INSN_UID (XEXP (in_rtx, i)));
else
fprintf (outfile, " 0");
sawclose = 0;
break;
case '*':
fprintf (outfile, " Unknown");
sawclose = 0;
break;
default:
fprintf (stderr,
"switch format wrong in rtl.print_rtx(). format was: %c.\n",
format_ptr[-1]);
abort ();
}
fprintf (outfile, ")");
sawclose = 1;
}
/* Print an rtx on the current line of FILE. Initially indent IND
characters. */
void
print_inline_rtx (outf, x, ind)
FILE *outf;
rtx x;
int ind;
{
int oldsaw = sawclose;
int oldindent = indent;
sawclose = 0;
indent = ind;
outfile = outf;
print_rtx (x);
sawclose = oldsaw;
indent = oldindent;
}
/* Call this function from the debugger to see what X looks like. */
void
debug_rtx (x)
rtx x;
{
outfile = stderr;
print_rtx (x);
fprintf (stderr, "\n");
}
/* Count of rtx's to print with debug_rtx_list.
This global exists because gdb user defined commands have no arguments. */
int debug_rtx_count = 0; /* 0 is treated as equivalent to 1 */
/* Call this function to print list from X on.
N is a count of the rtx's to print. Positive values print from the specified
rtx on. Negative values print a window around the rtx.
EG: -5 prints 2 rtx's on either side (in addition to the specified rtx). */
void
debug_rtx_list (x, n)
rtx x;
int n;
{
int i,count;
rtx insn;
count = n == 0 ? 1 : n < 0 ? -n : n;
/* If we are printing a window, back up to the start. */
if (n < 0)
for (i = count / 2; i > 0; i--)
{
if (PREV_INSN (x) == 0)
break;
x = PREV_INSN (x);
}
for (i = count, insn = x; i > 0 && insn != 0; i--, insn = NEXT_INSN (insn))
debug_rtx (insn);
}
/* Call this function to search an rtx list to find one with insn uid UID,
and then call debug_rtx_list to print it, using DEBUG_RTX_COUNT.
The found insn is returned to enable further debugging analysis. */
rtx
debug_rtx_find (x, uid)
rtx x;
int uid;
{
while (x != 0 && INSN_UID (x) != uid)
x = NEXT_INSN (x);
if (x != 0)
{
debug_rtx_list (x, debug_rtx_count);
return x;
}
else
{
fprintf (stderr, "insn uid %d not found\n", uid);
return 0;
}
}
/* External entry point for printing a chain of insns
starting with RTX_FIRST onto file OUTF.
A blank line separates insns.
If RTX_FIRST is not an insn, then it alone is printed, with no newline. */
void
print_rtl (outf, rtx_first)
FILE *outf;
rtx rtx_first;
{
register rtx tmp_rtx;
outfile = outf;
sawclose = 0;
if (rtx_first == 0)
fprintf (outf, "(nil)\n");
else
switch (GET_CODE (rtx_first))
{
case INSN:
case JUMP_INSN:
case CALL_INSN:
case NOTE:
case CODE_LABEL:
case BARRIER:
for (tmp_rtx = rtx_first; NULL != tmp_rtx; tmp_rtx = NEXT_INSN (tmp_rtx))
{
print_rtx (tmp_rtx);
fprintf (outfile, "\n");
}
break;
default:
print_rtx (rtx_first);
}
}
/* Like print_rtx, except specify a file. */
void
print_rtl_single (outf, x)
FILE *outf;
rtx x;
{
outfile = outf;
sawclose = 0;
print_rtx (x);
putc ('\n', outf);
}