Skip to content
Snippets Groups Projects
Commit 579d15a3 authored by Erwan Jahier's avatar Erwan Jahier
Browse files

--when-on-ident: replace enum clock in var_info too!

var_info appears in
- node decl
- left var
- static args

not yet working. I commit as Ive fix a missing dep on WenOnId in the _oasis.
parent 06e1f9d3
No related branches found
No related tags found
No related merge requests found
OASISFormat: 0.4
Name: lustre-v6
Version: 1.652
Version: 1.653
Synopsis: The Lustre V6 Verimag compiler
Description: This package contains:
(1) lus2lic: the (current) name of the compiler (and interpreter via -exec).
......@@ -12,6 +12,7 @@ Plugins: DevFiles (0.3), META (0.3), StdFiles (0.3)
Homepage: http://www-verimag.imag.fr/lustre-v6.html
BuildTools: ocamlbuild
# distribution version (native)
Executable lus2lic
Install:true
......@@ -49,5 +50,5 @@ Library "lustre-v6"
BuildDepends: str,unix,num,rdbg-plugin (>= 1.51)
Install:true
XMETAEnable: true
InternalModules: SocExecValue,SocUtils,Lv6util,Lv6version,Lv6errors,Lxm,Lv6MainArgs,Lv6Verbose,Soc,SocPredef,Lv6Id,SocExecDbg,SocExec,SocExecEvalPredef,Lv6Compile,AstTab,AstTabSymbol,AstInstanciateModel,Lv6parserUtils,AstV6,FilenameExtras,LicTab,LicDump,AstPredef,Lic,AstCore,FreshName,IdSolver,EvalConst,LicEvalConst,LicEvalType,UnifyType,Ast2lic,AstV6Dump,EvalClock,UnifyClock,LicEvalClock,EvalType,LicPrg,LicMetaOp,L2lCheckOutputs,Lv6Misc,L2lRmPoly,L2lExpandMetaOp,L2lSplit,L2lExpandNodes,L2lExpandArrays,L2lCheckLoops,L2lCheckMemSafe,L2lOptimIte,Lv6lexer,Lv6parser,AstRecognizePredef,Lic2soc,Action,ActionsDeps,SocVar,TopoSort,SortActions,SortActionsExpe,L2lCheckKcgKeyWord
InternalModules: SocExecValue,SocUtils,Lv6util,Lv6version,Lv6errors,Lxm,Lv6MainArgs,Lv6Verbose,Soc,SocPredef,Lv6Id,SocExecDbg,SocExec,SocExecEvalPredef,Lv6Compile,AstTab,AstTabSymbol,AstInstanciateModel,Lv6parserUtils,AstV6,FilenameExtras,LicTab,LicDump,AstPredef,Lic,AstCore,FreshName,IdSolver,EvalConst,LicEvalConst,LicEvalType,UnifyType,Ast2lic,AstV6Dump,EvalClock,UnifyClock,LicEvalClock,EvalType,LicPrg,LicMetaOp,L2lCheckOutputs,Lv6Misc,L2lRmPoly,L2lExpandMetaOp,L2lSplit,L2lExpandNodes,L2lExpandArrays,L2lCheckLoops,L2lCheckMemSafe,L2lOptimIte,Lv6lexer,Lv6parser,AstRecognizePredef,Lic2soc,Action,ActionsDeps,SocVar,TopoSort,SortActions,SortActionsExpe,L2lCheckKcgKeyWord,L2lWhenOnId
# Comment se passer de cette liste à la Prevert ?
(** Time-stamp: <modified the 01/06/2016 (at 17:34) by Erwan Jahier> *)
(** Time-stamp: <modified the 07/06/2016 (at 13:30) by Erwan Jahier> *)
open Lxm
open Lic
......@@ -13,23 +13,58 @@ let dbg = (Lv6Verbose.get_flag "woi")
(3) the fresh variables
*)
type clock_tbl = ((Lv6Id.long * Lv6Id.t), Lic.var_info) Hashtbl.t (* Map.t ? *)
type acc =
Lic.var_info list (* new local vars *)
* Lic.eq_info srcflagged list (* equations *)
* Lic.val_exp srcflagged list (* assertions *)
* clock_tbl
let rec update_clock : clock_tbl -> clock -> clock =
fun clk_tbl clk ->
match clk with
| BaseLic | ClockVar _ -> clk
| On((cc,cv,ct),sclk) ->
let sclk = update_clock clk_tbl sclk in
try
let nv = Hashtbl.find clk_tbl (cc,cv) in
On((("Lustre","true"),nv.var_name_eff, Bool_type_eff), sclk)
with Not_found ->
On((cc,cv,ct),sclk)
let update_var_info : clock_tbl -> var_info -> var_info =
fun tbl vi ->
let (id, clk) = vi.var_clock_eff in
{ vi with var_clock_eff = id, update_clock tbl clk }
let rec update_left : clock_tbl -> left -> left =
fun tbl l ->
match l with
| LeftVarLic(vi,lxm) -> LeftVarLic(update_var_info tbl vi,lxm)
| LeftFieldLic(l,id,t) -> LeftFieldLic(update_left tbl l,id,t)
| LeftArrayLic(l,i,t) -> LeftArrayLic(update_left tbl l,i,t)
| LeftSliceLic(l,si,t) -> LeftSliceLic(update_left tbl l,si,t)
let new_var (cc,cv) type_eff clock_eff clk_tbl =
try Hashtbl.find clk_tbl (cc,cv)
with Not_found ->
let str = (snd cc) ^ "_" ^ cv in
let id = Lv6Id.of_string (FreshName.local_var str) in
let var =
{
var_name_eff = id;
var_nature_eff = AstCore.VarLocal;
var_number_eff = -1;
var_type_eff = type_eff;
var_clock_eff = id,clock_eff;
}
in
Hashtbl.add clk_tbl (cc,cv) var;
var
let new_var = FreshName.var_info
let new_var str type_eff clock_eff =
let id = Lv6Id.of_string (FreshName.local_var str) in
let var =
{
var_name_eff = id;
var_nature_eff = AstCore.VarLocal;
var_number_eff = -1;
var_type_eff = type_eff;
var_clock_eff = id,clock_eff;
} in
var
(********************************************************************************)
(* The one that perform the real work, namely:
......@@ -41,10 +76,9 @@ let new_var str type_eff clock_eff =
let (gen_ident : Lxm.t -> Lv6Id.long -> Lv6Id.t -> type_ -> Lic.clock -> acc ->
Lic.by_pos_op srcflagged * acc ) =
fun lxm cc cv ct clk (vl,eql,al) -> (* On(Idle, st, enum_t) *)
fun lxm cc cv ct clk (vl,eql,al,tbl) -> (* On(Idle, st, enum_t) *)
let nv_base = (snd cc) ^ "_" ^ cv in
let nv = new_var nv_base Bool_type_eff clk in
let nv = new_var (cc,cv) Bool_type_eff clk tbl in
let ve1 = {
ve_typ = [ct];
......@@ -69,15 +103,16 @@ let (gen_ident : Lxm.t -> Lv6Id.long -> Lv6Id.t -> type_ -> Lic.clock -> acc ->
let new_eq = (* NV=(Idle=st) *) {src=lxm;it=[LeftVarLic (nv, lxm)], ve} in
let true_cc = "Lustre","true" in
let op = WHEN (On((true_cc, nv.var_name_eff, Bool_type_eff),clk)) in
Lxm.flagit op lxm, (nv::vl,new_eq::eql,al)
Lxm.flagit op lxm, (nv::vl,new_eq::eql,al,tbl)
(********************************************************************************)
(* All the remaining are admnistrative functions *)
let rec (do_eq : LicPrg.t -> Lic.eq_info srcflagged -> acc -> acc) =
fun licprg { src = lxm_eq ; it = (left_list, ve) } acc ->
let ve, (nv,neqs,nass) = do_val_exp licprg ve acc in
nv, { src = lxm_eq ; it = (left_list, ve) }::neqs, nass
let ve, (nv,neqs,nass,tbl) = do_val_exp licprg ve acc in
let left_list = List.map (update_left tbl) left_list in
nv, { src = lxm_eq ; it = (left_list, ve) }::neqs, nass,tbl
and (do_val_exp: LicPrg.t -> val_exp -> acc -> val_exp * acc) =
fun licprg ve acc ->
......@@ -88,10 +123,9 @@ and (do_val_exp: LicPrg.t -> val_exp -> acc -> val_exp * acc) =
List.fold_left
(fun (ncl,acc) (c, ve) ->
let ve, acc = do_val_exp licprg ve acc in
((c, ve)::ncl), acc
)
((c, ve)::ncl), acc)
([],acc)
cl
cl
in
Merge(ce,cl),acc
)
......@@ -134,34 +168,43 @@ and (do_val_exp_flag: LicPrg.t -> val_exp srcflagged -> acc ->
and (do_node : LicPrg.t -> Lic.node_exp -> Lic.node_exp) =
fun licprg n ->
let tbl = Hashtbl.create 0 in
let aux licprg n =
match n.def_eff with
| ExternLic | MetaOpLic | AbstractLic _ -> n
| BodyLic b ->
let acc = List.fold_left
(fun acc eq -> do_eq licprg eq acc)
([],[],[])
([],[],[],tbl)
(List.rev b.eqs_eff)
in
let acc = List.fold_left
(fun acc ve ->
let ve,(nv,neq,nass) = do_val_exp_flag licprg ve acc in
(nv,neq,ve::nass)
let ve,(nv,neq,nass,tbl) = do_val_exp_flag licprg ve acc in
(nv,neq,ve::nass,tbl)
)
acc
b.asserts_eff
in
let (nv,neqs,nass) = acc in
let (nv,neqs,nass,tbl) = acc in
let nlocs = match n.loclist_eff with
| None -> nv (* SNO, but eats no bread *)
| Some v -> List.rev_append nv v
in
let update_var_info = update_var_info tbl in
{ n with
def_eff = BodyLic {
eqs_eff = neqs;
asserts_eff = nass;
};
loclist_eff = Some nlocs;
inlist_eff = List.map update_var_info n.inlist_eff;
outlist_eff = List.map update_var_info n.outlist_eff;
loclist_eff = Some (List.map update_var_info nlocs);
}
in
let n = aux licprg n in
let n = aux licprg n in (* do it twice to make sure they are all substituted *)
n
(* exported *)
let rec (doit : LicPrg.t -> LicPrg.t) =
......
# OASIS_START
# DO NOT EDIT (digest: dbb10b1e67d7883ec20936ed84df7d60)
# DO NOT EDIT (digest: 08427847d9f356f6dcae766f4a3bba7a)
Lus2licRun
SocExecValue
SocUtils
......@@ -62,4 +62,5 @@ TopoSort
SortActions
SortActionsExpe
L2lCheckKcgKeyWord
L2lWhenOnId
# OASIS_STOP
# OASIS_START
# DO NOT EDIT (digest: dbb10b1e67d7883ec20936ed84df7d60)
# DO NOT EDIT (digest: 08427847d9f356f6dcae766f4a3bba7a)
Lus2licRun
SocExecValue
SocUtils
......@@ -62,4 +62,5 @@ TopoSort
SortActions
SortActionsExpe
L2lCheckKcgKeyWord
L2lWhenOnId
# OASIS_STOP
(* Time-stamp: <modified the 01/06/2016 (at 17:32) by Erwan Jahier> *)
(* Time-stamp: <modified the 03/06/2016 (at 11:08) by Erwan Jahier> *)
(*
Le manager d'argument adapt de celui de lutin, plus joli
N.B. solution un peu batarde : les options sont stockes, comme avant, dans Global,
......
(** Automatically generated from Makefile *)
let tool = "lus2lic"
let branch = "master"
let commit = "652"
let sha_1 = "0c2759d4df7185de1deb237cd389606154b63b47"
let commit = "653"
let sha_1 = "06e1f9d35436d9720d771ee4584b57b3816f53bc"
let str = (branch ^ "." ^ commit ^ " (" ^ sha_1 ^ ")")
let maintainer = "jahier@imag.fr"
==> lus2lic0.sum <==
Test Run By jahier on Wed Jun 1 17:37:32
Test Run By jahier on Tue Jun 14 15:32:44
Native configuration is x86_64-unknown-linux-gnu
=== lus2lic0 tests ===
......@@ -64,7 +64,7 @@ XFAIL: Test bad programs (assert): test_lus2lic_no_node should_fail/assert/lecte
XFAIL: Test bad programs (assert): test_lus2lic_no_node should_fail/assert/s.lus
==> lus2lic1.sum <==
Test Run By jahier on Wed Jun 1 17:37:36
Test Run By jahier on Tue Jun 14 15:32:44
Native configuration is x86_64-unknown-linux-gnu
=== lus2lic1 tests ===
......@@ -249,6 +249,7 @@ PASS: /home/jahier/lus2lic/test/../utils/compare_exec_and_2c ec.lus {}
PASS: ./lus2lic {-2c enum0.lus -n enum0}
PASS: gcc -o enum0.exec enum0_enum0.c enum0_enum0_loop.c
PASS: /home/jahier/lus2lic/test/../utils/compare_exec_and_2c enum0.lus {}
FAIL: Generate c code : ./lus2lic {-2c enum0_lv4.lus -n enum0_lv4}
PASS: ./lus2lic {-2c ex.lus -n ex}
PASS: gcc -o ex.exec ex_ex.c ex_ex_loop.c
PASS: /home/jahier/lus2lic/test/../utils/compare_exec_and_2c ex.lus {}
......@@ -396,7 +397,7 @@ PASS: gcc -o multipar.exec multipar_multipar.c multipar_multipar_loop.c
PASS: /home/jahier/lus2lic/test/../utils/compare_exec_and_2c multipar.lus {}
==> lus2lic2.sum <==
Test Run By jahier on Wed Jun 1 17:37:32
Test Run By jahier on Tue Jun 14 15:33:01
Native configuration is x86_64-unknown-linux-gnu
=== lus2lic2 tests ===
......@@ -615,6 +616,7 @@ PASS: /home/jahier/lus2lic/test/../utils/compare_exec_and_2c sincos.lus {}
PASS: ./lus2lic --expand-nodes {-2c speedcontrol.lus -n speedcontrol}
PASS: gcc -o speedcontrol.exec speedcontrol_speedcontrol.c speedcontrol_speedcontrol_loop.c
PASS: /home/jahier/lus2lic/test/../utils/compare_exec_and_2c speedcontrol.lus { --expand-nodes}
PASS: ./lus2lic {-2c sqrt.lus -n sqrt}
PASS: ./lus2lic {-2c stopwatch.lus -n stopwatch}
PASS: gcc -o stopwatch.exec stopwatch_stopwatch.c stopwatch_stopwatch_loop.c
PASS: /home/jahier/lus2lic/test/../utils/compare_exec_and_2c stopwatch.lus {}
......@@ -741,7 +743,7 @@ PASS: gcc -o zzz2.exec zzz2_zzz2.c zzz2_zzz2_loop.c
PASS: /home/jahier/lus2lic/test/../utils/compare_exec_and_2c zzz2.lus {}
==> lus2lic3.sum <==
Test Run By jahier on Wed Jun 1 17:37:34
Test Run By jahier on Tue Jun 14 15:33:37
Native configuration is x86_64-unknown-linux-gnu
=== lus2lic3 tests ===
......@@ -1015,6 +1017,9 @@ PASS: /home/jahier/lus2lic/test/../utils/test_lus2lic_no_node ec.lus {}
PASS: ./lus2lic {-o enum0.lic enum0.lus}
PASS: ./lus2lic {-ec -o enum0.ec enum0.lus}
PASS: ./myec2c {-o enum0.c enum0.ec}
PASS: ./lus2lic {-o enum0_lv4.lic enum0_lv4.lus}
PASS: ./lus2lic {-ec -o enum0_lv4.ec enum0_lv4.lus}
FAIL: Try ec2c on the result: ./myec2c {-o enum0_lv4.c enum0_lv4.ec}
PASS: ./lus2lic {-o ex.lic ex.lus}
PASS: ./lus2lic {-ec -o ex.ec ex.lus}
PASS: ./myec2c {-o ex.c ex.ec}
......@@ -1193,6 +1198,7 @@ PASS: ./lus2lic {-o modes3x2_v3.lic modes3x2_v3.lus}
PASS: ./lus2lic {-ec -o modes3x2_v3.ec modes3x2_v3.lus}
PASS: ./lus2lic {-o modes3x2_v4.lic modes3x2_v4.lus}
PASS: ./lus2lic {-ec -o modes3x2_v4.ec modes3x2_v4.lus}
FAIL: without any option: ./lus2lic {-o modes3x2_v4.lv4.lic modes3x2_v4.lv4.lus}
PASS: ./lus2lic {-o morel.lic morel.lus}
PASS: ./lus2lic {-ec -o morel.ec morel.lus}
PASS: ./myec2c {-o morel.c morel.ec}
......@@ -1243,7 +1249,7 @@ PASS: ./myec2c {-o multipar.c multipar.ec}
PASS: /home/jahier/lus2lic/test/../utils/test_lus2lic_no_node multipar.lus {}
==> lus2lic4.sum <==
Test Run By jahier on Wed Jun 1 17:37:34
Test Run By jahier on Tue Jun 14 15:33:49
Native configuration is x86_64-unknown-linux-gnu
=== lus2lic4 tests ===
......@@ -1548,6 +1554,9 @@ PASS: ./lus2lic {-o speedcontrol.lic speedcontrol.lus}
PASS: ./lus2lic {-ec -o speedcontrol.ec speedcontrol.lus}
PASS: ./myec2c {-o speedcontrol.c speedcontrol.ec}
PASS: /home/jahier/lus2lic/test/../utils/test_lus2lic_no_node speedcontrol.lus { --expand-nodes}
PASS: ./lus2lic {-o sqrt.lic sqrt.lus}
PASS: ./lus2lic {-ec -o sqrt.ec sqrt.lus}
PASS: ./myec2c {-o sqrt.c sqrt.ec}
PASS: ./lus2lic {-o stopwatch.lic stopwatch.lus}
PASS: ./lus2lic {-ec -o stopwatch.ec stopwatch.lus}
PASS: ./myec2c {-o stopwatch.c stopwatch.ec}
......@@ -1740,38 +1749,38 @@ PASS: /home/jahier/lus2lic/test/../utils/test_lus2lic_no_node zzz2.lus {}
=== lus2lic1 Summary ===
# of expected passes 315
# of unexpected failures 5
# of unexpected failures 6
==> lus2lic2.sum <==
=== lus2lic2 Summary ===
# of expected passes 330
# of expected passes 331
# of unexpected failures 3
==> lus2lic3.sum <==
=== lus2lic3 Summary ===
# of expected passes 479
# of unexpected failures 11
# of expected passes 481
# of unexpected failures 13
==> lus2lic4.sum <==
=== lus2lic4 Summary ===
# of expected passes 471
# of expected passes 474
# of unexpected failures 4
===============================
# Total number of failures: 23
# Total number of failures: 26
lus2lic0.log:testcase ./lus2lic.tests/test0.exp completed in 0 seconds
lus2lic1.log:testcase ./lus2lic.tests/test1.exp completed in 22 seconds
lus2lic2.log:testcase ./lus2lic.tests/test2.exp completed in 42 seconds
lus2lic3.log:testcase ./lus2lic.tests/test3.exp completed in 16 seconds
lus2lic4.log:testcase ./lus2lic.tests/test4.exp completed in 42 seconds
lus2lic1.log:testcase ./lus2lic.tests/test1.exp completed in 17 seconds
lus2lic2.log:testcase ./lus2lic.tests/test2.exp completed in 36 seconds
lus2lic3.log:testcase ./lus2lic.tests/test3.exp completed in 12 seconds
lus2lic4.log:testcase ./lus2lic.tests/test4.exp completed in 39 seconds
* Ref time:
0.04user 0.04system 1:46.01elapsed 0%CPU (0avgtext+0avgdata 5172maxresident)k
0inputs+0outputs (0major+5554minor)pagefaults 0swaps
0.04user 0.03system 1:44.23elapsed 0%CPU (0avgtext+0avgdata 5148maxresident)k
0inputs+0outputs (0major+5598minor)pagefaults 0swaps
* Quick time (-j 4):
0.05user 0.01system 0:44.35elapsed 0%CPU (0avgtext+0avgdata 5236maxresident)k
64inputs+0outputs (0major+5570minor)pagefaults 0swaps
0.04user 0.01system 0:56.78elapsed 0%CPU (0avgtext+0avgdata 5152maxresident)k
32inputs+0outputs (0major+5619minor)pagefaults 0swaps
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment