guile-devel
[Top][All Lists]
Advanced

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

Re: CPS language and Tree-IL->CPS->RTL compiler


From: Ludovic Courtès
Subject: Re: CPS language and Tree-IL->CPS->RTL compiler
Date: Thu, 29 Aug 2013 22:42:03 +0200
User-agent: Gnus/5.130007 (Ma Gnus v0.7) Emacs/24.3 (gnu/linux)

Hello!

Andy Wingo <address@hidden> skribis:

> This patchset implements the CPS compiler I've been working on over the
> last couple months.  At the end of it, you can
>
>   guild compile -t rtl foo.scm
>
> and, if there are no bugs or unimplemented bits, at that point you have
> a loadable .go with RTL code.  (Try readelf -a on the .go!)

Woow, wonderful!

> As a little example:
>
>    (+ 1 2)
>
> Here + is a primcall, so we would get:
>
>    ($letk ((kone ($kargs (oneb)
>                    ($letk ((ktwo ($kargs (two)
>                                    ($continue ktail
>                                      ($primcall + one two)))))
>                     ($continue ktwo ($const 2))))))
>      ($continue kone ($const 1)))
>
> Here all CPS language constructs are prefixed with "$".  Everything else
> is a variable, except the + in the primcall.

Thanks for the example that nicely complements a first-time read of
Kennedy’s paper.

[...]

> If you ever worked with the old (language tree-il compile-glil) module,
> you know it's very hairy, mostly because it's mixing code emission with
> semantic transformations.  Nowhere is this more evident than the
> so-called "labels allocation" strategy, in which we try to allocate
> procedures as basic blocks, if they all return to the same place.  It's
> a funky pass.  It turns out this concept is well-studied and has a name,
> "contification", and is cleanly expressed as a source-to-source pass
> over CPS.  So compile-rtl.scm is dumb: it just loops over all
> expressions, emitting code for each of them, and emitting jumps and
> shuffling registers as needed (based on a prior analysis pass).

That’s really appreciable.  :-)

> OK.  WDYT, Ludo?  Comments?  OK to merge? :)

Well, I guess so!

Thanks to Noah for getting you started, and to Mark and you for getting
this far!

(I’m going to browse the patches, mostly so I can learn from this.)

Ludo’.




reply via email to

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