Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LLVM what is it and how can i use it to cross platform compilations

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 ?

like image 614
user63898 Avatar asked May 12 '09 09:05

user63898


2 Answers

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.

like image 111
David Dolson Avatar answered Sep 28 '22 08:09

David Dolson


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.

like image 40
lothar Avatar answered Sep 28 '22 07:09

lothar