-
Notifications
You must be signed in to change notification settings - Fork 18
SMV: convert typecasts to SMV #1094
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
Conversation
328c22d
to
898660b
Compare
898660b
to
3615f28
Compare
src/smvlang/expr2smv.cpp
Outdated
|
||
if(src_width == dest_width) | ||
{ | ||
// signess change only |
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.
Nit pick: signess -> signedness
// Signedness _and_ width change. First go to signed, then extend. | ||
return convert_rec(smv_extend_exprt{ | ||
smv_signed_cast_exprt{expr.op(), signedbv_typet{src_width}}, | ||
dest_width - src_width, | ||
dest_type}); |
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.
Can we please have a test that covers this case? I suppose the order of operations makes a difference when the most significant bit is 1.
src/smvlang/expr2smv.cpp
Outdated
to_signedbv_type(src_type).get_width() == | ||
to_unsignedbv_type(dest_type).get_width()) | ||
{ | ||
// signess change only |
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.
signess -> signedness
// Signedness _and_ width change. | ||
// First enlarge, then go unsigned. | ||
return convert_rec(smv_unsigned_cast_exprt{ | ||
smv_extend_exprt{ | ||
expr.op(), dest_width - src_width, signedbv_typet{dest_width}}, | ||
dest_type}); |
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.
Again: test would be most appreciated.
src/smvlang/expr2smv.cpp
Outdated
else if(src_type.id() == ID_signedbv && dest_type.id() == ID_signedbv) | ||
{ | ||
// signed to signed, width change. | ||
// Note that resize(...) preserves the sign bit, unlike our typecast. |
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.
You use extend rather than resize here.
3615f28
to
5b8d0f2
Compare
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.
Approving, but tests would be appreciated as indicated.
4777980
to
485489e
Compare
Test added with all 12 cases. |
485489e
to
2447060
Compare
This adds conversion for a variety of typecast expressions into SMV syntax.
2447060
to
86c8025
Compare
This adds conversion for a variety of typecast expressions into SMV syntax.