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

core: allow result variadic inference #3559

Merged
merged 3 commits into from
Dec 3, 2024

Conversation

alexarice
Copy link
Collaborator

Sort of a revert of #3416, but I believe this fixes the underlying problem.

Changes range constraint inference so that passing in a length is optional. The rationale for this is that the length of operands is always known, but the length of results is never known (as they can always be omitted). Similarly updates the can_infer function.

Probably needs a test of something. 🤷

@alexarice alexarice added the core xDSL core (ir, textual format, ...) label Dec 2, 2024
@alexarice alexarice self-assigned this Dec 2, 2024
Copy link

codecov bot commented Dec 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.40%. Comparing base (52431ee) to head (2f0dd23).
Report is 9 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##             main    #3559    +/-   ##
========================================
  Coverage   90.39%   90.40%            
========================================
  Files         466      466            
  Lines       58642    58760   +118     
  Branches     5585     5599    +14     
========================================
+ Hits        53009    53121   +112     
- Misses       4202     4203     +1     
- Partials     1431     1436     +5     

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

@@ -677,17 +677,21 @@ def get_variable_extractors(
"""
return {}

def can_infer(self, var_constraint_names: Set[str]) -> bool:
def can_infer(self, var_constraint_names: Set[str], length_known: bool) -> bool:
Copy link
Member

Choose a reason for hiding this comment

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

At the call site, the True or False don't communicate much in terms of what's going on, how do you feel about making the argument mandatory?

Suggested change
def can_infer(self, var_constraint_names: Set[str], length_known: bool) -> bool:
def can_infer(self, var_constraint_names: Set[str], *, length_known: bool) -> bool:

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

absolutely, I might do the same for infer?

Copy link
Member

@superlopuh superlopuh left a comment

Choose a reason for hiding this comment

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

Very very nice

@alexarice
Copy link
Collaborator Author

I'm think I'm going to add a test that shows that trying to infer a var_result_def(IntegerType(64)) fails, then this should be good to go

@alexarice alexarice merged commit 06e8ecb into main Dec 3, 2024
15 checks passed
@alexarice alexarice deleted the alexarice/range-inference-length branch December 3, 2024 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core xDSL core (ir, textual format, ...)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants