From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29669 invoked by alias); 5 Mar 2012 13:51:52 -0000 Received: (qmail 29659 invoked by uid 22791); 5 Mar 2012 13:51:51 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-gx0-f175.google.com (HELO mail-gx0-f175.google.com) (209.85.161.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 05 Mar 2012 13:51:37 +0000 Received: by ggcy3 with SMTP id y3so1633160ggc.20 for ; Mon, 05 Mar 2012 05:51:36 -0800 (PST) MIME-Version: 1.0 Received: by 10.50.197.170 with SMTP id iv10mr5610967igc.31.1330955496450; Mon, 05 Mar 2012 05:51:36 -0800 (PST) Received: by 10.231.64.207 with HTTP; Mon, 5 Mar 2012 05:51:36 -0800 (PST) In-Reply-To: References: <1329507251.15787.25.camel@surprise> <4F3F09A5.5050301@grosser.es> Date: Mon, 05 Mar 2012 13:51:00 -0000 Message-ID: Subject: Re: Iterating over RTL in Graphite From: Arnaldo To: Tobias Grosser Cc: David Malcolm , gcc@gcc.gnu.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Gm-Message-State: ALoCoQns6HwYttREP4R4MbkqCanlfKJQA112Yzk2JgN78FpdPhR1tBynIJEYlp8nefv9TeKk3YIe X-IsSubscribed: yes Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2012-03/txt/msg00051.txt.bz2 On Sat, Feb 18, 2012 at 6:46 PM, Arnaldo wrote: > On Fri, Feb 17, 2012 at 10:15 PM, Tobias Grosser wrot= e: >> On 02/17/2012 08:34 PM, David Malcolm wrote: >>> >>> On Thu, 2012-02-16 at 19:17 -0400, Arnaldo wrote: >>>> >>>> Hello everyone, >>>> >>>> I'm working on an extension to the Graphite pass of GCC 4.4.0. =A0My >>>> intention is to associate costs to RTL instructions by adding them as >>>> RTX attributes to a machine description file, and to read them back >>>> during the Graphite pass by iterating through each basic block. >>>> >>>> Is the RTL available during this optimization pass? I'm not sure this >>>> is the case as I get a segfault when trying to iterate over the RTL >>>> with the code below ("internal compiler error: Segmentation fault"). I >>>> don't need the fully resolved RTL, just to be able to read the >>>> attribute given an RTL instruction. >>>> >>>> I've tried debugging the compiler with gdb but it can't find the >>>> debugging symbols even though they're there. =A0I'll keep trying to get >>>> gdb to work but any leads on reading these attributes from within >>>> Graphite is greatly appreciated. >>> >>> I don't know about GCC 4.4, but a while back I wrote a script using my >>> GCC Python plugin to draw a "subway map" of GCC 4.6's passes: >>> http://gcc.gnu.org/ml/gcc/2011-07/msg00157.html >>> which you can see here: >>> http://gcc-python-plugin.readthedocs.org/en/latest/tables-of-passes.html >>> >>> If I reading things correctly, the graphite passes happen whilst the >>> code is still in gimple form: the blocks are converted to RTL form in >>> the "expand" pass, which happens about 20 or so passes later. >>> >>> Caveat: I'm not familiar with the insides of the graphite, and am >>> relatively new to gcc's insides, so I could be wrong; also the script >>> relies on the pass flags, and they're not necessarily correct either... >> >> >> Yes, graphite works on GIMPLE. I believe I have never seen RTL when work= ing >> on graphite, so I doubt it is easily available. (Maybe it is, but it is >> definitely not used within graphite). >> >> Cheers >> Tobi >> > > Thanks David and Tobias, that helped. > > I started looking into the expand pass (cfgexpand.c), there's an > interesting function there: > static basic_block expand_gimple_basic_block (basic_block bb) > > When I get a change I'll make it 'public' and see if I can call it > from graphite.c > > -Arnaldo I couldn't get cfgexpand.c:basic_block expand_gimple_basic_block (basic_block bb) to work by calling it directly because there is some preprocessing in gimple_expand_cfg() that has to be done first. But calling gimple_expand_cfg() modifies the CFG and asserts will fail later on during compilation. I think the only way to solve this would be to somehow duplicate the current cfun structure when entering the part of Graphite I'm extending, then calling push_cfun(), gimple_expand_cfg(), extracting the BBs with the RTL and calling pop_cfun() before continuing. -Arnaldo