diff --git a/src/soc2c.ml b/src/soc2c.ml index 85cb9ba0ad1f4e3a790fcf261c52664b93991b21..b2e47b4adda03813b5cbc9a095671a427c374442 100644 --- a/src/soc2c.ml +++ b/src/soc2c.ml @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 18/06/2014 (at 08:46) by Erwan Jahier> *) +(* Time-stamp: <modified the 18/06/2014 (at 17:53) by Erwan Jahier> *) (* let put (os: out_channel) (fmt:('a, unit, string, unit) format4) : 'a = *) @@ -140,6 +140,7 @@ let (gao2c : Soc.tbl -> 'a soc_pp -> Soc.gao -> unit) = let (step2c : Soc.tbl -> 'a soc_pp -> Soc.step_method -> unit) = fun stbl sp sm -> let sm_str = sm.name in +(* let sname = Soc2cUtil.step_name sp.soc.key sm.name in *) let sname = Soc2cUtil.step_name sp.soc.key sm.name in let ctx = if is_memory_less sp.soc then "" else Printf.sprintf "%s_type* ctx" (get_ctx_name sp.soc.key) @@ -363,7 +364,7 @@ let (gen_loop_file : Soc.t -> unit) = let oc = open_out loopfile in let putc s = output_string oc s in let ctx = get_ctx_name soc.key in - let step = get_step_name soc.key in + let step = Soc2cUtil.step_name soc.key "step" in let (n,_,_) = soc.key in let n = id2s n in Lv6util.entete oc "/*" "*/"; diff --git a/src/soc2cIdent.ml b/src/soc2cIdent.ml index b61716b7675ed446d90f5ddf0e4b118928d82f60..4e6a680d82168f338abcd4120354c270ed50fd42 100644 --- a/src/soc2cIdent.ml +++ b/src/soc2cIdent.ml @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 13/06/2014 (at 16:24) by Erwan Jahier> *) +(* Time-stamp: <modified the 18/06/2014 (at 17:48) by Erwan Jahier> *) let colcol = Str.regexp "::" let id2s id = (* XXX Refuser les noms de module à la con plutot *) @@ -42,13 +42,21 @@ let rec (type_to_short_string : Data.t -> string) = in str +let (key_op2str : Soc.key_opt -> string) = function + | Nomore -> "" + | Slic(b,e,s) -> Printf.sprintf "_slice_%d_%d_%d" b e s + | MemInit(var_expr) -> "_" ^ + (* XXX This is wrong !!! *) + (string_of_int (Hashtbl.hash var_expr)) + + let (get_base_name : Soc.key -> string) = - fun (name,tl,_) -> + fun (name,tl,opt) -> let l = List.map type_to_short_string tl in - (id2s (Printf.sprintf "%s_%s" (id2s name) (String.concat "" l))) + (id2s (Printf.sprintf "%s_%s%s" (id2s name) (String.concat "" l) (key_op2str opt))) let (get_ctx_name : Soc.key -> string) = fun sk -> (get_base_name sk) ^ "_ctx" -let (get_step_name : Soc.key -> string) = - fun sk -> (get_base_name sk) ^ "_step" +let (get_soc_name : Soc.key -> string) = + fun sk -> (get_base_name sk) diff --git a/src/soc2cUtil.ml b/src/soc2cUtil.ml index d0685e82feedb7318d0509e276d3c54e6a1c77a3..295d4b643b5b3a907f10af19ef5c5aba34df728d 100644 --- a/src/soc2cUtil.ml +++ b/src/soc2cUtil.ml @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 18/06/2014 (at 08:30) by Erwan Jahier> *) +(* Time-stamp: <modified the 18/06/2014 (at 17:48) by Erwan Jahier> *) (* exported *) @@ -23,9 +23,8 @@ let rec (gen_assign : Data.t -> string -> string -> string) = let id2s = Soc2cIdent.id2s let (step_name : Soc.key -> string -> string) = - fun (soc_name,tl,_) sm -> - let l = List.map Soc2cIdent.type_to_short_string tl in - let str = Printf.sprintf "%s_%s_%s" (id2s soc_name) (String.concat "" l) sm in + fun sk sm -> + let str = Printf.sprintf "%s_%s" (Soc2cIdent.get_soc_name sk) sm in id2s str diff --git a/src/socPredef2c.ml b/src/socPredef2c.ml index 09b4bc3bddbf79d534c5149926976ee778594869..1218be251eb0767cd02ee19698f7c3c998725462 100644 --- a/src/socPredef2c.ml +++ b/src/socPredef2c.ml @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 18/06/2014 (at 14:06) by Erwan Jahier> *) +(* Time-stamp: <modified the 18/06/2014 (at 18:24) by Erwan Jahier> *) open Data open Soc @@ -89,10 +89,10 @@ let (lustre_concat: Soc.key -> string) = | [Data.Array(t,s1); Data.Array(_,s2); _] -> t,s1,s2 | _ -> assert false in - let t1 = Printf.sprintf "%s.x" ctx - and t2 = Printf.sprintf "%s.y" ctx - and t12 = Printf.sprintf "%s.z" ctx in - (Printf.sprintf " memcpy(%s, %s, sizeof(%s));\n" t12 t1 t1)^ + let t1 = Printf.sprintf "%s.x" ctx + and t2 = Printf.sprintf "%s.y" ctx + and t12 = Printf.sprintf "%s.z" ctx in + (Printf.sprintf " memcpy(%s, %s, sizeof(%s));\n" t12 t1 t1)^ (Printf.sprintf " memcpy(%s[%d], %s, sizeof(%s));\n" t12 s1 t2 t2) (* Both seems to work *) (* let buff = ref "" in *) @@ -107,9 +107,24 @@ let (lustre_concat: Soc.key -> string) = (* !buff *) let (lustre_slice: Soc.key -> string) = - fun sk -> - let ctx = get_ctx_name sk in - assert false + fun (n,tl,si_opt) -> + let ctx = get_ctx_name (n,tl,si_opt) in + let t,size = match List.hd (List.rev tl) with + | Data.Array(t,i) -> t,i + | _ -> assert false + in + match si_opt with + | Slic(b,e,step) -> + let buff = ref "" in + let j=ref 0 in + for i = b to e do + if (i-b) mod step = 0 then ( + buff := !buff^(Soc2cUtil.gen_assign t (Printf.sprintf "%s.z[%d]" ctx !j) + (Printf.sprintf "%s.x[%d]" ctx i)); + incr j); + done; + !buff + | _ -> assert false diff --git a/test/lus2lic.sum b/test/lus2lic.sum index c8306bd0f84a56d8e99167e172f7eb0c97816309..b2a6b21fccb564803dca790b5fae4b9d4ff2e41c 100644 --- a/test/lus2lic.sum +++ b/test/lus2lic.sum @@ -1,4 +1,4 @@ -Test Run By jahier on Wed Jun 18 14:08:00 2014 +Test Run By jahier on Wed Jun 18 18:25:10 2014 Native configuration is i686-pc-linux-gnu === lus2lic tests === @@ -93,8 +93,8 @@ PASS: ./lus2lic {-o /tmp/t0.lic should_work/t0.lus} PASS: ./lus2lic {-ec -o /tmp/t0.ec should_work/t0.lus} PASS: ./myec2c {-o /tmp/t0.c /tmp/t0.ec} PASS: ../utils/test_lus2lic_no_node should_work/t0.lus -FAIL: Generate c code : ./lus2lic {-2c should_work/t0.lus -n t0} -FAIL: Check that the generated C code compiles : gcc t0_t0.c t0_t0_loop.c +PASS: ./lus2lic {-2c should_work/t0.lus -n t0} +PASS: gcc t0_t0.c t0_t0_loop.c PASS: ./lus2lic {-o /tmp/lucky.lic should_work/lucky.lus} PASS: ./lus2lic {-ec -o /tmp/lucky.ec should_work/lucky.lus} PASS: ./myec2c {-o /tmp/lucky.c /tmp/lucky.ec} @@ -129,14 +129,14 @@ PASS: ./lus2lic {-o /tmp/access.lic should_work/access.lus} PASS: ./lus2lic {-ec -o /tmp/access.ec should_work/access.lus} PASS: ./myec2c {-o /tmp/access.c /tmp/access.ec} PASS: ../utils/test_lus2lic_no_node should_work/access.lus -FAIL: Generate c code : ./lus2lic {-2c should_work/access.lus -n access} -FAIL: Check that the generated C code compiles : gcc access_access.c access_access_loop.c +PASS: ./lus2lic {-2c should_work/access.lus -n access} +PASS: gcc access_access.c access_access_loop.c PASS: ./lus2lic {-o /tmp/consensus2.lic should_work/consensus2.lus} PASS: ./lus2lic {-ec -o /tmp/consensus2.ec should_work/consensus2.lus} PASS: ./myec2c {-o /tmp/consensus2.c /tmp/consensus2.ec} PASS: ../utils/test_lus2lic_no_node should_work/consensus2.lus -FAIL: Generate c code : ./lus2lic {-2c should_work/consensus2.lus -n consensus2} -FAIL: Check that the generated C code compiles : gcc consensus2_consensus2.c consensus2_consensus2_loop.c +PASS: ./lus2lic {-2c should_work/consensus2.lus -n consensus2} +PASS: gcc consensus2_consensus2.c consensus2_consensus2_loop.c PASS: ./lus2lic {-o /tmp/dependeur.lic should_work/dependeur.lus} PASS: ./lus2lic {-ec -o /tmp/dependeur.ec should_work/dependeur.lus} PASS: ./myec2c {-o /tmp/dependeur.c /tmp/dependeur.ec} @@ -206,8 +206,8 @@ PASS: ./lus2lic {-o /tmp/t1.lic should_work/t1.lus} PASS: ./lus2lic {-ec -o /tmp/t1.ec should_work/t1.lus} PASS: ./myec2c {-o /tmp/t1.c /tmp/t1.ec} PASS: ../utils/test_lus2lic_no_node should_work/t1.lus -FAIL: Generate c code : ./lus2lic {-2c should_work/t1.lus -n t1} -FAIL: Check that the generated C code compiles : gcc t1_t1.c t1_t1_loop.c +PASS: ./lus2lic {-2c should_work/t1.lus -n t1} +PASS: gcc t1_t1.c t1_t1_loop.c PASS: ./lus2lic {-o /tmp/nc9.lic should_work/nc9.lus} PASS: ./lus2lic {-ec -o /tmp/nc9.ec should_work/nc9.lus} PASS: ./myec2c {-o /tmp/nc9.c /tmp/nc9.ec} @@ -725,8 +725,8 @@ PASS: ./lus2lic {-o /tmp/t2.lic should_work/t2.lus} PASS: ./lus2lic {-ec -o /tmp/t2.ec should_work/t2.lus} PASS: ./myec2c {-o /tmp/t2.c /tmp/t2.ec} PASS: ../utils/test_lus2lic_no_node should_work/t2.lus -FAIL: Generate c code : ./lus2lic {-2c should_work/t2.lus -n t2} -FAIL: Check that the generated C code compiles : gcc t2_t2.c t2_t2_loop.c +PASS: ./lus2lic {-2c should_work/t2.lus -n t2} +PASS: gcc t2_t2.c t2_t2_loop.c PASS: ./lus2lic {-o /tmp/arbitre.lic should_work/arbitre.lus} PASS: ./lus2lic {-ec -o /tmp/arbitre.ec should_work/arbitre.lus} FAIL: Try ec2c on the result: ./myec2c {-o /tmp/arbitre.c /tmp/arbitre.ec} @@ -891,8 +891,8 @@ PASS: ./lus2lic {-o /tmp/consensus.lic should_work/consensus.lus} PASS: ./lus2lic {-ec -o /tmp/consensus.ec should_work/consensus.lus} PASS: ./myec2c {-o /tmp/consensus.c /tmp/consensus.ec} PASS: ../utils/test_lus2lic_no_node should_work/consensus.lus -FAIL: Generate c code : ./lus2lic {-2c should_work/consensus.lus -n consensus} -FAIL: Check that the generated C code compiles : gcc consensus_consensus.c consensus_consensus_loop.c +PASS: ./lus2lic {-2c should_work/consensus.lus -n consensus} +PASS: gcc consensus_consensus.c consensus_consensus_loop.c PASS: ./lus2lic {-o /tmp/activation2.lic should_work/activation2.lus} PASS: ./lus2lic {-ec -o /tmp/activation2.ec should_work/activation2.lus} PASS: ./myec2c {-o /tmp/activation2.c /tmp/activation2.ec} @@ -1040,7 +1040,7 @@ PASS: ./lus2lic {-o /tmp/filliter.lic should_work/filliter.lus} PASS: ./lus2lic {-ec -o /tmp/filliter.ec should_work/filliter.lus} PASS: ./myec2c {-o /tmp/filliter.c /tmp/filliter.ec} FAIL: Try to compare lus2lic -exec and ecexe: ../utils/test_lus2lic_no_node should_work/filliter.lus -FAIL: Generate c code : ./lus2lic {-2c should_work/filliter.lus -n filliter} +PASS: ./lus2lic {-2c should_work/filliter.lus -n filliter} FAIL: Check that the generated C code compiles : gcc filliter_filliter.c filliter_filliter_loop.c PASS: ./lus2lic {-o /tmp/minmax4.lic should_work/minmax4.lus} PASS: ./lus2lic {-ec -o /tmp/minmax4.ec should_work/minmax4.lus} @@ -1479,9 +1479,9 @@ XPASS: Test bad programs (semantics): lus2lic {-o /tmp/bug.lic should_fail/seman === lus2lic Summary === -# of expected passes 1234 -# of unexpected failures 175 +# of expected passes 1247 +# of unexpected failures 162 # of unexpected successes 21 # of expected failures 37 -testcase ./lus2lic.tests/non-reg.exp completed in 129 seconds +testcase ./lus2lic.tests/non-reg.exp completed in 125 seconds testcase ./lus2lic.tests/progression.exp completed in 0 seconds diff --git a/test/lus2lic.time b/test/lus2lic.time index b771258b27d419d55d4c949273a79842020ac0d2..5bc3104514c77e7f8701fc1c04744382a2887f03 100644 --- a/test/lus2lic.time +++ b/test/lus2lic.time @@ -1,2 +1,2 @@ -testcase ./lus2lic.tests/non-reg.exp completed in 129 seconds +testcase ./lus2lic.tests/non-reg.exp completed in 125 seconds testcase ./lus2lic.tests/progression.exp completed in 0 seconds