-
Notifications
You must be signed in to change notification settings - Fork 1
/
plugin.c
72 lines (55 loc) · 1.55 KB
/
plugin.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//#include "gtkinterface.h"
#include "gcc.h"
void process (tree t); // forward
void process_type(tree t);
static void generic_callbackPLUGIN_ALL_IPA_PASSES_START()
{
plugin_close_files();
}
static void generic_callbackPLUGIN_FINISH_TYPE (tree t, void *i)
{
plugin_finish_type (t,i);
}
static void generic_callbackPLUGIN_START_UNIT()
{
plugin_open_files();
}
static void generic_callbackPLUGIN_FINISH (tree t, void *_)
{
#ifdef USE_GTK
gtk_shutdown();
#endif
}
static void generic_callbackPLUGIN_ATTRIBUTES ()
{
#ifdef USE_GTK
gtk_startup();
#endif
}
/*
register a simple handler for all plugins,
the commented out ones just crash
*/
#define DEFEVENTSPECIAL(X) register_callback (plugin_info->base_name, X, (plugin_callback_func)&generic_callback ##X, #X );
//#define DEFEVENT(X)
//void (*)(union tree_node *, void *)
void register_special_plugins (struct plugin_name_args *plugin_info){
DEFEVENTSPECIAL (PLUGIN_FINISH_TYPE);
/* Called before GCC exits. */
DEFEVENTSPECIAL (PLUGIN_FINISH);
DEFEVENTSPECIAL (PLUGIN_ATTRIBUTES);
/* Called at start of GCC Garbage Collection. */
// DEFEVENTSPECIAL (PLUGIN_GGC_START);
// DEFEVENTSPECIAL (PLUGIN_GGC_END);
DEFEVENTSPECIAL ( PLUGIN_START_UNIT); // open the output files
DEFEVENTSPECIAL ( PLUGIN_ALL_IPA_PASSES_START); // close the output files
}
int plugin_is_GPL_compatible; //
int
plugin_init (struct plugin_name_args *plugin_info,
struct plugin_gcc_version *version)
{
// register_all_plugins(plugin_info);
register_special_plugins (plugin_info);
return 0;
}