cprover
Loading...
Searching...
No Matches
boolbv_ieee_float_rel.cpp
Go to the documentation of this file.
1/*******************************************************************\
2
3Module:
4
5Author: Daniel Kroening, kroening@kroening.com
6
7\*******************************************************************/
8
9#include "boolbv.h"
10
11#include "boolbv_type.h"
12
14
16
18{
19 const exprt::operandst &operands=expr.operands();
20 const irep_idt &rel=expr.id();
21
22 if(operands.size()==2)
23 {
24 const exprt &op0=expr.op0();
25 const exprt &op1=expr.op1();
26
27 bvtypet bvtype0=get_bvtype(op0.type());
28 bvtypet bvtype1=get_bvtype(op1.type());
29
30 const bvt &bv0=convert_bv(op0);
31 const bvt &bv1=convert_bv(op1);
32
33 if(bv0.size()==bv1.size() && !bv0.empty() &&
34 bvtype0==bvtypet::IS_FLOAT && bvtype1==bvtypet::IS_FLOAT)
35 {
36 float_utilst float_utils(prop, to_floatbv_type(op0.type()));
37
38 if(rel==ID_ieee_float_equal)
39 return float_utils.relation(bv0, float_utilst::relt::EQ, bv1);
40 else if(rel==ID_ieee_float_notequal)
41 return !float_utils.relation(bv0, float_utilst::relt::EQ, bv1);
42 else
43 return SUB::convert_rest(expr);
44 }
45 }
46
47 return SUB::convert_rest(expr);
48}
Pre-defined bitvector types.
const floatbv_typet & to_floatbv_type(const typet &type)
Cast a typet to a floatbv_typet.
bvtypet get_bvtype(const typet &type)
bvtypet
Definition boolbv_type.h:17
exprt & op0()
Definition expr.h:99
exprt & op1()
Definition expr.h:102
A base class for relations, i.e., binary predicates whose two operands have the same type.
Definition std_expr.h:674
virtual literalt convert_ieee_float_rel(const binary_relation_exprt &)
virtual const bvt & convert_bv(const exprt &expr, const optionalt< std::size_t > expected_width=nullopt)
Convert expression to vector of literalts, using an internal cache to speed up conversion if availabl...
Definition boolbv.cpp:40
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition dstring.h:37
Base class for all expressions.
Definition expr.h:54
std::vector< exprt > operandst
Definition expr.h:56
typet & type()
Return the type of the expression.
Definition expr.h:82
operandst & operands()
Definition expr.h:92
literalt relation(const bvt &src1, relt rel, const bvt &src2)
const irep_idt & id() const
Definition irep.h:396
virtual literalt convert_rest(const exprt &expr)
std::vector< literalt > bvt
Definition literal.h:201