20 typedef std::map<exprt, std::set<exprt> > used_bits_mapt;
21 used_bits_mapt used_bits_map;
23 for(
const auto &op : expr.
operands())
25 if(op.id() == ID_extractbit)
28 if(extractbit_expr.op1().is_constant())
29 used_bits_map[extractbit_expr.src()].insert(extractbit_expr.index());
31 else if(op.id() == ID_not &&
to_not_expr(op).op().
id() == ID_extractbit)
34 if(extractbit_expr.op1().is_constant())
35 used_bits_map[extractbit_expr.src()].insert(extractbit_expr.index());
41 for(used_bits_mapt::const_iterator it=used_bits_map.begin();
42 it!=used_bits_map.end();
47 boolbv_get_width(it->first.type(), width);
49 std::string value_string;
50 value_string.resize(width,
'0');
52 if(it->second.size()==width)
54 const irep_idt &ident=it->first.get(ID_identifier);
58 for(exprt::operandst::const_iterator oit=old_operands.begin();
59 oit!=old_operands.end();
62 if(oit->id()==ID_extractbit &&
63 oit->op1().is_constant())
65 if(oit->op0().get(ID_identifier)==ident)
68 const std::size_t value = numeric_cast_v<std::size_t>(val_expr);
69 value_string[value]=
'1';
72 std::cout <<
"[" << value <<
"]=1\n";
78 else if(oit->id()==ID_not &&
79 oit->op0().id()==ID_extractbit &&
80 oit->op0().op1().is_constant())
82 if(oit->op0().op0().get(ID_identifier)==ident)
89 new_operands.push_back(*oit);
93 new_operands.push_back(equality_exprt(it->first, new_value));
96 std::cout <<
"FINAL: " << value_string <<
'\n';
API to expression classes for bitvectors.
const extractbit_exprt & to_extractbit_expr(const exprt &expr)
Cast an exprt to an extractbit_exprt.
A constant literal expression.
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Base class for all expressions.
std::vector< exprt > operandst
const irep_idt & id() const
void simplify_extractbits(exprt &expr) const
API to expression classes.
const not_exprt & to_not_expr(const exprt &expr)
Cast an exprt to an not_exprt.