Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transformations: (convert-ptr-to-llvm) add lowering for ptr to llvm #3825

Draft
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

kaylendog
Copy link
Contributor

@kaylendog kaylendog commented Feb 3, 2025

WIP: Adds a pass, convert-ptr-to-llvm, for lowering the ptr_xdsl dialect to llvm.

TODO

  • Filecheck tests
  • Remove unsquashed commits(?)
  • Better realization of type sizes
  • Inference for pointee types, may require modification to ptr?

There's also a revert to 27bf821 as it breaks xdsl-opt.

Copy link

codecov bot commented Feb 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.16%. Comparing base (73437cd) to head (b1f374b).
Report is 27 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3825      +/-   ##
==========================================
- Coverage   91.25%   91.16%   -0.10%     
==========================================
  Files         461      462       +1     
  Lines       57630    57748     +118     
  Branches     5567     5587      +20     
==========================================
+ Hits        52591    52644      +53     
- Misses       3612     3675      +63     
- Partials     1427     1429       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@compor
Copy link
Collaborator

compor commented Feb 4, 2025

good stuff overall; I wouldn't worry about the unsquashed commits.
Wrt the reverted commit, not sure why it breaks your local xdsl-opt, but maybe something for later.

@superlopuh superlopuh added the transformations Changes or adds a transformatio label Feb 8, 2025
class ConvertPtrAddOp(RewritePattern):
@op_type_rewrite_pattern
def match_and_rewrite(self, op: ptr.PtrAddOp, rewriter: PatternRewriter, /):
# TODO: could be one cast?
Copy link
Member

Choose a reason for hiding this comment

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

please remove all todos in this file, either by addressing them, or by filing issues, let's discuss this

class ConvertTypeOffsetOp(RewritePattern):
@op_type_rewrite_pattern
def match_and_rewrite(self, op: ptr.TypeOffsetOp, rewriter: PatternRewriter, /):
# TODO: replace with memoized dict lookup
Copy link
Member

Choose a reason for hiding this comment

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

we have a helper for this, it should just be op.elem_type.size if it's a FixedBitwidthType, we might want to raise an error otherwise.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Btw I merged the type offset conversion pass so maybe you can just use it in this case

ConvertLoadOp(),
ConvertTypeOffsetOp(),
ConvertPtrAddOp(),
# TODO: could maybe use type rewriting?
Copy link
Member

Choose a reason for hiding this comment

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

let's try that

@superlopuh
Copy link
Member

Let's iterate on this? It would be good to merge everything you used, and throw away the rest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
transformations Changes or adds a transformatio
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants