[PSA] Tablegen language features via MLIR VSCode Extension

Hi all, this is just a friendly-ish PSA that the MLIR vscode extension now (as of v0.0.8) provides builtin syntax highlighting (newly rewritten!) and language features for TableGen. The documentation for the extension will be updated in the next week to properly document this, but wanted to send out an early PSA so people weren’t too surprised by what’s going on. The provided language features right now are semi-limited, but I intend to build out more, like code completion/signature help/inlay hints/etc., over the coming months (as I have time, I’m mostly doing this for fun when I should really be doing my actual work). Try it out if your interested (though for most that develop upstream/have a checkout of MLIR in-tree I assume it’ll automatically be running, hence this PSA :smiley:), there’s a good chance that you may even crash the TableGen parser :upside_down_face:. Feel free to suggest features (or add them yourself), but I’ll otherwise just be adding things as I find time.

Syntax highlighting is always present (including in markdown files). To run the language facilities (think go-to-definition) you essentially need two things:

  • The tblgen-lsp-server executable

    • Unlike MLIR you don’t need your own version of this. The extension also looks for this in your workspace, so in most cases if you’ve built mlir you don’t actually need to do anything else.
  • A compilation database file: tablegen_compile_commands.yml

    • This is a yaml document containing information on file includes/build information/etc. (essentially a tablegen equivalent of compile_commands), e.g:

      --- !FileInfo:
        filepath: "/home/user/llvm/mlir/lib/Dialect/Arithmetic/IR/ArithmeticCanonicalization.td"
        includes: "/home/user/llvm/mlir/lib/Dialect/Arithmetic/IR;/home/user/llvm/mlir/include"
    • This should-ish be generated automatically for things using mlir_tablegen

    • The extension looks for this in a build/ directory by default, but it can be manually provided to the extension if necessary.

– River


The extension doc is now updated and includes poorly made images for the various features! Like I said before, the current set of features is limited but the PDLL feature set should give a decent hint of what’s to come.

I’m guessing this is the extension: GitHub - llvm/vscode-mlir

When I try to install, it tells me I need to trust it (Visual Studio Code Workspace Trust security), but not many other extensions have that.

Is that because of settings, external executables or internal scripting that I need to run? If so, and the trusted part isn’t directly related to MLIR, perhaps it could be a separate extension?

Ignore me, apparently that’s a new thing in VSCode and nothing to do with the extension… Others have that, too. Hmm.