@@ -871,12 +871,11 @@ smt2_astt smt2_convt::convert_expr(const exprt &expr)
871
871
// do bitnot component-by-component
872
872
for (mp_integer i=0 ; i!=size; ++i)
873
873
{
874
- bvnot_node.add_child (
874
+ bvnot_node.add_child (smt2_astt::make (
875
+ " bvnot" ,
875
876
smt2_astt::make (
876
- " bvnot" ,
877
- smt2_astt::make (
878
- smt_typename + " ." + std::to_string ((size - i - 1 ).to_long ()),
879
- smt2_astt (" ?vectorop" ))));
877
+ smt_typename + " ." + std::to_string ((size - i - 1 ).to_long ()),
878
+ smt2_astt (" ?vectorop" ))));
880
879
}
881
880
882
881
return smt2_let (
@@ -932,12 +931,11 @@ smt2_astt smt2_convt::convert_expr(const exprt &expr)
932
931
// negate component-by-component
933
932
for (mp_integer i=0 ; i!=size; ++i)
934
933
{
935
- bvneg_node.add_child (
934
+ bvneg_node.add_child (smt2_astt::make (
935
+ " bvneg" ,
936
936
smt2_astt::make (
937
- " bvneg" ,
938
- smt2_astt::make (
939
- smt_typename + " ." + std::to_string ((size - i - 1 ).to_long ()),
940
- smt2_astt (" ?vectorop" ))));
937
+ smt_typename + " ." + std::to_string ((size - i - 1 ).to_long ()),
938
+ smt2_astt (" ?vectorop" ))));
941
939
}
942
940
943
941
return smt2_let (
@@ -1319,9 +1317,8 @@ smt2_astt smt2_convt::convert_expr(const exprt &expr)
1319
1317
{
1320
1318
typecast_exprt tmp (extractbit_expr.index (), extractbit_expr.src ().type ());
1321
1319
return smt2_eq (
1322
- smt2_extract (0 , 0 )(
1323
- smt2_astt::make (
1324
- " bvlshr" , flatten2bv (extractbit_expr.src ()), convert_expr (tmp))),
1320
+ smt2_extract (0 , 0 )(smt2_astt::make (
1321
+ " bvlshr" , flatten2bv (extractbit_expr.src ()), convert_expr (tmp))),
1325
1322
smt2_astt (" bin1" ));
1326
1323
}
1327
1324
}
@@ -1538,21 +1535,19 @@ smt2_astt smt2_convt::convert_expr(const exprt &expr)
1538
1535
convert_expr (expr.op0 ())),
1539
1536
smt2_sign_extend (smt2_astt::integer (mp_integer (1 )))(
1540
1537
convert_expr (expr.op1 ()))))},
1541
- smt2_not (
1542
- smt2_eq (
1543
- smt2_extract (width, width)(smt2_astt (" ?sum" )),
1544
- smt2_extract (width - 1 , width - 1 )(smt2_astt (" ?sum" )))));
1538
+ smt2_not (smt2_eq (
1539
+ smt2_extract (width, width)(smt2_astt (" ?sum" )),
1540
+ smt2_extract (width - 1 , width - 1 )(smt2_astt (" ?sum" )))));
1545
1541
}
1546
1542
else if (op_type.id ()==ID_unsignedbv ||
1547
1543
op_type.id ()==ID_pointer)
1548
1544
{
1549
1545
// overflow is simply carry-out
1550
1546
return smt2_eq (
1551
- smt2_extract (width, width)(
1552
- smt2_astt::make (
1553
- (subtract ? " bvsub" : " bvadd" ),
1554
- smt2_zero_extend (1 )(convert_expr (expr.op0 ())),
1555
- smt2_zero_extend (1 )(convert_expr (expr.op1 ())))),
1547
+ smt2_extract (width, width)(smt2_astt::make (
1548
+ (subtract ? " bvsub" : " bvadd" ),
1549
+ smt2_zero_extend (1 )(convert_expr (expr.op0 ())),
1550
+ smt2_zero_extend (1 )(convert_expr (expr.op1 ())))),
1556
1551
smt2_astt (" #b1" ));
1557
1552
}
1558
1553
else
@@ -1732,12 +1727,11 @@ smt2_astt smt2_convt::convert_expr(const exprt &expr)
1732
1727
1733
1728
for (std::size_t byte = 0 ; byte < bytes; byte++)
1734
1729
{
1735
- bindings.push_back (
1736
- std::make_pair (
1737
- smt2_astt (" bswap_byte_" + byte),
1738
- smt2_extract (
1739
- (byte * bits_per_byte + (bits_per_byte - 1 )),
1740
- (byte * bits_per_byte))(smt2_astt (" bswap_op" ))));
1730
+ bindings.push_back (std::make_pair (
1731
+ smt2_astt (" bswap_byte_" + byte),
1732
+ smt2_extract (
1733
+ (byte * bits_per_byte + (bits_per_byte - 1 )),
1734
+ (byte * bits_per_byte))(smt2_astt (" bswap_op" ))));
1741
1735
}
1742
1736
1743
1737
auto concat_node = smt2_astt::make (" concat" );
@@ -1872,9 +1866,8 @@ smt2_astt smt2_convt::convert_typecast(const typecast_exprt &expr)
1872
1866
if (to_width > from_integer_bits)
1873
1867
{
1874
1868
return smt2_sign_extend (
1875
- smt2_astt::integer (to_width - from_integer_bits))(
1876
- smt2_extract (from_width - 1 , from_fraction_bits)(
1877
- convert_expr (src)));
1869
+ smt2_astt::integer (to_width - from_integer_bits))(smt2_extract (
1870
+ from_width - 1 , from_fraction_bits)(convert_expr (src)));
1878
1871
}
1879
1872
else
1880
1873
{
@@ -1885,10 +1878,9 @@ smt2_astt smt2_convt::convert_typecast(const typecast_exprt &expr)
1885
1878
}(),
1886
1879
smt2_ite (
1887
1880
smt2_and (
1888
- smt2_not (
1889
- smt2_eq (
1890
- smt2_extract (from_fraction_bits - 1 , 0 )(smt2_astt (" ?tcop" )),
1891
- smt2_bv (0 , from_fraction_bits))),
1881
+ smt2_not (smt2_eq (
1882
+ smt2_extract (from_fraction_bits - 1 , 0 )(smt2_astt (" ?tcop" )),
1883
+ smt2_bv (0 , from_fraction_bits))),
1892
1884
smt2_eq (
1893
1885
smt2_extract (from_width - 1 , from_width - 1 )(
1894
1886
smt2_astt (" ?tcop" )),
@@ -2061,9 +2053,8 @@ smt2_astt smt2_convt::convert_typecast(const typecast_exprt &expr)
2061
2053
}
2062
2054
else
2063
2055
{
2064
- return smt2_sign_extend (
2065
- smt2_astt::integer (to_integer_bits - from_width))(
2066
- convert_expr (src));
2056
+ return smt2_sign_extend (smt2_astt::integer (
2057
+ to_integer_bits - from_width))(convert_expr (src));
2067
2058
}
2068
2059
}
2069
2060
}(),
@@ -2690,10 +2681,8 @@ smt2_astt smt2_convt::convert_is_dynamic_object(const exprt &expr)
2690
2681
auto node = smt2_astt::make (" or" );
2691
2682
for (const auto &object : dynamic_objects)
2692
2683
{
2693
- node.add_child (
2694
- smt2_eq (
2695
- smt2_bv (object, config.bv_encoding .object_bits ),
2696
- smt2_astt (" ?obj" )));
2684
+ node.add_child (smt2_eq (
2685
+ smt2_bv (object, config.bv_encoding .object_bits ), smt2_astt (" ?obj" )));
2697
2686
}
2698
2687
return node;
2699
2688
}());
@@ -3099,12 +3088,11 @@ smt2_astt smt2_convt::convert_div(const div_exprt &expr)
3099
3088
fixedbv_spect spec (to_fixedbv_type (expr.type ()));
3100
3089
std::size_t fraction_bits=spec.get_fraction_bits ();
3101
3090
3102
- return smt2_extract (spec.width - 1 , 0 )(
3091
+ return smt2_extract (spec.width - 1 , 0 )(smt2_astt::make (
3092
+ " bvsdiv" ,
3103
3093
smt2_astt::make (
3104
- " bvsdiv" ,
3105
- smt2_astt::make (
3106
- " concat" , convert_expr (expr.op0 ()), smt2_bv (0 , fraction_bits)),
3107
- smt2_sign_extend (fraction_bits)(convert_expr (expr.op1 ()))));
3094
+ " concat" , convert_expr (expr.op0 ()), smt2_bv (0 , fraction_bits)),
3095
+ smt2_sign_extend (fraction_bits)(convert_expr (expr.op1 ()))));
3108
3096
}
3109
3097
else if (expr.type ().id ()==ID_floatbv)
3110
3098
{
@@ -3498,24 +3486,22 @@ smt2_astt smt2_convt::convert_index(const index_exprt &expr)
3498
3486
std::size_t sub_width=boolbv_width (array_type.subtype ());
3499
3487
std::size_t index_width=boolbv_width (expr.index ().type ());
3500
3488
3501
- auto node = smt2_extract (sub_width - 1 , 0 )(
3502
- smt2_astt::make (
3503
- " bvlshr" ,
3504
- convert_expr (expr.array ()),
3505
- smt2_astt::make (" bvmul" , smt2_bv (sub_width, array_width), [&] {
3506
- // SMT2 says that the shift distance must be the same as
3507
- // the width of what we shift.
3508
- if (array_width > index_width)
3509
- {
3510
- return smt2_zero_extend (array_width - index_width)(
3511
- convert_expr (expr.index ()));
3512
- }
3513
- else
3514
- {
3515
- return smt2_extract (array_width - 1 , 0 )(
3516
- convert_expr (expr.index ()));
3517
- }
3518
- }())));
3489
+ auto node = smt2_extract (sub_width - 1 , 0 )(smt2_astt::make (
3490
+ " bvlshr" ,
3491
+ convert_expr (expr.array ()),
3492
+ smt2_astt::make (" bvmul" , smt2_bv (sub_width, array_width), [&] {
3493
+ // SMT2 says that the shift distance must be the same as
3494
+ // the width of what we shift.
3495
+ if (array_width > index_width)
3496
+ {
3497
+ return smt2_zero_extend (array_width - index_width)(
3498
+ convert_expr (expr.index ()));
3499
+ }
3500
+ else
3501
+ {
3502
+ return smt2_extract (array_width - 1 , 0 )(convert_expr (expr.index ()));
3503
+ }
3504
+ }())));
3519
3505
3520
3506
return unflatten (array_type.subtype (), std::move (node));
3521
3507
}
@@ -3537,11 +3523,10 @@ smt2_astt smt2_convt::convert_index(const index_exprt &expr)
3537
3523
}
3538
3524
else
3539
3525
{
3540
- return smt2_astt (
3541
- std::vector<smt2_astt>{smt2_index (
3542
- smt2_astt (smt_typename),
3543
- smt2_astt::integer (index_int->to_long ())),
3544
- convert_expr (expr.array ())});
3526
+ return smt2_astt (std::vector<smt2_astt>{
3527
+ smt2_index (
3528
+ smt2_astt (smt_typename), smt2_astt::integer (index_int->to_long ())),
3529
+ convert_expr (expr.array ())});
3545
3530
}
3546
3531
}
3547
3532
else
@@ -3628,11 +3613,9 @@ smt2_astt smt2_convt::flatten2bv(const exprt &expr)
3628
3613
auto concat_node = smt2_astt::make (" concat" );
3629
3614
for (mp_integer i=0 ; i!=size; ++i)
3630
3615
{
3631
- concat_node.add_child (
3632
- smt2_astt (
3633
- std::vector<smt2_astt>{
3634
- smt2_index (smt2_astt (smt_typename), smt2_astt::integer (i)),
3635
- smt2_astt (" ?vflop" )}));
3616
+ concat_node.add_child (smt2_astt (std::vector<smt2_astt>{
3617
+ smt2_index (smt2_astt (smt_typename), smt2_astt::integer (i)),
3618
+ smt2_astt (" ?vflop" )}));
3636
3619
}
3637
3620
return smt2_let (
3638
3621
{std::make_pair (smt2_astt (" ?vflop" ), convert_expr (expr))},
@@ -3656,22 +3639,20 @@ smt2_astt smt2_convt::flatten2bv(const exprt &expr)
3656
3639
const struct_typet::componentst &components=
3657
3640
struct_type.components ();
3658
3641
3659
- auto concat_node = smt2_astt (
3660
- std::vector<smt2_astt>{
3661
- smt2_index (
3662
- smt2_astt (smt_typename),
3663
- smt2_astt (id2string (components[0 ].get_name ()))),
3664
- smt2_astt (" ?sflop" )});
3642
+ auto concat_node = smt2_astt (std::vector<smt2_astt>{
3643
+ smt2_index (
3644
+ smt2_astt (smt_typename),
3645
+ smt2_astt (id2string (components[0 ].get_name ()))),
3646
+ smt2_astt (" ?sflop" )});
3665
3647
3666
3648
// SMT-LIB 2 concat is binary only
3667
3649
for (std::size_t i = 0 ; i < components.size (); ++i)
3668
3650
{
3669
3651
concat_node = smt2_concat (
3670
- smt2_astt (
3671
- std::vector<smt2_astt>{smt2_index (
3672
- smt2_astt (smt_typename),
3673
- smt2_astt (components[i - 1 ].get_name ())),
3674
- smt2_astt (" ?sflop" )}),
3652
+ smt2_astt (std::vector<smt2_astt>{
3653
+ smt2_index (
3654
+ smt2_astt (smt_typename), smt2_astt (components[i - 1 ].get_name ())),
3655
+ smt2_astt (" ?sflop" )}),
3675
3656
std::move (concat_node));
3676
3657
}
3677
3658
@@ -3729,9 +3710,8 @@ smt2_convt::unflatten(const typet &type, smt2_astt ast, unsigned nesting)
3729
3710
auto extract_node = smt2_extract (offset + subtype_width - 1 , offset)(
3730
3711
smt2_astt (" ?ufop" ));
3731
3712
extract_node.add_child (smt2_astt::integer (nesting));
3732
- mk_node.add_child (
3733
- unflatten (
3734
- vector_type.subtype (), std::move (extract_node), nesting + 1 ));
3713
+ mk_node.add_child (unflatten (
3714
+ vector_type.subtype (), std::move (extract_node), nesting + 1 ));
3735
3715
}
3736
3716
return mk_node;
3737
3717
}());
@@ -3745,8 +3725,7 @@ smt2_convt::unflatten(const typet &type, smt2_astt ast, unsigned nesting)
3745
3725
}
3746
3726
3747
3727
return smt2_let (
3748
- {std::make_pair (smt2_astt (" ?ufop" ), smt2_astt::integer (nesting))},
3749
- [&]() {
3728
+ {std::make_pair (smt2_astt (" ?ufop" ), smt2_astt::integer (nesting))}, [&]() {
3750
3729
// TODO ast is missing from here!!!
3751
3730
3752
3731
// extract members
0 commit comments