[all-commits] [llvm/llvm-project] 9b88d3: [mlir][ptr] Add conversion to LLVM for all existin...

Fabian Mora via All-commits all-commits at lists.llvm.org
Fri Aug 29 09:58:10 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 9b88d38c43ed70a6dfed379bc1d29e674804adba
      https://github.com/llvm/llvm-project/commit/9b88d38c43ed70a6dfed379bc1d29e674804adba
  Author: Fabian Mora <fmora.dev at gmail.com>
  Date:   2025-08-29 (Fri, 29 Aug 2025)

  Changed paths:
    A mlir/include/mlir/Conversion/PtrToLLVM/PtrToLLVM.h
    M mlir/lib/Conversion/CMakeLists.txt
    A mlir/lib/Conversion/PtrToLLVM/CMakeLists.txt
    A mlir/lib/Conversion/PtrToLLVM/PtrToLLVM.cpp
    M mlir/lib/RegisterAllExtensions.cpp
    A mlir/test/Conversion/PtrToLLVM/ptr-to-llvm.mlir

  Log Message:
  -----------
  [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
}
```



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list