What are the differences between an LLVM and a regular compiler?
Is it more dynamic and thus can be used to compile normally very dynamic languages (i.e. Javascript) into static binary code?
What are the principles behind creating one?
I know the Dragon Book for compilers, but is there such a thing for a LLVM?
EDIT: I have found this interesting project.
LLVM helps build new computer languages and improve existing languages. It automates many of the difficult and unpleasant tasks involved in language creation, such as porting the outputted code to multiple platforms and architectures.
What makes it so popular is that its modular design allows its functionality to be adapted and reused very easily.
One big reason is new tools for building languages—specifically, compilers. And chief among them is LLVM, an open source project originally developed by Swift language creator Chris Lattner as a research project at the University of Illinois.
LLVM is a library that is used to construct, optimize and produce intermediate and/or binary machine code. LLVM can be used as a compiler framework, where you provide the "front end" (parser and lexer) and the "back end" (code that converts LLVM's representation to actual machine code).
There are a couple of difference between LLVM and "a regular compiler", which I'll assume to mean "gcc":
As for Javascript and other dynamic languages, we're seeing a lot of interesting in LLVM from the dynamic language community, with Python and Ruby implementations trying it out. However, these are not attempting to be static compilers. They are focussed on using the JIT. In particular, the are optimizing long running executables using a "mixed mode interpreter", where they initially interpret the programs, and then compile them using LLVM at run-time. I haven't seen a javascript engine using LLVM, but there probably is one. It just won't create static executables, except in unusual circumstances, or for cut down versions of Javascript.
As for the reason for the creation of LLVM, it started as part of Vikram Adve's research group's work on life long compilation (which means JITs and link-time optimization). After his PhD, Chris Lattner moved to Apple, which is moving the project forward greatly (probably because it is BSD licenced, which has caused them problems in the past with gcc, which is GPL).
Nothing it is a regular compiler. Its primary reason for creation was to create a platform for compiler research. Therefore it is designed to be very modular so that you can work on that part of the compiler that deals with your research and not have to worry about other parts of the compiler. There is no dragon compiler just as there is no LLVM book(any theory you read in the dragon book or any other compiler book should be directly applicable). In fact while I haven't looked in on LLVM in a while their documentation was pretty poor.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With