could you give me some suggestions as to learning llvm?

hello, there.

I am new and very interested in llvm. I have read the language reference, developer manual, backend guide, tablegen guide, pass guide and other related materials. and I have started to read the source code of llvm-8.0.1.
I want to write a backend to support part of mips instructions or part of sparc instructions.

There is few compiler engineerer around me. Could you give me some suggestion? Thanks in advance!

If I wanna to make it quickly, are there any tips or tutorials(the backend tutorial on 3.9 is hard to understand)? Thank you!

sincerely

Jack

Hi Jack,

There’s a rough learning path to LLVM, both because its intrinsic complexity and the lack of deep documentation, so I don’t think that a completely new backend can be produced in a short time. I think that only who have already previous experience with LLVM could do it. To complicate things, it looks that the few available documents are scattered down in Google searches, so they are not easy to find either. The fact that google seems to give different results depending on your computer settings (starting by language) and your past searching history does not help to have a consistent experience for all of us.

I joined LLVM only 3 months ago, so by no way I am an expert but I managed to successfully implement a custom LLVM backend as part of a project I am working on. This is a list of links that I collected over that time that I found useful:

https://jonathan2251.github.io/lbd/index.html

https://pdfs.semanticscholar.org/2298/9c214aedc3c58af857d6edc29770c544848c.pdf

https://opus4.kobv.de/opus4-fau/files/1108/tricore_llvm.pdf

Unfortunately, most of the above is partially outdated, due to the frenetic stream of changes that LLVM has received over the last few years, but the good point is that these documents cover some deep aspects that are hardly available on the official documentation.

I shall also mention that I started by purchasing the "Getting Started with LLVM Core Libraries” and “LLVM Essentials” books, but to be honest I wouldn’t recommend them as I found them to be the least useful resources of all. The problem is that the authors attempt to cover so much and they ultimately fail to cover anything properly.

The usual approach is to start from an already implemented (and working) backend that resembles most the architecture you want to implement. Study a backend by stepping its source code with a debugger, and create another one according to your needs. The documents linked above have helped me to understand essential concepts at times where I got stuck. The positive point of this approach, is that you don’t necessarily need to understand absolutely everything. You learn as you go, and as long as you get the concepts right, you will be able to produce code to your needs and solve all compiler issues specific to your backend (although not in no time, I’m afraid)

Of course, the LLVM mailing lists are also a source of information and the place to ask concrete questions. You won’t immediately find all the answers, but in most cases developers will reply with something that will be useful to you in order to continue your journey.

So, good luck with your project!

Joan.