Skip to content

[Feat] Add to_llvm_ptr op to convert fly.ptr to llvm.ptr - #921

Merged
coderfeli merged 5 commits into
mainfrom
pr/feat-to-llvm-ptr
Jul 30, 2026
Merged

[Feat] Add to_llvm_ptr op to convert fly.ptr to llvm.ptr #921
coderfeli merged 5 commits into
mainfrom
pr/feat-to-llvm-ptr

Conversation

@sjfeng1999

Copy link
Copy Markdown
Collaborator

Motivation

Technical Details

Test Plan

Test Result

Submission Checklist

sjfeng1999 and others added 2 commits July 29, 2026 02:50
Keep the new backend address-space API compliant with the repository's Python style gate.

Co-authored-by: Cursor <cursoragent@cursor.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_ptr op 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_ptr lowers to a no-op passthrough without ptrtoint/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.

Comment thread include/flydsl/Dialect/Fly/IR/FlyOps.td
Comment thread lib/Conversion/FlyToROCDL/FlyToROCDL.cpp
Comment thread lib/Dialect/Fly/IR/FlyOps.cpp
sjfeng1999 and others added 3 commits July 29, 2026 03:23
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
coderfeli merged commit 6d412e7 into main Jul 30, 2026
15 checks passed
@coderfeli
coderfeli deleted the pr/feat-to-llvm-ptr branch July 30, 2026 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants