Skip to content

Commit d641d17

Browse files
authored
Unify bit and bitvector(1) (rems-project#1491)
* Unify bit and bitvector(1) For mostly historical reasons Sail has had a separate type `bit` which is distinct from bits(1). This was because (a long time ago), `bitvector(N)` and `vector(N, bit)` were the same type. Therefore `bit` could not be `vector(1, bit)` because that would be `vector(1, vector(1, bit))` and so on. Now `bitvector` and `vector` are different, so there is no reason to keep `bit` and `bitvector(1)` separate other than inertia (except for one caveat, discussed below). The downside of these types being different was that extracting a single bit into a bitvector has to be written as `[v[0]]`, i.e. extract the `bit` then put it back into a singleton bitvector. It also meant we had separate literals `bitzero` and `bitone` for the bit type, which is a bit ugly. The one caveat as mentioned for merging these two concepts is that it makes it ever so slightly trickier to write a Sail backend that uses a bitlist representation for bitvectors (in OCaml for example it is quite natural to map `bivector(1)` to `bit list` and `bit` to `bit`). The changes here are fairly substantial: * The literal constructors L_zero and L_one are removed from the AST * The V_bit value constructor is removed. V_vector is replaced with V_bitvector and V_vector. * [x,y,z] is treated as a concatenation of length-1 bitvectors (when not a generic vector expression). * For backwards compatability `bitzero` and `bitone` are aliases for `0b0` and `0b1` respectively. * The bit type is removed, and replaced with a type synonym in the prelude. * The CT_bit type is removed from the Jib IR. We could keep it for SystemVerilog generation, but it seems cleaner to just remove it too. * Adjust pattern completeness checking behaviour when all patterns are impossible * Fix interpreter semantics for bit and bits(1) unification * Fix issues causing lem backend to loop forever * Fix all Sail->C tests * Get Sail->OCaml tests working again * Fix some issues with large vector concat matches * Fix SV tests * Fix non-machine word lem tests * Fix executable Lean tests * Update Lean expected tests * Remove void OCaml test We no longer allow clauses with impossible constraints * Remove now defunct rewrite * Fixing lem machine word tests * Remove separate eq_bit function from == overload Leave it in stdlib, but equivalent to eq_bits * Fix some Coq tests This is a bit of hack, but mostly to see what it gets past CI and what needs to change. * Should be all Rocq tests passing Again fix is a bit hacky * Update tests Mark one monomorphisation test as expected fail for now
1 parent 990b266 commit d641d17

File tree

119 files changed

+1903
-1734
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+1903
-1734
lines changed

language/jib.ott

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ ctyp :: 'CT_' ::=
162162
% Other Sail types
163163
| unit :: :: unit
164164
| bool_t :: :: bool
165-
| bit :: :: bit
166165
| string_t :: :: string
167166

168167
% The real type in sail. Abstract here, so the code generator can

lib/flow.sail

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ therefore be included in just about every Sail specification.
5555
5656
*/
5757

58+
type bit = bitvector(1)
59+
5860
val eq_unit = pure { lean : "_lean_beq", _ : "eq_unit" } : (unit, unit) -> bool(true)
5961
function eq_unit(_, _) = true
6062

61-
val eq_bit = pure { lem : "eq", lean : "_lean_beq", _ : "eq_bit" } : (bit, bit) -> bool
62-
6363
val not_bool = pure {coq: "negb", lean: "_lean_not", _: "not"} : forall ('p : Bool). bool('p) -> bool(not('p))
6464
/* NB: There are special cases in Sail for effectful uses of and_bool and
6565
or_bool that are not shown here. */
@@ -85,7 +85,7 @@ val gteq_int = pure {coq: "Z.geb", lean: "_lean_ge",_:"gteq"} : forall 'n 'm. (i
8585
val lt_int = pure {coq: "Z.ltb", lean: "_lean_lt", _:"lt"} : forall 'n 'm. (int('n), int('m)) -> bool('n < 'm)
8686
val gt_int = pure {coq: "Z.gtb", lean: "_lean_gt", _:"gt"} : forall 'n 'm. (int('n), int('m)) -> bool('n > 'm)
8787

88-
overload operator == = {eq_int, eq_bit, eq_bool, eq_unit}
88+
overload operator == = {eq_int, eq_bool, eq_unit}
8989
overload operator != = {neq_int, neq_bool}
9090
overload operator | = {or_bool}
9191
overload operator & = {and_bool}

lib/vector.sail

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ $include <arith.sail>
5656

5757
type bits('n) = bitvector('n)
5858

59+
val eq_bit = pure {
60+
ocaml: "eq_list",
61+
interpreter: "eq_list",
62+
lem: "eq_vec",
63+
coq: "eq_vec",
64+
lean: "_lean_beq",
65+
_: "eq_bits"
66+
} : (bit, bit) -> bool
67+
5968
val eq_bits = pure {
6069
ocaml: "eq_list",
6170
interpreter: "eq_list",
@@ -65,7 +74,7 @@ val eq_bits = pure {
6574
_: "eq_bits"
6675
} : forall 'n. (bits('n), bits('n)) -> bool
6776

68-
overload operator == = {eq_bit, eq_bits}
77+
overload operator == = {eq_bits}
6978

7079
val neq_bits = pure {
7180
lem: "neq_vec",
@@ -207,7 +216,7 @@ val bitvector_access = pure {
207216
$endif
208217

209218
val plain_vector_access = pure {
210-
ocaml: "access",
219+
ocaml: "access_list",
211220
interpreter: "access",
212221
lem: "access_list_dec",
213222
coq: "vec_access_dec",
@@ -238,7 +247,7 @@ val bitvector_update = pure {
238247
$endif
239248

240249
val plain_vector_update = pure {
241-
ocaml: "update",
250+
ocaml: "update_list",
242251
interpreter: "update",
243252
lem: "update_list_dec",
244253
coq: "vec_update_dec",

src/gen_lib/sail2_operators_bitlists.lem

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,23 +59,29 @@ let inline vec_of_bits_maybe bits = Just bits
5959
let inline vec_of_bits_nondet bits = return bits*)
6060
let inline vec_of_bits_failwith bits = bits
6161

62-
val access_vec_inc : list bitU -> integer -> bitU
63-
let access_vec_inc = access_bv_inc
62+
val access_vec_inc : list bitU -> integer -> list bitU
63+
let access_vec_inc xs n = [access_bv_inc xs n]
6464

65-
val access_vec_dec : list bitU -> integer -> bitU
66-
let access_vec_dec = access_bv_dec
65+
val access_vec_dec : list bitU -> integer -> list bitU
66+
let access_vec_dec xs n = [access_bv_dec xs n]
67+
68+
val update_vec_inc : list bitU -> integer -> list bitU -> list bitU
69+
let update_vec_inc v i b =
70+
match b with
71+
| [b] -> update_bv_inc v i b
72+
| _ -> v
73+
end
6774

68-
val update_vec_inc : list bitU -> integer -> bitU -> list bitU
69-
let update_vec_inc = update_bv_inc
7075
let update_vec_inc_maybe v i b = Just (update_vec_inc v i b)
71-
(*let update_vec_inc_fail v i b = return (update_vec_inc v i b)
72-
let update_vec_inc_nondet v i b = return (update_vec_inc v i b)*)
7376

74-
val update_vec_dec : list bitU -> integer -> bitU -> list bitU
75-
let update_vec_dec = update_bv_dec
77+
val update_vec_dec : list bitU -> integer -> list bitU -> list bitU
78+
let update_vec_dec v i b =
79+
match b with
80+
| [b] -> update_bv_dec v i b
81+
| _ -> v
82+
end
83+
7684
let update_vec_dec_maybe v i b = Just (update_vec_dec v i b)
77-
(*let update_vec_dec_fail v i b = return (update_vec_dec v i b)
78-
let update_vec_dec_nondet v i b = return (update_vec_dec v i b)*)
7985

8086
val subrange_vec_inc : list bitU -> integer -> integer -> list bitU
8187
let subrange_vec_inc = subrange_bv_inc

src/gen_lib/sail2_operators_mwords.lem

Lines changed: 20 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -2,55 +2,30 @@ open import Pervasives_extra
22
open import Machine_word
33
open import Sail2_values
44
open import Sail2_operators
5-
(* TODO: Move monadic operations (to sail2_monadic_combinators?)
6-
open import Sail2_prompt_monad
7-
open import Sail2_prompt*)
85

96
(* Specialisation of operators to machine words *)
107

118
let inline uint v = unsignedIntegerFromWord v
129
let uint_maybe v = Just (uint v)
13-
(*let uint_fail v = return (uint v)
14-
let uint_nondet v = return (uint v)*)
1510

1611
let inline sint v = signedIntegerFromWord v
1712
let sint_maybe v = Just (sint v)
18-
(*let sint_fail v = return (sint v)
19-
let sint_nondet v = return (sint v)*)
20-
21-
val vec_of_bits_maybe : forall 'a. Size 'a => list bitU -> maybe (mword 'a)
22-
(*val vec_of_bits_fail : forall 'rv 'a 'e. Size 'a => list bitU -> monad 'rv (mword 'a) 'e
23-
val vec_of_bits_nondet : forall 'rv 'a 'e. Size 'a, Register_Value 'rv => list bitU -> monad 'rv (mword 'a) 'e*)
24-
val vec_of_bits_failwith : forall 'a. Size 'a => list bitU -> mword 'a
25-
val vec_of_bits : forall 'a. Size 'a => list bitU -> mword 'a
26-
let vec_of_bits_maybe bits = of_bits bits
27-
(*let vec_of_bits_fail bits = of_bits_fail bits
28-
let vec_of_bits_nondet bits = of_bits_nondet bits*)
29-
let vec_of_bits_failwith bits = of_bits_failwith bits
30-
let vec_of_bits bits = of_bits_failwith bits
31-
32-
val access_vec_inc : forall 'a. Size 'a => mword 'a -> integer -> bitU
33-
let access_vec_inc = access_bv_inc
34-
35-
val access_vec_dec : forall 'a. Size 'a => mword 'a -> integer -> bitU
36-
let access_vec_dec = access_bv_dec
37-
38-
let update_vec_dec_maybe w i b = update_mword_dec w i b
39-
(*let update_vec_dec_fail w i b =
40-
bool_of_bitU_fail b >>= (fun b ->
41-
return (update_mword_bool_dec w i b))
42-
let update_vec_dec_nondet w i b =
43-
bool_of_bitU_nondet b >>= (fun b ->
44-
return (update_mword_bool_dec w i b))*)
13+
14+
val vec_of_bits_maybe : forall 'a. Size 'a => list (mword ty1) -> maybe (mword 'a)
15+
val vec_of_bits_failwith : forall 'a. Size 'a => list (mword ty1) -> mword 'a
16+
val vec_of_bits : forall 'a. Size 'a => list (mword ty1) -> mword 'a
17+
let vec_of_bits_maybe bits = of_bits (List.map (fun b -> bitU_of_bool (getBit b 0)) bits)
18+
let vec_of_bits_failwith bits = of_bits_failwith (List.map (fun b -> bitU_of_bool (getBit b 0)) bits)
19+
let vec_of_bits bits = of_bits_failwith (List.map (fun b -> bitU_of_bool (getBit b 0)) bits)
20+
21+
val update_vec_dec_maybe : forall 'a. Size 'a => mword 'a -> integer -> mword ty1 -> maybe (mword 'a)
22+
val update_vec_dec : forall 'a. Size 'a => mword 'a -> integer -> mword ty1 -> mword 'a
23+
let update_vec_dec_maybe w i b = Just (update_mword_bool_dec w i (getBit b 0))
4524
let update_vec_dec w i b = maybe_failwith (update_vec_dec_maybe w i b)
4625

47-
let update_vec_inc_maybe w i b = update_mword_inc w i b
48-
(*let update_vec_inc_fail w i b =
49-
bool_of_bitU_fail b >>= (fun b ->
50-
return (update_mword_bool_inc w i b))
51-
let update_vec_inc_nondet w i b =
52-
bool_of_bitU_nondet b >>= (fun b ->
53-
return (update_mword_bool_inc w i b))*)
26+
val update_vec_inc_maybe : forall 'a. Size 'a => mword 'a -> integer -> mword ty1 -> maybe (mword 'a)
27+
val update_vec_inc : forall 'a. Size 'a => mword 'a -> integer -> mword ty1 -> mword 'a
28+
let update_vec_inc_maybe w i b = Just (update_mword_bool_inc w i (getBit b 0))
5429
let update_vec_inc w i b = maybe_failwith (update_vec_inc_maybe w i b)
5530

5631
val subrange_vec_dec : forall 'a 'b. Size 'a, Size 'b => mword 'a -> integer -> integer -> mword 'b
@@ -59,6 +34,12 @@ let subrange_vec_dec w i j = Machine_word.word_extract (nat_of_int j) (nat_of_in
5934
val subrange_vec_inc : forall 'a 'b. Size 'a, Size 'b => mword 'a -> integer -> integer -> mword 'b
6035
let subrange_vec_inc w i j = subrange_vec_dec w (length w - 1 - i) (length w - 1 - j)
6136

37+
val access_vec_inc : forall 'a. Size 'a => mword 'a -> integer -> mword ty1
38+
let access_vec_inc w i = subrange_vec_inc w i i
39+
40+
val access_vec_dec : forall 'a. Size 'a => mword 'a -> integer -> mword ty1
41+
let access_vec_dec w i = subrange_vec_dec w i i
42+
6243
val update_subrange_vec_dec : forall 'a 'b. Size 'a, Size 'b => mword 'a -> integer -> integer -> mword 'b -> mword 'a
6344
let update_subrange_vec_dec w i j w' = Machine_word.word_update w (nat_of_int j) (nat_of_int i) w'
6445

@@ -96,22 +77,16 @@ let concat_vec = Machine_word.word_concat
9677
val cons_vec_bool : forall 'a 'b 'c. Size 'a, Size 'b => bool -> mword 'a -> mword 'b
9778
let cons_vec_bool b w = wordFromBitlist (b :: bitlistFromWord w)
9879
let cons_vec_maybe b w = Maybe.map (fun b -> cons_vec_bool b w) (bool_of_bitU b)
99-
(*let cons_vec_fail b w = bool_of_bitU_fail b >>= (fun b -> return (cons_vec_bool b w))
100-
let cons_vec_nondet b w = bool_of_bitU_nondet b >>= (fun b -> return (cons_vec_bool b w))*)
10180
let cons_vec b w = maybe_failwith (cons_vec_maybe b w)
10281

10382
val vec_of_bool : forall 'a. Size 'a => integer -> bool -> mword 'a
10483
let vec_of_bool _ b = wordFromBitlist [b]
10584
let vec_of_bit_maybe len b = Maybe.map (vec_of_bool len) (bool_of_bitU b)
106-
(*let vec_of_bit_fail len b = bool_of_bitU_fail b >>= (fun b -> return (vec_of_bool len b))
107-
let vec_of_bit_nondet len b = bool_of_bitU_nondet b >>= (fun b -> return (vec_of_bool len b))*)
10885
let vec_of_bit len b = maybe_failwith (vec_of_bit_maybe len b)
10986

11087
val cast_bool_vec : bool -> mword ty1
11188
let cast_bool_vec b = vec_of_bool 1 b
11289
let cast_unit_vec_maybe b = vec_of_bit_maybe 1 b
113-
(*let cast_unit_vec_fail b = bool_of_bitU_fail b >>= (fun b -> return (cast_bool_vec b))
114-
let cast_unit_vec_nondet b = bool_of_bitU_nondet b >>= (fun b -> return (cast_bool_vec b))*)
11590
let cast_unit_vec b = maybe_failwith (cast_unit_vec_maybe b)
11691

11792
val msb : forall 'a. Size 'a => mword 'a -> bitU
@@ -123,7 +98,6 @@ let int_of_vec sign w =
12398
then signedIntegerFromWord w
12499
else unsignedIntegerFromWord w
125100
let int_of_vec_maybe sign w = Just (int_of_vec sign w)
126-
(*let int_of_vec_fail sign w = return (int_of_vec sign w)*)
127101

128102
val string_of_bits : forall 'a. Size 'a => mword 'a -> string
129103
let string_of_bits = string_of_bv
@@ -177,55 +151,20 @@ val subs_vec_bool : forall 'a. Size 'a => mword 'a -> bool -> mword 'a
177151

178152
let add_vec_bool l r = arith_op_bv_bool integerAdd false l r
179153
let add_vec_bit_maybe l r = Maybe.map (add_vec_bool l) (bool_of_bitU r)
180-
(*let add_vec_bit_fail l r = bool_of_bitU_fail r >>= (fun r -> return (add_vec_bool l r))
181-
let add_vec_bit_nondet l r = bool_of_bitU_nondet r >>= (fun r -> return (add_vec_bool l r))*)
182154
let add_vec_bit l r = maybe_failwith (add_vec_bit_maybe l r)
183155

184156
let adds_vec_bool l r = arith_op_bv_bool integerAdd true l r
185157
let adds_vec_bit_maybe l r = Maybe.map (adds_vec_bool l) (bool_of_bitU r)
186-
(*let adds_vec_bit_fail l r = bool_of_bitU_fail r >>= (fun r -> return (adds_vec_bool l r))
187-
let adds_vec_bit_nondet l r = bool_of_bitU_nondet r >>= (fun r -> return (adds_vec_bool l r))*)
188158
let adds_vec_bit l r = maybe_failwith (adds_vec_bit_maybe l r)
189159

190160
let sub_vec_bool l r = arith_op_bv_bool integerMinus false l r
191161
let sub_vec_bit_maybe l r = Maybe.map (sub_vec_bool l) (bool_of_bitU r)
192-
(*let sub_vec_bit_fail l r = bool_of_bitU_fail r >>= (fun r -> return (sub_vec_bool l r))
193-
let sub_vec_bit_nondet l r = bool_of_bitU_nondet r >>= (fun r -> return (sub_vec_bool l r))*)
194162
let sub_vec_bit l r = maybe_failwith (sub_vec_bit_maybe l r)
195163

196164
let subs_vec_bool l r = arith_op_bv_bool integerMinus true l r
197165
let subs_vec_bit_maybe l r = Maybe.map (subs_vec_bool l) (bool_of_bitU r)
198-
(*let subs_vec_bit_fail l r = bool_of_bitU_fail r >>= (fun r -> return (subs_vec_bool l r))
199-
let subs_vec_bit_nondet l r = bool_of_bitU_nondet r >>= (fun r -> return (subs_vec_bool l r))*)
200166
let subs_vec_bit l r = maybe_failwith (subs_vec_bit_maybe l r)
201167

202-
(* TODO
203-
val maybe_mword_of_bits_overflow : forall 'a. Size 'a => (list bitU * bitU * bitU) -> maybe (mword 'a * bitU * bitU)
204-
let maybe_mword_of_bits_overflow (bits, overflow, carry) =
205-
Maybe.map (fun w -> (w, overflow, carry)) (of_bits bits)
206-
207-
val add_overflow_vec : forall 'a. Size 'a => mword 'a -> mword 'a -> maybe (mword 'a * bitU * bitU)
208-
val adds_overflow_vec : forall 'a. Size 'a => mword 'a -> mword 'a -> maybe (mword 'a * bitU * bitU)
209-
val sub_overflow_vec : forall 'a. Size 'a => mword 'a -> mword 'a -> maybe (mword 'a * bitU * bitU)
210-
val subs_overflow_vec : forall 'a. Size 'a => mword 'a -> mword 'a -> maybe (mword 'a * bitU * bitU)
211-
val mult_overflow_vec : forall 'a. Size 'a => mword 'a -> mword 'a -> maybe (mword 'a * bitU * bitU)
212-
val mults_overflow_vec : forall 'a. Size 'a => mword 'a -> mword 'a -> maybe (mword 'a * bitU * bitU)
213-
let add_overflow_vec l r = maybe_mword_of_bits_overflow (add_overflow_bv l r)
214-
let adds_overflow_vec l r = maybe_mword_of_bits_overflow (adds_overflow_bv l r)
215-
let sub_overflow_vec l r = maybe_mword_of_bits_overflow (sub_overflow_bv l r)
216-
let subs_overflow_vec l r = maybe_mword_of_bits_overflow (subs_overflow_bv l r)
217-
let mult_overflow_vec l r = maybe_mword_of_bits_overflow (mult_overflow_bv l r)
218-
let mults_overflow_vec l r = maybe_mword_of_bits_overflow (mults_overflow_bv l r)
219-
220-
val add_overflow_vec_bit : forall 'a. Size 'a => mword 'a -> bitU -> (mword 'a * bitU * bitU)
221-
val add_overflow_vec_bit_signed : forall 'a. Size 'a => mword 'a -> bitU -> (mword 'a * bitU * bitU)
222-
val sub_overflow_vec_bit : forall 'a. Size 'a => mword 'a -> bitU -> (mword 'a * bitU * bitU)
223-
val sub_overflow_vec_bit_signed : forall 'a. Size 'a => mword 'a -> bitU -> (mword 'a * bitU * bitU)
224-
let add_overflow_vec_bit = add_overflow_bv_bit
225-
let add_overflow_vec_bit_signed = add_overflow_bv_bit_signed
226-
let sub_overflow_vec_bit = sub_overflow_bv_bit
227-
let sub_overflow_vec_bit_signed = sub_overflow_bv_bit_signed*)
228-
229168
val shiftl : forall 'a. Size 'a => mword 'a -> integer -> mword 'a
230169
val shiftr : forall 'a. Size 'a => mword 'a -> integer -> mword 'a
231170
val arith_shiftr : forall 'a. Size 'a => mword 'a -> integer -> mword 'a
@@ -239,77 +178,35 @@ let rotr = rotr_mword
239178

240179
val mod_vec : forall 'a. Size 'a => mword 'a -> mword 'a -> mword 'a
241180
val mod_vec_maybe : forall 'a. Size 'a => mword 'a -> mword 'a -> maybe (mword 'a)
242-
(*val mod_vec_fail : forall 'rv 'a 'e. Size 'a => mword 'a -> mword 'a -> monad 'rv (mword 'a) 'e
243-
val mod_vec_nondet : forall 'rv 'a 'e. Size 'a, Register_Value 'rv => mword 'a -> mword 'a -> monad 'rv (mword 'a) 'e*)
244181
let mod_vec l r = mod_mword l r
245182
let mod_vec_maybe l r = mod_bv l r
246-
(*let mod_vec_fail l r = maybe_fail "mod_vec" (mod_bv l r)
247-
let mod_vec_nondet l r =
248-
match (mod_bv l r) with
249-
| Just w -> return w
250-
| Nothing -> mword_nondet ()
251-
end*)
252183

253184
val quot_vec : forall 'a. Size 'a => mword 'a -> mword 'a -> mword 'a
254185
val quot_vec_maybe : forall 'a. Size 'a => mword 'a -> mword 'a -> maybe (mword 'a)
255-
(*val quot_vec_fail : forall 'rv 'a 'e. Size 'a => mword 'a -> mword 'a -> monad 'rv (mword 'a) 'e
256-
val quot_vec_nondet : forall 'rv 'a 'e. Size 'a, Register_Value 'rv => mword 'a -> mword 'a -> monad 'rv (mword 'a) 'e*)
257186
let quot_vec l r = quot_mword l r
258187
let quot_vec_maybe l r = quot_bv l r
259-
(*let quot_vec_fail l r = maybe_fail "quot_vec" (quot_bv l r)
260-
let quot_vec_nondet l r =
261-
match (quot_bv l r) with
262-
| Just w -> return w
263-
| Nothing -> mword_nondet ()
264-
end*)
265188

266189
val quots_vec : forall 'a. Size 'a => mword 'a -> mword 'a -> mword 'a
267190
val quots_vec_maybe : forall 'a. Size 'a => mword 'a -> mword 'a -> maybe (mword 'a)
268-
(*val quots_vec_fail : forall 'rv 'a 'e. Size 'a => mword 'a -> mword 'a -> monad 'rv (mword 'a) 'e
269-
val quots_vec_nondet : forall 'rv 'a 'e. Size 'a, Register_Value 'rv => mword 'a -> mword 'a -> monad 'rv (mword 'a) 'e*)
270191
let quots_vec l r = quots_mword l r
271192
let quots_vec_maybe l r = quots_bv l r
272-
(*let quots_vec_fail l r = maybe_fail "quots_vec" (quots_bv l r)
273-
let quots_vec_nondet l r =
274-
match (quots_bv l r) with
275-
| Just w -> return w
276-
| Nothing -> mword_nondet ()
277-
end*)
278193

279194
val mod_vec_int : forall 'a. Size 'a => mword 'a -> integer -> mword 'a
280195
val mod_vec_int_maybe : forall 'a. Size 'a => mword 'a -> integer -> maybe (mword 'a)
281-
(*val mod_vec_int_fail : forall 'rv 'a 'e. Size 'a => mword 'a -> integer -> monad 'rv (mword 'a) 'e
282-
val mod_vec_int_nondet : forall 'rv 'a 'e. Size 'a, Register_Value 'rv => mword 'a -> integer -> monad 'rv (mword 'a) 'e*)
283196
let mod_vec_int l r = mod_mword_int l r
284197
let mod_vec_int_maybe l r = mod_bv_int l r
285-
(*let mod_vec_int_fail l r = maybe_fail "mod_vec_int" (mod_bv_int l r)
286-
let mod_vec_int_nondet l r =
287-
match (mod_bv_int l r) with
288-
| Just w -> return w
289-
| Nothing -> mword_nondet ()
290-
end*)
291198

292199
val quot_vec_int : forall 'a. Size 'a => mword 'a -> integer -> mword 'a
293200
val quot_vec_int_maybe : forall 'a. Size 'a => mword 'a -> integer -> maybe (mword 'a)
294-
(*val quot_vec_int_fail : forall 'rv 'a 'e. Size 'a => mword 'a -> integer -> monad 'rv (mword 'a) 'e
295-
val quot_vec_int_nondet : forall 'rv 'a 'e. Size 'a, Register_Value 'rv => mword 'a -> integer -> monad 'rv (mword 'a) 'e*)
296201
let quot_vec_int l r = quot_mword_int l r
297202
let quot_vec_int_maybe l r = quot_bv_int l r
298-
(*let quot_vec_int_fail l r = maybe_fail "quot_vec_int" (quot_bv_int l r)
299-
let quot_vec_int_nondet l r =
300-
match (quot_bv_int l r) with
301-
| Just w -> return w
302-
| Nothing -> mword_nondet ()
303-
end*)
304203

305204
val replicate_bits : forall 'a 'b. Size 'a, Size 'b => mword 'a -> integer -> mword 'b
306205
let replicate_bits v count = wordFromBitlist (repeat (bitlistFromWord v) count)
307206

308207
val duplicate_bool : forall 'a. Size 'a => bool -> integer -> mword 'a
309208
let duplicate_bool b n = wordFromBitlist (repeat [b] n)
310209
let duplicate_maybe b n = Maybe.map (fun b -> duplicate_bool b n) (bool_of_bitU b)
311-
(*let duplicate_fail b n = bool_of_bitU_fail b >>= (fun b -> return (duplicate_bool b n))
312-
let duplicate_nondet b n = bool_of_bitU_nondet b >>= (fun b -> return (duplicate_bool b n))*)
313210
let duplicate b n = maybe_failwith (duplicate_maybe b n)
314211

315212
val reverse_endianness : forall 'a. Size 'a => mword 'a -> mword 'a

0 commit comments

Comments
 (0)