Commit Graph

164 Commits

Author SHA1 Message Date
Jake Hall
96267b6b88 [mlir] Add Float8E5M2FNUZ and Float8E4M3FNUZ types to MLIR
Float8E5M2FNUZ and Float8E4M3FNUZ have been added to APFloat in D141863.
This change adds these types as MLIR builtin types alongside Float8E5M2
and Float8E4M3FN (added in D133823 and D138075).

Reviewed By: krzysz00

Differential Revision: https://reviews.llvm.org/D143744
2023-02-13 18:26:27 +00:00
Tobias Hieta
fff762d674
Revert "[CMake] Remove custom ccache CMake logic"
This reverts commit 0fad18c44a.

We need bots to be updated first.
2023-02-13 08:57:19 +01:00
Tobias Hieta
0fad18c44a
[CMake] Remove custom ccache CMake logic
CMake supports CMAKE_CXX_COMPILER_LAUNCHER since CMake 3.4
so this custom CMake logic we had in LLVM can now be removed.

The only downside with this is that we can't set ccache
options from LLVM CMake, but it's arguable that this doesn't
belong in LLVM but should be done in a script calling the
build.

This was discussed in the forums here:

https://discourse.llvm.org/t/tips-for-incremental-building/67289/4?u=tobiashieta

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D143468
2023-02-13 08:42:38 +01:00
Lei Zhang
84ce59a0e4 [mlir][spirv] Fix MLIR code snippet marker in TD files
Reviewed By: kuhar

Differential Revision: https://reviews.llvm.org/D141316
2023-01-09 12:58:37 -08:00
River Riddle
62fec084d6 [mlir] Add LLDB visualizers for MLIR constructs
This commit adds a significant amount of visualizers attempting
to cover the majority of our visualization needs. It covers:

* Operations/OperationName/Ops/OpInterfaces
* Attributes/Types/Attr|TypeInterfaces/NamedAttribute
* Blocks/Regions
* Various range types (e.g. ValueRange/TypeRange)
* Values/BlockArguments/OpResults

This does require an NFC change to interfaces to rename
the concept field to avoid clash with the base class. It
also requires exposing a few method to the debugger
to help resolve information that is non-trivial to reconstruct.
These methods are re-exported using a debug_Blah naming
scheme to avoid messing with hot methods.

Note that this makes use of the new callback feature in lldb-16
(currently trunk) that allows for providing visualizers based on
a dynamic callback, instead of just the typename. It requires
a very new lldb, but allows for providing good default visualization
for all attributes/operations/types out of the box.

Differential Revision: https://reviews.llvm.org/D139602
2022-12-11 22:45:34 -08:00
Jakub Kuderski
03e6bf5f56 [mlir][spirv] Define spirv.*Dot integer dot product ops
This covers `SDot`, `SUDot`, and `UDot`. The `*AccSat` version will be
added in a follow-up revision.

Reviewed By: antiagainst

Differential Revision: https://reviews.llvm.org/D139242
2022-12-06 20:17:41 -05:00
Ivan Butygin
339c87a8a0 [mlir][spirv] Add group ops
Also, gen_spirv_dialect script was broken was broken due to SPV->SPIRV renamings.

Differential Revision: https://reviews.llvm.org/D138756
2022-11-29 15:03:31 +01:00
Mehdi Amini
377af86847 MLIR: Add --fix-error to clang-tidy script 2022-11-18 06:22:32 +00:00
River Riddle
c1e27d2989 [vscode-mlir] Bump to version 0.0.11
Since version 0.10 we've:

* Added support for viewing/editing bytecode files
2022-09-28 02:50:24 -07:00
Jakub Kuderski
2d62833048 Reland "[mlir][spirv] Change td def/class prefix from SPV to SPIRV"
This reverts commit ce82530cd0.

Undo accidental Vulkan/SPIR-V name changes.
Tested with `ninja check-mlir check-mlir-mlir-spirv-cpu-runner check-mlir-mlir-vulkan-runner`.
2022-09-26 14:45:52 -04:00
Jakub Kuderski
ce82530cd0 Revert "[mlir][spirv] Change td def/class prefix from SPV to SPIRV"
This reverts commit a2052b8794.

This commit renamed some Vulkan identifiers that shouldn't have been
renamed, e.g., `SPV_KHR_storage_buffer_storage_class`.
2022-09-26 12:40:35 -04:00
Jakub Kuderski
a2052b8794 [mlir][spirv] Change td def/class prefix from SPV to SPIRV
Tested with `check-mlir` and `check-mlir-integration`.

Fixes: https://github.com/llvm/llvm-project/issues/56863

Reviewed By: antiagainst

Differential Revision: https://reviews.llvm.org/D134649
2022-09-26 11:42:49 -04:00
Jacques Pienaar
55e4417bb9 [mlir][emacs] Enable loading bytecode files as text
Use auto-compression-mode to read bytecode files in human readable
manner.

Differential Revision: https://reviews.llvm.org/D133879
2022-09-16 15:08:55 -07:00
River Riddle
82b6549654 [mlir:vscode] Add support for loading big bytecode files
VSCode doesn't let our extension manage files >50mb. This commit
adds a proper diagnostic in this case, and also gives the user an option
to open as a temporary .mlir file instead.

Differential Revision: https://reviews.llvm.org/D133242
2022-09-06 14:49:16 -07:00
Jakub Kuderski
b8bea837f3 [mlir][spirv] Refactor vendor op definitions
Use dedicated vendor op classes/categories. This is so that we can later
change the mnemonics of all vendor ops by changing the base class: `SPV_VendorOp`.

Issue: https://github.com/llvm/llvm-project/issues/56863
2022-09-06 13:35:08 -04:00
River Riddle
f7b8a70e7a [mlir:vscode] Add support for viewing and editing a bytecode file as .mlir
This commit adds support for interacting with a (valid) bytecode file in the same
way as .mlir. This allows editing, using all of the traditional LSP features, etc. but
still using bytecode as the on-disk serialization format. Loading a bytecode file this
way will fail if the bytecode is invalid, and saving will fail if the edited .mlir is invalid.

Differential Revision: https://reviews.llvm.org/D132970
2022-09-02 18:16:05 -07:00
Lei Zhang
a29fffc475 [mlir][spirv] Migrate to use specalized enum attributes
Previously we are using IntegerAttr to back all SPIR-V enum
attributes. Therefore we all such attributes are showed like
IntegerAttr in IRs, which is barely readable and breaks
roundtripability of the IR. This commit changes to use
`EnumAttr` as the base directly so that we can have separate
attribute definitions and better IR printing.

Reviewed By: kuhar

Differential Revision: https://reviews.llvm.org/D131311
2022-08-09 14:14:54 -04:00
Lei Zhang
4bd25d0b81 [mlir][spirv] Refresh base definitions to latest spec (v1.6)
This commit updates all SPIR-V enum definitions to match the latest
specification (v1.6 revision 2). Along the way, fixed some issues
in `gen_spirv_dialect.py` and added a new script for refreshing
all op definitions for such cases.

Reviewed By: kuhar

Differential Revision: https://reviews.llvm.org/D131293
2022-08-08 12:22:32 -04:00
River Riddle
40abd7ea64 [mlir] Remove OpaqueElementsAttr
This attribute is technical debt from the early stages of MLIR, before
ElementsAttr was an interface and when it was more difficult for
dialects to define their own types of attributes. At present it isn't
used at all in tree (aside from being convenient for eliding other
ElementsAttr), and has had little to no evolution in the past three years.

Differential Revision: https://reviews.llvm.org/D129917
2022-08-01 15:00:54 -07:00
Jakub Kuderski
3930cc6847 [mlir][spirv] Rename spv.ocl to spv.cl. NFC.
This is to improve the consistency within the SPIR-V dialect and to make op names a bit shorter.

Reviewed By: antiagainst

Differential Revision: https://reviews.llvm.org/D130194
2022-07-20 17:46:45 -04:00
Ingo Müller
b9f5b02fd0 [mlir][mbr] Improve diagnostics on error with raise from.
This commit extends the `raise` statements on errors in user-provided
code with `from e` clauses that attach the original exception to the one
being raised. This allows to debug the root cause of the error more
easily.

Reviewed By: SaurabhJha

Differential Revision: https://reviews.llvm.org/D129762
2022-07-15 15:15:58 +00:00
Ryan Thomas Lynch (@emosy)
f192392299 [vscode-mlir] add tablegen <> bracket colorization
Add support for colorizing angle brackets "<>" in TableGen files.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D128229
2022-07-08 10:58:38 -07:00
River Riddle
d81edc7d9d [vscode-mlir] Bump to version 0.0.10
Since version 0.9 we've:

* Bumped the language-client to `8.0.2-next.5` to fix various bugs/stability issues
* Fixed an issue with starting a language server for non-workspace files
2022-07-07 14:55:57 -07:00
River Riddle
7e08885582 [mlir-vscode] Bump the language client version
This includes a fix for a code completion/document update bug where
code completion results were being requested before the document actually
updated.

Differential Revision: https://reviews.llvm.org/D129182
2022-07-07 13:35:53 -07:00
River Riddle
0c442776a9 [mlir-vscode] Explicitly set the return type for didOpen
In the newer versions of the language client, this explicitly expects a
Promise<void> return type, otherwise it errors out.

Fixes #56297

Differential Revision: https://reviews.llvm.org/D129181
2022-07-07 13:35:53 -07:00
rdzhabarov
f59c279b72 [mlir] Fix usages of run-reproducer.
There is no need to specify `run-reproducer` explicitly anymore.

Differential Revision: https://reviews.llvm.org/D129010
2022-07-01 18:36:07 +00:00
Krzysztof Drewniak
7c5c4e781b [gdb-scripts] Add to_string methods to printer implementations
Some GDB versions require all prettyprinter classes to define to_string.
This commit adds these definitions.

Reviewed By: csigg

Differential Revision: https://reviews.llvm.org/D127969
2022-06-21 16:09:30 +00:00
River Riddle
a3a4f0335f [vscode-mlir] Bump to version 0.9
Since version 0.8 we've added:

* Switched PDLL and TableGen to use incremental doc updates
* Added support to PDLL for inlay hints
2022-06-06 20:20:19 -07:00
River Riddle
5919eab55c [mlir:PDLL] Add support for inlay hints
These allow for displaying additional inline information,
such as the types of variables, names operands/results,
constraint/rewrite arguments, etc. This requires a bump in the
vscode extension to a newer version, as inlay hints are a new LSP feature.

Differential Revision: https://reviews.llvm.org/D126033
2022-06-06 20:20:19 -07:00
River Riddle
bb81b3b274 [vscode-mlir] Bump to version 0.8
Since version 0.7 we've added:

* Initial language support for TableGen
* Tweaked syntax highlighting for PDLL
* Added a new command to view intermediate PDLL output
2022-06-02 16:35:09 -07:00
River Riddle
01652d889c [mlir:PDLL-LSP] Add a custom LSP command for viewing the output of PDLL
This commit adds a new PDLL specific LSP command, pdll.viewOutput, that
allows for viewing the intermediate outputs of a given PDLL file. The available
intermediate forms currently mirror those in mlir-pdll, namely: AST, MLIR, CPP.
This is extremely useful for a developer of PDLL, as it simplifies various testing,
and is also quite useful for users as they can easily view what is actually being
generated for their PDLL files.

This new command is added to the vscode client, and is available in the right
client context menu of PDLL files, or via the vscode command palette.

Differential Revision: https://reviews.llvm.org/D124783
2022-05-30 17:35:34 -07:00
River Riddle
dc9fb65c4f [mlir][Tablegen-LSP] Add support for a compilation database
This provides a format for externally specifying the include directories
for a source file. The format of the tablegen database is exactly the
same as that for PDLL, namely it includes the absolute source file name and
the set of include directories. The database format is shared to simplify
the infra, and also because the format itself is general enough to share. Even
if we desire to expand in the future to contain the actual compilation command,
nothing there is specific enough that we would need two different formats.

As with PDLL, support for generating the database is added to our mlir_tablegen
cmake command.

Differential Revision: https://reviews.llvm.org/D125441
2022-05-27 02:39:49 -07:00
River Riddle
d6708b7419 [mlir-vscode] Add support for highlighting pdll and tablegen markdown code blocks
This essentially just piggy backs off of the existing mlir support.

Differential Revision: https://reviews.llvm.org/D125734
2022-05-27 00:34:42 -07:00
Cullen Rhodes
6ad6b00f6a [mlir] vim: add bf16 type 2022-05-17 13:28:31 +00:00
River Riddle
1febbd67aa [mlir][PDLL] Tweak the grammar to highlight partial code better
This commit enables proper highlighting when inner statements are
outside of a constraint/pattern/etc. This shouldn't really happen in
actual code, but can happen in documentation (which uses the same
syntax grammar).
2022-05-16 16:46:13 -07:00
River Riddle
5de12bb703 [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
2022-05-16 16:03:51 -07:00
River Riddle
a6cef03f66 [mlir] Remove the type keyword from type alias definitions
This was carry over from LLVM IR where the alias definition can
be ambiguous, but MLIR type aliases have no such problems.
Having the `type` keyword is superfluous and doesn't add anything.
This commit drops it, which also nicely aligns with the syntax for
attribute aliases (which doesn't have a keyword).

Differential Revision: https://reviews.llvm.org/D125501
2022-05-16 13:54:02 -07:00
River Riddle
80c28a400c [mlir] Bump mlir-vscode to 0.0.7
The syntax highlighting for mlir has gotten a significant facelift,
we also have some recent bug fixes for server launches.
2022-05-12 15:52:46 -07:00
River Riddle
86f5caeee9 [mlir] Significantly overhaul the textmate grammar
The current grammar is really crusty, only supports a handful of
cases, and is also out-of-date after various refactorings. This commit
refactors the textmate grammar to handle significantly more cases,
and now provides proper coloring for a majority of cases (including
dialect attributes, operations, types, etc.)

Differential Revision: https://reviews.llvm.org/D125458
2022-05-12 15:50:32 -07:00
River Riddle
867cd5007d [mlir-LSP] Ensure existing documents are process synchronously
This prevents races where we accidentally launched multiple servers.
2022-05-09 15:23:23 -07:00
Jacques Pienaar
9a4472c56c [mlir] Add basic tree-sitter grammar file
tree-sitter grammar file that tries to closely matches LangRef (it could use
some tweaking and cleanup, but kept fairly basic). Also updated LangRef in
places where found some issues while doing the nearly direct transcription.

This only adds a grammar file, not all the other parts (npm etc) that
accompanies it. Those I'll propose for separate repo like we do for vscode
extension.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D124352
2022-04-28 11:42:46 -07:00
River Riddle
fb5a59f6e1 [mlir][PDLL] Add initial support for a PDLL compilation database
The compilation database acts in a similar way to the compilation database
(compile_commands.json) used by clang-tidy, i.e. it provides additional
information about the compilation of project files to help the language
server. The main piece of information provided by the PDLL compilation
database in this commit is the set of include directories used when processing
the input .pdll file. This allows for the server to properly process .pdll files
that use includes anchored by the include directories set up in the build system.

The structure of the textual form of a compilation database is a yaml file
containing documents of the following form:

```
--- !FileInfo:
  filepath: <string> - Absolute file path of the file.
  includes: <string> - Semi-colon delimited list of include directories.
```

This commit also adds support to cmake for automatically generating
a `pdll_compile_commands.yml` file at the top-level of the build
directory.

Differential Revision: https://reviews.llvm.org/D124076
2022-04-26 18:33:17 -07:00
River Riddle
2310ced874 [mlir][NFC] Update textual references of func to func.func in examples+python scripts
The special case parsing of `func` operations is being removed.
2022-04-20 22:17:26 -07:00
Okwan Kwon
18a01527ea [mlir] Fix a typo to load lsp-mode correctly.
Differential Revision: https://reviews.llvm.org/D123745
2022-04-14 00:04:40 +00:00
River Riddle
e93ba84262 [mlir-vscode] Don't emit errors if the user didn't set the server path
This avoids emitting errors in situations where the user doesn't have a server
setup, and doesn't mean to (e.g. when they merely want syntax highlighting).

Differential Revision: https://reviews.llvm.org/D123240
2022-04-11 15:41:19 -07:00
River Riddle
4a6f5d73a4 [mlir-vscode] Refactor server creation to be lazy
We currently proactively create language clients for every workspace folder,
and every language. This makes startup time more costly, and also emits errors
for missing language servers in contexts that the user currently isn't in. For example,
if a user opens a .mlir file we don't want to emit errors about .pdll files. We also don't
want to emit errors for missing servers in workspace folders that don't even utilize
MLIR.

This commit refactors client creation to lazy-load when a document that requires the
server is opened.

Differential Revision: https://reviews.llvm.org/D123184
2022-04-11 15:41:19 -07:00
River Riddle
3c7e467406 [mlir-vscode] Fix processing of files not within the workspace
In a previous commit we added proper support for separate configurations
per workspace folder, but that effectively broke support for processing out-of-workspace
files. Given how useful this is (e.g. when iterating on a test case in /tmp), this
commit refactors server creation to support this again. We support this case using
a "fallback" server that specifically handles files not within the workspace. This uses
the configuration settings for the current workspace itself (not the specific folder).

Differential Revision: https://reviews.llvm.org/D123183
2022-04-11 15:41:19 -07:00
River Riddle
43c0a45a79 [mlir-vscode] Add better support for multiple workspace folders
We currently only launch one set of language clients when starting the extension,
but this has the unfortunate effect of applying the same settings to all workspace
folders. This commit adds support for multiple workspace folders by launching
a server for each folder in the workspace. This allows for having different servers
for different workspace folders, e.g. when there are multiple MLIR projects in
the same workspace.

Differential Revision: https://reviews.llvm.org/D122793
2022-04-05 13:41:40 -07:00
River Riddle
ade148d936 [mlir-vscode] Add better resolution for server file paths
We currently require that server paths are full paths, which is
fairly inconvenient for a myriad of reasons. This commit
attempts to resolve a given server path with the current workspace.

This has a nice additional affect that we can now actually have
default server paths. This means that mlir-lsp-server and
mlir-pdll-lsp-server can be transparently picked up from
build directories (i.e. generally no need for upstream users to
configure the extension).

Fixes #54627

Differential Revision: https://reviews.llvm.org/D122792
2022-04-05 13:41:40 -07:00
Mehdi Amini
435a176db9 [mlir] Add the Emacs support for MLIR's LSP server
In order to use the MLIR LSP server in Emacs, first the `mlir-lsp-client.el`
has to be loaded via elisp and then, one should call `lsp-mlir-setup` function
to setup the LSP client. After that simply calling the `lsp` function while
the `mlir-mode` is active with result in finding the language server (default
to `mlir-lsp-server`) via the `lsp-mlir-server-executable` customization variable
and connecting to it by the LSP library. Users who use MLIR's language server
library to create their own server can simply set the variable `lsp-mlir-server-executable`
to point to their own implementation executable.

Reviewed By: tschuett

Differential Revision: https://reviews.llvm.org/D123002
2022-04-05 18:11:35 +00:00