[llvm] b81bfea - [llvm][TableGen] Add a README to the main TableGen folder (#69943)

via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 25 01:45:34 PDT 2023


Author: David Spickett
Date: 2023-10-25T09:45:31+01:00
New Revision: b81bfea99ba373a149a8787f61d816812e88ceb0

URL: https://github.com/llvm/llvm-project/commit/b81bfea99ba373a149a8787f61d816812e88ceb0
DIFF: https://github.com/llvm/llvm-project/commit/b81bfea99ba373a149a8787f61d816812e88ceb0.diff

LOG: [llvm][TableGen] Add a README to the main TableGen folder (#69943)

Though I doubt that many people will land here directly, I thought it
odd that we didn't have one we can at least reference in response to questions.

The intro I've copied from the programmer's reference and added a simple
example. Then some links to resources and tools, which is the main
reason to have this page.

Added: 
    llvm/utils/TableGen/README.md

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/llvm/utils/TableGen/README.md b/llvm/utils/TableGen/README.md
new file mode 100644
index 000000000000000..e19701acfce63ac
--- /dev/null
+++ b/llvm/utils/TableGen/README.md
@@ -0,0 +1,55 @@
+# LLVM TableGen
+
+The purpose of TableGen is to generate complex output files based on information
+from source files that are significantly easier to code than the output files would be, and also easier to maintain and modify over time.
+
+The information is coded in a declarative style involving classes and records,
+which are then processed by TableGen.
+
+```
+class Hello <string _msg> {
+  string msg = !strconcat("Hello ", _msg);
+}
+
+def HelloWorld: Hello<"world!"> {}
+```
+```
+------------- Classes -----------------
+class Hello<string Hello:_msg = ?> {
+  string msg = !strconcat("Hello ", Hello:_msg);
+}
+------------- Defs -----------------
+def HelloWorld {        // Hello
+  string msg = "Hello world!";
+}
+```
+
+The internalized records are passed on to various backends, which extract
+information from a subset of the records and generate one or more output files.
+
+These output files are typically .inc files for C++, but may be any type of file
+that the backend developer needs.
+
+Resources for learning the language:
+* [TableGen Overview](https://llvm.org/docs/TableGen/index.html)
+* [Programmer's reference guide](https://llvm.org/docs/TableGen/ProgRef.html)
+* [Tutorial](jupyter/tablegen_tutorial_part_1.ipynb)
+* [Lessons in TableGen](https://www.youtube.com/watch?v=45gmF77JFBY) (video),
+  [slides](https://archive.fosdem.org/2019/schedule/event/llvm_tablegen/attachments/slides/3304/export/events/attachments/llvm_tablegen/slides/3304/tablegen.pdf)
+* [Improving Your TableGen Descriptions](https://www.youtube.com/watch?v=dIEVUlsiktQ)
+  (video), [slides](https://llvm.org/devmtg/2019-10/slides/Absar-ImprovingYourTableGenDescription.pdf)
+
+Writing TableGen backends:
+* [TableGen Backend Developer's Guide](https://llvm.org/docs/TableGen/BackGuide.html)
+* [How to write a TableGen backend](https://www.youtube.com/watch?v=UP-LBRbvI_U)
+  (video), [slides](https://llvm.org/devmtg/2021-11/slides/2021-how-to-write-a-tablegen-backend.pdf), also available as a
+	[notebook](jupyter/sql_query_backend.ipynb).
+
+TableGen in MLIR:
+* [Operation Definition Specification](https://mlir.llvm.org/docs/DefiningDialects/Operations/)
+* [Defining Dialect Attributes and Types](https://mlir.llvm.org/docs/DefiningDialects/AttributesAndTypes/)
+
+Useful tools:
+* [TableGen Jupyter Kernel](jupyter/)
+* [TableGen LSP Language Server](https://mlir.llvm.org/docs/Tools/MLIRLSP/#tablegen-lsp-language-server--tblgen-lsp-server)
+


        


More information about the llvm-commits mailing list