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 ?

5 Answers
5

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.

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.
– old_timerJul 9 '09 at 18:33

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.

It's important to note that a bunch of information about the target comes from the system header files that you use when compiling. LLVM does not defer resolving things like "size of pointer" or "byte layout" so if you compile with 64-bit headers for a little-endian platform, you cannot use that LLVM source code to target a 32-bit big-endian assembly output pater.