1,401 changes: 1,401 additions & 0 deletions mlir/docs/PDLL.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions mlir/lib/Tools/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
add_subdirectory(lsp-server-support)
add_subdirectory(mlir-lsp-server)
add_subdirectory(mlir-opt)
add_subdirectory(mlir-reduce)
Expand Down
11 changes: 11 additions & 0 deletions mlir/lib/Tools/lsp-server-support/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
add_mlir_library(MLIRLspServerSupportLib
Logging.cpp
Protocol.cpp
Transport.cpp

ADDITIONAL_HEADER_DIRS
${MLIR_MAIN_INCLUDE_DIR}/mlir/Tools/lsp-server

LINK_LIBS PUBLIC
MLIRSupport
)
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//

#ifndef LIB_MLIR_TOOLS_MLIRLSPSERVER_LSP_LOGGING_H
#define LIB_MLIR_TOOLS_MLIRLSPSERVER_LSP_LOGGING_H
#ifndef LIB_MLIR_TOOLS_LSPSERVERSUPPORT_LOGGING_H
#define LIB_MLIR_TOOLS_LSPSERVERSUPPORT_LOGGING_H

#include "mlir/Support/LLVM.h"
#include "llvm/Support/Debug.h"
Expand All @@ -30,13 +30,16 @@ class Logger {

/// Initiate a log message at various severity levels. These should be called
/// after a call to `initialize`.
template <typename... Ts> static void debug(const char *fmt, Ts &&... vals) {
template <typename... Ts>
static void debug(const char *fmt, Ts &&...vals) {
log(Level::Debug, fmt, llvm::formatv(fmt, std::forward<Ts>(vals)...));
}
template <typename... Ts> static void info(const char *fmt, Ts &&... vals) {
template <typename... Ts>
static void info(const char *fmt, Ts &&...vals) {
log(Level::Info, fmt, llvm::formatv(fmt, std::forward<Ts>(vals)...));
}
template <typename... Ts> static void error(const char *fmt, Ts &&... vals) {
template <typename... Ts>
static void error(const char *fmt, Ts &&...vals) {
log(Level::Error, fmt, llvm::formatv(fmt, std::forward<Ts>(vals)...));
}

Expand All @@ -59,4 +62,4 @@ class Logger {
} // namespace lsp
} // namespace mlir

#endif // LIB_MLIR_TOOLS_MLIRLSPSERVER_LSP_LOGGING_H
#endif // LIB_MLIR_TOOLS_LSPSERVERSUPPORT_LOGGING_H
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
//
//===----------------------------------------------------------------------===//

#ifndef LIB_MLIR_TOOLS_MLIRLSPSERVER_LSP_PROTOCOL_H_
#define LIB_MLIR_TOOLS_MLIRLSPSERVER_LSP_PROTOCOL_H_
#ifndef LIB_MLIR_TOOLS_LSPSERVERSUPPORT_PROTOCOL_H_
#define LIB_MLIR_TOOLS_LSPSERVERSUPPORT_PROTOCOL_H_

#include "mlir/Support/LLVM.h"
#include "llvm/ADT/Optional.h"
Expand Down Expand Up @@ -644,7 +644,8 @@ llvm::json::Value toJSON(const PublishDiagnosticsParams &params);
} // namespace mlir

namespace llvm {
template <> struct format_provider<mlir::lsp::Position> {
template <>
struct format_provider<mlir::lsp::Position> {
static void format(const mlir::lsp::Position &pos, raw_ostream &os,
StringRef style) {
assert(style.empty() && "style modifiers for this type are not supported");
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
//
//===----------------------------------------------------------------------===//

#ifndef LIB_MLIR_TOOLS_MLIRLSPSERVER_LSP_TRANSPORT_H_
#define LIB_MLIR_TOOLS_MLIRLSPSERVER_LSP_TRANSPORT_H_
#ifndef LIB_MLIR_TOOLS_LSPSERVERSUPPORT_TRANSPORT_H_
#define LIB_MLIR_TOOLS_LSPSERVERSUPPORT_TRANSPORT_H_

#include "Logging.h"
#include "Protocol.h"
Expand Down
4 changes: 1 addition & 3 deletions mlir/lib/Tools/mlir-lsp-server/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
add_mlir_library(MLIRLspServerLib
lsp/Logging.cpp
lsp/Protocol.cpp
lsp/Transport.cpp
LSPServer.cpp
MLIRServer.cpp
MlirLspServerMain.cpp
Expand All @@ -11,5 +8,6 @@ add_mlir_library(MLIRLspServerLib

LINK_LIBS PUBLIC
MLIRIR
MLIRLspServerSupportLib
MLIRParser
)
6 changes: 3 additions & 3 deletions mlir/lib/Tools/mlir-lsp-server/LSPServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
//===----------------------------------------------------------------------===//

#include "LSPServer.h"
#include "../lsp-server-support/Logging.h"
#include "../lsp-server-support/Protocol.h"
#include "../lsp-server-support/Transport.h"
#include "MLIRServer.h"
#include "lsp/Logging.h"
#include "lsp/Protocol.h"
#include "lsp/Transport.h"
#include "llvm/ADT/FunctionExtras.h"
#include "llvm/ADT/StringMap.h"

Expand Down
25 changes: 10 additions & 15 deletions mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//

#include "MLIRServer.h"
#include "lsp/Logging.h"
#include "lsp/Protocol.h"
#include "../lsp-server-support/Logging.h"
#include "../lsp-server-support/Protocol.h"
#include "mlir/IR/FunctionInterfaces.h"
#include "mlir/IR/Operation.h"
#include "mlir/Parser/AsmParserState.h"
Expand Down Expand Up @@ -38,8 +38,7 @@ static lsp::Range getRangeFromLoc(llvm::SourceMgr &mgr, SMRange range) {
}

/// Returns a language server location from the given source range.
static lsp::Location getLocationFromLoc(llvm::SourceMgr &mgr,
SMRange range,
static lsp::Location getLocationFromLoc(llvm::SourceMgr &mgr, SMRange range,
const lsp::URIForFile &uri) {
return lsp::Location{uri, getRangeFromLoc(mgr, range)};
}
Expand Down Expand Up @@ -82,8 +81,7 @@ getLocationFromLoc(llvm::SourceMgr &sourceMgr, Location loc,
// Use range of potential identifier starting at location, else length 1
// range.
location->range.end.character += 1;
if (Optional<SMRange> range =
AsmParserState::convertIdLocToRange(loc)) {
if (Optional<SMRange> range = AsmParserState::convertIdLocToRange(loc)) {
auto lineCol = sourceMgr.getLineAndColumn(range->End);
location->range.end.character =
std::max(fileLoc.getColumn() + 1, lineCol.second - 1);
Expand Down Expand Up @@ -134,9 +132,8 @@ static bool isDefOrUse(const AsmParserState::SMDefinition &def, SMLoc loc,
}

// Check the uses.
const auto *useIt = llvm::find_if(def.uses, [&](const SMRange &range) {
return contains(range, loc);
});
const auto *useIt = llvm::find_if(
def.uses, [&](const SMRange &range) { return contains(range, loc); });
if (useIt != def.uses.end()) {
if (overlappedRange)
*overlappedRange = *useIt;
Expand Down Expand Up @@ -188,8 +185,7 @@ static unsigned getBlockNumber(Block *block) {

/// Given a block and source location, print the source name of the block to the
/// given output stream.
static void printDefBlockName(raw_ostream &os, Block *block,
SMRange loc = {}) {
static void printDefBlockName(raw_ostream &os, Block *block, SMRange loc = {}) {
// Try to extract a name from the source location.
Optional<StringRef> text = getTextFromRange(loc);
if (text && text->startswith("^")) {
Expand Down Expand Up @@ -288,10 +284,9 @@ struct MLIRDocument {
Optional<lsp::Hover>
buildHoverForOperation(SMRange hoverRange,
const AsmParserState::OperationDefinition &op);
lsp::Hover buildHoverForOperationResult(SMRange hoverRange,
Operation *op, unsigned resultStart,
unsigned resultEnd,
SMLoc posLoc);
lsp::Hover buildHoverForOperationResult(SMRange hoverRange, Operation *op,
unsigned resultStart,
unsigned resultEnd, SMLoc posLoc);
lsp::Hover buildHoverForBlock(SMRange hoverRange,
const AsmParserState::BlockDefinition &block);
lsp::Hover
Expand Down
4 changes: 2 additions & 2 deletions mlir/lib/Tools/mlir-lsp-server/MlirLspServerMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
//===----------------------------------------------------------------------===//

#include "mlir/Tools/mlir-lsp-server/MlirLspServerMain.h"
#include "../lsp-server-support/Logging.h"
#include "../lsp-server-support/Transport.h"
#include "LSPServer.h"
#include "MLIRServer.h"
#include "lsp/Logging.h"
#include "lsp/Transport.h"
#include "mlir/IR/Dialect.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Program.h"
Expand Down