-
Notifications
You must be signed in to change notification settings - Fork 72
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
Conversation
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.
Codecov ReportAll modified and coverable lines are covered by tests ✅
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. |
"ult": "<", | ||
"ule": "<=", | ||
"une": "!=", | ||
"uno": None, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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);
Adds integer and floating point comparisons as well as
and
andor
.Signed and unsigned integers are compared the same way.
Ordered and unordered floats are compared the same way.
true
andfalse
float comparisons are printed astrue
andfalse
literals.ord
anduno
comparisons result in an error.arith.andi
andarith.ori
produceand
andor
operators when operating oni1
(bools) and&
and|
otherwise