CBMC
bitvector_expr.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: API to expression classes for bitvectors
4 
5 Author: 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 
18 class bswap_exprt : public unary_exprt
19 {
20 public:
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 
44 template <>
45 inline bool can_cast_expr<bswap_exprt>(const exprt &base)
46 {
47  return base.id() == ID_bswap;
48 }
49 
50 inline 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 
63 inline 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 
81 class bitnot_exprt : public unary_exprt
82 {
83 public:
84  explicit bitnot_exprt(exprt op) : unary_exprt(ID_bitnot, std::move(op))
85  {
86  }
87 };
88 
89 template <>
90 inline bool can_cast_expr<bitnot_exprt>(const exprt &base)
91 {
92  return base.id() == ID_bitnot;
93 }
94 
95 inline void validate_expr(const bitnot_exprt &value)
96 {
97  validate_operands(value, 1, "Bit-wise not must have one operand");
98 }
99 
106 inline 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 
125 {
126 public:
127  bitor_exprt(const exprt &_op0, exprt _op1)
128  : multi_ary_exprt(_op0, ID_bitor, std::move(_op1), _op0.type())
129  {
130  }
131 };
132 
133 template <>
134 inline bool can_cast_expr<bitor_exprt>(const exprt &base)
135 {
136  return base.id() == ID_bitor;
137 }
138 
145 inline const bitor_exprt &to_bitor_expr(const exprt &expr)
146 {
147  PRECONDITION(expr.id() == ID_bitor);
148  return static_cast<const bitor_exprt &>(expr);
149 }
150 
153 {
154  PRECONDITION(expr.id() == ID_bitor);
155  return static_cast<bitor_exprt &>(expr);
156 }
157 
160 {
161 public:
163  : multi_ary_exprt(std::move(_op0), ID_bitxor, std::move(_op1))
164  {
165  }
166 };
167 
168 template <>
169 inline bool can_cast_expr<bitxor_exprt>(const exprt &base)
170 {
171  return base.id() == ID_bitxor;
172 }
173 
180 inline const bitxor_exprt &to_bitxor_expr(const exprt &expr)
181 {
182  PRECONDITION(expr.id() == ID_bitxor);
183  return static_cast<const bitxor_exprt &>(expr);
184 }
185 
188 {
189  PRECONDITION(expr.id() == ID_bitxor);
190  return static_cast<bitxor_exprt &>(expr);
191 }
192 
195 {
196 public:
197  bitand_exprt(const exprt &_op0, exprt _op1)
198  : multi_ary_exprt(_op0, ID_bitand, std::move(_op1), _op0.type())
199  {
200  }
201 };
202 
203 template <>
204 inline bool can_cast_expr<bitand_exprt>(const exprt &base)
205 {
206  return base.id() == ID_bitand;
207 }
208 
215 inline const bitand_exprt &to_bitand_expr(const exprt &expr)
216 {
217  PRECONDITION(expr.id() == ID_bitand);
218  return static_cast<const bitand_exprt &>(expr);
219 }
220 
223 {
224  PRECONDITION(expr.id() == ID_bitand);
225  return static_cast<bitand_exprt &>(expr);
226 }
227 
229 class shift_exprt : public binary_exprt
230 {
231 public:
232  shift_exprt(exprt _src, const irep_idt &_id, exprt _distance)
233  : binary_exprt(std::move(_src), _id, std::move(_distance))
234  {
235  }
236 
237  shift_exprt(exprt _src, const irep_idt &_id, const std::size_t _distance);
238 
240  {
241  return op0();
242  }
243 
244  const exprt &op() const
245  {
246  return op0();
247  }
248 
250  {
251  return op1();
252  }
253 
254  const exprt &distance() const
255  {
256  return op1();
257  }
258 };
259 
260 template <>
261 inline bool can_cast_expr<shift_exprt>(const exprt &base)
262 {
263  return base.id() == ID_shl || base.id() == ID_ashr || base.id() == ID_lshr ||
264  base.id() == ID_ror || base.id() == ID_rol;
265 }
266 
267 inline void validate_expr(const shift_exprt &value)
268 {
269  validate_operands(value, 2, "Shifts must have two operands");
270 }
271 
278 inline const shift_exprt &to_shift_expr(const exprt &expr)
279 {
280  const shift_exprt &ret = static_cast<const shift_exprt &>(expr);
281  validate_expr(ret);
282  return ret;
283 }
284 
287 {
288  shift_exprt &ret = static_cast<shift_exprt &>(expr);
289  validate_expr(ret);
290  return ret;
291 }
292 
294 class shl_exprt : public shift_exprt
295 {
296 public:
297  shl_exprt(exprt _src, exprt _distance)
298  : shift_exprt(std::move(_src), ID_shl, std::move(_distance))
299  {
300  }
301 
302  shl_exprt(exprt _src, const std::size_t _distance)
303  : shift_exprt(std::move(_src), ID_shl, _distance)
304  {
305  }
306 };
307 
308 template <>
309 inline bool can_cast_expr<shl_exprt>(const exprt &base)
310 {
311  return base.id() == ID_shl;
312 }
313 
320 inline const shl_exprt &to_shl_expr(const exprt &expr)
321 {
322  PRECONDITION(expr.id() == ID_shl);
323  const shl_exprt &ret = static_cast<const shl_exprt &>(expr);
324  validate_expr(ret);
325  return ret;
326 }
327 
330 {
331  PRECONDITION(expr.id() == ID_shl);
332  shl_exprt &ret = static_cast<shl_exprt &>(expr);
333  validate_expr(ret);
334  return ret;
335 }
336 
338 class ashr_exprt : public shift_exprt
339 {
340 public:
341  ashr_exprt(exprt _src, exprt _distance)
342  : shift_exprt(std::move(_src), ID_ashr, std::move(_distance))
343  {
344  }
345 
346  ashr_exprt(exprt _src, const std::size_t _distance)
347  : shift_exprt(std::move(_src), ID_ashr, _distance)
348  {
349  }
350 };
351 
352 template <>
353 inline bool can_cast_expr<ashr_exprt>(const exprt &base)
354 {
355  return base.id() == ID_ashr;
356 }
357 
359 class lshr_exprt : public shift_exprt
360 {
361 public:
362  lshr_exprt(exprt _src, exprt _distance)
363  : shift_exprt(std::move(_src), ID_lshr, std::move(_distance))
364  {
365  }
366 
367  lshr_exprt(exprt _src, const std::size_t _distance)
368  : shift_exprt(std::move(_src), ID_lshr, std::move(_distance))
369  {
370  }
371 };
372 
373 template <>
374 inline bool can_cast_expr<lshr_exprt>(const exprt &base)
375 {
376  return base.id() == ID_lshr;
377 }
378 
381 {
382 public:
385  : binary_predicate_exprt(std::move(_src), ID_extractbit, std::move(_index))
386  {
387  }
388 
389  extractbit_exprt(exprt _src, const std::size_t _index);
390 
392  {
393  return op0();
394  }
395 
397  {
398  return op1();
399  }
400 
401  const exprt &src() const
402  {
403  return op0();
404  }
405 
406  const exprt &index() const
407  {
408  return op1();
409  }
410 };
411 
412 template <>
413 inline bool can_cast_expr<extractbit_exprt>(const exprt &base)
414 {
415  return base.id() == ID_extractbit;
416 }
417 
418 inline void validate_expr(const extractbit_exprt &value)
419 {
420  validate_operands(value, 2, "Extract bit must have two operands");
421 }
422 
429 inline const extractbit_exprt &to_extractbit_expr(const exprt &expr)
430 {
431  PRECONDITION(expr.id() == ID_extractbit);
432  const extractbit_exprt &ret = static_cast<const extractbit_exprt &>(expr);
433  validate_expr(ret);
434  return ret;
435 }
436 
439 {
440  PRECONDITION(expr.id() == ID_extractbit);
441  extractbit_exprt &ret = static_cast<extractbit_exprt &>(expr);
442  validate_expr(ret);
443  return ret;
444 }
445 
448 {
449 public:
455  extractbits_exprt(exprt _src, exprt _upper, exprt _lower, typet _type)
456  : expr_protectedt(
457  ID_extractbits,
458  std::move(_type),
459  {std::move(_src), std::move(_upper), std::move(_lower)})
460  {
461  }
462 
464  exprt _src,
465  const std::size_t _upper,
466  const std::size_t _lower,
467  typet _type);
468 
470  {
471  return op0();
472  }
473 
475  {
476  return op1();
477  }
478 
480  {
481  return op2();
482  }
483 
484  const exprt &src() const
485  {
486  return op0();
487  }
488 
489  const exprt &upper() const
490  {
491  return op1();
492  }
493 
494  const exprt &lower() const
495  {
496  return op2();
497  }
498 };
499 
500 template <>
501 inline bool can_cast_expr<extractbits_exprt>(const exprt &base)
502 {
503  return base.id() == ID_extractbits;
504 }
505 
506 inline void validate_expr(const extractbits_exprt &value)
507 {
508  validate_operands(value, 3, "Extract bits must have three operands");
509 }
510 
517 inline const extractbits_exprt &to_extractbits_expr(const exprt &expr)
518 {
519  PRECONDITION(expr.id() == ID_extractbits);
520  const extractbits_exprt &ret = static_cast<const extractbits_exprt &>(expr);
521  validate_expr(ret);
522  return ret;
523 }
524 
527 {
528  PRECONDITION(expr.id() == ID_extractbits);
529  extractbits_exprt &ret = static_cast<extractbits_exprt &>(expr);
530  validate_expr(ret);
531  return ret;
532 }
533 
536 {
537 public:
539  : binary_exprt(
540  std::move(_times),
541  ID_replication,
542  std::move(_src),
543  std::move(_type))
544  {
545  }
546 
548  {
549  return static_cast<constant_exprt &>(op0());
550  }
551 
552  const constant_exprt &times() const
553  {
554  return static_cast<const constant_exprt &>(op0());
555  }
556 
558  {
559  return op1();
560  }
561 
562  const exprt &op() const
563  {
564  return op1();
565  }
566 };
567 
568 template <>
569 inline bool can_cast_expr<replication_exprt>(const exprt &base)
570 {
571  return base.id() == ID_replication;
572 }
573 
574 inline void validate_expr(const replication_exprt &value)
575 {
576  validate_operands(value, 2, "Bit-wise replication must have two operands");
577 }
578 
585 inline const replication_exprt &to_replication_expr(const exprt &expr)
586 {
587  PRECONDITION(expr.id() == ID_replication);
588  const replication_exprt &ret = static_cast<const replication_exprt &>(expr);
589  validate_expr(ret);
590  return ret;
591 }
592 
595 {
596  PRECONDITION(expr.id() == ID_replication);
597  replication_exprt &ret = static_cast<replication_exprt &>(expr);
598  validate_expr(ret);
599  return ret;
600 }
601 
608 {
609 public:
611  : multi_ary_exprt(ID_concatenation, std::move(_operands), std::move(_type))
612  {
613  }
614 
616  : multi_ary_exprt(
617  ID_concatenation,
618  {std::move(_op0), std::move(_op1)},
619  std::move(_type))
620  {
621  }
622 };
623 
624 template <>
626 {
627  return base.id() == ID_concatenation;
628 }
629 
637 {
638  PRECONDITION(expr.id() == ID_concatenation);
639  return static_cast<const concatenation_exprt &>(expr);
640 }
641 
644 {
645  PRECONDITION(expr.id() == ID_concatenation);
646  return static_cast<concatenation_exprt &>(expr);
647 }
648 
651 {
652 public:
654  : unary_exprt(ID_popcount, std::move(_op), std::move(_type))
655  {
656  }
657 
658  explicit popcount_exprt(const exprt &_op)
659  : unary_exprt(ID_popcount, _op, _op.type())
660  {
661  }
662 
665  exprt lower() const;
666 };
667 
668 template <>
669 inline bool can_cast_expr<popcount_exprt>(const exprt &base)
670 {
671  return base.id() == ID_popcount;
672 }
673 
674 inline void validate_expr(const popcount_exprt &value)
675 {
676  validate_operands(value, 1, "popcount must have one operand");
677 }
678 
685 inline const popcount_exprt &to_popcount_expr(const exprt &expr)
686 {
687  PRECONDITION(expr.id() == ID_popcount);
688  const popcount_exprt &ret = static_cast<const popcount_exprt &>(expr);
689  validate_expr(ret);
690  return ret;
691 }
692 
695 {
696  PRECONDITION(expr.id() == ID_popcount);
697  popcount_exprt &ret = static_cast<popcount_exprt &>(expr);
698  validate_expr(ret);
699  return ret;
700 }
701 
705 {
706 public:
707  binary_overflow_exprt(exprt _lhs, const irep_idt &kind, exprt _rhs)
708  : binary_predicate_exprt(std::move(_lhs), make_id(kind), std::move(_rhs))
709  {
710  INVARIANT(
711  valid_id(id()),
712  "The kind used to construct binary_overflow_exprt should be in the set "
713  "of expected valid kinds.");
714  }
715 
716  static void check(
717  const exprt &expr,
719  {
720  binary_exprt::check(expr, vm);
721 
722  if(expr.id() != ID_overflow_shl)
723  {
724  const binary_exprt &binary_expr = to_binary_expr(expr);
725  DATA_CHECK(
726  vm,
727  binary_expr.lhs().type() == binary_expr.rhs().type(),
728  "operand types must match");
729  }
730  }
731 
732  static void validate(
733  const exprt &expr,
734  const namespacet &,
736  {
737  check(expr, vm);
738  }
739 
741  static bool valid_id(const irep_idt &id)
742  {
743  return id == ID_overflow_plus || id == ID_overflow_mult ||
744  id == ID_overflow_minus || id == ID_overflow_shl;
745  }
746 
747 private:
748  static irep_idt make_id(const irep_idt &kind)
749  {
750  if(valid_id(kind))
751  return kind;
752  else
753  return "overflow-" + id2string(kind);
754  }
755 };
756 
757 template <>
759 {
760  return binary_overflow_exprt::valid_id(base.id());
761 }
762 
763 inline void validate_expr(const binary_overflow_exprt &value)
764 {
766  value, 2, "binary overflow expression must have two operands");
767 }
768 
776 {
777  PRECONDITION(
778  expr.id() == ID_overflow_plus || expr.id() == ID_overflow_mult ||
779  expr.id() == ID_overflow_minus || expr.id() == ID_overflow_shl);
780  const binary_overflow_exprt &ret =
781  static_cast<const binary_overflow_exprt &>(expr);
782  validate_expr(ret);
783  return ret;
784 }
785 
788 {
789  PRECONDITION(
790  expr.id() == ID_overflow_plus || expr.id() == ID_overflow_mult ||
791  expr.id() == ID_overflow_minus || expr.id() == ID_overflow_shl);
792  binary_overflow_exprt &ret = static_cast<binary_overflow_exprt &>(expr);
793  validate_expr(ret);
794  return ret;
795 }
796 
798 {
799 public:
801  : binary_overflow_exprt(std::move(_lhs), ID_overflow_plus, std::move(_rhs))
802  {
803  }
804 
807  exprt lower() const;
808 };
809 
810 template <>
812 {
813  return base.id() == ID_overflow_plus;
814 }
815 
817 {
818 public:
820  : binary_overflow_exprt(std::move(_lhs), ID_overflow_minus, std::move(_rhs))
821  {
822  }
823 
826  exprt lower() const;
827 };
828 
829 template <>
831 {
832  return base.id() == ID_overflow_minus;
833 }
834 
836 {
837 public:
839  : binary_overflow_exprt(std::move(_lhs), ID_overflow_mult, std::move(_rhs))
840  {
841  }
842 
845  exprt lower() const;
846 };
847 
848 template <>
850 {
851  return base.id() == ID_overflow_mult;
852 }
853 
855 {
856 public:
858  : binary_overflow_exprt(std::move(_lhs), ID_overflow_shl, std::move(_rhs))
859  {
860  }
861 };
862 
863 template <>
864 inline bool can_cast_expr<shl_overflow_exprt>(const exprt &base)
865 {
866  return base.id() == ID_overflow_shl;
867 }
868 
872 {
873 public:
875  : unary_predicate_exprt("overflow-" + id2string(kind), std::move(_op))
876  {
877  }
878 
879  static void check(
880  const exprt &expr,
882  {
883  unary_exprt::check(expr, vm);
884  }
885 
886  static void validate(
887  const exprt &expr,
888  const namespacet &,
890  {
891  check(expr, vm);
892  }
893 };
894 
895 template <>
897 {
898  return base.id() == ID_overflow_unary_minus;
899 }
900 
901 inline void validate_expr(const unary_overflow_exprt &value)
902 {
904  value, 1, "unary overflow expression must have one operand");
905 }
906 
910 {
911 public:
913  : unary_overflow_exprt(ID_unary_minus, std::move(_op))
914  {
915  }
916 
917  static void check(
918  const exprt &expr,
920  {
921  unary_exprt::check(expr, vm);
922  }
923 
924  static void validate(
925  const exprt &expr,
926  const namespacet &,
928  {
929  check(expr, vm);
930  }
931 };
932 
933 template <>
935 {
936  return base.id() == ID_overflow_unary_minus;
937 }
938 
939 inline void validate_expr(const unary_minus_overflow_exprt &value)
940 {
942  value, 1, "unary minus overflow expression must have one operand");
943 }
944 
952 {
953  PRECONDITION(expr.id() == ID_overflow_unary_minus);
954  const unary_overflow_exprt &ret =
955  static_cast<const unary_overflow_exprt &>(expr);
956  validate_expr(ret);
957  return ret;
958 }
959 
962 {
963  PRECONDITION(expr.id() == ID_overflow_unary_minus);
964  unary_overflow_exprt &ret = static_cast<unary_overflow_exprt &>(expr);
965  validate_expr(ret);
966  return ret;
967 }
968 
975 {
976 public:
977  count_leading_zeros_exprt(exprt _op, bool _zero_permitted, typet _type)
978  : unary_exprt(ID_count_leading_zeros, std::move(_op), std::move(_type))
979  {
980  zero_permitted(_zero_permitted);
981  }
982 
983  explicit count_leading_zeros_exprt(const exprt &_op)
984  : count_leading_zeros_exprt(_op, true, _op.type())
985  {
986  }
987 
988  bool zero_permitted() const
989  {
990  return !get_bool(ID_C_bounds_check);
991  }
992 
993  void zero_permitted(bool value)
994  {
995  set(ID_C_bounds_check, !value);
996  }
997 
998  static void check(
999  const exprt &expr,
1001  {
1002  DATA_CHECK(
1003  vm,
1004  expr.operands().size() == 1,
1005  "unary expression must have a single operand");
1006  DATA_CHECK(
1007  vm,
1009  "operand must be of bitvector type");
1010  }
1011 
1012  static void validate(
1013  const exprt &expr,
1014  const namespacet &,
1016  {
1017  check(expr, vm);
1018  }
1019 
1022  exprt lower() const;
1023 };
1024 
1025 template <>
1027 {
1028  return base.id() == ID_count_leading_zeros;
1029 }
1030 
1031 inline void validate_expr(const count_leading_zeros_exprt &value)
1032 {
1033  validate_operands(value, 1, "count_leading_zeros must have one operand");
1034 }
1035 
1042 inline const count_leading_zeros_exprt &
1044 {
1045  PRECONDITION(expr.id() == ID_count_leading_zeros);
1046  const count_leading_zeros_exprt &ret =
1047  static_cast<const count_leading_zeros_exprt &>(expr);
1048  validate_expr(ret);
1049  return ret;
1050 }
1051 
1054 {
1055  PRECONDITION(expr.id() == ID_count_leading_zeros);
1057  static_cast<count_leading_zeros_exprt &>(expr);
1058  validate_expr(ret);
1059  return ret;
1060 }
1061 
1068 {
1069 public:
1070  count_trailing_zeros_exprt(exprt _op, bool _zero_permitted, typet _type)
1071  : unary_exprt(ID_count_trailing_zeros, std::move(_op), std::move(_type))
1072  {
1073  zero_permitted(_zero_permitted);
1074  }
1075 
1076  explicit count_trailing_zeros_exprt(const exprt &_op)
1077  : count_trailing_zeros_exprt(_op, true, _op.type())
1078  {
1079  }
1080 
1081  bool zero_permitted() const
1082  {
1083  return !get_bool(ID_C_bounds_check);
1084  }
1085 
1086  void zero_permitted(bool value)
1087  {
1088  set(ID_C_bounds_check, !value);
1089  }
1090 
1091  static void check(
1092  const exprt &expr,
1094  {
1095  DATA_CHECK(
1096  vm,
1097  expr.operands().size() == 1,
1098  "unary expression must have a single operand");
1099  DATA_CHECK(
1100  vm,
1102  "operand must be of bitvector type");
1103  }
1104 
1105  static void validate(
1106  const exprt &expr,
1107  const namespacet &,
1109  {
1110  check(expr, vm);
1111  }
1112 
1115  exprt lower() const;
1116 };
1117 
1118 template <>
1120 {
1121  return base.id() == ID_count_trailing_zeros;
1122 }
1123 
1125 {
1126  validate_operands(value, 1, "count_trailing_zeros must have one operand");
1127 }
1128 
1135 inline const count_trailing_zeros_exprt &
1137 {
1138  PRECONDITION(expr.id() == ID_count_trailing_zeros);
1139  const count_trailing_zeros_exprt &ret =
1140  static_cast<const count_trailing_zeros_exprt &>(expr);
1141  validate_expr(ret);
1142  return ret;
1143 }
1144 
1147 {
1148  PRECONDITION(expr.id() == ID_count_trailing_zeros);
1150  static_cast<count_trailing_zeros_exprt &>(expr);
1151  validate_expr(ret);
1152  return ret;
1153 }
1154 
1157 {
1158 public:
1160  : unary_exprt(ID_bitreverse, std::move(op))
1161  {
1162  }
1163 
1166  exprt lower() const;
1167 };
1168 
1169 template <>
1170 inline bool can_cast_expr<bitreverse_exprt>(const exprt &base)
1171 {
1172  return base.id() == ID_bitreverse;
1173 }
1174 
1175 inline void validate_expr(const bitreverse_exprt &value)
1176 {
1177  validate_operands(value, 1, "Bit-wise reverse must have one operand");
1178 }
1179 
1186 inline const bitreverse_exprt &to_bitreverse_expr(const exprt &expr)
1187 {
1188  PRECONDITION(expr.id() == ID_bitreverse);
1189  const bitreverse_exprt &ret = static_cast<const bitreverse_exprt &>(expr);
1190  validate_expr(ret);
1191  return ret;
1192 }
1193 
1196 {
1197  PRECONDITION(expr.id() == ID_bitreverse);
1198  bitreverse_exprt &ret = static_cast<bitreverse_exprt &>(expr);
1199  validate_expr(ret);
1200  return ret;
1201 }
1202 
1205 {
1206 public:
1208  : binary_exprt(std::move(_lhs), ID_saturating_plus, std::move(_rhs))
1209  {
1210  }
1211 
1213  : binary_exprt(
1214  std::move(_lhs),
1215  ID_saturating_plus,
1216  std::move(_rhs),
1217  std::move(_type))
1218  {
1219  }
1220 };
1221 
1222 template <>
1224 {
1225  return base.id() == ID_saturating_plus;
1226 }
1227 
1228 inline void validate_expr(const saturating_plus_exprt &value)
1229 {
1230  validate_operands(value, 2, "saturating plus must have two operands");
1231 }
1232 
1240 {
1241  PRECONDITION(expr.id() == ID_saturating_plus);
1242  const saturating_plus_exprt &ret =
1243  static_cast<const saturating_plus_exprt &>(expr);
1244  validate_expr(ret);
1245  return ret;
1246 }
1247 
1250 {
1251  PRECONDITION(expr.id() == ID_saturating_plus);
1252  saturating_plus_exprt &ret = static_cast<saturating_plus_exprt &>(expr);
1253  validate_expr(ret);
1254  return ret;
1255 }
1256 
1259 {
1260 public:
1262  : binary_exprt(std::move(_lhs), ID_saturating_minus, std::move(_rhs))
1263  {
1264  }
1265 };
1266 
1267 template <>
1269 {
1270  return base.id() == ID_saturating_minus;
1271 }
1272 
1273 inline void validate_expr(const saturating_minus_exprt &value)
1274 {
1275  validate_operands(value, 2, "saturating minus must have two operands");
1276 }
1277 
1285 {
1286  PRECONDITION(expr.id() == ID_saturating_minus);
1287  const saturating_minus_exprt &ret =
1288  static_cast<const saturating_minus_exprt &>(expr);
1289  validate_expr(ret);
1290  return ret;
1291 }
1292 
1295 {
1296  PRECONDITION(expr.id() == ID_saturating_minus);
1297  saturating_minus_exprt &ret = static_cast<saturating_minus_exprt &>(expr);
1298  validate_expr(ret);
1299  return ret;
1300 }
1301 
1305 {
1306 public:
1307  overflow_result_exprt(exprt _lhs, const irep_idt &kind, exprt _rhs)
1308  : expr_protectedt(
1309  make_id(kind),
1310  struct_typet{
1311  {{ID_value, _lhs.type()},
1312  {"overflow-" + id2string(kind), bool_typet{}}}},
1313  {_lhs, std::move(_rhs)})
1314  {
1315  INVARIANT(
1316  valid_id(id()),
1317  "The kind used to construct overflow_result_exprt should be in the set "
1318  "of expected valid kinds.");
1319  }
1320 
1322  : expr_protectedt(
1323  make_id(kind),
1324  struct_typet{
1325  {{ID_value, _op.type()},
1326  {"overflow-" + id2string(kind), bool_typet{}}}},
1327  {_op})
1328  {
1329  INVARIANT(
1330  valid_id(id()),
1331  "The kind used to construct overflow_result_exprt should be in the set "
1332  "of expected valid kinds.");
1333  }
1334 
1335  // make op0 and op1 public
1336  using exprt::op0;
1337  using exprt::op1;
1338 
1339  const exprt &op2() const = delete;
1340  exprt &op2() = delete;
1341  const exprt &op3() const = delete;
1342  exprt &op3() = delete;
1343 
1344  static void check(
1345  const exprt &expr,
1347  {
1348  if(expr.id() != ID_overflow_result_unary_minus)
1349  binary_exprt::check(expr, vm);
1350 
1351  if(
1352  expr.id() != ID_overflow_result_unary_minus &&
1353  expr.id() != ID_overflow_result_shl)
1354  {
1355  const binary_exprt &binary_expr = to_binary_expr(expr);
1356  DATA_CHECK(
1357  vm,
1358  binary_expr.lhs().type() == binary_expr.rhs().type(),
1359  "operand types must match");
1360  }
1361  }
1362 
1363  static void validate(
1364  const exprt &expr,
1365  const namespacet &,
1367  {
1368  check(expr, vm);
1369  }
1370 
1372  static bool valid_id(const irep_idt &id)
1373  {
1374  return id == ID_overflow_result_plus || id == ID_overflow_result_mult ||
1375  id == ID_overflow_result_minus || id == ID_overflow_result_shl ||
1376  id == ID_overflow_result_unary_minus;
1377  }
1378 
1379 private:
1380  static irep_idt make_id(const irep_idt &kind)
1381  {
1382  return "overflow_result-" + id2string(kind);
1383  }
1384 };
1385 
1386 template <>
1388 {
1389  return overflow_result_exprt::valid_id(base.id());
1390 }
1391 
1392 inline void validate_expr(const overflow_result_exprt &value)
1393 {
1394  if(value.id() == ID_overflow_result_unary_minus)
1395  {
1397  value, 1, "unary overflow expression must have two operands");
1398  }
1399  else
1400  {
1402  value, 2, "binary overflow expression must have two operands");
1403  }
1404 }
1405 
1413 {
1415  const overflow_result_exprt &ret =
1416  static_cast<const overflow_result_exprt &>(expr);
1417  validate_expr(ret);
1418  return ret;
1419 }
1420 
1423 {
1425  overflow_result_exprt &ret = static_cast<overflow_result_exprt &>(expr);
1426  validate_expr(ret);
1427  return ret;
1428 }
1429 
1433 {
1434 public:
1436  : unary_exprt(ID_find_first_set, std::move(_op), std::move(_type))
1437  {
1438  }
1439 
1440  explicit find_first_set_exprt(const exprt &_op)
1441  : find_first_set_exprt(_op, _op.type())
1442  {
1443  }
1444 
1445  static void check(
1446  const exprt &expr,
1448  {
1449  DATA_CHECK(
1450  vm,
1451  expr.operands().size() == 1,
1452  "unary expression must have a single operand");
1453  DATA_CHECK(
1454  vm,
1456  "operand must be of bitvector type");
1457  }
1458 
1459  static void validate(
1460  const exprt &expr,
1461  const namespacet &,
1463  {
1464  check(expr, vm);
1465  }
1466 
1469  exprt lower() const;
1470 };
1471 
1472 template <>
1474 {
1475  return base.id() == ID_find_first_set;
1476 }
1477 
1478 inline void validate_expr(const find_first_set_exprt &value)
1479 {
1480  validate_operands(value, 1, "find_first_set must have one operand");
1481 }
1482 
1490 {
1491  PRECONDITION(expr.id() == ID_find_first_set);
1492  const find_first_set_exprt &ret =
1493  static_cast<const find_first_set_exprt &>(expr);
1494  validate_expr(ret);
1495  return ret;
1496 }
1497 
1500 {
1501  PRECONDITION(expr.id() == ID_find_first_set);
1502  find_first_set_exprt &ret = static_cast<find_first_set_exprt &>(expr);
1503  validate_expr(ret);
1504  return ret;
1505 }
1506 
1507 #endif // CPROVER_UTIL_BITVECTOR_EXPR_H
exprt::op2
exprt & op2()
Definition: expr.h:131
binary_overflow_exprt::make_id
static irep_idt make_id(const irep_idt &kind)
Definition: bitvector_expr.h:748
dstringt
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:36
binary_overflow_exprt::binary_overflow_exprt
binary_overflow_exprt(exprt _lhs, const irep_idt &kind, exprt _rhs)
Definition: bitvector_expr.h:707
find_first_set_exprt::find_first_set_exprt
find_first_set_exprt(const exprt &_op)
Definition: bitvector_expr.h:1440
irept::get_size_t
std::size_t get_size_t(const irep_idt &name) const
Definition: irep.cpp:68
plus_overflow_exprt::plus_overflow_exprt
plus_overflow_exprt(exprt _lhs, exprt _rhs)
Definition: bitvector_expr.h:800
to_extractbit_expr
const extractbit_exprt & to_extractbit_expr(const exprt &expr)
Cast an exprt to an extractbit_exprt.
Definition: bitvector_expr.h:429
shl_exprt::shl_exprt
shl_exprt(exprt _src, const std::size_t _distance)
Definition: bitvector_expr.h:302
to_unary_expr
const unary_exprt & to_unary_expr(const exprt &expr)
Cast an exprt to a unary_exprt.
Definition: std_expr.h:361
can_cast_expr< saturating_minus_exprt >
bool can_cast_expr< saturating_minus_exprt >(const exprt &base)
Definition: bitvector_expr.h:1268
multi_ary_exprt
A base class for multi-ary expressions Associativity is not specified.
Definition: std_expr.h:856
DATA_CHECK
#define DATA_CHECK(vm, condition, message)
This macro takes a condition which denotes a well-formedness criterion on goto programs,...
Definition: validate.h:22
overflow_result_exprt::check
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
Definition: bitvector_expr.h:1344
extractbits_exprt::lower
exprt & lower()
Definition: bitvector_expr.h:479
mult_overflow_exprt::mult_overflow_exprt
mult_overflow_exprt(exprt _lhs, exprt _rhs)
Definition: bitvector_expr.h:838
shift_exprt::shift_exprt
shift_exprt(exprt _src, const irep_idt &_id, exprt _distance)
Definition: bitvector_expr.h:232
binary_exprt::rhs
exprt & rhs()
Definition: std_expr.h:623
can_cast_expr< bitor_exprt >
bool can_cast_expr< bitor_exprt >(const exprt &base)
Definition: bitvector_expr.h:134
count_trailing_zeros_exprt
The count trailing zeros (counting the number of zero bits starting from the least-significant bit) e...
Definition: bitvector_expr.h:1067
count_leading_zeros_exprt::lower
exprt lower() const
Lower a count_leading_zeros_exprt to arithmetic and logic expressions.
Definition: bitvector_expr.cpp:91
can_cast_expr< count_trailing_zeros_exprt >
bool can_cast_expr< count_trailing_zeros_exprt >(const exprt &base)
Definition: bitvector_expr.h:1119
lshr_exprt::lshr_exprt
lshr_exprt(exprt _src, exprt _distance)
Definition: bitvector_expr.h:362
can_cast_expr< replication_exprt >
bool can_cast_expr< replication_exprt >(const exprt &base)
Definition: bitvector_expr.h:569
unary_overflow_exprt::unary_overflow_exprt
unary_overflow_exprt(const irep_idt &kind, exprt _op)
Definition: bitvector_expr.h:874
to_bitor_expr
const bitor_exprt & to_bitor_expr(const exprt &expr)
Cast an exprt to a bitor_exprt.
Definition: bitvector_expr.h:145
can_cast_expr< count_leading_zeros_exprt >
bool can_cast_expr< count_leading_zeros_exprt >(const exprt &base)
Definition: bitvector_expr.h:1026
unary_overflow_exprt::check
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
Definition: bitvector_expr.h:879
typet
The type of an expression, extends irept.
Definition: type.h:28
can_cast_expr< shift_exprt >
bool can_cast_expr< shift_exprt >(const exprt &base)
Definition: bitvector_expr.h:261
overflow_result_exprt::valid_id
static bool valid_id(const irep_idt &id)
Returns true iff id is a valid identifier of an overflow_exprt.
Definition: bitvector_expr.h:1372
can_cast_expr< concatenation_exprt >
bool can_cast_expr< concatenation_exprt >(const exprt &base)
Definition: bitvector_expr.h:625
extractbits_exprt::src
const exprt & src() const
Definition: bitvector_expr.h:484
count_trailing_zeros_exprt::lower
exprt lower() const
Lower a count_trailing_zeros_exprt to arithmetic and logic expressions.
Definition: bitvector_expr.cpp:129
plus_overflow_exprt::lower
exprt lower() const
Lower a plus_overflow_exprt to arithmetic and logic expressions.
Definition: bitvector_expr.cpp:156
replication_exprt::times
constant_exprt & times()
Definition: bitvector_expr.h:547
validate_operands
void validate_operands(const exprt &value, exprt::operandst::size_type number, const char *message, bool allow_more=false)
Definition: expr_cast.h:250
popcount_exprt::lower
exprt lower() const
Lower a popcount_exprt to arithmetic and logic expressions.
Definition: bitvector_expr.cpp:45
can_cast_expr< bitand_exprt >
bool can_cast_expr< bitand_exprt >(const exprt &base)
Definition: bitvector_expr.h:204
unary_minus_overflow_exprt::unary_minus_overflow_exprt
unary_minus_overflow_exprt(exprt _op)
Definition: bitvector_expr.h:912
unary_minus_overflow_exprt::check
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
Definition: bitvector_expr.h:917
bitxor_exprt::bitxor_exprt
bitxor_exprt(exprt _op0, exprt _op1)
Definition: bitvector_expr.h:162
overflow_result_exprt::make_id
static irep_idt make_id(const irep_idt &kind)
Definition: bitvector_expr.h:1380
can_cast_expr< saturating_plus_exprt >
bool can_cast_expr< saturating_plus_exprt >(const exprt &base)
Definition: bitvector_expr.h:1223
count_trailing_zeros_exprt::zero_permitted
bool zero_permitted() const
Definition: bitvector_expr.h:1081
exprt
Base class for all expressions.
Definition: expr.h:55
minus_overflow_exprt::minus_overflow_exprt
minus_overflow_exprt(exprt _lhs, exprt _rhs)
Definition: bitvector_expr.h:819
overflow_result_exprt::op3
const exprt & op3() const =delete
binary_exprt::lhs
exprt & lhs()
Definition: std_expr.h:613
unary_exprt
Generic base class for unary expressions.
Definition: std_expr.h:313
ashr_exprt::ashr_exprt
ashr_exprt(exprt _src, exprt _distance)
Definition: bitvector_expr.h:341
binary_exprt
A base class for binary expressions.
Definition: std_expr.h:582
overflow_result_exprt
An expression returning both the result of the arithmetic operation under wrap-around semantics as we...
Definition: bitvector_expr.h:1304
saturating_plus_exprt::saturating_plus_exprt
saturating_plus_exprt(exprt _lhs, exprt _rhs, typet _type)
Definition: bitvector_expr.h:1212
bswap_exprt::bswap_exprt
bswap_exprt(exprt _op, std::size_t bits_per_byte)
Definition: bitvector_expr.h:27
bswap_exprt::get_bits_per_byte
std::size_t get_bits_per_byte() const
Definition: bitvector_expr.h:33
exprt::op0
exprt & op0()
Definition: expr.h:125
extractbits_exprt::upper
const exprt & upper() const
Definition: bitvector_expr.h:489
replication_exprt::op
const exprt & op() const
Definition: bitvector_expr.h:562
mult_overflow_exprt::lower
exprt lower() const
Lower a mult_overflow_exprt to arithmetic and logic expressions.
Definition: bitvector_expr.cpp:194
bool_typet
The Boolean type.
Definition: std_types.h:35
concatenation_exprt
Concatenation of bit-vector operands.
Definition: bitvector_expr.h:607
to_bitnot_expr
const bitnot_exprt & to_bitnot_expr(const exprt &expr)
Cast an exprt to a bitnot_exprt.
Definition: bitvector_expr.h:106
find_first_set_exprt::lower
exprt lower() const
Lower a find_first_set_exprt to arithmetic and logic expressions.
Definition: bitvector_expr.cpp:213
replication_exprt::replication_exprt
replication_exprt(constant_exprt _times, exprt _src, typet _type)
Definition: bitvector_expr.h:538
can_cast_expr< bitnot_exprt >
bool can_cast_expr< bitnot_exprt >(const exprt &base)
Definition: bitvector_expr.h:90
lshr_exprt
Logical right shift.
Definition: bitvector_expr.h:359
shift_exprt::op
exprt & op()
Definition: bitvector_expr.h:239
saturating_minus_exprt
Saturating subtraction expression.
Definition: bitvector_expr.h:1258
to_popcount_expr
const popcount_exprt & to_popcount_expr(const exprt &expr)
Cast an exprt to a popcount_exprt.
Definition: bitvector_expr.h:685
count_trailing_zeros_exprt::count_trailing_zeros_exprt
count_trailing_zeros_exprt(const exprt &_op)
Definition: bitvector_expr.h:1076
to_find_first_set_expr
const find_first_set_exprt & to_find_first_set_expr(const exprt &expr)
Cast an exprt to a find_first_set_exprt.
Definition: bitvector_expr.h:1489
replication_exprt
Bit-vector replication.
Definition: bitvector_expr.h:535
can_cast_expr< find_first_set_exprt >
bool can_cast_expr< find_first_set_exprt >(const exprt &base)
Definition: bitvector_expr.h:1473
count_leading_zeros_exprt::count_leading_zeros_exprt
count_leading_zeros_exprt(const exprt &_op)
Definition: bitvector_expr.h:983
replication_exprt::op
exprt & op()
Definition: bitvector_expr.h:557
can_cast_expr< extractbit_exprt >
bool can_cast_expr< extractbit_exprt >(const exprt &base)
Definition: bitvector_expr.h:413
shl_overflow_exprt
Definition: bitvector_expr.h:854
extractbits_exprt::upper
exprt & upper()
Definition: bitvector_expr.h:474
saturating_plus_exprt
The saturating plus expression.
Definition: bitvector_expr.h:1204
can_cast_expr< lshr_exprt >
bool can_cast_expr< lshr_exprt >(const exprt &base)
Definition: bitvector_expr.h:374
to_binary_expr
const binary_exprt & to_binary_expr(const exprt &expr)
Cast an exprt to a binary_exprt.
Definition: std_expr.h:660
to_bswap_expr
const bswap_exprt & to_bswap_expr(const exprt &expr)
Cast an exprt to a bswap_exprt.
Definition: bitvector_expr.h:63
find_first_set_exprt::validate
static void validate(const exprt &expr, const namespacet &, const validation_modet vm=validation_modet::INVARIANT)
Definition: bitvector_expr.h:1459
validate_expr
void validate_expr(const bswap_exprt &value)
Definition: bitvector_expr.h:50
can_cast_expr< bitreverse_exprt >
bool can_cast_expr< bitreverse_exprt >(const exprt &base)
Definition: bitvector_expr.h:1170
count_trailing_zeros_exprt::zero_permitted
void zero_permitted(bool value)
Definition: bitvector_expr.h:1086
namespacet
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition: namespace.h:90
can_cast_expr< overflow_result_exprt >
bool can_cast_expr< overflow_result_exprt >(const exprt &base)
Definition: bitvector_expr.h:1387
exprt::type
typet & type()
Return the type of the expression.
Definition: expr.h:84
count_leading_zeros_exprt::zero_permitted
bool zero_permitted() const
Definition: bitvector_expr.h:988
bitxor_exprt
Bit-wise XOR.
Definition: bitvector_expr.h:159
bitor_exprt
Bit-wise OR.
Definition: bitvector_expr.h:124
can_cast_expr< unary_minus_overflow_exprt >
bool can_cast_expr< unary_minus_overflow_exprt >(const exprt &base)
Definition: bitvector_expr.h:934
mult_overflow_exprt
Definition: bitvector_expr.h:835
DATA_INVARIANT
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
Definition: invariant.h:510
overflow_result_exprt::overflow_result_exprt
overflow_result_exprt(exprt _op, const irep_idt &kind)
Definition: bitvector_expr.h:1321
id2string
const std::string & id2string(const irep_idt &d)
Definition: irep.h:47
bitor_exprt::bitor_exprt
bitor_exprt(const exprt &_op0, exprt _op1)
Definition: bitvector_expr.h:127
irept::set
void set(const irep_idt &name, const irep_idt &value)
Definition: irep.h:420
binary_overflow_exprt
A Boolean expression returning true, iff operation kind would result in an overflow when applied to o...
Definition: bitvector_expr.h:704
count_leading_zeros_exprt::count_leading_zeros_exprt
count_leading_zeros_exprt(exprt _op, bool _zero_permitted, typet _type)
Definition: bitvector_expr.h:977
binary_predicate_exprt
A base class for expressions that are predicates, i.e., Boolean-typed, and that take exactly two argu...
Definition: std_expr.h:675
PRECONDITION
#define PRECONDITION(CONDITION)
Definition: invariant.h:463
extractbits_exprt::lower
const exprt & lower() const
Definition: bitvector_expr.h:494
can_cast_expr< plus_overflow_exprt >
bool can_cast_expr< plus_overflow_exprt >(const exprt &base)
Definition: bitvector_expr.h:811
count_leading_zeros_exprt::zero_permitted
void zero_permitted(bool value)
Definition: bitvector_expr.h:993
shl_exprt::shl_exprt
shl_exprt(exprt _src, exprt _distance)
Definition: bitvector_expr.h:297
extractbits_exprt::src
exprt & src()
Definition: bitvector_expr.h:469
to_unary_overflow_expr
const unary_overflow_exprt & to_unary_overflow_expr(const exprt &expr)
Cast an exprt to a unary_overflow_exprt.
Definition: bitvector_expr.h:951
exprt::op1
exprt & op1()
Definition: expr.h:128
find_first_set_exprt::find_first_set_exprt
find_first_set_exprt(exprt _op, typet _type)
Definition: bitvector_expr.h:1435
concatenation_exprt::concatenation_exprt
concatenation_exprt(operandst _operands, typet _type)
Definition: bitvector_expr.h:610
overflow_result_exprt::overflow_result_exprt
overflow_result_exprt(exprt _lhs, const irep_idt &kind, exprt _rhs)
Definition: bitvector_expr.h:1307
count_leading_zeros_exprt::validate
static void validate(const exprt &expr, const namespacet &, const validation_modet vm=validation_modet::INVARIANT)
Definition: bitvector_expr.h:1012
plus_overflow_exprt
Definition: bitvector_expr.h:797
extractbit_exprt::index
exprt & index()
Definition: bitvector_expr.h:396
saturating_plus_exprt::saturating_plus_exprt
saturating_plus_exprt(exprt _lhs, exprt _rhs)
Definition: bitvector_expr.h:1207
validation_modet
validation_modet
Definition: validation_mode.h:12
irept::id
const irep_idt & id() const
Definition: irep.h:396
binary_exprt::check
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
Definition: std_expr.h:595
popcount_exprt::popcount_exprt
popcount_exprt(const exprt &_op)
Definition: bitvector_expr.h:658
exprt::operandst
std::vector< exprt > operandst
Definition: expr.h:58
to_count_trailing_zeros_expr
const count_trailing_zeros_exprt & to_count_trailing_zeros_expr(const exprt &expr)
Cast an exprt to a count_trailing_zeros_exprt.
Definition: bitvector_expr.h:1136
unary_exprt::op
const exprt & op() const
Definition: std_expr.h:326
bitand_exprt
Bit-wise AND.
Definition: bitvector_expr.h:194
overflow_result_exprt::validate
static void validate(const exprt &expr, const namespacet &, const validation_modet vm=validation_modet::INVARIANT)
Definition: bitvector_expr.h:1363
to_shl_expr
const shl_exprt & to_shl_expr(const exprt &expr)
Cast an exprt to a shl_exprt.
Definition: bitvector_expr.h:320
irept::set_size_t
void set_size_t(const irep_idt &name, const std::size_t value)
Definition: irep.cpp:87
saturating_minus_exprt::saturating_minus_exprt
saturating_minus_exprt(exprt _lhs, exprt _rhs)
Definition: bitvector_expr.h:1261
to_shift_expr
const shift_exprt & to_shift_expr(const exprt &expr)
Cast an exprt to a shift_exprt.
Definition: bitvector_expr.h:278
to_binary_overflow_expr
const binary_overflow_exprt & to_binary_overflow_expr(const exprt &expr)
Cast an exprt to a binary_overflow_exprt.
Definition: bitvector_expr.h:775
bitnot_exprt
Bit-wise negation of bit-vectors.
Definition: bitvector_expr.h:81
extractbit_exprt
Extracts a single bit of a bit-vector operand.
Definition: bitvector_expr.h:380
to_concatenation_expr
const concatenation_exprt & to_concatenation_expr(const exprt &expr)
Cast an exprt to a concatenation_exprt.
Definition: bitvector_expr.h:636
extractbit_exprt::extractbit_exprt
extractbit_exprt(exprt _src, exprt _index)
Extract the _index-th least significant bit from _src.
Definition: bitvector_expr.h:384
unary_overflow_exprt
A Boolean expression returning true, iff operation kind would result in an overflow when applied to t...
Definition: bitvector_expr.h:871
shift_exprt
A base class for shift and rotate operators.
Definition: bitvector_expr.h:229
exprt::check
static void check(const exprt &, const validation_modet)
Check that the expression is well-formed (shallow checks only, i.e., subexpressions and its type are ...
Definition: expr.h:234
binary_overflow_exprt::check
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
Definition: bitvector_expr.h:716
struct_typet
Structure type, corresponds to C style structs.
Definition: std_types.h:230
can_cast_expr< bitxor_exprt >
bool can_cast_expr< bitxor_exprt >(const exprt &base)
Definition: bitvector_expr.h:169
shl_overflow_exprt::shl_overflow_exprt
shl_overflow_exprt(exprt _lhs, exprt _rhs)
Definition: bitvector_expr.h:857
extractbits_exprt::extractbits_exprt
extractbits_exprt(exprt _src, exprt _upper, exprt _lower, typet _type)
Extract the bits [_lower .
Definition: bitvector_expr.h:455
unary_minus_overflow_exprt
A Boolean expression returning true, iff negation would result in an overflow when applied to the (si...
Definition: bitvector_expr.h:909
bitand_exprt::bitand_exprt
bitand_exprt(const exprt &_op0, exprt _op1)
Definition: bitvector_expr.h:197
shift_exprt::distance
exprt & distance()
Definition: bitvector_expr.h:249
to_bitreverse_expr
const bitreverse_exprt & to_bitreverse_expr(const exprt &expr)
Cast an exprt to a bitreverse_exprt.
Definition: bitvector_expr.h:1186
can_cast_expr< bswap_exprt >
bool can_cast_expr< bswap_exprt >(const exprt &base)
Definition: bitvector_expr.h:45
can_cast_expr< binary_overflow_exprt >
bool can_cast_expr< binary_overflow_exprt >(const exprt &base)
Definition: bitvector_expr.h:758
extractbit_exprt::src
exprt & src()
Definition: bitvector_expr.h:391
ashr_exprt
Arithmetic right shift.
Definition: bitvector_expr.h:338
lshr_exprt::lshr_exprt
lshr_exprt(exprt _src, const std::size_t _distance)
Definition: bitvector_expr.h:367
count_trailing_zeros_exprt::validate
static void validate(const exprt &expr, const namespacet &, const validation_modet vm=validation_modet::INVARIANT)
Definition: bitvector_expr.h:1105
extractbit_exprt::index
const exprt & index() const
Definition: bitvector_expr.h:406
can_cast_expr< unary_overflow_exprt >
bool can_cast_expr< unary_overflow_exprt >(const exprt &base)
Definition: bitvector_expr.h:896
can_cast_expr< shl_exprt >
bool can_cast_expr< shl_exprt >(const exprt &base)
Definition: bitvector_expr.h:309
can_cast_expr< extractbits_exprt >
bool can_cast_expr< extractbits_exprt >(const exprt &base)
Definition: bitvector_expr.h:501
bswap_exprt::set_bits_per_byte
void set_bits_per_byte(std::size_t bits_per_byte)
Definition: bitvector_expr.h:38
can_cast_expr< mult_overflow_exprt >
bool can_cast_expr< mult_overflow_exprt >(const exprt &base)
Definition: bitvector_expr.h:849
to_extractbits_expr
const extractbits_exprt & to_extractbits_expr(const exprt &expr)
Cast an exprt to an extractbits_exprt.
Definition: bitvector_expr.h:517
can_cast_expr< popcount_exprt >
bool can_cast_expr< popcount_exprt >(const exprt &base)
Definition: bitvector_expr.h:669
count_leading_zeros_exprt::check
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
Definition: bitvector_expr.h:998
concatenation_exprt::concatenation_exprt
concatenation_exprt(exprt _op0, exprt _op1, typet _type)
Definition: bitvector_expr.h:615
to_overflow_result_expr
const overflow_result_exprt & to_overflow_result_expr(const exprt &expr)
Cast an exprt to a overflow_result_exprt.
Definition: bitvector_expr.h:1412
bswap_exprt
The byte swap expression.
Definition: bitvector_expr.h:18
shift_exprt::distance
const exprt & distance() const
Definition: bitvector_expr.h:254
to_saturating_minus_expr
const saturating_minus_exprt & to_saturating_minus_expr(const exprt &expr)
Cast an exprt to a saturating_minus_exprt.
Definition: bitvector_expr.h:1284
bitreverse_exprt::lower
exprt lower() const
Lower a bitreverse_exprt to arithmetic and logic expressions.
Definition: bitvector_expr.cpp:142
shift_exprt::op
const exprt & op() const
Definition: bitvector_expr.h:244
find_first_set_exprt
Returns one plus the index of the least-significant one bit, or zero if the operand is zero.
Definition: bitvector_expr.h:1432
extractbits_exprt
Extracts a sub-range of a bit-vector operand.
Definition: bitvector_expr.h:447
exprt::operands
operandst & operands()
Definition: expr.h:94
count_trailing_zeros_exprt::count_trailing_zeros_exprt
count_trailing_zeros_exprt(exprt _op, bool _zero_permitted, typet _type)
Definition: bitvector_expr.h:1070
ashr_exprt::ashr_exprt
ashr_exprt(exprt _src, const std::size_t _distance)
Definition: bitvector_expr.h:346
can_cast_expr< ashr_exprt >
bool can_cast_expr< ashr_exprt >(const exprt &base)
Definition: bitvector_expr.h:353
minus_overflow_exprt::lower
exprt lower() const
Lower a minus_overflow_exprt to arithmetic and logic expressions.
Definition: bitvector_expr.cpp:175
minus_overflow_exprt
Definition: bitvector_expr.h:816
to_bitand_expr
const bitand_exprt & to_bitand_expr(const exprt &expr)
Cast an exprt to a bitand_exprt.
Definition: bitvector_expr.h:215
popcount_exprt
The popcount (counting the number of bits set to 1) expression.
Definition: bitvector_expr.h:650
count_trailing_zeros_exprt::check
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
Definition: bitvector_expr.h:1091
unary_overflow_exprt::validate
static void validate(const exprt &expr, const namespacet &, const validation_modet vm=validation_modet::INVARIANT)
Definition: bitvector_expr.h:886
replication_exprt::times
const constant_exprt & times() const
Definition: bitvector_expr.h:552
binary_overflow_exprt::valid_id
static bool valid_id(const irep_idt &id)
Returns true iff id is a valid identifier of a binary_overflow_exprt.
Definition: bitvector_expr.h:741
constant_exprt
A constant literal expression.
Definition: std_expr.h:2941
overflow_result_exprt::op2
const exprt & op2() const =delete
binary_overflow_exprt::validate
static void validate(const exprt &expr, const namespacet &, const validation_modet vm=validation_modet::INVARIANT)
Definition: bitvector_expr.h:732
bswap_exprt::bswap_exprt
bswap_exprt(exprt _op, std::size_t bits_per_byte, typet _type)
Definition: bitvector_expr.h:21
can_cast_expr< shl_overflow_exprt >
bool can_cast_expr< shl_overflow_exprt >(const exprt &base)
Definition: bitvector_expr.h:864
std_expr.h
find_first_set_exprt::check
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
Definition: bitvector_expr.h:1445
unary_predicate_exprt
A base class for expressions that are predicates, i.e., Boolean-typed, and that take exactly one argu...
Definition: std_expr.h:527
popcount_exprt::popcount_exprt
popcount_exprt(exprt _op, typet _type)
Definition: bitvector_expr.h:653
bitnot_exprt::bitnot_exprt
bitnot_exprt(exprt op)
Definition: bitvector_expr.h:84
unary_minus_overflow_exprt::validate
static void validate(const exprt &expr, const namespacet &, const validation_modet vm=validation_modet::INVARIANT)
Definition: bitvector_expr.h:924
irept::get_bool
bool get_bool(const irep_idt &name) const
Definition: irep.cpp:58
extractbit_exprt::src
const exprt & src() const
Definition: bitvector_expr.h:401
can_cast_type< bitvector_typet >
bool can_cast_type< bitvector_typet >(const typet &type)
Check whether a reference to a typet is a bitvector_typet.
Definition: std_types.h:899
to_count_leading_zeros_expr
const count_leading_zeros_exprt & to_count_leading_zeros_expr(const exprt &expr)
Cast an exprt to a count_leading_zeros_exprt.
Definition: bitvector_expr.h:1043
to_replication_expr
const replication_exprt & to_replication_expr(const exprt &expr)
Cast an exprt to a replication_exprt.
Definition: bitvector_expr.h:585
bitreverse_exprt::bitreverse_exprt
bitreverse_exprt(exprt op)
Definition: bitvector_expr.h:1159
expr_protectedt
Base class for all expressions.
Definition: expr.h:323
validation_modet::INVARIANT
@ INVARIANT
to_saturating_plus_expr
const saturating_plus_exprt & to_saturating_plus_expr(const exprt &expr)
Cast an exprt to a saturating_plus_exprt.
Definition: bitvector_expr.h:1239
count_leading_zeros_exprt
The count leading zeros (counting the number of zero bits starting from the most-significant bit) exp...
Definition: bitvector_expr.h:974
shl_exprt
Left shift.
Definition: bitvector_expr.h:294
can_cast_expr< minus_overflow_exprt >
bool can_cast_expr< minus_overflow_exprt >(const exprt &base)
Definition: bitvector_expr.h:830
bitreverse_exprt
Reverse the order of bits in a bit-vector.
Definition: bitvector_expr.h:1156
to_bitxor_expr
const bitxor_exprt & to_bitxor_expr(const exprt &expr)
Cast an exprt to a bitxor_exprt.
Definition: bitvector_expr.h:180