Commit Graph

1747 Commits

Author SHA1 Message Date
Rik Huijzer
061e4f24b2 [mlir][doc] Escape effects, interfaces, and traits (#76297)
Fixes https://github.com/llvm/llvm-project/issues/76270.

Thanks to @scottamain for the clear description.


Co-authored-by: Scott Main <scott@modular.com>
2023-12-23 21:48:33 +01:00
Guray Ozen
5caae72d1a [mlir][gpu] Productize test-lower-to-nvvm as gpu-lower-to-nvvm (#75775)
The `test-lower-to-nvvm` pipeline serves as the common and proper
pipeline for nvvm+host compilation, and it's used across our CUDA
integration tests.

This PR updates the `test-lower-to-nvvm` pipeline to `gpu-lower-to-nvvm`
and moves it within `InitAllPasses.h`. The aim is to call it from
Python, also having a standardize compilation process for nvvm.
2023-12-19 08:40:46 +01:00
Kazu Hirata
88d319a29f [mlir] Use StringRef::{starts,ends}_with (NFC)
This patch replaces uses of StringRef::{starts,ends}with with
StringRef::{starts,ends}_with for consistency with
std::{string,string_view}::{starts,ends}_with in C++20.

I'm planning to deprecate and eventually remove
StringRef::{starts,ends}with.
2023-12-13 22:58:30 -08:00
Stella Laurenzo
8eff570482 Add missing dep on MLIRToLLVMIRTranslationRegistration to mlir-opt. (#75111)
I was not able to fully triage why this just started failing on one of
our bots as it seems that the use was added 4 months ago. I would assume
that it was accidentally coming in transitively in some way as the dep
was definitely missing.

For context, this started failing in [our
byo_llvm](https://github.com/openxla/iree/blob/main/build_tools/llvm/byo_llvm.sh)
build on a stock build of MLIR on top of an existing LLVM. We were
getting:

```
ld.lld: error: undefined symbol: mlir::registerSPIRVDialectTranslation(mlir::DialectRegistry&)                                                        >>> referenced by mlir-opt.cpp
>>>               tools/mlir-opt/CMakeFiles/mlir-opt.dir/mlir-opt.cpp.o:(main)
```
2023-12-12 14:10:06 -08:00
Boian Petkantchin
4b3446771f [mlir][mesh] Add endomorphism simplification for all-reduce (#73150)
Does transformations like
all_reduce(x) + all_reduce(y) -> all_reduce(x + y)

max(all_reduce(x), all_reduce(y)) -> all_reduce(max(x, y))
when the all_reduce element-wise op is max.

Added general rewrite pattern HomomorphismSimplification and
EndomorphismSimplification that encapsulate the general algorithm.
Made specialization for all-reduce with respect to
addf, addi, minsi, maxsi, minimumf and maximumf
in the Arithmetic dialect.
2023-12-12 10:21:52 -08:00
Fehr Mathieu
3dbac2c007 [mlir] Expose type and attribute names in the MLIRContext and abstract type/attr classes (#72189)
This patch expose the type and attribute names in C++ as methods in the
`AbstractType` and `AbstractAttribute` classes, and keep a map of names
to `AbstractType` and `AbstractAttribute` in the `MLIRContext`. Type and
attribute names should be unique.

It adds support in ODS to generate the `getName` methods in
`AbstractType` and `AbstractAttribute`, through the use of two new
variables, `typeName` and `attrName`. It also adds names to C++-defined
type and attributes.
2023-12-01 00:39:34 +01:00
Rik Huijzer
e9869b5770 [mlir][docgen] Add ops source link (#73657)
This patch suggests to change two things. Firstly, it adds a source link
above the generated operations docs (above the `emitOpDoc` calls). This
link will point directly to the source TableGen file for the group of
operations. For example, for the current
[`amdgpu`](https://mlir.llvm.org/docs/Dialects/AMDGPU/) page, the link
will add a source link below the "Operation definition" heading pointing
to
[`mlir/include/mlir/Dialect/AMDGPU/IR/AMDGPU.td`](https://github.com/llvm/llvm-project/blob/main/mlir/include/mlir/Dialect/AMDGPU/IR/AMDGPU.td).
The link is wrapped in a "op-definitions-source-link" class which could
allow for custom styling, but it also looks reasonable without custom
styling I think:

![afbeelding](https://github.com/llvm/llvm-project/assets/20724914/7c0e59b9-b14b-4f5d-a671-c87e857a7b03)

Secondly, this patch simplifies the header names such as "Operation
definition" and "Attribute definition" to "Operations" and "Attributes"
respectively. This is in line with manually defined subheadings on pages
such as the one for the
[`vector`](https://mlir.llvm.org/docs/Dialects/Vector/#operations)
dialect.
2023-11-30 10:29:50 +01:00
Rik Huijzer
88f0e4c75c [mlir][async] Avoid crash when not using func.func (#72801)
The `createParallelComputeFunction` crashed when calling
`getFunctionTypeAttrName` during the creation of a new `FuncOp` inside
the pass. The problem is that `getFunctionTypeAttrName` looks up the
attribute name for the function type which in this case is `func.func`.
However, `name.getAttributeNames()` was empty when clients used
`llvm.func` instead of `func.func`.

To fix this, the `func` dialect is now registered as a dependent
dialect. Also, I've added an assertion which could save other people
some time.

Fixes #71281, fixes #64326.
2023-11-21 08:40:16 +01:00
long.chen
1609f1c2a5 [mlir][affine][nfc] cleanup deprecated T.cast style functions (#71269)
detail see the docment: https://mlir.llvm.org/deprecation/

Not all changes are made manually, most of them are made through a clang
tool I wrote https://github.com/lipracer/cpp-refactor.
2023-11-14 13:01:19 +08:00
Maksim Levental
7c850867b9 [mlir][python] value casting (#69644)
This PR adds "value casting", i.e., a mechanism to wrap `ir.Value` in a
proxy class that overloads dunders such as `__add__`, `__sub__`, and
`__mul__` for fun and great profit.

This is thematically similar to
bfb1ba7526
and
9566ee2806.
The example in the test demonstrates the value of the feature (no pun
intended):

```python
    @register_value_caster(F16Type.static_typeid)
    @register_value_caster(F32Type.static_typeid)
    @register_value_caster(F64Type.static_typeid)
    @register_value_caster(IntegerType.static_typeid)
    class ArithValue(Value):
        __add__ = partialmethod(_binary_op, op="add")
        __sub__ = partialmethod(_binary_op, op="sub")
        __mul__ = partialmethod(_binary_op, op="mul")

    a = arith.constant(value=FloatAttr.get(f16_t, 42.42))
    b = a + a
    # CHECK: ArithValue(%0 = arith.addf %cst, %cst : f16)
    print(b)

    a = arith.constant(value=FloatAttr.get(f32_t, 42.42))
    b = a - a
    # CHECK: ArithValue(%1 = arith.subf %cst_0, %cst_0 : f32)
    print(b)

    a = arith.constant(value=FloatAttr.get(f64_t, 42.42))
    b = a * a
    # CHECK: ArithValue(%2 = arith.mulf %cst_1, %cst_1 : f64)
    print(b)
```

**EDIT**: this now goes through the bindings and thus supports automatic
casting of `OpResult` (including as an element of `OpResultList`),
`BlockArgument` (including as an element of `BlockArgumentList`), as
well as `Value`.
2023-11-07 10:49:41 -06:00
Jacques Pienaar
c7a7a43dbb [mlir] Fix unused variable warning. (NFC)
Not used in all cases. Shown by python test ops.
2023-11-03 15:50:49 -07:00
Jacques Pienaar
eb166030a1 [mlir] Expand default arg builders to wrapped attributes.
Previously only unwrapped values were considered for default values in
builders, expand to Attributes given the change to populate defaults. To avoid
overlap between wrapped and unwrapped, the starting index is incremented
depending on if the smallest starting index for default valued args can be
materialized in unwrapped form or not.

Given the above limitation this is pretty small change.

`optional` is unfortunately meant to also represent conditionally set which
means we cannot allow nullptr for all Attributes marked optional at the moment.

Reviewed By: Mogball

Differential Revision: https://reviews.llvm.org/D140705
2023-11-03 15:30:10 -07:00
Jacques Pienaar
308f58ceda [mlir][attrtypedef] Sort by def order in file. (#71083)
Enables having attribute that has another from same file as member.
2023-11-02 18:02:08 -07:00
Matteo Franciolini
7ad9e9dcf5 [mlir][bytecode] Implements back deployment capability for MLIR dialects (#70724)
When emitting bytecode, clients can specify a target dialect version to
emit in `BytecodeWriterConfig`. This exposes a target dialect version to
the DialectBytecodeWriter, which can be queried by name and used to
back-deploy attributes, types, and properties.
2023-10-31 15:41:29 -07:00
Christian Ulmann
fcb9a8a5ee Reland "[MLIR][FuncToLLVM] Remove typed pointer support" (#70717)
This relands 6a0f6dd835 that was reverted
due to a missing integration test change.
 
This commit removes the support for lowering Func to LLVM dialect with
typed pointers. Typed pointers have been deprecated for a while now and
it's planned to soon remove them from the LLVM dialect.

Original PR: https://github.com/llvm/llvm-project/pull/70574
2023-10-31 07:36:11 +01:00
Benjamin Kramer
f664326363 Remove the opaque pointers flag from tools
This has been the default for a while and the flags are slowly going
away. NFCI.
2023-10-30 12:58:24 +01:00
tsitdikov
97f05956c6 Update mlir-spirv-cpu-runner.cpp (#70649)
https://github.com/llvm/llvm-project/pull/70568 removed the support for
lowering SPIRV to LLVM dialect. We now need to stop using
enableOpaquePointers with ConvertSPIRVToLLVMPassOptions.
2023-10-30 12:39:03 +01:00
Matteo Franciolini
631e2911ea [mlir][bytecode] Fix D155919 and enable backward-compatibility and back-deployment between version 5 and version 6 of the bytecode encoding (#70498)
Before D155919, when a dialect was leveraging properties to store
attributes with `usePropertiesForAttributes`, the operand segment sizes
attribute was emitted in the property section in sorted order together
with all the other attributes of an op. After D155919, version 5 of the
bytecode was emitting and parsing operand segment sizes after all the
properties of an op, breaking backward compatibility and back
deployment. This patch fixes the emission ordering and allows to parse
bytecode files emitted before (D155919) with version 5 of MLIR bytecode.
The patch also enables to emit correctly version 5 of MLIR bytecode.
2023-10-27 23:13:21 -07:00
Kunwar Grover
ec7c1a476d Reland [mlir][tools] Introduce tblgen-to-irdl tool (#70121)
This patch relands the reverted commit
e6e9beb977
after fixing the sanitizer issue.
2023-10-27 14:48:49 +05:30
Mogball
ba468d4dab [mlir][ods] Emit bytecode readers with generic Attribute/Type (NFC)
This aligns the API with the builder API that allows arbitrary
attributes or types to be returned.
2023-10-24 08:06:51 +00:00
Maksim Levental
a2288a8944 [mlir][python] remove mixins (#68853)
This PR replaces the mixin `OpView` extension mechanism with the
standard inheritance mechanism.

Why? Firstly, mixins are not very pythonic (inheritance is usually used
for this), a little convoluted, and too "tight" (can only be used in the
immediately adjacent `_ext.py`). Secondly, it (mixins) are now blocking
are correct implementation of "value builders" (see
[here](https://github.com/llvm/llvm-project/pull/68764)) where the
problem becomes how to choose the correct base class that the value
builder should call.

This PR looks big/complicated but appearances are deceiving; 4 things
were needed to make this work:

1. Drop `skipDefaultBuilders` in
`OpPythonBindingGen::emitDefaultOpBuilders`
2. Former mixin extension classes are converted to inherit from the
generated `OpView` instead of being "mixins"
a. extension classes that simply were calling into an already generated
`super().__init__` continue to do so
b. (almost all) extension classes that were calling `self.build_generic`
because of a lack of default builder being generated can now also just
call `super().__init__`
3. To handle the [lone single
use-case](https://sourcegraph.com/search?q=context%3Aglobal+select_opview_mixin&patternType=standard&sm=1&groupBy=repo)
of `select_opview_mixin`, namely
[linalg](https://github.com/llvm/llvm-project/blob/main/mlir/python/mlir/dialects/_linalg_ops_ext.py#L38),
only a small change was necessary in `opdsl/lang/emitter.py` (thanks to
the emission/generation of default builders/`__init__`s)
4. since the `extend_opview_class` decorator is removed, we need a way
to register extension classes as the desired `OpView` that `op.opview`
conjures into existence; so we do the standard thing and just enable
replacing the existing registered `OpView` i.e.,
`register_operation(_Dialect, replace=True)`.

Note, the upgrade path for the common case is to change an extension to
inherit from the generated builder and decorate it with
`register_operation(_Dialect, replace=True)`. In the slightly more
complicated case where `super().__init(self.build_generic(...))` is
called in the extension's `__init__`, this needs to be updated to call
`__init__` in `OpView`, i.e., the grandparent (see updated docs). 
Note, also `<DIALECT>_ext.py` files/modules will no longer be automatically loaded.

Note, the PR has 3 base commits that look funny but this was done for
the purpose of tracking the line history of moving the
`<DIALECT>_ops_ext.py` class into `<DIALECT>.py` and updating (commit
labeled "fix").
2023-10-19 16:20:14 -05:00
Jacques Pienaar
616c86accb [mlir][drr] Set operand segment in rewrite
This allows some basic variadic operands in rewrites. There were some workarounds employed (like "aliasing" the attribute). Couldn't find a way to do this directly with properties.
2023-10-19 13:06:17 -07:00
Devajith
02d9f4d1f1 [mlir][mlir-query] Introduce mlir-query tool with autocomplete support
This commit adds the initial version of the mlir-query tool, which leverages the pre-existing matchers defined in mlir/include/mlir/IR/Matchers.h

The tool provides the following set of basic queries:

hasOpAttrName(string)
hasOpName(string)
isConstantOp()
isNegInfFloat()
isNegZeroFloat()
isNonZero()
isOne()
isOneFloat()
isPosInfFloat()
isPosZeroFloat()
isZero()
isZeroFloat()

Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D155127
2023-10-13 14:03:27 -07:00
Benjamin Maxwell
f54dc7b393 [mlir][ODS] Omit printing default-valued attributes in oilists (#68880)
This makes these match the behaviour of optional attributes (which are
omitted when they are their default value of none). This allows for
concise assembly formats without a custom printer.

An extra print of " " is also removed, this does change any existing
uses of oilists, but if the parameter before the oilist is optional,
that would previously add an extra space.

This #68694 + some fixes for the MLIR Python tests, unfortunately GitHub
does not allow re-opening PRs 😕
2023-10-13 10:22:05 +01:00
Rik Huijzer
9a8ff346bb [mlir][doc] Trim summary text during DocGen (#68477)
When defining a multi-line string in tblgen, the output in the Markdown
file currently contains too much whitespace and newlines for Hugo's
Markdown parser. For example, for `arith.addui_extended` the tblgen
```tblgen
let summary = [{
  extended unsigned integer addition operation returning sum and overflow bit
}];
```
is currently converted to
```markdown
_
    extended unsigned integer addition operation returning sum and overflow bit
  _
```
which causes the text to not be italicized (as can be seen at
https://mlir.llvm.org/docs/Dialects/ArithOps/#arithaddui_extended-arithadduiextendedop).
After this PR, the output becomes
```
_Extended unsigned integer addition operation returning sum and overflow bit_
```
2023-10-13 10:09:44 +02:00
Benjamin Maxwell
434b8a3080 Revert "[mlir][ODS] Omit printing default-valued attributes in oilists (#68694)"
This reverts commit e98a4bb00d.

This caused test failures:
- https://lab.llvm.org/buildbot/#/builders/61/builds/50374
- https://lab.llvm.org/buildbot/#/builders/220/builds/29092
2023-10-12 11:35:37 +00:00
Benjamin Maxwell
e98a4bb00d [mlir][ODS] Omit printing default-valued attributes in oilists (#68694)
This makes these match the behaviour of optional attributes (which are
omitted when they are their default value of `none`). This allows for
concise assembly formats without a custom printer.

An extra print of " " is also removed, this does change any existing
uses of oilists, but if the parameter before the oilist is optional,
that would previously add an extra space.
2023-10-12 12:25:48 +01:00
JoelWee
44600bae89 [mlir][python] Improve sanitization of python names (#68801)
Follow up to 7d4cd47e24, where I fixed
just the case of a dash. This fixes it for all possible types of
strings, which can include "-,." etc.

This modifies some code written in
27c6d55cae

It also handles the case of a leading number which is not valid for
python names.

Ref:
- https://llvm.org/docs/TableGen/ProgRef.html#literals
2023-10-12 08:53:53 +01:00
Benjamin Maxwell
2754f88a09 [mlir][docgen] Add option to enable Hugo Docs specific features (#68725)
This is set to off by default but enabled for the MLIR project, which
uses Hugo Docs. Downstream projects can choose if they want to set this
option or not.

Also fix an incorrectly closed `<table>` tag.
2023-10-11 10:03:23 +01:00
JoelWee
7d4cd47e24 [mlir][python] Handle dashes in op name
The python generated code for 
```
def StableHLO_CrossReplicaSumOp : StableHLO_Op<"cross-replica-sum",
```

fails because the python code 

`def cross-replica-sum...` is generated, which is not a valid python name.

https://github.com/openxla/stablehlo/blob/main/stablehlo/dialect/StablehloOps.td#L2109
2023-10-10 14:39:20 +01:00
Maksim Levental
27c6d55cae [mlir][python] generate value builders (#68308)
This PR adds the additional generation of what I'm calling "value
builders" (a term I'm not married to) that look like this:

```python
def empty(sizes, element_type, *, loc=None, ip=None):
    return get_result_or_results(tensor.EmptyOp(sizes=sizes, element_type=element_type, loc=loc, ip=ip))
```

which instantiates a `tensor.EmptyOp` and then immediately grabs the
result (`OpResult`) and then returns that *instead of a handle to the
op*.

What's the point of adding these when `EmptyOp.result` already exists?
My claim/feeling/intuition is that eDSL users are more comfortable with
a value centric programming model (i.e., passing values as operands) as
opposed to an operator instantiation programming model. Thus this change
enables (or at least goes towards) the bindings supporting such a user
and use case. For example,

```python
i32 = IntegerType.get_signless(32)
...
ten1 = tensor.empty((10, 10), i32)
ten2 = tensor.empty((10, 10), i32)
ten3 = arith.addi(ten1, ten2)
```

Note, in order to present a "pythonic" API and enable "pythonic" eDSLs,
the generated identifiers (op names and operand names) are snake case
instead of camel case and thus `llvm::convertToSnakeFromCamelCase`
needed a small fix. Thus this PR is stacked on top of
https://github.com/llvm/llvm-project/pull/68375.

In addition, as a kind of victory lap, this PR adds a "rangefor" that
looks and acts exactly like python's `range` but emits `scf.for`.
2023-10-09 14:16:28 -07:00
Thurston Dang
a968beca73 Revert "[mlir][tools] Introduce tblgen-to-irdl tool (#66865)"
This reverts commit e6e9beb977
due to an ongoing buildbot breakage starting from
https://lab.llvm.org/buildbot/#/builders/168/builds/16127
to present
(https://lab.llvm.org/buildbot/#/builders/168/builds/16152)
2023-10-09 16:35:17 +00:00
Kunwar Grover
e6e9beb977 [mlir][tools] Introduce tblgen-to-irdl tool (#66865)
RFC: https://discourse.llvm.org/t/rfc-tblgen-to-irdl-tool/73578
2023-10-07 10:39:13 +05:30
long.chen
5979e1dfb1 [mlir] Fix empty-tensor-elimination around self-copies (#68129)
* Fixes #67977, a crash in `empty-tensor-elimination`.
* Also improves `linalg.copy` canonicalization.
* Also improves indentation indentation in `mlir-linalg-ods-yaml-gen.cpp`.
2023-10-05 12:04:20 +02:00
Matthias Springer
8823e961f6 [mlir][ODS] Change get...Mutable to return OpOperand & for single operands (#66519)
The TableGen code generator now generates C++ code that returns a single
`OpOperand &` for `get...Mutable` of operands that are not variadic and
not optional. `OpOperand::set`/`assign` can be used to set a value (same
as `MutableOperandRange::assign`). This is safer than
`MutableOperandRange` because only single values (and no longer
`ValueRange`) can be assigned.

E.g.:
```
// Assignment of multiple values to non-variadic operand.
// Before: Compiles, but produces invalid op.
// After: Compilation error.
extractSliceOp.getSourceMutable().assign({v1, v2});
```
2023-10-04 08:35:40 +02:00
Mehdi Amini
5fc28e7a8d Improve MLIR Attribute::get() method efficiency by reducing the amount of argument copies (#68067)
This ensures that the proper std::forward/std::move are involved, we go from 6
copy-constructions to 0 (!) on Attribute creation in release builds.
2023-10-03 18:07:46 -07:00
cxy
0c63122713 [MLIR] Add stage to side effect
[MLIR] Add stage and effectOnFullRegion to side effect

    This patch add stage and effectOnFullRegion to side effect for optimization pass
    to obtain more accurate information.
    Stage uses numbering to track the side effects's stage of occurrence.
    EffectOnFullRegion indicates if effect act on every single value of resource.

    RFC disscussion: https://discourse.llvm.org/t/rfc-add-effect-index-in-memroy-effect/72235
    Differential Revision: https://reviews.llvm.org/D156087

Reviewed By: mehdi_amini, Mogball

Differential Revision: https://reviews.llvm.org/D156087
2023-09-29 17:47:13 -07:00
Benjamin Maxwell
d339d8fede [mlir][docgen] Display full attribute descriptions in expandable regions (#67009)
This updates the table of op attributes so that clicking the summary
expands to show the complete description.

```
   Attribute | MLIR Type | Description
   <name>      <type>      ▶ <summary>  <-- Click to expand
```

Enum attributes have now also been updated to generate a description
that lists all the cases (with both their MLIR and C++ names). This
makes viewing enums on the MLIR docs much nicer.

**Example**

Default view:

![image](https://github.com/llvm/llvm-project/assets/11597044/922669c7-b838-4230-bcfd-a77cde0f335d)

Expanded:

![image](https://github.com/llvm/llvm-project/assets/11597044/41da086e-a5ce-45dd-9f44-9d10a4d5f2e1)

---

This requires: https://github.com/llvm/mlir-www/pull/158 (adds a very
simple markdown shortcode)
2023-09-27 12:22:24 +01:00
Mehdi Amini
c50617dae3 Simplify diagnostic error management for MLIR properties API (NFC) (#67409)
This is a follow-up to 8c2bff1ab9 which lazy-initialized the
diagnostic and removed the need to dynamically abandon() an
InFlightDiagnostic. This further simplifies the code to not needed to
return a reference to an InFlightDiagnostic and instead eagerly emit
errors.

Also use `emitError` as name instead of `getDiag` which seems more
explicit and in-line with the common usage.
2023-09-26 11:44:37 -07:00
Shao-Ce SUN
b0e28eb832 [llvm][tblgen] Add Source Filename for emitSourceFileHeader (#65744)
I think this is very helpful for reading generated `.inc` files.
2023-09-26 13:40:56 +08:00
Jian Cai
7421040b44 [mlir] Move supplemental patterns before op replacement (#66959)
This moves the C++ code generated from supplemental patterns before op
replacement. It is necessary if the supllemental patterns need to access
the source op.
2023-09-21 15:35:05 -07:00
Matthias Springer
0b2197b0cf [mlir][Interfaces] Clean up DestinationStyleOpInterface (#67015)
* "init" operands are specified with `MutableOperandRange` (which gives
access to the underlying `OpOperand *`). No more magic numbers.
* Remove most interface methods and make them helper functions. Only
`getInitsMutable` should be implemented.
* Provide separate helper functions for accessing mutable/immutable
operands (`OpOperand`/`Value`, in line with #66515): `getInitsMutable`
and `getInits` (same naming convention as auto-generated op accessors).
`getInputOperands` was not renamed because this function cannot return a
`MutableOperandRange` (because the operands are not necessarily
consecutive). `OpOperandVector` is no longer needed.
* The new `getDpsInits`/`getDpsInitsMutable` is more efficient than the
old `getDpsInitOperands` because no `SmallVector` is created. The new
functions return a range of operands.
* Fix a bug in `getDpsInputOperands`: out-of-bounds operands were
potentially returned.
2023-09-21 18:04:08 +02:00
Krzysztof Drewniak
df852599f3 [mlir] Split up VectorToLLVM pass
Currently, the VectorToLLVM patterns are built into a library along
with the corresponding pass, which also pulls in all the
platform-specific vector dialects (like AMXDialect) to apply all the
vector to LLVM conversions.

This causes dependency bloat when writing libraries - for example the
GPU to LLVM passes, which use the vector to LLVM patterns, don't need
the X86Vector dialect to be present at all.

This commit partitions the library into VectorToLLVM and
VectorToLLVMPass, where the latter pulls in all the other vector
transformations.

Reviewed By: nicolasvasilache, mehdi_amini

Differential Revision: https://reviews.llvm.org/D158287
2023-09-13 16:09:56 +00:00
Mehdi Amini
830b9b072d Update some uses of getAttr() to be explicit about Inherent vs Discardable (NFC) 2023-09-12 01:33:47 -07:00
Markus Böck
cedeb31e6d [mlir] Support null interface to base conversion (#65988)
The current implicit conversion operator from an interface to a "base
interface" of the interface unconditionally calls `this->getImpl()`
which leads to accessing a null pointer if the interface instance is a
null instance.

This PR changes the ODS generated interface instance to explicitly check
and then return a null interface instance if the `this` instance is a
null instance.
2023-09-12 08:42:47 +02:00
Fabian Mora
1828deb752 [mlir][gpu] Deprecate gpu::Serialization* passes. (#65857)
Deprecate the `gpu-to-cubin` & `gpu-to-hsaco` passes in favor of the
`TargetAttr` workflow. This patch removes remaining upstream uses of the
aforementioned passes, including the option to use them in `mlir-opt`. A
future patch will remove these passes entirely.

The passes can be re-enabled in `mlir-opt` by adding the CMake flag: `-DMLIR_ENABLE_DEPRECATED_GPU_SERIALIZATION=1`.
2023-09-11 16:32:15 -04:00
Mehdi Amini
8c2bff1ab9 Lazy initialize diagnostic when handling MLIR properties (#65868)
Instead of eagerly creating a diagnostic that will be discarded in the
normal case, switch to lazy initialization on error.
2023-09-11 13:22:35 -07:00
Jakub Kuderski
1258c3f214 [mlir][spirv] Support spirv.coopmatrix type (de-)serialization (#65831)
Extend SPIR-V target serialization and deserialization to handle coop
matrix types. Add a roundtrip test. In addition to `FileCheck` checks,
the resulting spirv binary also passes `spir-val` (external tool).

Also fix a type attribute bug surfaced by the `CooperativeMatrixLength`
op.

Multiple matrix operand attributes will be handled in a future patch to
reduce the scope.
2023-09-11 12:23:18 -04:00
Jakub Kuderski
d01f559ce9 [mlir] Fix c++20 compat warning. NFC. (#65801)
`concept` is a c++20 keyword and makes some buildbots fail:
https://lab.llvm.org/buildbot/#/builders/160/builds/24345
2023-09-08 16:23:36 -04:00
Jakub Kuderski
53b3be7ecb [mlir][spirv] Fix coop matrix load (#65712)
- Fix order of operands/attributes
- Allow for stride to be any integer type
- Use ODS for parsing/printing
- Update examples and tests
- Fix a typo in SPIR-V tblgen code
2023-09-08 13:29:12 -04:00