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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.dg/] [plugin/] [ggcplug.c] - Blame information for rev 319

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 298 jeremybenn
/* This plugin tests the GGC related plugin events.  */
2
/* { dg-options "-O" } */
3
 
4
#include "config.h"
5
#include "system.h"
6
#include "coretypes.h"
7
#include "tm.h"
8
#include "toplev.h"
9
#include "basic-block.h"
10
#include "gimple.h"
11
#include "tree.h"
12
#include "tree-pass.h"
13
#include "intl.h"
14
#include "gcc-plugin.h"
15
#include "plugin-version.h"
16
 
17
int plugin_is_GPL_compatible;
18
 
19
/* our callback is the same for all PLUGIN_GGC_START,
20
   PLUGIN_GGC_MARKING, PLUGIN_GGC_END events; it just increments the
21
   user_data which is an int */
22
static void increment_callback (void *gcc_data, void *user_data);
23
 
24
/* our counters are user_data */
25
static int our_ggc_start_counter;
26
static int our_ggc_end_counter;
27
static int our_ggc_marking_counter;
28
 
29
/* our empty GGC extra root table */
30
static const struct ggc_root_tab our_xtratab[] = {
31
  LAST_GGC_ROOT_TAB
32
};
33
 
34
 
35
/* The initialization routine exposed to and called by GCC. The spec of this
36
   function is defined in gcc/gcc-plugin.h.
37
 
38
   Note that this function needs to be named exactly "plugin_init".  */
39
int
40
plugin_init (struct plugin_name_args *plugin_info,
41
              struct plugin_gcc_version *version)
42
{
43
  const char *plugin_name = plugin_info->base_name;
44
  int argc = plugin_info->argc;
45
  int i = 0;
46
  struct plugin_argument *argv = plugin_info->argv;
47
  if (!plugin_default_version_check (version, &gcc_version))
48
    return 1;
49
  /* Process the plugin arguments. This plugin takes the following arguments:
50
     count-ggc-start count-ggc-end count-ggc-mark */
51
  for (i = 0; i < argc; ++i)
52
    {
53
      if (!strcmp (argv[i].key, "count-ggc-start"))
54
        {
55
          if (argv[i].value)
56
            warning (0, G_ ("option '-fplugin-arg-%s-count-ggc-start=%s'"
57
                            " ignored (superfluous '=%s')"),
58
                     plugin_name, argv[i].value, argv[i].value);
59
          else
60
            register_callback ("ggcplug",
61
                               PLUGIN_GGC_START,
62
                               increment_callback,
63
                               (void *) &our_ggc_start_counter);
64
        }
65
      else if (!strcmp (argv[i].key, "count-ggc-end"))
66
        {
67
          if (argv[i].value)
68
            warning (0, G_ ("option '-fplugin-arg-%s-count-ggc-end=%s'"
69
                            " ignored (superfluous '=%s')"),
70
                     plugin_name, argv[i].value, argv[i].value);
71
          else
72
            register_callback ("ggcplug",
73
                               PLUGIN_GGC_END,
74
                               increment_callback,
75
                               (void *) &our_ggc_end_counter);
76
        }
77
      else if (!strcmp (argv[i].key, "count-ggc-mark"))
78
        {
79
          if (argv[i].value)
80
            warning (0, G_ ("option '-fplugin-arg-%s-count-ggc-mark=%s'"
81
                            " ignored (superfluous '=%s')"),
82
                     plugin_name, argv[i].value, argv[i].value);
83
          else
84
            register_callback ("ggcplug",
85
                               PLUGIN_GGC_MARKING,
86
                               increment_callback,
87
                               (void *) &our_ggc_marking_counter);
88
        }
89
      else if (!strcmp (argv[i].key, "test-extra-root"))
90
        {
91
          if (argv[i].value)
92
            warning (0, G_ ("option '-fplugin-arg-%s-test-extra-root=%s'"
93
                            " ignored (superfluous '=%s')"),
94
                     plugin_name, argv[i].value, argv[i].value);
95
          else
96
            register_callback ("ggcplug",
97
                               PLUGIN_REGISTER_GGC_ROOTS,
98
                               NULL,
99
                               (void *) our_xtratab);
100
        }
101
    }
102
  /* plugin initialization succeeded */
103
  return 0;
104
 }
105
 
106
static void
107
increment_callback (void *gcc_data, void *user_data)
108
{
109
  int *usercountptr = (int *) user_data;
110
  gcc_assert (!gcc_data);
111
  gcc_assert (user_data);
112
  (*usercountptr)++;
113
}

powered by: WebSVN 2.1.0

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