From f944d93d0b04b6855951c420741686debbe2b0c6 Mon Sep 17 00:00:00 2001 From: Erwan Jahier <jahier@imag.fr> Date: Fri, 6 Jun 2014 09:50:28 +0200 Subject: [PATCH] Soc2c : avoid multiple soc typedef definition in the C code. Indeed, Soc with memory can be used several times; hence we mark the set of visited soc while printing the soc typedef. of expected passes 1052 -> 1073 of unexpected failures 346 -> 325 --- src/soc2c.ml | 34 ++++++++++++++++++++------------ test/lus2lic.sum | 50 +++++++++++++++++++++++------------------------ test/lus2lic.time | 2 +- 3 files changed, 47 insertions(+), 39 deletions(-) diff --git a/src/soc2c.ml b/src/soc2c.ml index 8f9175c2..76f2aedd 100644 --- a/src/soc2c.ml +++ b/src/soc2c.ml @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 05/06/2014 (at 11:26) by Erwan Jahier> *) +(* Time-stamp: <modified the 06/06/2014 (at 09:43) by Erwan Jahier> *) (* let put (os: out_channel) (fmt:('a, unit, string, unit) format4) : 'a = *) @@ -213,8 +213,8 @@ let (type_to_format_string : Data.t -> string) = | Real-> "%g" | Extern s -> assert false | Enum (s, sl) -> "%d" - | Struct (sid,_) -> assert false - | Array (ty, sz) -> assert false + | Struct (sid,_) -> "%s" + | Array (ty, sz) -> "%s" | Alpha nb -> assert false (****************************************************************************) @@ -271,23 +271,30 @@ let (typedef_of_soc : Soc.t -> string) = let str = Printf.sprintf "%s} %s;\n\n" str ctx_name_type in str +module KeySet = Set.Make(struct type t = Soc.key let compare = compare end) + let (typedef : LicPrg.t -> Soc.tbl -> Soc.t -> string) = fun licprg soc_tbl main_soc -> (* We need to print the ctx typedef a good order (w.r.t. typedef dependancies). To do that, we traverse the tree of soc instances which root is the main soc. *) - let rec (soc_with_mem : string -> Soc.t -> string) = - fun acc soc -> - let acc = (typedef_of_soc soc) ^ acc in - List.fold_left - (fun acc (iname, sk) -> - let soc = SocUtils.find_no_exc sk soc_tbl in - soc_with_mem acc soc - ) - acc soc.instances + let visited = KeySet.empty in + (* Soc with memory can be used several times; hence we mark via this + set the ones that have already been visited. *) + let rec (soc_with_mem : string * KeySet.t -> Soc.t -> string* KeySet.t) = + fun (acc,visited) soc -> + if KeySet.mem soc.key visited then (acc,visited) else + let visited = KeySet.add soc.key visited in + let acc = (typedef_of_soc soc) ^ acc in + List.fold_left + (fun (acc,visited) (iname, sk) -> + let soc = SocUtils.find_no_exc sk soc_tbl in + soc_with_mem (acc,visited) soc + ) + (acc,visited) soc.instances in let soc_ctx_typedef_with = - if is_memory_less main_soc then "" else soc_with_mem "" main_soc + if is_memory_less main_soc then "" else fst (soc_with_mem ("",visited) main_soc) in (* Then we still have to print memoryless soc that can not appear as a soc instance *) @@ -481,6 +488,7 @@ int main(){ ++s; "); let inputs,outputs = soc.profile in + (* XXX do something for arrays and struct ! *) List.iter (fun (id,t) -> let t = Data.type_to_string t in let str = Printf.sprintf " ctx->%s = _get_%s(\"%s\");\n" id t id in diff --git a/test/lus2lic.sum b/test/lus2lic.sum index 90ddcbc0..c2c11026 100644 --- a/test/lus2lic.sum +++ b/test/lus2lic.sum @@ -1,4 +1,4 @@ -Test Run By jahier on Thu Jun 5 11:32:09 2014 +Test Run By jahier on Fri Jun 6 09:44:19 2014 Native configuration is i686-pc-linux-gnu === lus2lic tests === @@ -70,7 +70,7 @@ PASS: ./lus2lic {-ec -o /tmp/dep.ec should_work/dep.lus} PASS: ./myec2c {-o /tmp/dep.c /tmp/dep.ec} PASS: ../utils/test_lus2lic_no_node should_work/dep.lus PASS: ./lus2lic {-2c should_work/dep.lus -n dep} -FAIL: Check that the generated C code compiles : gcc dep_dep.c dep_dep_loop.c +PASS: gcc dep_dep.c dep_dep_loop.c PASS: ./lus2lic {-o /tmp/ELMU.lic should_work/ELMU.lus} PASS: ./lus2lic {-ec -o /tmp/ELMU.ec should_work/ELMU.lus} PASS: ./myec2c {-o /tmp/ELMU.c /tmp/ELMU.ec} @@ -234,7 +234,7 @@ PASS: ./lus2lic {-o /tmp/mm1.lic should_work/mm1.lus} PASS: ./lus2lic {-ec -o /tmp/mm1.ec should_work/mm1.lus} PASS: ./myec2c {-o /tmp/mm1.c /tmp/mm1.ec} PASS: ../utils/test_lus2lic_no_node should_work/mm1.lus -FAIL: Generate c code : ./lus2lic {-2c should_work/mm1.lus -n mm1} +PASS: ./lus2lic {-2c should_work/mm1.lus -n mm1} FAIL: Check that the generated C code compiles : gcc mm1_mm1.c mm1_mm1_loop.c PASS: ./lus2lic {-o /tmp/predef03.lic should_work/predef03.lus} PASS: ./lus2lic {-ec -o /tmp/predef03.ec should_work/predef03.lus} @@ -275,7 +275,7 @@ PASS: ./lus2lic {-o /tmp/test_node_expand2.lic should_work/test_node_expand2.lus PASS: ./lus2lic {-ec -o /tmp/test_node_expand2.ec should_work/test_node_expand2.lus} PASS: ./myec2c {-o /tmp/test_node_expand2.c /tmp/test_node_expand2.ec} FAIL: Try to compare lus2lic -exec and ecexe: ../utils/test_lus2lic_no_node should_work/test_node_expand2.lus -FAIL: Generate c code : ./lus2lic {-2c should_work/test_node_expand2.lus -n test_node_expand2} +PASS: ./lus2lic {-2c should_work/test_node_expand2.lus -n test_node_expand2} FAIL: Check that the generated C code compiles : gcc test_node_expand2_test_node_expand2.c test_node_expand2_test_node_expand2_loop.c PASS: ./lus2lic {-o /tmp/test.lic should_work/test.lus} PASS: ./lus2lic {-ec -o /tmp/test.ec should_work/test.lus} @@ -341,7 +341,7 @@ PASS: ./lus2lic {-ec -o /tmp/double_delay.ec should_work/double_delay.lus} PASS: ./myec2c {-o /tmp/double_delay.c /tmp/double_delay.ec} PASS: ../utils/test_lus2lic_no_node should_work/double_delay.lus PASS: ./lus2lic {-2c should_work/double_delay.lus -n double_delay} -FAIL: Check that the generated C code compiles : gcc double_delay_double_delay.c double_delay_double_delay_loop.c +PASS: gcc double_delay_double_delay.c double_delay_double_delay_loop.c PASS: ./lus2lic {-o /tmp/modes3x2-v2.lic should_work/modes3x2-v2.lus} PASS: ./lus2lic {-ec -o /tmp/modes3x2-v2.ec should_work/modes3x2-v2.lus} PASS: ./myec2c {-o /tmp/modes3x2-v2.c /tmp/modes3x2-v2.ec} @@ -351,7 +351,7 @@ PASS: ./lus2lic {-o /tmp/struct_with.lic should_work/struct_with.lus} PASS: ./lus2lic {-ec -o /tmp/struct_with.ec should_work/struct_with.lus} PASS: ./myec2c {-o /tmp/struct_with.c /tmp/struct_with.ec} PASS: ../utils/test_lus2lic_no_node should_work/struct_with.lus -FAIL: Generate c code : ./lus2lic {-2c should_work/struct_with.lus -n struct_with} +PASS: ./lus2lic {-2c should_work/struct_with.lus -n struct_with} FAIL: Check that the generated C code compiles : gcc struct_with_struct_with.c struct_with_struct_with_loop.c PASS: ./lus2lic {-o /tmp/test_node_expand.lic should_work/test_node_expand.lus} PASS: ./lus2lic {-ec -o /tmp/test_node_expand.ec should_work/test_node_expand.lus} @@ -363,7 +363,7 @@ PASS: ./lus2lic {-o /tmp/mm22.lic should_work/mm22.lus} PASS: ./lus2lic {-ec -o /tmp/mm22.ec should_work/mm22.lus} PASS: ./myec2c {-o /tmp/mm22.c /tmp/mm22.ec} PASS: ../utils/test_lus2lic_no_node should_work/mm22.lus -FAIL: Generate c code : ./lus2lic {-2c should_work/mm22.lus -n mm22} +PASS: ./lus2lic {-2c should_work/mm22.lus -n mm22} FAIL: Check that the generated C code compiles : gcc mm22_mm22.c mm22_mm22_loop.c PASS: ./lus2lic {-o /tmp/is_stable.lic should_work/is_stable.lus} PASS: ./lus2lic {-ec -o /tmp/is_stable.ec should_work/is_stable.lus} @@ -397,7 +397,7 @@ PASS: ./lus2lic {-o /tmp/zzz2.lic should_work/zzz2.lus} PASS: ./lus2lic {-ec -o /tmp/zzz2.ec should_work/zzz2.lus} PASS: ./myec2c {-o /tmp/zzz2.c /tmp/zzz2.ec} PASS: ../utils/test_lus2lic_no_node should_work/zzz2.lus -FAIL: Generate c code : ./lus2lic {-2c should_work/zzz2.lus -n zzz2} +PASS: ./lus2lic {-2c should_work/zzz2.lus -n zzz2} FAIL: Check that the generated C code compiles : gcc zzz2_zzz2.c zzz2_zzz2_loop.c PASS: ./lus2lic {-o /tmp/polymorphic_pack.lic should_work/polymorphic_pack.lus} PASS: ./lus2lic {-ec -o /tmp/polymorphic_pack.ec should_work/polymorphic_pack.lus} @@ -502,7 +502,7 @@ PASS: ./lus2lic {-ec -o /tmp/sincos.ec should_work/sincos.lus} PASS: ./myec2c {-o /tmp/sincos.c /tmp/sincos.ec} FAIL: Try to compare lus2lic -exec and ecexe: ../utils/test_lus2lic_no_node should_work/sincos.lus PASS: ./lus2lic {-2c should_work/sincos.lus -n sincos} -FAIL: Check that the generated C code compiles : gcc sincos_sincos.c sincos_sincos_loop.c +PASS: gcc sincos_sincos.c sincos_sincos_loop.c PASS: ./lus2lic {-o /tmp/newpacks.lic should_work/newpacks.lus} PASS: ./lus2lic {-ec -o /tmp/newpacks.ec should_work/newpacks.lus} PASS: ./myec2c {-o /tmp/newpacks.c /tmp/newpacks.ec} @@ -512,7 +512,7 @@ PASS: ./lus2lic {-o /tmp/morel5.lic should_work/morel5.lus} PASS: ./lus2lic {-ec -o /tmp/morel5.ec should_work/morel5.lus} PASS: ./myec2c {-o /tmp/morel5.c /tmp/morel5.ec} PASS: ../utils/test_lus2lic_no_node should_work/morel5.lus -FAIL: Generate c code : ./lus2lic {-2c should_work/morel5.lus -n morel5} +PASS: ./lus2lic {-2c should_work/morel5.lus -n morel5} FAIL: Check that the generated C code compiles : gcc morel5_morel5.c morel5_morel5_loop.c PASS: ./lus2lic {-o /tmp/bred.lic should_work/bred.lus} PASS: ./lus2lic {-ec -o /tmp/bred.ec should_work/bred.lus} @@ -624,7 +624,7 @@ PASS: ./lus2lic {-ec -o /tmp/integrator.ec should_work/integrator.lus} PASS: ./myec2c {-o /tmp/integrator.c /tmp/integrator.ec} FAIL: Try to compare lus2lic -exec and ecexe: ../utils/test_lus2lic_no_node should_work/integrator.lus PASS: ./lus2lic {-2c should_work/integrator.lus -n integrator} -FAIL: Check that the generated C code compiles : gcc integrator_integrator.c integrator_integrator_loop.c +PASS: gcc integrator_integrator.c integrator_integrator_loop.c PASS: ./lus2lic {-o /tmp/nc4.lic should_work/nc4.lus} PASS: ./lus2lic {-ec -o /tmp/nc4.ec should_work/nc4.lus} PASS: ./myec2c {-o /tmp/nc4.c /tmp/nc4.ec} @@ -635,7 +635,7 @@ PASS: ./lus2lic {-o /tmp/mm3.lic should_work/mm3.lus} PASS: ./lus2lic {-ec -o /tmp/mm3.ec should_work/mm3.lus} PASS: ./myec2c {-o /tmp/mm3.c /tmp/mm3.ec} PASS: ../utils/test_lus2lic_no_node should_work/mm3.lus -FAIL: Generate c code : ./lus2lic {-2c should_work/mm3.lus -n mm3} +PASS: ./lus2lic {-2c should_work/mm3.lus -n mm3} FAIL: Check that the generated C code compiles : gcc mm3_mm3.c mm3_mm3_loop.c PASS: ./lus2lic {-o /tmp/over2.lic should_work/over2.lus} PASS: ./lus2lic {-ec -o /tmp/over2.ec should_work/over2.lus} @@ -653,7 +653,7 @@ PASS: ./lus2lic {-o /tmp/complex.lic should_work/complex.lus} PASS: ./lus2lic {-ec -o /tmp/complex.ec should_work/complex.lus} PASS: ./myec2c {-o /tmp/complex.c /tmp/complex.ec} FAIL: Try to compare lus2lic -exec and ecexe: ../utils/test_lus2lic_no_node should_work/complex.lus -FAIL: Generate c code : ./lus2lic {-2c should_work/complex.lus -n complex} +PASS: ./lus2lic {-2c should_work/complex.lus -n complex} FAIL: Check that the generated C code compiles : gcc complex_complex.c complex_complex_loop.c PASS: ./lus2lic {-o /tmp/initial.lic should_work/initial.lus} PASS: ./lus2lic {-ec -o /tmp/initial.ec should_work/initial.lus} @@ -726,7 +726,7 @@ PASS: ./lus2lic {-o /tmp/test_const.lic should_work/test_const.lus} PASS: ./lus2lic {-ec -o /tmp/test_const.ec should_work/test_const.lus} PASS: ./myec2c {-o /tmp/test_const.c /tmp/test_const.ec} PASS: ../utils/test_lus2lic_no_node should_work/test_const.lus -FAIL: Generate c code : ./lus2lic {-2c should_work/test_const.lus -n test_const} +PASS: ./lus2lic {-2c should_work/test_const.lus -n test_const} FAIL: Check that the generated C code compiles : gcc test_const_test_const.c test_const_test_const_loop.c PASS: ./lus2lic {-o /tmp/when_tuple.lic should_work/when_tuple.lus} PASS: ./lus2lic {-ec -o /tmp/when_tuple.ec should_work/when_tuple.lus} @@ -894,7 +894,7 @@ PASS: ./lus2lic {-o /tmp/type_decl.lic should_work/type_decl.lus} PASS: ./lus2lic {-ec -o /tmp/type_decl.ec should_work/type_decl.lus} PASS: ./myec2c {-o /tmp/type_decl.c /tmp/type_decl.ec} PASS: ../utils/test_lus2lic_no_node should_work/type_decl.lus -FAIL: Generate c code : ./lus2lic {-2c should_work/type_decl.lus -n type_decl} +PASS: ./lus2lic {-2c should_work/type_decl.lus -n type_decl} FAIL: Check that the generated C code compiles : gcc type_decl_type_decl.c type_decl_type_decl_loop.c PASS: ./lus2lic {-o /tmp/import1.lic should_work/import1.lus} PASS: ./lus2lic {-ec -o /tmp/import1.ec should_work/import1.lus} @@ -935,7 +935,7 @@ PASS: ./lus2lic {-o /tmp/contractForElementSelectionInArray.lic should_work/cont PASS: ./lus2lic {-ec -o /tmp/contractForElementSelectionInArray.ec should_work/contractForElementSelectionInArray.lus} PASS: ./myec2c {-o /tmp/contractForElementSelectionInArray.c /tmp/contractForElementSelectionInArray.ec} PASS: ../utils/test_lus2lic_no_node should_work/contractForElementSelectionInArray.lus -FAIL: Generate c code : ./lus2lic {-2c should_work/contractForElementSelectionInArray.lus -n contractForElementSelectionInArray} +PASS: ./lus2lic {-2c should_work/contractForElementSelectionInArray.lus -n contractForElementSelectionInArray} FAIL: Check that the generated C code compiles : gcc contractForElementSelectionInArray_contractForElementSelectionInArray.c contractForElementSelectionInArray_contractForElementSelectionInArray_loop.c PASS: ./lus2lic {-o /tmp/iterFibo.lic should_work/iterFibo.lus} PASS: ./lus2lic {-ec -o /tmp/iterFibo.ec should_work/iterFibo.lus} @@ -1023,7 +1023,7 @@ PASS: ./lus2lic {-o /tmp/struct0.lic should_work/struct0.lus} PASS: ./lus2lic {-ec -o /tmp/struct0.ec should_work/struct0.lus} PASS: ./myec2c {-o /tmp/struct0.c /tmp/struct0.ec} PASS: ../utils/test_lus2lic_no_node should_work/struct0.lus -FAIL: Generate c code : ./lus2lic {-2c should_work/struct0.lus -n struct0} +PASS: ./lus2lic {-2c should_work/struct0.lus -n struct0} FAIL: Check that the generated C code compiles : gcc struct0_struct0.c struct0_struct0_loop.c PASS: ./lus2lic {-o /tmp/filliter.lic should_work/filliter.lus} PASS: ./lus2lic {-ec -o /tmp/filliter.ec should_work/filliter.lus} @@ -1081,7 +1081,7 @@ PASS: ./lus2lic {-o /tmp/dependeur_struct.lic should_work/dependeur_struct.lus} PASS: ./lus2lic {-ec -o /tmp/dependeur_struct.ec should_work/dependeur_struct.lus} PASS: ./myec2c {-o /tmp/dependeur_struct.c /tmp/dependeur_struct.ec} PASS: ../utils/test_lus2lic_no_node should_work/dependeur_struct.lus -FAIL: Generate c code : ./lus2lic {-2c should_work/dependeur_struct.lus -n dependeur_struct} +PASS: ./lus2lic {-2c should_work/dependeur_struct.lus -n dependeur_struct} FAIL: Check that the generated C code compiles : gcc dependeur_struct_dependeur_struct.c dependeur_struct_dependeur_struct_loop.c PASS: ./lus2lic {-o /tmp/minmax4_bis.lic should_work/minmax4_bis.lus} PASS: ./lus2lic {-ec -o /tmp/minmax4_bis.ec should_work/minmax4_bis.lus} @@ -1093,7 +1093,7 @@ PASS: ./lus2lic {-o /tmp/test_struct.lic should_work/test_struct.lus} PASS: ./lus2lic {-ec -o /tmp/test_struct.ec should_work/test_struct.lus} PASS: ./myec2c {-o /tmp/test_struct.c /tmp/test_struct.ec} PASS: ../utils/test_lus2lic_no_node should_work/test_struct.lus -FAIL: Generate c code : ./lus2lic {-2c should_work/test_struct.lus -n test_struct} +PASS: ./lus2lic {-2c should_work/test_struct.lus -n test_struct} FAIL: Check that the generated C code compiles : gcc test_struct_test_struct.c test_struct_test_struct_loop.c PASS: ./lus2lic {-o /tmp/uu.lic should_work/uu.lus} PASS: ./lus2lic {-ec -o /tmp/uu.ec should_work/uu.lus} @@ -1147,7 +1147,7 @@ PASS: ./lus2lic {-o /tmp/hanane.lic should_work/hanane.lus} PASS: ./lus2lic {-ec -o /tmp/hanane.ec should_work/hanane.lus} PASS: ./myec2c {-o /tmp/hanane.c /tmp/hanane.ec} FAIL: Try to compare lus2lic -exec and ecexe: ../utils/test_lus2lic_no_node should_work/hanane.lus -FAIL: Generate c code : ./lus2lic {-2c should_work/hanane.lus -n hanane} +PASS: ./lus2lic {-2c should_work/hanane.lus -n hanane} FAIL: Check that the generated C code compiles : gcc hanane_hanane.c hanane_hanane_loop.c PASS: ./lus2lic {-o /tmp/lustre.lic should_work/lustre.lus} PASS: ./lus2lic {-ec -o /tmp/lustre.ec should_work/lustre.lus} @@ -1187,7 +1187,7 @@ PASS: ./lus2lic {-o /tmp/zzz.lic should_work/zzz.lus} PASS: ./lus2lic {-ec -o /tmp/zzz.ec should_work/zzz.lus} PASS: ./myec2c {-o /tmp/zzz.c /tmp/zzz.ec} PASS: ../utils/test_lus2lic_no_node should_work/zzz.lus -FAIL: Generate c code : ./lus2lic {-2c should_work/zzz.lus -n zzz} +PASS: ./lus2lic {-2c should_work/zzz.lus -n zzz} FAIL: Check that the generated C code compiles : gcc zzz_zzz.c zzz_zzz_loop.c PASS: ./lus2lic {-o /tmp/STABLE.lic should_work/STABLE.lus} PASS: ./lus2lic {-ec -o /tmp/STABLE.ec should_work/STABLE.lus} @@ -1379,7 +1379,7 @@ PASS: ./lus2lic {-o /tmp/simple.lic should_work/simple.lus} PASS: ./lus2lic {-ec -o /tmp/simple.ec should_work/simple.lus} PASS: ./myec2c {-o /tmp/simple.c /tmp/simple.ec} FAIL: Try to compare lus2lic -exec and ecexe: ../utils/test_lus2lic_no_node should_work/simple.lus -FAIL: Generate c code : ./lus2lic {-2c should_work/simple.lus -n simple} +PASS: ./lus2lic {-2c should_work/simple.lus -n simple} FAIL: Check that the generated C code compiles : gcc simple_simple.c simple_simple_loop.c PASS: ./lus2lic {-o /tmp/func_with_body.lic should_work/func_with_body.lus} PASS: ./lus2lic {-ec -o /tmp/func_with_body.ec should_work/func_with_body.lus} @@ -1468,9 +1468,9 @@ XPASS: Test bad programs (semantics): lus2lic {-o /tmp/bug.lic should_fail/seman === lus2lic Summary === -# of expected passes 1052 -# of unexpected failures 346 +# of expected passes 1073 +# of unexpected failures 325 # of unexpected successes 21 # of expected failures 37 -testcase ./lus2lic.tests/non-reg.exp completed in 120 seconds +testcase ./lus2lic.tests/non-reg.exp completed in 118 seconds testcase ./lus2lic.tests/progression.exp completed in 0 seconds diff --git a/test/lus2lic.time b/test/lus2lic.time index b44d39a9..8501891b 100644 --- a/test/lus2lic.time +++ b/test/lus2lic.time @@ -1,2 +1,2 @@ -testcase ./lus2lic.tests/non-reg.exp completed in 120 seconds +testcase ./lus2lic.tests/non-reg.exp completed in 118 seconds testcase ./lus2lic.tests/progression.exp completed in 0 seconds -- GitLab