From: David Malcolm <dmalcolm@redhat.com>
To: Jeff Law <law@redhat.com>, gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [RFA][PATCH] Provide a class interface to ssa_propagate
Date: Tue, 24 Oct 2017 20:57:00 -0000 [thread overview]
Message-ID: <1508878173.17132.26.camel@redhat.com> (raw)
In-Reply-To: <4b766dde-648f-97a4-7366-e38e0154f29d@redhat.com>
On Tue, 2017-10-24 at 11:40 -0600, Jeff Law wrote:
> tree-ssa-propagate.c provides a fairly generic engine to propagate
> values through a lattice while in SSA form. The engine uses two
> callbacks to allow passes to provide pass specific handling of
> statements and phi nodes.
>
> The callback mechanism served us well in a C world. It is however
> somewhat painful to have state in those callbacks without resorting
> to
> global variables or passing around void * objects which contain the
> class instance pointer.
>
> For example, tree-vrp uses the propagation engine to compute global
> range information. Its callbacks vrp_visit_stmt and vrp_visit_phi
> and
> their children read/modify a variety of tree-vrp.c statics such as
> vr_data.
>
> In some changes I'm working on I'd really like to move vr_data into a
> distinct class and avoid having direct accesses to the underlying
> array.
>
> So the problem is how are routines like vrp_visit_stmt and
> vrp_visit_phi
> and their children supposed to access the class instance?
>
> One way would be to just add a void * argument to them and pass the
> class instance around. Alternately we could leave the global
> variable
> in place and have it set up, checked and wiped clean by the vr_data
> class's ctor/dtor. Both are valid and would work, but they're a bit
> ugly IMHO.
>
> This patch takes another approach. It builds a simple little class
> around ssa_propagate where the statement and phi visitors are virtual
> functions. Thus clients can override the visitors *and* they'll get
> a
> class instance pointer.
>
> I haven't gone hog wild with C++-ification, basically just enough to
> get
> the class around ssa_propagate and its children which are going to
> need
> to pass down the class instance to the virtual functions. There's a
> lot
> more that could be done here.
>
> As you can see the client side changes are pretty minimal. They just
> derive a new class from ssa_propagation_engine to provide their
> implementations of the statement and phi visitor. More importantly,
> they can hang data off that derived class which we'll exploit later.
>
> There will be a similar patch for the substitute_and_fold which has
> callbacks of its own.
>
> Bootstrapped and regression tested on x86_64.
>
> The ChangeLog makes the patch look huge. But it's actually
> relatively
> small and the client side bits are repetitive.
>
> OK for the trunk?
>
> Jeff
Looks like you forgot to attach the patch.
Dave
next prev parent reply other threads:[~2017-10-24 20:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-24 17:40 Jeff Law
2017-10-24 20:57 ` David Malcolm [this message]
2017-10-25 17:20 ` Jeff Law
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1508878173.17132.26.camel@redhat.com \
--to=dmalcolm@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=law@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).