diff --git a/README.md b/README.md index cc3697c..13eaed7 100644 --- a/README.md +++ b/README.md @@ -106,6 +106,17 @@ lit build/dev/mlir/test/ -v --filter "convert" --- +## Language server + +If you use VSCode and would like to enable the custom MLIR LSP server including quantum dialects, add this line to your +settings: + +``` +"mlir.server_path": "build/dev/bin/qcc-lsp-server" +``` + +--- + ## License headers The license headers in this repository are managed using the [`license-eye`](https://github.com/apache/skywalking-eyes) tool. diff --git a/mlir/test/CMakeLists.txt b/mlir/test/CMakeLists.txt index 00c9d33..1216ac7 100644 --- a/mlir/test/CMakeLists.txt +++ b/mlir/test/CMakeLists.txt @@ -1,7 +1,7 @@ configure_lit_site_cfg(${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py MAIN_CONFIG ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py) -set(MLIR_COMPILER_TEST_DEPENDS FileCheck count not qcc-opt qcc) +set(MLIR_COMPILER_TEST_DEPENDS FileCheck count not qcc-opt qcc qcc-lsp-server) add_lit_testsuite(test-qcc-project "Run the QCC project tests" ${CMAKE_CURRENT_BINARY_DIR} DEPENDS ${MLIR_COMPILER_TEST_DEPENDS}) diff --git a/mlir/tools/CMakeLists.txt b/mlir/tools/CMakeLists.txt index 2b8df2a..29726fe 100644 --- a/mlir/tools/CMakeLists.txt +++ b/mlir/tools/CMakeLists.txt @@ -1,2 +1,3 @@ add_subdirectory(qcc) add_subdirectory(qcc-opt) +add_subdirectory(qcc-lsp-server) diff --git a/mlir/tools/qcc-lsp-server/CMakeLists.txt b/mlir/tools/qcc-lsp-server/CMakeLists.txt new file mode 100644 index 0000000..2b6b73c --- /dev/null +++ b/mlir/tools/qcc-lsp-server/CMakeLists.txt @@ -0,0 +1,15 @@ +add_mlir_tool(qcc-lsp-server qcc-lsp-server.cpp) + +target_link_libraries( + qcc-lsp-server + PRIVATE MLIRLspServerLib + MLIRRegisterAllDialects + MLIRRegisterAllExtensions + MLIRRegisterAllPasses + # Dialect libraries used by our project + QCCJaspDialect + QCCAuxDialect + MLIRQCDialect) + +llvm_update_compile_flags(qcc-lsp-server) +mlir_check_all_link_libraries(qcc-lsp-server) diff --git a/mlir/tools/qcc-lsp-server/qcc-lsp-server.cpp b/mlir/tools/qcc-lsp-server/qcc-lsp-server.cpp new file mode 100644 index 0000000..32fcd48 --- /dev/null +++ b/mlir/tools/qcc-lsp-server/qcc-lsp-server.cpp @@ -0,0 +1,28 @@ +//===- qcc-lsp-server.cpp - QCC custom MLIR LSP server -------------------===// +// +// Part of the FullStaQD Project, under the Apache License v2.0 with LLVM +// Exceptions. +// See /LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "qcc/Dialect/Aux_/IR/Aux_.h" +#include "qcc/Dialect/Jasp/IR/Jasp.h" + +#include "mlir/Dialect/QC/IR/QCDialect.h" +#include "mlir/IR/DialectRegistry.h" +#include "mlir/InitAllDialects.h" +#include "mlir/Tools/mlir-lsp-server/MlirLspServerMain.h" + +int main(int argc, char** argv) { + mlir::DialectRegistry registry; + + // Register all builtin dialects and their extensions/interfaces. + mlir::registerAllDialects(registry); + + // Register our custom project dialects. + registry.insert(); + + return mlir::succeeded(mlir::MlirLspServerMain(argc, argv, registry)) ? 0 : 1; +}