[Feat] Add to_llvm_ptr op to convert fly.ptr to llvm.ptr - #921
Merged
Conversation
(cherry picked from commit 62d1e56)
Keep the new backend address-space API compliant with the repository's Python style gate. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a new Fly dialect operation (fly.to_llvm_ptr) and Python-facing helpers to expose a !fly.ptr<..., addrspace> as a backend-mapped !llvm.ptr<AS> for interoperability with LLVM/ROCDL-level ops during lowering.
Changes:
- Add
fly.to_llvm_ptrop with inferred return type!llvm.ptr<llvm_address_space>and add FlyToROCDL lowering that erases it as a passthrough when address spaces match. - Add ROCm backend address-space mapping and a backend-agnostic resolver used by the Python DSL helper
expr.primitive.to_llvm_ptr. - Add MLIR conversion tests asserting
fly.to_llvm_ptrlowers to a no-op passthrough withoutptrtoint/inttoptr.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/mlir/Conversion/pointer_ops.mlir | Adds conversion tests for fly.to_llvm_ptr lowering behavior. |
| python/flydsl/expr/typing.py | Adds Pointer.llvm_ptr convenience property to expose an LLVM pointer value. |
| python/flydsl/expr/primitive.py | Adds to_llvm_ptr(ptr) DSL helper calling the new Fly op. |
| python/flydsl/compiler/backends/rocm.py | Implements ROCm mapping from Fly semantic address spaces to LLVM address-space numbers. |
| python/flydsl/compiler/backends/base.py | Adds BaseBackend.llvm_address_space() extension point. |
| python/flydsl/compiler/backends/init.py | Adds resolve_llvm_address_space() using the active backend registry. |
| lib/Dialect/Fly/IR/FlyOps.cpp | Implements return-type inference for ToLLVMPtrOp. |
| lib/Conversion/FlyToROCDL/FlyToROCDL.cpp | Adds ToLLVMPtrOp lowering and uses ROCDL dialect AS constants in mapping. |
| include/flydsl/Dialect/Fly/IR/FlyOps.td | Declares the new Fly_ToLLVMPtrOp. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Reject malformed non-LLVM pointer results before lowering while leaving address-space policy to backends. Co-authored-by: Cursor <cursoragent@cursor.com>
Encode the LLVM pointer result contract in ODS so malformed result types are rejected by generated verification. Co-authored-by: Cursor <cursoragent@cursor.com>
The ODS result constraint remains covered by generated verification without a dedicated negative MLIR test. Co-authored-by: Cursor <cursoragent@cursor.com>
coderfeli
approved these changes
Jul 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Technical Details
Test Plan
Test Result
Submission Checklist