Cloud Strife
2008-Sep-24 07:27 UTC
[LLVMdev] What can llvm provide when writing a new compiler?
Hi everyone. Because there is still a little confusion about the huge document, I want to know what llvm can provide when we customize our new compiler? For example, a normal compiler includes lexer, parser, intermediate code generator , optimizer and target code generator. According to llvm documents, it seems that llvm can provide a better intermediate code presentation. And what else can it provide? Assuming my new lanuage is very unusual, should I write all the parts( lexer, parser, intermediate code generator , optimizer and target code generator) by myself? If so, is there any convenient method / scheme to do so? Because I heard that the biggest advantage of llvm is its flexible and quick-development for new language. If anyone knows the answer, would you please give me a reply or recommend the chapters which can answer my questions? Thank you very much for any help or any advise. -- Best regards. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080924/f2ebc7a0/attachment.html>
Nick Lewycky
2008-Sep-24 07:44 UTC
[LLVMdev] What can llvm provide when writing a new compiler?
Cloud Strife wrote:> Hi everyone. > Because there is still a little confusion about the huge document, I > want to know what llvm can provide when we customize our new compiler? > For example, a normal compiler includes lexer, parser, intermediate code > generator , optimizer and target code generator. According to llvm > documents, it seems that llvm can provide a better intermediate code > presentation. And what else can it provide?Optimizer and target codegen. We also provide an IR file format (both binary and textual). You provide the lexer and parser, and you write the code that turns your language into LLVM IR. Note that the codegen is capable of generating both assembly files on disk and of JITting. The optimizations are capable of doing interprocedural optimizations. Someone might want to put these pieces together in a program that ships some IR, generates some IR on the fly, and then link-time-optimizes them and JITs the result.> Assuming my new lanuage is very unusual, should I write all the > parts( lexer, parser, intermediate code generator , optimizer and target > code generator) by myself? If so, is there any convenient method / > scheme to do so? Because I heard that the biggest advantage of llvm is > its flexible and quick-development for new language.At some point your language has to become a sequence of operations executed in order, which can in turn be expressed in LLVM IR. Leave it to LLVM to perform your optimization and codegen. I don't know what document you're referring to, but the LLVM IR is really quite compact. Do read it: http://llvm.org/docs/LangRef.html . Nick> If anyone knows the answer, would you please give me a reply or > recommend the chapters which can answer my questions? Thank you very > much for any help or any advise. > > > > -- > Best regards. > > > ------------------------------------------------------------------------ > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Jonathan S. Shapiro
2008-Sep-24 09:33 UTC
[LLVMdev] What can llvm provide when writing a new compiler?
On Wed, 2008-09-24 at 15:27 +0800, Cloud Strife wrote:> I want to know what llvm can provide when we customize our new compiler?Cloud: There are some fairly good tutorials on the LLVM site. Looking them over would answer your question thoroughly. shap
David Greene
2008-Sep-24 16:19 UTC
[LLVMdev] What can llvm provide when writing a new compiler?
On Wednesday 24 September 2008 02:27, Cloud Strife wrote:> Hi everyone. > Because there is still a little confusion about the huge document, I want > to know what llvm can provide when we customize our new compiler? > For example, a normal compiler includes lexer, parser, intermediate code > generator , optimizer and target code generator. According to llvm > documents, it seems that llvm can provide a better intermediate code > presentation. And what else can it provide?Codegen, codegen, codegen. Oh, and optimizations too. :)> Assuming my new lanuage is very unusual, should I write all the parts( > lexer, parser, intermediate code generator , optimizer and target code > generator) by myself? If so, is there any convenient method / scheme to do > so? Because I heard that the biggest advantage of llvm is its flexible and > quick-development for new language.If you're targeting x86, for example, you do NOT want to write your own codegen! If you do, good luck digesting five volumes of ISA material. :) This is generally true for other architectures as well. Reuse, reuse, reuse. LLVM is well-designed to allow you to do that. Take advantage of it. Does LLVM have its shortcomings? Sure. But I can guarantee it has fewer shortcomings than a custom codegen would have down the road. Because there's a community working on it, itr's been forced to be designed in a flexible and reuseable way. Development process is a significant advantage of LLVM and open source in general, one that I think is greatly undervalued. -Dave
Apparently Analagous Threads
- [LLVMdev] LLVMdev Digest, Vol 51, Issue 76
- Want to contribute code to the Xapian project
- [LLVMdev] Has anyone sucessfully compile the llvm code using visual studio 2005?
- [LLVMdev] Has anyone sucessfully compile the llvm code using visual
- [LLVMdev] compilaton problem