7 Commits

Author SHA1 Message Date
Bertik23
a3a25996b1
[LLVM][MLIR] Move LSP server support library from MLIR into LLVM (#157885)
This is a second PR on this patch (first #155572), that fixes the
linking problem for `flang-aarch64-dylib` test.

The SupportLSP library was made a component library.

---

This PR moves the generic Language Server Protocol (LSP) server support
code that was copied from clangd into MLIR, into the LLVM tree so it can
be reused by multiple subprojects.

Centralizing the generic LSP support in LLVM lowers the barrier to
building new LSP servers across the LLVM ecosystem and avoids each
subproject maintaining its own copy.

The code originated in clangd and was copied into MLIR for its LSP
server. MLIR had this code seperate to be reused by all of their LSP
server. This PR relocates the MLIR copy into LLVM as a shared component
into LLVM/Support. If this is not a suitable place, please suggest a
better one.

A follow up to this move could be deduplication with the original clangd
implementation and converge on a single shared LSP support library used
by clangd, MLIR, and future servers.
What changes

mlir/include/mlir/Tools/lsp-server-support/{Logging, Protocol,
Transport}.h moved to llvm/include/llvm/Support/LSP
mlir/lib/Tools/lsp-server-support/{Logging, Protocol, Transport}.cpp
moved to llvm/lib/Support/LSP

and their namespace was changed from mlir to llvm

I ran clang-tidy --fix and clang-format on the whole moved files (last
two commits), as they are basically new files and should hold up to the
code style used by LLVM.

MLIR LSP servers where updated to include these files from their new
location and account for the namespace change.

This PR is made as part of the LLVM IR LSP project
([RFC](https://discourse.llvm.org/t/rfc-ir-visualization-with-vs-code-extension-using-an-lsp-server/87773))
2025-09-11 17:17:52 +00:00
Nikita Popov
31bee3421b Revert "[LLVM][MLIR] Move LSP server support library from MLIR into LLVM (#155572)"
This reverts commit c0aee322f7024250fd4a2c49f56534011178d07c.
This reverts commit a0b8d548fd250c92c8f9274b57e38ad3f0b215e9.

Fails to link with MLIR dylib build.
2025-09-09 16:42:09 +02:00
Bertik23
a0b8d548fd
[LLVM][MLIR] Move LSP server support library from MLIR into LLVM (#155572)
This PR moves the generic Language Server Protocol (LSP) server support
code that was copied from clangd into MLIR, into the LLVM tree so it can
be reused by multiple subprojects.

Centralizing the generic LSP support in LLVM lowers the barrier to
building new LSP servers across the LLVM ecosystem and avoids each
subproject maintaining its own copy.

The code originated in clangd and was copied into MLIR for its LSP
server. MLIR had this code seperate to be reused by all of their LSP
server. This PR relocates the MLIR copy into LLVM as a shared component
into `LLVM/Support`. If this is not a suitable place, please suggest a
better one.

A follow up to this move could be deduplication with the original clangd
implementation and converge on a single shared LSP support library used
by clangd, MLIR, and future servers.

### What changes
* `mlir/include/mlir/Tools/lsp-server-support/{Logging, Protocol,
Transport}.h` moved to `llvm/include/llvm/Support/LSP`
* `mlir/lib/Tools/lsp-server-support/{Logging, Protocol, Transport}.cpp`
moved to `llvm/lib/Support/LSP`

and their namespace was changed from `mlir` to `llvm`

I ran clang-tidy --fix and clang-format on the whole moved files (last
two commits), as they are basically new files and should hold up to the
code style used by LLVM.

MLIR LSP servers where updated to include these files from their new
location and account for the namespace change.

This PR is made as part of the LLVM IR LSP project
([RFC](https://discourse.llvm.org/t/rfc-ir-visualization-with-vs-code-extension-using-an-lsp-server/87773))
2025-09-09 10:02:45 +00:00
Kazu Hirata
d66af9c69b
[mlir] Use SetVector::insert_range (NFC) (#133595) 2025-03-29 14:27:10 -07:00
River Riddle
305d718539 [mlir][NFC] Move the headers for lsp-server-support to include/
This makes it a bit easier to share the functionality for building
language servers, and makes the API public. No real functional
change, as the API was already intended for this anyways.

Differential Revision: https://reviews.llvm.org/D142790
2023-01-27 17:36:06 -08:00
River Riddle
01652d889c [mlir:PDLL-LSP] Add a custom LSP command for viewing the output of PDLL
This commit adds a new PDLL specific LSP command, pdll.viewOutput, that
allows for viewing the intermediate outputs of a given PDLL file. The available
intermediate forms currently mirror those in mlir-pdll, namely: AST, MLIR, CPP.
This is extremely useful for a developer of PDLL, as it simplifies various testing,
and is also quite useful for users as they can easily view what is actually being
generated for their PDLL files.

This new command is added to the vscode client, and is available in the right
client context menu of PDLL files, or via the vscode command palette.

Differential Revision: https://reviews.llvm.org/D124783
2022-05-30 17:35:34 -07:00
River Riddle
dc9fb65c4f [mlir][Tablegen-LSP] Add support for a compilation database
This provides a format for externally specifying the include directories
for a source file. The format of the tablegen database is exactly the
same as that for PDLL, namely it includes the absolute source file name and
the set of include directories. The database format is shared to simplify
the infra, and also because the format itself is general enough to share. Even
if we desire to expand in the future to contain the actual compilation command,
nothing there is specific enough that we would need two different formats.

As with PDLL, support for generating the database is added to our mlir_tablegen
cmake command.

Differential Revision: https://reviews.llvm.org/D125441
2022-05-27 02:39:49 -07:00