Why write this?
There are few tutorials on writing LLVM backends, and the existing ones could get outdated quickly.
The main goal was to try to document how TableGen ISel patterns work and make it easier for newcomers to pick up without just relying on experimenting and looking at exampls from other backends.
With time I aim to add enough information to make this guide approachable to people not familiar with compilers or LLVM.
Copying existing patterns and reading the comments in Target.td and TargetSelectionDAG.td are the best ways I know of learning how this works. I haven’t seen a separate guide, although it would be very cool if one existed. — llvm-dev thread
Question: “How does one learn the details of TableGen’s pattern-matching syntax? I have tried to do this, maybe a dozen times and failed every time.”
Answer: “…by trial and error”
— asked in https://www.youtube.com/watch?v=nNQ6AF6i5FI
I hope it is no longer trial and error. Head on to the patterns section on the tablegen for instruction selection page!