This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

How to migrate struct rtl_opt_pass to class for GCC v6.x?


Hi GCC developers,

As ChangeLog-2013 mentioned:

2013-08-05  David Malcolm <dmalcolm@redhat.com>

    This is the automated part of the conversion of passes from C
    structs to C++ classes.

...

    * auto-inc-dec.c (pass_inc_dec): Convert from a global struct to a
    subclass of rtl_opt_pass along with...


so I migrate struct rtl_opt_pass: https://github.com/llvm-mirror/dragonegg/blob/master/src/Backend.cpp#L1731


static struct rtl_opt_pass pass_rtl_emit_function = { {
  RTL_PASS, "rtl_emit_function",         /* name */
#if (GCC_MINOR > 7)
  OPTGROUP_NONE,                         /* optinfo_flags */
#endif
  NULL,                                  /* gate */
  rtl_emit_function,                     /* execute */
  NULL,                                  /* sub */
  NULL,                                  /* next */
  0,                                     /* static_pass_number */
  TV_NONE,                               /* tv_id */
  PROP_ssa | PROP_gimple_leh | PROP_cfg, /* properties_required */
  0,                                     /* properties_provided */
  PROP_ssa | PROP_trees,                 /* properties_destroyed */
TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts, /* todo_flags_start */
  TODO_ggc_collect /* todo_flags_finish */
} };


to GCC v6.x C++ classes' style: https://github.com/xiangzhai/dragonegg/blob/gcc-6_3-branch/src/Backend.cpp#L2072


const pass_data pass_data_rtl_emit_function = {
  RTL_PASS,                              /* type */
  "rtl_emit_function",                   /* name */
  OPTGROUP_NONE,                         /* optinfo_flags */
  TV_NONE,                               /* tv_id */
  PROP_ssa | PROP_gimple_leh | PROP_cfg, /* properties_required */
  0,                                     /* properties_provided */
  PROP_ssa | PROP_trees,                 /* properties_destroyed */
  0,                                     /* todo_flags_start */
  0,                                     /* todo_flags_finish */
};

class pass_rtl_emit_function : public rtl_opt_pass {
public:
  pass_rtl_emit_function(gcc::context *ctxt)
      : rtl_opt_pass(pass_data_rtl_emit_function, ctxt) {}

  unsigned int execute(function *) { return rtl_emit_function(); }

  opt_pass *clone() { return this; }
};


GCC v4.6 will call the callback `rtl_emit_function`, but GCC v6.x will not, did I forget something? is there some options need to be set? please give me some hint, thanks a lot!

PS: GCC v6.x *call* the callback `rtl_emit_function` https://github.com/xiangzhai/dragonball/blob/master/tests/plugin.cpp#L67 in this testcase, I will check the source code about register_callback, rtl_opt_pass, and opt_pass.

--
Regards,
Leslie Zhai - a LLVM developer https://reviews.llvm.org/p/xiangzhai/
	@



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]