summaryrefslogtreecommitdiff
path: root/gcc/dumpfile.c
diff options
context:
space:
mode:
authorbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2013-11-12 15:23:33 +0000
committerbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2013-11-12 15:23:33 +0000
commit9456798d72d0e81a2a553287f436dcb05cff175a (patch)
tree1e80106d0c4f828b72deb6e782c20d788c0dd818 /gcc/dumpfile.c
parente89aee4174fe58eaba553027558144a0f423960c (diff)
downloadgcc-9456798d72d0e81a2a553287f436dcb05cff175a.tar.gz
[./]
2013-11-12 Basile Starynkevitch <basile@starynkevitch.net> {{merge with trunk GCC 4.9 svn rev 204695; previous trunk merge was 202773; very unstable...}} [gcc/] 2013-11-11 Basile Starynkevitch <basile@starynkevitch.net> {{merge with trunk GCC 4.9 svn rev 204695; very unstable}} * melt-runtime.h (MELT_VERSION_STRING): Bump to "1.0.1+". * melt-run.proto.h: Update copyright years. include tree-cfg.h instead of tree-flow.h for GCC 4.9. * melt-runtime.cc: Include tree-cfg.h not tree-flow.h for GCC 4.9. (meltgc_walk_gimple_seq): Fatal error with GCC 4.9 since the walk_use_def_chains function disappeared from GCC... * melt/xtramelt-ana-gimple.melt (walk_gimple_seq) (walk_gimple_seq_unique_tree): issue some #warning-s for GCC 4.9 because walk_use_def_chains function disappeared from GCC... * melt/xtramelt-probe.melt (probe_docmd): Issue an error since currently the MELT probe is not usable with GCC 4.9.... git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@204705 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/dumpfile.c')
-rw-r--r--gcc/dumpfile.c167
1 files changed, 99 insertions, 68 deletions
diff --git a/gcc/dumpfile.c b/gcc/dumpfile.c
index dc87ab35e8c..e80f9bf37e2 100644
--- a/gcc/dumpfile.c
+++ b/gcc/dumpfile.c
@@ -22,8 +22,9 @@ along with GCC; see the file COPYING3. If not see
#include "coretypes.h"
#include "diagnostic-core.h"
#include "dumpfile.h"
-#include "gimple-pretty-print.h"
#include "tree.h"
+#include "gimple-pretty-print.h"
+#include "context.h"
/* If non-NULL, return one past-the-end of the matching SUBPART of
the WHOLE string. */
@@ -34,7 +35,6 @@ static int pflags; /* current dump_flags */
static int alt_flags; /* current opt_info flags */
static void dump_loc (int, FILE *, source_location);
-static int dump_phase_enabled_p (int);
static FILE *dump_open_alternate_stream (struct dump_file_info *);
/* These are currently used for communicating between passes.
@@ -74,11 +74,6 @@ static struct dump_file_info dump_files[TDI_end] =
0, 0, 0, 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
{
@@ -141,33 +136,41 @@ static const struct dump_option_value_info optgroup_options[] =
{NULL, 0}
};
+gcc::dump_manager::dump_manager ():
+ m_next_dump (FIRST_AUTO_NUMBERED_DUMP),
+ m_extra_dump_files (NULL),
+ m_extra_dump_files_in_use (0),
+ m_extra_dump_files_alloced (0)
+{
+}
+
unsigned int
+gcc::dump_manager::
dump_register (const char *suffix, const char *swtch, const char *glob,
int flags, int optgroup_flags)
{
- static int next_dump = FIRST_AUTO_NUMBERED_DUMP;
- int num = next_dump++;
+ int num = m_next_dump++;
- size_t count = extra_dump_files_in_use++;
+ size_t count = m_extra_dump_files_in_use++;
- if (count >= extra_dump_files_alloced)
+ if (count >= m_extra_dump_files_alloced)
{
- if (extra_dump_files_alloced == 0)
- extra_dump_files_alloced = 32;
+ if (m_extra_dump_files_alloced == 0)
+ m_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);
+ m_extra_dump_files_alloced *= 2;
+ m_extra_dump_files = XRESIZEVEC (struct dump_file_info,
+ m_extra_dump_files,
+ m_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].pflags = flags;
- extra_dump_files[count].optgroup_flags = optgroup_flags;
- extra_dump_files[count].num = num;
+ memset (&m_extra_dump_files[count], 0, sizeof (struct dump_file_info));
+ 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].optgroup_flags = optgroup_flags;
+ m_extra_dump_files[count].num = num;
return count + TDI_end;
}
@@ -176,14 +179,15 @@ dump_register (const char *suffix, const char *swtch, const char *glob,
/* Return the dump_file_info for the given phase. */
struct dump_file_info *
-get_dump_file_info (int phase)
+gcc::dump_manager::
+get_dump_file_info (int phase) const
{
if (phase < TDI_end)
return &dump_files[phase];
- else if ((size_t) (phase - TDI_end) >= extra_dump_files_in_use)
+ else if ((size_t) (phase - TDI_end) >= m_extra_dump_files_in_use)
return NULL;
else
- return extra_dump_files + (phase - TDI_end);
+ return m_extra_dump_files + (phase - TDI_end);
}
@@ -191,7 +195,8 @@ get_dump_file_info (int phase)
If the dump is not enabled, returns NULL. */
char *
-get_dump_file_name (int phase)
+gcc::dump_manager::
+get_dump_file_name (int phase) const
{
char dump_id[10];
struct dump_file_info *dfi;
@@ -240,10 +245,10 @@ dump_open_alternate_stream (struct dump_file_info *dfi)
if (dfi->alt_stream)
return dfi->alt_stream;
- stream = strcmp("stderr", dfi->alt_filename) == 0
+ stream = strcmp ("stderr", dfi->alt_filename) == 0
? stderr
- : strcmp("stdout", dfi->alt_filename) == 0
- ? stdout
+ : strcmp ("stdout", dfi->alt_filename) == 0
+ ? stdout
: fopen (dfi->alt_filename, dfi->alt_state < 0 ? "w" : "a");
if (!stream)
@@ -391,6 +396,7 @@ dump_printf_loc (int dump_kind, source_location loc, const char *format, ...)
-fopt-info stream. */
int
+gcc::dump_manager::
dump_start (int phase, int *flag_ptr)
{
int count = 0;
@@ -404,10 +410,10 @@ dump_start (int phase, int *flag_ptr)
name = get_dump_file_name (phase);
if (name)
{
- stream = strcmp("stderr", name) == 0
+ stream = strcmp ("stderr", name) == 0
? stderr
- : strcmp("stdout", name) == 0
- ? stdout
+ : strcmp ("stdout", name) == 0
+ ? stdout
: fopen (name, dfi->pstate < 0 ? "w" : "a");
if (!stream)
error ("could not open dump file %qs: %m", name);
@@ -443,6 +449,7 @@ dump_start (int phase, int *flag_ptr)
reset the globals DUMP_FILE, ALT_DUMP_FILE, and DUMP_FLAGS. */
void
+gcc::dump_manager::
dump_finish (int phase)
{
struct dump_file_info *dfi;
@@ -451,12 +458,12 @@ dump_finish (int phase)
return;
dfi = get_dump_file_info (phase);
if (dfi->pstream && (!dfi->pfilename
- || (strcmp("stderr", dfi->pfilename) != 0
- && strcmp("stdout", dfi->pfilename) != 0)))
+ || (strcmp ("stderr", dfi->pfilename) != 0
+ && strcmp ("stdout", dfi->pfilename) != 0)))
fclose (dfi->pstream);
- if (dfi->alt_stream && strcmp("stderr", dfi->alt_filename) != 0
- && strcmp("stdout", dfi->alt_filename) != 0)
+ if (dfi->alt_stream && strcmp ("stderr", dfi->alt_filename) != 0
+ && strcmp ("stdout", dfi->alt_filename) != 0)
fclose (dfi->alt_stream);
dfi->alt_stream = NULL;
@@ -476,6 +483,13 @@ dump_finish (int phase)
FILE *
dump_begin (int phase, int *flag_ptr)
{
+ return g->get_dumps ()->dump_begin (phase, flag_ptr);
+}
+
+FILE *
+gcc::dump_manager::
+dump_begin (int phase, int *flag_ptr)
+{
char *name;
struct dump_file_info *dfi;
FILE *stream;
@@ -488,10 +502,10 @@ dump_begin (int phase, int *flag_ptr)
return NULL;
dfi = get_dump_file_info (phase);
- stream = strcmp("stderr", name) == 0
+ stream = strcmp ("stderr", name) == 0
? stderr
- : strcmp("stdout", name) == 0
- ? stdout
+ : strcmp ("stdout", name) == 0
+ ? stdout
: fopen (name, dfi->pstate < 0 ? "w" : "a");
if (!stream)
@@ -512,8 +526,9 @@ dump_begin (int phase, int *flag_ptr)
If PHASE is TDI_tree_all, return nonzero if any dump is enabled for
any phase. */
-static int
-dump_phase_enabled_p (int phase)
+int
+gcc::dump_manager::
+dump_phase_enabled_p (int phase) const
{
if (phase == TDI_tree_all)
{
@@ -521,8 +536,8 @@ dump_phase_enabled_p (int phase)
for (i = TDI_none + 1; i < (size_t) TDI_end; i++)
if (dump_files[i].pstate || dump_files[i].alt_state)
return 1;
- for (i = 0; i < extra_dump_files_in_use; i++)
- if (extra_dump_files[i].pstate || extra_dump_files[i].alt_state)
+ for (i = 0; i < m_extra_dump_files_in_use; i++)
+ if (m_extra_dump_files[i].pstate || m_extra_dump_files[i].alt_state)
return 1;
return 0;
}
@@ -536,7 +551,8 @@ dump_phase_enabled_p (int phase)
/* Returns nonzero if tree dump PHASE has been initialized. */
int
-dump_initialized_p (int phase)
+gcc::dump_manager::
+dump_initialized_p (int phase) const
{
struct dump_file_info *dfi = get_dump_file_info (phase);
return dfi->pstate > 0 || dfi->alt_state > 0;
@@ -547,6 +563,13 @@ dump_initialized_p (int phase)
const char *
dump_flag_name (int phase)
{
+ return g->get_dumps ()->dump_flag_name (phase);
+}
+
+const char *
+gcc::dump_manager::
+dump_flag_name (int phase) const
+{
struct dump_file_info *dfi = get_dump_file_info (phase);
return dfi->swtch;
}
@@ -564,7 +587,8 @@ dump_end (int phase ATTRIBUTE_UNUSED, FILE *stream)
/* Enable all tree dumps with FLAGS on FILENAME. Return number of
enabled tree dumps. */
-static int
+int
+gcc::dump_manager::
dump_enable_all (int flags, const char *filename)
{
int ir_dump_type = (flags & (TDF_TREE | TDF_RTL | TDF_IPA));
@@ -592,21 +616,21 @@ dump_enable_all (int flags, const char *filename)
}
}
- for (i = 0; i < extra_dump_files_in_use; i++)
+ for (i = 0; i < m_extra_dump_files_in_use; i++)
{
- if ((extra_dump_files[i].pflags & ir_dump_type))
+ if ((m_extra_dump_files[i].pflags & ir_dump_type))
{
- const char *old_filename = extra_dump_files[i].pfilename;
- extra_dump_files[i].pstate = -1;
- extra_dump_files[i].pflags |= flags;
+ const char *old_filename = m_extra_dump_files[i].pfilename;
+ m_extra_dump_files[i].pstate = -1;
+ m_extra_dump_files[i].pflags |= flags;
n++;
/* Override the existing filename. */
if (filename)
{
- extra_dump_files[i].pfilename = xstrdup (filename);
+ m_extra_dump_files[i].pfilename = xstrdup (filename);
/* Since it is a command-line provided file, which is
common to all the phases, use it in append mode. */
- extra_dump_files[i].pstate = 1;
+ m_extra_dump_files[i].pstate = 1;
}
if (old_filename && filename != old_filename)
free (CONST_CAST (char *, old_filename));
@@ -620,7 +644,8 @@ dump_enable_all (int flags, const char *filename)
Enable dumps with FLAGS on FILENAME. Return the number of enabled
dumps. */
-static int
+int
+gcc::dump_manager::
opt_info_enable_passes (int optgroup_flags, int flags, const char *filename)
{
int n = 0;
@@ -644,19 +669,19 @@ opt_info_enable_passes (int optgroup_flags, int flags, const char *filename)
}
}
- for (i = 0; i < extra_dump_files_in_use; i++)
+ for (i = 0; i < m_extra_dump_files_in_use; i++)
{
- if ((extra_dump_files[i].optgroup_flags & optgroup_flags))
+ if ((m_extra_dump_files[i].optgroup_flags & optgroup_flags))
{
- const char *old_filename = extra_dump_files[i].alt_filename;
+ const char *old_filename = m_extra_dump_files[i].alt_filename;
/* Since this file is shared among different passes, it
should be opened in append mode. */
- extra_dump_files[i].alt_state = 1;
- extra_dump_files[i].alt_flags |= flags;
+ m_extra_dump_files[i].alt_state = 1;
+ m_extra_dump_files[i].alt_flags |= flags;
n++;
/* Override the existing filename. */
if (filename)
- extra_dump_files[i].alt_filename = xstrdup (filename);
+ m_extra_dump_files[i].alt_filename = xstrdup (filename);
if (old_filename && filename != old_filename)
free (CONST_CAST (char *, old_filename));
}
@@ -668,7 +693,8 @@ opt_info_enable_passes (int optgroup_flags, int flags, const char *filename)
/* Parse ARG as a dump switch. Return nonzero if it is, and store the
relevant details in the dump_files array. */
-static int
+int
+gcc::dump_manager::
dump_switch_p_1 (const char *arg, struct dump_file_info *dfi, bool doglob)
{
const char *option_value;
@@ -743,6 +769,7 @@ dump_switch_p_1 (const char *arg, struct dump_file_info *dfi, bool doglob)
}
int
+gcc::dump_manager::
dump_switch_p (const char *arg)
{
size_t i;
@@ -756,12 +783,12 @@ dump_switch_p (const char *arg)
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);
+ for (i = 0; i < m_extra_dump_files_in_use; i++)
+ any |= dump_switch_p_1 (arg, &m_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);
+ for (i = 0; i < m_extra_dump_files_in_use; i++)
+ any |= dump_switch_p_1 (arg, &m_extra_dump_files[i], true);
return any;
@@ -853,6 +880,7 @@ opt_info_switch_p (const char *arg)
int optgroup_flags;
char *filename;
static char *file_seen = NULL;
+ gcc::dump_manager *dumps = g->get_dumps ();
if (!opt_info_switch_p_1 (arg, &flags, &optgroup_flags, &filename))
return 0;
@@ -874,7 +902,7 @@ opt_info_switch_p (const char *arg)
if (!optgroup_flags)
optgroup_flags = OPTGROUP_ALL;
- return opt_info_enable_passes (optgroup_flags, flags, filename);
+ return dumps->opt_info_enable_passes (optgroup_flags, flags, filename);
}
/* Print basic block on the dump streams. */
@@ -902,5 +930,8 @@ print_combine_total_stats (void)
bool
enable_rtl_dump_file (void)
{
- return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS, NULL) > 0;
+ gcc::dump_manager *dumps = g->get_dumps ();
+ int num_enabled =
+ dumps->dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS, NULL);
+ return num_enabled > 0;
}