OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc1/] [gcc/] [testsuite/] [gcc.dg/] [plugin/] [ggcplug.c] - Diff between revs 298 and 338

Only display areas with differences | Details | Blame | View Log

Rev 298 Rev 338
/* This plugin tests the GGC related plugin events.  */
/* This plugin tests the GGC related plugin events.  */
/* { dg-options "-O" } */
/* { dg-options "-O" } */
 
 
#include "config.h"
#include "config.h"
#include "system.h"
#include "system.h"
#include "coretypes.h"
#include "coretypes.h"
#include "tm.h"
#include "tm.h"
#include "toplev.h"
#include "toplev.h"
#include "basic-block.h"
#include "basic-block.h"
#include "gimple.h"
#include "gimple.h"
#include "tree.h"
#include "tree.h"
#include "tree-pass.h"
#include "tree-pass.h"
#include "intl.h"
#include "intl.h"
#include "gcc-plugin.h"
#include "gcc-plugin.h"
#include "plugin-version.h"
#include "plugin-version.h"
 
 
int plugin_is_GPL_compatible;
int plugin_is_GPL_compatible;
 
 
/* our callback is the same for all PLUGIN_GGC_START,
/* our callback is the same for all PLUGIN_GGC_START,
   PLUGIN_GGC_MARKING, PLUGIN_GGC_END events; it just increments the
   PLUGIN_GGC_MARKING, PLUGIN_GGC_END events; it just increments the
   user_data which is an int */
   user_data which is an int */
static void increment_callback (void *gcc_data, void *user_data);
static void increment_callback (void *gcc_data, void *user_data);
 
 
/* our counters are user_data */
/* our counters are user_data */
static int our_ggc_start_counter;
static int our_ggc_start_counter;
static int our_ggc_end_counter;
static int our_ggc_end_counter;
static int our_ggc_marking_counter;
static int our_ggc_marking_counter;
 
 
/* our empty GGC extra root table */
/* our empty GGC extra root table */
static const struct ggc_root_tab our_xtratab[] = {
static const struct ggc_root_tab our_xtratab[] = {
  LAST_GGC_ROOT_TAB
  LAST_GGC_ROOT_TAB
};
};
 
 
 
 
/* The initialization routine exposed to and called by GCC. The spec of this
/* The initialization routine exposed to and called by GCC. The spec of this
   function is defined in gcc/gcc-plugin.h.
   function is defined in gcc/gcc-plugin.h.
 
 
   Note that this function needs to be named exactly "plugin_init".  */
   Note that this function needs to be named exactly "plugin_init".  */
int
int
plugin_init (struct plugin_name_args *plugin_info,
plugin_init (struct plugin_name_args *plugin_info,
              struct plugin_gcc_version *version)
              struct plugin_gcc_version *version)
{
{
  const char *plugin_name = plugin_info->base_name;
  const char *plugin_name = plugin_info->base_name;
  int argc = plugin_info->argc;
  int argc = plugin_info->argc;
  int i = 0;
  int i = 0;
  struct plugin_argument *argv = plugin_info->argv;
  struct plugin_argument *argv = plugin_info->argv;
  if (!plugin_default_version_check (version, &gcc_version))
  if (!plugin_default_version_check (version, &gcc_version))
    return 1;
    return 1;
  /* Process the plugin arguments. This plugin takes the following arguments:
  /* Process the plugin arguments. This plugin takes the following arguments:
     count-ggc-start count-ggc-end count-ggc-mark */
     count-ggc-start count-ggc-end count-ggc-mark */
  for (i = 0; i < argc; ++i)
  for (i = 0; i < argc; ++i)
    {
    {
      if (!strcmp (argv[i].key, "count-ggc-start"))
      if (!strcmp (argv[i].key, "count-ggc-start"))
        {
        {
          if (argv[i].value)
          if (argv[i].value)
            warning (0, G_ ("option '-fplugin-arg-%s-count-ggc-start=%s'"
            warning (0, G_ ("option '-fplugin-arg-%s-count-ggc-start=%s'"
                            " ignored (superfluous '=%s')"),
                            " ignored (superfluous '=%s')"),
                     plugin_name, argv[i].value, argv[i].value);
                     plugin_name, argv[i].value, argv[i].value);
          else
          else
            register_callback ("ggcplug",
            register_callback ("ggcplug",
                               PLUGIN_GGC_START,
                               PLUGIN_GGC_START,
                               increment_callback,
                               increment_callback,
                               (void *) &our_ggc_start_counter);
                               (void *) &our_ggc_start_counter);
        }
        }
      else if (!strcmp (argv[i].key, "count-ggc-end"))
      else if (!strcmp (argv[i].key, "count-ggc-end"))
        {
        {
          if (argv[i].value)
          if (argv[i].value)
            warning (0, G_ ("option '-fplugin-arg-%s-count-ggc-end=%s'"
            warning (0, G_ ("option '-fplugin-arg-%s-count-ggc-end=%s'"
                            " ignored (superfluous '=%s')"),
                            " ignored (superfluous '=%s')"),
                     plugin_name, argv[i].value, argv[i].value);
                     plugin_name, argv[i].value, argv[i].value);
          else
          else
            register_callback ("ggcplug",
            register_callback ("ggcplug",
                               PLUGIN_GGC_END,
                               PLUGIN_GGC_END,
                               increment_callback,
                               increment_callback,
                               (void *) &our_ggc_end_counter);
                               (void *) &our_ggc_end_counter);
        }
        }
      else if (!strcmp (argv[i].key, "count-ggc-mark"))
      else if (!strcmp (argv[i].key, "count-ggc-mark"))
        {
        {
          if (argv[i].value)
          if (argv[i].value)
            warning (0, G_ ("option '-fplugin-arg-%s-count-ggc-mark=%s'"
            warning (0, G_ ("option '-fplugin-arg-%s-count-ggc-mark=%s'"
                            " ignored (superfluous '=%s')"),
                            " ignored (superfluous '=%s')"),
                     plugin_name, argv[i].value, argv[i].value);
                     plugin_name, argv[i].value, argv[i].value);
          else
          else
            register_callback ("ggcplug",
            register_callback ("ggcplug",
                               PLUGIN_GGC_MARKING,
                               PLUGIN_GGC_MARKING,
                               increment_callback,
                               increment_callback,
                               (void *) &our_ggc_marking_counter);
                               (void *) &our_ggc_marking_counter);
        }
        }
      else if (!strcmp (argv[i].key, "test-extra-root"))
      else if (!strcmp (argv[i].key, "test-extra-root"))
        {
        {
          if (argv[i].value)
          if (argv[i].value)
            warning (0, G_ ("option '-fplugin-arg-%s-test-extra-root=%s'"
            warning (0, G_ ("option '-fplugin-arg-%s-test-extra-root=%s'"
                            " ignored (superfluous '=%s')"),
                            " ignored (superfluous '=%s')"),
                     plugin_name, argv[i].value, argv[i].value);
                     plugin_name, argv[i].value, argv[i].value);
          else
          else
            register_callback ("ggcplug",
            register_callback ("ggcplug",
                               PLUGIN_REGISTER_GGC_ROOTS,
                               PLUGIN_REGISTER_GGC_ROOTS,
                               NULL,
                               NULL,
                               (void *) our_xtratab);
                               (void *) our_xtratab);
        }
        }
    }
    }
  /* plugin initialization succeeded */
  /* plugin initialization succeeded */
  return 0;
  return 0;
 }
 }
 
 
static void
static void
increment_callback (void *gcc_data, void *user_data)
increment_callback (void *gcc_data, void *user_data)
{
{
  int *usercountptr = (int *) user_data;
  int *usercountptr = (int *) user_data;
  gcc_assert (!gcc_data);
  gcc_assert (!gcc_data);
  gcc_assert (user_data);
  gcc_assert (user_data);
  (*usercountptr)++;
  (*usercountptr)++;
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.