Hello everyone! Is there any documentation about LLVM backend implementation, except "Writing an LLVM backend"? I'm trying to write InstrFormats.td and InstrInfo.td for my backend now. After reading "Writing an LLVM backend" and "Creating an LLVM Backend for the Cpu0 Architecture", many black holes have remained. These tutorials describe it on concrete examples, but general approach is missed. For example, how to implement different addressing modes using ComplexPattern? How to write a matching function? How does addressing modes correlate with address operands? When should we implement our own DAG nodes? Why does some backends have Format field, while other - don't? And so on... So, maybe somebody have materials that could help to clarify process of implementing backend? It might be books, articles, presentations etc. -- Regards, Vadim. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130224/1eec4601/attachment.html>
The Sparc port is maybe the closest thing to a text book example at this time. You can study it; debug some examples and trace through things. It's very simple because nobody is working on the Sparc port to make it a commercial compiler for the Sparc platform; yet at the same time it has complex patterns, custom inserters etc and all the elements of a more serious port. Most people learn LLVM by trying to do something with it and not just reading about it. I too wanted some better documentation and more complete examples and such but if you wait for that; you will wait for a very long time (several years at least). Tablegen is a vital tool to LLVM; yet there is little written about it; especially not about the code generation use of it. There are people that have done whole ports that have lots of holes in their knowledge; like myself for example and friends of mine that work at other companies that have done whole ports. As I've mentioned before on the list; make sure your C++ and STL is pretty good; that is one area that can hang you up. A lot of the information that you want is in the documents that already exist but you have to get some experience with LLVM and go back and read and re-read them many times in order to grock the whole thing. Reed On 02/23/2013 05:47 PM, Vadim Khoptynets wrote:> Hello everyone! > > Is there any documentation about LLVM backend implementation, except > "Writing an LLVM backend"? I'm trying to write InstrFormats.td and > InstrInfo.td for my backend now. After reading "Writing an LLVM backend" > and "Creating an LLVM Backend for the Cpu0 Architecture", many black > holes have remained. These tutorials describe it on concrete examples, > but general approach is missed. For example, how to implement different > addressing modes using ComplexPattern? How to write a matching function? > How does addressing modes correlate with address operands? When should > we implement our own DAG nodes? Why does some backends have Format > field, while other - don't? And so on... > So, maybe somebody have materials that could help to clarify process of > implementing backend? It might be books, articles, presentations etc. > > -- > Regards, > Vadim. > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >
Hello, On Sun, 24 Feb 2013 07:25:03 -0800 Reed Kotler <rkotler at mips.com> wrote:> > InstrInfo.td for my backend now. After reading "Writing an LLVM > > backend" and "Creating an LLVM Backend for the Cpu0 Architecture", > > many black holes have remained. These tutorials describe it on"Cpu0" links to Tricore port thesis (google for "tricore llvm"), and I found it to be more insightful than Cpu0 doc itself (which needs more work IMHO). It shows usage of custom addressing mode, predicates, and some issues at least that version of LLVm had (with ability to annotate and propagate annotations thru instruction selection graph, I wonder how latest LLVM in that regard).> It's very simple because nobody is working on the Sparc port to make > it a commercial compiler for the Sparc platform; yet at the same time > it has complex patterns, custom inserters etc and all the elements of > a more serious port. > > Most people learn LLVM by trying to do something with it and not just > reading about it. I too wanted some better documentation and more > complete examples and such but if you wait for that; you will wait > for a very long time (several years at least). > > Tablegen is a vital tool to LLVM; yet there is little written about > it; especially not about the code generation use of it.With my LLVM brainstorming, I find it soothing idea to think of tablegen as another separate layer. Because treating it as an unalienable part of LLVM, it's really hard to see how this all differs from GCC, except that they were missing to PR their GIMPLE IR for long time. I'm sure Tablegen is a good expressive language, and sure that if someone is to write generic solution, they would come up with something similar to Tablegen eventually. I just wonder if that's exactly the case when (re)implementing own adhoc solution offers much milder learning curve... Anyway, it would be nice to have a backend for (abstract) trivial CPU with just accumulator, index register and stack pointer and devoid of any tablegen usage (or maybe it would be tolerable for such CPU, after all, most of tablegen hardness comes from lack of keyword arguments and MLAs a typical machine def is ridden with). Such backend could be used to easily bootstrap a new arch backend, next might be to use any extra regs as just stack frame cache, and then it will be just good time to learn advanced tablegen stuff. [] -- Best regards, Paul mailto:pmiscml at gmail.com
On Sun, Feb 24, 2013 at 10:25 AM, Reed Kotler <rkotler at mips.com> wrote:> Most people learn LLVM by trying to do something with it and not just > reading about it.I wonder if there would be any interest in an annual (or some reasonable interval) "workshop" sort of thing that teaches backend development. That may be a better learning medium for this material than a book. -- Sean Silva
Vadim Khoptynets <vadya.poiuj at gmail.com> writes:> Hello everyone! > > Is there any documentation about LLVM backend implementation, except > "Writing an LLVM backend"? I'm trying to write InstrFormats.td and > InstrInfo.td for my backend now. After reading "Writing an LLVM > backend" and "Creating an LLVM Backend for the Cpu0 Architecture", > many black holes have remained.The reference documentation "The LLVM Target-Independent Code Generator" is about the best there is, AFAIK. It lacks a lot of important details but gives a good general overview of the concepts. -David
Reasonably Related Threads
- [LLVMdev] backend documentation
- [LLVMdev] backend documentation
- [LLVMdev] Passing return values on the stack & storing arbitrary sized integers
- [LLVMdev] TableGen related question for the Hexagon backend
- [LLVMdev] Passing return values on the stack & storing arbitrary sized integers