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

PR for shift left overflow problem (issue #85) #86

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion runtime/qsym_backend/Runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ DEF_BINARY_EXPR_BUILDER(signed_div, SDiv)
DEF_BINARY_EXPR_BUILDER(unsigned_rem, URem)
DEF_BINARY_EXPR_BUILDER(signed_rem, SRem)

DEF_BINARY_EXPR_BUILDER(shift_left, Shl)
// DEF_BINARY_EXPR_BUILDER(shift_left, Shl)
DEF_BINARY_EXPR_BUILDER(logical_shift_right, LShr)
DEF_BINARY_EXPR_BUILDER(arithmetic_shift_right, AShr)

Expand All @@ -256,6 +256,13 @@ DEF_BINARY_EXPR_BUILDER(xor, Xor)

#undef DEF_BINARY_EXPR_BUILDER

SymExpr _sym_build_shift_left(SymExpr a, SymExpr b) {
return registerExpression(
g_expr_builder->createShl(allocatedExpressions.at(a),
g_expr_builder->createAnd(allocatedExpressions.at(b),
allocatedExpressions.at(_sym_build_integer(31, 32)))));
}

SymExpr _sym_build_neg(SymExpr expr) {
return registerExpression(
g_expr_builder->createNeg(allocatedExpressions.at(expr)));
Expand Down
6 changes: 5 additions & 1 deletion runtime/simple_backend/Runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ DEF_BINARY_EXPR_BUILDER(unsigned_div, bvudiv)
DEF_BINARY_EXPR_BUILDER(signed_div, bvsdiv)
DEF_BINARY_EXPR_BUILDER(unsigned_rem, bvurem)
DEF_BINARY_EXPR_BUILDER(signed_rem, bvsrem)
DEF_BINARY_EXPR_BUILDER(shift_left, bvshl)
// DEF_BINARY_EXPR_BUILDER(shift_left, bvshl)
DEF_BINARY_EXPR_BUILDER(logical_shift_right, bvlshr)
DEF_BINARY_EXPR_BUILDER(arithmetic_shift_right, bvashr)

Expand All @@ -241,6 +241,10 @@ DEF_BINARY_EXPR_BUILDER(float_ordered_equal, fpa_eq)

#undef DEF_BINARY_EXPR_BUILDER

SymExpr _sym_build_shift_left(SymExpr a, SymExpr b) {
return registerExpression(Z3_mk_bvshl(g_context, a, Z3_mk_bvand(g_context, b, _sym_build_integer(31, 32))));
}

Z3_ast _sym_build_fp_add(Z3_ast a, Z3_ast b) {
return registerExpression(Z3_mk_fpa_add(g_context, g_rounding_mode, a, b));
}
Expand Down