[all-commits] [llvm/llvm-project] d15998: [mlir][ptr] Add translations to LLVMIR for ptr ops...

Fabian Mora via All-commits all-commits at lists.llvm.org
Wed Sep 3 07:11:59 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d15998fe64619e1cc0d6285fbd24d5fe5429c9ef
      https://github.com/llvm/llvm-project/commit/d15998fe64619e1cc0d6285fbd24d5fe5429c9ef
  Author: Fabian Mora <fmora.dev at gmail.com>
  Date:   2025-09-03 (Wed, 03 Sep 2025)

  Changed paths:
    M mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td
    M mlir/lib/Target/LLVMIR/Dialect/Ptr/PtrToLLVMIRTranslation.cpp
    M mlir/test/Target/LLVMIR/ptr.mlir

  Log Message:
  -----------
  [mlir][ptr] Add translations to LLVMIR for ptr ops. (#156355)

Implements translation from ptr dialect to LLVM IR for core pointer
operations:
- `ptr.ptr_add` -> `getelementptr`
- `ptr.load` -> `load` with atomic ordering, volatility, and metadata
support
- `ptr.store` -> `store` with atomic ordering, volatility, and metadata
support
- `ptr.type_offset` -> GEP-based size computation

Example:

```mlir
llvm.func @test(%arg0: !ptr.ptr<#llvm.address_space<0>>) {
  %0 = ptr.type_offset f64 : i32
  %1 = ptr.ptr_add inbounds %arg0, %0 : !ptr.ptr<#llvm.address_space<0>>, i32
  %2 = ptr.load volatile %1 : !ptr.ptr<#llvm.address_space<0>> -> f64
  ptr.store %2, %arg0 : f64, !ptr.ptr<#llvm.address_space<0>>
  llvm.return
}
```
Translates to:
```llvm
define void @test(ptr %0) {
  %2 = getelementptr inbounds i8, ptr %0, i32 8
  %3 = load volatile double, ptr %2, align 8
  store double %3, ptr %0, align 8
  ret void
}
```



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