CBMC
bitvector_types.cpp
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Pre-defined bitvector types
4 
5 Author: Daniel Kroening, kroening@kroening.com
6 
7 \*******************************************************************/
8 
11 
12 #include "bitvector_types.h"
13 
14 #include "arith_tools.h"
15 #include "bv_arithmetic.h"
16 #include "std_expr.h"
17 #include "string2int.h"
18 
20 {
21  const irep_idt integer_bits = get(ID_integer_bits);
22  DATA_INVARIANT(!integer_bits.empty(), "integer bits should be set");
23  return unsafe_string2unsigned(id2string(integer_bits));
24 }
25 
26 std::size_t floatbv_typet::get_f() const
27 {
28  const irep_idt &f = get(ID_f);
29  DATA_INVARIANT(!f.empty(), "the mantissa should be set");
31 }
32 
34 {
35  return bv_spect(*this).min_value();
36 }
37 
39 {
40  return bv_spect(*this).max_value();
41 }
42 
44 {
45  return from_integer(0, *this);
46 }
47 
49 {
50  return from_integer(smallest(), *this);
51 }
52 
54 {
55  return from_integer(largest(), *this);
56 }
constant_exprt from_integer(const mp_integer &int_value, const typet &type)
Pre-defined bitvector types.
mp_integer min_value() const
mp_integer max_value() const
A constant literal expression.
Definition: std_expr.h:2987
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:38
bool empty() const
Definition: dstring.h:89
std::size_t get_integer_bits() const
std::size_t get_f() const
constant_exprt largest_expr() const
Return an expression representing the largest value of this type.
mp_integer largest() const
Return the largest value that can be represented using this type.
constant_exprt zero_expr() const
Return an expression representing the zero value of this type.
constant_exprt smallest_expr() const
Return an expression representing the smallest value of this type.
mp_integer smallest() const
Return the smallest value that can be represented using this type.
const irep_idt & get(const irep_idt &name) const
Definition: irep.cpp:44
const std::string & id2string(const irep_idt &d)
Definition: irep.h:40
BigInt mp_integer
Definition: smt_terms.h:17
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
Definition: invariant.h:534
API to expression classes.
unsigned unsafe_string2unsigned(const std::string &str, int base)
Definition: string2int.cpp:35