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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [plugin/] [ggcplug.c] - Blame information for rev 749

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

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

powered by: WebSVN 2.1.0

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