[flang-commits] [flang] dda20ea - [flang] Add fir-lsp-server (#114059)

via flang-commits flang-commits at lists.llvm.org
Wed Oct 30 08:05:22 PDT 2024


Author: David Truby
Date: 2024-10-30T15:05:18Z
New Revision: dda20ea73d958584e6b162b34dd421582c52ddbb

URL: https://github.com/llvm/llvm-project/commit/dda20ea73d958584e6b162b34dd421582c52ddbb
DIFF: https://github.com/llvm/llvm-project/commit/dda20ea73d958584e6b162b34dd421582c52ddbb.diff

LOG: [flang] Add fir-lsp-server (#114059)

This patch adds a fir-lsp-server tool for editor support for editing fir
files, using the existing MLIR lsp server support.

See https://mlir.llvm.org/docs/Tools/MLIRLSP/ for more information.

Added: 
    flang/tools/fir-lsp-server/CMakeLists.txt
    flang/tools/fir-lsp-server/fir-lsp-server.cpp

Modified: 
    flang/tools/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/flang/tools/CMakeLists.txt b/flang/tools/CMakeLists.txt
index 337545ae0d4d7a..1d2d2c608faf95 100644
--- a/flang/tools/CMakeLists.txt
+++ b/flang/tools/CMakeLists.txt
@@ -12,3 +12,4 @@ add_subdirectory(flang-driver)
 add_subdirectory(tco)
 add_subdirectory(f18-parse-demo)
 add_subdirectory(fir-opt)
+add_subdirectory(fir-lsp-server)

diff  --git a/flang/tools/fir-lsp-server/CMakeLists.txt b/flang/tools/fir-lsp-server/CMakeLists.txt
new file mode 100644
index 00000000000000..ff0ced6693b97f
--- /dev/null
+++ b/flang/tools/fir-lsp-server/CMakeLists.txt
@@ -0,0 +1,17 @@
+set(LLVM_LINK_COMPONENTS
+  Core
+  Support
+  AsmParser
+  )
+
+add_flang_tool(fir-lsp-server fir-lsp-server.cpp)
+
+get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
+get_property(extension_libs GLOBAL PROPERTY MLIR_EXTENSION_LIBS)
+target_link_libraries(fir-lsp-server PRIVATE
+  CUFDialect
+  FIRDialect
+  HLFIRDialect
+  MLIRLspServerLib
+  ${dialect_libs}
+  ${extension_libs})

diff  --git a/flang/tools/fir-lsp-server/fir-lsp-server.cpp b/flang/tools/fir-lsp-server/fir-lsp-server.cpp
new file mode 100644
index 00000000000000..8b724e292b5abb
--- /dev/null
+++ b/flang/tools/fir-lsp-server/fir-lsp-server.cpp
@@ -0,0 +1,9 @@
+#include "mlir/Tools/mlir-lsp-server/MlirLspServerMain.h"
+#include "flang/Optimizer/Support/InitFIR.h"
+
+int main(int argc, char **argv) {
+  mlir::DialectRegistry registry;
+  fir::support::registerNonCodegenDialects(registry);
+  fir::support::addFIRExtensions(registry);
+  return mlir::failed(mlir::MlirLspServerMain(argc, argv, registry));
+}


        


More information about the flang-commits mailing list