Wednesday, March 27, 2013

[ LLVM ]

Subject: [ LLVM ]

  • note: originally emailed 03/27/2013 and sanitized for public consumption
  • sidenote: posting here so i can lead people here whenever they ask me about this stuff...



[BOSS,]

[SNIP]

While looking at the [XYZ] features, and wanting to use node.js – it is possible to take existing code (logic mostly) that can be 'converted' (for example, from C or C++) to run in the Google's V8 javascript engine – that node.js also uses.

But this isn't about javascript.  The piece of technology I want to bring to attention is called LLVM – Low Level Virtual Machine.  This project was only called a VM for legacy reasons.  But LLVM is much much more.  It's now known as the "LLVM compiler infrastructure".


Basically, it is possible to take (for example) a C++ library, convert it (for example) to javascript.


And since we like pictures to help describe things:
  • At the core, the programming language is generated to an "intermediate representation" (IR)
  • This IR object can then be used to be 'compiled to' the target platform
    • This can hardware (machine code)
    • But can also be software (byte code)


  • Here's an example of how nVidia took the LLVM project make their CUDA compiler


  • Here's another example of how source code from one language can be used to generate source code in another language

Here’s a pretty good slide deck intro to LLVM:

No comments: