Hi,

OK, the last progress for the rtl compilation is make it work to something
as close as the current
RTL VM,

I have added a few variables that can control the kind of compilation
strategy we would like
to have as an output. I can for example now do

(define f ((c (lambda (x) (let loop ((s 0) (i 0)) (if (eq? i x) s (loop (+
s i) (+ i 1))))))))

;; This will compile the following RTL Code
((begin-program program278)
 (assert-nargs-ee/locals 0 1)
 (label :LCASE273)
 (make-empty-closure 0 program277 0)
 (return 1)
 (end-program)
 (begin-program program277)
 (assert-nargs-ee/locals 1 2)
 (label :LCASE272)
 (br :L274)
 (label :LCASE271)
 (br-if-eq 2 0 1 :L275)
 (mov 0 1)
 (return 1)
 (label :L275)
 (add 1 1 2)
 (add1 2 2)
 (br :LCASE271)
 (label :L274)
 (load-constant 1 0)
 (load-constant 2 0)
 (br :LCASE271)
 (end-program))

Then we can do
(define g (lambda (x) (let loop ((s 0) (i 0)) (if (eq? i x) s (loop (+ s i)
(+ i 1))))))

And compare,
,time (g 10000000)
$3 = 49999995000000
;; 0.293595s real time, 0.290550s run time.  0.000000s spent in GC.
scheme@(guile-user)> ,time (f 10000000)
$4 = 49999995000000
;; 0.158049s real time, 0.150505s run time.  0.000000s spent in GC

So it starts to live in some sense.

Now I consider the compile-rtl code as a research code e.g. it can compile
correctly but it's a bit of a hack to churn in the rtl functionality
in the old compile-glil code. It seems to work and I have made enough
tooling so that the changes are clean in some sense at the higher level.
On the lower level I rest on fluids and hacks with set! to achieve what I
need. Anyway the abstractions are powerful enough so that I could build
several compilation strategies and mix between them, for example we could
have a native startegy and vm strategy that is more optimized if we have
a vm or is running native. There are a few more options as well.

The idea I have is that I would like to have a fairly complete picture of
how to compile to the current RTL VM and not introduce too large deviations
from wingo's
strategy. But instead make it work and build explore from that base. Again
having something that run's before trying to tweak is a good strategy I
would say.

Anyway, as you see there is some progress.

Cheers
Stefan

Reply via email to