<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Mon, Oct 8, 2018 at 8:53 AM Joachim Durchholz <<a href="mailto:jo@durchholz.org">jo@durchholz.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Am 08.10.2018 um 01:34 schrieb Vanessa McHale:<br>
> The problem with an IR is that some languages would inevitably suffer - <br>
> LLVM in particular was designed as a backend for a C compiler, and so it <br>
> is not necessarily well-suited for lazy languages, immutable languages, <br>
> etc. (not to mention self-modifying assembly and other such pathological <br>
> beasts...)<br>
Actually LLVM is built for being adaptable to different kinds of <br>
languages. It does have a bias towards C-style languages, but you can <br>
adapt what doesn't fit your needs *and still keep the rest*.<br>
<br>
The following was true a few years ago:<br>
<br>
When I asked, the LLVM IR was intentionally not specified to be reusable <br>
across languages, so that different compiler toolchain could adapt the <br>
IR to whatever needs their language or backend infrastructure needed.<br>
<br>
Garbage collection is one area where you have to do a lot of work. There <br>
are some primitive instructions that support it, but the semantics is <br>
vague and doesn't cover all kinds of write barriers. You'll have to roll <br>
your own IR extensions - or maybe I didn't understand the primitives <br>
well enough to see how much they cover.<br>
Anyway, LLVM does not come with a GC implementation.<br>
OTOH, it does not prevent you from doing a GC. In particular, you're <br>
free to avoid C-style pointers, so you have the full range of GC <br>
algorithms available.<br>
<br>
Laziness? No problem. If you do tagless/spineless, you'll code the <br>
evaluation machine anyway. Just add an IR instructions that calls the <br>
interpreter.<br></blockquote><div><br></div><div>I'm far from expert in this area, but isn't that "interpreter" a simple yet slow approach to codegen? My understanding is that when you use, say, a global variable as a register for your evaluation machine, it is slower than if you somehow pin real hardware register for that purpose. I think this is what "registerized" GHC build means.</div><div>In LLVM you can't use, say, RSP in a way you want, but it is doomed to be "stack pointer register", even if you don't use stack at all.</div><div><br></div><div>As I read in some blog, you can slightly affect LLVM codegen by adding calling conventions, but the real solution would be another algorithm for instruction selection. No one implemented that yet, AFAIK.<br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Immutability? No problem - actually nowhere a problem. Immutability <br>
happens at the language level, at the IR level it is pretty irrelevant <br>
because compilers try to replace object copying by in-place modification <br>
wherever possible, anyway.<br>
<br>
Self-modifying assembly? No IR really supports that. Mostly it's <br>
backends that generate self-modifying code from IR instructions for <br>
specific backends.<br>
<br>
TL;DR: For its generality, LLVM IR is better suited to languages with <br>
specific needs in the backend than anything else that I have seen (which <br>
means C runtimes, various VM proofs of concept which don't really count, <br>
and JVM - in particular I don't know how .net compares).<br>
<br>
Regards,<br>
Jo<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
Only members subscribed via the mailman list are allowed to post.</blockquote></div></div>