From ec143a2deaeedeac1e9bc603cf1124cbe85b48fd Mon Sep 17 00:00:00 2001 From: Collin Tod Date: Mon, 2 Dec 2024 20:04:20 +0000 Subject: [PATCH] Create `ttmlir-lsp-server` --- lib/Conversion/TTKernelToEmitC/CMakeLists.txt | 2 +- tools/CMakeLists.txt | 1 + tools/ttmlir-lsp-server/CMakeLists.txt | 18 ++++++++++++++++++ tools/ttmlir-lsp-server/ttmlir-lsp-server.cpp | 15 +++++++++++++++ 4 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 tools/ttmlir-lsp-server/CMakeLists.txt create mode 100644 tools/ttmlir-lsp-server/ttmlir-lsp-server.cpp diff --git a/lib/Conversion/TTKernelToEmitC/CMakeLists.txt b/lib/Conversion/TTKernelToEmitC/CMakeLists.txt index 4ed57a5d4..429a694f3 100644 --- a/lib/Conversion/TTKernelToEmitC/CMakeLists.txt +++ b/lib/Conversion/TTKernelToEmitC/CMakeLists.txt @@ -1,4 +1,4 @@ -add_mlir_library(TTMLIRTTKernelToEmitC +add_mlir_conversion_library(TTMLIRTTKernelToEmitC TTKernelToEmitC.cpp ADDITIONAL_HEADER_DIRS diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index e558d0567..e5a62f9c5 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -1,3 +1,4 @@ add_subdirectory(ttmlir-opt) +add_subdirectory(ttmlir-lsp-server) add_subdirectory(ttmlir-translate) add_subdirectory(explorer) diff --git a/tools/ttmlir-lsp-server/CMakeLists.txt b/tools/ttmlir-lsp-server/CMakeLists.txt new file mode 100644 index 000000000..1dd058a71 --- /dev/null +++ b/tools/ttmlir-lsp-server/CMakeLists.txt @@ -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) diff --git a/tools/ttmlir-lsp-server/ttmlir-lsp-server.cpp b/tools/ttmlir-lsp-server/ttmlir-lsp-server.cpp new file mode 100644 index 000000000..d23425e96 --- /dev/null +++ b/tools/ttmlir-lsp-server/ttmlir-lsp-server.cpp @@ -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)); +}