public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Building GENERIC trees
@ 2004-03-04 20:13 Tom Crick
  2004-03-05 18:11 ` law
  0 siblings, 1 reply; 9+ messages in thread
From: Tom Crick @ 2004-03-04 20:13 UTC (permalink / raw)
  To: gcc

Hi all,

I previously posted on the list asking about the potential of writing a GCC
front end for BCPL [see http://gcc.gnu.org/ml/gcc/2003-10/msg01064.html].

I'm at the stage now where I'm thinking about the best way to integrate with
GCC. During the parsing, would the best solution be to create my own AST along
the way and then write a 'genericise()' function to get in into a GENERIC form,
or to build GENERIC trees straight away. One of my biggest constraints at the
moment is time (as this is an undergraduate dissertation project), but I want to
ensure that the solution is elegant and if unfinished, I can explain what needs
to be done and how.

I'm leaning towards going straight to GENERIC trees, just for the simple fact
that it prevents having to write a 'genericise()' function and the need to
create my own AST - I'd have a documented format to aim towards. How complex is
it to build GENERIC trees, as I am mindful of having contingency plans if it
goes awry.

Thanks for your help,

Tom


Tom Crick
cs1tc@bath.ac.uk
Dept. of Computer Science
University of Bath
http://students.bath.ac.uk/cs1tc

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

* Re: Building GENERIC trees
  2004-03-04 20:13 Building GENERIC trees Tom Crick
@ 2004-03-05 18:11 ` law
  2004-03-05 18:23   ` Paul Brook
  2004-03-05 23:31   ` Tom Crick
  0 siblings, 2 replies; 9+ messages in thread
From: law @ 2004-03-05 18:11 UTC (permalink / raw)
  To: Tom Crick; +Cc: gcc

In message <1078431212.40478dec6ddeb@webmail.bath.ac.uk>, Tom Crick writes:
 >I'm leaning towards going straight to GENERIC trees, just for the simple fact
 >that it prevents having to write a 'genericise()' function and the need to
 >create my own AST - I'd have a documented format to aim towards. 
Creating generic directly would be my recommendation.

 > How complex is it to build GENERIC trees, as I am mindful of having
 > contingency plans if it goes awry.
Fairly simple if you start with GENERIC as your target.  It's harder to
retrofit if you've already got a large body of code which generates its
own AST.

The f95 front-end generates GENERIC trees directly and may be useful for
you to use as a reference.

jeff

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

* Re: Building GENERIC trees
  2004-03-05 18:11 ` law
@ 2004-03-05 18:23   ` Paul Brook
  2004-03-05 22:26     ` Kai Henningsen
  2004-03-05 23:31   ` Tom Crick
  1 sibling, 1 reply; 9+ messages in thread
From: Paul Brook @ 2004-03-05 18:23 UTC (permalink / raw)
  To: law, Tom Crick; +Cc: gcc

> The f95 front-end generates GENERIC trees directly and may be useful for
> you to use as a reference.

Not really. The f95 frontend does generate its own trees. It then translates 
them into GENERIC trees a function at a time as a seperate pass.

I agree that this is probably easier than building GENERIC+language extensions 
and lowering with genericise(). This is especially true if your language 
isn't very close to C.

Paul

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

* Re: Building GENERIC trees
  2004-03-05 18:23   ` Paul Brook
@ 2004-03-05 22:26     ` Kai Henningsen
  0 siblings, 0 replies; 9+ messages in thread
From: Kai Henningsen @ 2004-03-05 22:26 UTC (permalink / raw)
  To: gcc

paul@codesourcery.com (Paul Brook)  wrote on 05.03.04 in <200403051823.13994.paul@codesourcery.com>:

> > The f95 front-end generates GENERIC trees directly and may be useful for
> > you to use as a reference.
>
> Not really. The f95 frontend does generate its own trees. It then translates
> them into GENERIC trees a function at a time as a seperate pass.
>
> I agree that this is probably easier than building GENERIC+language
> extensions and lowering with genericise(). This is especially true if your
> language isn't very close to C.

Hmm. If BCPL is "not very close to C" then C has diverged pretty  
drastically from its beginnings. Which is possible, I guess.

I've never seen BCPL up close, but my impression is that semantically, it  
is rather close to "C without types".

MfG Kai

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

* Re: Building GENERIC trees
  2004-03-05 18:11 ` law
  2004-03-05 18:23   ` Paul Brook
@ 2004-03-05 23:31   ` Tom Crick
  2004-03-08 11:38     ` Lars Segerlund
  1 sibling, 1 reply; 9+ messages in thread
From: Tom Crick @ 2004-03-05 23:31 UTC (permalink / raw)
  To: law; +Cc: gcc

Quoting "" <law@redhat.com>:

> In message <1078431212.40478dec6ddeb@webmail.bath.ac.uk>, Tom Crick writes:
>  >I'm leaning towards going straight to GENERIC trees, just for the simple
> fact
>  >that it prevents having to write a 'genericise()' function and the need to
>  >create my own AST - I'd have a documented format to aim towards. 
> Creating generic directly would be my recommendation.
Good - I'm glad that it seems to be the best way!

>  > How complex is it to build GENERIC trees, as I am mindful of having
>  > contingency plans if it goes awry.
> Fairly simple if you start with GENERIC as your target.  It's harder to
> retrofit if you've already got a large body of code which generates its
> own AST.
Fair enough - it makes more sense to aim towards a set structure rather than
creating one of my own.

> The f95 front-end generates GENERIC trees directly and may be useful for
> you to use as a reference.
Is there a definition document for GENERIC? I've looked at the SSA for Trees
site [http://gnu.essentkabel.com/software/gcc/projects/tree-ssa/], but cannot
find an appropriate document. Where is the structure of GENERIC defined?

Thanks,

Tom

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

* Re: Building GENERIC trees
  2004-03-05 23:31   ` Tom Crick
@ 2004-03-08 11:38     ` Lars Segerlund
  2004-03-12 17:03       ` Building GENERIC trees and passing the symbol table Tom Crick
  0 siblings, 1 reply; 9+ messages in thread
From: Lars Segerlund @ 2004-03-08 11:38 UTC (permalink / raw)
  To: gcc


 Hi again, the thing about GENERIC is that it's not all that documented, however there were a thread about this a while ago on the gcc mailinglist, search through the archives and you will find a mail which states ' if it's not in these files then it's not GENERIC, ( and some files are named, fx. tree.h and some more ). I dare not give you an answer straight from my head because the probability of error is too large.

 / Lars Segerlund.


On Fri,  5 Mar 2004 23:31:31 +0000
Tom Crick <cs1tc@bath.ac.uk> wrote:

> Quoting "" <law@redhat.com>:
> 
> > In message <1078431212.40478dec6ddeb@webmail.bath.ac.uk>, Tom Crick writes:
> >  >I'm leaning towards going straight to GENERIC trees, just for the simple
> > fact
> >  >that it prevents having to write a 'genericise()' function and the need to
> >  >create my own AST - I'd have a documented format to aim towards. 
> > Creating generic directly would be my recommendation.
> Good - I'm glad that it seems to be the best way!
> 
> >  > How complex is it to build GENERIC trees, as I am mindful of having
> >  > contingency plans if it goes awry.
> > Fairly simple if you start with GENERIC as your target.  It's harder to
> > retrofit if you've already got a large body of code which generates its
> > own AST.
> Fair enough - it makes more sense to aim towards a set structure rather than
> creating one of my own.
> 
> > The f95 front-end generates GENERIC trees directly and may be useful for
> > you to use as a reference.
> Is there a definition document for GENERIC? I've looked at the SSA for Trees
> site [http://gnu.essentkabel.com/software/gcc/projects/tree-ssa/], but cannot
> find an appropriate document. Where is the structure of GENERIC defined?
> 
> Thanks,
> 
> Tom

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

* RE: Building GENERIC trees and passing the symbol table
  2004-03-08 11:38     ` Lars Segerlund
@ 2004-03-12 17:03       ` Tom Crick
  2004-03-12 17:24         ` Paul Brook
  0 siblings, 1 reply; 9+ messages in thread
From: Tom Crick @ 2004-03-12 17:03 UTC (permalink / raw)
  To: gcc; +Cc: 'Lars Segerlund'

> On Fri,  5 Mar 2004 23:31:31 +0000 Tom Crick <cs1tc@bath.ac.uk> wrote:
> 
> > Quoting "" <law@redhat.com>:
> > 
> > > In message <1078431212.40478dec6ddeb@webmail.bath.ac.uk>, Tom Crick
writes:  
>I'm leaning towards going straight to GENERIC trees, just 
> > > for the simple fact  >that it prevents having to write a 
> > > 'genericise()' function and the need to  >create my own AST - I'd 
> > > have a documented format to aim towards. Creating generic directly 
> > > would be my recommendation.
> > Good - I'm glad that it seems to be the best way!
> > 
> > >  > How complex is it to build GENERIC trees, as I am mindful of 
> > > having  > contingency plans if it goes awry. Fairly simple if you 
> > > start with GENERIC as your target.  It's harder to retrofit if 
> > > you've already got a large body of code which generates 
> its own AST.
> > Fair enough - it makes more sense to aim towards a set structure 
> > rather than creating one of my own.
> > 
> > > The f95 front-end generates GENERIC trees directly and may be useful 
> > > for you to use as a reference.
> > Is there a definition document for GENERIC? I've looked at the SSA for 
> > Trees site 
> > [http://gnu.essentkabel.com/software/gcc/projects/tree-ssa/], but 
> > cannot find an appropriate document. Where is the structure 
> of GENERIC 
> > defined?

> -----Original Message-----
> From: Lars Segerlund [mailto:lars.segerlund@comsys.se] 
> Sent: 08 March 2004 11:39
> To: gcc@gcc.gnu.org
> Subject: Re: Building GENERIC trees
> 
>  Hi again, the thing about GENERIC is that it's not all that 
> documented, however there were a thread about this a while 
> ago on the gcc mailinglist, search through the archives and 
> you will find a mail which states ' if it's not in these 
> files then it's not GENERIC, ( and some files are named, fx. 
> tree.h and some more ). I dare not give you an answer 
> straight from my head because the probability of error is too large.
> 
>  / Lars Segerlund.

Lovely, thanks for the pointer - I'll check out treelang in gcc-3.5 as well.


Also related to this, what is required with respect to the availability of
the symbol table? Would I have to pass my symbol table along with the
GENERIC tree? Does the symbol table have to be in any particular structure
or format?

Thanks again,

Tom


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

* Re: Building GENERIC trees and passing the symbol table
  2004-03-12 17:03       ` Building GENERIC trees and passing the symbol table Tom Crick
@ 2004-03-12 17:24         ` Paul Brook
  2004-04-12  2:31           ` Building GENERIC trees Tom Crick
  0 siblings, 1 reply; 9+ messages in thread
From: Paul Brook @ 2004-03-12 17:24 UTC (permalink / raw)
  To: cs1tc; +Cc: gcc


> >  Hi again, the thing about GENERIC is that it's not all that
> > documented, however there were a thread about this a while
> > ago on the gcc mailinglist, search through the archives and
> > you will find a mail which states ' if it's not in these
> > files then it's not GENERIC, ( and some files are named, fx.
> > tree.h and some more ). I dare not give you an answer
> > straight from my head because the probability of error is too large.
> >
> >  / Lars Segerlund.
>
> Lovely, thanks for the pointer - I'll check out treelang in gcc-3.5 as
> well.

tree.def contains a definitions of the tree nodes, tree.h contains macros for 
accessing them.

I wouldn't look too closely at either 3.5 or treelang. IIRC treelang has been 
removed on tree-ssa because the current implementation is so worthless.

> Also related to this, what is required with respect to the availability of
> the symbol table? Would I have to pass my symbol table along with the
> GENERIC tree? Does the symbol table have to be in any particular structure
> or format?

I think you basically just need to build and attach BLOCK nodes (containing 
declchains) to BIND_EXPR nodes.

That's what we do in gfortran anyway. See {push,pop}level and gfc_finish block 
in fortran/.

Paul

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

* Re: Building GENERIC trees
  2004-03-12 17:24         ` Paul Brook
@ 2004-04-12  2:31           ` Tom Crick
  0 siblings, 0 replies; 9+ messages in thread
From: Tom Crick @ 2004-04-12  2:31 UTC (permalink / raw)
  To: gcc; +Cc: Paul Brook

Quoting Paul Brook <paul@codesourcery.com>:
> > >  Hi again, the thing about GENERIC is that it's not all that
> > > documented, however there were a thread about this a while
> > > ago on the gcc mailinglist, search through the archives and
> > > you will find a mail which states ' if it's not in these
> > > files then it's not GENERIC, ( and some files are named, fx.
> > > tree.h and some more ). I dare not give you an answer
> > > straight from my head because the probability of error is too large.
> 
> tree.def contains a definitions of the tree nodes, tree.h contains macros for
> accessing them.

Hi all,

Apologies for replying to an old(ish) post, but wanted to ask some follow-up
questions after looking at tree.h and tree.def:

Where can I find the conversion of C trees into GENERIC (the famous 'genericize'
function), as I would like to build from this to see how I could build GENERIC
trees for BCPL.

Once GENERIC trees are built (in this case, probably for a subset of the BCPL
language), how do you go about linking them into the GCC chain - how do you
'latch-on' to the 'gimplification' and then into the back end?

Also, are there any plans for better documentation of GENERIC and GIMPLE e.g.
giving language definitions or a 'how to build GENERIC trees' guide? :-)

Thanks for your help.

Regards,

Tom

--
BCPL for GCC
http://sourceforge.net/projects/gccbcpl/

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

end of thread, other threads:[~2004-04-11 23:44 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-04 20:13 Building GENERIC trees Tom Crick
2004-03-05 18:11 ` law
2004-03-05 18:23   ` Paul Brook
2004-03-05 22:26     ` Kai Henningsen
2004-03-05 23:31   ` Tom Crick
2004-03-08 11:38     ` Lars Segerlund
2004-03-12 17:03       ` Building GENERIC trees and passing the symbol table Tom Crick
2004-03-12 17:24         ` Paul Brook
2004-04-12  2:31           ` Building GENERIC trees Tom Crick

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