Re: Constant expression evaluation?

david lindauer <camille@bluegrass.net>
29 May 2003 03:24:44 -0400

          From comp.compilers

Related articles
Constant expression evaluation? mdhe51ATdialDOTpipexDOTcom@eu.uu.net (Paul Davis) (2003-05-14)
Re: Constant expression evaluation? christian.bau@cbau.freeserve.co.uk (Christian Bau) (2003-05-16)
Re: Constant expression evaluation? chaos@vcc.de (Dierk Ohlerich) (2003-05-16)
Re: Constant expression evaluation? clint@0lsen.net (Clint Olsen) (2003-05-18)
Re: Constant expression evaluation? norlic@fly.srk.fer.hr (Niksa Orlic) (2003-05-29)
Re: Constant expression evaluation? camille@bluegrass.net (david lindauer) (2003-05-29)
| List of all articles for this month |

From: david lindauer <camille@bluegrass.net>
Newsgroups: comp.compilers
Date: 29 May 2003 03:24:44 -0400
Organization: http://www.randori.com
References: 03-05-089
Keywords: optimize
Posted-Date: 29 May 2003 03:24:44 EDT

Paul Davis wrote:


> I'm hoping to add constant expressions to a simple compiler I've
> written, but it looks like some of my early design decisions will make
> this difficult. I'd appreciate some ideas on better ways to do this.


My own compiler has a constant-expression evaluator... it just goes
through the intermediate parse-trees after the fact of generating them
and evaluates constant expressions before generating code. It works
well, but is kind of inefficient. A really cool thing I found out
from someone on this group is that if you generate say a three-address
intermediate code from the parse trees or whatever, and compile all
the variable references into a DAG tree, you can then evaluate
constant expressions on the fly as you are building the DAG tree.
Much more efficient than the present examination algorithm and gets me
local optimizations at the same time :).


David


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.