Prototype Assembly support for Clangd
A while ago I mentioned working on adding Assembly support to Clangd. I finally got some time to iron out the obvious bugs, and have announced it here as a discussion.
https://github.com/clangd/clangd/discussions/1805
(direct repo link https://github.com/BenjaminGrayNp1/llvm-project)
It's of particular interest to kernel developers I imagine, given the large amount of Assembly using preprocessor macros.
I probably won't add any more features for now, unless there's interest in adapting it up for upstream. I will try to keep this fork synchronized with upstream though, so I'll fix merge issues as much as possible.
Quoted 9 lines · Benjamin Gray
A while ago I mentioned working on adding Assembly support to Clangd. I finally got some time to iron out the obvious bugs, and have announced it here as a discussion.
https://github.com/clangd/clangd/discussions/1805
(direct repo link https://github.com/BenjaminGrayNp1/llvm-project)
Quoted 7 lines
It's of particular interest to kernel developers I imagine, given the large amount of Assembly using preprocessor macros.
I probably won't add any more features for now, unless there's interest in adapting it up for upstream. I will try to keep this fork synchronized with upstream though, so I'll fix merge issues as much as possible.
Neat! Yes, sorry I saw your first post and got distracted before I could reply.
I just recently started using clangd in vim via lunarvim. So far, I've been somewhat happy with it. Still need to work on lexing/parsing speed to make it smoother.
Can you tell us a little more about your use case?
Signature · 2 lines
Thanks, ~Nick Desaulniers
Quoted 18 lines · Nick Desaulniers
Quoted 9 lines · Benjamin Gray
A while ago I mentioned working on adding Assembly support to Clangd. I finally got some time to iron out the obvious bugs, and have announced it here as a discussion.
https://github.com/clangd/clangd/discussions/1805
(direct repo link https://github.com/BenjaminGrayNp1/llvm-project)
Quoted 7 lines
It's of particular interest to kernel developers I imagine, given the large amount of Assembly using preprocessor macros.
I probably won't add any more features for now, unless there's interest in adapting it up for upstream. I will try to keep this fork synchronized with upstream though, so I'll fix merge issues as much as possible.
Quoted 7 lines
Neat! Yes, sorry I saw your first post and got distracted before I could reply.
I just recently started using clangd in vim via lunarvim. So far, I've been somewhat happy with it. Still need to work on lexing/parsing speed to make it smoother.
Can you tell us a little more about your use case?
Yeah, I work on the PowerPC architecture part of the kernel, so sometimes that means reading/writing the Assembly files. A typical example of such a file is arch/powerpc/kernel/head_64.S
It's got a good mix of
- #include directives
- #ifdef regions
- CPP macro invocations
- Assembly instructions that look like they could be CPP macro invocations but aren't actually (e.g., ld r4,PACAKMSR(r13) )
- Lots of CPP macros generating function preambles / sectioning magic
Basically, I figured there's no technical reason this file can't be just as well supported by Clangd as C files with similar macro usage. I listed a few 'nice to haves' on the README, but really the macro support makes the biggest impact. As an aside, I only learnt after enabling it that every 'rN' in PowerPC assembly is actually a macro defined to just 'N' or '%rN' (it changes depending on which file you're looking at).
Another use case is symbol indexing, but that's not implemented here. If it was, then find references would work better (the Assembly files call a lot of C functions, which currently are not recognised by Clangd's find references/rename operations).
The documentation on hover was a personal want. When I started, I wasn't
experienced in the PowerPC Assembly instructions. The one I remember
struggling with the most was 'li'. It's an extended mnemonic, which
means it doesn't appear in the instruction index of the reference
manual. And searching a PDF for 'li' gives a lot of false positives
(Okular doesn't seem to offer whole word search). Obviously I found it in the end, but it would have been much easier if the editor could just tell me what it was and where to find more.