diff options
author | Sharad Singhai <singhai@google.com> | 2012-10-01 05:43:06 +0000 |
---|---|---|
committer | Sharad Singhai <singhai@gcc.gnu.org> | 2012-10-01 05:43:06 +0000 |
commit | 78c60e3da2d1a25ac13b725980e5f4dd53b9df60 (patch) | |
tree | 525ba5cb84f1f7d04874c56225d38fe09fea8455 /gcc/tree-dump.c | |
parent | d0cfc26205e59848a644a42790fcb3a76d82a287 (diff) | |
download | gcc-78c60e3da2d1a25ac13b725980e5f4dd53b9df60.zip gcc-78c60e3da2d1a25ac13b725980e5f4dd53b9df60.tar.gz gcc-78c60e3da2d1a25ac13b725980e5f4dd53b9df60.tar.bz2 |
invoke.texi: Add documentation for the new option.
2012-09-30 Sharad Singhai <singhai@google.com>
* doc/invoke.texi: Add documentation for the new option.
* tree-dump.c: Move general dump file related functionality into
dumpfile.c. Remove unneeded headers.
* tree-dump.h: Move function declarations into dumpfile.h.
* dumpfile.h: Include "line-map.h". Add defines for MSG flags.
(struct dump_file_info): Move here from tree-dump.c. Rename flags
to pflags, state to pstate, stream to pstream, filename to
pfilename. All callers updated. Add alt_flags, alt_state,
alt_filenmae, alt_stream.
* tree-vectorizer.c: Include "dumpfile.h". Remove vect_dump.
(vect_set_dump_settings): Remove.
(vect_print_dump_info): Ditto.
* tree-vectorizer.h: Remove declaration of vect_dump and
vect_print_dump_info.
* tree-vect-loop.c: Include "dumpfile.h". Use new dump style.
* tree-vect-data-refs.c: Ditto.
* tree-vect-stmts.c: Ditto.
* tree-vect-slp.c: Ditto.
* tree-vect-patterns.c: Ditto.
* tree-vect-loop-manip.c: Ditto.
* testsuite/gcc.target/i386/vect-double-1.c: Fix test.
* opts.c (vect_set_verbosity_level): Remove.
(common_handle_option): Handle -fopt-info flag. Deprecate
-ftree-vectorizer-verbose.
* tree-parloops.c (gather_scalar_reductions): Remove reference to
vect_dump.
* flag-types.h: Remove vect_verbosity_levels.
* common.opt: Add -fopt-info. Deprecate -ftree-vectorizer-verbose.
* opts-global.c (dump_remap_tree_vectorizer_verbose): New
function.
(handle_common_deferred_options): Handle -fopt-info and
-ftree-vectorizer-verbose.
* Makefile.in: Add dumpfile.o.
(tree-dump.o): Update dependencies.
(tree-vect-loop.o): Ditto.
(tree-vect-loop-manip.o): Ditto.
(tree-vect-slp.o): Ditto.
(tree-vect-stmts.o): Ditto.
(tree-vectorizer.o): Ditto.
(opts.o): Ditto.
* passes.c (finish_optimization_passes): Instead of using
dump_begin/dump_end, use dump_start/dump_finish. Do not use dump_file.
(pass_init_dump_file): Ditto.
* c-decl.c (c_write_global_declarations): Use a different method
to determine if the dump has ben initialized.
* decl2.c (cp_write_global_declarations): Use a different method
to determine if the dump has ben initialized.
From-SVN: r191883
Diffstat (limited to 'gcc/tree-dump.c')
-rw-r--r-- | gcc/tree-dump.c | 382 |
1 files changed, 16 insertions, 366 deletions
diff --git a/gcc/tree-dump.c b/gcc/tree-dump.c index 5a1fa3a..a1511ea 100644 --- a/gcc/tree-dump.c +++ b/gcc/tree-dump.c @@ -26,17 +26,10 @@ along with GCC; see the file COPYING3. If not see #include "tree.h" #include "splay-tree.h" #include "filenames.h" -#include "diagnostic-core.h" -#include "toplev.h" #include "tree-dump.h" #include "langhooks.h" #include "tree-iterator.h" -/* If non-NULL, return one past-the-end of the matching SUBPART of - the WHOLE string. */ -#define skip_leading_substring(whole, part) \ - (strncmp (whole, part, strlen (part)) ? NULL : whole + strlen (part)) - static unsigned int queue (dump_info_p, const_tree, int); static void dump_index (dump_info_p, unsigned int); static void dequeue_and_dump (dump_info_p); @@ -162,6 +155,22 @@ dump_maybe_newline (dump_info_p di) } } +/* Dump FUNCTION_DECL FN as tree dump PHASE. */ + +void +dump_function (int phase, tree fn) +{ + FILE *stream; + int flags; + + stream = dump_begin (phase, &flags); + if (stream) + { + dump_function_to_file (fn, stream, flags); + dump_end (phase, stream); + } +} + /* Dump pointer PTR using FIELD to identify it. */ void @@ -766,362 +775,3 @@ dump_node (const_tree t, int flags, FILE *stream) } splay_tree_delete (di.nodes); } - - -/* Table of tree dump switches. This must be consistent with the - tree_dump_index enumeration in tree-pass.h. */ -static struct dump_file_info dump_files[TDI_end] = -{ - {NULL, NULL, NULL, 0, 0, 0}, - {".cgraph", "ipa-cgraph", NULL, TDF_IPA, 0, 0}, - {".tu", "translation-unit", NULL, TDF_TREE, 0, 1}, - {".class", "class-hierarchy", NULL, TDF_TREE, 0, 2}, - {".original", "tree-original", NULL, TDF_TREE, 0, 3}, - {".gimple", "tree-gimple", NULL, TDF_TREE, 0, 4}, - {".nested", "tree-nested", NULL, TDF_TREE, 0, 5}, - {".vcg", "tree-vcg", NULL, TDF_TREE, 0, 6}, - {".ads", "ada-spec", NULL, 0, 0, 7}, -#define FIRST_AUTO_NUMBERED_DUMP 8 - - {NULL, "tree-all", NULL, TDF_TREE, 0, 0}, - {NULL, "rtl-all", NULL, TDF_RTL, 0, 0}, - {NULL, "ipa-all", NULL, TDF_IPA, 0, 0}, -}; - -/* Dynamically registered tree dump files and switches. */ -static struct dump_file_info *extra_dump_files; -static size_t extra_dump_files_in_use; -static size_t extra_dump_files_alloced; - -/* Define a name->number mapping for a dump flag value. */ -struct dump_option_value_info -{ - const char *const name; /* the name of the value */ - const int value; /* the value of the name */ -}; - -/* Table of dump options. This must be consistent with the TDF_* flags - in tree.h */ -static const struct dump_option_value_info dump_options[] = -{ - {"address", TDF_ADDRESS}, - {"asmname", TDF_ASMNAME}, - {"slim", TDF_SLIM}, - {"raw", TDF_RAW}, - {"graph", TDF_GRAPH}, - {"details", TDF_DETAILS}, - {"cselib", TDF_CSELIB}, - {"stats", TDF_STATS}, - {"blocks", TDF_BLOCKS}, - {"vops", TDF_VOPS}, - {"lineno", TDF_LINENO}, - {"uid", TDF_UID}, - {"stmtaddr", TDF_STMTADDR}, - {"memsyms", TDF_MEMSYMS}, - {"verbose", TDF_VERBOSE}, - {"eh", TDF_EH}, - {"alias", TDF_ALIAS}, - {"nouid", TDF_NOUID}, - {"enumerate_locals", TDF_ENUMERATE_LOCALS}, - {"scev", TDF_SCEV}, - {"all", ~(TDF_RAW | TDF_SLIM | TDF_LINENO | TDF_TREE | TDF_RTL | TDF_IPA - | TDF_STMTADDR | TDF_GRAPH | TDF_DIAGNOSTIC | TDF_VERBOSE - | TDF_RHS_ONLY | TDF_NOUID | TDF_ENUMERATE_LOCALS | TDF_SCEV)}, - {NULL, 0} -}; - -unsigned int -dump_register (const char *suffix, const char *swtch, const char *glob, - int flags) -{ - static int next_dump = FIRST_AUTO_NUMBERED_DUMP; - int num = next_dump++; - - size_t count = extra_dump_files_in_use++; - - if (count >= extra_dump_files_alloced) - { - if (extra_dump_files_alloced == 0) - extra_dump_files_alloced = 32; - else - extra_dump_files_alloced *= 2; - extra_dump_files = XRESIZEVEC (struct dump_file_info, - extra_dump_files, - extra_dump_files_alloced); - } - - memset (&extra_dump_files[count], 0, sizeof (struct dump_file_info)); - extra_dump_files[count].suffix = suffix; - extra_dump_files[count].swtch = swtch; - extra_dump_files[count].glob = glob; - extra_dump_files[count].flags = flags; - extra_dump_files[count].num = num; - - return count + TDI_end; -} - - -/* Return the dump_file_info for the given phase. */ - -struct dump_file_info * -get_dump_file_info (int phase) -{ - if (phase < TDI_end) - return &dump_files[phase]; - else if ((size_t) (phase - TDI_end) >= extra_dump_files_in_use) - return NULL; - else - return extra_dump_files + (phase - TDI_end); -} - - -/* Return the name of the dump file for the given phase. - If the dump is not enabled, returns NULL. */ - -char * -get_dump_file_name (int phase) -{ - char dump_id[10]; - struct dump_file_info *dfi; - - if (phase == TDI_none) - return NULL; - - dfi = get_dump_file_info (phase); - if (dfi->state == 0) - return NULL; - - if (dfi->num < 0) - dump_id[0] = '\0'; - else - { - char suffix; - if (dfi->flags & TDF_TREE) - suffix = 't'; - else if (dfi->flags & TDF_IPA) - suffix = 'i'; - else - suffix = 'r'; - - if (snprintf (dump_id, sizeof (dump_id), ".%03d%c", dfi->num, suffix) < 0) - dump_id[0] = '\0'; - } - - return concat (dump_base_name, dump_id, dfi->suffix, NULL); -} - -/* Begin a tree dump for PHASE. Stores any user supplied flag in - *FLAG_PTR and returns a stream to write to. If the dump is not - enabled, returns NULL. - Multiple calls will reopen and append to the dump file. */ - -FILE * -dump_begin (int phase, int *flag_ptr) -{ - char *name; - struct dump_file_info *dfi; - FILE *stream; - - if (phase == TDI_none || !dump_enabled_p (phase)) - return NULL; - - name = get_dump_file_name (phase); - dfi = get_dump_file_info (phase); - stream = fopen (name, dfi->state < 0 ? "w" : "a"); - if (!stream) - error ("could not open dump file %qs: %m", name); - else - dfi->state = 1; - free (name); - - if (flag_ptr) - *flag_ptr = dfi->flags; - - return stream; -} - -/* Returns nonzero if tree dump PHASE is enabled. If PHASE is - TDI_tree_all, return nonzero if any dump is enabled. */ - -int -dump_enabled_p (int phase) -{ - if (phase == TDI_tree_all) - { - size_t i; - for (i = TDI_none + 1; i < (size_t) TDI_end; i++) - if (dump_files[i].state) - return 1; - for (i = 0; i < extra_dump_files_in_use; i++) - if (extra_dump_files[i].state) - return 1; - return 0; - } - else - { - struct dump_file_info *dfi = get_dump_file_info (phase); - return dfi->state; - } -} - -/* Returns nonzero if tree dump PHASE has been initialized. */ - -int -dump_initialized_p (int phase) -{ - struct dump_file_info *dfi = get_dump_file_info (phase); - return dfi->state > 0; -} - -/* Returns the switch name of PHASE. */ - -const char * -dump_flag_name (int phase) -{ - struct dump_file_info *dfi = get_dump_file_info (phase); - return dfi->swtch; -} - -/* Finish a tree dump for PHASE. STREAM is the stream created by - dump_begin. */ - -void -dump_end (int phase ATTRIBUTE_UNUSED, FILE *stream) -{ - fclose (stream); -} - -/* Enable all tree dumps. Return number of enabled tree dumps. */ - -static int -dump_enable_all (int flags) -{ - int ir_dump_type = (flags & (TDF_TREE | TDF_RTL | TDF_IPA)); - int n = 0; - size_t i; - - for (i = TDI_none + 1; i < (size_t) TDI_end; i++) - if ((dump_files[i].flags & ir_dump_type)) - { - dump_files[i].state = -1; - dump_files[i].flags |= flags; - n++; - } - - for (i = 0; i < extra_dump_files_in_use; i++) - if ((extra_dump_files[i].flags & ir_dump_type)) - { - extra_dump_files[i].state = -1; - extra_dump_files[i].flags |= flags; - n++; - } - - return n; -} - -/* Parse ARG as a dump switch. Return nonzero if it is, and store the - relevant details in the dump_files array. */ - -static int -dump_switch_p_1 (const char *arg, struct dump_file_info *dfi, bool doglob) -{ - const char *option_value; - const char *ptr; - int flags; - - if (doglob && !dfi->glob) - return 0; - - option_value = skip_leading_substring (arg, doglob ? dfi->glob : dfi->swtch); - if (!option_value) - return 0; - - if (*option_value && *option_value != '-') - return 0; - - ptr = option_value; - flags = 0; - - while (*ptr) - { - const struct dump_option_value_info *option_ptr; - const char *end_ptr; - unsigned length; - - while (*ptr == '-') - ptr++; - end_ptr = strchr (ptr, '-'); - if (!end_ptr) - end_ptr = ptr + strlen (ptr); - length = end_ptr - ptr; - - for (option_ptr = dump_options; option_ptr->name; option_ptr++) - if (strlen (option_ptr->name) == length - && !memcmp (option_ptr->name, ptr, length)) - { - flags |= option_ptr->value; - goto found; - } - warning (0, "ignoring unknown option %q.*s in %<-fdump-%s%>", - length, ptr, dfi->swtch); - found:; - ptr = end_ptr; - } - - dfi->state = -1; - dfi->flags |= flags; - - /* Process -fdump-tree-all and -fdump-rtl-all, by enabling all the - known dumps. */ - if (dfi->suffix == NULL) - dump_enable_all (dfi->flags); - - return 1; -} - -int -dump_switch_p (const char *arg) -{ - size_t i; - int any = 0; - - for (i = TDI_none + 1; i != TDI_end; i++) - any |= dump_switch_p_1 (arg, &dump_files[i], false); - - /* Don't glob if we got a hit already */ - if (!any) - for (i = TDI_none + 1; i != TDI_end; i++) - any |= dump_switch_p_1 (arg, &dump_files[i], true); - - for (i = 0; i < extra_dump_files_in_use; i++) - any |= dump_switch_p_1 (arg, &extra_dump_files[i], false); - - if (!any) - for (i = 0; i < extra_dump_files_in_use; i++) - any |= dump_switch_p_1 (arg, &extra_dump_files[i], true); - - - return any; -} - -/* Dump FUNCTION_DECL FN as tree dump PHASE. */ - -void -dump_function (int phase, tree fn) -{ - FILE *stream; - int flags; - - stream = dump_begin (phase, &flags); - if (stream) - { - dump_function_to_file (fn, stream, flags); - dump_end (phase, stream); - } -} - -bool -enable_rtl_dump_file (void) -{ - return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS) > 0; -} |