From patchwork Tue Aug 6 17:15:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 265180 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id EB8CC2C009D for ; Wed, 7 Aug 2013 03:15:36 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:subject:from:to:cc:date:in-reply-to:references :content-type:mime-version; q=dns; s=default; b=bzStXSujkN+w4Uix Rim/60sURcu5v5KCvx0P/Ok6zxKiEgd62F2AIZ0jul4xJP8lrWY9gd+METmheh7Y GhTu0Ah28QRBqxVy059GFdQEY4kp+y/wMJZE+Lls4QGAIHT7GNIsTMGrNsqm1mo6 kKHtYTBW9Jc/gzWTVhwlkkqCzGo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:subject:from:to:cc:date:in-reply-to:references :content-type:mime-version; s=default; bh=HEu3gqclx08CT8BeSP92jK IMN38=; b=ZJ2gwpxPqlrIMyfPhHLQzDSWyS1N7+9NWOKSXkQhEEcn69c5Mfa0eq hQ7VERzLR5OjBr23gR0j3GJq57yVuHb1DiaIOz1krl79bMMEs4jg/xkbTriwpN24 3xJ1jF1hFG2zwCbePfPdi7nMAV0/eco1+8MdiiInoXzMhN6ijIjK4= Received: (qmail 22245 invoked by alias); 6 Aug 2013 17:15:29 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 22227 invoked by uid 89); 6 Aug 2013 17:15:29 -0000 X-Spam-SWARE-Status: No, score=-5.4 required=5.0 tests=AWL, BAYES_00, KHOP_THREADED, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, RDNS_NONE, SPF_HELO_PASS, SPF_PASS autolearn=no version=3.3.1 Received: from Unknown (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Tue, 06 Aug 2013 17:15:28 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r76HFKlM004347 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 6 Aug 2013 13:15:20 -0400 Received: from [10.18.25.132] ([10.18.25.132]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r76HFJGf013139; Tue, 6 Aug 2013 13:15:19 -0400 Message-ID: <1375809318.5818.10.camel@surprise> Subject: [rl78]: Port to new pass C++ API (was Re: [buildbot] r201508: Build failures after pass C++ conversion) From: David Malcolm To: Jan-Benedict Glaw Cc: gcc-patches@gcc.gnu.org Date: Tue, 06 Aug 2013 13:15:18 -0400 In-Reply-To: <20130806111816.GB16320@lug-owl.de> References: <20130805201605.1748.qmail@sourceware.org> <20130806111256.GA16320@lug-owl.de> <20130806111816.GB16320@lug-owl.de> Mime-Version: 1.0 X-Virus-Found: No 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 wrote: > > On Mon, 2013-08-05 20:16:05 -0000, 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 ‘’ 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 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); }