From 8260d857ddbe14efe0df694a0657434f70201027 Mon Sep 17 00:00:00 2001 From: Erwan Jahier <jahier@imag.fr> Date: Fri, 13 Jun 2014 15:05:27 +0200 Subject: [PATCH] Soc2c : handle array concat expressions. --- src/socPredef2c.ml | 29 +++++++++++++++++++++++------ test/lus2lic.sum | 23 ++++++++++++++--------- test/lus2lic.time | 2 +- test/should_work/array_concat.lus | 5 +++++ test/should_work/array_concat2.lus | 5 +++++ test/should_work/trivial_array.lus | 4 ++-- 6 files changed, 50 insertions(+), 18 deletions(-) create mode 100644 test/should_work/array_concat.lus create mode 100644 test/should_work/array_concat2.lus diff --git a/src/socPredef2c.ml b/src/socPredef2c.ml index 244e2fc5..53da07b8 100644 --- a/src/socPredef2c.ml +++ b/src/socPredef2c.ml @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 12/06/2014 (at 11:11) by Erwan Jahier> *) +(* Time-stamp: <modified the 13/06/2014 (at 15:34) by Erwan Jahier> *) open Data open Soc @@ -81,13 +81,30 @@ let (lustre_array: Soc.key -> string) = (Printf.sprintf "%s.x%d" ctx (j+1))); done; !buff - - let (lustre_concat: 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,s1,s2 = match tl with + | [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)^ + (Printf.sprintf " memcpy(%s[%d], %s, sizeof(%s));\n" t12 s1 t2 t2) +(* Both seems to work *) +(* let buff = ref "" in *) +(* for j=0 to s1-1 do *) +(* buff := !buff^(Soc2cUtil.gen_assign t (Printf.sprintf "%s.z[%d]" ctx j) *) +(* (Printf.sprintf "%s.x[%d]" ctx j)); *) +(* done; *) +(* for j=s1 to s1+s2-1 do *) +(* buff := !buff^(Soc2cUtil.gen_assign t (Printf.sprintf "%s.z[%d]" ctx j) *) +(* (Printf.sprintf "%s.y[%d]" ctx (j-s1))); *) +(* done; *) +(* !buff *) let (lustre_slice: Soc.key -> string) = fun sk -> diff --git a/test/lus2lic.sum b/test/lus2lic.sum index c60d61f3..edede8dc 100644 --- a/test/lus2lic.sum +++ b/test/lus2lic.sum @@ -1,4 +1,4 @@ -Test Run By jahier on Thu Jun 12 11:12:29 2014 +Test Run By jahier on Fri Jun 13 14:46:06 2014 Native configuration is i686-pc-linux-gnu === lus2lic tests === @@ -365,6 +365,9 @@ PASS: ./myec2c {-o /tmp/mm22.c /tmp/mm22.ec} PASS: ../utils/test_lus2lic_no_node should_work/mm22.lus PASS: ./lus2lic {-2c should_work/mm22.lus -n mm22} PASS: gcc mm22_mm22.c mm22_mm22_loop.c +PASS: ./lus2lic {-o /tmp/array_concat2.lic should_work/array_concat2.lus} +PASS: ./lus2lic {-ec -o /tmp/array_concat2.ec should_work/array_concat2.lus} +FAIL: Try ec2c on the result: ./myec2c {-o /tmp/array_concat2.c /tmp/array_concat2.ec} 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} PASS: ./myec2c {-o /tmp/is_stable.c /tmp/is_stable.ec} @@ -565,11 +568,10 @@ PASS: ./myec2c {-o /tmp/morel4.c /tmp/morel4.ec} PASS: ../utils/test_lus2lic_no_node should_work/morel4.lus PASS: ./lus2lic {-2c should_work/morel4.lus -n morel4} FAIL: Check that the generated C code compiles : gcc morel4_morel4.c morel4_morel4_loop.c -PASS: ./lus2lic {-o /tmp/trivial_array.lic should_work/trivial_array.lus} -PASS: ./lus2lic {-ec -o /tmp/trivial_array.ec should_work/trivial_array.lus} -PASS: ./myec2c {-o /tmp/trivial_array.c /tmp/trivial_array.ec} -PASS: ../utils/test_lus2lic_no_node should_work/trivial_array.lus -PASS: ./lus2lic {-2c should_work/trivial_array.lus -n trivial_array} +FAIL: without any option: ./lus2lic {-o /tmp/trivial_array.lic should_work/trivial_array.lus} +FAIL: Generate ec code : ./lus2lic {-ec -o /tmp/trivial_array.ec should_work/trivial_array.lus} +FAIL: Try to compare lus2lic -exec and ecexe: ../utils/test_lus2lic_no_node should_work/trivial_array.lus +FAIL: Generate c code : ./lus2lic {-2c should_work/trivial_array.lus -n trivial_array} PASS: gcc trivial_array_trivial_array.c trivial_array_trivial_array_loop.c PASS: ./lus2lic {-o /tmp/param_node4.lic should_work/param_node4.lus} PASS: ./lus2lic {-ec -o /tmp/param_node4.ec should_work/param_node4.lus} @@ -973,6 +975,9 @@ PASS: ./myec2c {-o /tmp/mouse3.c /tmp/mouse3.ec} PASS: ../utils/test_lus2lic_no_node should_work/mouse3.lus PASS: ./lus2lic {-2c should_work/mouse3.lus -n mouse3} FAIL: Check that the generated C code compiles : gcc mouse3_mouse3.c mouse3_mouse3_loop.c +PASS: ./lus2lic {-o /tmp/array_concat.lic should_work/array_concat.lus} +PASS: ./lus2lic {-ec -o /tmp/array_concat.ec should_work/array_concat.lus} +FAIL: Try ec2c on the result: ./myec2c {-o /tmp/array_concat.c /tmp/array_concat.ec} PASS: ./lus2lic {-o /tmp/ex.lic should_work/ex.lus} PASS: ./lus2lic {-ec -o /tmp/ex.ec should_work/ex.lus} PASS: ./myec2c {-o /tmp/ex.c /tmp/ex.ec} @@ -1474,9 +1479,9 @@ XPASS: Test bad programs (semantics): lus2lic {-o /tmp/bug.lic should_fail/seman === lus2lic Summary === -# of expected passes 1172 -# of unexpected failures 232 +# of expected passes 1171 +# of unexpected failures 238 # 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 116 seconds testcase ./lus2lic.tests/progression.exp completed in 0 seconds diff --git a/test/lus2lic.time b/test/lus2lic.time index b771258b..45ce21b1 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 116 seconds testcase ./lus2lic.tests/progression.exp completed in 0 seconds diff --git a/test/should_work/array_concat.lus b/test/should_work/array_concat.lus new file mode 100644 index 00000000..84fa41ca --- /dev/null +++ b/test/should_work/array_concat.lus @@ -0,0 +1,5 @@ +node array_concat(x:bool) returns (y: bool^2); +let + y = [x]|[x]; +tel + diff --git a/test/should_work/array_concat2.lus b/test/should_work/array_concat2.lus new file mode 100644 index 00000000..47578be0 --- /dev/null +++ b/test/should_work/array_concat2.lus @@ -0,0 +1,5 @@ +node array_concat2(x:bool^3) returns (y: bool^3^2); +let + y = [x]|[x]; +tel + diff --git a/test/should_work/trivial_array.lus b/test/should_work/trivial_array.lus index 63077dbd..fa47600c 100644 --- a/test/should_work/trivial_array.lus +++ b/test/should_work/trivial_array.lus @@ -1,5 +1,5 @@ -node trivial_array(x:bool) returns (y: bool^2); +node trivial_array(x:int^3) returns (y: int^3^4); let - y = [x,x]; + y = [x]|[x]|[x]|[x]; tel -- GitLab