<feed xmlns='http://www.w3.org/2005/Atom'>
<title>llvm-project.git/mlir/test/lib/Dialect/Test/TestAttributes.cpp, branch main</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.
</subtitle>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/'/>
<entry>
<title>[mlir][bufferization] Test tensor encoding -&gt; memref layout conversion (#161166)</title>
<updated>2025-10-15T10:44:17+00:00</updated>
<author>
<name>Andrei Golubev</name>
<email>andrey.golubev@intel.com</email>
</author>
<published>2025-10-15T10:44:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=3141bdefff4e6ec8dd266ce5ff7c4db4fff1ea23'/>
<id>3141bdefff4e6ec8dd266ce5ff7c4db4fff1ea23</id>
<content type='text'>
Support custom types (4/N): test that it is possible to customize memref
layout specification for custom operations and function boundaries.

This is purely a test setup (no API modifications) to ensure users are
able to pass information from tensors to memrefs within bufferization
process. To achieve this, a test pass is required (since bufferization
options have to be set manually). As there is already a
--test-one-shot-module-bufferize pass present, it is extended for the
purpose.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Support custom types (4/N): test that it is possible to customize memref
layout specification for custom operations and function boundaries.

This is purely a test setup (no API modifications) to ensure users are
able to pass information from tensors to memrefs within bufferization
process. To achieve this, a test pass is required (since bufferization
options have to be set manually). As there is already a
--test-one-shot-module-bufferize pass present, it is extended for the
purpose.</pre>
</div>
</content>
</entry>
<entry>
<title>[mlir][LLVM|ptr] Add the `#llvm.address_space` attribute, and allow `ptr` translation (#156333)</title>
<updated>2025-09-02T12:02:14+00:00</updated>
<author>
<name>Fabian Mora</name>
<email>fmora.dev@gmail.com</email>
</author>
<published>2025-09-02T12:02:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=8a820f133aa00557498d666a901003d1c4f64f00'/>
<id>8a820f133aa00557498d666a901003d1c4f64f00</id>
<content type='text'>
This commit introduces the `#llvm.address_space` attribute. This
attribute implements the `ptr::MemorySpaceAttrInterface`, establishing
the semantics of the LLVM address space.
This allows making `!ptr.ptr` translatable to LLVM IR as long it uses
the `#llvm.address_space` attribute.
Concretely, `!ptr.ptr&lt;#llvm.address_space&lt;N&gt;&gt;` now translates to `ptr
addrspace(N)`.

Additionally, this patch makes `PtrLikeTypes` with no metadata, no
element type, and with `#llvm.address_space` memory space, compatible
with the LLVM dialect.

**Infrastructure Updates:**
- Refactor `ptr::MemorySpaceAttrInterface` to include DataLayout
parameter for better validation
- Add new utility functions `LLVM::isLoadableType()` and
`LLVM::isTypeCompatibleWithAtomicOp()`
- Update type compatibility checks to support ptr-like types with LLVM
address spaces
- Splice the `MemorySpaceAttrInterface` to its own library, so the
LLVMDialect won't depend on the PtrDialect yet

**Translation Support:**
- New `PtrToLLVMIRTranslation` module for converting ptr dialect to LLVM
IR
- Type translation support for ptr types with LLVM address spaces
- Proper address space preservation during IR lowering

Example:
```mlir
llvm.func @llvm_ops_with_ptr_values(%arg0: !llvm.ptr) {
  %1 = llvm.load %arg0 : !llvm.ptr -&gt; !ptr.ptr&lt;#llvm.address_space&lt;1&gt;&gt;
  llvm.store %1, %arg0 : !ptr.ptr&lt;#llvm.address_space&lt;1&gt;&gt;, !llvm.ptr
  llvm.return
}
```
Translates to:
```llvmir
; ModuleID = 'LLVMDialectModule'
source_filename = "LLVMDialectModule"

define void @llvm_ops_with_ptr_values(ptr %0) {
  %2 = load ptr addrspace(1), ptr %0, align 8
  store ptr addrspace(1) %2, ptr %0, align 8
  ret void
}

!llvm.module.flags = !{!0}

!0 = !{i32 2, !"Debug Info Version", i32 3}
```</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This commit introduces the `#llvm.address_space` attribute. This
attribute implements the `ptr::MemorySpaceAttrInterface`, establishing
the semantics of the LLVM address space.
This allows making `!ptr.ptr` translatable to LLVM IR as long it uses
the `#llvm.address_space` attribute.
Concretely, `!ptr.ptr&lt;#llvm.address_space&lt;N&gt;&gt;` now translates to `ptr
addrspace(N)`.

Additionally, this patch makes `PtrLikeTypes` with no metadata, no
element type, and with `#llvm.address_space` memory space, compatible
with the LLVM dialect.

**Infrastructure Updates:**
- Refactor `ptr::MemorySpaceAttrInterface` to include DataLayout
parameter for better validation
- Add new utility functions `LLVM::isLoadableType()` and
`LLVM::isTypeCompatibleWithAtomicOp()`
- Update type compatibility checks to support ptr-like types with LLVM
address spaces
- Splice the `MemorySpaceAttrInterface` to its own library, so the
LLVMDialect won't depend on the PtrDialect yet

**Translation Support:**
- New `PtrToLLVMIRTranslation` module for converting ptr dialect to LLVM
IR
- Type translation support for ptr types with LLVM address spaces
- Proper address space preservation during IR lowering

Example:
```mlir
llvm.func @llvm_ops_with_ptr_values(%arg0: !llvm.ptr) {
  %1 = llvm.load %arg0 : !llvm.ptr -&gt; !ptr.ptr&lt;#llvm.address_space&lt;1&gt;&gt;
  llvm.store %1, %arg0 : !ptr.ptr&lt;#llvm.address_space&lt;1&gt;&gt;, !llvm.ptr
  llvm.return
}
```
Translates to:
```llvmir
; ModuleID = 'LLVMDialectModule'
source_filename = "LLVMDialectModule"

define void @llvm_ops_with_ptr_values(ptr %0) {
  %2 = load ptr addrspace(1), ptr %0, align 8
  store ptr addrspace(1) %2, ptr %0, align 8
  ret void
}

!llvm.module.flags = !{!0}

!0 = !{i32 2, !"Debug Info Version", i32 3}
```</pre>
</div>
</content>
</entry>
<entry>
<title>[mlir][ptr] Add load and store ops. (#156093)</title>
<updated>2025-09-01T11:16:17+00:00</updated>
<author>
<name>Fabian Mora</name>
<email>fmora.dev@gmail.com</email>
</author>
<published>2025-09-01T11:16:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=77f256070f985029a53da5e76ecd85ca7686a7ea'/>
<id>77f256070f985029a53da5e76ecd85ca7686a7ea</id>
<content type='text'>
This patch adds the load and store operations to the ptr dialect. It's
future work to implement SROA and Mem2Reg interfaces, as well as
conversion to LLVM, and add alias information.

This patch also fixes a bug in `OptionalProp` that was causing the
bytecode writer to exit early of writing the Op props if an optional
prop had the default value.

Example:
```mlir
func.func @load_ops(%arg0: !ptr.ptr&lt;#ptr.generic_space&gt;) -&gt; (f32, f32, f32, f32, f32, i64, i32) {
  %0 = ptr.load %arg0 : !ptr.ptr&lt;#ptr.generic_space&gt; -&gt; f32
  %1 = ptr.load volatile %arg0 : !ptr.ptr&lt;#ptr.generic_space&gt; -&gt; f32
  %2 = ptr.load %arg0 nontemporal : !ptr.ptr&lt;#ptr.generic_space&gt; -&gt; f32
  %3 = ptr.load %arg0 invariant : !ptr.ptr&lt;#ptr.generic_space&gt; -&gt; f32
  %4 = ptr.load %arg0 invariant_group : !ptr.ptr&lt;#ptr.generic_space&gt; -&gt; f32
  %5 = ptr.load %arg0 atomic monotonic alignment = 8 : !ptr.ptr&lt;#ptr.generic_space&gt; -&gt; i64
  %6 = ptr.load volatile %arg0 atomic syncscope("workgroup") acquire nontemporal alignment = 4 : !ptr.ptr&lt;#ptr.generic_space&gt; -&gt; i32
  return %0, %1, %2, %3, %4, %5, %6 : f32, f32, f32, f32, f32, i64, i32
}

func.func @store_ops(%arg0: !ptr.ptr&lt;#ptr.generic_space&gt;, %arg1: f32, %arg2: i64, %arg3: i32) {
  ptr.store %arg1, %arg0 : f32, !ptr.ptr&lt;#ptr.generic_space&gt;
  ptr.store volatile %arg1, %arg0 : f32, !ptr.ptr&lt;#ptr.generic_space&gt;
  ptr.store %arg1, %arg0 nontemporal : f32, !ptr.ptr&lt;#ptr.generic_space&gt;
  ptr.store %arg1, %arg0 invariant_group : f32, !ptr.ptr&lt;#ptr.generic_space&gt;
  ptr.store %arg2, %arg0 atomic monotonic alignment = 8 : i64, !ptr.ptr&lt;#ptr.generic_space&gt;
  ptr.store volatile %arg3, %arg0 atomic syncscope("workgroup") release nontemporal alignment = 4 : i32, !ptr.ptr&lt;#ptr.generic_space&gt;
  return
}
```

Finally, this patch allows testing more advanced features of ptr memory
spaces, for example:
```mlir
// mlir-opt -verify-diagnostics
func.func @store_const(%arg0: !ptr.ptr&lt;#test.const_memory_space&gt;, %arg1: i64) {
  // expected-error@+1 {{memory space is read-only}}
  ptr.store %arg1, %arg0 atomic monotonic alignment = 8 : i64, !ptr.ptr&lt;#test.const_memory_space&gt;
  return
}
```</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch adds the load and store operations to the ptr dialect. It's
future work to implement SROA and Mem2Reg interfaces, as well as
conversion to LLVM, and add alias information.

This patch also fixes a bug in `OptionalProp` that was causing the
bytecode writer to exit early of writing the Op props if an optional
prop had the default value.

Example:
```mlir
func.func @load_ops(%arg0: !ptr.ptr&lt;#ptr.generic_space&gt;) -&gt; (f32, f32, f32, f32, f32, i64, i32) {
  %0 = ptr.load %arg0 : !ptr.ptr&lt;#ptr.generic_space&gt; -&gt; f32
  %1 = ptr.load volatile %arg0 : !ptr.ptr&lt;#ptr.generic_space&gt; -&gt; f32
  %2 = ptr.load %arg0 nontemporal : !ptr.ptr&lt;#ptr.generic_space&gt; -&gt; f32
  %3 = ptr.load %arg0 invariant : !ptr.ptr&lt;#ptr.generic_space&gt; -&gt; f32
  %4 = ptr.load %arg0 invariant_group : !ptr.ptr&lt;#ptr.generic_space&gt; -&gt; f32
  %5 = ptr.load %arg0 atomic monotonic alignment = 8 : !ptr.ptr&lt;#ptr.generic_space&gt; -&gt; i64
  %6 = ptr.load volatile %arg0 atomic syncscope("workgroup") acquire nontemporal alignment = 4 : !ptr.ptr&lt;#ptr.generic_space&gt; -&gt; i32
  return %0, %1, %2, %3, %4, %5, %6 : f32, f32, f32, f32, f32, i64, i32
}

func.func @store_ops(%arg0: !ptr.ptr&lt;#ptr.generic_space&gt;, %arg1: f32, %arg2: i64, %arg3: i32) {
  ptr.store %arg1, %arg0 : f32, !ptr.ptr&lt;#ptr.generic_space&gt;
  ptr.store volatile %arg1, %arg0 : f32, !ptr.ptr&lt;#ptr.generic_space&gt;
  ptr.store %arg1, %arg0 nontemporal : f32, !ptr.ptr&lt;#ptr.generic_space&gt;
  ptr.store %arg1, %arg0 invariant_group : f32, !ptr.ptr&lt;#ptr.generic_space&gt;
  ptr.store %arg2, %arg0 atomic monotonic alignment = 8 : i64, !ptr.ptr&lt;#ptr.generic_space&gt;
  ptr.store volatile %arg3, %arg0 atomic syncscope("workgroup") release nontemporal alignment = 4 : i32, !ptr.ptr&lt;#ptr.generic_space&gt;
  return
}
```

Finally, this patch allows testing more advanced features of ptr memory
spaces, for example:
```mlir
// mlir-opt -verify-diagnostics
func.func @store_const(%arg0: !ptr.ptr&lt;#test.const_memory_space&gt;, %arg1: i64) {
  // expected-error@+1 {{memory space is read-only}}
  ptr.store %arg1, %arg0 atomic monotonic alignment = 8 : i64, !ptr.ptr&lt;#test.const_memory_space&gt;
  return
}
```</pre>
</div>
</content>
</entry>
<entry>
<title>Avoid copies in getChecked (#147721)</title>
<updated>2025-07-29T15:13:03+00:00</updated>
<author>
<name>Alexandru Lorinti</name>
<email>alexandru.lorinti@intel.com</email>
</author>
<published>2025-07-29T15:13:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=8e7b02fc0cd5f63a14f4117866f860b7f174baf3'/>
<id>8e7b02fc0cd5f63a14f4117866f860b7f174baf3</id>
<content type='text'>
Following-up on #68067 ; adding std::move to getChecked method as well.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Following-up on #68067 ; adding std::move to getChecked method as well.</pre>
</div>
</content>
</entry>
<entry>
<title>[mlir][ODS] Fix TableGen for AttrOrTypeDef::hasStorageCustomConstructor (#147957)</title>
<updated>2025-07-11T10:45:21+00:00</updated>
<author>
<name>Andrei Golubev</name>
<email>andrey.golubev@intel.com</email>
</author>
<published>2025-07-11T10:45:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=4a35214bddbb67f9597a500d48ab8c4fb25af150'/>
<id>4a35214bddbb67f9597a500d48ab8c4fb25af150</id>
<content type='text'>
There is a `hasStorageCustomConstructor` flag that allows one to provide
custom attribute/type construction implementation. Unfortunately, it
seems like the flag does not work properly: the generated C++ produces
*empty body* method instead of producing only a declaration.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
There is a `hasStorageCustomConstructor` flag that allows one to provide
custom attribute/type construction implementation. Unfortunately, it
seems like the flag does not work properly: the generated C++ produces
*empty body* method instead of producing only a declaration.</pre>
</div>
</content>
</entry>
<entry>
<title>[mlir] Migrate away from ArrayRef(std::nullopt) (NFC) (#145140)</title>
<updated>2025-06-21T15:20:49+00:00</updated>
<author>
<name>Kazu Hirata</name>
<email>kazu@google.com</email>
</author>
<published>2025-06-21T15:20:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=e6ebf8f99ba27d60026c7473b0cd5e24c855b018'/>
<id>e6ebf8f99ba27d60026c7473b0cd5e24c855b018</id>
<content type='text'>
ArrayRef has a constructor that accepts std::nullopt.  This
constructor dates back to the days when we still had llvm::Optional.

Since the use of std::nullopt outside the context of std::optional is
kind of abuse and not intuitive to new comers, I would like to move
away from the constructor and eventually remove it.

This patch takes care of the mlir side of the migration, starting with
straightforward places like "return std::nullopt;" and ternally
expressions involving std::nullopt.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
ArrayRef has a constructor that accepts std::nullopt.  This
constructor dates back to the days when we still had llvm::Optional.

Since the use of std::nullopt outside the context of std::optional is
kind of abuse and not intuitive to new comers, I would like to move
away from the constructor and eventually remove it.

This patch takes care of the mlir side of the migration, starting with
straightforward places like "return std::nullopt;" and ternally
expressions involving std::nullopt.</pre>
</div>
</content>
</entry>
<entry>
<title>[MLIR][parser] Add token type and parser methods for forward slashes (#125056)</title>
<updated>2025-05-14T16:33:21+00:00</updated>
<author>
<name>Andi Drebes</name>
<email>47449897+andidr@users.noreply.github.com</email>
</author>
<published>2025-05-14T16:33:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=ba23eedc68ee1363ae8c31afc0f4b5071779eb0b'/>
<id>ba23eedc68ee1363ae8c31afc0f4b5071779eb0b</id>
<content type='text'>
This adds a token for a forward slash to the token definition list and
the methods to `AsmParser::parseSlash()` and
`AsmParser::parseOptionalSlash()`, similar to other tokens used as
operators (e.g., star, plus, etc.). This allows implementations of
attributes that contain arithmetic expressions to support operators with
a forward slash, e.g., a division.

The newly added check tests trigger the parsing of a slash in an
attribute.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This adds a token for a forward slash to the token definition list and
the methods to `AsmParser::parseSlash()` and
`AsmParser::parseOptionalSlash()`, similar to other tokens used as
operators (e.g., star, plus, etc.). This allows implementations of
attributes that contain arithmetic expressions to support operators with
a forward slash, e.g., a division.

The newly added check tests trigger the parsing of a slash in an
attribute.</pre>
</div>
</content>
</entry>
<entry>
<title>[mlir][tblgen] Add custom parsing and printing within struct (#133939)</title>
<updated>2025-04-30T12:43:03+00:00</updated>
<author>
<name>Jorn Tuyls</name>
<email>jtuyls@users.noreply.github.com</email>
</author>
<published>2025-04-30T12:43:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=de6d010f4e3fbfdb54e257c496c16db30c6c0d91'/>
<id>de6d010f4e3fbfdb54e257c496c16db30c6c0d91</id>
<content type='text'>
This PR extends the `struct` directive in tablegen to support nested
`custom` directives. Note that this assumes/verifies that that `custom`
directive has a single parameter.

This enables defining custom field parsing and printing functions if the
`struct` directive doesn't suffice. There is some existing potential
downstream usage for it:
https://github.com/openxla/stablehlo/blob/a3c7de92425e8035437dae67ab2318a82eca79a1/stablehlo/dialect/StablehloOps.cpp#L3102</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This PR extends the `struct` directive in tablegen to support nested
`custom` directives. Note that this assumes/verifies that that `custom`
directive has a single parameter.

This enables defining custom field parsing and printing functions if the
`struct` directive doesn't suffice. There is some existing potential
downstream usage for it:
https://github.com/openxla/stablehlo/blob/a3c7de92425e8035437dae67ab2318a82eca79a1/stablehlo/dialect/StablehloOps.cpp#L3102</pre>
</div>
</content>
</entry>
<entry>
<title>[mlir][ptr] Switch `LogicalResult` to `bool` in `MemorySpaceAttrInterrface` (#137513)</title>
<updated>2025-04-27T15:16:03+00:00</updated>
<author>
<name>Fabian Mora</name>
<email>fmora.dev@gmail.com</email>
</author>
<published>2025-04-27T15:16:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=e7313421f1ad2e269a55e1f31280936d8d5395a3'/>
<id>e7313421f1ad2e269a55e1f31280936d8d5395a3</id>
<content type='text'>
This patch switches the return type in `MemorySpaceAttrInterface`
methods from `LogicalResult` to `bool`. As `is*` methods are predicates.

Users of the `MemorySpaceAttrInterface` API must note that, if
`emitError` is non-null and the result of a `is*` method is `false`,
then an error was likely emitted. To avoid the emission of an error the
user can pass a default constructed `emitError`.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch switches the return type in `MemorySpaceAttrInterface`
methods from `LogicalResult` to `bool`. As `is*` methods are predicates.

Users of the `MemorySpaceAttrInterface` API must note that, if
`emitError` is non-null and the result of a `is*` method is `false`,
then an error was likely emitted. To avoid the emission of an error the
user can pass a default constructed `emitError`.</pre>
</div>
</content>
</entry>
<entry>
<title>[mlir][Ptr] Add the `MemorySpaceAttrInterface` interface and dependencies. (#86870)</title>
<updated>2025-03-19T14:55:24+00:00</updated>
<author>
<name>Fabian Mora</name>
<email>fmora.dev@gmail.com</email>
</author>
<published>2025-03-19T14:55:24+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=2b8f887915020431112c35397368edd34b313f9a'/>
<id>2b8f887915020431112c35397368edd34b313f9a</id>
<content type='text'>
This patch introduces the `MemorySpaceAttrInterface` interface. This
interface is responsible for handling the semantics of `ptr` operations.

For example, this interface can be used to create read-only memory
spaces, making any other operation other than a load a verification
error, see `TestConstMemorySpaceAttr` for a possible implementation of
this concept.

This patch also introduces Enum dependencies `AtomicOrdering`, and
`AtomicBinOp`, both enumerations are clones of the Enums with the same
name in the LLVM Dialect.

Also, see:
- [[RFC] `ptr` dialect &amp; modularizing ptr ops in the LLVM
dialect](https://discourse.llvm.org/t/rfc-ptr-dialect-modularizing-ptr-ops-in-the-llvm-dialect/75142)
for rationale.
- https://github.com/llvm/llvm-project/pull/73057 for a prototype
implementation of the full change.

**Note: Ignore the first commit, that's being reviewed in
https://github.com/llvm/llvm-project/pull/86860 .**</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch introduces the `MemorySpaceAttrInterface` interface. This
interface is responsible for handling the semantics of `ptr` operations.

For example, this interface can be used to create read-only memory
spaces, making any other operation other than a load a verification
error, see `TestConstMemorySpaceAttr` for a possible implementation of
this concept.

This patch also introduces Enum dependencies `AtomicOrdering`, and
`AtomicBinOp`, both enumerations are clones of the Enums with the same
name in the LLVM Dialect.

Also, see:
- [[RFC] `ptr` dialect &amp; modularizing ptr ops in the LLVM
dialect](https://discourse.llvm.org/t/rfc-ptr-dialect-modularizing-ptr-ops-in-the-llvm-dialect/75142)
for rationale.
- https://github.com/llvm/llvm-project/pull/73057 for a prototype
implementation of the full change.

**Note: Ignore the first commit, that's being reviewed in
https://github.com/llvm/llvm-project/pull/86860 .**</pre>
</div>
</content>
</entry>
</feed>
