public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andrew MacLeod <amacleod@redhat.com>
To: Lawrence Crowl <crowl@googlers.com>
Cc: "gcc@gcc.gnu.org" <gcc@gcc.gnu.org>
Subject: Re: Simplifying Gimple Generation
Date: Tue, 20 Nov 2012 16:49:00 -0000	[thread overview]
Message-ID: <50ABB494.9030202@redhat.com> (raw)
In-Reply-To: <CAGqM8fZbnET=4GGrBt-sXJ-jweTxYYLAGdaYuzK2HfiwCi7K=A@mail.gmail.com>

On 11/14/2012 08:13 PM, Lawrence Crowl wrote:
> Diego and I seek your comments on the following (loose) proposal.
>
>
>
> We propose a simplified form using new build helper classes ssa_seq
> and ssa_stmt that would allow the above code to be written as
> follows.
>
> ssa_seq q;
> ssa_stmt t = q.stmt (NE_EXPR, shadow, 0);
> ssa_stmt a = q.stmt (BIT_AND_EXPR, base_addr, 7);
> ssa_stmt b = q.stmt (shadow_type, a);
> ssa_stmt c = q.stmt (PLUS_EXPR, b, offset);
> ssa_stmt d = q.stmt (GE_EXPR, c, shadow);
> ssa_stmt e = q.stmt (BIT_AND_EXPR, t, d);
> q.set_location (location);
> r = e.lhs ();
<...>
>
> There will be another class of builders for generating GIMPLE
> in normal form (gimple_stmt).  We expect that this will mostly
> affect all transformations that need to generate new expressions
> and statements, like instrumentation passes.
I certainly like the general idea.

Have you actually sat down and worked out the interface?  Do we really 
need a set of SSA *and* a set of gimple routines? I fooled around with a 
few variations and it doesn't seem like we should.

It seems to me that SSA is just a specialization of gimple, so I would 
think maybe a very small set of SSA specializations could be applied to 
the gimple interface.   All the statement linking, manipulation and 
accessing is identical, so maybe something as simple as making the 
stmt() method have 2 variations on whether you want SSA results or not 
in the gimple expression.

GimpleSeq q;
GimpleStmt t = q.ssa_stmt (NE_EXPR, shadow, 0);
GimpleStmt a = q.ssa_stmt (BIT_AND_EXPR, base_addr, 7);
GimpleStmt b = q.ssa_stmt (shadow_type, a);

Any accesses to 'a' when you are generating code is going to pick up the LHS of the expression, whether its SSA or not. So if you want gimple generated instead of SSA, you do something like
GimpleStmt b = q.gimple_stmt (shadow_type, a);  // result is just a gimple temp insterad of ssa temp

And would the GimpleStmt class give you access to ALL the gimple_YYY access routines?  ie,  b.has_ops() instead of gimple_has_ops (b)

This would certainly help pave the way for replacing the gimple data structure with a proper object eventually.

The GinmpleSeq object which affects everything in the sequence... I presume there is just a subset of the methods which would be available.. ie set_use_ops() would clearly not make sense. Have you enumerated which routines that would be, or just leave that until its actually implemented?

We may find there are other interesting uses of the GimpelSeq object along the way as well.


>
> We also expect to reduce calls to tree expression builders by
> allowing the use of numeric and string constants to be converted
> to the appropriate tree _CST node.  This will only work when the
> type of the constant can be deduced from the other argument in some
> expressions, of course.
>
<...>

I think this would be great.. I find I'm constantly having to look up 
the right thing to do and it annoys me to no end that I cant just say 0 
when I mean 0. or "a string". I have to look up the correct way to get 
everything back as well...
>
> Proposal
>
> Create a set of IL builder classes that provide a simplified IL
> building interface.  Essentially, these builder classes will abstract
> most of the bookkeeping code required by the current interfaces.
>
> These classes will not replace the existing interfaces.  We do not
> expect that all the IL generation done in current transformations
> will be able to use the simplified interfaces.  The goal is to
> simplify most of them, however.
The long term goal *would* be a complete replacement, so as long as that 
is kept in mind and these changes help move in that direction, then I 
think the effort is worthwhile.

Andrew



  parent reply	other threads:[~2012-11-20 16:49 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-15  1:13 Lawrence Crowl
2012-11-15  6:06 ` Basile Starynkevitch
2012-11-15 19:34   ` Lawrence Crowl
2012-11-16 13:15   ` Diego Novillo
2012-11-15  7:32 ` Xinliang David Li
2012-11-16 13:13   ` Diego Novillo
2012-11-17  1:05     ` Xinliang David Li
2012-11-15 14:48 ` Michael Matz
2012-11-15 16:52   ` Gabriel Dos Reis
2012-11-15 17:01     ` Michael Matz
2012-11-15 17:07       ` Xinliang David Li
2012-11-15 19:59   ` Lawrence Crowl
2012-11-16 12:44     ` Michael Matz
2012-11-16 13:59   ` Diego Novillo
2012-11-16 14:30     ` Michael Matz
2012-11-16 17:31       ` Andrew Pinski
2012-11-20 16:49 ` Andrew MacLeod [this message]
2012-11-25  1:35 ` 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=50ABB494.9030202@redhat.com \
    --to=amacleod@redhat.com \
    --cc=crowl@googlers.com \
    --cc=gcc@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).