void bv_refinementt::convert_floatbv_op(const exprt &expr, bvt &bv) { if(ns.follow(expr.type()).id()!=ID_floatbv || expr.operands().size()!=3) return SUB::convert_floatbv_op(expr, bv); add_approximation(expr, bv); }
void bv_refinementt::convert_mod(const exprt &expr, bvt &bv) { // we catch any mod // unless it's integer + constant assert(expr.operands().size()==2); if(expr.op1().is_constant()) return SUB::convert_mod(expr, bv); add_approximation(expr, bv); }
bvt bv_refinementt::convert_floatbv_op(const exprt &expr) { if(!do_arithmetic_refinement) return SUB::convert_floatbv_op(expr); if(ns.follow(expr.type()).id()!=ID_floatbv || expr.operands().size()!=3) return SUB::convert_floatbv_op(expr); bvt bv; add_approximation(expr, bv); return bv; }
bvt bv_refinementt::convert_mult(const exprt &expr) { if(!do_arithmetic_refinement || expr.type().id()==ID_fixedbv) return SUB::convert_mult(expr); // we catch any multiplication // unless it involves a constant const exprt::operandst &operands=expr.operands(); const typet &type=ns.follow(expr.type()); assert(operands.size()>=2); if(operands.size()>2) return convert_mult(make_binary(expr)); // make binary // we keep multiplication by a constant for integers if(type.id()!=ID_floatbv) if(operands[0].is_constant() || operands[1].is_constant()) return SUB::convert_mult(expr); bvt bv; approximationt &a=add_approximation(expr, bv); // initially, we have a partial interpretation for integers if(type.id()==ID_signedbv || type.id()==ID_unsignedbv) { // x*0==0 and 0*x==0 literalt op0_zero=bv_utils.is_zero(a.op0_bv); literalt op1_zero=bv_utils.is_zero(a.op1_bv); literalt res_zero=bv_utils.is_zero(a.result_bv); prop.l_set_to_true( prop.limplies(prop.lor(op0_zero, op1_zero), res_zero)); // x*1==x and 1*x==x literalt op0_one=bv_utils.is_one(a.op0_bv); literalt op1_one=bv_utils.is_one(a.op1_bv); literalt res_op0=bv_utils.equal(a.op0_bv, a.result_bv); literalt res_op1=bv_utils.equal(a.op1_bv, a.result_bv); prop.l_set_to_true(prop.limplies(op0_one, res_op1)); prop.l_set_to_true(prop.limplies(op1_one, res_op0)); } return bv; }
bvt bv_refinementt::convert_mod(const mod_exprt &expr) { if(!do_arithmetic_refinement || expr.type().id()==ID_fixedbv) return SUB::convert_mod(expr); // we catch any mod // unless it's integer + constant assert(expr.operands().size()==2); if(expr.op1().is_constant()) return SUB::convert_mod(expr); bvt bv; add_approximation(expr, bv); return bv; }