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

Add support for atomic_min* and atomic_umin* intrinsics #1212

Merged
merged 8 commits into from
May 26, 2022

Conversation

adpaco-aws
Copy link
Contributor

Description of changes:

Defines a min expression on top of other expressions. Then uses the min expression to add support for atomic_min* and atomic_umin* intrinsics.

Resolved issues:

Part of #1163

Testing:

  • How is this change tested? Removes 10 tests and adds 2.

  • Is this a refactor change? No.

Checklist

  • Each commit message has a non-empty body, explaining why the change was made
  • Methods or procedures are documented
  • Regression or unit tests are included, or existing tests cover the modified code
  • My PR is restricted to a single feature or bugfix

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.

@adpaco-aws adpaco-aws requested a review from a team as a code owner May 23, 2022 21:55
// Expressions defined on top of other expressions

/// `min(self, e)`
pub fn min(self, e: Expr) -> Expr {
Copy link
Contributor

Choose a reason for hiding this comment

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

If there are side effects, this will evaluate them twice

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please take a look at the new changes, which complete the definition for is_side_effect and assert that neither of these cause side effects.

@adpaco-aws adpaco-aws requested a review from danielsn May 25, 2022 22:15
Comment on lines 290 to 297
fn are_side_effect(exprs: &Vec<Expr>) -> bool {
for expr in exprs {
if expr.is_side_effect() {
return true;
}
}
false
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Style ⛏️ : you could use exprs.iter().any(|e| e.is_side_effect())

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks!


#[kani::proof]
fn main() {
let mut a1 = 1 as u8;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason we only test for u8? Could we make this take a <T> and then test multiple bitwidths?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's pending in #25. But I'd like to do it once all atomic tests are in.

@danielsn danielsn merged commit fb03ccb into model-checking:main May 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants