Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
marcpouzet committed Oct 31, 2024
1 parent 7a667c6 commit 2ff55eb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
14 changes: 9 additions & 5 deletions src/compiler/gencode/translate.ml
Original file line number Diff line number Diff line change
Expand Up @@ -458,10 +458,11 @@ let rec exp env loop_path code { Zelus.e_desc = desc } =
Econcat { left = e1; left_size = s1; right = e2; right_size = s2 }, code
| Zelus.Eop(Zelus.Eatomic, [e]) ->
exp env loop_path code e
| Zelus.Elet _ | Zelus.Eop(Eseq, _) | Zelus.Eop(Eperiod, _)
| Zelus.Eop _ | Zelus.Epresent _
| Zelus.Ematch _ | Zelus.Elocal _ -> assert false
| Zelus.Eapp { f; arg_list } ->
| Zelus.Eop(Eseq, [e1; e2]) ->
let e1, code = exp env loop_path code e1 in
let e2, code = exp env loop_path code e2 in
Oaux.seq e1 e2, code
| Zelus.Eapp { f; arg_list } ->
(* make an application *)
let make_app f arg_list =
match arg_list with | [] -> f | _ -> Eapp { f; arg_list } in
Expand Down Expand Up @@ -490,7 +491,10 @@ let rec exp env loop_path code { Zelus.e_desc = desc } =
| Eforloop _ -> Misc.not_yet_implemented "for loops"
| Ereset _ -> Misc.not_yet_implemented "reset"
| Eassert _ -> Misc.not_yet_implemented "assert"

| Zelus.Elet _
| Zelus.Eop(Eperiod, _) | Zelus.Eop _ | Zelus.Epresent _
| Zelus.Ematch _ | Zelus.Elocal _ -> assert false

and arg a_list =
match a_list with | [] -> Ewildpat | _ -> Etuplepat (List.map vardec a_list)

Expand Down
6 changes: 3 additions & 3 deletions src/compiler/rewrite/deadcode.ml
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,15 @@ let pattern funs useful ({ pat_desc } as p) =
| Evarpat(x) ->
if S.mem x useful then p, useful else { p with pat_desc = Ewildpat }, useful
| Ealiaspat(p_alias, x) ->
let p_alias, acc = Mapfold.pattern funs useful p_alias in
let p_alias, acc = Mapfold.pattern_it funs useful p_alias in
if S.mem x useful then { p with pat_desc = Ealiaspat(p_alias, x) }, useful
else p_alias, useful
| _ -> raise Mapfold.Fallback

(* Remove useless equations. [useful] is the set of useful names *)
let equation funs useful eq =
let eq_empty = Aux.eqmake Defnames.empty EQempty in
let { eq_desc; eq_write } as eq, useful = Mapfold.equation_it funs useful eq in
let { eq_desc; eq_write } as eq, useful = Mapfold.equation funs useful eq in
match eq_desc with
| EQeq(p, e) ->
let { v = w } = Vars.pattern { lv = S.empty; v = S.empty } p in
Expand Down Expand Up @@ -221,7 +221,7 @@ let remove_useless_in_equation useful eq =

(* the main entry for expressions. Warning: [e] must be in normal form *)
let expression funs acc e =
let { e_desc } as e, acc = Mapfold.expression_it funs acc e in
let { e_desc } as e, acc = Mapfold.expression funs acc e in
match e_desc with
| Elet({ l_eq } as l, e_let) ->
let { v } = Vars.expression { lv = S.empty; v = S.empty } e_let in
Expand Down

0 comments on commit 2ff55eb

Please sign in to comment.