public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Design Considerations of GIMPLE Front End
@ 2010-05-17 20:21 Sandeep Soni
  2010-05-17 21:04 ` Andrew Haley
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Sandeep Soni @ 2010-05-17 20:21 UTC (permalink / raw)
  To: GCC LIST; +Cc: Diego Novillo

Hi,

As part of GSoC 2010, I am developing a front end for GIMPLE.
You can find the basic theme of the project at:
http://gcc.gnu.org/wiki/GimpleFrontEnd

One of the most important components in this GIMPLE Front End is to
convert the GIMPLE tuples into text.
How such a textual representation should be, will obviously dictate
the design and complexity of the
subsequent parsing component. So, as per Diego's suggestion, to have a
view on some of the issues
I have started this thread.

Following are some of the issues/questions that have come  up:

1. What should be the format of representation of the GIMPLE tuples in text?

   Ideally, the textual representation should be satisfying two goals:
Easy to parse and easy for a programmer
   to write by hand.Considering this,what is the best way in which the
GIMPLE tuples be represented.

   For example:
   A textual GIMPLE tuple for the statement a=b+c can be like
   <GIMPLE_ASSIGN<PLUS_EXPR,a,b,c>>  (As demonstrated by the internal
manual also).
   Is such a representation easy to parse?

   The other alternative is to represent the tuples in a C-like syntax
much like what -fdump-tree-gimple flag does.

   Which is more better? In terms of ease in parsing, intuitiveness
for a programmer to code by hand etc.
   Any other alternative?

2. The most important aspect in the representation is that of types.
Since there are many possibilities in
   the types, mapping each in a common representation can be
difficult. An approach suggested by Diego is to
   read what fields are read from 'tree' structures and then lay out
the tuples as follows:

   <TREE_TYPE <name, size, ...>>

   So, we make all the sub-structures into nested tuples. This seems
to be easy to parse.
   Again the question: Are there any ideas from anybody about the way
the types be
   represented so that the parsing becomes simple?

3. Finally, what could be the overall structure of such a textual
gimple file. A possible way could be to have the
    same structure as the sections encoded in the bytestream.So we can
have a section for types, symbols,
    function bodies etc. Such a simple structure will be helpful for
any programmer and be relatively easy to parse.
    Any other ideas? arguments against such a structure?


So, If there are any alternative ideas to any one of these or
arguments in favour of /against the ideas presented
in this mail. Please add it to this thread.

If there are any more vital points which are missing in this mail but
require serious discussions,
please add them to this thread too.
--
Cheers
Sandy

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Design Considerations of GIMPLE Front End
  2010-05-17 20:21 Design Considerations of GIMPLE Front End Sandeep Soni
@ 2010-05-17 21:04 ` Andrew Haley
  2010-05-18  3:25   ` Sandeep Soni
  2010-05-18 13:18 ` Diego Novillo
  2010-06-04  8:24 ` Sebastian Pop
  2 siblings, 1 reply; 16+ messages in thread
From: Andrew Haley @ 2010-05-17 21:04 UTC (permalink / raw)
  To: gcc

On 05/17/2010 09:15 PM, Sandeep Soni wrote:
> Hi,
> 
> As part of GSoC 2010, I am developing a front end for GIMPLE.
> You can find the basic theme of the project at:
> http://gcc.gnu.org/wiki/GimpleFrontEnd
> 
> One of the most important components in this GIMPLE Front End is to
> convert the GIMPLE tuples into text.
> How such a textual representation should be, will obviously dictate
> the design and complexity of the
> subsequent parsing component. So, as per Diego's suggestion, to have a
> view on some of the issues
> I have started this thread.
> 
> Following are some of the issues/questions that have come  up:
> 
> 1. What should be the format of representation of the GIMPLE tuples in text?
> 
>    Ideally, the textual representation should be satisfying two goals:
> Easy to parse and easy for a programmer
>    to write by hand.Considering this,what is the best way in which the
> GIMPLE tuples be represented.
> 
>    For example:
>    A textual GIMPLE tuple for the statement a=b+c can be like
>    <GIMPLE_ASSIGN<PLUS_EXPR,a,b,c>>  (As demonstrated by the internal
> manual also).
>    Is such a representation easy to parse?

S-expressions are easier to parse and more compact, and are consistent
with gcc's back end.  Also, there are editors that already know how to
edit and indent S-expressions.

Andrew.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Design Considerations of GIMPLE Front End
  2010-05-17 21:04 ` Andrew Haley
@ 2010-05-18  3:25   ` Sandeep Soni
  2010-05-18  8:39     ` Andrew Haley
  0 siblings, 1 reply; 16+ messages in thread
From: Sandeep Soni @ 2010-05-18  3:25 UTC (permalink / raw)
  To: GCC LIST

On Tue, May 18, 2010 at 2:34 AM, Andrew Haley <aph@redhat.com> wrote:

>>    For example:
>>    A textual GIMPLE tuple for the statement a=b+c can be like
>>    <GIMPLE_ASSIGN<PLUS_EXPR,a,b,c>>  (As demonstrated by the internal
>> manual also).
>>    Is such a representation easy to parse?
>
> S-expressions are easier to parse and more compact, and are consistent
> with gcc's back end.  Also, there are editors that already know how to
> edit and indent S-expressions.

Thanks Andrew . Any thoughts on the 3rd point?

>
> Andrew.
>



-- 
Cheers
Sandy

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Design Considerations of GIMPLE Front End
  2010-05-18  3:25   ` Sandeep Soni
@ 2010-05-18  8:39     ` Andrew Haley
  0 siblings, 0 replies; 16+ messages in thread
From: Andrew Haley @ 2010-05-18  8:39 UTC (permalink / raw)
  To: gcc

On 05/18/2010 04:24 AM, Sandeep Soni wrote:
> On Tue, May 18, 2010 at 2:34 AM, Andrew Haley <aph@redhat.com> wrote:
> 
>>>    For example:
>>>    A textual GIMPLE tuple for the statement a=b+c can be like
>>>    <GIMPLE_ASSIGN<PLUS_EXPR,a,b,c>>  (As demonstrated by the internal
>>> manual also).
>>>    Is such a representation easy to parse?
>>
>> S-expressions are easier to parse and more compact, and are consistent
>> with gcc's back end.  Also, there are editors that already know how to
>> edit and indent S-expressions.
> 
> Thanks Andrew . Any thoughts on the 3rd point?

Your suggestion for 3 is perfectly sensible, and is a good way to
start.

It's quite possible that, whatever you do, you'll find that the file
structure will need to be changed, so it makes sense to do something
as simple and straightforward as possible.  If your code is
well-factored it can be reorganized later.

Andrew.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Design Considerations of GIMPLE Front End
  2010-05-17 20:21 Design Considerations of GIMPLE Front End Sandeep Soni
  2010-05-17 21:04 ` Andrew Haley
@ 2010-05-18 13:18 ` Diego Novillo
  2010-05-18 14:00   ` Michael Matz
  2010-06-04  8:24 ` Sebastian Pop
  2 siblings, 1 reply; 16+ messages in thread
From: Diego Novillo @ 2010-05-18 13:18 UTC (permalink / raw)
  To: Sandeep Soni; +Cc: GCC LIST

On Mon, May 17, 2010 at 16:15, Sandeep Soni <soni.sandeepb@gmail.com> wrote:

> 1. What should be the format of representation of the GIMPLE tuples in text?

I liked Andrew's suggestion about S-expressions.  It looks like a good
balance between ease of parsing/writing.  We can always tweak the
format as we go.

As for points 2 and 3, I'd suggest start documenting the grammar for
types and sections on the wiki.  That will expose some shortcomings
early on before any code is written.


Diego.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Design Considerations of GIMPLE Front End
  2010-05-18 13:18 ` Diego Novillo
@ 2010-05-18 14:00   ` Michael Matz
  2010-05-18 14:09     ` Diego Novillo
  2010-05-18 14:30     ` Basile Starynkevitch
  0 siblings, 2 replies; 16+ messages in thread
From: Michael Matz @ 2010-05-18 14:00 UTC (permalink / raw)
  To: Diego Novillo; +Cc: Sandeep Soni, GCC LIST

Hi,

On Tue, 18 May 2010, Diego Novillo wrote:

> On Mon, May 17, 2010 at 16:15, Sandeep Soni <soni.sandeepb@gmail.com> wrote:
> 
> > 1. What should be the format of representation of the GIMPLE tuples in 
> >    text?
> 
> I liked Andrew's suggestion about S-expressions.

I can see that for describing types, maybe.  But isn't that artificially 
awkward for representing tuple instructions?  I mean most instructions 
will look like

  (= i_1 (+ k_1 m_1))
or
  (= j_1 (call func arg1 arg2))

I don't see how that is much easier to parse compared to
  i_1 = k_1 + m_1
  j_1 = func (arg1, arg2)

The nice thing with tuples is that there's always only one operator, and 
hence no ambiguity in precedence that needs to be resolved or explicitely 
encoded via a list structure.

Or is the format also intended to be able to represent GENERIC, i.e. 
deeply nested structures?


Ciao,
Michael.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Design Considerations of GIMPLE Front End
  2010-05-18 14:00   ` Michael Matz
@ 2010-05-18 14:09     ` Diego Novillo
  2010-05-18 14:18       ` Steven Bosscher
  2010-05-18 14:30     ` Basile Starynkevitch
  1 sibling, 1 reply; 16+ messages in thread
From: Diego Novillo @ 2010-05-18 14:09 UTC (permalink / raw)
  To: Michael Matz; +Cc: Sandeep Soni, GCC LIST

On Tue, May 18, 2010 at 09:59, Michael Matz <matz@suse.de> wrote:

> I don't see how that is much easier to parse compared to
>  i_1 = k_1 + m_1
>  j_1 = func (arg1, arg2)

Well, it would make the parser almost trivial to implement.  But you
have a point, the only structurally complex objects we need to parse
are type declarations.  Everything else should have very uniform
syntax.

> The nice thing with tuples is that there's always only one operator, and
> hence no ambiguity in precedence that needs to be resolved or explicitely
> encoded via a list structure.

That's true.

> Or is the format also intended to be able to represent GENERIC, i.e.
> deeply nested structures?

No, just gimple.


Diego.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Design Considerations of GIMPLE Front End
  2010-05-18 14:09     ` Diego Novillo
@ 2010-05-18 14:18       ` Steven Bosscher
  2010-05-18 14:46         ` Dave Korn
  0 siblings, 1 reply; 16+ messages in thread
From: Steven Bosscher @ 2010-05-18 14:18 UTC (permalink / raw)
  To: Diego Novillo; +Cc: Michael Matz, Sandeep Soni, GCC LIST

On Tue, May 18, 2010 at 4:09 PM, Diego Novillo <dnovillo@google.com> wrote:
> On Tue, May 18, 2010 at 09:59, Michael Matz <matz@suse.de> wrote:
>
>> I don't see how that is much easier to parse compared to
>>  i_1 = k_1 + m_1
>>  j_1 = func (arg1, arg2)
>
> Well, it would make the parser almost trivial to implement.  But you
> have a point, the only structurally complex objects we need to parse
> are type declarations.  Everything else should have very uniform
> syntax.
>
>> The nice thing with tuples is that there's always only one operator, and
>> hence no ambiguity in precedence that needs to be resolved or explicitely
>> encoded via a list structure.
>
> That's true.
>
>> Or is the format also intended to be able to represent GENERIC, i.e.
>> deeply nested structures?
>
> No, just gimple.

IMHO, ideally we would have a syntax that is human readable and human
writable. S-expressions are not as easy to read for me as something
that resembles C.

Related subject: Is it possible to have a formal grammar of some kind
for, say, bison? It would be nice if we can generate different tools
from one grammar, e.g. a GIMPLE front end, a syntax checker, maybe
static analyzers, etc. If you make a reader that already constructs
the gimple data structures, it will be harder to construct multiple
tools on top of it that are independent of libbackend.

Ciao!
Steven

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Design Considerations of GIMPLE Front End
  2010-05-18 14:00   ` Michael Matz
  2010-05-18 14:09     ` Diego Novillo
@ 2010-05-18 14:30     ` Basile Starynkevitch
  2010-05-18 14:32       ` Richard Guenther
  2010-05-18 14:47       ` Steven Bosscher
  1 sibling, 2 replies; 16+ messages in thread
From: Basile Starynkevitch @ 2010-05-18 14:30 UTC (permalink / raw)
  To: Michael Matz; +Cc: Diego Novillo, Sandeep Soni, GCC LIST

On Tue, 2010-05-18 at 15:59 +0200, Michael Matz wrote:
> Hi,
> 
> On Tue, 18 May 2010, Diego Novillo wrote:
> 
> > On Mon, May 17, 2010 at 16:15, Sandeep Soni <soni.sandeepb@gmail.com> wrote:
> > 
> > > 1. What should be the format of representation of the GIMPLE tuples in 
> > >    text?
> > 
> > I liked Andrew's suggestion about S-expressions.
> 
> I can see that for describing types, maybe.  But isn't that artificially 
> awkward for representing tuple instructions?  I mean most instructions 
> will look like
> 
>   (= i_1 (+ k_1 m_1))
> or
>   (= j_1 (call func arg1 arg2))
> 
> I don't see how that is much easier to parse compared to
>   i_1 = k_1 + m_1
>   j_1 = func (arg1, arg2)

My intuition might be that once a Gimple parser exists, most of its use
would be writing various translators (e.g. external front-ends) to this
syntax, so people might probably code more Gimple-syntax printers than
Gimple-syntax parsers.

Still, I prefer the Lispy S-expression syntax everywhere -including
Gimple- because it is so simple to define and to implement, and because
GCC MELT already have [almost] the infrastructure for it.

However, I tend to think that the Gimple syntax would also [at least
optionally] contain the location information, so it would be instead
   (= (@ "foo.cobol" 23 2) i_1 (+ k_1 m_1)))
or even
   (= (@ "foo.cobol" 23 3) i_1 (+ (@ "foo.cobol" 23 5) k_1 m_1)))
I am using, perhaps wrongly, @ as an "operator" giving the location
information as a file name, line number, column number. I am not sure to
have the syntax right (because I am not sure to remember what exactly
has a location information).

I believe a Gimple-syntax should provide the features (or hooks, or
syntax) to convey all the Gimple information, and this includes the
source file location. This is needed both for external (GPLv3+ or
compatibly licensed) programs producing Gimple (such as an hypothetical
Cobol frontend) and for external (GPLv3+ or compatibly licensed)
programs consuming Gimple (like sophisticated static analyzers) or for
external programs both consuming & producing Gimple (e.g. an
"optimization" implemented by an external program).

Otherwise, what is the purpose of Gimple-syntax? Why making it if it
does not contain all the information inside GCC?


BTW, is it possible today to have a GCC plugin providing a front-end to
GCC? [last time I looked, I believe the answer is no]

Cheers.


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Design Considerations of GIMPLE Front End
  2010-05-18 14:30     ` Basile Starynkevitch
@ 2010-05-18 14:32       ` Richard Guenther
  2010-05-18 14:47       ` Steven Bosscher
  1 sibling, 0 replies; 16+ messages in thread
From: Richard Guenther @ 2010-05-18 14:32 UTC (permalink / raw)
  To: basile; +Cc: Michael Matz, Diego Novillo, Sandeep Soni, GCC LIST

On Tue, May 18, 2010 at 4:30 PM, Basile Starynkevitch
<basile@starynkevitch.net> wrote:
> On Tue, 2010-05-18 at 15:59 +0200, Michael Matz wrote:
>> Hi,
>>
>> On Tue, 18 May 2010, Diego Novillo wrote:
>>
>> > On Mon, May 17, 2010 at 16:15, Sandeep Soni <soni.sandeepb@gmail.com> wrote:
>> >
>> > > 1. What should be the format of representation of the GIMPLE tuples in
>> > >    text?
>> >
>> > I liked Andrew's suggestion about S-expressions.
>>
>> I can see that for describing types, maybe.  But isn't that artificially
>> awkward for representing tuple instructions?  I mean most instructions
>> will look like
>>
>>   (= i_1 (+ k_1 m_1))
>> or
>>   (= j_1 (call func arg1 arg2))
>>
>> I don't see how that is much easier to parse compared to
>>   i_1 = k_1 + m_1
>>   j_1 = func (arg1, arg2)
>
> My intuition might be that once a Gimple parser exists, most of its use
> would be writing various translators (e.g. external front-ends) to this
> syntax, so people might probably code more Gimple-syntax printers than
> Gimple-syntax parsers.
>
> Still, I prefer the Lispy S-expression syntax everywhere -including
> Gimple- because it is so simple to define and to implement, and because
> GCC MELT already have [almost] the infrastructure for it.
>
> However, I tend to think that the Gimple syntax would also [at least
> optionally] contain the location information, so it would be instead
>   (= (@ "foo.cobol" 23 2) i_1 (+ k_1 m_1)))
> or even
>   (= (@ "foo.cobol" 23 3) i_1 (+ (@ "foo.cobol" 23 5) k_1 m_1)))
> I am using, perhaps wrongly, @ as an "operator" giving the location
> information as a file name, line number, column number. I am not sure to
> have the syntax right (because I am not sure to remember what exactly
> has a location information).

Yep, we also need to be able to specify the various flags on
gimple statements and information such as alias info.

At least if we eventually want to use this as a framework for
real unit-testing.  So I'm not too concerned about using
s-expressions even for the statements.

Richard.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Design Considerations of GIMPLE Front End
  2010-05-18 14:18       ` Steven Bosscher
@ 2010-05-18 14:46         ` Dave Korn
  2010-05-18 14:52           ` Andrew Haley
  0 siblings, 1 reply; 16+ messages in thread
From: Dave Korn @ 2010-05-18 14:46 UTC (permalink / raw)
  To: Steven Bosscher; +Cc: Diego Novillo, Michael Matz, Sandeep Soni, GCC LIST

On 18/05/2010 15:17, Steven Bosscher wrote:

> IMHO, ideally we would have a syntax that is human readable and human
> writable. S-expressions are not as easy to read for me as something
> that resembles C.

  I'd like it that way too, but I acknowledge that it would be more work and
it's not me who'd have to do that extra work...

    cheers,
      DaveK

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Design Considerations of GIMPLE Front End
  2010-05-18 14:30     ` Basile Starynkevitch
  2010-05-18 14:32       ` Richard Guenther
@ 2010-05-18 14:47       ` Steven Bosscher
  1 sibling, 0 replies; 16+ messages in thread
From: Steven Bosscher @ 2010-05-18 14:47 UTC (permalink / raw)
  To: basile; +Cc: Michael Matz, Diego Novillo, Sandeep Soni, GCC LIST

On Tue, May 18, 2010 at 4:30 PM, Basile Starynkevitch
<basile@starynkevitch.net> wrote:
> BTW, is it possible today to have a GCC plugin providing a front-end to
> GCC? [last time I looked, I believe the answer is no]

This is one of the reasons for my patches to better hide the
middle-end details from the front ends.

Ciao!
Steven

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Design Considerations of GIMPLE Front End
  2010-05-18 14:46         ` Dave Korn
@ 2010-05-18 14:52           ` Andrew Haley
       [not found]             ` <AANLkTilQWdLDrQypzwqbzTKsUYKyPKMvHMKVClFvZJWH@mail.gmail.com>
  0 siblings, 1 reply; 16+ messages in thread
From: Andrew Haley @ 2010-05-18 14:52 UTC (permalink / raw)
  To: gcc

On 05/18/2010 04:05 PM, Dave Korn wrote:
> On 18/05/2010 15:17, Steven Bosscher wrote:
> 
>> IMHO, ideally we would have a syntax that is human readable and human
>> writable. S-expressions are not as easy to read for me as something
>> that resembles C.
> 
>   I'd like it that way too, but I acknowledge that it would be more work and
> it's not me who'd have to do that extra work...

Well, it can always be changed later, but there's a lot to be said for
not spending time now writing a parser, and getting on with the project.
It's a matter of taste anyway.

Andrew.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Design Considerations of GIMPLE Front End
       [not found]             ` <AANLkTilQWdLDrQypzwqbzTKsUYKyPKMvHMKVClFvZJWH@mail.gmail.com>
@ 2010-05-18 15:04               ` Diego Novillo
  2010-05-18 15:24                 ` Sandeep Soni
  0 siblings, 1 reply; 16+ messages in thread
From: Diego Novillo @ 2010-05-18 15:04 UTC (permalink / raw)
  To: Andrew Haley; +Cc: gcc, Sandeep Soni

[ apologies for the duplicate message.  My previous reply was bounced
by the ML. ]

> On Tue, May 18, 2010 at 10:52, Andrew Haley <aph@redhat.com> wrote:
>>
>> On 05/18/2010 04:05 PM, Dave Korn wrote:
>> > On 18/05/2010 15:17, Steven Bosscher wrote:
>> >
>> >> IMHO, ideally we would have a syntax that is human readable and human
>> >> writable. S-expressions are not as easy to read for me as something
>> >> that resembles C.
>> >
>> >   I'd like it that way too, but I acknowledge that it would be more work and
>> > it's not me who'd have to do that extra work...
>>
>> Well, it can always be changed later, but there's a lot to be said for
>> not spending time now writing a parser, and getting on with the project.
>> It's a matter of taste anyway.
>
Yup.  This shade of blue can be changed later.  Sandi, let's start
with the S-expression syntax for everything.  Richard is correct in
pointing out that even gimple expressions have metadata associated
with them that will need to be represented.


Diego.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Design Considerations of GIMPLE Front End
  2010-05-18 15:04               ` Diego Novillo
@ 2010-05-18 15:24                 ` Sandeep Soni
  0 siblings, 0 replies; 16+ messages in thread
From: Sandeep Soni @ 2010-05-18 15:24 UTC (permalink / raw)
  To: Diego Novillo; +Cc: GCC LIST, Richard Guenther, Andrew Haley

On Tue, May 18, 2010 at 8:33 PM, Diego Novillo <dnovillo@google.com> wrote:

> Yup.  This shade of blue can be changed later.  Sandi, let's start
> with the S-expression syntax for everything.  Richard is correct in
> pointing out that even gimple expressions have metadata associated
> with them that will need to be represented.

Yes. I will start editing the wiki page created to document the S-expression
syntax and the grammar.

This will be an ongoing process though, in parallel with my current work of
getting familiar with the LTO code base, so might take some time earlier on.

>
>
> Diego.
>



-- 
Cheers
Sandy

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Design Considerations of GIMPLE Front End
  2010-05-17 20:21 Design Considerations of GIMPLE Front End Sandeep Soni
  2010-05-17 21:04 ` Andrew Haley
  2010-05-18 13:18 ` Diego Novillo
@ 2010-06-04  8:24 ` Sebastian Pop
  2 siblings, 0 replies; 16+ messages in thread
From: Sebastian Pop @ 2010-06-04  8:24 UTC (permalink / raw)
  To: Sandeep Soni; +Cc: GCC LIST, Diego Novillo

Hi,

On Mon, May 17, 2010 at 15:15, Sandeep Soni <soni.sandeepb@gmail.com> wrote:
> Hi,
>
> As part of GSoC 2010, I am developing a front end for GIMPLE.
> You can find the basic theme of the project at:
> http://gcc.gnu.org/wiki/GimpleFrontEnd
>
> One of the most important components in this GIMPLE Front End is to
> convert the GIMPLE tuples into text.
> How such a textual representation should be, will obviously dictate
> the design and complexity of the
> subsequent parsing component. So, as per Diego's suggestion, to have a
> view on some of the issues
> I have started this thread.
>
> Following are some of the issues/questions that have come  up:
>
> 1. What should be the format of representation of the GIMPLE tuples in text?
>
>   Ideally, the textual representation should be satisfying two goals:
> Easy to parse and easy for a programmer
>   to write by hand.Considering this,what is the best way in which the
> GIMPLE tuples be represented.
>
>   For example:
>   A textual GIMPLE tuple for the statement a=b+c can be like
>   <GIMPLE_ASSIGN<PLUS_EXPR,a,b,c>>  (As demonstrated by the internal
> manual also).
>   Is such a representation easy to parse?
>
>   The other alternative is to represent the tuples in a C-like syntax
> much like what -fdump-tree-gimple flag does.
>
>   Which is more better? In terms of ease in parsing, intuitiveness
> for a programmer to code by hand etc.
>   Any other alternative?
>
> 2. The most important aspect in the representation is that of types.
> Since there are many possibilities in
>   the types, mapping each in a common representation can be
> difficult. An approach suggested by Diego is to
>   read what fields are read from 'tree' structures and then lay out
> the tuples as follows:
>
>   <TREE_TYPE <name, size, ...>>
>
>   So, we make all the sub-structures into nested tuples. This seems
> to be easy to parse.
>   Again the question: Are there any ideas from anybody about the way
> the types be
>   represented so that the parsing becomes simple?
>
> 3. Finally, what could be the overall structure of such a textual
> gimple file. A possible way could be to have the
>    same structure as the sections encoded in the bytestream.So we can
> have a section for types, symbols,
>    function bodies etc. Such a simple structure will be helpful for
> any programmer and be relatively easy to parse.
>    Any other ideas? arguments against such a structure?
>
>
> So, If there are any alternative ideas to any one of these or
> arguments in favour of /against the ideas presented
> in this mail. Please add it to this thread.

Please have a look at the LLVM language specification:
http://llvm.org/docs/LangRef.html
that should give you a good intuition of what you need to represent
for GIMPLE, and how the LLVM file format is structured.

Would LLVM be acceptable to dump the GIMPLE representation?
In which case you would have an implementation of the pretty printer,
and you would need a parser of LLVM to get that representation back
to GCC.

Sebastian

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2010-06-03 23:34 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-17 20:21 Design Considerations of GIMPLE Front End Sandeep Soni
2010-05-17 21:04 ` Andrew Haley
2010-05-18  3:25   ` Sandeep Soni
2010-05-18  8:39     ` Andrew Haley
2010-05-18 13:18 ` Diego Novillo
2010-05-18 14:00   ` Michael Matz
2010-05-18 14:09     ` Diego Novillo
2010-05-18 14:18       ` Steven Bosscher
2010-05-18 14:46         ` Dave Korn
2010-05-18 14:52           ` Andrew Haley
     [not found]             ` <AANLkTilQWdLDrQypzwqbzTKsUYKyPKMvHMKVClFvZJWH@mail.gmail.com>
2010-05-18 15:04               ` Diego Novillo
2010-05-18 15:24                 ` Sandeep Soni
2010-05-18 14:30     ` Basile Starynkevitch
2010-05-18 14:32       ` Richard Guenther
2010-05-18 14:47       ` Steven Bosscher
2010-06-04  8:24 ` Sebastian Pop

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).