Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Compilers > Optimizing in m...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 3 Topic 2325 of 2472
Post > Topic >>

Optimizing in my toy compiler

by Nils M Holm <nmh@[EMAIL PROTECTED] > Feb 11, 2008 at 06:48 AM

Boriel <boriel@[EMAIL PROTECTED]
> wrote:
> If I'm not wrong, stack-oriented code is easy to generate, but
> difficult to optimize whilst three or quad code is much easy to
> optimize. Any ideas? Which one should you suggest? I'm with "The
> Dragon book", and it have *too* much information. :-P

You can always optimize your code while it is in tree form an then
emit RPN. Or, in case your compiler does not build a syntax tree
while parsing, you can build one from the RPN code just for the
purpose of optimization.

This is what I have done in the T3X compiler[1]. Early versions did
not have an optimizer nor did they create syntax trees. The optimizer
in later versions was a separate program that read an intermediate
code file in RPN, built a tree from it, optimized that tree and
emitted optimized RPN. Converting RPN to a tree is not really hard.

Feel free to download the sources for inspiration:

[1] http://www.t3x.org/t3x/

--
Nils M Holm <nmh@[EMAIL PROTECTED]
> -- http://t3x.org/nmh/
 




 3 Posts in Topic:
Optimizing in my toy compiler
Boriel <boriel@[EMAIL   2008-02-07 12:05:06 
Optimizing in my toy compiler
Nils M Holm <nmh@[EMAI  2008-02-11 06:48:52 
Re: Optimizing in my toy compiler
Max Hailperin <max@[EM  2008-02-12 19:00:54 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Jul 24 14:37:03 CDT 2008.