public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Pop Sébastian <pop@gauvain.u-strasbg.fr>
To: Chris Lattner <sabre@nondot.org>, dnovillo@redhat.com
Cc: gcc@gcc.gnu.org
Subject: [tree-ssa] AST optimizer in C++?
Date: Sun, 25 Aug 2002 09:48:00 -0000	[thread overview]
Message-ID: <20020825164825.GA2934@gauvain.u-strasbg.fr> (raw)
In-Reply-To: <Pine.LNX.4.30.0208231132140.13372-100000@nondot.org>

On Fri, Aug 23, 2002 at 12:28:53PM -0500, Chris Lattner wrote:
> 
> Anyway, I'd love to discuss various IR design issues.  If anyone would
> like to talk about the Pros/cons of optimizing on a tree vs a low-level
> IR with type information, I can certainly talk about the experience I have
> with it.  Hopefully I can convince you that tree's are not really
> neccesary at all.  :) :)
> 

Agree, since we deal with (more or less) the same amount of information 
structured differently: trees vs. list of instructions.

AST representation as it exists now has the following information transformed 
directly from the input source code:
- control flow
- def-use 
- caller-callee
- types

Intermediate representations are created for better handling all this information.
IR can be viewed as sub-languages of the original language:
- CFG is a the sub-language that contains information about the control flow 
- SSA and dependence graphs for def-use
- Call-graph for caller-callee
- symbol tables for types
(see also 
http://www.stratego-language.org/twiki/bin/view/Stratego/StrategoPublications
http://www.stratego-language.org/twiki/bin/view/Transform/ProgramTransformation
)

These IR expose the same information as the original source code but in a more
compact form to optimizers.  

OTOH this information is not ready to be used dirrectly by optimizers since IRs
can produce different representations for the same semantic-equivalent program.
This increase the complexity of optimizers.  The idea is to reduce a class of
semantic-equivalent programs to a single representative program.  This is the 
normalization process:
- SIMPLE normalizes def-use IRs
- goto/break/switch elimination and loop canonicalization aim to normalize 
  control flow.
- ??? normalization for caller-callee
- ??? normalization for types
(I have no idea yet about question marks... work in progress...)

  Low Level Virtual Machine (LLVM) defines a virtual instruction set that 
contains exactly the same amount of information as the AST representation and 
it has all the benefits of the three-address-code normalization.
  However LLVM does not provide support for high level loop constructs 
(nested loops for example).  It defines instead branch "br" instructions.  
You then need extra informations for loop nest optimizers.
  Thus, I agree that writing optimizers on LLVM is as difficult :-) as writing 
them on trees under SIMPLE form.  However I think that introducing yet another 
translation from trees to LLVM could be expensive in compiling time (yet it is 
a quick transformation from SIMPLE).  

  A good idea I saw in the LLVM is that the SSA infromation is stored directly 
in the operations stream: ie. (from LLVMCompilationStrategy.pdf)
<result> = phi <type> [<val0>, <label0>], ..., [<valN>, <labelN>]

  Diego, maybe it is worth to include PHI nodes directly as a SIMPLE extension?
This could solve the problem with the tree_common.aux field...  The only difficult
bit I see is to remove them before we generate RTL (or otherwise propagate 
information about SSA into RTL through the translation of these nodes).

What do others think?

  reply	other threads:[~2002-08-25  9:48 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-22 13:50 A FrontEnd " Chris Lattner
2002-08-23  0:51 ` AST optimizer " Pop Sébastian
2002-08-23 10:25   ` Chris Lattner
2002-08-25  9:48     ` Pop Sébastian [this message]
2002-08-25 14:33       ` [tree-ssa] " Chris Lattner
2002-08-25 16:03         ` Diego Novillo
2002-08-27  9:32           ` Chris Lattner
2002-08-26  8:52         ` Pop Sébastian
2002-08-26  9:17           ` Chris Lattner
2002-08-26 21:18           ` Daniel Berlin
2002-08-27  1:17             ` Pop Sébastian
2002-08-27  6:28               ` Diego Novillo
2002-08-27  7:08                 ` Steven Bosscher
2002-08-27  8:37               ` Daniel Berlin
2002-08-27 12:21               ` Per Bothner
2002-08-27 12:32                 ` Gabriel Dos Reis
2002-08-27 12:51                   ` Per Bothner
2002-08-27 13:02                     ` Gabriel Dos Reis
2002-08-27  6:44             ` Discussion about a new development plan? (was: Re: [tree-ssa] ASToptimizer in C++?) Steven Bosscher
2002-08-27  7:09               ` Discussion about a new development plan? (was: Re: [tree-ssa] AST optimizer " Jan Hubicka
2002-08-27  8:29             ` [tree-ssa] AST optimizer in C++? Chris Lattner
2002-08-25 15:35       ` Diego Novillo
2002-08-25 15:45         ` Chris Lattner
2002-08-25 16:08           ` Diego Novillo
2002-08-25 16:19             ` Diego Novillo
2002-08-26  8:39               ` Chris Lattner
2002-08-26 17:43                 ` Daniel Berlin
2002-08-26 18:12                   ` Chris Lattner
2002-08-26  8:35             ` Chris Lattner
2002-08-25 16:12           ` Daniel Berlin
2002-08-26  7:02             ` Pop Sébastian
2002-08-26  8:28               ` Steven Bosscher
2002-08-26  8:52             ` Chris Lattner
2002-08-26 17:40               ` Daniel Berlin
2002-08-26 17:44                 ` Daniel Berlin
2002-08-26 18:11                 ` Chris Lattner
2002-08-26 18:46                   ` Daniel Berlin
2002-08-27  9:26                     ` Chris Lattner
2002-08-27  9:57                       ` Chris Lattner

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=20020825164825.GA2934@gauvain.u-strasbg.fr \
    --to=pop@gauvain.u-strasbg.fr \
    --cc=dnovillo@redhat.com \
    --cc=gcc@gcc.gnu.org \
    --cc=sabre@nondot.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).