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

[rl78]: Port to new pass C++ API (was Re: [buildbot] r201508: Build failures after pass C++ conversion)


On Tue, 2013-08-06 at 13:18 +0200, Jan-Benedict Glaw wrote:
> On Tue, 2013-08-06 13:12:57 +0200, Jan-Benedict Glaw <jbglaw@lug-owl.de> wrote:
> > On Mon, 2013-08-05 20:16:05 -0000, dmalcolm@gcc.gnu.org <dmalcolm@gcc.gnu.org> wrote:
> > > New Revision: 201508
> > > 
> > > URL: http://gcc.gnu.org/viewcvs?rev=201508&root=gcc&view=rev
> > > Log:
> > > Automated conversion of passes to C++ classes
> > > 
> > > gcc/
> > > 
> > > 	Patch autogenerated by refactor_passes.py from
> > > 	https://github.com/davidmalcolm/gcc-refactoring-scripts
> > > 	revision 03fe39476a4c4ea450b49e087cfa817b5f92021e
> 
> And probably also for rl78-elf:
> 
> g++ -c   -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE  -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -fno-common  -DHAVE_CONFIG_H -I. -I. -I../../../../gcc/gcc -I../../../../gcc/gcc/. -I../../../../gcc/gcc/../include -I../../../../gcc/gcc/../libcpp/include  -I../../../../gcc/gcc/../libdecnumber -I../../../../gcc/gcc/../libdecnumber/dpd -I../libdecnumber -I../../../../gcc/gcc/../libbacktrace    \
>                 ../../../../gcc/gcc/config/rl78/rl78.c -o rl78.o
> ../../../../gcc/gcc/config/rl78/rl78.c:146:1: error: in C++98 ârl78_devirt_passâ must be initialized by constructor, not by â{...}â
>  };
>  ^
> ../../../../gcc/gcc/config/rl78/rl78.c:146:1: error: could not convert â{RTL_PASS, "devirt", 0, devirt_gate, devirt_pass, 0, 0, 212, TV_MACH_DEP, 0, 0, 0, 0, 0}â from â<brace-enclosed initializer list>â to âopt_passâ
> 
> MfG, JBG

Sorry again.

The attached patch fixes the build for me with --target=rl78-elf.  Only
tested lightly with build&host=x86_64 so far; I was able to build
stage1, verify cc1 generates assembler on a simple .c file, and step
through the changed code.   However it's much more self-contained than
the epiphany fix.  There was a hardcoded value of 212 for the
static_pass_number of the pass, which may have been what stopped by
automated script from fixing this, so I set this in the ctor in case
anything is relying on this.  The make_pass_rl78_devirt function is
rather redundant, but I was deliberately mimicking the changes made by
the automated script.

It adds a dep on context.h to gcc/config/rl78/rl78.c, and I didn't see
how to add this (t-rl78 only lists rl78-c.o).

commit 4eb61ff39f72295f680d4be9d447e7e6bdfe629f
Author: David Malcolm <dmalcolm@redhat.com>
Date:   Tue Aug 6 13:08:42 2013 -0400

    gcc/
    	* config/rl78/rl78.c (rl78_devirt_pass): Convert from a struct to...
    	(pass_rl78_devirt): ...new subclass of rtl_opt_pass along with...
    	(pass_data_rl78_devirt): ...new pass_data instance and...
    	(make_pass_rl78_devirt): ...new function.
    	(rl78_asm_file_start): Port pass registration to new C++ API.

diff --git a/gcc/config/rl78/rl78.c b/gcc/config/rl78/rl78.c
index c2ed738..5bfb21f 100644
--- a/gcc/config/rl78/rl78.c
+++ b/gcc/config/rl78/rl78.c
@@ -49,6 +49,7 @@
 #include "rl78-protos.h"
 #include "dumpfile.h"
 #include "tree-pass.h"
+#include "context.h"
 
 static inline bool is_interrupt_func (const_tree decl);
 static inline bool is_brk_interrupt_func (const_tree decl);
@@ -129,30 +130,48 @@ devirt_pass (void)
 /* This pass converts virtual instructions using virtual registers, to
    real instructions using real registers.  Rather than run it as
    reorg, we reschedule it before vartrack to help with debugging.  */
-static struct opt_pass rl78_devirt_pass =
-{
-  RTL_PASS,
-  "devirt",
-  OPTGROUP_NONE,                        /* optinfo_flags */
-  devirt_gate,
-  devirt_pass,
-  NULL,
-  NULL,
-  212,
-  TV_MACH_DEP,
-  0, 0, 0,
-  0,
-  0
+namespace {
+
+const pass_data pass_data_rl78_devirt =
+{
+  RTL_PASS, /* type */
+  "devirt", /* name */
+  OPTGROUP_NONE, /* optinfo_flags */
+  true, /* has_gate */
+  true, /* has_execute */
+  TV_MACH_DEP, /* tv_id */
+  0, /* properties_required */
+  0, /* properties_provided */
+  0, /* properties_destroyed */
+  0, /* todo_flags_start */
+  0, /* todo_flags_finish */
 };
 
-static struct register_pass_info rl78_devirt_info =
+class pass_rl78_devirt : public rtl_opt_pass
 {
-  & rl78_devirt_pass,
-  "vartrack",
-  1,
-  PASS_POS_INSERT_BEFORE
+public:
+  pass_rl78_devirt(gcc::context *ctxt)
+    : rtl_opt_pass(pass_data_rl78_devirt, ctxt)
+  {
+    /* Prior to porting to C++, the static_pass_number was hardcoded
+       to 212.  Replicate this behavior. */
+    static_pass_number = 212;
+  }
+
+  /* opt_pass methods: */
+  bool gate () { return devirt_gate (); }
+  unsigned int execute () { return devirt_pass (); }
 };
 
+} // anon namespace
+
+rtl_opt_pass *
+make_pass_rl78_devirt (gcc::context *ctxt)
+{
+  return new pass_rl78_devirt (ctxt);
+}
+
+
 #undef  TARGET_ASM_FILE_START
 #define TARGET_ASM_FILE_START rl78_asm_file_start
 
@@ -167,6 +186,15 @@ rl78_asm_file_start (void)
       fprintf (asm_out_file, "r%d\t=\t0x%x\n", 16 + i, 0xffee8 + i);
     }
 
+  opt_pass *rl78_devirt_pass = make_pass_rl78_devirt (g);
+  struct register_pass_info rl78_devirt_info =
+    {
+      rl78_devirt_pass,
+      "vartrack",
+      1,
+      PASS_POS_INSERT_BEFORE
+    };
+
   register_pass (& rl78_devirt_info);
 }
 

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