Skip to content

Commit

Permalink
[flang] Add fir-lsp-server (llvm#114059)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
DavidTruby authored Oct 30, 2024
1 parent 95c2d79 commit dda20ea
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions flang/tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
17 changes: 17 additions & 0 deletions flang/tools/fir-lsp-server/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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})
9 changes: 9 additions & 0 deletions flang/tools/fir-lsp-server/fir-lsp-server.cpp
Original file line number Diff line number Diff line change
@@ -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));
}

0 comments on commit dda20ea

Please sign in to comment.