[llvm-dev] nlvm, a new LLVM-based compiler for Nim

Jacek Sieka via llvm-dev llvm-dev at lists.llvm.org
Sun Sep 4 02:09:32 PDT 2016


I'd like to introduce to the list a new, LLVM-based compiler for the Nim
language (http://nim-lang.org) - https://github.com/arnetheduck/nlvm.

Nim itself is a nice little statically typed language with many handy
features such as meta-programming, garbage collection, etc. Python
programmers will also be happy to know that indentation is significant.

To say that I've written the compiler would of course be a gross
overstatement. Nim's own compiler produces a semantically analyzed and
simplified AST that it later translates to C, and with LLVM providing
everything from intermediate representation to machine code generation,
there's not much left to do for an aspiring compiler writer these days -
I've merely glued together the Nim AST with LLVM, replacing the C output
with LLVM bitcode.

The glue is written in Nim itself, and most of the LLVM translation fits in
a single file. Of course, this file is pretty long, but at least it sounds
cool ;)

One of the strengths of Nim is the easy integration with C, and
consequently nlvm uses the llvm-c interface.

This has worked well, except that I can't seem to find the right
incantations to bring about debugging / dwarf support. My confidence is
somewhat restored by the fact that the rust devs failed to find them as
well and therefore wrote their own wrappers, but I'd love to hear from you
if you know of a better way.

I'd also love to hear from you if you have any feedback or questions, and
contributors are warmly welcome.


PS please cc me in replies for a quicker answer.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160904/6b7eeca7/attachment.html>

More information about the llvm-dev mailing list