I'm trying to do a simple plugin example like this:
#include "gcc-plugin.h"
#include "tree.h"
#include "gimple.h"
#include "tree-pass.h"
#include <stdio.h>
extern void
test(void*gcc_data, void*b) {
printf("Hellow world\n");
}
extern int plugin_init (struct plugin_name_args *plugin_info,
struct plugin_gcc_version *version)
{
const char * nombre = "Hello world";
register_callback(nombre, GIMPLE_PASS, &test, NULL);
return 0;
}
But GIMPLE_PASS is not a predefined event in gcc-plugin.h and I know I have to do something with PLUGIN_PASS_MANAGER_SETUP and struct pass_data in tree-pass.h, but I don't know exactly how and I didn't find any examples.
Somebody would show me how? iThanks.
I know you probably don't need this anymore but it can be useful for others, I have been working lately on this, and there is like 0 documentation about this ... All you can do is to find some example ( there is only few ) and try to understand what they are trying to do ( if it's well commented ), I am writing a plugin that kind of parse the gimple code, here is how my
plugin_inityou need to create your pass before :
and don't forget this for the license :