Skip to content

Commit

Permalink
Create ttmlir-lsp-server (#1462)
Browse files Browse the repository at this point in the history
This change introduces the tool `ttmlir-lsp-server`. It will fall under `build/bin`, and is built alongside the rest of the compiler via `cmake --build build`. This is a language server that should be used alongside your IDE/Text editor to give you IDE like features while editing .mlir files. For more info, please see https://mlir.llvm.org/docs/Tools/MLIRLSP/

Closes #1383
  • Loading branch information
ctodTT authored Dec 3, 2024
1 parent 7a6f335 commit ca09c69
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Conversion/TTKernelToEmitC/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_mlir_library(TTMLIRTTKernelToEmitC
add_mlir_conversion_library(TTMLIRTTKernelToEmitC
TTKernelToEmitC.cpp

ADDITIONAL_HEADER_DIRS
Expand Down
1 change: 1 addition & 0 deletions tools/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
add_subdirectory(ttmlir-opt)
add_subdirectory(ttmlir-lsp-server)
add_subdirectory(ttmlir-translate)
add_subdirectory(explorer)
18 changes: 18 additions & 0 deletions tools/ttmlir-lsp-server/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
get_property(conversion_libs GLOBAL PROPERTY MLIR_CONVERSION_LIBS)
get_property(extension_libs GLOBAL PROPERTY MLIR_EXTENSION_LIBS)

set(LIBS ${dialect_libs} ${conversion_libs} ${extension_libs}
MLIROptLib
MLIRTargetCpp
TTMLIRStatic
MLIRLspServerLib
)

add_llvm_executable(ttmlir-lsp-server ttmlir-lsp-server.cpp DISABLE_LLVM_LINK_LLVM_DYLIB)
llvm_update_compile_flags(ttmlir-lsp-server)
target_link_libraries(ttmlir-lsp-server PRIVATE ${LIBS})

mlir_check_all_link_libraries(ttmlir-lsp-server)

install(TARGETS ttmlir-lsp-server DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT Test EXCLUDE_FROM_ALL)
15 changes: 15 additions & 0 deletions tools/ttmlir-lsp-server/ttmlir-lsp-server.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// SPDX-FileCopyrightText: (c) 2024 Tenstorrent AI ULC
//
// SPDX-License-Identifier: Apache-2.0

#include "mlir/InitAllDialects.h"
#include "ttmlir/RegisterAll.h"

#include "mlir/Tools/mlir-lsp-server/MlirLspServerMain.h"

int main(int argc, char **argv) {
mlir::DialectRegistry registry;
mlir::tt::registerAllDialects(registry);

return mlir::failed(mlir::MlirLspServerMain(argc, argv, registry));
}

0 comments on commit ca09c69

Please sign in to comment.