This is a humble initiative to collect all the “pain points” of LLVM TableGen (eg: llvm-tblgen) like common errors or missing features in the below excel sheet along with the next corrective steps like
documenting the meaning of the common errors on the official TableGen documentation or enhancing the existing LLVM documentation
or making changes to the TableGen Backend for say emitting better error messages,
thus making TableGen more user friendly.
The idea for this initiative arises from personal struggles of using llvm-tblgen and then further motivation from Chris Lattner during my talk at 2025 AsiaLLVM Developer Meeting to bring the LLVM community together to list down the pain points and the corrective measures for the same, thus making LLVM TableGen more user friendly!
Hence, I thought may be we can call this initiative as “FriendlyTableGen”!
Aim of the initiative :
Collect more issues/features/documentation opportunities related to TableGen.
Anyone interested, can choose to work on the issues of their choice.
Additionally, I shall keep this thread updated with monthly progress.
There are three sheets
1.1 Sheet 1 : The plan i.e what to do with these errors
1.2 Sheet 2 : The errors, its meaning and some empty placeholders for the corrective actions
1.3 Sheet 3 : Good to have features.
The excel sheet currently provides only commenting access to avoid any accidental edits. Please let me know if you want write access. Would be happy to share.
The excel sheet has been pre-populated by some of my colleagues at NVIDIA.
Looking forward to your valuable inputs!
Special thanks to @jurahul for his valuable guidance in finding out the various existing github issues.
Thank you for putting up this spreadsheet! I’m really happy to see this initiative happening.
A meta suggestion: it will be nice if we could split these feedbacks & issues into those related to the language itself (e.g. the lack of source location on Init) v.s. those raised from individual TableGen backend (e.g. support for multiple destinations in a ISel pattern). There might be some overlaps but I reckon most of them would fall in either categories.
When I wrote the backend for MIR patterns, I tried to make it more user friendly by treating it more like a compiler frontend. I added some basic semantics check, reported error messages, handled failures and tested all errors messages as best I could. I wanted to move away from the “assert/crash on error” pattern that’s used in TableGen usually. It’s not perfect but I think it does a pretty OK job. I’m happy to see there is an effort to improve other backends too!
Another issue with TableGen is that backends don’t have a ton of documentation. It’s pretty barebones, and the motto is “check what others are doing” for many things. I documented the MIR patterns backend with examples, I wish other backends had that (especially the core ones). Even after years of working on LLVM I still find myself struggling, or even getting stuck entirely, when working on ISel patterns. The generic "type set is empty” message is awful.
For anyone like me not paying enough attention, there are several tabs to the sheet, the first is just the intro.
I worked on TableGen in the past (Tools for Learning LLVM TableGen - The LLVM Project Blog), but kept to the language itself. In my experience the language itself is the smaller part of the challenge, developers are thrown into the deep end because LLVM’s use of it is very advanced.
Room for improvement on both of course, so I’m glad to see this. I hope that it will lead to improvements in the things built with TableGen, as Pierre said above.
Cascade of errors triggered by one small mistake makes it very hard to find the right error to fix.
Little context on what went wrong. Things like using edit distance to suggest possible mispellings, or identifying poorly formed patterns (with an actionable fixit) would materially help.
Second this. And a big problem here is that individual TableGen class / record’s meaning varies by how individual TableGen backend interprets them. The most famous example is that add is both used as an ADD SDNode and an operator to build a collection of registers for a register class. Another more subtle example is that ins could be a list of input operands for a MLIR operation or that of an instruction in LLVM backends.
In the past I really wished we could have a doxygen-alike documentation system but more recently when I think of this problem, I feel like maybe we should solve this problem the other way around and ask individual TableGen backend to present a documentation of what TableGen records or classes they consume and how they interpret those.
Another issue with TableGen is that backends don’t have a ton of documentation. It’s pretty barebones, and the motto is “check what others are doing” for many things.
@Pierre-vh , @mshockwave
Can we list down the areas/topics for which we would like to improve documentation ?
I am familiar with llvm-tblgen, so I am hopeful to contribute to some topics related to it.
For anyone like me not paying enough attention, there are several tabs to the sheet, the first is just the intro.
@DavidSpickett Thanks for pointing this out, I have updated the first tab in the sheet with the relevant details
Cascade of errors triggered by one small mistake makes it very hard to find the right error to fix.
@preames I think I have come across this. But do you have an example ?
A fair share of occurrences of cryptic error messages comes from type inference. I thought about adding tracing code to it, so when an error occurs it could provide a better information about its origin. It’s been on my nice-to-do-one-day list, but it wasn’t a priority since it would require non-trivial changes to the code.
If there is enough interest in it, this idea could be revisited.
I think that the biggest productivity boost would be to finish the support for LSP for tablegen such that it also works in the LLVM context not just MLIR. There has been initiatives on this before (e.g.[RFC] TableGen: Include What You Use (IWYU)) but I don’t think anything got realized.
>> Type set is empty for each HW mode: possible type contradiction in the pattern below (use -print-records with llvm-tblgen to see all expanded records).
Improving the error reporting for that is actually the first in this tracking excel sheet . In fact I am very much in support of improving the error reporting.
Even reporting for which operand did the type inferencing fail will be very helpful.
In my experience so far, there are two cases/reasons due to which we can get the error
(1) The operands need to be assigned proper classes
(2) The generic SDnode or GMIR code is not in accordance with the InOperandList, OutOperandList specified by the assembly. And the InOperandList or OutOperandList need to be either modified or the patterns need to be converted to C++ code.
Do you think any other case can invoke this error ?
>> but it wasn’t a priority since it would require non-trivial changes to the code.
Just a thought, since its non-trivial effort, may be this can be considered as a “mini GSOC project” and someone new to the TableGen code can contribute under your guidance ?
In any case, it would be wonderful to have this IMO.
In my experience, the cause of the error is usually something simple, but I don’t remember what categories it usually falls into (outside of what you already mentioned).
I like the “mini-GSOC” idea. I’d have to brush up on that part of TableGen myself (it’s been a while since I worked on it). I remember that I thought the type inference code could use some refactoring to make it easier to understand, but before I can guide anyone I’d have to revisit that and see what concrete changes are needed, if any.
Hello Everyone
Just wanted to share a monthly summary of this initiative.
The GOOD :
We have got a wonderful response to this initiative. And many of the projects which were technical debts have been collected.
We also saw projects for which PR was raised but could not be merged. So this initiative hopefully will help checkin those changes .
I recently came across a github issue where we were using “asserts” instead of proper error reporting. This seems to be a wider issue and can be easily addressed according to me.
Additionally some bug fixes and enhancements to TableGen were checked in recently.
The Underwhelming Aspects :
Slow progress on the issues. Not many volunteers for the issues/items.
I am working on adding SMLoc to Init classes with guidance from Rahul Joshi. I shall update the github issue regularly.
I am hopeful that in the next monthly summary we will have better updates
If you have any feedbacks on this please let me know.
I am reviving this thread after a long time as I somehow was unable to devote the expected time to this initiative.
So this is my attempt at reviving this initiative, i.e
inviting anyone interested to contribute to the issues mentioned on the excel sheet - FriendlyTableGen - Google Sheets or even add new issues/feature enhancements.
I will again try to target some tasks from the list
I was wondering, if we can try to emit better error message than
Type set is empty for each HW mode:
whenever there is a type mismatch, because I feel this will be of great help to developers.
I am interested to contribute to this effort. I am currently trying to understand the code in CodeGenDAGPatterns.cpp with Claude’s help, but wanted to check if you had any inputs for the same.