This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[ast-optimizer-branch] dump flag switches
- To: gcc-patches at gcc dot gnu dot org, Diego Novillo <dnovillo at redhat dot com>
- Subject: [ast-optimizer-branch] dump flag switches
- From: Nathan Sidwell <nathan at codesourcery dot com>
- Date: Tue, 04 Sep 2001 12:55:46 +0100
- Organization: Codesourcery LLC
I've installed this patch on the ast-optimizer-branch. [a similar
patch went onto the mainline too.]
It names the dumpflags consistently as -fdump-tree-foo
and names any options to the flags symbolically.
Diego, I've named your ssa flag 'refs' and given it the #define
TDF_REFS. I've not gone through your ssa stuff to see where you've
used it, so you'll need to do that. The value of TDF_REFS remains
unchanged as 1.
nathan
--
Dr Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
2001-09-04 Nathan Sidwell <nathan@codesourcery.com>
* c-common.h (tree_dump_index): Add more comments.
(TDF_REFS): New dump flag.
* c-dump.c (dump_files): Name flags `tree' rather than `ast'.
(dump_option_value_info): New struct.
(dump_options): New array.
(dump_switch_p): Parse switch options symbolically.
* doc/invoke.texi (-fdump-ast): Rename to ...
(-fdump-tree): ... here. Document options are symbolic, and
not all are applicable. Combine ssa related flags into the other
tree dump flags.
Index: c-common.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-common.h,v
retrieving revision 1.79.2.1
diff -c -3 -p -r1.79.2.1 c-common.h
*** c-common.h 2001/08/20 15:23:51 1.79.2.1
--- c-common.h 2001/09/04 11:04:46
*************** extern int c_safe_from_p
*** 838,846 ****
extern int c_unsafe_for_reeval PARAMS ((tree));
! /* In dump.c */
! /* Different tree dump places. */
enum tree_dump_index
{
TDI_all, /* dump the whole translation unit */
--- 838,847 ----
extern int c_unsafe_for_reeval PARAMS ((tree));
! /* In c-dump.c */
! /* Different tree dump places. When you add new tree dump places,
! extend the DUMP_FILES array in c-dump.c */
enum tree_dump_index
{
TDI_all, /* dump the whole translation unit */
*************** enum tree_dump_index
*** 856,864 ****
TDI_end
};
! /* Bit masks to control tree dumping. */
#define TDF_ADDRESS (1 << 0) /* dump node addresses */
#define TDF_SLIM (1 << 1) /* don't go wild following links */
typedef struct dump_info *dump_info_p;
--- 857,868 ----
TDI_end
};
! /* Bit masks to control tree dumping. Not all values are applicable to
! all tree dumps. Add new ones at the end. When you define new
! values, extend the DUMP_OPTIONS array in c-dump.c */
#define TDF_ADDRESS (1 << 0) /* dump node addresses */
#define TDF_SLIM (1 << 1) /* don't go wild following links */
+ #define TDF_REFS (1 << 0) /* dump ssa variable refs */
typedef struct dump_info *dump_info_p;
Index: c-dump.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-dump.c,v
retrieving revision 1.5.2.1
diff -c -3 -p -r1.5.2.1 c-dump.c
*** c-dump.c 2001/08/20 15:23:52 1.5.2.1
--- c-dump.c 2001/09/04 11:04:46
*************** struct dump_file_info
*** 795,813 ****
int state; /* state of play */
};
! /* Table of tree dump switches. */
static struct dump_file_info dump_files[TDI_end] =
{
{".tu", "dump-translation-unit", 0, 0},
{".class", "dump-class-hierarchy", 0, 0},
! {".original", "dump-ast-original", 0, 0},
! {".optimized", "dump-ast-optimized", 0, 0},
! {".inlined", "dump-ast-inlined", 0, 0},
! {".cfg", "dump-ast-cfg", 0, 0},
! {".dot", "dump-ast-graphviz", 0, 0},
! {".ssa", "dump-ast-ssa", 0, 0},
};
/* 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.
--- 795,832 ----
int state; /* state of play */
};
! /* Table of tree dump switches. This must be consistent with the
! TREE_DUMP_INDEX enumeration in c-common.h */
static struct dump_file_info dump_files[TDI_end] =
{
{".tu", "dump-translation-unit", 0, 0},
{".class", "dump-class-hierarchy", 0, 0},
! {".original", "dump-tree-original", 0, 0},
! {".optimized", "dump-tree-optimized", 0, 0},
! {".inlined", "dump-tree-inlined", 0, 0},
! {".cfg", "dump-tree-cfg", 0, 0},
! {".dot", "dump-tree-graphviz", 0, 0},
! {".ssa", "dump-tree-ssa", 0, 0},
};
+ /* Define a name->number mapping for a dump flag value. */
+ struct dump_option_value_info
+ {
+ const char *name; /* the name of the value */
+ int value; /* the value of the name */
+ };
+
+ /* Table of dump options. This must be consistent with the TDF_* flags
+ in c-common.h */
+ static const struct dump_option_value_info dump_options[] =
+ {
+ {"address", TDF_ADDRESS},
+ {"slim", TDF_SLIM},
+ {"refs", TDF_REFS},
+ {"all", ~0},
+ {NULL, 0}
+ };
+
/* 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.
*************** dump_switch_p (arg)
*** 879,891 ****
for (ix = 0; ix != TDI_end; ix++)
if ((option_value = skip_leading_substring (arg, dump_files[ix].swtch)))
{
dump_files[ix].state = -1;
! if (*option_value == '-')
! dump_files[ix].flags
! = read_integral_parameter (option_value + 1, arg, 0);
! else if (*option_value)
! warning ("ignoring `%s' at end of `-f%s'",
! option_value, dump_files[ix].swtch);
return 1;
}
--- 898,935 ----
for (ix = 0; ix != TDI_end; ix++)
if ((option_value = skip_leading_substring (arg, dump_files[ix].swtch)))
{
+ const char *ptr = option_value;
+ int 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 ("ignoring unknown option `%.*s' in `-f%s'",
+ length, ptr, dump_files[ix].swtch);
+ found:;
+ ptr = end_ptr;
+ }
+
dump_files[ix].state = -1;
! dump_files[ix].flags = flags;
return 1;
}
Index: doc/invoke.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/invoke.texi,v
retrieving revision 1.39.4.3
diff -c -3 -p -r1.39.4.3 invoke.texi
*** invoke.texi 2001/08/20 15:23:55 1.39.4.3
--- invoke.texi 2001/09/04 11:04:49
*************** in the following sections.
*** 239,246 ****
-a -ax -d@var{letters} -dumpspecs -dumpmachine -dumpversion @gol
-fdump-unnumbered -fdump-translation-unit@r{[}-@var{n}@r{]} @gol
-fdump-class-hierarchy@r{[}-@var{n}@r{]} @gol
! -fdump-ast-original@r{[}-@var{n}@r{]} -fdump-ast-optimized@r{[}-@var{n}@r{]} @gol
! -fdump-ast-inlined@r{[}-@var{n}@r{]} @gol
-fdump-tree-cfg -fdump-tree-graphviz -fdump-tree-ssa@r{[}-@var{n}@r{]} @gol
-fmem-report -fpretend-float @gol
-fprofile-arcs -ftest-coverage -ftime-report @gol
--- 239,246 ----
-a -ax -d@var{letters} -dumpspecs -dumpmachine -dumpversion @gol
-fdump-unnumbered -fdump-translation-unit@r{[}-@var{n}@r{]} @gol
-fdump-class-hierarchy@r{[}-@var{n}@r{]} @gol
! -fdump-tree-original@r{[}-@var{n}@r{]} -fdump-tree-optimized@r{[}-@var{n}@r{]} @gol
! -fdump-tree-inlined@r{[}-@var{n}@r{]} @gol
-fdump-tree-cfg -fdump-tree-graphviz -fdump-tree-ssa@r{[}-@var{n}@r{]} @gol
-fmem-report -fpretend-float @gol
-fprofile-arcs -ftest-coverage -ftime-report @gol
*************** use diff on debugging dumps for compiler
*** 2994,3067 ****
options, in particular with and without @option{-g}.
@item -fdump-translation-unit @r{(C and C++ only)}
! @itemx -fdump-translation-unit-@var{number} @r{(C and C++ only)}
@opindex fdump-translation-unit
Dump a representation of the tree structure for the entire translation
unit to a file. The file name is made by appending @file{.tu} to the
! source file name. If the @samp{-@var{number}} form is used, @var{number}
! controls the details of the dump as described for the @option{-fdump-ast} options.
@item -fdump-class-hierarchy @r{(C++ only)}
! @itemx -fdump-class-hierarchy-@var{number} @r{(C++ only)}
@opindex fdump-class-hierarchy
Dump a representation of each class's hierarchy and virtual function
table layout to a file. The file name is made by appending @file{.class}
! to the source file name. If the @samp{-@var{number}} form is used, @var{number}
! controls the details of the dump as described for the @option{-fdump-ast}
! options.
!
! @item -fdump-ast-@var{switch} @r{(C++ only)}
! @itemx -fdump-ast-@var{switch}-@var{number} @r{(C++ only)}
! @opindex fdump-ast
! Control the dumping at various stages of processing the abstract syntax
! tree to a file. The file name is generated by appending a switch
! specific suffix to the source file name. If the @samp{-@var{number}} form is
! used, @var{number} is a bit mask which controls the details of the
! dump. The following bits are meaningful (these are not set symbolically,
! as the primary function of these dumps is for debugging gcc itself):
@table @samp
! @item bit0 (1)
Print the address of each node. Usually this is not meaningful as it
! changes according to the environment and source file.
! @item bit1 (2)
! Inhibit dumping of members of a scope or body of a function, unless they
! are reachable by some other path.
@end table
The following tree dumps are possible:
@table @samp
@item original
Dump before any tree based optimization, to @file{@var{file}.original}.
@item optimized
Dump after all tree based optimization, to @file{@var{file}.optimized}.
@item inlined
Dump after inlining within the body of the function, to
@file{@var{file}.inlined}.
- @end table
! @item -fdump-tree-cfg
@opindex fdump-tree-cfg
Dump the control flow graph of each function to a file. The file name is
made by appending @file{.cfg} to the source file name.
! @item -fdump-tree-graphviz
@opindex fdump-tree-graphviz
Dump a representation of the control flow graph, suitable for viewing with
GraphViz, to a file. The file name is made by appending @file{.dot} to the
source file name.
! @item -fdump-tree-ssa
! @itemx -fdump-tree-ssa-@var{number}
@opindex fdump-tree-ssa
Dump SSA related information to a file. The file name is made by appending
! @file{.ssa} to the source file name. If the @samp{-@var{number}} form is
! used, @var{number} is a bit mask which controls the details of the dump.
! The following bits are meaningful:
- @table @samp
- @item bit0 (1)
- Print the list of references made to each variable in the program.
@end table
@item -fpretend-float
--- 2994,3071 ----
options, in particular with and without @option{-g}.
@item -fdump-translation-unit @r{(C and C++ only)}
! @itemx -fdump-translation-unit-@var{options} @r{(C and C++ only)}
@opindex fdump-translation-unit
Dump a representation of the tree structure for the entire translation
unit to a file. The file name is made by appending @file{.tu} to the
! source file name. If the @samp{-@var{options}} form is used, @var{options}
! controls the details of the dump as described for the
! @option{-fdump-tree} options.
@item -fdump-class-hierarchy @r{(C++ only)}
! @itemx -fdump-class-hierarchy-@var{options} @r{(C++ only)}
@opindex fdump-class-hierarchy
Dump a representation of each class's hierarchy and virtual function
table layout to a file. The file name is made by appending @file{.class}
! to the source file name. If the @samp{-@var{options}} form is used,
! @var{options} controls the details of the dump as described for the
! @option{-fdump-tree} options.
!
! @item -fdump-tree-@var{switch} @r{(C++ only)}
! @itemx -fdump-tree-@var{switch}-@var{options} @r{(C++ only)}
! @opindex fdump-tree
! Control the dumping at various stages of processing the intermediate
! language tree to a file. The file name is generated by appending a switch
! specific suffix to the source file name. If the @samp{-@var{options}}
! form is used, @var{options} is a list of @samp{-} separated options that
! control the details of the dump. Not all options are applicable to all
! dumps, those which are not meaningful will be ignored. The following
! options are available
@table @samp
! @item address
Print the address of each node. Usually this is not meaningful as it
! changes according to the environment and source file. Its primary use
! is for tying up a dump file with a debug environment.
! @item slim
! Inhibit dumping of members of a scope or body of a function merely
! because that scope has been reached. Only dump such items when they
! are directly reachable by some other path.
! @item refs
! Print the list of references made to each variable in the program.
! @item all
! Turn on all options.
@end table
The following tree dumps are possible:
@table @samp
+
@item original
Dump before any tree based optimization, to @file{@var{file}.original}.
+
@item optimized
Dump after all tree based optimization, to @file{@var{file}.optimized}.
+
@item inlined
Dump after inlining within the body of the function, to
@file{@var{file}.inlined}.
! @item cfg
@opindex fdump-tree-cfg
Dump the control flow graph of each function to a file. The file name is
made by appending @file{.cfg} to the source file name.
! @item graphviz
@opindex fdump-tree-graphviz
Dump a representation of the control flow graph, suitable for viewing with
GraphViz, to a file. The file name is made by appending @file{.dot} to the
source file name.
! @item ssa
@opindex fdump-tree-ssa
Dump SSA related information to a file. The file name is made by appending
! @file{.ssa} to the source file name.
@end table
@item -fpretend-float