<div dir="ltr"><div>Is there a backend to Tablegen which can dump a map of pattern-to-matched to instruction-to-be-generated? <br></div><div>--help doesn't seem to indicate anything like that.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jul 14, 2020 at 2:13 PM Rotate Right <<a href="mailto:rightrotate5@gmail.com" target="_blank">rightrotate5@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto">Thanks Matt and Thomas. I will go through them.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jul 14, 2020, 1:35 PM Matt P. Dziubinski <<a href="mailto:matdzb@gmail.com" target="_blank">matdzb@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 7/13/2020 21:30, Thomas Lively via llvm-dev wrote:<br>
> Part of the problem is that ISel patterns are like their own DSL inside <br>
> the TableGen DSL, so keywords like "ins", "outs", and "ops" aren't <br>
> keywords at the TableGen level, but rather at the level of the ISel <br>
> system implemented with TableGen. Copying existing patterns and reading <br>
> the comments in Target.td and TargetSelectionDAG.td are the best ways I <br>
> know of learning how this works. I haven't seen a separate guide, <br>
> although it would be very cool if one existed.<br>
<br>
FWIW, there are also some third-party resources that may be of help:<br>
<br>
"Lessons in TableGen"<br>
FOSDEM 2019; Nicolai Hähnle<br>
<a href="https://fosdem.org/2019/schedule/event/llvm_tablegen/" rel="noreferrer noreferrer" target="_blank">https://fosdem.org/2019/schedule/event/llvm_tablegen/</a><br>
Slides: <br>
<a href="https://archive.fosdem.org/2019/schedule/event/llvm_tablegen/attachments/slides/3304/export/events/attachments/llvm_tablegen/slides/3304/tablegen.pdf" rel="noreferrer noreferrer" target="_blank">https://archive.fosdem.org/2019/schedule/event/llvm_tablegen/attachments/slides/3304/export/events/attachments/llvm_tablegen/slides/3304/tablegen.pdf</a><br>
<br>
Series:<br>
- What has TableGen ever done for us?: <br>
<a href="http://nhaehnle.blogspot.com/2018/02/tablegen-1-what-has-tablegen-ever-done.html" rel="noreferrer noreferrer" target="_blank">http://nhaehnle.blogspot.com/2018/02/tablegen-1-what-has-tablegen-ever-done.html</a><br>
- Functional Programming: <br>
<a href="http://nhaehnle.blogspot.com/2018/02/tablegen-2-functional-programming.html" rel="noreferrer noreferrer" target="_blank">http://nhaehnle.blogspot.com/2018/02/tablegen-2-functional-programming.html</a><br>
- Bits: <a href="http://nhaehnle.blogspot.com/2018/02/tablegen-3-bits.html" rel="noreferrer noreferrer" target="_blank">http://nhaehnle.blogspot.com/2018/02/tablegen-3-bits.html</a><br>
- Resolving variables: <br>
<a href="http://nhaehnle.blogspot.com/2018/03/tablegen-4-resolving-variables.html" rel="noreferrer noreferrer" target="_blank">http://nhaehnle.blogspot.com/2018/03/tablegen-4-resolving-variables.html</a><br>
- DAGs: <a href="http://nhaehnle.blogspot.com/2018/03/tablegen-5-dags.html" rel="noreferrer noreferrer" target="_blank">http://nhaehnle.blogspot.com/2018/03/tablegen-5-dags.html</a><br>
<br>
Some of the parts of TableGen used in SelectionDAG are in the backend <br>
docs (e.g., the keywords OP asked about):<br>
<a href="https://llvm.org/docs/WritingAnLLVMBackend.html#instruction-set" rel="noreferrer noreferrer" target="_blank">https://llvm.org/docs/WritingAnLLVMBackend.html#instruction-set</a><br>
& <a href="https://llvm.org/docs/WritingAnLLVMBackend.html#instruction-selector" rel="noreferrer noreferrer" target="_blank">https://llvm.org/docs/WritingAnLLVMBackend.html#instruction-selector</a> <br>
(has a simple example of `PatFrag` for `store`).<br>
<br>
There are a few examples of simple .td files an LLVM backend in the <br>
following:<br>
<br>
LLVM backend development by example (RISC-V)<br>
2018 LLVM Developers’ Meeting; Alex Bradbury<br>
<a href="https://www.youtube.com/watch?v=AFaIP-dF-RA" rel="noreferrer noreferrer" target="_blank">https://www.youtube.com/watch?v=AFaIP-dF-RA</a><br>
<br>
2014 - Building an LLVM Backend - LLVM Developer's Meeting<br>
<a href="https://llvm.org/devmtg/2014-10/#tutorial1" rel="noreferrer noreferrer" target="_blank">https://llvm.org/devmtg/2014-10/#tutorial1</a><br>
<a href="https://llvm.org/devmtg/2014-10/Slides/Cormack-BuildingAnLLVMBackend.pdf" rel="noreferrer noreferrer" target="_blank">https://llvm.org/devmtg/2014-10/Slides/Cormack-BuildingAnLLVMBackend.pdf</a><br>
<a href="https://llvm.org/devmtg/2014-04/PDFs/Talks/Building%20an%20LLVM%20backend.pdf" rel="noreferrer noreferrer" target="_blank">https://llvm.org/devmtg/2014-04/PDFs/Talks/Building%20an%20LLVM%20backend.pdf</a><br>
<a href="http://web.archive.org/http://llvm.org/devmtg/2014-10/Videos/Building%20an%20LLVM%20backend-720.mov" rel="noreferrer noreferrer" target="_blank">http://web.archive.org/http://llvm.org/devmtg/2014-10/Videos/Building%20an%20LLVM%20backend-720.mov</a><br>
<a href="http://llvm.org/devmtg/2014-10/#tutorial1" rel="noreferrer noreferrer" target="_blank">http://llvm.org/devmtg/2014-10/#tutorial1</a><br>
<a href="http://www.inf.ed.ac.uk/teaching/courses/ct/other/LLVMBackend-2015-03-26_v2.pdf" rel="noreferrer noreferrer" target="_blank">http://www.inf.ed.ac.uk/teaching/courses/ct/other/LLVMBackend-2015-03-26_v2.pdf</a><br>
<br>
llvm-leg: LEG Example Backend<br>
LEG Example Backend: a simple example LLVM backend for an ARM-like <br>
architecture: 'LEG'.<br>
<a href="https://github.com/frasercrmck/llvm-leg" rel="noreferrer noreferrer" target="_blank">https://github.com/frasercrmck/llvm-leg</a><br>
<br>
Best,<br>
Matt<br>
</blockquote></div>
</blockquote></div>