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 }
dstringt
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:36
mp_integer
BigInt mp_integer
Definition: smt_terms.h:17
arith_tools.h
integer_bitvector_typet::smallest
mp_integer smallest() const
Return the smallest value that can be represented using this type.
Definition: bitvector_types.cpp:33
integer_bitvector_typet::largest_expr
constant_exprt largest_expr() const
Return an expression representing the largest value of this type.
Definition: bitvector_types.cpp:53
floatbv_typet::get_f
std::size_t get_f() const
Definition: bitvector_types.cpp:26
bv_arithmetic.h
integer_bitvector_typet::zero_expr
constant_exprt zero_expr() const
Return an expression representing the zero value of this type.
Definition: bitvector_types.cpp:43
integer_bitvector_typet::smallest_expr
constant_exprt smallest_expr() const
Return an expression representing the smallest value of this type.
Definition: bitvector_types.cpp:48
irept::get
const irep_idt & get(const irep_idt &name) const
Definition: irep.cpp:45
string2int.h
bv_spect
Definition: bv_arithmetic.h:21
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
id2string
const std::string & id2string(const irep_idt &d)
Definition: irep.h:47
bitvector_types.h
dstringt::empty
bool empty() const
Definition: dstring.h:88
from_integer
constant_exprt from_integer(const mp_integer &int_value, const typet &type)
Definition: arith_tools.cpp:100
fixedbv_typet::get_integer_bits
std::size_t get_integer_bits() const
Definition: bitvector_types.cpp:19
unsafe_string2unsigned
unsigned unsafe_string2unsigned(const std::string &str, int base)
Definition: string2int.cpp:35
integer_bitvector_typet::largest
mp_integer largest() const
Return the largest value that can be represented using this type.
Definition: bitvector_types.cpp:38
bv_spect::min_value
mp_integer min_value() const
Definition: bv_arithmetic.cpp:28
constant_exprt
A constant literal expression.
Definition: std_expr.h:2941
std_expr.h
bv_spect::max_value
mp_integer max_value() const
Definition: bv_arithmetic.cpp:22