views:

524

answers:

3

I was reading here and there about llvm that can be used to ease the pain of cross platform compilations in c++ , i was trying to read the documents but i didn't understand how can i use it in real life development problems can someone please explain me in simple words how can i use it ?

+1  A: 

LLVM is, as its name says a low level virtual machine which have code generator. If you want to compile to it, you can use either gcc front end or clang, which is c/c++ compiler for LLVM which is still work in progress.

Dev er dev
+1  A: 

Why don't you go to the LLVM website and check out all the documentation there. They explain in great detail what LLVM is and how to use it. For example they have a Getting Started page.

lothar
+4  A: 

The key concept of LLVM is a low-level "intermediate" representation (IR) of your program. This IR is at about the level of assembler code, but it contains more information to facilitate optimization.

The power of LLVM comes from its ability to defer compilation of this intermediate representation to a specific target machine until just before the code needs to run. A just-in-time (JIT) compilation approach can be used for an application to produce the code it needs just before it needs it.

In many cases, you have more information at the time the program is running that you do back at head office, so the program can be much optimized.

To get started, you could compile a C++ program to a single intermediate representation, then compile it to multiple platforms from that IR.

You can also try the Kaleidoscope demo, which walks you through creating a new language without having to actually write a compiler, just write the IR.

In performance-critical applications, the application can essentially write its own code that it needs to run, just before it needs to run it.

David Dolson
You can also compile binaries as well, you are not forced to use the runtime JIT method. It has a handful of backends so far, I have only just started to use it and so far it is easy to use as an ARM cross compiler. It is easy to join the individual modules together and optimize the program as a whole.
dwelch