3 Commits

Author SHA1 Message Date
Maksim Levental
27af6bc240 [MLIR] fix LLVM::InsertValueOp::create 2025-09-07 22:23:12 -04:00
Jakub Kuderski
2ed3f49c49
[mlir] Use free op create functions. NFC. (#157374)
The builder create methods are deprecated:
https://mlir.llvm.org/deprecation/. See
https://discourse.llvm.org/t/psa-opty-create-now-with-100-more-tab-complete/87339.
2025-09-07 22:13:20 -04:00
Fabian Mora
9b88d38c43
[mlir][ptr] Add conversion to LLVM for all existing ptr ops (#156053)
This patch adds conversion to LLVM for all existing pointer ops. This is
a stop gap measure to allow users to use the `ptr` dialect now. In the
future some of these conversions will be removed, and added as
translations, for example `ptradd`.

Example:
```mlir
func.func @test_memref_ptradd_indexing(%arg0: memref<10x?x30xf32, #ptr.generic_space>, %arg1: index) -> !ptr.ptr<#ptr.generic_space> {
  %0 = ptr.to_ptr %arg0 : memref<10x?x30xf32, #ptr.generic_space> -> <#ptr.generic_space>
  %1 = ptr.type_offset f32 : index
  %2 = arith.muli %1, %arg1 : index
  %3 = ptr.ptr_add %0, %2 : <#ptr.generic_space>, index
  return %3 : !ptr.ptr<#ptr.generic_space>
}
// mlir-opt --convert-to-llvm --canonicalize --cse
llvm.func @test_memref_ptradd_indexing(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i64, %arg3: i64, %arg4: i64, %arg5: i64, %arg6: i64, %arg7: i64, %arg8: i64, %arg9: i64) -> !llvm.ptr {
  %0 = llvm.mlir.zero : !llvm.ptr
  %1 = llvm.getelementptr %0[1] : (!llvm.ptr) -> !llvm.ptr, f32
  %2 = llvm.ptrtoint %1 : !llvm.ptr to i64
  %3 = llvm.mul %2, %arg9 : i64
  %4 = llvm.getelementptr %arg1[%3] : (!llvm.ptr, i64) -> !llvm.ptr, i8
  llvm.return %4 : !llvm.ptr
}
```
2025-08-29 16:57:48 +00:00