Skip to content

Commit a8d03ac

Browse files
committed
Fix issues causing lem backend to loop forever
1 parent aaa4d6a commit a8d03ac

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/lib/monomorphise.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ let rec lem_nexps_of_typ (Typ_aux (t, l)) =
7676
| Typ_tuple ts -> List.fold_left (fun s t -> NexpSet.union s (trec t)) NexpSet.empty ts
7777
| Typ_app (Id_aux (Id "bitvector", _), [A_aux (A_nexp m, _)]) ->
7878
let m = nexp_simp m in
79-
if !opt_mwords && not (is_nexp_constant m) then NexpSet.singleton (orig_nexp m) else trec bit_typ
79+
if !opt_mwords && not (is_nexp_constant m) then NexpSet.singleton (orig_nexp m) else NexpSet.empty
8080
| Typ_app (Id_aux (Id "vector", _), [A_aux (A_nexp m, _); A_aux (A_typ elem_typ, _)]) -> trec elem_typ
8181
| Typ_app (Id_aux (Id "register", _), [A_aux (A_typ etyp, _)]) -> trec etyp
8282
| Typ_app (Id_aux (Id "range", _), _) | Typ_app (Id_aux (Id "implicit", _), _) | Typ_app (Id_aux (Id "atom", _), _) ->

src/sail_lem_backend/pretty_print_lem.ml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ let doc_id_lem_ctor (Id_aux (i, _)) =
132132
match i with
133133
| And_bool -> string "and_bool"
134134
| Or_bool -> string "or_bool"
135-
| Id "bit" -> string "bitU"
136135
| Id "int" -> string "integer"
137136
| Id "nat" -> string "integer"
138137
| Id "Some" -> string "Just"
@@ -297,7 +296,7 @@ let rec lem_nexps_of_typ params_to_print (Typ_aux (t, l)) =
297296
| Typ_tuple ts -> List.fold_left (fun s t -> NexpSet.union s (trec t)) NexpSet.empty ts
298297
| Typ_app (Id_aux (Id "bitvector", _), [A_aux (A_nexp m, _)]) ->
299298
let m = nexp_simp m in
300-
if !Monomorphise.opt_mwords && not (is_nexp_constant m) then NexpSet.singleton (orig_nexp m) else trec bit_typ
299+
if !Monomorphise.opt_mwords && not (is_nexp_constant m) then NexpSet.singleton (orig_nexp m) else NexpSet.empty
301300
| Typ_app (Id_aux (Id "vector", _), [A_aux (A_nexp m, _); A_aux (A_typ elem_typ, _)]) -> trec elem_typ
302301
| Typ_app (Id_aux (Id "register", _), [A_aux (A_typ etyp, _)]) -> trec etyp
303302
| Typ_app (Id_aux (Id "range", _), _) | Typ_app (Id_aux (Id "implicit", _), _) | Typ_app (Id_aux (Id "atom", _), _) ->
@@ -356,7 +355,7 @@ let doc_typ_lem, doc_typ_lem_brackets, doc_atomic_typ_lem =
356355
| Typ_app (Id_aux (Id "bitvector", _), [A_aux (A_nexp m, _)]) ->
357356
let tpp =
358357
if !Monomorphise.opt_mwords then string "mword " ^^ doc_nexp_lem (nexp_simp m)
359-
else string "list" ^^ space ^^ typ params_to_print true bit_typ
358+
else string "list" ^^ space ^^ string "bitU"
360359
in
361360
if atyp_needed then parens tpp else tpp
362361
| Typ_app (Id_aux (Id "register", _), [A_aux (A_typ etyp, _)]) ->
@@ -385,7 +384,6 @@ let doc_typ_lem, doc_typ_lem_brackets, doc_atomic_typ_lem =
385384
match t with
386385
| Typ_id (Id_aux (Id "string_literal", _)) -> string "string"
387386
| Typ_id (Id_aux (Id "bool", _)) -> string "bool"
388-
| Typ_id (Id_aux (Id "bit", _)) -> string "bitU"
389387
| Typ_id id ->
390388
(*if List.exists ((=) (string_of_id id)) regtypes
391389
then string "register"
@@ -501,6 +499,8 @@ let doc_tannot_lem ctxt env eff typ =
501499
let min_int32 = Big_int.of_int64 (Int64.of_int32 Int32.min_int)
502500
let max_int32 = Big_int.of_int64 (Int64.of_int32 Int32.max_int)
503501

502+
let doc_bit = function Value_type.B0 -> string "B0" | Value_type.B1 -> string "B1"
503+
504504
let rec doc_lit_lem (L_aux (lit, l)) =
505505
match lit with
506506
| L_unit -> utf8string "()"
@@ -512,8 +512,8 @@ let rec doc_lit_lem (L_aux (lit, l)) =
512512
| L_hex hex when !Monomorphise.opt_mwords ->
513513
utf8string ("0x" ^ string_of_hex_lit ~group_separator:"" ~case:Uppercase hex)
514514
| L_bin bin when !Monomorphise.opt_mwords -> utf8string ("0b" ^ string_of_bin_lit ~group_separator:"" bin)
515-
| L_hex _ | L_bin _ ->
516-
vector_string_to_bit_list (L_aux (lit, l)) |> flow_map (semi ^^ break 0) doc_lit_lem |> group |> align |> brackets
515+
| L_hex hex -> Semantics.bitlist_of_hex_lit hex |> flow_map (semi ^^ break 0) doc_bit |> group |> align |> brackets
516+
| L_bin bin -> Semantics.bitlist_of_bin_lit bin |> flow_map (semi ^^ break 0) doc_bit |> group |> align |> brackets
517517
| L_undef -> utf8string "(return (failwith \"undefined value of unsupported type\"))"
518518
| L_string s -> utf8string ("\"" ^ String.escaped s ^ "\"")
519519
| L_real s ->

0 commit comments

Comments
 (0)