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

dialects: (csl) Added operations to manage symbols #2616

Merged
merged 11 commits into from
May 24, 2024

Conversation

dk949
Copy link
Collaborator

@dk949 dk949 commented May 21, 2024

This PR adds:

  • csl.addressof
    • Take address of a value (required for csl.export)
  • csl.export
    • Exports symbol by ssa value and name (as a string) or by symbol name
  • csl.rpc
    • equivalend to @rpc in the language
    • NOTE: I thought @rpc was going away in SDK 1.1, but now I can't find a reference to it in the documentation.
  • csl.param
    • Module import parameters (with optional default values)

@dk949 dk949 added the dialects Changes on the dialects label May 21, 2024
@dk949 dk949 requested review from superlopuh, AntonLydike and n-io May 21, 2024 17:26
@dk949 dk949 self-assigned this May 21, 2024
Copy link

codecov bot commented May 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.56%. Comparing base (6252a84) to head (e544e97).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2616      +/-   ##
==========================================
- Coverage   89.62%   89.56%   -0.06%     
==========================================
  Files         358      358              
  Lines       45676    45782     +106     
  Branches     6888     6920      +32     
==========================================
+ Hits        40935    41004      +69     
- Misses       3687     3712      +25     
- Partials     1054     1066      +12     

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

Comment on lines 718 to 733
def _verify_memref_addr(self, val_ty: MemRefType[Attribute], res_ty: PtrType):
res_elem_ty = res_ty.get_element_type()
if res_elem_ty == val_ty.get_element_type():
if res_ty.kind.data != PtrKind.MANY:
raise VerifyException(
f"The kind of scalar pointer to array has to be {PtrKind.MANY.value}"
)
elif res_elem_ty == val_ty:
if res_ty.kind.data != PtrKind.SINGLE:
raise VerifyException(
f"The kind of array pointer to array has to be {PtrKind.SINGLE.value}"
)
else:
raise VerifyException(
"Contained type of the result pointer must match the contained type of the operand memref or the memref itself"
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add a docstring to this method? It seems to be quite complex

Copy link
Collaborator

@AntonLydike AntonLydike left a comment

Choose a reason for hiding this comment

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

This is already pretty neat, I just have a few questions here where I'm not 100% sure if we are modelling it the right way.

%other_global_ptr = "test.op"() : () -> !csl.ptr<i16, #csl<ptr_kind single>, #csl<ptr_const var>>

"csl.export"() <{var_name = @initialize, type = () -> ()}> : () -> ()
"csl.export"() <{var_name = @global_ptr, type = !csl.ptr<f32, #csl<ptr_kind many>, #csl<ptr_const const>>}> : () -> ()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Where is @global_ptr? I think we should only allow function exporting using symbols, or do we have an op to "bind" a value to a symbol?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I assumed it's possible to declare a global pointer like that in MLIR, but it would make more sense to limit symbols to just function types.

dk949 added 3 commits May 22, 2024 12:23
When passing name as string with SSA operand, only pointer types can be
used.

When passing a symbol ref, only function types.
Copy link
Collaborator

@AntonLydike AntonLydike left a comment

Choose a reason for hiding this comment

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

Nice! Thank you!

@AntonLydike AntonLydike merged commit 9c12a76 into main May 24, 2024
10 checks passed
@AntonLydike AntonLydike deleted the david/csl-dialect/symbols branch May 24, 2024 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dialects Changes on the dialects
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants