Skip to content

Commit 14a5744

Browse files
committed
WIPP
1 parent 0665cf8 commit 14a5744

File tree

1 file changed

+39
-38
lines changed

1 file changed

+39
-38
lines changed

compiler/src/CL_vsimpl.ml

+39-38
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,28 @@ module GhostVector = struct
225225
let unfold_vghosts_epred ghosts pre =
226226
List.map (unfold_ghosts_epred ghosts) pre
227227

228+
let unfold_clauses node formals =
229+
match node with
230+
| {iname = "assert"; iargs = [Pred (ep, rp)]} ->
231+
let ep' = unfold_vghosts_epred formals ep in
232+
let rp' = unfold_vghosts_rpred formals rp in
233+
{iname = "assert"; iargs = [Pred (ep',rp')]}
234+
| {iname = "assume"; iargs = [Pred (ep, rp)]} ->
235+
let ep' = unfold_vghosts_epred formals ep in
236+
let rp' = unfold_vghosts_rpred formals rp in
237+
{iname = "assume"; iargs = [Pred (ep',rp')]}
238+
| {iname = "cut"; iargs = [Pred (ep, rp)]} ->
239+
let ep' = unfold_vghosts_epred formals ep in
240+
let rp' = unfold_vghosts_rpred formals rp in
241+
{iname = "cut"; iargs = [Pred (ep',rp')]}
242+
| _ -> node
243+
244+
let rec unfold_cfg_clauses cfg formals =
245+
match cfg with
246+
| h::t ->
247+
[unfold_clauses h formals] @ (unfold_cfg_clauses t formals)
248+
| [] -> []
249+
228250
let unfold_vectors formals ret_vars =
229251
let aux ((v,ty) as tv) =
230252
let mk_vector = Annot.filter_string_list None ["u16x16", U16x16] in
@@ -261,28 +283,6 @@ module GhostVector = struct
261283
let fs,ispre,ispost = aux tv in
262284
fs @ acc1, ispre @ acc2, ispost @ acc3)
263285
([],[],[]) formals
264-
265-
let unfold_clauses node formals =
266-
match node with
267-
| {iname = "assert"; iargs = [Pred (ep, rp)]} ->
268-
let ep' = unfold_vghosts_epred formals ep in
269-
let rp' = unfold_vghosts_rpred formals rp in
270-
{iname = "assert"; iargs = [Pred (ep',rp')]}
271-
| {iname = "assume"; iargs = [Pred (ep, rp)]} ->
272-
let ep' = unfold_vghosts_epred formals ep in
273-
let rp' = unfold_vghosts_rpred formals rp in
274-
{iname = "assume"; iargs = [Pred (ep',rp')]}
275-
| {iname = "cut"; iargs = [Pred (ep, rp)]} ->
276-
let ep' = unfold_vghosts_epred formals ep in
277-
let rp' = unfold_vghosts_rpred formals rp in
278-
{iname = "cut"; iargs = [Pred (ep',rp')]}
279-
| _ -> node
280-
281-
let rec unfold_cfg_clauses cfg formals =
282-
match cfg with
283-
| h::t ->
284-
[unfold_clauses h formals] @ (unfold_cfg_clauses t formals)
285-
| [] -> []
286286
end
287287

288288
module SimplVector = struct
@@ -337,22 +337,6 @@ module SimplVector = struct
337337
| None -> None
338338
in
339339
match n.nkind with
340-
| {iname = "cast"; iargs = [Lval (Llvar (v',ty')); Atom (Avar (v'', ty''))]} ->
341-
if v == v' then
342-
if is_equiv_type ty' ty'' then
343-
aux (v'',ty'') n
344-
else
345-
Some (v', ty')
346-
else
347-
aux (v, ty) n
348-
| {iname = "cast"; iargs = [Lval (Llvar (v',ty')); Atom (Avatome (Avar (v'', ty'') :: t))]} ->
349-
let ll = (List.length t) + 1 in
350-
if ll == 1 && v == v' && is_equiv_type ty' ty'' then
351-
aux (v'', ty'') n
352-
else if v == v' && ((int_of_ty ty'') * ll) == (int_of_ty ty') then (* Since we're not able to reconstruct the list, this is no longer invertible *)
353-
Some (v', ty')
354-
else
355-
aux (v, ty) n
356340
| {iname = "mov"; iargs = [Lval (Llvar (v',ty')); Atom (Avar (v'', ty''))]} ->
357341
if v == v' && is_equiv_type ty' ty'' then
358342
aux (v'',ty'') n
@@ -371,6 +355,22 @@ module SimplVector = struct
371355
Some (v', ty')
372356
else
373357
aux (v, ty) n
358+
| {iname = "cast"; iargs = [Lval (Llvar (v',ty')); Atom (Avar (v'', ty''))]} ->
359+
if v == v' then
360+
if is_equiv_type ty' ty'' then
361+
aux (v'',ty'') n
362+
else
363+
Some (v', ty')
364+
else
365+
aux (v, ty) n
366+
| {iname = "cast"; iargs = [Lval (Llvar (v',ty')); Atom (Avatome (Avar (v'', ty'') :: t))]} ->
367+
let ll = (List.length t) + 1 in
368+
if ll == 1 && v == v' && is_equiv_type ty' ty'' then
369+
aux (v'', ty'') n
370+
else if v == v' && ((int_of_ty ty'') * ll) == (int_of_ty ty') then (* Since we're not able to reconstruct the list, this is no longer invertible *)
371+
Some (v', ty')
372+
else
373+
aux (v, ty) n
374374
| {iname = "adds"; iargs = [_; Lval (Llvar (v',ty')); Atom (Avar (_, ty'')); Atom (Avar (_, ty'''))]} ->
375375
if v == v' && (is_equiv_type ty' ty'' || is_equiv_type ty' ty''') then
376376
Some (v', ty')
@@ -550,6 +550,7 @@ module SimplVector = struct
550550

551551
let rec nop_uinst cfg ret_vars node =
552552
let nI = getNextI node in
553+
(* TODO: search for unused lval in Lvatome *)
553554
match node.nkind with
554555
| {iname = "cast"; iargs = [Lval (Llvar tv); _]} ->
555556
if not(List.exists (is_eq_tyvar tv) ret_vars) && unused_lval tv nI then

0 commit comments

Comments
 (0)