1 Star 1 Fork 0

dingguangya/plugin-gcc-indirect-prefetch-pass

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
HelloWorldPass.cc 2.26 KB
一键复制 编辑 原始数据 按行查看 历史
dingguangya 提交于 2022-12-01 15:19 . add array-widen pass
#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;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/dguangya/plugin-gcc-indirect-prefetch-pass.git
git@gitee.com:dguangya/plugin-gcc-indirect-prefetch-pass.git
dguangya
plugin-gcc-indirect-prefetch-pass
plugin-gcc-indirect-prefetch-pass
master

搜索帮助