public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Trevor Saunders <tsaunders@mozilla.com>
To: David Malcolm <dmalcolm@redhat.com>
Cc: Andrew MacLeod <amacleod@redhat.com>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH 0/6] Conversion of gimple types to C++ inheritance (v3)
Date: Fri, 01 Nov 2013 23:43:00 -0000	[thread overview]
Message-ID: <20131101234319.GB2102@tsaunders-iceball.corp.tor1.mozilla.com> (raw)
In-Reply-To: <1383345756.5282.35.camel@surprise>

> > It is a start, but it doesnt do the rest of the work that needs doing to 
> > really take advantage of it... which will be extensive.
> > for instance, we should change:
> > 
> >    static inline void
> > ! gimple_call_set_lhs (gimple gs, tree lhs)
> >    {
> > -   GIMPLE_CHECK (gs, GIMPLE_CALL);
> >      gimple_set_op (gs, 0, lhs);
> > to
> >      static inline void
> > ! gimple_call_set_lhs (gimple_statement_call *gs, tree lhs)
> >    {
> >      gimple_set_op (gs, 0, lhs);
> > 
> > 
> > but then every location that calls it needs an appropriate change:
> > 
> > !       gimple call;
> > !       call = gimple_build_call_vec (build_fold_addr_expr_loc (0, 
> > alias), vargs);
> >          gimple_call_set_lhs (call, atree);
> > 
> > --- 1518,1524 ----
> > 
> > !       gimple_statement_call *call;
> > !       call = as_a<gimple_statement_call> (gimple_build_call_vec 
> > (build_fold_addr_expr_loc (0, alias), vargs));
> >          gimple_call_set_lhs (call, atree);
> > 
> > And in fact there is a ripple effect to then change 
> > gimple_build_call_vec to simply return a gimple_statement_call *... Then 
> > this doesn't look as ugly either...
> > 
> > !       gimple_statement_call *call;
> > !       call = gimple_build_call_vec (build_fold_addr_expr_loc (0, 
> > alias), vargs);
> >          gimple_call_set_lhs (call, atree);
> > 
> > that is looking much better :-)
> 
> I'd love to make use of compile-time type-safety like this, but does
> this have to gate this initial step?

 I don't think Andrew was suggesting it should, but fwiw I agree with
 you one step at a time.

> The transition to strongly-typed getters/setters could be done one
> at-a-time, I guess.

I actually have a slightly different suggestion, see below.

> > Leaving the names as they are should be ok, but the I'd also add a 
> > typedef for the pointer without the 'statement' in the name.. ie
> >      typedef gimple_statement_call *gimple_call;
> > That seems in line with what we do with 'gimple' right now and the short 
> > form is the type we'd normally use.
> > 
> > That adds a touch of difficulty with "as_a", since that requires the 
> > type name, not the shorthand pointer.... so you have something like
> > gimple_call call = as_a <gimple_statement_call> blah().
> > I think as the changes to use the gimple_call type are pushed through 
> > all the callers and callee's, the requirement of as_a and the long name 
> > being ugly begins to rapidly disappear...  it'll only exist in the core 
> > creation routines and no one will usually see it.   So I don't *think* 
> > this is an issue...  but it is an ugly transition if its only partially 
> > done.
> 
> (nods)
> 
> > And eventually we can pull the accessor routines and others into the 
> > class itself:
> >         gimple_call call;
> >         call = gimple_build_call_vec (build_fold_addr_expr_loc (0, 
> > alias), vargs);
> >         call->set_lhs (atree);
> 
> Nice.  It's readable (IMHO), and the type-checking (that it's a call) is
> enforced at compile-time, rather than at run-time (and only in
> ENABLE_CHECKING builds).

Well, if you never need to downcast its always enforced by the type
system.

> Sadly, this may need some further gengtype work: the simple inheritance
> support I'm using in this patch series will barf if it sees methods
> within a class.  So I can have a look at supporting methods in gengtype,
> I guess.   Though the change above of gimple_call_set_lhs to accepting a
> subclass ptr gives a middle-ground.

hm, I have a patch around that adds member functions to symtab_node and
gentype doesn't fall over on it, is it just sub classes maybe?

 Anyway to avoid churn multiple times / ugly intermediates what I think
 we should do is:

 1. add methods to the sub classes as appropriate (fixing gentype first
 if needed).
 2. change creator functions to return dirived types.
 3. when we already have the sub type replace the function with the
 method.
 4. when all uses of the function are gone remove it.

> > that don't have them now, like gimple_statement_assign. Its lumped in as 
> > a general GSS_WITH_MEM_OPS, so there is no gimple_statement_assign 
> > class/struct to use.
> 
> > It would really be nice to use the DEFGSCODE macro and gimple.def to 
> > make this happen automagically somehow... Its tantalizingly close now I 
> > think, especially combined with the info in gsstruct.def... Although if 
> > we are moving to proper classes eventually its probably better to 
> > explicitly write the required class for a statement kind.
> 
> I think writing them out explicitly is better than doing them with
> preprocessor magic: if we go down the route described above of wanting
> to add methods, the various subclasses will eventually gain their own
> methods, so we'll want code rather than building it all from .def files.

agreed.

> > That all said, this change enables that work to proceed if someone wants 
> > to do it.
> > 
> > My question is: Is anyone going to do it, and if so,  who and when? :-)
> 
> I'd be up for working on a followup patch that adds such subclasses, and
> I'd be up for changing the accessors to give up compile-time
> type-safety.  I'd do it one accessor at a time.

I'd be happy to work on this too.

> > > Again, as noted in the earlier patch series, the names of the structs
> > > are rather verbose.  I would prefer to also rename them all to eliminate
> > > the "_statement" component:
> > >    "gimple_statement_base" -> "gimple_base"
> > >    "gimple_statement_phi"  -> "gimple_phi"
> > >    "gimple_statement_omp"  -> "gimple_omp"
> > > etc, but I didn't do this to mimimize the patch size.  But if the core
> > > maintainers are up for that, I can redo the patch series with that
> > > change also, or do that as a followup.
> > 
> > As mentioned, I'd rather see the short names be typedefs for pointers to 
> > the long names since we're typically using the pointers.
> 
> [FWIW, I'm not a fan of such typedefs, but I'll defer to you in this]

agreed, especially since C++ lets us omit the struct / class part
anyway.

Trev

> Also, I take it we'd use the "printable_name" from gimple.def - though
> would we use it for the subclass name, or for the ptr typedef?
> 
> > Other than stomping on the same bits at the moment (less so once 
> > gimple-stmt.[ch] is split out), these changes are completely orthogonal, 
> > but in line with with my direction.  I think It should be done sooner or 
> > later....  My preference is to also see the follow up work carried out 
> > as well.  Or at least a plan for it.
> 
> So you like the approach, provided I commit to the followup work? [1]
> 
> OK, I'll try to create some followup patches next week.  I'd prefer to
> get the conversion to inheritance into trunk sooner rather than later,
> though.
> 
> Thanks for looking at this (and for your cleanup work!)
> 
> Dave
> [1] and the patches still need formal review.
> 

  reply	other threads:[~2013-11-01 23:43 UTC|newest]

Thread overview: 116+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-31  5:45 RFC: gimple.[ch] break apart Andrew MacLeod
2013-10-31  6:15 ` Jeff Law
2013-10-31 16:41 ` [PATCH 0/6] Conversion of gimple types to C++ inheritance (v3) David Malcolm
2013-10-31 16:27   ` [PATCH 2/6] Hand-written port of various accessors within gimple.h David Malcolm
2013-11-14  9:53     ` Jeff Law
2013-10-31 16:27   ` [PATCH 4/6] Implement is_a_helper <>::test specializations for various gimple types David Malcolm
2013-11-14  9:41     ` Jeff Law
2013-11-18 19:51       ` David Malcolm
2013-11-18 20:10         ` Andrew MacLeod
2013-11-18 20:15         ` Jeff Law
2013-10-31 16:27   ` [PATCH 1/6] Convert gimple types from a union to C++ inheritance David Malcolm
2013-11-14 23:00     ` Jeff Law
2013-11-19  0:22       ` David Malcolm
2013-11-19  8:49         ` Jeff Law
2013-10-31 16:31   ` [PATCH 3/6] Automated part of conversion of gimple types to use " David Malcolm
2013-11-14  9:43     ` Jeff Law
2013-11-18 22:17       ` [PATCH] Updated automated patch (was Re: [PATCH 3/6] Automated part of conversion of gimple types to use C++ inheritance) David Malcolm
2013-11-19  8:49         ` Jeff Law
2013-11-19 16:36           ` David Malcolm
2013-11-22  0:27         ` Jakub Jelinek
2013-11-22  0:35           ` Jeff Law
2013-11-22  1:51             ` Jakub Jelinek
2013-11-22  2:52               ` Andrew MacLeod
2013-11-22  3:48                 ` David Malcolm
2013-11-25 18:09                 ` [PATCH] Fix checking of gimple types David Malcolm
2013-11-25 18:42                   ` Michael Matz
2013-11-25 22:18                   ` Jeff Law
2013-11-27  8:54                     ` David Malcolm
2014-07-23 13:16                   ` Thomas Schwinge
2014-07-24  1:50                     ` David Malcolm
2014-07-29  8:11                       ` Thomas Schwinge
2013-10-31 16:46   ` [PATCH 6/6] Update gdb hooks to reflect changes to " David Malcolm
2013-11-14  9:10     ` Jeff Law
2013-10-31 16:49   ` [PATCH 5/6] Port various places from union access to subclass access David Malcolm
2013-11-14  9:23     ` Jeff Law
2013-11-19  0:52       ` David Malcolm
2013-10-31 18:43   ` [PATCH 0/6] Conversion of gimple types to C++ inheritance (v3) Basile Starynkevitch
2013-11-01 21:36   ` Andrew MacLeod
2013-11-01 21:41     ` Jakub Jelinek
2013-11-01 21:47       ` Andrew MacLeod
2013-11-01 21:57         ` Jakub Jelinek
2013-11-01 22:58           ` David Malcolm
2013-11-04 13:23             ` Andrew MacLeod
2013-11-04 21:52               ` David Malcolm
2013-11-04 22:09                 ` David Malcolm
2013-11-04 22:31                   ` Andrew MacLeod
2013-11-05 21:27                     ` Jeff Law
2013-11-04 22:43                   ` Andrew MacLeod
2013-11-04 22:28                 ` Jakub Jelinek
2013-11-04 22:49                   ` Andrew MacLeod
2013-11-05 21:09                   ` Jeff Law
2013-11-05 11:53                 ` Richard Biener
2013-11-05 12:33                   ` David Malcolm
2013-11-05 12:52                     ` Richard Biener
2013-11-04 14:00           ` Andrew MacLeod
2013-11-04 14:01             ` Jakub Jelinek
2013-11-04 14:15               ` Andrew MacLeod
2013-11-04 18:23       ` Jeff Law
2013-11-01 22:43     ` David Malcolm
2013-11-01 23:43       ` Trevor Saunders [this message]
2013-11-04 13:15       ` Andrew MacLeod
2013-11-05 17:23     ` [PATCH] Add gimple subclasses for every gimple code (was Re: [PATCH 0/6] Conversion of gimple types to C++ inheritance (v3)) David Malcolm
2013-11-06 16:53       ` Michael Matz
2013-11-07  6:19         ` David Malcolm
2013-11-07  7:08           ` Jeff Law
2013-11-08 19:23             ` David Malcolm
2013-11-14  8:38               ` Jeff Law
2013-11-14 15:06                 ` Michael Matz
2013-11-14 18:32                 ` David Malcolm
2013-11-15  2:49                   ` Jeff Law
2013-11-07 14:57           ` Michael Matz
2013-11-08  0:07         ` Alec Teal
2013-11-08 14:31           ` Michael Matz
2013-11-05 18:22     ` [PATCH 0/6] Conversion of gimple types to C++ inheritance (v3) Andrew MacLeod
2013-11-05 21:33   ` Jeff Law
2013-11-05 22:01     ` David Malcolm
2013-11-05 22:17       ` Jeff Law
2013-11-06  1:14         ` Ian Lance Taylor
2013-11-06 20:49           ` Jeff Law
2013-11-06 20:57             ` Trevor Saunders
2013-11-05 22:24       ` Andrew MacLeod
2013-11-05 22:12     ` Andrew MacLeod
2013-11-06  9:37     ` Richard Biener
2013-11-06 11:20       ` Bernd Schmidt
2013-11-06 11:43         ` Richard Biener
2013-11-06 11:53           ` Jakub Jelinek
2013-11-06 13:14             ` Richard Biener
2013-11-06 13:23               ` Jakub Jelinek
2013-11-06 16:42                 ` David Malcolm
2013-11-06 16:55                   ` Jakub Jelinek
2013-11-06 18:34                     ` Tom Tromey
2013-11-06 19:15                       ` Jeff Law
2013-11-06 20:05                         ` Tom Tromey
2013-11-06 20:45                           ` Jeff Law
2013-11-06 13:31             ` Joseph S. Myers
2013-11-06 21:25               ` Jeff Law
2013-11-06 21:09             ` Jeff Law
2013-11-06 12:42           ` Bernd Schmidt
2013-11-06 21:04           ` Jeff Law
2013-11-06 21:06           ` Andrew MacLeod
2013-11-06 21:52             ` Jeff Law
2013-11-07 10:29             ` Richard Biener
2013-11-07 14:01               ` Joseph S. Myers
2013-11-07 14:42                 ` Richard Biener
2013-11-07 14:53               ` Andrew MacLeod
2013-11-10 12:35             ` Richard Sandiford
2013-11-10 15:27               ` Richard Biener
2013-11-06 11:56         ` Eric Botcazou
2013-11-06 20:51         ` Jeff Law
2013-11-06 21:26       ` Jeff Law
2013-11-14  8:40   ` Jeff Law
2013-11-05 16:58 ` [patch] Create gimple-expr..[ch] ... was Re: RFC: gimple.[ch] break apart Andrew MacLeod
2013-11-05 17:52   ` Jeff Law
2013-11-07 10:58   ` Basile Starynkevitch
2013-11-07 13:47     ` Andrew MacLeod
2013-11-07 18:13       ` Diego Novillo

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=20131101234319.GB2102@tsaunders-iceball.corp.tor1.mozilla.com \
    --to=tsaunders@mozilla.com \
    --cc=amacleod@redhat.com \
    --cc=dmalcolm@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    /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).