Commit Graph

176 Commits

Author SHA1 Message Date
darkfeline
5b4abae763
[emacs] Fix Emacs library formatting (#76110)
This makes it easier to ship/install these using the builtin Emacs
package format (in particular, a Version is required).
2024-01-10 13:14:21 +01:00
Daniil Dudkin
8a6e54c9b3
[mlir][arith] Rename operations: maxfmaximumf, minfminimumf (#65800)
This patch is part of a larger initiative aimed at fixing floating-point `max` and `min` operations in MLIR: https://discourse.llvm.org/t/rfc-fix-floating-point-max-and-min-operations-in-mlir/72671.

This commit addresses Task 1.2 of the mentioned RFC. By renaming these operations, we align their names with LLVM intrinsics that have corresponding semantics.
2023-09-11 22:02:19 -07:00
Walter Erquinigo
9d1063642c
[NFC] Set a variable in the mlir data formatter (#65554)
The formatter fails when num_children is invoked and self.impl_type is
not set.
2023-09-06 20:13:39 -04:00
Benjamin Maxwell
dbf798fa64 [mlir] Fix generating checks for multiple funcs in generate-test-checks
This regressed in D154458 due to the added tracking of used variable
names that now also has to be cleared alongside the counter.

Reviewed By: rafaelubalmw, c-rhodes, awarzynski

Differential Revision: https://reviews.llvm.org/D156547
2023-08-03 15:55:03 +00:00
Rafael Ubal Tena
dea01f5e00 New features and bug fix in MLIR test generation tool
- Option `--variable_names <names>` allows the user to pass names for FileCheck
  regexps representing variables. Variable names are separated by commas, and
  empty names can be used to generate specific variable names automatically.
  For example, `--variable-names arg_0,arg_1,,,result` will produce regexp names
  `ARG_0`, `ARG_1`, `VAR_0`, `VAR_1`, `RESULT`, `VAR_2`, `VAR_3`, ...

- Option '--attribute_names <names>' can be used to generate global regexp names
  to represent attributes. Useful for affine maps. Same behavior as
  '--variable_names'.

- Bug fixed for scope detection of SSA variables in ops with nested regions that
  return SSA values (e.g., 'linalg.generic'). Originally, returned SSA values were
  inserted in the nested scope.

This version of the tool has been used to generate unit tests for the following
patch: https://reviews.llvm.org/D153291

For example, the main body of the test named 'test_select_2d_one_dynamic' was
generated using the following command:

```
$ mlir-opt -pass-pipeline='builtin.module(func.func(tosa-to-linalg))' test_select_2d_one_dynamic.tosa.mlir | generate-test-checks.py --attribute_names map0,map1,map2 --variable_names arg0,arg1,arg2,const1,arg0_dim1,arg1_dim1,,arg2_dim1,max_dim1,,,arg0_broadcast,,,,,,,arg1_broadcast,,,,,,,arg2_broadcast,,,,,,result
```

Reviewed By: eric-k256

Differential Revision: https://reviews.llvm.org/D154458
2023-07-07 18:15:11 +00:00
Jeremy Furtek
6685fd8239 [mlir] Add support for TF32 as a Builtin FloatType
This diff adds support for TF32 as a Builtin floating point type. This
supplements the recent addition of the TF32 semantic to the LLVM APFloat class
by extending usage to MLIR.

https://reviews.llvm.org/D151923

More information on the TF32 type can be found here:

https://blogs.nvidia.com/blog/2020/05/14/tensorfloat-32-precision-format/

Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D153705
2023-07-06 08:56:07 -07:00
Yuanfang Chen
e4246d90d0 [vscode-mlir] bump vsce version to 2.19.0
For https://bugs.chromium.org/p/llvm/issues/detail?id=46

Differential Revision: https://reviews.llvm.org/D153473
2023-06-22 09:25:31 -07:00
Ramkumar Ramachandra
10f8be19e7 tree-sitter-mlir: add a more complete grammar
Contribute a grammar, along with associated tests, from the upstream
project maintained at https://github.com/artagnon/tree-sitter-mlir. The
new grammar includes several fixes, and successfully parses 60-80% of
MLIR tests in the Arith, Math, ControlFlow, SCF, Tensor, Affine, and
Linalg dialects.

Differential Revision: https://reviews.llvm.org/D144408
2023-06-05 19:11:06 +01:00
Philipp Stephani
fdbfdbdf42 Add customization group for MLIR.
Otherwise the customization options don’t appear in any group.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D148920
2023-06-05 15:34:47 +02:00
Tobias Hieta
f9008e6366
[NFC][Py Reformat] Reformat python files in mlir subdir
This is an ongoing series of commits that are reformatting our
Python code.

Reformatting is done with `black`.

If you end up having problems merging this commit because you
have made changes to a python file, the best way to handle that
is to run git checkout --ours <yourfile> and then reformat it
with black.

If you run into any problems, post to discourse about it and
we will try to help.

RFC Thread below:

https://discourse.llvm.org/t/rfc-document-and-standardize-python-code-style

Differential Revision: https://reviews.llvm.org/D150782
2023-05-26 08:05:40 +02:00
Mehdi Amini
1020150e7a Add a GDB/LLDB interface for interactive debugging of MLIR Actions
This includes a small runtime acting as callback for the ExecutionEngine
and a C API that makes it possible to control from the debugger.

A python script for LLDB is included that hook a new `mlir` subcommand
and allows to set breakpoints and inspect the current action, the context
and the stack.

Differential Revision: https://reviews.llvm.org/D144817
2023-04-24 14:34:15 -07:00
David Majnemer
2f086f265b [APFloat] Add E4M3B11FNUZ
X. Sun et al. (https://dl.acm.org/doi/10.5555/3454287.3454728) published
a paper showing that an FP format with 4 bits of exponent, 3 bits of
significand and an exponent bias of 11 would work quite well for ML
applications.

Google hardware supports a variant of this format where 0x80 is used to
represent NaN, as in the Float8E4M3FNUZ format. Just like the
Float8E4M3FNUZ format, this format does not support -0 and values which
would map to it will become +0.

This format is proposed for inclusion in OpenXLA's StableHLO dialect: https://github.com/openxla/stablehlo/pull/1308

As part of inclusion in that dialect, APFloat needs to know how to
handle this format.

Differential Revision: https://reviews.llvm.org/D146441
2023-03-24 20:06:40 +00:00
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