Go to Definition in #included TableGen files
- Dominant language
- TypeScript
- Stars
- 71
- Forks
- 17
- PR merge metrics
- No merged PRs in 30d
Description
I am not sure if this is a bug or not, or whether I'm using the tablegen language server incorrectly.
I modified the LLVM CMake to generate an entry in `tablegen_compile_commands.yml` for every single tablegen'd file. This contains duplicates (as the one on `main` does if you build and include MLIR in the enabled projects), but all duplicates have the same include list.
I'm working on the AArch64 backend (in `llvm-project/llvm/lib/Target/AArch64`), and I don't think that "Go To Definition" works in some cases.
For instance:
- In `AArch64.td`, trying "Go To Definition" on `SubtargetFeature<...` correctly takes me to the definition of `SubtargetFeature` in Target.td.
- In `AArch64InstrInfo.td`, trying "Go To Definition" on anything doesn't work (I also get a problem on the first definition of not being able to find the class). The same applies in e.g. `AArch64SystemOperands.td` There are not `filepath:` entries for these files, because they are not passed to llvm-tblgen directly.
Is this because the extension doesn't cope well with how LLVM normally structures the tablegen in backends? For instance, in the AArch64 backend, `AArch64.td` contains a few definitions, and then a lot of `#include` for the other `AArch64*.td` files, and it is only `AArch64.td` which is run through `llvm-tblgen`. Some of the definitions in the `AArch64*.td` files rely on definitions in `AArch64.td`, but do not `#include` that file because the inclusions go in the other direction.
Presumably there are methods to solve this, as C/C++ plugins do cope with definitions/declarations in header files (which do not normally show up in a compile_commands.json), but I don't know how complex that would be to implement.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing Go to Definition for SubtargetFeature in AArch64.td, then compare it with AArch64InstrInfo.td and AArch64SystemOperands.td. Inspect tablegen_compile_commands.yml and the llvm-tblgen entry points to understand how included files are represented. Done means definitions in included AArch64*.td files resolve without filepath entries.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100