lightning
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Lightning] Compiling C to Lightning


From: Paolo Bonzini
Subject: Re: [Lightning] Compiling C to Lightning
Date: Tue, 23 Aug 2005 11:50:19 +0200
User-agent: Mozilla Thunderbird 0.9 (Macintosh/20041103)

Ludovic Courtès wrote:

Hi,

Paolo Bonzini <address@hidden> writes:

I think Ludovic does not want that, but rather something similar to `c (which was based on lcc). Starting from TinyCC to get a working parser, could be an idea.

What's `c?  Pointers?  Googling for it proved to be hard.  ;-)
tick c gives this result: http://pdos.csail.mit.edu/tickc/

How did you address similar issues in OCaml and GNU Smalltalk?
By recoding everything. Unfortunately you will need to do some recoding anyway, if you want to optimize register allocation for some common cases. For example GST usually stores results in V0, but simple operands (no message sends) can be also loaded in V1. So when adding two values I need something like

   compute operand 0 in V0
   save it
   compute operand 1 in V0
   load operand 0 into V1
   compute addition

But if operand 0 and 1 are both pretty simple, I can just do

   compute operand 0 in V1
   compute operand 1 in V0
   compute addition

And if operand 1 is simple, I can do

   compute operand 0 in V0
   move it to V1
   compute operand 1 in V0
   compute addition

Just a couple of this special cases may give a speed boost of 10-15%. I don't remember `c, but I think that it could implement this kind of templating only because its backend supported an infinite number of registers (so it just created new temporaries for every expression it compiled).

Paolo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]