CBMC
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 "bitvector_types.h"
16#include "std_expr.h"
17
20{
21public:
23 : unary_exprt(ID_bswap, std::move(_op), std::move(_type))
24 {
26 }
27
33
34 std::size_t get_bits_per_byte() const
35 {
37 }
38
43};
44
45template <>
46inline bool can_cast_expr<bswap_exprt>(const exprt &base)
47{
48 return base.id() == ID_bswap;
49}
50
51inline void validate_expr(const bswap_exprt &value)
52{
53 validate_operands(value, 1, "bswap must have one operand");
55 value.op().type() == value.type(), "bswap type must match operand type");
56}
57
64inline const bswap_exprt &to_bswap_expr(const exprt &expr)
65{
66 PRECONDITION(expr.id() == ID_bswap);
67 const bswap_exprt &ret = static_cast<const bswap_exprt &>(expr);
69 return ret;
70}
71
74{
75 PRECONDITION(expr.id() == ID_bswap);
76 bswap_exprt &ret = static_cast<bswap_exprt &>(expr);
78 return ret;
79}
80
83{
84public:
86 {
87 }
88};
89
90template <>
91inline bool can_cast_expr<bitnot_exprt>(const exprt &base)
92{
93 return base.id() == ID_bitnot;
94}
95
96inline void validate_expr(const bitnot_exprt &value)
97{
98 validate_operands(value, 1, "Bit-wise not must have one operand");
99}
100
107inline const bitnot_exprt &to_bitnot_expr(const exprt &expr)
108{
109 PRECONDITION(expr.id() == ID_bitnot);
110 const bitnot_exprt &ret = static_cast<const bitnot_exprt &>(expr);
112 return ret;
113}
114
117{
118 PRECONDITION(expr.id() == ID_bitnot);
119 bitnot_exprt &ret = static_cast<bitnot_exprt &>(expr);
121 return ret;
122}
123
128{
129public:
132 {
133 }
134
139
141 : multi_ary_exprt(ID_bitor, std::move(_operands), std::move(_type))
142 {
143 }
144};
145
146template <>
147inline bool can_cast_expr<bitor_exprt>(const exprt &base)
148{
149 return base.id() == ID_bitor;
150}
151
158inline const bitor_exprt &to_bitor_expr(const exprt &expr)
159{
160 PRECONDITION(expr.id() == ID_bitor);
161 return static_cast<const bitor_exprt &>(expr);
162}
163
166{
167 PRECONDITION(expr.id() == ID_bitor);
168 return static_cast<bitor_exprt &>(expr);
169}
170
179{
180public:
182 : multi_ary_exprt(std::move(_op0), ID_bitnor, std::move(_op1))
183 {
184 }
185
190
192 : multi_ary_exprt(ID_bitnor, std::move(_operands), std::move(_type))
193 {
194 }
195};
196
197template <>
198inline bool can_cast_expr<bitnor_exprt>(const exprt &base)
199{
200 return base.id() == ID_bitnor;
201}
202
209inline const bitnor_exprt &to_bitnor_expr(const exprt &expr)
210{
211 PRECONDITION(expr.id() == ID_bitnor);
212 return static_cast<const bitnor_exprt &>(expr);
213}
214
217{
218 PRECONDITION(expr.id() == ID_bitnor);
219 return static_cast<bitnor_exprt &>(expr);
220}
221
226{
227public:
229 : multi_ary_exprt(std::move(_op0), ID_bitxor, std::move(_op1))
230 {
231 }
232
237
239 : multi_ary_exprt(ID_bitxor, std::move(_operands), std::move(_type))
240 {
241 }
242};
243
244template <>
245inline bool can_cast_expr<bitxor_exprt>(const exprt &base)
246{
247 return base.id() == ID_bitxor;
248}
249
256inline const bitxor_exprt &to_bitxor_expr(const exprt &expr)
257{
258 PRECONDITION(expr.id() == ID_bitxor);
259 return static_cast<const bitxor_exprt &>(expr);
260}
261
264{
265 PRECONDITION(expr.id() == ID_bitxor);
266 return static_cast<bitxor_exprt &>(expr);
267}
268
277{
278public:
283
288
290 : multi_ary_exprt(ID_bitxnor, std::move(_operands), std::move(_type))
291 {
292 }
293};
294
295template <>
296inline bool can_cast_expr<bitxnor_exprt>(const exprt &base)
297{
298 return base.id() == ID_bitxnor;
299}
300
307inline const bitxnor_exprt &to_bitxnor_expr(const exprt &expr)
308{
309 PRECONDITION(expr.id() == ID_bitxnor);
311 return static_cast<const bitxnor_exprt &>(expr);
312}
313
316{
317 PRECONDITION(expr.id() == ID_bitxnor);
319 return static_cast<bitxnor_exprt &>(expr);
320}
321
326{
327public:
330 {
331 }
332
337
339 : multi_ary_exprt(ID_bitand, std::move(_operands), std::move(_type))
340 {
341 }
342};
343
344template <>
345inline bool can_cast_expr<bitand_exprt>(const exprt &base)
346{
347 return base.id() == ID_bitand;
348}
349
356inline const bitand_exprt &to_bitand_expr(const exprt &expr)
357{
358 PRECONDITION(expr.id() == ID_bitand);
359 return static_cast<const bitand_exprt &>(expr);
360}
361
364{
365 PRECONDITION(expr.id() == ID_bitand);
366 return static_cast<bitand_exprt &>(expr);
367}
368
377{
378public:
383
388
390 : multi_ary_exprt(ID_bitnand, std::move(_operands), std::move(_type))
391 {
392 }
393};
394
395template <>
396inline bool can_cast_expr<bitnand_exprt>(const exprt &base)
397{
398 return base.id() == ID_bitnand;
399}
400
407inline const bitnand_exprt &to_bitnand_expr(const exprt &expr)
408{
409 PRECONDITION(expr.id() == ID_bitnand);
410 return static_cast<const bitnand_exprt &>(expr);
411}
412
415{
416 PRECONDITION(expr.id() == ID_bitnand);
417 return static_cast<bitnand_exprt &>(expr);
418}
419
422{
423public:
425 : binary_exprt(std::move(_src), _id, std::move(_distance))
426 {
427 }
428
429 shift_exprt(exprt _src, const irep_idt &_id, const std::size_t _distance);
430
432 {
433 return op0();
434 }
435
436 const exprt &op() const
437 {
438 return op0();
439 }
440
442 {
443 return op1();
444 }
445
446 const exprt &distance() const
447 {
448 return op1();
449 }
450};
451
452template <>
453inline bool can_cast_expr<shift_exprt>(const exprt &base)
454{
455 return base.id() == ID_shl || base.id() == ID_ashr || base.id() == ID_lshr ||
456 base.id() == ID_ror || base.id() == ID_rol;
457}
458
459inline void validate_expr(const shift_exprt &value)
460{
461 validate_operands(value, 2, "Shifts must have two operands");
462}
463
470inline const shift_exprt &to_shift_expr(const exprt &expr)
471{
472 const shift_exprt &ret = static_cast<const shift_exprt &>(expr);
474 return ret;
475}
476
479{
480 shift_exprt &ret = static_cast<shift_exprt &>(expr);
482 return ret;
483}
484
486class shl_exprt : public shift_exprt
487{
488public:
490 : shift_exprt(std::move(_src), ID_shl, std::move(_distance))
491 {
492 }
493
494 shl_exprt(exprt _src, const std::size_t _distance)
496 {
497 }
498};
499
500template <>
501inline bool can_cast_expr<shl_exprt>(const exprt &base)
502{
503 return base.id() == ID_shl;
504}
505
512inline const shl_exprt &to_shl_expr(const exprt &expr)
513{
514 PRECONDITION(expr.id() == ID_shl);
515 const shl_exprt &ret = static_cast<const shl_exprt &>(expr);
517 return ret;
518}
519
522{
523 PRECONDITION(expr.id() == ID_shl);
524 shl_exprt &ret = static_cast<shl_exprt &>(expr);
526 return ret;
527}
528
531{
532public:
537
538 ashr_exprt(exprt _src, const std::size_t _distance)
540 {
541 }
542};
543
544template <>
545inline bool can_cast_expr<ashr_exprt>(const exprt &base)
546{
547 return base.id() == ID_ashr;
548}
549
552{
553public:
558
559 lshr_exprt(exprt _src, const std::size_t _distance)
560 : shift_exprt(std::move(_src), ID_lshr, std::move(_distance))
561 {
562 }
563};
564
565template <>
566inline bool can_cast_expr<lshr_exprt>(const exprt &base)
567{
568 return base.id() == ID_lshr;
569}
570
573{
574public:
580
581 extractbit_exprt(exprt _src, const std::size_t _index);
582
584 {
585 return op0();
586 }
587
589 {
590 return op1();
591 }
592
593 const exprt &src() const
594 {
595 return op0();
596 }
597
598 const exprt &index() const
599 {
600 return op1();
601 }
602};
603
604template <>
606{
607 return base.id() == ID_extractbit;
608}
609
610inline void validate_expr(const extractbit_exprt &value)
611{
612 validate_operands(value, 2, "Extract bit must have two operands");
613}
614
621inline const extractbit_exprt &to_extractbit_expr(const exprt &expr)
622{
623 PRECONDITION(expr.id() == ID_extractbit);
624 const extractbit_exprt &ret = static_cast<const extractbit_exprt &>(expr);
626 return ret;
627}
628
631{
632 PRECONDITION(expr.id() == ID_extractbit);
633 extractbit_exprt &ret = static_cast<extractbit_exprt &>(expr);
635 return ret;
636}
637
640{
641public:
650 std::move(_type),
651 {std::move(_src), std::move(_index)})
652 {
653 }
654
655 extractbits_exprt(exprt _src, const std::size_t _index, typet _type);
656
658 {
659 return op0();
660 }
661
663 {
664 return op1();
665 }
666
667 const exprt &src() const
668 {
669 return op0();
670 }
671
672 const exprt &index() const
673 {
674 return op1();
675 }
676};
677
678template <>
680{
681 return base.id() == ID_extractbits;
682}
683
684inline void validate_expr(const extractbits_exprt &value)
685{
686 validate_operands(value, 2, "Extractbits must have two operands");
687}
688
696{
697 PRECONDITION(expr.id() == ID_extractbits);
698 const extractbits_exprt &ret = static_cast<const extractbits_exprt &>(expr);
700 return ret;
701}
702
705{
706 PRECONDITION(expr.id() == ID_extractbits);
707 extractbits_exprt &ret = static_cast<extractbits_exprt &>(expr);
709 return ret;
710}
711
714{
715public:
723 _src.type(),
724 {_src, std::move(_index), std::move(_new_value)})
725 {
726 PRECONDITION(new_value().type().id() == ID_bool);
727 }
728
729 update_bit_exprt(exprt _src, const std::size_t _index, exprt _new_value);
730
732 {
733 return op0();
734 }
735
737 {
738 return op1();
739 }
740
742 {
743 return op2();
744 }
745
746 const exprt &src() const
747 {
748 return op0();
749 }
750
751 const exprt &index() const
752 {
753 return op1();
754 }
755
756 const exprt &new_value() const
757 {
758 return op2();
759 }
760
761 static void check(
762 const exprt &expr,
764 {
765 validate_operands(expr, 3, "update_bit must have three operands");
766 }
767
769 exprt lower() const;
770};
771
772template <>
774{
775 return base.id() == ID_update_bit;
776}
777
784inline const update_bit_exprt &to_update_bit_expr(const exprt &expr)
785{
786 PRECONDITION(expr.id() == ID_update_bit);
788 return static_cast<const update_bit_exprt &>(expr);
789}
790
793{
794 PRECONDITION(expr.id() == ID_update_bit);
796 return static_cast<update_bit_exprt &>(expr);
797}
798
801{
802public:
810 _src.type(),
811 {_src, std::move(_index), std::move(_new_value)})
812 {
813 }
814
816
818 {
819 return op0();
820 }
821
823 {
824 return op1();
825 }
826
828 {
829 return op2();
830 }
831
832 const exprt &src() const
833 {
834 return op0();
835 }
836
837 const exprt &index() const
838 {
839 return op1();
840 }
841
842 const exprt &new_value() const
843 {
844 return op2();
845 }
846
847 static void check(
848 const exprt &expr,
850 {
851 validate_operands(expr, 3, "update_bits must have three operands");
852 }
853
855 exprt lower() const;
856};
857
858template <>
860{
861 return base.id() == ID_update_bits;
862}
863
871{
872 PRECONDITION(expr.id() == ID_update_bits);
874 return static_cast<const update_bits_exprt &>(expr);
875}
876
879{
880 PRECONDITION(expr.id() == ID_update_bits);
882 return static_cast<update_bits_exprt &>(expr);
883}
884
887{
888public:
890 : binary_exprt(
891 std::move(_times),
893 std::move(_src),
894 std::move(_type))
895 {
896 }
897
899 {
900 return static_cast<constant_exprt &>(op0());
901 }
902
903 const constant_exprt &times() const
904 {
905 return static_cast<const constant_exprt &>(op0());
906 }
907
909 {
910 return op1();
911 }
912
913 const exprt &op() const
914 {
915 return op1();
916 }
917};
918
919template <>
921{
922 return base.id() == ID_replication;
923}
924
925inline void validate_expr(const replication_exprt &value)
926{
927 validate_operands(value, 2, "Bit-wise replication must have two operands");
928}
929
937{
938 PRECONDITION(expr.id() == ID_replication);
939 const replication_exprt &ret = static_cast<const replication_exprt &>(expr);
941 return ret;
942}
943
946{
947 PRECONDITION(expr.id() == ID_replication);
948 replication_exprt &ret = static_cast<replication_exprt &>(expr);
950 return ret;
951}
952
960{
961public:
966
970 {std::move(_op0), std::move(_op1)},
971 std::move(_type))
972 {
973 }
974};
975
976template <>
978{
979 return base.id() == ID_concatenation;
980}
981
989{
991 return static_cast<const concatenation_exprt &>(expr);
992}
993
996{
998 return static_cast<concatenation_exprt &>(expr);
999}
1000
1003{
1004public:
1006 : unary_exprt(ID_popcount, std::move(_op), std::move(_type))
1007 {
1008 }
1009
1010 explicit popcount_exprt(const exprt &_op)
1012 {
1013 }
1014
1017 exprt lower() const;
1018};
1019
1020template <>
1021inline bool can_cast_expr<popcount_exprt>(const exprt &base)
1022{
1023 return base.id() == ID_popcount;
1024}
1025
1026inline void validate_expr(const popcount_exprt &value)
1027{
1028 validate_operands(value, 1, "popcount must have one operand");
1029}
1030
1037inline const popcount_exprt &to_popcount_expr(const exprt &expr)
1038{
1039 PRECONDITION(expr.id() == ID_popcount);
1040 const popcount_exprt &ret = static_cast<const popcount_exprt &>(expr);
1042 return ret;
1043}
1044
1047{
1048 PRECONDITION(expr.id() == ID_popcount);
1049 popcount_exprt &ret = static_cast<popcount_exprt &>(expr);
1051 return ret;
1052}
1053
1057{
1058public:
1060 : binary_predicate_exprt(std::move(_lhs), make_id(kind), std::move(_rhs))
1061 {
1062 INVARIANT(
1063 valid_id(id()),
1064 "The kind used to construct binary_overflow_exprt should be in the set "
1065 "of expected valid kinds.");
1066 }
1067
1068 static void check(
1069 const exprt &expr,
1071 {
1072 binary_exprt::check(expr, vm);
1073
1074 if(expr.id() != ID_overflow_shl)
1075 {
1077 DATA_CHECK(
1078 vm,
1079 binary_expr.lhs().type() == binary_expr.rhs().type(),
1080 "operand types must match");
1081 }
1082 }
1083
1084 static void validate(
1085 const exprt &expr,
1086 const namespacet &,
1088 {
1089 check(expr, vm);
1090 }
1091
1093 static bool valid_id(const irep_idt &id)
1094 {
1095 return id == ID_overflow_plus || id == ID_overflow_mult ||
1096 id == ID_overflow_minus || id == ID_overflow_shl;
1097 }
1098
1099private:
1100 static irep_idt make_id(const irep_idt &kind)
1101 {
1102 if(valid_id(kind))
1103 return kind;
1104 else
1105 return "overflow-" + id2string(kind);
1106 }
1107};
1108
1109template <>
1111{
1112 return binary_overflow_exprt::valid_id(base.id());
1113}
1114
1115inline void validate_expr(const binary_overflow_exprt &value)
1116{
1118 value, 2, "binary overflow expression must have two operands");
1119}
1120
1128{
1130 expr.id() == ID_overflow_plus || expr.id() == ID_overflow_mult ||
1131 expr.id() == ID_overflow_minus || expr.id() == ID_overflow_shl);
1132 const binary_overflow_exprt &ret =
1133 static_cast<const binary_overflow_exprt &>(expr);
1135 return ret;
1136}
1137
1140{
1142 expr.id() == ID_overflow_plus || expr.id() == ID_overflow_mult ||
1143 expr.id() == ID_overflow_minus || expr.id() == ID_overflow_shl);
1144 binary_overflow_exprt &ret = static_cast<binary_overflow_exprt &>(expr);
1146 return ret;
1147}
1148
1150{
1151public:
1156
1159 exprt lower() const;
1160};
1161
1162template <>
1164{
1165 return base.id() == ID_overflow_plus;
1166}
1167
1169{
1170public:
1175
1178 exprt lower() const;
1179};
1180
1181template <>
1183{
1184 return base.id() == ID_overflow_minus;
1185}
1186
1188{
1189public:
1194
1197 exprt lower() const;
1198};
1199
1200template <>
1202{
1203 return base.id() == ID_overflow_mult;
1204}
1205
1207{
1208public:
1213};
1214
1215template <>
1217{
1218 return base.id() == ID_overflow_shl;
1219}
1220
1224{
1225public:
1227 : unary_predicate_exprt("overflow-" + id2string(kind), std::move(_op))
1228 {
1229 }
1230
1231 static void check(
1232 const exprt &expr,
1234 {
1235 unary_exprt::check(expr, vm);
1236 }
1237
1238 static void validate(
1239 const exprt &expr,
1240 const namespacet &,
1242 {
1243 check(expr, vm);
1244 }
1245};
1246
1247template <>
1249{
1250 return base.id() == ID_overflow_unary_minus;
1251}
1252
1253inline void validate_expr(const unary_overflow_exprt &value)
1254{
1256 value, 1, "unary overflow expression must have one operand");
1257}
1258
1262{
1263public:
1268
1269 static void check(
1270 const exprt &expr,
1272 {
1273 unary_exprt::check(expr, vm);
1274 }
1275
1276 static void validate(
1277 const exprt &expr,
1278 const namespacet &,
1280 {
1281 check(expr, vm);
1282 }
1283};
1284
1285template <>
1287{
1288 return base.id() == ID_overflow_unary_minus;
1289}
1290
1292{
1294 value, 1, "unary minus overflow expression must have one operand");
1295}
1296
1304{
1306 const unary_overflow_exprt &ret =
1307 static_cast<const unary_overflow_exprt &>(expr);
1309 return ret;
1310}
1311
1314{
1316 unary_overflow_exprt &ret = static_cast<unary_overflow_exprt &>(expr);
1318 return ret;
1319}
1320
1327{
1328public:
1334
1337 {
1338 }
1339
1340 bool zero_permitted() const
1341 {
1342 return !get_bool(ID_C_bounds_check);
1343 }
1344
1345 void zero_permitted(bool value)
1346 {
1347 set(ID_C_bounds_check, !value);
1348 }
1349
1350 static void check(
1351 const exprt &expr,
1353 {
1354 DATA_CHECK(
1355 vm,
1356 expr.operands().size() == 1,
1357 "unary expression must have a single operand");
1358 DATA_CHECK(
1359 vm,
1361 "operand must be of bitvector type");
1362 }
1363
1364 static void validate(
1365 const exprt &expr,
1366 const namespacet &,
1368 {
1369 check(expr, vm);
1370 }
1371
1374 exprt lower() const;
1375};
1376
1377template <>
1379{
1380 return base.id() == ID_count_leading_zeros;
1381}
1382
1384{
1385 validate_operands(value, 1, "count_leading_zeros must have one operand");
1386}
1387
1394inline const count_leading_zeros_exprt &
1396{
1399 static_cast<const count_leading_zeros_exprt &>(expr);
1401 return ret;
1402}
1403
1413
1420{
1421public:
1427
1432
1433 bool zero_permitted() const
1434 {
1435 return !get_bool(ID_C_bounds_check);
1436 }
1437
1438 void zero_permitted(bool value)
1439 {
1440 set(ID_C_bounds_check, !value);
1441 }
1442
1443 static void check(
1444 const exprt &expr,
1446 {
1447 DATA_CHECK(
1448 vm,
1449 expr.operands().size() == 1,
1450 "unary expression must have a single operand");
1451 DATA_CHECK(
1452 vm,
1454 "operand must be of bitvector type");
1455 }
1456
1457 static void validate(
1458 const exprt &expr,
1459 const namespacet &,
1461 {
1462 check(expr, vm);
1463 }
1464
1467 exprt lower() const;
1468};
1469
1470template <>
1472{
1473 return base.id() == ID_count_trailing_zeros;
1474}
1475
1477{
1478 validate_operands(value, 1, "count_trailing_zeros must have one operand");
1479}
1480
1487inline const count_trailing_zeros_exprt &
1489{
1492 static_cast<const count_trailing_zeros_exprt &>(expr);
1494 return ret;
1495}
1496
1506
1509{
1510public:
1512 : unary_exprt(ID_bitreverse, std::move(op))
1513 {
1514 }
1515
1518 exprt lower() const;
1519};
1520
1521template <>
1523{
1524 return base.id() == ID_bitreverse;
1525}
1526
1527inline void validate_expr(const bitreverse_exprt &value)
1528{
1529 validate_operands(value, 1, "Bit-wise reverse must have one operand");
1530}
1531
1539{
1540 PRECONDITION(expr.id() == ID_bitreverse);
1541 const bitreverse_exprt &ret = static_cast<const bitreverse_exprt &>(expr);
1543 return ret;
1544}
1545
1548{
1549 PRECONDITION(expr.id() == ID_bitreverse);
1550 bitreverse_exprt &ret = static_cast<bitreverse_exprt &>(expr);
1552 return ret;
1553}
1554
1557{
1558public:
1563
1565 : binary_exprt(
1566 std::move(_lhs),
1568 std::move(_rhs),
1569 std::move(_type))
1570 {
1571 }
1572};
1573
1574template <>
1576{
1577 return base.id() == ID_saturating_plus;
1578}
1579
1580inline void validate_expr(const saturating_plus_exprt &value)
1581{
1582 validate_operands(value, 2, "saturating plus must have two operands");
1583}
1584
1592{
1594 const saturating_plus_exprt &ret =
1595 static_cast<const saturating_plus_exprt &>(expr);
1597 return ret;
1598}
1599
1602{
1604 saturating_plus_exprt &ret = static_cast<saturating_plus_exprt &>(expr);
1606 return ret;
1607}
1608
1611{
1612public:
1617};
1618
1619template <>
1621{
1622 return base.id() == ID_saturating_minus;
1623}
1624
1625inline void validate_expr(const saturating_minus_exprt &value)
1626{
1627 validate_operands(value, 2, "saturating minus must have two operands");
1628}
1629
1637{
1640 static_cast<const saturating_minus_exprt &>(expr);
1642 return ret;
1643}
1644
1647{
1649 saturating_minus_exprt &ret = static_cast<saturating_minus_exprt &>(expr);
1651 return ret;
1652}
1653
1657{
1658public:
1661 make_id(kind),
1663 {{ID_value, _lhs.type()},
1664 {"overflow-" + id2string(kind), bool_typet{}}}},
1665 {_lhs, std::move(_rhs)})
1666 {
1667 INVARIANT(
1668 valid_id(id()),
1669 "The kind used to construct overflow_result_exprt should be in the set "
1670 "of expected valid kinds.");
1671 }
1672
1675 make_id(kind),
1677 {{ID_value, _op.type()},
1678 {"overflow-" + id2string(kind), bool_typet{}}}},
1679 {_op})
1680 {
1681 INVARIANT(
1682 valid_id(id()),
1683 "The kind used to construct overflow_result_exprt should be in the set "
1684 "of expected valid kinds.");
1685 }
1686
1687 // make op0 and op1 public
1688 using exprt::op0;
1689 using exprt::op1;
1690
1691 const exprt &op2() const = delete;
1692 exprt &op2() = delete;
1693 const exprt &op3() const = delete;
1694 exprt &op3() = delete;
1695
1696 static void check(
1697 const exprt &expr,
1699 {
1701 binary_exprt::check(expr, vm);
1702
1703 if(
1705 expr.id() != ID_overflow_result_shl)
1706 {
1708 DATA_CHECK(
1709 vm,
1710 binary_expr.lhs().type() == binary_expr.rhs().type(),
1711 "operand types must match");
1712 }
1713 }
1714
1715 static void validate(
1716 const exprt &expr,
1717 const namespacet &,
1719 {
1720 check(expr, vm);
1721 }
1722
1724 static bool valid_id(const irep_idt &id)
1725 {
1726 return id == ID_overflow_result_plus || id == ID_overflow_result_mult ||
1729 }
1730
1731private:
1732 static irep_idt make_id(const irep_idt &kind)
1733 {
1734 return "overflow_result-" + id2string(kind);
1735 }
1736};
1737
1738template <>
1740{
1741 return overflow_result_exprt::valid_id(base.id());
1742}
1743
1744inline void validate_expr(const overflow_result_exprt &value)
1745{
1746 if(value.id() == ID_overflow_result_unary_minus)
1747 {
1749 value, 1, "unary overflow expression must have two operands");
1750 }
1751 else
1752 {
1754 value, 2, "binary overflow expression must have two operands");
1755 }
1756}
1757
1765{
1767 const overflow_result_exprt &ret =
1768 static_cast<const overflow_result_exprt &>(expr);
1770 return ret;
1771}
1772
1781
1785{
1786public:
1788 : unary_exprt(ID_find_first_set, std::move(_op), std::move(_type))
1789 {
1790 }
1791
1794 {
1795 }
1796
1797 static void check(
1798 const exprt &expr,
1800 {
1801 DATA_CHECK(
1802 vm,
1803 expr.operands().size() == 1,
1804 "unary expression must have a single operand");
1805 DATA_CHECK(
1806 vm,
1808 "operand must be of bitvector type");
1809 }
1810
1811 static void validate(
1812 const exprt &expr,
1813 const namespacet &,
1815 {
1816 check(expr, vm);
1817 }
1818
1821 exprt lower() const;
1822};
1823
1824template <>
1826{
1827 return base.id() == ID_find_first_set;
1828}
1829
1830inline void validate_expr(const find_first_set_exprt &value)
1831{
1832 validate_operands(value, 1, "find_first_set must have one operand");
1833}
1834
1842{
1844 const find_first_set_exprt &ret =
1845 static_cast<const find_first_set_exprt &>(expr);
1847 return ret;
1848}
1849
1852{
1854 find_first_set_exprt &ret = static_cast<find_first_set_exprt &>(expr);
1856 return ret;
1857}
1858
1865{
1866public:
1868 : unary_exprt(ID_zero_extend, std::move(_op), std::move(_type))
1869 {
1870 }
1871
1872 // a lowering to extraction or concatenation
1873 exprt lower() const;
1874};
1875
1876template <>
1878{
1879 return base.id() == ID_zero_extend;
1880}
1881
1889{
1890 PRECONDITION(expr.id() == ID_zero_extend);
1892 return static_cast<const zero_extend_exprt &>(expr);
1893}
1894
1897{
1898 PRECONDITION(expr.id() == ID_zero_extend);
1900 return static_cast<zero_extend_exprt &>(expr);
1901}
1902
1906{
1907public:
1910 {
1911 }
1912
1914 exprt lower() const;
1915};
1916
1923inline const onehot_exprt &to_onehot_expr(const exprt &expr)
1924{
1925 PRECONDITION(expr.id() == ID_onehot);
1926 onehot_exprt::check(expr);
1927 return static_cast<const onehot_exprt &>(expr);
1928}
1929
1932{
1933 PRECONDITION(expr.id() == ID_onehot);
1934 onehot_exprt::check(expr);
1935 return static_cast<onehot_exprt &>(expr);
1936}
1937
1941{
1942public:
1945 {
1946 }
1947
1949 exprt lower() const;
1950};
1951
1958inline const onehot0_exprt &to_onehot0_expr(const exprt &expr)
1959{
1960 PRECONDITION(expr.id() == ID_onehot0);
1962 return static_cast<const onehot0_exprt &>(expr);
1963}
1964
1967{
1968 PRECONDITION(expr.id() == ID_onehot0);
1970 return static_cast<onehot0_exprt &>(expr);
1971}
1972
1975{
1976public:
1981};
1982
1983template <>
1985{
1986 return expr.id() == ID_reduction_and;
1987}
1988
1996{
1997 PRECONDITION(expr.id() == ID_reduction_and);
1999 return static_cast<const reduction_and_exprt &>(expr);
2000}
2001
2004{
2005 PRECONDITION(expr.id() == ID_reduction_and);
2007 return static_cast<reduction_and_exprt &>(expr);
2008}
2009
2012{
2013public:
2018};
2019
2020template <>
2022{
2023 return expr.id() == ID_reduction_or;
2024}
2025
2033{
2034 PRECONDITION(expr.id() == ID_reduction_or);
2036 return static_cast<const reduction_or_exprt &>(expr);
2037}
2038
2041{
2042 PRECONDITION(expr.id() == ID_reduction_or);
2044 return static_cast<reduction_or_exprt &>(expr);
2045}
2046
2049{
2050public:
2055};
2056
2057template <>
2059{
2060 return expr.id() == ID_reduction_nor;
2061}
2062
2070{
2071 PRECONDITION(expr.id() == ID_reduction_nor);
2073 return static_cast<const reduction_nor_exprt &>(expr);
2074}
2075
2078{
2079 PRECONDITION(expr.id() == ID_reduction_nor);
2081 return static_cast<reduction_nor_exprt &>(expr);
2082}
2083
2086{
2087public:
2092};
2093
2094template <>
2096{
2097 return expr.id() == ID_reduction_nand;
2098}
2099
2107{
2110 return static_cast<const reduction_nand_exprt &>(expr);
2111}
2112
2115{
2118 return static_cast<reduction_nand_exprt &>(expr);
2119}
2120
2123{
2124public:
2129};
2130
2131template <>
2133{
2134 return expr.id() == ID_reduction_xor;
2135}
2136
2144{
2145 PRECONDITION(expr.id() == ID_reduction_xor);
2147 return static_cast<const reduction_xor_exprt &>(expr);
2148}
2149
2152{
2153 PRECONDITION(expr.id() == ID_reduction_xor);
2155 return static_cast<reduction_xor_exprt &>(expr);
2156}
2157
2160{
2161public:
2166};
2167
2168template <>
2170{
2171 return expr.id() == ID_reduction_xnor;
2172}
2173
2181{
2184 return static_cast<const reduction_xnor_exprt &>(expr);
2185}
2186
2189{
2192 return static_cast<reduction_xnor_exprt &>(expr);
2193}
2194
2195#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.
const reduction_xnor_exprt & to_reduction_xnor_expr(const exprt &expr)
Cast an exprt to a reduction_xnor_exprt.
const reduction_nand_exprt & to_reduction_nand_expr(const exprt &expr)
Cast an exprt to a reduction_nand_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.
const reduction_and_exprt & to_reduction_and_expr(const exprt &expr)
Cast an exprt to a reduction_and_exprt.
const reduction_or_exprt & to_reduction_or_expr(const exprt &expr)
Cast an exprt to a reduction_or_exprt.
bool can_cast_expr< reduction_xor_exprt >(const exprt &expr)
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)
bool can_cast_expr< reduction_and_exprt >(const exprt &expr)
bool can_cast_expr< reduction_nand_exprt >(const exprt &expr)
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< reduction_nor_exprt >(const exprt &expr)
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)
bool can_cast_expr< reduction_xnor_exprt >(const exprt &expr)
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.
bool can_cast_expr< reduction_or_exprt >(const exprt &expr)
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.
const reduction_xor_exprt & to_reduction_xor_expr(const exprt &expr)
Cast an exprt to a reduction_xor_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 reduction_nor_exprt & to_reduction_nor_expr(const exprt &expr)
Cast an exprt to a reduction_nor_exprt.
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.
Pre-defined bitvector types.
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Definition ai.h:566
Arithmetic right shift.
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:649
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
Definition std_expr.h:661
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)
A base class for expressions that are predicates, i.e., Boolean-typed, and that take exactly two argu...
Definition std_expr.h:737
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:35
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:3007
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.
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition dstring.h:38
Base class for all expressions.
Definition expr.h:350
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 & 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
Logical right shift.
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.
A base class for multi-ary expressions Associativity is not specified.
Definition std_expr.h:908
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)
Boolean reduction: true iff every bit of the operand is 1.
reduction_and_exprt(exprt _op)
Boolean reduction: negation of reduction_and_exprt.
reduction_nand_exprt(exprt _op)
Boolean reduction: negation of reduction_or_exprt.
reduction_nor_exprt(exprt _op)
Boolean reduction: true iff any bit of the operand is 1.
reduction_or_exprt(exprt _op)
Boolean reduction: negation of reduction_xor_exprt.
reduction_xnor_exprt(exprt _op)
Boolean reduction: XOR (parity) of all bits in the operand.
reduction_xor_exprt(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:230
The type of an expression, extends irept.
Definition type.h:29
Generic base class for unary expressions.
Definition std_expr.h:364
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
Definition std_expr.h:376
const exprt & op() const
Definition std_expr.h:394
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)
A base class for expressions that are predicates, i.e., Boolean-typed, and that take exactly one argu...
Definition std_expr.h:574
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
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:721
const unary_exprt & to_unary_expr(const exprt &expr)
Cast an exprt to a unary_exprt.
Definition std_expr.h:424
#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