Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. register_callback("my_plugin_
  2. name", PLUGIN_PASS_MANAGER_SETUP, NULL, &pass_info);
  3.  
  4. class pass_greg : public gimple_opt_pass
  5. {
  6. public:
  7. pass_greg (gcc::context ctxt)
  8. : gimple_opt_pass (pass_data_greg, gcc::context ctxt)
  9. {}
  10.  
  11. bool gate () { return greg_gate(); }
  12. unsigned int execute () { return greg_pass (); }
  13.  
  14. };
  15.  
  16. #include <gcc-plugin.h>
  17. #include <context.h> //This is is the context g that is needed for the pass constructor
  18.  
  19.  
  20. const pass_data pass_data_greg =
  21. {
  22. GIMPLE_PASS, /* type */
  23. "Greg's Plugin", /* name */
  24. OPTGROUP_LOOP, /* optinfo_flags */
  25. true, /* has_gate */
  26. true, /* has_execute */
  27. TV_TREE_PREFETCH, /* tv_id */
  28. ( PROP_cfg | PROP_ssa ), /* properties_required */
  29. 0, /* properties_provided */
  30. 0, /* properties_destroyed */
  31. 0, /* todo_flags_start */
  32. 0, /* todo_flags_finish */
  33. };
  34.  
  35. class pass_greg : public gimple_opt_pass
  36. {
  37. public:
  38. pass_greg (gcc::context ctxt)
  39. : gimple_opt_pass (pass_data_greg, gcc::context ctxt)
  40. {}
  41.  
  42. bool gate () { return greg_gate(); }
  43. unsigned int execute () { return greg_pass (); }
  44.  
  45. int plugin_init(struct plugin_name_args *info, /* Argument infor */
  46. struct plugin_gcc_version *ver) /* Version of GCC */
  47. {
  48. //... Some version check and so ...
  49. pass.pass = make_pass_greg(g);
  50. pass.reference_pass_name = "ssa";
  51. pass.ref_pass_instance_number = 1;
  52. pass.pos_op = PASS_POS_INSERT_AFTER;
  53.  
  54. register_callback("rodetect", PLUGIN_PASS_MANAGER_SETUP, NULL, &pass);
  55.  
  56. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement