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

backend: (csl) Add comparison operators to CSL #3139

Merged
merged 3 commits into from
Sep 4, 2024

Conversation

dk949
Copy link
Collaborator

@dk949 dk949 commented Sep 3, 2024

Adds integer and floating point comparisons as well as and and or.

Signed and unsigned integers are compared the same way.

Ordered and unordered floats are compared the same way.

true and false float comparisons are printed as true and false literals.

ord and uno comparisons result in an error.

arith.andi and arith.ori produce and and or operators when operating on i1 (bools) and & and | otherwise

Adds integer and floating point comparisons.

Signed and unsigned integers are compared the same way.

Ordered and unordered floats are compared the same way.

`true` and `false` float comparisons are printed as `true` and `false`
literals.

`ord` and `uno` comparisons result in an error.
@dk949 dk949 added the backend Compiler backend in xDSL label Sep 3, 2024
@dk949 dk949 self-assigned this Sep 3, 2024
Copy link

codecov bot commented Sep 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.99%. Comparing base (1559579) to head (a95b927).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3139   +/-   ##
=======================================
  Coverage   89.99%   89.99%           
=======================================
  Files         427      427           
  Lines       53834    53854   +20     
  Branches     8339     8343    +4     
=======================================
+ Hits        48449    48468   +19     
- Misses       4037     4038    +1     
  Partials     1348     1348           

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

"ult": "<",
"ule": "<=",
"une": "!=",
"uno": None,
Copy link
Collaborator

Choose a reason for hiding this comment

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

What happens in this case?

Copy link
Collaborator Author

@dk949 dk949 Sep 4, 2024

Choose a reason for hiding this comment

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

There is a check on line 122 for when the op maps to None.

Specifically for ord and uno we throw an error (line 127), because I think for now we don't need to handle this, and if we do, we will find out quickly when the error is thrown.

The technically correct version would be to do something like:

// place this at the top of the module
const math = @import_module("<math>");

...
// %res1 = arith.cmpf ord, %num1, %num2 : f32
const res1: bool = !math.isNaN(num1) and !math.isNaN(num2);

// %res2 = arith.cmpf ord, %num1, %num2 : f32
const res2: bool = math.isNaN(num1) or math.isNaN(num2);

@dk949 dk949 merged commit d775ed7 into main Sep 4, 2024
14 checks passed
@dk949 dk949 deleted the david/csl-backend/comparisons branch September 4, 2024 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Compiler backend in xDSL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants