diff --git a/_oasis b/_oasis index 89993b92f13ef756353a639c1e1185806a3f8383..26e52ca7b4e9e4dce8d298d9b54bc6ede840a560 100644 --- a/_oasis +++ b/_oasis @@ -1,6 +1,6 @@ OASISFormat: 0.4 Name: lustre-v6 -Version: 1.678 +Version: 1.679 Synopsis: The Lustre V6 Verimag compiler Description: This package contains: (1) lus2lic: the (current) name of the compiler (and interpreter via -exec). diff --git a/src/l2lCheckKcgKeyWord.mli b/src/l2lCheckKcgKeyWord.mli index e945c5a6609aee9d48c6c135087258e6c3242f0b..e6c1ebc09efce253b671a5277926775ca4c1558c 100644 --- a/src/l2lCheckKcgKeyWord.mli +++ b/src/l2lCheckKcgKeyWord.mli @@ -1,5 +1,5 @@ -(* Time-stamp: <modified the 17/08/2015 (at 16:58) by Erwan Jahier> *) +(* Time-stamp: <modified the 10/01/2017 (at 18:07) by Erwan Jahier> *) -(** Check that the inoput program does not use KCG keywords an ident *) +(** Check that the input program does not use KCG keywords an ident *) val doit : LicPrg.t -> unit diff --git a/src/lic2soc.ml b/src/lic2soc.ml index 8d653db2fed353571b6c08afb87edde4afd69ec5..6ce04a9349b3413f8da878133665378db4961e7d 100644 --- a/src/lic2soc.ml +++ b/src/lic2soc.ml @@ -1,4 +1,4 @@ -(** Time-stamp: <modified the 24/11/2016 (at 17:19) by Erwan Jahier> *) +(** Time-stamp: <modified the 10/01/2017 (at 17:27) by Erwan Jahier> *) (* XXX ce module est mal écrit. A reprendre. (R1) *) @@ -80,7 +80,11 @@ actuellement lors des l2l*.ml *) (* R1: je vire le "_" parce que ca m'emmerde ce truc. - On verra plus tard les clash de nom...*) + On verra plus tard les clash de nom... + +bon, des clashs de nom, y'en a pas trop, mais avec les mots clefs C, si ! +ex: si un noeud a une variable qui s'appelle "long"... +*) let user_var_prefix = "_" let user_var_prefix = "" diff --git a/src/lv6version.ml b/src/lv6version.ml index ab7cce7abf4b29ffa4dd40c94d9f2a814ecce96c..a630731967f3be82feda259f8f45850efeee344d 100644 --- a/src/lv6version.ml +++ b/src/lv6version.ml @@ -1,7 +1,7 @@ (** Automatically generated from Makefile *) let tool = "lus2lic" let branch = "master" -let commit = "678" -let sha_1 = "50197035822142c871f65b41f584fde225359e4f" +let commit = "679" +let sha_1 = "946ca4cf5781377ea43c0247b80d09606517ea56" let str = (branch ^ "." ^ commit ^ " (" ^ sha_1 ^ ")") let maintainer = "jahier@imag.fr" diff --git a/src/soc2c.ml b/src/soc2c.ml index 98058d6fd4fa3b62c8f4a2a77c628c0f1b4f1c11..c06d3d2a88e77733312b748b955231bf73bb35af 100644 --- a/src/soc2c.ml +++ b/src/soc2c.ml @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 09/01/2017 (at 11:06) by Erwan Jahier> *) +(* Time-stamp: <modified the 10/01/2017 (at 14:37) by Erwan Jahier> *) (* let put (os: out_channel) (fmt:('a, unit, string, unit) format4) : 'a = *) @@ -943,7 +943,10 @@ typedef float _float; let l = (Soc2cGenAssign.gen_used_types socs) in if l <> [] then ( output_string types_h_oc "// Defining array and extern types assignments \n"; - List.iter (fun t -> output_string types_h_oc (Soc2cGenAssign.f t)) l + if Lv6MainArgs.global_opt.Lv6MainArgs.gen_wcet then + List.iter (fun t -> output_string types_h_oc (Soc2cGenAssign.f_forloop t)) l + else + List.iter (fun t -> output_string types_h_oc (Soc2cGenAssign.f t)) l ); puth "#endif\n"; flush occ; close_out occ; diff --git a/src/soc2cGenAssign.ml b/src/soc2cGenAssign.ml index 2293691521233ba8f18a7365ef9c67efc3f235b8..5b12c6025f2ea2cc2096824dc2d5ee62cd87d4fc 100644 --- a/src/soc2cGenAssign.ml +++ b/src/soc2cGenAssign.ml @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 06/09/2016 (at 11:15) by Erwan Jahier> *) +(* Time-stamp: <modified the 10/01/2017 (at 17:04) by Erwan Jahier> *) open Data open Lic @@ -61,4 +61,22 @@ let (f: Data.t -> string) = in t_def - +let (f_forloop: Data.t -> string) = + fun t -> + let rec (aux: int -> string -> Data.t -> string) = fun i index t -> + match t with + | Array(t, size) -> + let index = Printf.sprintf "%s[_j%i]" index i in + let body = aux (i+1) index t in + Printf.sprintf "{ int _j%i; for (_j%i=0; _j%i<%i; _j%i++) { %s }}" + i i i size i body + | _ -> + Printf.sprintf " dest%s=source%s;" index index + in + let t_str = Soc2cIdent.type_to_short_string t in + let loop_def = aux 0 "" t in + Printf.sprintf "#ifndef _assign_%s +#define _assign_%s(dest, source, _dummy) %s +#endif + " t_str t_str loop_def + diff --git a/src/soc2cGenAssign.mli b/src/soc2cGenAssign.mli index 0abc6108764a9d2a760b294f9f437a81cd08cb3c..4c7553b2b809e9b00071b81df6655abf5d6ecc2b 100644 --- a/src/soc2cGenAssign.mli +++ b/src/soc2cGenAssign.mli @@ -1,9 +1,11 @@ - (* Time-stamp: <modified the 06/09/2016 (at 11:07) by Erwan Jahier> *) + (* Time-stamp: <modified the 10/01/2017 (at 17:49) by Erwan Jahier> *) (* Returns the list of non-trivial data types (i.e., arrays and extern) that are used in a program, with no duplicates *) val gen_used_types : Soc.t list -> Data.t list -(* Generates a ccp macro the provides a default definition copying Data.t *) +(* Generates a ccp macro that provides a default definition copying Data.t *) val f: Data.t -> string +(* Ditto, but using a for loop instead of memcpy *) +val f_forloop: Data.t -> string diff --git a/src/socPredef2cHeap.ml b/src/socPredef2cHeap.ml index d4254d450fa8b5db4286b183be8357a11cd2f37e..44509b58484539bee9cae3fcb0d7ec4db3144b15 100644 --- a/src/socPredef2cHeap.ml +++ b/src/socPredef2cHeap.ml @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 30/11/2016 (at 17:10) by Erwan Jahier> *) +(* Time-stamp: <modified the 10/01/2017 (at 17:59) by Erwan Jahier> *) open Data open Soc @@ -72,29 +72,38 @@ let (lustre_array: Soc.key -> string) = let (lustre_concat: Soc.key -> string) = 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.i1" ctx - and t2 = Printf.sprintf "%s.i2" ctx - and t12 = Printf.sprintf "%s.out" ctx - and t1_type = Soc2cUtil.data_type_to_c (Data.Array(t,s1)) "" - and t2_type = Soc2cUtil.data_type_to_c (Data.Array(t,s2)) "" - in - (Printf.sprintf " memcpy(&%s, &%s, sizeof(%s));\n" t12 t1 t1_type)^ + 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.i1" ctx + and t2 = Printf.sprintf "%s.i2" ctx + and t12 = Printf.sprintf "%s.out" ctx + and t1_type = Soc2cUtil.data_type_to_c (Data.Array(t,s1)) "" + and t2_type = Soc2cUtil.data_type_to_c (Data.Array(t,s2)) "" + in + if not Lv6MainArgs.global_opt.Lv6MainArgs.gen_wcet then ( + (Printf.sprintf " memcpy(&%s, &%s, sizeof(%s));\n" t12 t1 t1_type)^ (Printf.sprintf " // memcpy(&%s+%d, &%s, sizeof(%s));\n" t12 s1 t2 t2_type) ^ - (Printf.sprintf " memcpy(&%s[%d], &%s, sizeof(%s));\n" t12 s1 t2 t2_type) -(* Both seems to work *) -(* let buff = ref "" in *) -(* for j=0 to s1-1 do *) -(* buff := !buff^(Soc2cHeap.gen_assign t (Printf.sprintf "%s.z[%d]" ctx j)); *) -(* done; *) -(* for j=s1 to s1+s2-1 do *) -(* buff := !buff^(Soc2cHeap.gen_assign t (Printf.sprintf "%s.z[%d]" ctx j)); *) -(* done; *) -(* !buff *) + (Printf.sprintf " memcpy(&%s[%d], &%s, sizeof(%s));\n" t12 s1 t2 t2_type) + ) + else + (* Both seems to work *) + let buff = ref "" in + for j=0 to s1-1 do + buff := !buff^(Soc2cHeap.gen_assign t + (Printf.sprintf "%s[%d]" t12 j) + (Printf.sprintf "%s[%d]" t1 j) + ); + done; + for j=s1 to s1+s2-1 do + buff := !buff^(Soc2cHeap.gen_assign t + (Printf.sprintf "%s[%d]" t12 j) + (Printf.sprintf "%s[%d]" t2 (j-s1)) + ); + done; + !buff let (lustre_slice: Soc.key -> string) = fun (n,tl,si_opt) -> diff --git a/src/socPredef2cStack.ml b/src/socPredef2cStack.ml index fc0773d3aa9c391d6a2e395b96ee784c5ee142b0..8260a64568531e631758dc1c1503fba558877587 100644 --- a/src/socPredef2cStack.ml +++ b/src/socPredef2cStack.ml @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 30/11/2016 (at 17:09) by Erwan Jahier> *) +(* Time-stamp: <modified the 10/01/2017 (at 18:04) by Erwan Jahier> *) open Data open Soc @@ -72,19 +72,36 @@ let (lustre_array: Soc.key -> string) = let (lustre_concat: Soc.key -> string) = fun (n,tl,si_opt) -> - let t,s1,s2 = match tl with - | [Data.Array(t,s1); Data.Array(_,s2); _] -> t,s1,s2 - | _ -> assert false - in - let t1 = Printf.sprintf "i1" - and t2 = Printf.sprintf "i2" - and t12 = Printf.sprintf "out" - and t1_type = Soc2cUtil.data_type_to_c (Data.Array(t,s1)) "" - and t2_type = Soc2cUtil.data_type_to_c (Data.Array(t,s2)) "" - in - (Printf.sprintf " memcpy(%s, %s, sizeof(%s));\n" t12 t1 t1_type)^ - (Printf.sprintf " memcpy(%s+%d, %s, sizeof(%s));\n" t12 s1 t2 t2_type) -(* Both seems to work *) + let t,s1,s2 = match tl with + | [Data.Array(t,s1); Data.Array(_,s2); _] -> t,s1,s2 + | _ -> assert false + in + let t1 = Printf.sprintf "i1" + and t2 = Printf.sprintf "i2" + and t12 = Printf.sprintf "out" + and t1_type = Soc2cUtil.data_type_to_c (Data.Array(t,s1)) "" + and t2_type = Soc2cUtil.data_type_to_c (Data.Array(t,s2)) "" + in + if not Lv6MainArgs.global_opt.Lv6MainArgs.gen_wcet then ( + (Printf.sprintf " memcpy(%s, %s, sizeof(%s));\n" t12 t1 t1_type)^ + (Printf.sprintf " memcpy(%s+%d, %s, sizeof(%s));\n" t12 s1 t2 t2_type) + ) else ( + (* Both seems to work *) + let buff = ref "" in + for j=0 to s1-1 do + buff := !buff^(Soc2cStack.gen_assign t + (Printf.sprintf "%s[%d]" t12 j) + (Printf.sprintf "%s[%d]" t1 j) + ); + done; + for j=s1 to s1+s2-1 do + buff := !buff^(Soc2cStack.gen_assign t + (Printf.sprintf "%s[%d]" t12 j) + (Printf.sprintf "%s[%d]" t2 (j-s1)) + ); + done; + !buff + ) (* let buff = ref "" in *) (* for j=0 to s1-1 do *) (* buff := !buff^(Soc2cStack.gen_assign t (Printf.sprintf "%s.z[%d]" ctx j)); *) diff --git a/test/lus2lic.sum b/test/lus2lic.sum index 916085720a3455185964a9bf9e1a7f36e1a58d79..90829ba9fea07dcb15edd3189942769f7bf4b9b9 100644 --- a/test/lus2lic.sum +++ b/test/lus2lic.sum @@ -1,5 +1,5 @@ ==> lus2lic0.sum <== -Test Run By jahier on Mon Jan 9 11:08:30 +Test Run By jahier on Tue Jan 10 18:31:09 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 Mon Jan 9 11:08:31 +Test Run By jahier on Tue Jan 10 18:31:10 Native configuration is x86_64-unknown-linux-gnu === lus2lic1 tests === @@ -399,7 +399,7 @@ PASS: sh multipar.sh PASS: /home/jahier/lus2lic/test/../utils/compare_exec_and_2c multipar.lus {} ==> lus2lic2.sum <== -Test Run By jahier on Mon Jan 9 11:08:50 +Test Run By jahier on Tue Jan 10 18:31:29 Native configuration is x86_64-unknown-linux-gnu === lus2lic2 tests === @@ -745,7 +745,7 @@ PASS: sh zzz2.sh PASS: /home/jahier/lus2lic/test/../utils/compare_exec_and_2c zzz2.lus {} ==> lus2lic3.sum <== -Test Run By jahier on Mon Jan 9 11:09:29 +Test Run By jahier on Tue Jan 10 18:32:08 Native configuration is x86_64-unknown-linux-gnu === lus2lic3 tests === @@ -1251,7 +1251,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 Mon Jan 9 11:09:40 +Test Run By jahier on Tue Jan 10 18:32:19 Native configuration is x86_64-unknown-linux-gnu === lus2lic4 tests === @@ -1778,11 +1778,11 @@ PASS: /home/jahier/lus2lic/test/../utils/test_lus2lic_no_node zzz2.lus {} lus2lic0.log:testcase ./lus2lic.tests/test0.exp completed in 1 seconds lus2lic1.log:testcase ./lus2lic.tests/test1.exp completed in 19 seconds lus2lic2.log:testcase ./lus2lic.tests/test2.exp completed in 39 seconds -lus2lic3.log:testcase ./lus2lic.tests/test3.exp completed in 10 seconds -lus2lic4.log:testcase ./lus2lic.tests/test4.exp completed in 29 seconds +lus2lic3.log:testcase ./lus2lic.tests/test3.exp completed in 11 seconds +lus2lic4.log:testcase ./lus2lic.tests/test4.exp completed in 30 seconds * Ref time: -0.06user 0.03system 1:39.43elapsed 0%CPU (0avgtext+0avgdata 5696maxresident)k -128inputs+0outputs (0major+6056minor)pagefaults 0swaps +0.05user 0.04system 1:39.96elapsed 0%CPU (0avgtext+0avgdata 5672maxresident)k +96inputs+0outputs (0major+6149minor)pagefaults 0swaps * Quick time (-j 4): -0.05user 0.03system 0:45.66elapsed 0%CPU (0avgtext+0avgdata 5640maxresident)k -96inputs+0outputs (0major+6039minor)pagefaults 0swaps +0.06user 0.03system 0:50.78elapsed 0%CPU (0avgtext+0avgdata 5672maxresident)k +64inputs+0outputs (0major+6154minor)pagefaults 0swaps