Add `circt-lsp-server` tool which can be used with the MLIR VSCode extension (#2199)

This commit is contained in:
George Lyon 2021-11-17 12:16:30 -08:00 committed by GitHub
parent 2c47356c31
commit 7c006d9fb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 78 additions and 0 deletions

View File

@ -1,4 +1,5 @@
add_subdirectory(circt-lsp-server)
add_subdirectory(circt-opt)
add_subdirectory(circt-reduce)
add_subdirectory(circt-rtl-sim)

View File

@ -0,0 +1,55 @@
set(LLVM_OPTIONAL_SOURCES
null.cpp
)
get_property(mlir_dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
get_property(circt_dialect_libs GLOBAL PROPERTY CIRCT_DIALECT_LIBS)
get_property(conversion_libs GLOBAL PROPERTY MLIR_CONVERSION_LIBS)
set(LLVM_LINK_COMPONENTS
Core
Support
AsmParser
)
if(MLIR_INCLUDE_TESTS)
set(test_libs
MLIRAffineTransformsTestPasses
MLIRShapeTestPasses
MLIRSPIRVTestPasses
MLIRTestAnalysis
MLIRTestDialect
MLIRTestIR
MLIRTestPass
MLIRTestReducer
MLIRTestRewrite
MLIRTestTransforms
)
endif()
set(LIBS
${mlir_dialect_libs}
${circt_dialect_libs}
${conversion_libs}
${test_libs}
MLIRLoopAnalysis
MLIRAnalysis
MLIRDialect
MLIRLspServerLib
MLIRParser
MLIRPass
MLIRTransforms
MLIRTransformUtils
MLIRSupport
MLIRIR
)
add_llvm_tool(circt-lsp-server
circt-lsp-server.cpp
DEPENDS
${LIBS}
)
target_link_libraries(circt-lsp-server PRIVATE ${LIBS})
llvm_update_compile_flags(circt-lsp-server)
mlir_check_all_link_libraries(circt-lsp-server)

View File

@ -0,0 +1,22 @@
//===- circt-lsp-server.cpp - CIRCT Language Server ---------- ------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "circt/InitAllDialects.h"
#include "mlir/IR/Dialect.h"
#include "mlir/IR/MLIRContext.h"
#include "mlir/InitAllDialects.h"
#include "mlir/Tools/mlir-lsp-server/MlirLspServerMain.h"
using namespace mlir;
int main(int argc, char **argv) {
DialectRegistry registry;
registerAllDialects(registry);
circt::registerAllDialects(registry);
return failed(MlirLspServerMain(argc, argv, registry));
}