代码拉取完成,页面将自动刷新
#include <iostream>
#include <vector>
#include <algorithm>
// This is the first gcc header to be included
#include "gcc-plugin.h"
#include "plugin-version.h"
#include "tree-pass.h"
#include "context.h"
// We must assert that this plugin is GPL compatible
int plugin_is_GPL_compatible;
static struct plugin_info my_gcc_plugin_info = { "1.0", "This is a very simple plugin" };
namespace {
const pass_data pass_data_hello_world =
{
GIMPLE_PASS,
"hello_world", /* name */
OPTGROUP_NONE, /* optinfo_flags */
TV_NONE, /* tv_id */
( PROP_cfg | PROP_ssa ), /* properties_required */
0, /* properties_provided */
0, /* properties_destroyed */
0, /* todo_flags_start */
0 /* todo_flags_finish */
};
class pass_hello_world : public gimple_opt_pass
{
public:
pass_hello_world (gcc::context *ctx)
: gimple_opt_pass(pass_data_hello_world, ctx)
{}
/* opt_pass methods: */
virtual unsigned int execute (function *);
}; // class pass_hello_world
} // anon namespace
unsigned int
pass_hello_world::execute (function *fun)
{
std::cout << "Running my first pass, OMG\n";
return 0;
}
gimple_opt_pass *
make_pass_hello_world (gcc::context *ctxt)
{
return new pass_hello_world (ctxt);
}
int plugin_init (struct plugin_name_args *plugin_info,
struct plugin_gcc_version *version)
{
// We check the current gcc loading this plugin against the gcc we used to
// created this plugin
if (!plugin_default_version_check (version, &gcc_version))
{
std::cerr << "This GCC plugin is for version " << GCCPLUGIN_VERSION_MAJOR << "." << GCCPLUGIN_VERSION_MINOR << "\n";
return 1;
}
struct register_pass_info pass_info;
// Register the phase right before cfg
pass_info.pass = make_pass_hello_world(g);
pass_info.reference_pass_name = "phiopt";
pass_info.ref_pass_instance_number = 1;
pass_info.pos_op = PASS_POS_INSERT_AFTER;
register_callback(plugin_info->base_name,
/* event */ PLUGIN_INFO,
/* callback */ NULL, /* user_data */ &my_gcc_plugin_info);
register_callback (plugin_info->base_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &pass_info);
return 0;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。