[llvm-dev] [Beginner] Understanding Tablegen language
Matt P. Dziubinski via llvm-dev
llvm-dev at lists.llvm.org
Tue Jul 14 01:04:57 PDT 2020
On 7/13/2020 21:30, Thomas Lively via llvm-dev wrote:
> Part of the problem is that ISel patterns are like their own DSL inside
> the TableGen DSL, so keywords like "ins", "outs", and "ops" aren't
> keywords at the TableGen level, but rather at the level of the ISel
> system implemented with TableGen. 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.
FWIW, there are also some third-party resources that may be of help:
"Lessons in TableGen"
FOSDEM 2019; Nicolai Hähnle
https://fosdem.org/2019/schedule/event/llvm_tablegen/
Slides:
https://archive.fosdem.org/2019/schedule/event/llvm_tablegen/attachments/slides/3304/export/events/attachments/llvm_tablegen/slides/3304/tablegen.pdf
Series:
- What has TableGen ever done for us?:
http://nhaehnle.blogspot.com/2018/02/tablegen-1-what-has-tablegen-ever-done.html
- Functional Programming:
http://nhaehnle.blogspot.com/2018/02/tablegen-2-functional-programming.html
- Bits: http://nhaehnle.blogspot.com/2018/02/tablegen-3-bits.html
- Resolving variables:
http://nhaehnle.blogspot.com/2018/03/tablegen-4-resolving-variables.html
- DAGs: http://nhaehnle.blogspot.com/2018/03/tablegen-5-dags.html
Some of the parts of TableGen used in SelectionDAG are in the backend
docs (e.g., the keywords OP asked about):
https://llvm.org/docs/WritingAnLLVMBackend.html#instruction-set
& https://llvm.org/docs/WritingAnLLVMBackend.html#instruction-selector
(has a simple example of `PatFrag` for `store`).
There are a few examples of simple .td files an LLVM backend in the
following:
LLVM backend development by example (RISC-V)
2018 LLVM Developers’ Meeting; Alex Bradbury
https://www.youtube.com/watch?v=AFaIP-dF-RA
2014 - Building an LLVM Backend - LLVM Developer's Meeting
https://llvm.org/devmtg/2014-10/#tutorial1
https://llvm.org/devmtg/2014-10/Slides/Cormack-BuildingAnLLVMBackend.pdf
https://llvm.org/devmtg/2014-04/PDFs/Talks/Building%20an%20LLVM%20backend.pdf
http://web.archive.org/http://llvm.org/devmtg/2014-10/Videos/Building%20an%20LLVM%20backend-720.mov
http://llvm.org/devmtg/2014-10/#tutorial1
http://www.inf.ed.ac.uk/teaching/courses/ct/other/LLVMBackend-2015-03-26_v2.pdf
llvm-leg: LEG Example Backend
LEG Example Backend: a simple example LLVM backend for an ARM-like
architecture: 'LEG'.
https://github.com/frasercrmck/llvm-leg
Best,
Matt
More information about the llvm-dev
mailing list