-
Notifications
You must be signed in to change notification settings - Fork 20
Verilog: cleanup downwards type propagation #1292
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
base: main
Are you sure you want to change the base?
Conversation
efc46fe
to
ef2522f
Compare
Should the failing regression test cause the test to be changed or is this a bug being introduced? |
I'll change the test. I think it's better not to try to optimise during type checking, even if it's just folding a constant. |
I'll do the semantic change as a separate PR. |
This cleans up verilog_typecheck_exprt::downwards_type_progatation to handle all the cases in 1800-2017 11.8.2.
ef2522f
to
9b7f39d
Compare
Restored previous semantics, which prevents the test failure |
static exprt zero_extend(const exprt &expr, const typet &type) | ||
{ | ||
auto old_width = expr.type().id() == ID_bool ? 1 | ||
: expr.type().id() == ID_integer | ||
? 32 | ||
: to_bitvector_type(expr.type()).get_width(); | ||
|
||
// first make unsigned | ||
typet tmp_type; | ||
|
||
if(type.id() == ID_unsignedbv) | ||
tmp_type = unsignedbv_typet{old_width}; | ||
else if(type.id() == ID_verilog_unsignedbv) | ||
tmp_type = verilog_unsignedbv_typet{old_width}; | ||
else | ||
PRECONDITION(false); | ||
|
||
return typecast_exprt::conditional_cast( | ||
typecast_exprt::conditional_cast(expr, tmp_type), 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.
Wouldn't use of zero_extend_exprt
make this unnecessary?
This cleans up
verilog_typecheck_exprt::downwards_type_progatation
to handle all the cases in 1800-2017 11.8.2.