cprover
Loading...
Searching...
No Matches
bitvector_expr.h
Go to the documentation of this file.
1/*******************************************************************\
2
3Module: API to expression classes for bitvectors
4
5Author: Daniel Kroening, kroening@kroening.com
6
7\*******************************************************************/
8
9#ifndef CPROVER_UTIL_BITVECTOR_EXPR_H
10#define CPROVER_UTIL_BITVECTOR_EXPR_H
11
14
15#include "std_expr.h"
16
19{
20public:
21 bswap_exprt(exprt _op, std::size_t bits_per_byte, typet _type)
22 : unary_exprt(ID_bswap, std::move(_op), std::move(_type))
23 {
24 set_bits_per_byte(bits_per_byte);
25 }
26
27 bswap_exprt(exprt _op, std::size_t bits_per_byte)
28 : unary_exprt(ID_bswap, std::move(_op))
29 {
30 set_bits_per_byte(bits_per_byte);
31 }
32
33 std::size_t get_bits_per_byte() const
34 {
35 return get_size_t(ID_bits_per_byte);
36 }
37
38 void set_bits_per_byte(std::size_t bits_per_byte)
39 {
40 set_size_t(ID_bits_per_byte, bits_per_byte);
41 }
42};
43
44template <>
45inline bool can_cast_expr<bswap_exprt>(const exprt &base)
46{
47 return base.id() == ID_bswap;
48}
49
50inline void validate_expr(const bswap_exprt &value)
51{
52 validate_operands(value, 1, "bswap must have one operand");
54 value.op().type() == value.type(), "bswap type must match operand type");
55}
56
63inline const bswap_exprt &to_bswap_expr(const exprt &expr)
64{
65 PRECONDITION(expr.id() == ID_bswap);
66 const bswap_exprt &ret = static_cast<const bswap_exprt &>(expr);
67 validate_expr(ret);
68 return ret;
69}
70
73{
74 PRECONDITION(expr.id() == ID_bswap);
75 bswap_exprt &ret = static_cast<bswap_exprt &>(expr);
76 validate_expr(ret);
77 return ret;
78}
79
82{
83public:
84 explicit bitnot_exprt(exprt op) : unary_exprt(ID_bitnot, std::move(op))
85 {
86 }
87};
88
89template <>
90inline bool can_cast_expr<bitnot_exprt>(const exprt &base)
91{
92 return base.id() == ID_bitnot;
93}
94
95inline void validate_expr(const bitnot_exprt &value)
96{
97 validate_operands(value, 1, "Bit-wise not must have one operand");
98}
99
106inline const bitnot_exprt &to_bitnot_expr(const exprt &expr)
107{
108 PRECONDITION(expr.id() == ID_bitnot);
109 const bitnot_exprt &ret = static_cast<const bitnot_exprt &>(expr);
110 validate_expr(ret);
111 return ret;
112}
113
116{
117 PRECONDITION(expr.id() == ID_bitnot);
118 bitnot_exprt &ret = static_cast<bitnot_exprt &>(expr);
119 validate_expr(ret);
120 return ret;
121}
122
127{
128public:
129 bitor_exprt(const exprt &_op0, exprt _op1)
130 : multi_ary_exprt(_op0, ID_bitor, std::move(_op1), _op0.type())
131 {
132 }
133
134 explicit bitor_exprt(exprt::operandst _operands)
135 : multi_ary_exprt(ID_bitor, std::move(_operands))
136 {
137 }
138
140 : multi_ary_exprt(ID_bitor, std::move(_operands), std::move(_type))
141 {
142 }
143};
144
145template <>
146inline bool can_cast_expr<bitor_exprt>(const exprt &base)
147{
148 return base.id() == ID_bitor;
149}
150
157inline const bitor_exprt &to_bitor_expr(const exprt &expr)
158{
159 PRECONDITION(expr.id() == ID_bitor);
160 return static_cast<const bitor_exprt &>(expr);
161}
162
165{
166 PRECONDITION(expr.id() == ID_bitor);
167 return static_cast<bitor_exprt &>(expr);
168}
169
178{
179public:
181 : multi_ary_exprt(std::move(_op0), ID_bitnor, std::move(_op1))
182 {
183 }
184
185 explicit bitnor_exprt(exprt::operandst _operands)
186 : multi_ary_exprt(ID_bitnor, std::move(_operands))
187 {
188 }
189
191 : multi_ary_exprt(ID_bitnor, std::move(_operands), std::move(_type))
192 {
193 }
194};
195
196template <>
197inline bool can_cast_expr<bitnor_exprt>(const exprt &base)
198{
199 return base.id() == ID_bitnor;
200}
201
208inline const bitnor_exprt &to_bitnor_expr(const exprt &expr)
209{
210 PRECONDITION(expr.id() == ID_bitnor);
211 return static_cast<const bitnor_exprt &>(expr);
212}
213
216{
217 PRECONDITION(expr.id() == ID_bitnor);
218 return static_cast<bitnor_exprt &>(expr);
219}
220
225{
226public:
228 : multi_ary_exprt(std::move(_op0), ID_bitxor, std::move(_op1))
229 {
230 }
231
232 explicit bitxor_exprt(exprt::operandst _operands)
233 : multi_ary_exprt(ID_bitxor, std::move(_operands))
234 {
235 }
236
238 : multi_ary_exprt(ID_bitxor, std::move(_operands), std::move(_type))
239 {
240 }
241};
242
243template <>
244inline bool can_cast_expr<bitxor_exprt>(const exprt &base)
245{
246 return base.id() == ID_bitxor;
247}
248
255inline const bitxor_exprt &to_bitxor_expr(const exprt &expr)
256{
257 PRECONDITION(expr.id() == ID_bitxor);
258 return static_cast<const bitxor_exprt &>(expr);
259}
260
263{
264 PRECONDITION(expr.id() == ID_bitxor);
265 return static_cast<bitxor_exprt &>(expr);
266}
267
276{
277public:
279 : multi_ary_exprt(_op0, ID_bitxnor, _op1, _op0.type())
280 {
281 }
282
283 explicit bitxnor_exprt(exprt::operandst _operands)
284 : multi_ary_exprt(ID_bitxnor, std::move(_operands))
285 {
286 }
287
289 : multi_ary_exprt(ID_bitxnor, std::move(_operands), std::move(_type))
290 {
291 }
292};
293
294template <>
295inline bool can_cast_expr<bitxnor_exprt>(const exprt &base)
296{
297 return base.id() == ID_bitxnor;
298}
299
306inline const bitxnor_exprt &to_bitxnor_expr(const exprt &expr)
307{
308 PRECONDITION(expr.id() == ID_bitxnor);
310 return static_cast<const bitxnor_exprt &>(expr);
311}
312
315{
316 PRECONDITION(expr.id() == ID_bitxnor);
318 return static_cast<bitxnor_exprt &>(expr);
319}
320
325{
326public:
327 bitand_exprt(const exprt &_op0, exprt _op1)
328 : multi_ary_exprt(_op0, ID_bitand, std::move(_op1), _op0.type())
329 {
330 }
331
332 explicit bitand_exprt(exprt::operandst _operands)
333 : multi_ary_exprt(ID_bitand, std::move(_operands))
334 {
335 }
336
338 : multi_ary_exprt(ID_bitand, std::move(_operands), std::move(_type))
339 {
340 }
341};
342
343template <>
344inline bool can_cast_expr<bitand_exprt>(const exprt &base)
345{
346 return base.id() == ID_bitand;
347}
348
355inline const bitand_exprt &to_bitand_expr(const exprt &expr)
356{
357 PRECONDITION(expr.id() == ID_bitand);
358 return static_cast<const bitand_exprt &>(expr);
359}
360
363{
364 PRECONDITION(expr.id() == ID_bitand);
365 return static_cast<bitand_exprt &>(expr);
366}
367
376{
377public:
379 : multi_ary_exprt(std::move(_op0), ID_bitnand, std::move(_op1))
380 {
381 }
382
383 explicit bitnand_exprt(exprt::operandst _operands)
384 : multi_ary_exprt(ID_bitnand, std::move(_operands))
385 {
386 }
387
389 : multi_ary_exprt(ID_bitnand, std::move(_operands), std::move(_type))
390 {
391 }
392};
393
394template <>
395inline bool can_cast_expr<bitnand_exprt>(const exprt &base)
396{
397 return base.id() == ID_bitnand;
398}
399
406inline const bitnand_exprt &to_bitnand_expr(const exprt &expr)
407{
408 PRECONDITION(expr.id() == ID_bitnand);
409 return static_cast<const bitnand_exprt &>(expr);
410}
411
414{
415 PRECONDITION(expr.id() == ID_bitnand);
416 return static_cast<bitnand_exprt &>(expr);
417}
418
421{
422public:
423 shift_exprt(exprt _src, const irep_idt &_id, exprt _distance)
424 : binary_exprt(std::move(_src), _id, std::move(_distance))
425 {
426 }
427
428 shift_exprt(exprt _src, const irep_idt &_id, const std::size_t _distance);
429
431 {
432 return op0();
433 }
434
435 const exprt &op() const
436 {
437 return op0();
438 }
439
441 {
442 return op1();
443 }
444
445 const exprt &distance() const
446 {
447 return op1();
448 }
449};
450
451template <>
452inline bool can_cast_expr<shift_exprt>(const exprt &base)
453{
454 return base.id() == ID_shl || base.id() == ID_ashr || base.id() == ID_lshr ||
455 base.id() == ID_ror || base.id() == ID_rol;
456}
457
458inline void validate_expr(const shift_exprt &value)
459{
460 validate_operands(value, 2, "Shifts must have two operands");
461}
462
469inline const shift_exprt &to_shift_expr(const exprt &expr)
470{
471 const shift_exprt &ret = static_cast<const shift_exprt &>(expr);
472 validate_expr(ret);
473 return ret;
474}
475
478{
479 shift_exprt &ret = static_cast<shift_exprt &>(expr);
480 validate_expr(ret);
481 return ret;
482}
483
485class shl_exprt : public shift_exprt
486{
487public:
488 shl_exprt(exprt _src, exprt _distance)
489 : shift_exprt(std::move(_src), ID_shl, std::move(_distance))
490 {
491 }
492
493 shl_exprt(exprt _src, const std::size_t _distance)
494 : shift_exprt(std::move(_src), ID_shl, _distance)
495 {
496 }
497};
498
499template <>
500inline bool can_cast_expr<shl_exprt>(const exprt &base)
501{
502 return base.id() == ID_shl;
503}
504
511inline const shl_exprt &to_shl_expr(const exprt &expr)
512{
513 PRECONDITION(expr.id() == ID_shl);
514 const shl_exprt &ret = static_cast<const shl_exprt &>(expr);
515 validate_expr(ret);
516 return ret;
517}
518
521{
522 PRECONDITION(expr.id() == ID_shl);
523 shl_exprt &ret = static_cast<shl_exprt &>(expr);
524 validate_expr(ret);
525 return ret;
526}
527
530{
531public:
532 ashr_exprt(exprt _src, exprt _distance)
533 : shift_exprt(std::move(_src), ID_ashr, std::move(_distance))
534 {
535 }
536
537 ashr_exprt(exprt _src, const std::size_t _distance)
538 : shift_exprt(std::move(_src), ID_ashr, _distance)
539 {
540 }
541};
542
543template <>
544inline bool can_cast_expr<ashr_exprt>(const exprt &base)
545{
546 return base.id() == ID_ashr;
547}
548
551{
552public:
553 lshr_exprt(exprt _src, exprt _distance)
554 : shift_exprt(std::move(_src), ID_lshr, std::move(_distance))
555 {
556 }
557
558 lshr_exprt(exprt _src, const std::size_t _distance)
559 : shift_exprt(std::move(_src), ID_lshr, std::move(_distance))
560 {
561 }
562};
563
564template <>
565inline bool can_cast_expr<lshr_exprt>(const exprt &base)
566{
567 return base.id() == ID_lshr;
568}
569
572{
573public:
576 : binary_predicate_exprt(std::move(_src), ID_extractbit, std::move(_index))
577 {
578 }
579
580 extractbit_exprt(exprt _src, const std::size_t _index);
581
583 {
584 return op0();
585 }
586
588 {
589 return op1();
590 }
591
592 const exprt &src() const
593 {
594 return op0();
595 }
596
597 const exprt &index() const
598 {
599 return op1();
600 }
601};
602
603template <>
605{
606 return base.id() == ID_extractbit;
607}
608
609inline void validate_expr(const extractbit_exprt &value)
610{
611 validate_operands(value, 2, "Extract bit must have two operands");
612}
613
620inline const extractbit_exprt &to_extractbit_expr(const exprt &expr)
621{
622 PRECONDITION(expr.id() == ID_extractbit);
623 const extractbit_exprt &ret = static_cast<const extractbit_exprt &>(expr);
624 validate_expr(ret);
625 return ret;
626}
627
630{
631 PRECONDITION(expr.id() == ID_extractbit);
632 extractbit_exprt &ret = static_cast<extractbit_exprt &>(expr);
633 validate_expr(ret);
634 return ret;
635}
636
639{
640public:
646 extractbits_exprt(exprt _src, exprt _index, typet _type)
648 ID_extractbits,
649 std::move(_type),
650 {std::move(_src), std::move(_index)})
651 {
652 }
653
654 extractbits_exprt(exprt _src, const std::size_t _index, typet _type);
655
657 {
658 return op0();
659 }
660
662 {
663 return op1();
664 }
665
666 const exprt &src() const
667 {
668 return op0();
669 }
670
671 const exprt &index() const
672 {
673 return op1();
674 }
675};
676
677template <>
679{
680 return base.id() == ID_extractbits;
681}
682
683inline void validate_expr(const extractbits_exprt &value)
684{
685 validate_operands(value, 2, "Extractbits must have two operands");
686}
687
695{
696 PRECONDITION(expr.id() == ID_extractbits);
697 const extractbits_exprt &ret = static_cast<const extractbits_exprt &>(expr);
698 validate_expr(ret);
699 return ret;
700}
701
704{
705 PRECONDITION(expr.id() == ID_extractbits);
706 extractbits_exprt &ret = static_cast<extractbits_exprt &>(expr);
707 validate_expr(ret);
708 return ret;
709}
710
713{
714public:
719 update_bit_exprt(exprt _src, exprt _index, exprt _new_value)
721 ID_update_bit,
722 _src.type(),
723 {_src, std::move(_index), std::move(_new_value)})
724 {
725 PRECONDITION(new_value().type().id() == ID_bool);
726 }
727
728 update_bit_exprt(exprt _src, const std::size_t _index, exprt _new_value);
729
731 {
732 return op0();
733 }
734
736 {
737 return op1();
738 }
739
741 {
742 return op2();
743 }
744
745 const exprt &src() const
746 {
747 return op0();
748 }
749
750 const exprt &index() const
751 {
752 return op1();
753 }
754
755 const exprt &new_value() const
756 {
757 return op2();
758 }
759
760 static void check(
761 const exprt &expr,
763 {
764 validate_operands(expr, 3, "update_bit must have three operands");
765 }
766
768 exprt lower() const;
769};
770
771template <>
773{
774 return base.id() == ID_update_bit;
775}
776
783inline const update_bit_exprt &to_update_bit_expr(const exprt &expr)
784{
785 PRECONDITION(expr.id() == ID_update_bit);
787 return static_cast<const update_bit_exprt &>(expr);
788}
789
792{
793 PRECONDITION(expr.id() == ID_update_bit);
795 return static_cast<update_bit_exprt &>(expr);
796}
797
800{
801public:
806 update_bits_exprt(exprt _src, exprt _index, exprt _new_value)
808 ID_update_bits,
809 _src.type(),
810 {_src, std::move(_index), std::move(_new_value)})
811 {
812 }
813
814 update_bits_exprt(exprt _src, const std::size_t _index, exprt _new_value);
815
817 {
818 return op0();
819 }
820
822 {
823 return op1();
824 }
825
827 {
828 return op2();
829 }
830
831 const exprt &src() const
832 {
833 return op0();
834 }
835
836 const exprt &index() const
837 {
838 return op1();
839 }
840
841 const exprt &new_value() const
842 {
843 return op2();
844 }
845
846 static void check(
847 const exprt &expr,
849 {
850 validate_operands(expr, 3, "update_bits must have three operands");
851 }
852
854 exprt lower() const;
855};
856
857template <>
859{
860 return base.id() == ID_update_bits;
861}
862
870{
871 PRECONDITION(expr.id() == ID_update_bits);
873 return static_cast<const update_bits_exprt &>(expr);
874}
875
878{
879 PRECONDITION(expr.id() == ID_update_bits);
881 return static_cast<update_bits_exprt &>(expr);
882}
883
886{
887public:
889 : binary_exprt(
890 std::move(_times),
891 ID_replication,
892 std::move(_src),
893 std::move(_type))
894 {
895 }
896
898 {
899 return static_cast<constant_exprt &>(op0());
900 }
901
902 const constant_exprt &times() const
903 {
904 return static_cast<const constant_exprt &>(op0());
905 }
906
908 {
909 return op1();
910 }
911
912 const exprt &op() const
913 {
914 return op1();
915 }
916};
917
918template <>
920{
921 return base.id() == ID_replication;
922}
923
924inline void validate_expr(const replication_exprt &value)
925{
926 validate_operands(value, 2, "Bit-wise replication must have two operands");
927}
928
936{
937 PRECONDITION(expr.id() == ID_replication);
938 const replication_exprt &ret = static_cast<const replication_exprt &>(expr);
939 validate_expr(ret);
940 return ret;
941}
942
945{
946 PRECONDITION(expr.id() == ID_replication);
947 replication_exprt &ret = static_cast<replication_exprt &>(expr);
948 validate_expr(ret);
949 return ret;
950}
951
958{
959public:
961 : multi_ary_exprt(ID_concatenation, std::move(_operands), std::move(_type))
962 {
963 }
964
967 ID_concatenation,
968 {std::move(_op0), std::move(_op1)},
969 std::move(_type))
970 {
971 }
972};
973
974template <>
976{
977 return base.id() == ID_concatenation;
978}
979
987{
988 PRECONDITION(expr.id() == ID_concatenation);
989 return static_cast<const concatenation_exprt &>(expr);
990}
991
994{
995 PRECONDITION(expr.id() == ID_concatenation);
996 return static_cast<concatenation_exprt &>(expr);
997}
998
1001{
1002public:
1004 : unary_exprt(ID_popcount, std::move(_op), std::move(_type))
1005 {
1006 }
1007
1008 explicit popcount_exprt(const exprt &_op)
1009 : unary_exprt(ID_popcount, _op, _op.type())
1010 {
1011 }
1012
1015 exprt lower() const;
1016};
1017
1018template <>
1019inline bool can_cast_expr<popcount_exprt>(const exprt &base)
1020{
1021 return base.id() == ID_popcount;
1022}
1023
1024inline void validate_expr(const popcount_exprt &value)
1025{
1026 validate_operands(value, 1, "popcount must have one operand");
1027}
1028
1035inline const popcount_exprt &to_popcount_expr(const exprt &expr)
1036{
1037 PRECONDITION(expr.id() == ID_popcount);
1038 const popcount_exprt &ret = static_cast<const popcount_exprt &>(expr);
1039 validate_expr(ret);
1040 return ret;
1041}
1042
1045{
1046 PRECONDITION(expr.id() == ID_popcount);
1047 popcount_exprt &ret = static_cast<popcount_exprt &>(expr);
1048 validate_expr(ret);
1049 return ret;
1050}
1051
1055{
1056public:
1058 : binary_predicate_exprt(std::move(_lhs), make_id(kind), std::move(_rhs))
1059 {
1060 INVARIANT(
1061 valid_id(id()),
1062 "The kind used to construct binary_overflow_exprt should be in the set "
1063 "of expected valid kinds.");
1064 }
1065
1066 static void check(
1067 const exprt &expr,
1069 {
1070 binary_exprt::check(expr, vm);
1071
1072 if(expr.id() != ID_overflow_shl)
1073 {
1074 const binary_exprt &binary_expr = to_binary_expr(expr);
1075 DATA_CHECK(
1076 vm,
1077 binary_expr.lhs().type() == binary_expr.rhs().type(),
1078 "operand types must match");
1079 }
1080 }
1081
1082 static void validate(
1083 const exprt &expr,
1084 const namespacet &,
1086 {
1087 check(expr, vm);
1088 }
1089
1091 static bool valid_id(const irep_idt &id)
1092 {
1093 return id == ID_overflow_plus || id == ID_overflow_mult ||
1094 id == ID_overflow_minus || id == ID_overflow_shl;
1095 }
1096
1097private:
1098 static irep_idt make_id(const irep_idt &kind)
1099 {
1100 if(valid_id(kind))
1101 return kind;
1102 else
1103 return "overflow-" + id2string(kind);
1104 }
1105};
1106
1107template <>
1109{
1110 return binary_overflow_exprt::valid_id(base.id());
1111}
1112
1113inline void validate_expr(const binary_overflow_exprt &value)
1114{
1116 value, 2, "binary overflow expression must have two operands");
1117}
1118
1126{
1128 expr.id() == ID_overflow_plus || expr.id() == ID_overflow_mult ||
1129 expr.id() == ID_overflow_minus || expr.id() == ID_overflow_shl);
1130 const binary_overflow_exprt &ret =
1131 static_cast<const binary_overflow_exprt &>(expr);
1132 validate_expr(ret);
1133 return ret;
1134}
1135
1138{
1140 expr.id() == ID_overflow_plus || expr.id() == ID_overflow_mult ||
1141 expr.id() == ID_overflow_minus || expr.id() == ID_overflow_shl);
1142 binary_overflow_exprt &ret = static_cast<binary_overflow_exprt &>(expr);
1143 validate_expr(ret);
1144 return ret;
1145}
1146
1148{
1149public:
1151 : binary_overflow_exprt(std::move(_lhs), ID_overflow_plus, std::move(_rhs))
1152 {
1153 }
1154
1157 exprt lower() const;
1158};
1159
1160template <>
1162{
1163 return base.id() == ID_overflow_plus;
1164}
1165
1167{
1168public:
1170 : binary_overflow_exprt(std::move(_lhs), ID_overflow_minus, std::move(_rhs))
1171 {
1172 }
1173
1176 exprt lower() const;
1177};
1178
1179template <>
1181{
1182 return base.id() == ID_overflow_minus;
1183}
1184
1186{
1187public:
1189 : binary_overflow_exprt(std::move(_lhs), ID_overflow_mult, std::move(_rhs))
1190 {
1191 }
1192
1195 exprt lower() const;
1196};
1197
1198template <>
1200{
1201 return base.id() == ID_overflow_mult;
1202}
1203
1205{
1206public:
1208 : binary_overflow_exprt(std::move(_lhs), ID_overflow_shl, std::move(_rhs))
1209 {
1210 }
1211};
1212
1213template <>
1215{
1216 return base.id() == ID_overflow_shl;
1217}
1218
1222{
1223public:
1225 : unary_predicate_exprt("overflow-" + id2string(kind), std::move(_op))
1226 {
1227 }
1228
1229 static void check(
1230 const exprt &expr,
1232 {
1233 unary_exprt::check(expr, vm);
1234 }
1235
1236 static void validate(
1237 const exprt &expr,
1238 const namespacet &,
1240 {
1241 check(expr, vm);
1242 }
1243};
1244
1245template <>
1247{
1248 return base.id() == ID_overflow_unary_minus;
1249}
1250
1251inline void validate_expr(const unary_overflow_exprt &value)
1252{
1254 value, 1, "unary overflow expression must have one operand");
1255}
1256
1260{
1261public:
1263 : unary_overflow_exprt(ID_unary_minus, std::move(_op))
1264 {
1265 }
1266
1267 static void check(
1268 const exprt &expr,
1270 {
1271 unary_exprt::check(expr, vm);
1272 }
1273
1274 static void validate(
1275 const exprt &expr,
1276 const namespacet &,
1278 {
1279 check(expr, vm);
1280 }
1281};
1282
1283template <>
1285{
1286 return base.id() == ID_overflow_unary_minus;
1287}
1288
1290{
1292 value, 1, "unary minus overflow expression must have one operand");
1293}
1294
1302{
1303 PRECONDITION(expr.id() == ID_overflow_unary_minus);
1304 const unary_overflow_exprt &ret =
1305 static_cast<const unary_overflow_exprt &>(expr);
1306 validate_expr(ret);
1307 return ret;
1308}
1309
1312{
1313 PRECONDITION(expr.id() == ID_overflow_unary_minus);
1314 unary_overflow_exprt &ret = static_cast<unary_overflow_exprt &>(expr);
1315 validate_expr(ret);
1316 return ret;
1317}
1318
1325{
1326public:
1327 count_leading_zeros_exprt(exprt _op, bool _zero_permitted, typet _type)
1328 : unary_exprt(ID_count_leading_zeros, std::move(_op), std::move(_type))
1329 {
1330 zero_permitted(_zero_permitted);
1331 }
1332
1334 : count_leading_zeros_exprt(_op, true, _op.type())
1335 {
1336 }
1337
1338 bool zero_permitted() const
1339 {
1340 return !get_bool(ID_C_bounds_check);
1341 }
1342
1343 void zero_permitted(bool value)
1344 {
1345 set(ID_C_bounds_check, !value);
1346 }
1347
1348 static void check(
1349 const exprt &expr,
1351 {
1352 DATA_CHECK(
1353 vm,
1354 expr.operands().size() == 1,
1355 "unary expression must have a single operand");
1356 DATA_CHECK(
1357 vm,
1359 "operand must be of bitvector type");
1360 }
1361
1362 static void validate(
1363 const exprt &expr,
1364 const namespacet &,
1366 {
1367 check(expr, vm);
1368 }
1369
1372 exprt lower() const;
1373};
1374
1375template <>
1377{
1378 return base.id() == ID_count_leading_zeros;
1379}
1380
1382{
1383 validate_operands(value, 1, "count_leading_zeros must have one operand");
1384}
1385
1392inline const count_leading_zeros_exprt &
1394{
1395 PRECONDITION(expr.id() == ID_count_leading_zeros);
1396 const count_leading_zeros_exprt &ret =
1397 static_cast<const count_leading_zeros_exprt &>(expr);
1398 validate_expr(ret);
1399 return ret;
1400}
1401
1404{
1405 PRECONDITION(expr.id() == ID_count_leading_zeros);
1407 static_cast<count_leading_zeros_exprt &>(expr);
1408 validate_expr(ret);
1409 return ret;
1410}
1411
1418{
1419public:
1420 count_trailing_zeros_exprt(exprt _op, bool _zero_permitted, typet _type)
1421 : unary_exprt(ID_count_trailing_zeros, std::move(_op), std::move(_type))
1422 {
1423 zero_permitted(_zero_permitted);
1424 }
1425
1427 : count_trailing_zeros_exprt(_op, true, _op.type())
1428 {
1429 }
1430
1431 bool zero_permitted() const
1432 {
1433 return !get_bool(ID_C_bounds_check);
1434 }
1435
1436 void zero_permitted(bool value)
1437 {
1438 set(ID_C_bounds_check, !value);
1439 }
1440
1441 static void check(
1442 const exprt &expr,
1444 {
1445 DATA_CHECK(
1446 vm,
1447 expr.operands().size() == 1,
1448 "unary expression must have a single operand");
1449 DATA_CHECK(
1450 vm,
1452 "operand must be of bitvector type");
1453 }
1454
1455 static void validate(
1456 const exprt &expr,
1457 const namespacet &,
1459 {
1460 check(expr, vm);
1461 }
1462
1465 exprt lower() const;
1466};
1467
1468template <>
1470{
1471 return base.id() == ID_count_trailing_zeros;
1472}
1473
1475{
1476 validate_operands(value, 1, "count_trailing_zeros must have one operand");
1477}
1478
1485inline const count_trailing_zeros_exprt &
1487{
1488 PRECONDITION(expr.id() == ID_count_trailing_zeros);
1489 const count_trailing_zeros_exprt &ret =
1490 static_cast<const count_trailing_zeros_exprt &>(expr);
1491 validate_expr(ret);
1492 return ret;
1493}
1494
1497{
1498 PRECONDITION(expr.id() == ID_count_trailing_zeros);
1500 static_cast<count_trailing_zeros_exprt &>(expr);
1501 validate_expr(ret);
1502 return ret;
1503}
1504
1507{
1508public:
1510 : unary_exprt(ID_bitreverse, std::move(op))
1511 {
1512 }
1513
1516 exprt lower() const;
1517};
1518
1519template <>
1521{
1522 return base.id() == ID_bitreverse;
1523}
1524
1525inline void validate_expr(const bitreverse_exprt &value)
1526{
1527 validate_operands(value, 1, "Bit-wise reverse must have one operand");
1528}
1529
1537{
1538 PRECONDITION(expr.id() == ID_bitreverse);
1539 const bitreverse_exprt &ret = static_cast<const bitreverse_exprt &>(expr);
1540 validate_expr(ret);
1541 return ret;
1542}
1543
1546{
1547 PRECONDITION(expr.id() == ID_bitreverse);
1548 bitreverse_exprt &ret = static_cast<bitreverse_exprt &>(expr);
1549 validate_expr(ret);
1550 return ret;
1551}
1552
1555{
1556public:
1558 : binary_exprt(std::move(_lhs), ID_saturating_plus, std::move(_rhs))
1559 {
1560 }
1561
1563 : binary_exprt(
1564 std::move(_lhs),
1565 ID_saturating_plus,
1566 std::move(_rhs),
1567 std::move(_type))
1568 {
1569 }
1570};
1571
1572template <>
1574{
1575 return base.id() == ID_saturating_plus;
1576}
1577
1578inline void validate_expr(const saturating_plus_exprt &value)
1579{
1580 validate_operands(value, 2, "saturating plus must have two operands");
1581}
1582
1590{
1591 PRECONDITION(expr.id() == ID_saturating_plus);
1592 const saturating_plus_exprt &ret =
1593 static_cast<const saturating_plus_exprt &>(expr);
1594 validate_expr(ret);
1595 return ret;
1596}
1597
1600{
1601 PRECONDITION(expr.id() == ID_saturating_plus);
1602 saturating_plus_exprt &ret = static_cast<saturating_plus_exprt &>(expr);
1603 validate_expr(ret);
1604 return ret;
1605}
1606
1609{
1610public:
1612 : binary_exprt(std::move(_lhs), ID_saturating_minus, std::move(_rhs))
1613 {
1614 }
1615};
1616
1617template <>
1619{
1620 return base.id() == ID_saturating_minus;
1621}
1622
1623inline void validate_expr(const saturating_minus_exprt &value)
1624{
1625 validate_operands(value, 2, "saturating minus must have two operands");
1626}
1627
1635{
1636 PRECONDITION(expr.id() == ID_saturating_minus);
1637 const saturating_minus_exprt &ret =
1638 static_cast<const saturating_minus_exprt &>(expr);
1639 validate_expr(ret);
1640 return ret;
1641}
1642
1645{
1646 PRECONDITION(expr.id() == ID_saturating_minus);
1647 saturating_minus_exprt &ret = static_cast<saturating_minus_exprt &>(expr);
1648 validate_expr(ret);
1649 return ret;
1650}
1651
1655{
1656public:
1659 make_id(kind),
1661 {{ID_value, _lhs.type()},
1662 {"overflow-" + id2string(kind), bool_typet{}}}},
1663 {_lhs, std::move(_rhs)})
1664 {
1665 INVARIANT(
1666 valid_id(id()),
1667 "The kind used to construct overflow_result_exprt should be in the set "
1668 "of expected valid kinds.");
1669 }
1670
1673 make_id(kind),
1675 {{ID_value, _op.type()},
1676 {"overflow-" + id2string(kind), bool_typet{}}}},
1677 {_op})
1678 {
1679 INVARIANT(
1680 valid_id(id()),
1681 "The kind used to construct overflow_result_exprt should be in the set "
1682 "of expected valid kinds.");
1683 }
1684
1685 // make op0 and op1 public
1686 using exprt::op0;
1687 using exprt::op1;
1688
1689 const exprt &op2() const = delete;
1690 exprt &op2() = delete;
1691 const exprt &op3() const = delete;
1692 exprt &op3() = delete;
1693
1694 static void check(
1695 const exprt &expr,
1697 {
1698 if(expr.id() != ID_overflow_result_unary_minus)
1699 binary_exprt::check(expr, vm);
1700
1701 if(
1702 expr.id() != ID_overflow_result_unary_minus &&
1703 expr.id() != ID_overflow_result_shl)
1704 {
1705 const binary_exprt &binary_expr = to_binary_expr(expr);
1706 DATA_CHECK(
1707 vm,
1708 binary_expr.lhs().type() == binary_expr.rhs().type(),
1709 "operand types must match");
1710 }
1711 }
1712
1713 static void validate(
1714 const exprt &expr,
1715 const namespacet &,
1717 {
1718 check(expr, vm);
1719 }
1720
1722 static bool valid_id(const irep_idt &id)
1723 {
1724 return id == ID_overflow_result_plus || id == ID_overflow_result_mult ||
1725 id == ID_overflow_result_minus || id == ID_overflow_result_shl ||
1726 id == ID_overflow_result_unary_minus;
1727 }
1728
1729private:
1730 static irep_idt make_id(const irep_idt &kind)
1731 {
1732 return "overflow_result-" + id2string(kind);
1733 }
1734};
1735
1736template <>
1738{
1739 return overflow_result_exprt::valid_id(base.id());
1740}
1741
1742inline void validate_expr(const overflow_result_exprt &value)
1743{
1744 if(value.id() == ID_overflow_result_unary_minus)
1745 {
1747 value, 1, "unary overflow expression must have two operands");
1748 }
1749 else
1750 {
1752 value, 2, "binary overflow expression must have two operands");
1753 }
1754}
1755
1763{
1765 const overflow_result_exprt &ret =
1766 static_cast<const overflow_result_exprt &>(expr);
1767 validate_expr(ret);
1768 return ret;
1769}
1770
1773{
1775 overflow_result_exprt &ret = static_cast<overflow_result_exprt &>(expr);
1776 validate_expr(ret);
1777 return ret;
1778}
1779
1783{
1784public:
1786 : unary_exprt(ID_find_first_set, std::move(_op), std::move(_type))
1787 {
1788 }
1789
1790 explicit find_first_set_exprt(const exprt &_op)
1791 : find_first_set_exprt(_op, _op.type())
1792 {
1793 }
1794
1795 static void check(
1796 const exprt &expr,
1798 {
1799 DATA_CHECK(
1800 vm,
1801 expr.operands().size() == 1,
1802 "unary expression must have a single operand");
1803 DATA_CHECK(
1804 vm,
1806 "operand must be of bitvector type");
1807 }
1808
1809 static void validate(
1810 const exprt &expr,
1811 const namespacet &,
1813 {
1814 check(expr, vm);
1815 }
1816
1819 exprt lower() const;
1820};
1821
1822template <>
1824{
1825 return base.id() == ID_find_first_set;
1826}
1827
1828inline void validate_expr(const find_first_set_exprt &value)
1829{
1830 validate_operands(value, 1, "find_first_set must have one operand");
1831}
1832
1840{
1841 PRECONDITION(expr.id() == ID_find_first_set);
1842 const find_first_set_exprt &ret =
1843 static_cast<const find_first_set_exprt &>(expr);
1844 validate_expr(ret);
1845 return ret;
1846}
1847
1850{
1851 PRECONDITION(expr.id() == ID_find_first_set);
1852 find_first_set_exprt &ret = static_cast<find_first_set_exprt &>(expr);
1853 validate_expr(ret);
1854 return ret;
1855}
1856
1863{
1864public:
1866 : unary_exprt(ID_zero_extend, std::move(_op), std::move(_type))
1867 {
1868 }
1869
1870 // a lowering to extraction or concatenation
1871 exprt lower() const;
1872};
1873
1874template <>
1876{
1877 return base.id() == ID_zero_extend;
1878}
1879
1887{
1888 PRECONDITION(expr.id() == ID_zero_extend);
1890 return static_cast<const zero_extend_exprt &>(expr);
1891}
1892
1895{
1896 PRECONDITION(expr.id() == ID_zero_extend);
1898 return static_cast<zero_extend_exprt &>(expr);
1899}
1900
1904{
1905public:
1906 explicit onehot_exprt(exprt _op)
1907 : unary_predicate_exprt(ID_onehot, std::move(_op))
1908 {
1909 }
1910
1912 exprt lower() const;
1913};
1914
1921inline const onehot_exprt &to_onehot_expr(const exprt &expr)
1922{
1923 PRECONDITION(expr.id() == ID_onehot);
1924 onehot_exprt::check(expr);
1925 return static_cast<const onehot_exprt &>(expr);
1926}
1927
1930{
1931 PRECONDITION(expr.id() == ID_onehot);
1932 onehot_exprt::check(expr);
1933 return static_cast<onehot_exprt &>(expr);
1934}
1935
1939{
1940public:
1941 explicit onehot0_exprt(exprt _op)
1942 : unary_predicate_exprt(ID_onehot0, std::move(_op))
1943 {
1944 }
1945
1947 exprt lower() const;
1948};
1949
1956inline const onehot0_exprt &to_onehot0_expr(const exprt &expr)
1957{
1958 PRECONDITION(expr.id() == ID_onehot0);
1960 return static_cast<const onehot0_exprt &>(expr);
1961}
1962
1965{
1966 PRECONDITION(expr.id() == ID_onehot0);
1968 return static_cast<onehot0_exprt &>(expr);
1969}
1970
1971#endif // CPROVER_UTIL_BITVECTOR_EXPR_H
bool can_cast_expr< count_trailing_zeros_exprt >(const exprt &base)
const bitxnor_exprt & to_bitxnor_expr(const exprt &expr)
Cast an exprt to a bitxnor_exprt.
const onehot0_exprt & to_onehot0_expr(const exprt &expr)
Cast an exprt to a onehot0_exprt.
const saturating_minus_exprt & to_saturating_minus_expr(const exprt &expr)
Cast an exprt to a saturating_minus_exprt.
const replication_exprt & to_replication_expr(const exprt &expr)
Cast an exprt to a replication_exprt.
const saturating_plus_exprt & to_saturating_plus_expr(const exprt &expr)
Cast an exprt to a saturating_plus_exprt.
bool can_cast_expr< mult_overflow_exprt >(const exprt &base)
bool can_cast_expr< replication_exprt >(const exprt &base)
bool can_cast_expr< bswap_exprt >(const exprt &base)
const shift_exprt & to_shift_expr(const exprt &expr)
Cast an exprt to a shift_exprt.
const bitnand_exprt & to_bitnand_expr(const exprt &expr)
Cast an exprt to a bitnand_exprt.
bool can_cast_expr< find_first_set_exprt >(const exprt &base)
bool can_cast_expr< saturating_plus_exprt >(const exprt &base)
const shl_exprt & to_shl_expr(const exprt &expr)
Cast an exprt to a shl_exprt.
bool can_cast_expr< bitreverse_exprt >(const exprt &base)
bool can_cast_expr< count_leading_zeros_exprt >(const exprt &base)
const popcount_exprt & to_popcount_expr(const exprt &expr)
Cast an exprt to a popcount_exprt.
const update_bits_exprt & to_update_bits_expr(const exprt &expr)
Cast an exprt to an update_bits_exprt.
bool can_cast_expr< bitnand_exprt >(const exprt &base)
bool can_cast_expr< shift_exprt >(const exprt &base)
bool can_cast_expr< bitand_exprt >(const exprt &base)
bool can_cast_expr< update_bits_exprt >(const exprt &base)
bool can_cast_expr< saturating_minus_exprt >(const exprt &base)
const extractbits_exprt & to_extractbits_expr(const exprt &expr)
Cast an exprt to an extractbits_exprt.
bool can_cast_expr< popcount_exprt >(const exprt &base)
const onehot_exprt & to_onehot_expr(const exprt &expr)
Cast an exprt to a onehot_exprt.
bool can_cast_expr< extractbits_exprt >(const exprt &base)
bool can_cast_expr< bitxor_exprt >(const exprt &base)
const binary_overflow_exprt & to_binary_overflow_expr(const exprt &expr)
Cast an exprt to a binary_overflow_exprt.
bool can_cast_expr< bitor_exprt >(const exprt &base)
bool can_cast_expr< update_bit_exprt >(const exprt &base)
bool can_cast_expr< minus_overflow_exprt >(const exprt &base)
void validate_expr(const bswap_exprt &value)
const find_first_set_exprt & to_find_first_set_expr(const exprt &expr)
Cast an exprt to a find_first_set_exprt.
bool can_cast_expr< ashr_exprt >(const exprt &base)
bool can_cast_expr< zero_extend_exprt >(const exprt &base)
bool can_cast_expr< shl_overflow_exprt >(const exprt &base)
bool can_cast_expr< bitxnor_exprt >(const exprt &base)
const bitor_exprt & to_bitor_expr(const exprt &expr)
Cast an exprt to a bitor_exprt.
const bitand_exprt & to_bitand_expr(const exprt &expr)
Cast an exprt to a bitand_exprt.
bool can_cast_expr< overflow_result_exprt >(const exprt &base)
const update_bit_exprt & to_update_bit_expr(const exprt &expr)
Cast an exprt to an update_bit_exprt.
const bitnot_exprt & to_bitnot_expr(const exprt &expr)
Cast an exprt to a bitnot_exprt.
const unary_overflow_exprt & to_unary_overflow_expr(const exprt &expr)
Cast an exprt to a unary_overflow_exprt.
const bitnor_exprt & to_bitnor_expr(const exprt &expr)
Cast an exprt to a bitnor_exprt.
bool can_cast_expr< concatenation_exprt >(const exprt &base)
bool can_cast_expr< unary_overflow_exprt >(const exprt &base)
const overflow_result_exprt & to_overflow_result_expr(const exprt &expr)
Cast an exprt to a overflow_result_exprt.
bool can_cast_expr< lshr_exprt >(const exprt &base)
bool can_cast_expr< shl_exprt >(const exprt &base)
const bitxor_exprt & to_bitxor_expr(const exprt &expr)
Cast an exprt to a bitxor_exprt.
const bswap_exprt & to_bswap_expr(const exprt &expr)
Cast an exprt to a bswap_exprt.
bool can_cast_expr< plus_overflow_exprt >(const exprt &base)
const count_leading_zeros_exprt & to_count_leading_zeros_expr(const exprt &expr)
Cast an exprt to a count_leading_zeros_exprt.
bool can_cast_expr< bitnot_exprt >(const exprt &base)
bool can_cast_expr< binary_overflow_exprt >(const exprt &base)
const bitreverse_exprt & to_bitreverse_expr(const exprt &expr)
Cast an exprt to a bitreverse_exprt.
const extractbit_exprt & to_extractbit_expr(const exprt &expr)
Cast an exprt to an extractbit_exprt.
bool can_cast_expr< unary_minus_overflow_exprt >(const exprt &base)
bool can_cast_expr< extractbit_exprt >(const exprt &base)
const concatenation_exprt & to_concatenation_expr(const exprt &expr)
Cast an exprt to a concatenation_exprt.
bool can_cast_expr< bitnor_exprt >(const exprt &base)
const zero_extend_exprt & to_zero_extend_expr(const exprt &expr)
Cast an exprt to a zero_extend_exprt.
const count_trailing_zeros_exprt & to_count_trailing_zeros_expr(const exprt &expr)
Cast an exprt to a count_trailing_zeros_exprt.
ashr_exprt(exprt _src, exprt _distance)
ashr_exprt(exprt _src, const std::size_t _distance)
A base class for binary expressions.
Definition std_expr.h:639
exprt & lhs()
Definition std_expr.h:669
binary_exprt(const exprt &_lhs, const irep_idt &_id, exprt _rhs)
Definition std_expr.h:641
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
Definition std_expr.h:651
exprt & rhs()
Definition std_expr.h:679
exprt & op0()
Definition expr.h:134
exprt & op1()
Definition expr.h:137
A Boolean expression returning true, iff operation kind would result in an overflow when applied to o...
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
static void validate(const exprt &expr, const namespacet &, const validation_modet vm=validation_modet::INVARIANT)
static bool valid_id(const irep_idt &id)
Returns true iff id is a valid identifier of a binary_overflow_exprt.
static irep_idt make_id(const irep_idt &kind)
binary_overflow_exprt(exprt _lhs, const irep_idt &kind, exprt _rhs)
binary_predicate_exprt(exprt _op0, const irep_idt &_id, exprt _op1)
Definition std_expr.h:729
Bit-wise AND Any number of operands that is greater or equal one.
bitand_exprt(exprt::operandst _operands, typet _type)
bitand_exprt(exprt::operandst _operands)
bitand_exprt(const exprt &_op0, exprt _op1)
Bit-wise NAND.
bitnand_exprt(exprt::operandst _operands)
bitnand_exprt(exprt _op0, exprt _op1)
bitnand_exprt(exprt::operandst _operands, typet _type)
Bit-wise NOR.
bitnor_exprt(exprt::operandst _operands, typet _type)
bitnor_exprt(exprt::operandst _operands)
bitnor_exprt(exprt _op0, exprt _op1)
Bit-wise negation of bit-vectors.
bitnot_exprt(exprt op)
Bit-wise OR Any number of operands that is greater or equal one.
bitor_exprt(exprt::operandst _operands)
bitor_exprt(exprt::operandst _operands, typet _type)
bitor_exprt(const exprt &_op0, exprt _op1)
Reverse the order of bits in a bit-vector.
bitreverse_exprt(exprt op)
exprt lower() const
Lower a bitreverse_exprt to arithmetic and logic expressions.
Bit-wise XNOR.
bitxnor_exprt(exprt::operandst _operands)
bitxnor_exprt(exprt::operandst _operands, typet _type)
bitxnor_exprt(exprt _op0, exprt _op1)
Bit-wise XOR Any number of operands that is greater or equal one.
bitxor_exprt(exprt::operandst _operands, typet _type)
bitxor_exprt(exprt::operandst _operands)
bitxor_exprt(exprt _op0, exprt _op1)
The Boolean type.
Definition std_types.h:36
The byte swap expression.
bswap_exprt(exprt _op, std::size_t bits_per_byte)
std::size_t get_bits_per_byte() const
bswap_exprt(exprt _op, std::size_t bits_per_byte, typet _type)
void set_bits_per_byte(std::size_t bits_per_byte)
Concatenation of bit-vector operands.
concatenation_exprt(operandst _operands, typet _type)
concatenation_exprt(exprt _op0, exprt _op1, typet _type)
A constant literal expression.
Definition std_expr.h:2997
The count leading zeros (counting the number of zero bits starting from the most-significant bit) exp...
static void validate(const exprt &expr, const namespacet &, const validation_modet vm=validation_modet::INVARIANT)
void zero_permitted(bool value)
exprt lower() const
Lower a count_leading_zeros_exprt to arithmetic and logic expressions.
count_leading_zeros_exprt(const exprt &_op)
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
count_leading_zeros_exprt(exprt _op, bool _zero_permitted, typet _type)
The count trailing zeros (counting the number of zero bits starting from the least-significant bit) e...
count_trailing_zeros_exprt(const exprt &_op)
count_trailing_zeros_exprt(exprt _op, bool _zero_permitted, typet _type)
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
static void validate(const exprt &expr, const namespacet &, const validation_modet vm=validation_modet::INVARIANT)
void zero_permitted(bool value)
exprt lower() const
Lower a count_trailing_zeros_exprt to arithmetic and logic expressions.
expr_protectedt(irep_idt _id, typet _type)
Definition expr.h:353
exprt & op0()
Definition expr.h:134
exprt & op1()
Definition expr.h:137
exprt & op2()
Definition expr.h:140
Base class for all expressions.
Definition expr.h:57
std::vector< exprt > operandst
Definition expr.h:59
exprt()
Definition expr.h:62
exprt & op0()
Definition expr.h:134
exprt & op1()
Definition expr.h:137
typet & type()
Return the type of the expression.
Definition expr.h:85
operandst & operands()
Definition expr.h:95
static void check(const exprt &, const validation_modet=validation_modet::INVARIANT)
Check that the expression is well-formed (shallow checks only, i.e., subexpressions and its type are ...
Definition expr.h:260
Extracts a single bit of a bit-vector operand.
extractbit_exprt(exprt _src, exprt _index)
Extract the _index-th least significant bit from _src.
const exprt & index() const
const exprt & src() const
Extracts a sub-range of a bit-vector operand.
const exprt & index() const
extractbits_exprt(exprt _src, exprt _index, typet _type)
Extract the bits [_index .
const exprt & src() const
Returns one plus the index of the least-significant one bit, or zero if the operand is zero.
find_first_set_exprt(exprt _op, typet _type)
static void validate(const exprt &expr, const namespacet &, const validation_modet vm=validation_modet::INVARIANT)
exprt lower() const
Lower a find_first_set_exprt to arithmetic and logic expressions.
find_first_set_exprt(const exprt &_op)
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
bool get_bool(const irep_idt &name) const
Definition irep.cpp:57
std::size_t get_size_t(const irep_idt &name) const
Definition irep.cpp:67
void set(const irep_idt &name, const irep_idt &value)
Definition irep.h:412
void set_size_t(const irep_idt &name, const std::size_t value)
Definition irep.cpp:82
const irep_idt & id() const
Definition irep.h:388
lshr_exprt(exprt _src, const std::size_t _distance)
lshr_exprt(exprt _src, exprt _distance)
minus_overflow_exprt(exprt _lhs, exprt _rhs)
exprt lower() const
Lower a minus_overflow_exprt to arithmetic and logic expressions.
mult_overflow_exprt(exprt _lhs, exprt _rhs)
exprt lower() const
Lower a mult_overflow_exprt to arithmetic and logic expressions.
multi_ary_exprt(const irep_idt &_id, operandst _operands, typet _type)
Definition std_expr.h:900
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition namespace.h:91
A Boolean expression returning true iff the given operand consists of exactly one '0' and '1' otherwi...
onehot0_exprt(exprt _op)
exprt lower() const
lowering to extractbit
A Boolean expression returning true iff the given operand consists of exactly one '1' and '0' otherwi...
onehot_exprt(exprt _op)
exprt lower() const
lowering to extractbit
An expression returning both the result of the arithmetic operation under wrap-around semantics as we...
exprt & op3()=delete
overflow_result_exprt(exprt _lhs, const irep_idt &kind, exprt _rhs)
overflow_result_exprt(exprt _op, const irep_idt &kind)
static void validate(const exprt &expr, const namespacet &, const validation_modet vm=validation_modet::INVARIANT)
exprt & op2()=delete
static bool valid_id(const irep_idt &id)
Returns true iff id is a valid identifier of an overflow_exprt.
const exprt & op2() const =delete
static irep_idt make_id(const irep_idt &kind)
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
const exprt & op3() const =delete
plus_overflow_exprt(exprt _lhs, exprt _rhs)
exprt lower() const
Lower a plus_overflow_exprt to arithmetic and logic expressions.
The popcount (counting the number of bits set to 1) expression.
exprt lower() const
Lower a popcount_exprt to arithmetic and logic expressions.
popcount_exprt(exprt _op, typet _type)
popcount_exprt(const exprt &_op)
Bit-vector replication.
const exprt & op() const
const constant_exprt & times() const
constant_exprt & times()
replication_exprt(constant_exprt _times, exprt _src, typet _type)
Saturating subtraction expression.
saturating_minus_exprt(exprt _lhs, exprt _rhs)
The saturating plus expression.
saturating_plus_exprt(exprt _lhs, exprt _rhs, typet _type)
saturating_plus_exprt(exprt _lhs, exprt _rhs)
A base class for shift and rotate operators.
exprt & distance()
shift_exprt(exprt _src, const irep_idt &_id, exprt _distance)
const exprt & distance() const
const exprt & op() const
Left shift.
shl_exprt(exprt _src, const std::size_t _distance)
shl_exprt(exprt _src, exprt _distance)
shl_overflow_exprt(exprt _lhs, exprt _rhs)
Structure type, corresponds to C style structs.
Definition std_types.h:231
The type of an expression, extends irept.
Definition type.h:29
unary_exprt(const irep_idt &_id, const exprt &_op)
Definition std_expr.h:356
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
Definition std_expr.h:366
const exprt & op() const
Definition std_expr.h:384
A Boolean expression returning true, iff negation would result in an overflow when applied to the (si...
static void validate(const exprt &expr, const namespacet &, const validation_modet vm=validation_modet::INVARIANT)
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
A Boolean expression returning true, iff operation kind would result in an overflow when applied to t...
static void validate(const exprt &expr, const namespacet &, const validation_modet vm=validation_modet::INVARIANT)
unary_overflow_exprt(const irep_idt &kind, exprt _op)
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
unary_predicate_exprt(const irep_idt &_id, exprt _op)
Definition std_expr.h:566
Replaces a sub-range of a bit-vector operand.
const exprt & src() const
const exprt & index() const
update_bit_exprt(exprt _src, exprt _index, exprt _new_value)
Replaces the bit [_index] from _src to produce a result of the same type as _src.
exprt lower() const
A lowering to masking, shifting, or.
const exprt & new_value() const
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
Replaces a sub-range of a bit-vector operand.
const exprt & index() const
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
update_bits_exprt(exprt _src, exprt _index, exprt _new_value)
Replace the bits [_index .
const exprt & new_value() const
exprt lower() const
A lowering to masking, shifting, or.
const exprt & src() const
update_bits_exprt(exprt _src, const std::size_t _index, exprt _new_value)
zero extension The operand is converted to the given type by either a) truncating if the new type is ...
zero_extend_exprt(exprt _op, typet _type)
void validate_operands(const exprt &value, exprt::operandst::size_type number, const char *message, bool allow_more=false)
Definition expr_cast.h:250
bool can_cast_type(const typet &base)
Check whether a reference to a generic typet is of a specific derived class.
const std::string & id2string(const irep_idt &d)
Definition irep.h:44
STL namespace.
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
Definition invariant.h:534
#define PRECONDITION(CONDITION)
Definition invariant.h:463
#define INVARIANT(CONDITION, REASON)
This macro uses the wrapper function 'invariant_violated_string'.
Definition invariant.h:423
API to expression classes.
const binary_exprt & to_binary_expr(const exprt &expr)
Cast an exprt to a binary_exprt.
Definition std_expr.h:711
const unary_exprt & to_unary_expr(const exprt &expr)
Cast an exprt to a unary_exprt.
Definition std_expr.h:414
#define DATA_CHECK(vm, condition, message)
This macro takes a condition which denotes a well-formedness criterion on goto programs,...
Definition validate.h:22
validation_modet
dstringt irep_idt