Skip to content

Commit

Permalink
Merge branch 'Xilinx:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
jackl-xilinx authored Mar 19, 2024
2 parents f9aad29 + 19d9a96 commit a1c90bd
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 3 deletions.
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ configure_lit_site_cfg(
set(TEST_DEPENDS
FileCheck count not
AIEPythonModules
aie-lsp-server
aie-opt
aie-translate
)
Expand Down
43 changes: 43 additions & 0 deletions test/aie-lsp-server/hover.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// This file is licensed 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
//
// (c) Copyright 2024 AMD Inc.
//
// RUN: aie-lsp-server -lit-test < %s | FileCheck -strict-whitespace %s
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"mlir","capabilities":{},"trace":"off"}}
// -----
{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{
"uri":"test:///foo.mlir",
"languageId":"mlir",
"version":1,
"text":"module @example0 {\n%t42 = aie.tile(4, 2)\n%buf42 = aie.buffer(%t42) : memref<256xi32>\n}"
}}}
// -----
// Hover on an operation.
{"jsonrpc":"2.0","id":1,"method":"textDocument/hover","params":{
"textDocument":{"uri":"test:///foo.mlir"},
"position":{"line":1,"character":7}
}}
// CHECK: "id": 1,
// CHECK-NEXT: "jsonrpc": "2.0",
// CHECK-NEXT: "result": {
// CHECK-NEXT: "contents": {
// CHECK-NEXT: "kind": "markdown",
// CHECK-NEXT: "value": "\"aie.tile\"\n\nGeneric Form:\n\n```mlir\n%0 = \"aie.tile\"() <{col = 4 : i32, row = 2 : i32}> : () -> index\n```\n"
// CHECK-NEXT: },
// CHECK-NEXT: "range": {
// CHECK-NEXT: "end": {
// CHECK-NEXT: "character": 15,
// CHECK-NEXT: "line": 1
// CHECK-NEXT: },
// CHECK-NEXT: "start": {
// CHECK-NEXT: "character": 7,
// CHECK-NEXT: "line": 1
// CHECK-NEXT: }
// CHECK-NEXT: }
// CHECK-NEXT: }
// -----
{"jsonrpc":"2.0","id":7,"method":"shutdown"}
// -----
{"jsonrpc":"2.0","method":"exit"}
2 changes: 1 addition & 1 deletion test/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
)

# suffixes: A list of file extensions to treat as test files.
config.suffixes = [".mlir", ".py"]
config.suffixes = [".mlir", ".py", ".test"]

# test_source_root: The root path where tests are located.
config.test_source_root = os.path.dirname(__file__)
Expand Down
5 changes: 3 additions & 2 deletions tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ add_subdirectory(aie-opt)
if(NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
add_subdirectory(aie-reset)
endif()
add_subdirectory(bootgen)
add_subdirectory(aie-lsp-server)
add_subdirectory(aie-translate)
add_subdirectory(chess-clang)
add_subdirectory(aie2xclbin)
add_subdirectory(bootgen)
add_subdirectory(chess-clang)
18 changes: 18 additions & 0 deletions tools/aie-lsp-server/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# This file is licensed 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
#
# (c) Copyright 2024 AMD Inc.

get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)

set(AIE_LSP_LIBS
${dialect_libs}
MLIRLspServerLib
)

add_llvm_tool(aie-lsp-server
aie-lsp-server.cpp
)

target_link_libraries(aie-lsp-server PRIVATE ${AIE_LSP_LIBS})
23 changes: 23 additions & 0 deletions tools/aie-lsp-server/aie-lsp-server.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//===- aie-lsp-server -------------------------------------------*- C++ -*-===//
//
// This file is licensed 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
//
// (c) Copyright 2024 AMD Inc.
//
// A server exposing AIE dialects to be used by IDE & editors supporting LSP
// https://microsoft.github.io/language-server-protocol like Emacs, VScode, etc.
//===----------------------------------------------------------------------===//

#include "mlir/InitAllDialects.h"
#include "mlir/Tools/mlir-lsp-server/MlirLspServerMain.h"

#include "aie/InitialAllDialect.h"

int main(int argc, char **argv) {
mlir::DialectRegistry registry;
mlir::registerAllDialects(registry);
xilinx::registerAllDialects(registry);
return mlir::failed(mlir::MlirLspServerMain(argc, argv, registry));
}

0 comments on commit a1c90bd

Please sign in to comment.