This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
AST optimizer in C++?
- From: Pop Sébastian <pop at gauvain dot u-strasbg dot fr>
- To: Chris Lattner <sabre at nondot dot org>
- Cc: gcc at gcc dot gnu dot org
- Date: Fri, 23 Aug 2002 09:51:26 +0200
- Subject: AST optimizer in C++?
- References: <Pine.LNX.4.30.0208221544090.9172-100000@nondot.org>
Hi Chris,
On Thu, Aug 22, 2002 at 03:53:54PM -0500, Chris Lattner wrote:
>
> > Go right ahead. All you need is a new branch and some free time. I
> > would personally suggest following some of the design and implementation
> > ideas from SUIF and/or Sage++. They are kind of neat.
>
> As long as we are plugging compiler infrastructures, I thought I might
> mention my own project LLVM: http://llvm.cs.uiuc.edu/
>
I had a look at the project, and I'm interested to have a look at the sources
(if it's possible).
> It's also completely written in C++ (G++ 3.2), uses a GCC->LLVM frontend,
> is SSA based, open-source, and has some interesting technology available
> in it. The LLVM instruction set is roughly equivalent to SIMPLE
> (http://llvm.cs.uiuc.edu/docs/LangRef.html).
>
> A few of the nify things LLVM provides are the modular pass system:
> http://llvm.cs.uiuc.edu/docs/WritingAnLLVMPass.html
> strong infrastructure for interprocedural optimizations, linktime, and
> runtime optimizations, etc. The infrastructure is _very_ fast.
>
> Additionally, because it uses C++ and the STL throughout, writing
> transformations is quite simple. For example, LICM and GCSE are each
> just a couple hundred lines of code (which are mostly comments):
>
> http://llvm/doxygen/LICM_8cpp-source.html
> http://llvm/doxygen/GCSE_8cpp-source.html
>
> If you have any questions about LLVM or would like to discuss compiler
> architecture, I'd be more than happy to participate.
>
After what I (quickly) read from the web page you use gcc's front-ends.
My questions are:
- Do you have a class hierarchy for representing statements and expressions?
- Is it possible to generate GCC trees after your optimizations? (and then
generate RTL by passing these trees to the RTL-translator...)
In fact what I want for gcc is an AST optimizer that could be built independently
of gcc's front-ends. This optimizer takes as input SIMPLE trees and its output
is again gcc trees (a subset of SIMPLE, or even a superset of SIMPLE if we decide
to promote some stmts/exprs to a higher level during optimization).
The overall schema could be:
(GCC front-ends) -> (GENERIC trees) -> [(SIMPLE trees) -> (AST Optimizer)] ->
-> (RTL conversion) -> (Code generation)
with optional components in "-> [...] ->". These components are not mandatory
for building the GCC compiler. They could be built apart once the g++ compiler
is available. The AST optimizer could be loaded from a .so file (as in open64
compiler) and thus avoiding to grow too much the size of the executable when
AST optimization is not needed.