Hi all, myself and some colleagues at Arm were discussing how we can help people learn how to do the work that we do in llvm. Which for architecture support involves a lot of TableGen.
I thought it would be great to have more “explorer” type tools along the lines of Compiler Explorer, which I use all the time to experiment with various languages.
There is a system in the same lane called Jupyter (https://jupyter.org/). If you don’t know already, Jupyter lets you make “notebooks” which are like the notes you might take when you’re studying. Except that you can include the code you were using, and the result of it, inside the document itself.
(meaning, if someone else’s notes don’t cover what you want, just edit the code and find out for yourself!)
Jupyter has a Python focus (hence the name) but you can add what’s called a “kernel” for almost anything. So I did one for Tablegen. Here’s an example of what you can do with it:
%reset
%json
class Root {}
def thing : Root {}
{
"!instanceof": {
"Root": [
"thing"
]
},
"!tablegen_json_version": 1,
"thing": {
"!anonymous": false,
"!fields": [],
"!name": "thing",
"!superclasses": [
"Root"
]
}
}```
Or you can see a full notebook here: llvm-project/LLVM TableGen.md at 7eb80c910e923c395b0807068d7485a246989cf3 · DavidSpickett/llvm-project · GitHub
I am looking for anyone who would like to review the changes (either because you want to review some Python code or you have used other notebooks in the past).
- ⚙ D132378 [LLVM][TableGen] Add jupyter kernel for llvm-tblgen
- ⚙ D132646 [LLVM][TableGen] Support combined cells in jupyter kernel
- ⚙ D132647 [LLVM][TableGen] Add JSON magic directive to Jupyter kernel
You can also use the tree here to try it out: GitHub - DavidSpickett/llvm-project at tablgen-jupyter
I welcome any suggestions for future features. I am new to notebooks myself so I am still impressed at just being able to embed the output, I’m sure there’s more to it.
My next goal is to write a notebook that covers the basics of Tablegen. Following the same topics as 1 TableGen Programmer’s Reference — LLVM 16.0.0git documentation. That will be checked into the repo next to the kernel itself.