Commit 4042dca9 by Gabriel Dos Reis Committed by Gabriel Dos Reis

sched-vis.c (rtl_slim_pp_initialized): Remove.

	* sched-vis.c (rtl_slim_pp_initialized): Remove.
	(rtl_slim_pp): Likewise.
	(init_rtl_slim_pretty_print): Likewise.
	(dump_value_slim):  Don't call it.  Use local pretty printer.
	(dump_insn_slim): Likewise.
	(dump_rtl_slim): Likewise.
	(str_pattern_slim): Likewise.
	* tree-mudflap.c (mf_varname_tree): Use local pretty printer.
	Simplify.

From-SVN: r201785
parent 5073d509
2013-08-16 Gabriel Dos Reis <gdr@integrable-solutions.net>
* sched-vis.c (rtl_slim_pp_initialized): Remove.
(rtl_slim_pp): Likewise.
(init_rtl_slim_pretty_print): Likewise.
(dump_value_slim): Don't call it. Use local pretty printer.
(dump_insn_slim): Likewise.
(dump_rtl_slim): Likewise.
(str_pattern_slim): Likewise.
* tree-mudflap.c (mf_varname_tree): Use local pretty printer.
Simplify.
2013-08-16 Jakub Jelinek <jakub@redhat.com> 2013-08-16 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/58164 PR tree-optimization/58164
......
...@@ -47,10 +47,6 @@ along with GCC; see the file COPYING3. If not see ...@@ -47,10 +47,6 @@ along with GCC; see the file COPYING3. If not see
It is also possible to obtain a string for a single pattern as a string It is also possible to obtain a string for a single pattern as a string
pointer, via str_pattern_slim, but this usage is discouraged. */ pointer, via str_pattern_slim, but this usage is discouraged. */
/* A pretty-printer for slim rtl printing. */
static bool rtl_slim_pp_initialized = false;
static pretty_printer rtl_slim_pp;
/* For insns we print patterns, and for some patterns we print insns... */ /* For insns we print patterns, and for some patterns we print insns... */
static void print_insn_with_notes (pretty_printer *, const_rtx); static void print_insn_with_notes (pretty_printer *, const_rtx);
...@@ -760,24 +756,6 @@ print_insn_with_notes (pretty_printer *pp, const_rtx x) ...@@ -760,24 +756,6 @@ print_insn_with_notes (pretty_printer *pp, const_rtx x)
} }
} }
/* Return a pretty-print buffer set up to print to file F. */
static pretty_printer *
init_rtl_slim_pretty_print (FILE *f)
{
if (! rtl_slim_pp_initialized)
{
pp_construct (&rtl_slim_pp, /*prefix=*/NULL, /*linewidth=*/0);
rtl_slim_pp_initialized = true;
}
else
/* Clean out any data that str_insn_slim may have left here. */
pp_clear_output_area (&rtl_slim_pp);
rtl_slim_pp.buffer->stream = f;
return &rtl_slim_pp;
}
/* Print X, an RTL value node, to file F in slim format. Include /* Print X, an RTL value node, to file F in slim format. Include
additional information if VERBOSE is nonzero. additional information if VERBOSE is nonzero.
...@@ -787,9 +765,11 @@ init_rtl_slim_pretty_print (FILE *f) ...@@ -787,9 +765,11 @@ init_rtl_slim_pretty_print (FILE *f)
void void
dump_value_slim (FILE *f, const_rtx x, int verbose) dump_value_slim (FILE *f, const_rtx x, int verbose)
{ {
pretty_printer *pp = init_rtl_slim_pretty_print (f); pretty_printer rtl_slim_pp;
print_value (pp, x, verbose); pp_construct (&rtl_slim_pp, /*prefix=*/NULL, /*linewidth=*/0);
pp_flush (pp); rtl_slim_pp.buffer->stream = f;
print_value (&rtl_slim_pp, x, verbose);
pp_flush (&rtl_slim_pp);
} }
/* Emit a slim dump of X (an insn) to the file F, including any register /* Emit a slim dump of X (an insn) to the file F, including any register
...@@ -797,9 +777,11 @@ dump_value_slim (FILE *f, const_rtx x, int verbose) ...@@ -797,9 +777,11 @@ dump_value_slim (FILE *f, const_rtx x, int verbose)
void void
dump_insn_slim (FILE *f, const_rtx x) dump_insn_slim (FILE *f, const_rtx x)
{ {
pretty_printer *pp = init_rtl_slim_pretty_print (f); pretty_printer rtl_slim_pp;
print_insn_with_notes (pp, x); pp_construct (&rtl_slim_pp, /*prefix=*/NULL, /*linewidth=*/0);
pp_flush (pp); rtl_slim_pp.buffer->stream = f;
print_insn_with_notes (&rtl_slim_pp, x);
pp_flush (&rtl_slim_pp);
} }
/* Same as above, but stop at LAST or when COUNT == 0. /* Same as above, but stop at LAST or when COUNT == 0.
...@@ -810,19 +792,21 @@ dump_rtl_slim (FILE *f, const_rtx first, const_rtx last, ...@@ -810,19 +792,21 @@ dump_rtl_slim (FILE *f, const_rtx first, const_rtx last,
int count, int flags ATTRIBUTE_UNUSED) int count, int flags ATTRIBUTE_UNUSED)
{ {
const_rtx insn, tail; const_rtx insn, tail;
pretty_printer *pp = init_rtl_slim_pretty_print (f); pretty_printer rtl_slim_pp;
pp_construct (&rtl_slim_pp, /*prefix=*/NULL, /*linewidth=*/0);
rtl_slim_pp.buffer->stream = f;
tail = last ? NEXT_INSN (last) : NULL_RTX; tail = last ? NEXT_INSN (last) : NULL_RTX;
for (insn = first; for (insn = first;
(insn != NULL) && (insn != tail) && (count != 0); (insn != NULL) && (insn != tail) && (count != 0);
insn = NEXT_INSN (insn)) insn = NEXT_INSN (insn))
{ {
print_insn_with_notes (pp, insn); print_insn_with_notes (&rtl_slim_pp, insn);
if (count > 0) if (count > 0)
count--; count--;
} }
pp_flush (pp); pp_flush (&rtl_slim_pp);
} }
/* Dumps basic block BB to pretty-printer PP in slim form and without and /* Dumps basic block BB to pretty-printer PP in slim form and without and
...@@ -857,9 +841,10 @@ rtl_dump_bb_for_graph (pretty_printer *pp, basic_block bb) ...@@ -857,9 +841,10 @@ rtl_dump_bb_for_graph (pretty_printer *pp, basic_block bb)
const char * const char *
str_pattern_slim (const_rtx x) str_pattern_slim (const_rtx x)
{ {
pretty_printer *pp = init_rtl_slim_pretty_print (NULL); pretty_printer rtl_slim_pp;
print_pattern (pp, x, 0); pp_construct (&rtl_slim_pp, /*prefix=*/NULL, /*linewidth=*/0);
return pp_formatted_text (pp); print_pattern (&rtl_slim_pp, x, 0);
return ggc_strdup (pp_formatted_text (&rtl_slim_pp));
} }
/* Emit a slim dump of X (an insn) to stderr. */ /* Emit a slim dump of X (an insn) to stderr. */
......
...@@ -106,20 +106,14 @@ mf_build_string (const char *string) ...@@ -106,20 +106,14 @@ mf_build_string (const char *string)
static tree static tree
mf_varname_tree (tree decl) mf_varname_tree (tree decl)
{ {
static pretty_printer buf_rec;
static int initialized = 0;
pretty_printer *buf = & buf_rec;
const char *buf_contents; const char *buf_contents;
tree result; tree result;
gcc_assert (decl); gcc_assert (decl);
if (!initialized) pretty_printer buf;
{ pp_construct (&buf, /* prefix */ NULL, /* line-width */ 0);
pp_construct (buf, /* prefix */ NULL, /* line-width */ 0); pp_clear_output_area (&buf);
initialized = 1;
}
pp_clear_output_area (buf);
/* Add FILENAME[:LINENUMBER[:COLUMNNUMBER]]. */ /* Add FILENAME[:LINENUMBER[:COLUMNNUMBER]]. */
{ {
...@@ -134,17 +128,17 @@ mf_varname_tree (tree decl) ...@@ -134,17 +128,17 @@ mf_varname_tree (tree decl)
if (sourcefile == NULL) if (sourcefile == NULL)
sourcefile = "<unknown file>"; sourcefile = "<unknown file>";
pp_string (buf, sourcefile); pp_string (&buf, sourcefile);
if (sourceline != 0) if (sourceline != 0)
{ {
pp_colon (buf); pp_colon (&buf);
pp_decimal_int (buf, sourceline); pp_decimal_int (&buf, sourceline);
if (sourcecolumn != 0) if (sourcecolumn != 0)
{ {
pp_colon (buf); pp_colon (&buf);
pp_decimal_int (buf, sourcecolumn); pp_decimal_int (&buf, sourcecolumn);
} }
} }
} }
...@@ -152,7 +146,7 @@ mf_varname_tree (tree decl) ...@@ -152,7 +146,7 @@ mf_varname_tree (tree decl)
if (current_function_decl != NULL_TREE) if (current_function_decl != NULL_TREE)
{ {
/* Add (FUNCTION) */ /* Add (FUNCTION) */
pp_string (buf, " ("); pp_string (&buf, " (");
{ {
const char *funcname = NULL; const char *funcname = NULL;
if (DECL_NAME (current_function_decl)) if (DECL_NAME (current_function_decl))
...@@ -160,12 +154,12 @@ mf_varname_tree (tree decl) ...@@ -160,12 +154,12 @@ mf_varname_tree (tree decl)
if (funcname == NULL) if (funcname == NULL)
funcname = "anonymous fn"; funcname = "anonymous fn";
pp_string (buf, funcname); pp_string (&buf, funcname);
} }
pp_string (buf, ") "); pp_string (&buf, ") ");
} }
else else
pp_space (buf); pp_space (&buf);
/* Add <variable-declaration>, possibly demangled. */ /* Add <variable-declaration>, possibly demangled. */
{ {
...@@ -186,13 +180,13 @@ mf_varname_tree (tree decl) ...@@ -186,13 +180,13 @@ mf_varname_tree (tree decl)
if (declname == NULL) if (declname == NULL)
declname = "<unnamed variable>"; declname = "<unnamed variable>";
pp_string (buf, declname); pp_string (&buf, declname);
} }
/* Return the lot as a new STRING_CST. */ /* Return the lot as a new STRING_CST. */
buf_contents = pp_formatted_text (buf); buf_contents = ggc_strdup (pp_formatted_text (&buf));
result = mf_build_string (buf_contents); result = mf_build_string (buf_contents);
pp_clear_output_area (buf); pp_clear_output_area (&buf);
return result; return result;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment