summaryrefslogtreecommitdiff
path: root/mlir/utils
diff options
context:
space:
mode:
authorRiver Riddle <riddleriver@gmail.com>2022-05-09 10:36:48 -0700
committerRiver Riddle <riddleriver@gmail.com>2022-05-16 16:03:51 -0700
commit5de12bb703c5104b3fd64ee51c6900d6171d826a (patch)
tree7ab6b383bbaedb911548117b612917aac50eebdd /mlir/utils
parent45e01ce5fe6a5e4dc25ffdf626caa344fbcb93dd (diff)
downloadllvm-5de12bb703c5104b3fd64ee51c6900d6171d826a.tar.gz
[mlir][Tablegen-LSP] Add support for a basic TableGen language server
This follows the same general structure of the MLIR and PDLL language servers. This commits adds the basic functionality for setting up the server, and initially only supports providing diagnostics. Followon commits will build out more comprehensive behavior. Realistically this should eventually live in llvm/, but building in MLIR is an easier initial step given that: * All of the necessary LSP functionality is already here * It allows for proving out useful language features (e.g. compilation databases) without affecting wider scale tablegen users * MLIR has a vscode extension that can immediately take advantage of it Differential Revision: https://reviews.llvm.org/D125440
Diffstat (limited to 'mlir/utils')
-rw-r--r--mlir/utils/vscode/.gitignore1
-rw-r--r--mlir/utils/vscode/package.json29
-rw-r--r--mlir/utils/vscode/src/mlirContext.ts5
-rw-r--r--mlir/utils/vscode/tablegen-language-configuration.json71
4 files changed, 104 insertions, 2 deletions
diff --git a/mlir/utils/vscode/.gitignore b/mlir/utils/vscode/.gitignore
index 6cf6422af90a..9354f9119287 100644
--- a/mlir/utils/vscode/.gitignore
+++ b/mlir/utils/vscode/.gitignore
@@ -3,5 +3,6 @@ node_modules
.vscode-test
*.vsix
grammar.json
+tablegen-grammar.json
!.vscode \ No newline at end of file
diff --git a/mlir/utils/vscode/package.json b/mlir/utils/vscode/package.json
index 3178d9890756..793ea00e18fe 100644
--- a/mlir/utils/vscode/package.json
+++ b/mlir/utils/vscode/package.json
@@ -15,11 +15,15 @@
"keywords": [
"LLVM",
"MLIR",
- "PDLL"
+ "PDLL",
+ "TableGen",
+ "tblgen",
+ "tablegen"
],
"activationEvents": [
"onLanguage:mlir",
- "onLanguage:pdll"
+ "onLanguage:pdll",
+ "onLanguage:tablegen"
],
"main": "./out/extension",
"scripts": {
@@ -75,6 +79,17 @@
".pdll"
],
"configuration": "./pdll-language-configuration.json"
+ },
+ {
+ "id": "tablegen",
+ "aliases": [
+ "TableGen",
+ "tblgen"
+ ],
+ "extensions": [
+ ".td"
+ ],
+ "configuration": "./tablegen-language-configuration.json"
}
],
"grammars": [
@@ -108,6 +123,11 @@
"language": "pdll",
"scopeName": "source.pdll",
"path": "./pdll-grammar.json"
+ },
+ {
+ "language": "tablegen",
+ "scopeName": "source.tablegen",
+ "path": "./tablegen-grammar.json"
}
],
"configuration": {
@@ -129,6 +149,11 @@
"type": "array",
"description": "A list of `pdll_compile_commands.yml` database files containing information about .pdll files processed by the server."
},
+ "mlir.tablegen_server_path": {
+ "scope": "resource",
+ "type": "string",
+ "description": "The file path of the tblgen-lsp-server executable."
+ },
"mlir.onSettingsChanged": {
"type": "string",
"default": "prompt",
diff --git a/mlir/utils/vscode/src/mlirContext.ts b/mlir/utils/vscode/src/mlirContext.ts
index a8dbb229b5bd..c8d4f78818a0 100644
--- a/mlir/utils/vscode/src/mlirContext.ts
+++ b/mlir/utils/vscode/src/mlirContext.ts
@@ -42,6 +42,8 @@ export class MLIRContext implements vscode.Disposable {
serverSettingName = 'server_path';
} else if (document.languageId === 'pdll') {
serverSettingName = 'pdll_server_path';
+ } else if (document.languageId === 'tablegen') {
+ serverSettingName = 'tablegen_server_path';
} else {
return;
}
@@ -268,6 +270,9 @@ export class MLIRContext implements vscode.Disposable {
if (serverSettingName === 'server_path') {
return 'mlir-lsp-server';
}
+ if (serverSettingName === 'tablegen_server_path') {
+ return 'tblgen-lsp-server';
+ }
return '';
}
diff --git a/mlir/utils/vscode/tablegen-language-configuration.json b/mlir/utils/vscode/tablegen-language-configuration.json
new file mode 100644
index 000000000000..24227bc75ef7
--- /dev/null
+++ b/mlir/utils/vscode/tablegen-language-configuration.json
@@ -0,0 +1,71 @@
+{
+ "comments": {
+ "lineComment": "//",
+ "blockComment": [
+ "/*",
+ "*/"
+ ]
+ },
+ "brackets": [
+ [
+ "{",
+ "}"
+ ],
+ [
+ "[",
+ "]"
+ ],
+ [
+ "(",
+ ")"
+ ],
+ [
+ "<",
+ ">"
+ ]
+ ],
+ "autoClosingPairs": [
+ [
+ "{",
+ "}"
+ ],
+ [
+ "[",
+ "]"
+ ],
+ [
+ "(",
+ ")"
+ ],
+ [
+ "<",
+ ">"
+ ],
+ [
+ "\"",
+ "\""
+ ]
+ ],
+ "surroundingPairs": [
+ [
+ "{",
+ "}"
+ ],
+ [
+ "[",
+ "]"
+ ],
+ [
+ "(",
+ ")"
+ ],
+ [
+ "<",
+ ">"
+ ],
+ [
+ "\"",
+ "\""
+ ]
+ ]
+} \ No newline at end of file