Commit 8264c84d by Martin Liska Committed by Martin Liska

Transform TDF_{lang,tree,ipa,rtl} to dump_kind enum.

2017-05-18  Martin Liska  <mliska@suse.cz>

	* cfgrtl.c (rtl_verify_edges): Remove usage of TDF_RTL.
	* dumpfile.c (dump_register): Use new enum dump_kind.
	(get_dump_file_name): Likewise.
	(dump_enable_all): Likewise.
	(dump_switch_p_1): Likewise.
	(enable_rtl_dump_file): Remove usage of TDF_RTL.
	* dumpfile.h (enum dump_kind): New enum type.
	(struct dump_file_info): Create constructor and
	format fields and comments.
	* passes.c (pass_manager::register_one_dump_file):
	Use num dump_kind.
	* statistics.c (statistics_early_init): Likewise.
	* tree-ssa-loop-prefetch.c (dump_mem_details): Replace
	TDF_TREE with TDF_SLIM.
	(gather_memory_references_ref): Likewise.

From-SVN: r248206
parent 671d5bcb
2017-05-18 Martin Liska <mliska@suse.cz>
* cfgrtl.c (rtl_verify_edges): Remove usage of TDF_RTL.
* dumpfile.c (dump_register): Use new enum dump_kind.
(get_dump_file_name): Likewise.
(dump_enable_all): Likewise.
(dump_switch_p_1): Likewise.
(enable_rtl_dump_file): Remove usage of TDF_RTL.
* dumpfile.h (enum dump_kind): New enum type.
(struct dump_file_info): Create constructor and
format fields and comments.
* passes.c (pass_manager::register_one_dump_file):
Use num dump_kind.
* statistics.c (statistics_early_init): Likewise.
* tree-ssa-loop-prefetch.c (dump_mem_details): Replace
TDF_TREE with TDF_SLIM.
(gather_memory_references_ref): Likewise.
2017-05-18 Martin Liska <mliska@suse.cz>
* vec.h (struct vnull): Use it.
2017-05-18 Jan Hubicka <hubicka@ucw.cz>
......
......@@ -2527,7 +2527,7 @@ rtl_verify_edges (void)
&& JUMP_P (BB_END (bb))
&& CROSSING_JUMP_P (BB_END (bb)))
{
print_rtl_with_bb (stderr, get_insns (), TDF_RTL | TDF_BLOCKS | TDF_DETAILS);
print_rtl_with_bb (stderr, get_insns (), TDF_BLOCKS | TDF_DETAILS);
error ("Region crossing jump across same section in bb %i",
bb->index);
err = 1;
......
......@@ -47,37 +47,43 @@ FILE *alt_dump_file = NULL;
const char *dump_file_name;
dump_flags_t dump_flags;
CONSTEXPR dump_file_info::dump_file_info (): suffix (NULL), swtch (NULL),
glob (NULL), pfilename (NULL), alt_filename (NULL), pstream (NULL),
alt_stream (NULL), dkind (DK_none), pflags (), alt_flags (0),
optgroup_flags (0), pstate (0), alt_state (0), num (0), owns_strings (false),
graph_dump_initialized (false)
{
}
dump_file_info::dump_file_info (const char *_suffix, const char *_swtch,
dump_kind _dkind, int _num):
suffix (_suffix), swtch (_swtch), glob (NULL),
pfilename (NULL), alt_filename (NULL), pstream (NULL), alt_stream (NULL),
dkind (_dkind), pflags (), alt_flags (0), optgroup_flags (0),
pstate (0), alt_state (0), num (_num), owns_strings (false),
graph_dump_initialized (false)
{
}
/* Table of tree dump switches. This must be consistent with the
TREE_DUMP_INDEX enumeration in dumpfile.h. */
static struct dump_file_info dump_files[TDI_end] =
{
{NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0, 0, false, false},
{".cgraph", "ipa-cgraph", NULL, NULL, NULL, NULL, NULL, TDF_IPA,
0, 0, 0, 0, 0, false, false},
{".type-inheritance", "ipa-type-inheritance", NULL, NULL, NULL, NULL, NULL, TDF_IPA,
0, 0, 0, 0, 0, false, false},
{".ipa-clones", "ipa-clones", NULL, NULL, NULL, NULL, NULL, TDF_IPA,
0, 0, 0, 0, 0, false, false},
{".tu", "translation-unit", NULL, NULL, NULL, NULL, NULL, TDF_LANG,
0, 0, 0, 0, 1, false, false},
{".class", "class-hierarchy", NULL, NULL, NULL, NULL, NULL, TDF_LANG,
0, 0, 0, 0, 2, false, false},
{".original", "tree-original", NULL, NULL, NULL, NULL, NULL, TDF_TREE,
0, 0, 0, 0, 3, false, false},
{".gimple", "tree-gimple", NULL, NULL, NULL, NULL, NULL, TDF_TREE,
0, 0, 0, 0, 4, false, false},
{".nested", "tree-nested", NULL, NULL, NULL, NULL, NULL, TDF_TREE,
0, 0, 0, 0, 5, false, false},
dump_file_info (),
dump_file_info (".cgraph", "ipa-cgraph", DK_ipa, 0),
dump_file_info (".type-inheritance", "ipa-type-inheritance", DK_ipa, 0),
dump_file_info (".ipa-clones", "ipa-clones", DK_ipa, 0),
dump_file_info (".tu", "translation-unit", DK_lang, 1),
dump_file_info (".class", "class-hierarchy", DK_lang, 2),
dump_file_info (".original", "tree-original", DK_tree, 3),
dump_file_info (".gimple", "tree-gimple", DK_tree, 4),
dump_file_info (".nested", "tree-nested", DK_tree, 5),
#define FIRST_AUTO_NUMBERED_DUMP 6
{NULL, "lang-all", NULL, NULL, NULL, NULL, NULL, TDF_LANG,
0, 0, 0, 0, 0, false, false},
{NULL, "tree-all", NULL, NULL, NULL, NULL, NULL, TDF_TREE,
0, 0, 0, 0, 0, false, false},
{NULL, "rtl-all", NULL, NULL, NULL, NULL, NULL, TDF_RTL,
0, 0, 0, 0, 0, false, false},
{NULL, "ipa-all", NULL, NULL, NULL, NULL, NULL, TDF_IPA,
0, 0, 0, 0, 0, false, false},
dump_file_info (NULL, "lang-all", DK_lang, 0),
dump_file_info (NULL, "tree-all", DK_tree, 0),
dump_file_info (NULL, "rtl-all", DK_rtl, 0),
dump_file_info (NULL, "ipa-all", DK_ipa, 0),
};
/* Define a name->number mapping for a dump flag value. */
......@@ -118,7 +124,7 @@ static const struct dump_option_value_info dump_options[] =
{"missed", MSG_MISSED_OPTIMIZATION},
{"note", MSG_NOTE},
{"optall", MSG_ALL},
{"all", ~(TDF_KIND_MASK | TDF_RAW | TDF_SLIM | TDF_LINENO
{"all", ~(TDF_RAW | TDF_SLIM | TDF_LINENO
| TDF_STMTADDR | TDF_GRAPH | TDF_DIAGNOSTIC | TDF_VERBOSE
| TDF_RHS_ONLY | TDF_NOUID | TDF_ENUMERATE_LOCALS | TDF_SCEV
| TDF_GIMPLE)},
......@@ -181,8 +187,7 @@ gcc::dump_manager::~dump_manager ()
unsigned int
gcc::dump_manager::
dump_register (const char *suffix, const char *swtch, const char *glob,
dump_flags_t flags, int optgroup_flags,
bool take_ownership)
dump_kind dkind, int optgroup_flags, bool take_ownership)
{
int num = m_next_dump++;
......@@ -203,7 +208,7 @@ dump_register (const char *suffix, const char *swtch, const char *glob,
m_extra_dump_files[count].suffix = suffix;
m_extra_dump_files[count].swtch = swtch;
m_extra_dump_files[count].glob = glob;
m_extra_dump_files[count].pflags = flags;
m_extra_dump_files[count].dkind = dkind;
m_extra_dump_files[count].optgroup_flags = optgroup_flags;
m_extra_dump_files[count].num = num;
m_extra_dump_files[count].owns_strings = take_ownership;
......@@ -285,11 +290,10 @@ get_dump_file_name (struct dump_file_info *dfi) const
dump_id[0] = '\0';
else
{
/* LANG, TREE, RTL, IPA. */
char suffix = "ltri"[TDF_KIND (dfi->pflags)];
/* (null), LANG, TREE, RTL, IPA. */
char suffix = " ltri"[dfi->dkind];
if (snprintf (dump_id, sizeof (dump_id), ".%03d%c", dfi->num, suffix)
< 0)
if (snprintf (dump_id, sizeof (dump_id), ".%03d%c", dfi->num, suffix) < 0)
dump_id[0] = '\0';
}
......@@ -494,7 +498,7 @@ dump_start (int phase, dump_flags_t *flag_ptr)
dfi->pstream = stream;
dump_file = dfi->pstream;
/* Initialize current dump flags. */
pflags = TDF_FLAGS (dfi->pflags);
pflags = dfi->pflags;
}
stream = dump_open_alternate_stream (dfi);
......@@ -504,7 +508,7 @@ dump_start (int phase, dump_flags_t *flag_ptr)
count++;
alt_dump_file = dfi->alt_stream;
/* Initialize current -fopt-info flags. */
alt_flags = TDF_FLAGS (dfi->alt_flags);
alt_flags = dfi->alt_flags;
}
if (flag_ptr)
......@@ -657,15 +661,14 @@ dump_end (int phase ATTRIBUTE_UNUSED, FILE *stream)
int
gcc::dump_manager::
dump_enable_all (dump_flags_t flags, const char *filename)
dump_enable_all (dump_kind dkind, dump_flags_t flags, const char *filename)
{
dump_flags_t ir_dump_type = TDF_KIND (flags);
int n = 0;
size_t i;
for (i = TDI_none + 1; i < (size_t) TDI_end; i++)
{
if (TDF_KIND (dump_files[i].pflags) == ir_dump_type)
if ((dump_files[i].dkind == dkind))
{
const char *old_filename = dump_files[i].pfilename;
dump_files[i].pstate = -1;
......@@ -686,7 +689,7 @@ dump_enable_all (dump_flags_t flags, const char *filename)
for (i = 0; i < m_extra_dump_files_in_use; i++)
{
if (TDF_KIND (m_extra_dump_files[i].pflags) == ir_dump_type)
if ((m_extra_dump_files[i].dkind == dkind))
{
const char *old_filename = m_extra_dump_files[i].pfilename;
m_extra_dump_files[i].pstate = -1;
......@@ -832,7 +835,7 @@ dump_switch_p_1 (const char *arg, struct dump_file_info *dfi, bool doglob)
/* Process -fdump-tree-all and -fdump-rtl-all, by enabling all the
known dumps. */
if (dfi->suffix == NULL)
dump_enable_all (dfi->pflags, dfi->pfilename);
dump_enable_all (dfi->dkind, dfi->pflags, dfi->pfilename);
return 1;
}
......@@ -1017,6 +1020,7 @@ enable_rtl_dump_file (void)
{
gcc::dump_manager *dumps = g->get_dumps ();
int num_enabled =
dumps->dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS, NULL);
dumps->dump_enable_all (DK_rtl, dump_flags_t (TDF_DETAILS) | TDF_BLOCKS,
NULL);
return num_enabled > 0;
}
......@@ -44,20 +44,22 @@ enum tree_dump_index
TDI_end
};
/* Enum used to distinguish dump files to types. */
enum dump_kind
{
DK_none,
DK_lang,
DK_tree,
DK_rtl,
DK_ipa,
};
/* Bit masks to control dumping. Not all values are applicable to all
dumps. Add new ones at the end. When you define new values, extend
the DUMP_OPTIONS array in dumpfile.c. The TDF_* flags coexist with
MSG_* flags (for -fopt-info) and the bit values must be chosen to
allow that. */
#define TDF_LANG 0 /* is a lang-specific dump. */
#define TDF_TREE 1 /* is a tree dump */
#define TDF_RTL 2 /* is a RTL dump */
#define TDF_IPA 3 /* is an IPA dump */
#define TDF_KIND_MASK 3
#define TDF_KIND(X) ((X) & TDF_KIND_MASK)
#define TDF_FLAGS(X) ((X) & ~TDF_KIND_MASK)
/* Bit 2 unused, available for hire. */
#define TDF_ADDRESS (1 << 3) /* dump node addresses */
#define TDF_SLIM (1 << 4) /* don't go wild following links */
#define TDF_RAW (1 << 5) /* don't unparse the function */
......@@ -124,27 +126,47 @@ typedef uint64_t dump_flags_t;
/* Define a tree dump switch. */
struct dump_file_info
{
const char *suffix; /* suffix to give output file. */
const char *swtch; /* command line dump switch */
const char *glob; /* command line glob */
const char *pfilename; /* filename for the pass-specific stream */
const char *alt_filename; /* filename for the -fopt-info stream */
FILE *pstream; /* pass-specific dump stream */
FILE *alt_stream; /* -fopt-info stream */
dump_flags_t pflags; /* dump flags */
int optgroup_flags; /* optgroup flags for -fopt-info */
int alt_flags; /* flags for opt-info */
int pstate; /* state of pass-specific stream */
int alt_state; /* state of the -fopt-info stream */
int num; /* dump file number */
bool owns_strings; /* fields "suffix", "swtch", "glob" can be
const strings, or can be dynamically
allocated, needing free. */
bool graph_dump_initialized; /* When a given dump file is being
initialized, this flag is set to
true if the corresponding TDF_graph
dump file has also been
initialized. */
/* Constructor. */
CONSTEXPR dump_file_info ();
/* Constructor. */
dump_file_info (const char *_suffix, const char *_swtch, dump_kind _dkind,
int _num);
/* Suffix to give output file. */
const char *suffix;
/* Command line dump switch. */
const char *swtch;
/* Command line glob. */
const char *glob;
/* Filename for the pass-specific stream. */
const char *pfilename;
/* Filename for the -fopt-info stream. */
const char *alt_filename;
/* Pass-specific dump stream. */
FILE *pstream;
/* -fopt-info stream. */
FILE *alt_stream;
/* Dump kind. */
dump_kind dkind;
/* Dump flags. */
dump_flags_t pflags;
/* A pass flags for -fopt-info. */
int alt_flags;
/* Flags for -fopt-info given by a user. */
int optgroup_flags;
/* State of pass-specific stream. */
int pstate;
/* State of the -fopt-info stream. */
int alt_state;
/* Dump file number. */
int num;
/* Fields "suffix", "swtch", "glob" can be const strings,
or can be dynamically allocated, needing free. */
bool owns_strings;
/* When a given dump file is being initialized, this flag is set to true
if the corresponding TDF_graph dump file has also been initialized. */
bool graph_dump_initialized;
};
/* In dumpfile.c */
......@@ -201,8 +223,7 @@ public:
SUFFIX, SWTCH, and GLOB. */
unsigned int
dump_register (const char *suffix, const char *swtch, const char *glob,
dump_flags_t flags, int optgroup_flags,
bool take_ownership);
dump_kind dkind, int optgroup_flags, bool take_ownership);
/* Return the dump_file_info for the given phase. */
struct dump_file_info *
......@@ -255,7 +276,7 @@ private:
dump_switch_p_1 (const char *arg, struct dump_file_info *dfi, bool doglob);
int
dump_enable_all (dump_flags_t flags, const char *filename);
dump_enable_all (dump_kind dkind, dump_flags_t flags, const char *filename);
int
opt_info_enable_passes (int optgroup_flags, dump_flags_t flags,
......
......@@ -191,7 +191,7 @@ static rtx get_expansion (struct var_to_expand *);
static void
report_unroll (struct loop *loop, location_t locus)
{
dump_flags_t report_flags = MSG_OPTIMIZED_LOCATIONS | TDF_RTL | TDF_DETAILS;
dump_flags_t report_flags = MSG_OPTIMIZED_LOCATIONS | TDF_DETAILS;
if (loop->lpt_decision.decision == LPT_NONE)
return;
......@@ -223,7 +223,7 @@ decide_unrolling (int flags)
location_t locus = get_loop_location (loop);
if (dump_enabled_p ())
dump_printf_loc (TDF_RTL, locus,
dump_printf_loc (MSG_NOTE, locus,
";; *** Considering loop %d at BB %d for "
"unrolling ***\n",
loop->num, loop->header->index);
......
......@@ -776,7 +776,7 @@ pass_manager::register_one_dump_file (opt_pass *pass)
/* Buffer big enough to format a 32-bit UINT_MAX into. */
char num[11];
dump_flags_t flags;
dump_kind dkind;
int id;
int optgroup_flags = OPTGROUP_NONE;
gcc::dump_manager *dumps = m_ctxt->get_dumps ();
......@@ -798,18 +798,18 @@ pass_manager::register_one_dump_file (opt_pass *pass)
if (pass->type == SIMPLE_IPA_PASS || pass->type == IPA_PASS)
{
prefix = "ipa-";
flags = TDF_IPA;
dkind = DK_ipa;
optgroup_flags |= OPTGROUP_IPA;
}
else if (pass->type == GIMPLE_PASS)
{
prefix = "tree-";
flags = TDF_TREE;
dkind = DK_tree;
}
else
{
prefix = "rtl-";
flags = TDF_RTL;
dkind = DK_rtl;
}
flag_name = concat (prefix, name, num, NULL);
......@@ -820,7 +820,7 @@ pass_manager::register_one_dump_file (opt_pass *pass)
any dump messages are emitted properly under -fopt-info(-optall). */
if (optgroup_flags == OPTGROUP_NONE)
optgroup_flags = OPTGROUP_OTHER;
id = dumps->dump_register (dot_name, flag_name, glob_name, flags,
id = dumps->dump_register (dot_name, flag_name, glob_name, dkind,
optgroup_flags,
true);
set_pass_for_id (id, pass);
......
......@@ -259,7 +259,7 @@ statistics_early_init (void)
{
gcc::dump_manager *dumps = g->get_dumps ();
statistics_dump_nr = dumps->dump_register (".statistics", "statistics",
"statistics", TDF_TREE,
"statistics", DK_tree,
OPTGROUP_NONE,
false);
}
......
......@@ -686,7 +686,7 @@ try_unroll_loop_completely (struct loop *loop,
struct loop_size size;
bool n_unroll_found = false;
edge edge_to_cancel = NULL;
dump_flags_t report_flags = MSG_OPTIMIZED_LOCATIONS | TDF_RTL | TDF_DETAILS;
dump_flags_t report_flags = MSG_OPTIMIZED_LOCATIONS | TDF_DETAILS;
/* See if we proved number of iterations to be low constant.
......
......@@ -288,7 +288,7 @@ dump_mem_details (FILE *file, tree base, tree step,
if (cst_and_fits_in_hwi (step))
fprintf (file, HOST_WIDE_INT_PRINT_DEC, int_cst_value (step));
else
print_generic_expr (file, step, TDF_TREE);
print_generic_expr (file, step, TDF_SLIM);
fprintf (file, ")\n");
fprintf (file, " delta ");
fprintf (file, HOST_WIDE_INT_PRINT_DEC, delta);
......@@ -553,8 +553,8 @@ gather_memory_references_ref (struct loop *loop, struct mem_ref_group **refs,
if (dump_file && (dump_flags & TDF_DETAILS))
{
fprintf (dump_file, "Memory expression %p\n",(void *) ref );
print_generic_expr (dump_file, ref, TDF_TREE);
fprintf (dump_file,":");
print_generic_expr (dump_file, ref, TDF_SLIM);
fprintf (dump_file,":");
dump_mem_details (dump_file, base, step, delta, write_p);
fprintf (dump_file,
"Ignoring %p, non-constant step prefetching is "
......@@ -570,7 +570,7 @@ gather_memory_references_ref (struct loop *loop, struct mem_ref_group **refs,
if (dump_file && (dump_flags & TDF_DETAILS))
{
fprintf (dump_file, "Memory expression %p\n",(void *) ref );
print_generic_expr (dump_file, ref, TDF_TREE);
print_generic_expr (dump_file, ref, TDF_SLIM);
fprintf (dump_file,":");
dump_mem_details (dump_file, base, step, delta, write_p);
fprintf (dump_file,
......
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