This is the mail archive of the 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]

[PATCH 04/11] Automated conversion of passes to C++ classes

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

It is generated by the script in

The script has its own test suite:, and you can
get an idea of the behavior of the script by reviewing the test suite.

This patch converts all existing pass structs for say RTL pass_foo into
the following:

  namespace {

  const pass_data pass_data_foo =
     /* initialization data */

  class pass_foo : public rtl_opt_pass
    pass_web(gcc::context *ctxt)
      : rtl_opt_pass(pass_data_web, ctxt)

   /* opt_pass methods: */
   bool gate () { return gate_foo (); }
   unsigned int execute () { return execute_foo (); }

  }; // class pass_foo

  } // anon namespace

  rtl_opt_pass *
  make_pass_foo (gcc::context *ctxt)
    return new pass_foo (ctxt);

so that the only exposed API to the pass is the factory function (i.e.

It also updates tree-pass.h to replace all of the struct declarations:

  extern struct rtl_opt_pass pass_foo;

with those of the new factory functions:

  extern rtl_opt_pass *make_pass_foo (gcc::context *ctxt);

The full patch is 500k in size; I have posted it to:
to avoid exceeding mailing list size limits (that version of the patch
includes the ChangeLog entries).

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