Common — library colibrilib.bv_dolmen — module Dolmen
13
module Dolmen
14
use int.Int
15
use option.Option
16
use mach.int.Int63
17
use colibrilib.bv_sem.Sem
18
19
type
builtin
=
20
|
Int_And
21
|
Int_Or
22
|
Int_Xor
23
|
Int_Not
24
|
Int_Asr
25
|
Int_Extract
26
|
Int_SignedExtract
27
|
Int_Update
28
|
Int_Test
29
|
Bitv_to_int
int63 bool
30
|
Bitv_to_nat
int63
31
|
Bitv_of_int
int63
32
|
Bitv_concat
int63 int63
33
|
Bitv_extract
int63 int63 int63
34
|
Bitv_repeat
int63 int63
35
|
Bitv_zero_extend
int63 int63
36
|
Bitv_sign_extend
int63 int63
37
|
Bitv_rotate_left
int63 int63
38
|
Bitv_rotate_right
int63 int63
39
|
Bitv_not
int63
40
|
Bitv_and
int63
41
|
Bitv_or
int63
42
|
Bitv_xor
int63
43
|
Bitv_nand
int63
44
|
Bitv_nor
int63
45
|
Bitv_xnor
int63
46
|
Bitv_comp
int63
47
|
Bitv_neg
int63
48
|
Bitv_add
int63
49
|
Bitv_sub
int63
50
|
Bitv_mul
int63
51
|
Bitv_udiv
int63
52
|
Bitv_urem
int63
53
|
Bitv_sdiv
int63
54
|
Bitv_srem
int63
55
|
Bitv_smod
int63
56
|
Bitv_shl
int63
57
|
Bitv_lshr
int63
58
|
Bitv_ashr
int63
59
|
Bitv_ult
int63
60
|
Bitv_ule
int63
61
|
Bitv_ugt
int63
62
|
Bitv_uge
int63
63
|
Bitv_slt
int63
64
|
Bitv_sle
int63
65
|
Bitv_sgt
int63
66
|
Bitv_sge
int63
67
|
Other

The builtin of bv_sem.mlw of a Dolmen builtin. SMT–LIB (_ extract i j) is the bits j..i; ubv_to_int (Bitv_to_int unsigned) is bv2nat

72
let function
of_builtin
(b: builtin) : option Sem.builtin
73
= match b with
74
| Int_And -> Some Sem.And
75
| Int_Or -> Some Sem.Or
76
| Int_Xor -> Some Sem.Xor
77
| Int_Not -> Some Sem.Not
78
| Int_Asr -> Some Sem.Asr
79
| Int_Extract -> Some Sem.Extract
80
| Int_SignedExtract -> Some Sem.SignedExtract
81
| Int_Update -> Some Sem.Update
82
| Int_Test -> Some Sem.Test
83
| Bitv_to_int n True -> Some (Sem.Sbv2int (to_int n))
84
| Bitv_to_int n False -> Some (Sem.Bv2nat (to_int n))
85
| Bitv_to_nat n -> Some (Sem.Bv2nat (to_int n))
86
| Bitv_of_int n -> Some (Sem.Int2bv (to_int n))
87
| Bitv_concat n m -> Some (Sem.BvConcat (to_int n) (to_int m))
88
| Bitv_extract n i j -> Some (Sem.BvExtract (to_int n) (to_int j) (to_int i))
89
| Bitv_repeat n k -> Some (Sem.BvRepeat (to_int n) (to_int k))
90
| Bitv_zero_extend n k -> Some (Sem.BvZeroExtend (to_int n) (to_int k))
91
| Bitv_sign_extend n k -> Some (Sem.BvSignExtend (to_int n) (to_int k))
92
| Bitv_rotate_left n i -> Some (Sem.BvRotl (to_int n) (to_int i))
93
| Bitv_rotate_right n i -> Some (Sem.BvRotr (to_int n) (to_int i))
94
| Bitv_not n -> Some (Sem.BvNot (to_int n))
95
| Bitv_and n -> Some (Sem.BvAnd (to_int n))
96
| Bitv_or n -> Some (Sem.BvOr (to_int n))
97
| Bitv_xor n -> Some (Sem.BvXor (to_int n))
98
| Bitv_nand n -> Some (Sem.BvNand (to_int n))
99
| Bitv_nor n -> Some (Sem.BvNor (to_int n))
100
| Bitv_xnor n -> Some (Sem.BvXnor (to_int n))
101
| Bitv_comp n -> Some (Sem.BvComp (to_int n))
102
| Bitv_neg n -> Some (Sem.BvNeg (to_int n))
103
| Bitv_add n -> Some (Sem.BvAdd (to_int n))
104
| Bitv_sub n -> Some (Sem.BvSub (to_int n))
105
| Bitv_mul n -> Some (Sem.BvMul (to_int n))
106
| Bitv_udiv n -> Some (Sem.BvUdiv (to_int n))
107
| Bitv_urem n -> Some (Sem.BvUrem (to_int n))
108
| Bitv_sdiv n -> Some (Sem.BvSdiv (to_int n))
109
| Bitv_srem n -> Some (Sem.BvSrem (to_int n))
110
| Bitv_smod n -> Some (Sem.BvSmod (to_int n))
111
| Bitv_shl n -> Some (Sem.BvShl (to_int n))
112
| Bitv_lshr n -> Some (Sem.BvLshr (to_int n))
113
| Bitv_ashr n -> Some (Sem.BvAshr (to_int n))
114
| Bitv_ult n -> Some (Sem.BvUlt (to_int n))
115
| Bitv_ule n -> Some (Sem.BvUle (to_int n))
116
| Bitv_ugt n -> Some (Sem.BvUgt (to_int n))
117
| Bitv_uge n -> Some (Sem.BvUge (to_int n))
118
| Bitv_slt n -> Some (Sem.BvSlt (to_int n))
119
| Bitv_sle n -> Some (Sem.BvSle (to_int n))
120
| Bitv_sgt n -> Some (Sem.BvSgt (to_int n))
121
| Bitv_sge n -> Some (Sem.BvSge (to_int n))
122
| _ -> None
123
end
124
end