diff --git a/lib/l2lExpandArrays.ml b/lib/l2lExpandArrays.ml index b5184d878c4f3afe980c77c5f6f8a4bb2f9dfd28..7fd62181d52bf8128dc5bd816be75d3c9252fff6 100644 --- a/lib/l2lExpandArrays.ml +++ b/lib/l2lExpandArrays.ml @@ -1,4 +1,4 @@ -(** Time-stamp: <modified the 11/03/2021 (at 21:07) by Erwan Jahier> *) +(** Time-stamp: <modified the 05/05/2022 (at 16:06) by Erwan Jahier> *) (* Replace structures and arrays by as many variables as necessary. Since structures can be nested, it might be a lot of new variables... @@ -546,7 +546,18 @@ and (expand_val_exp: local_ctx -> acc -> val_exp -> val_exp * acc) = | [_ve1; _ve2] -> by_pos_op, acc, vel | _ -> assert false (* sno *) ) - | CONCAT | PREDEF_CALL _ | CALL _ + | CALL { src=lxm; it = ("Lustre", ("fillred"|"fill"|"red"|"map")), + NodeStaticArgLic (_, ((m,n), sargs))::_ } -> + (* The l2lExpandMetaOp pass should have done most of the necessary work! + + nb: nested meta op do not work yet with -esa -knc (sigh) + *) + let vel,acc = expand_val_exp_list lctx acc vel in + let by_pos_op = CALL { src=lxm; it = (m,n),sargs } in + by_pos_op, acc, vel + + | CALL _ + | CONCAT | PREDEF_CALL _ | PRE | ARROW | FBY | CURRENT _ | WHEN _ | TUPLE | CONST _ -> let vel,acc = expand_val_exp_list lctx acc vel in diff --git a/lib/licDump.ml b/lib/licDump.ml index 206150264728a7d1c008e07ea08462d9f6f7cc62..f48d665b20d9a795303647d916421a48b9bb556e 100644 --- a/lib/licDump.ml +++ b/lib/licDump.ml @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 04/09/2019 (at 17:53) by Erwan Jahier> *) +(* Time-stamp: <modified the 05/05/2022 (at 13:47) by Erwan Jahier> *) (* This module is used both for @@ -265,9 +265,8 @@ and string_of_node_key forprint = function (string_of_ident forprint ik) | (ik, sargs) -> Printf.sprintf "%s<<%s>>" - (string_of_ident forprint ik) - (String.concat ", " - (List.map (string_of_static_arg forprint) sargs)) + (string_of_ident forprint ik) + (String.concat ", " (List.map (string_of_static_arg forprint) sargs)) and string_of_static_arg forprint = function | ConstStaticArgLic(id, ceff) -> @@ -325,7 +324,7 @@ and string_of_node_key_rec forprint (no_prefix:bool) (nkey: node_key) = let name = sprintf "%s_%s" (Lv6Id.no_pack_string_of_long ik) (String.concat "_" astrings) in (FreshName.node_key nkey name) - + (* for printing iterators *) and string_of_node_key_iter forprint (nkey: node_key) = match nkey with @@ -489,10 +488,10 @@ and (string_of_by_pos_op_eff: bool -> Lic.by_pos_op srcflagged -> Lic.val_exp li ) else let nk = op.it in - if not global_opt.lv4 then - ((string_of_node_key forprint nk) ^ (tuple_par vel)) - else + if global_opt.lv4 || global_opt.inline_iterator then ((string_of_node_key_rec forprint global_opt.no_prefix nk) ^ (tuple_par vel)) + else + ((string_of_node_key forprint nk) ^ (tuple_par vel)) ) | CONST_REF idl, _ -> dump_long forprint idl | VAR_REF id, _ -> id diff --git a/lib/lv6Compile.ml b/lib/lv6Compile.ml index b6899cecbdbc26e020411a76ffc93eaa1a6dffb1..5fd7a368d80ad3f45b8e104c9c3305d854204626 100644 --- a/lib/lv6Compile.ml +++ b/lib/lv6Compile.ml @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 04/05/2022 (at 10:58) by Erwan Jahier> *) +(* Time-stamp: <modified the 05/05/2022 (at 13:39) by Erwan Jahier> *) open Lxm open AstV6 @@ -83,12 +83,12 @@ let remove_polymorphism _opt zelic = profile_info "Removing polymorphism...\n"; L2lRmPoly.doit zelic -let expand_iterators opt zelic = - if not opt.Lv6MainArgs.inline_iterator then zelic else ( +let expand_iterators _opt zelic = + if not Lv6MainArgs.global_opt.Lv6MainArgs.inline_iterator then zelic else ( profile_info "Inlining iterators...\n"; (* to be done before array expansion otherwise they won't be expanded *) let zelic = L2lExpandMetaOp.doit zelic in - if Lv6MainArgs.global_opt.Lv6MainArgs.kcg && not opt.Lv6MainArgs.inline_iterator + if Lv6MainArgs.global_opt.Lv6MainArgs.kcg && not Lv6MainArgs.global_opt.Lv6MainArgs.inline_iterator then L2lExpandMetaOp.doit_boolred zelic else diff --git a/lib/lv6MainArgs.ml b/lib/lv6MainArgs.ml index f1e2ca2f2dcfd798a32b41ab2874e20ce0030d30..c5b85446d1e5e55dee47b3d73eef5879cf0def80 100644 --- a/lib/lv6MainArgs.ml +++ b/lib/lv6MainArgs.ml @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 05/05/2022 (at 08:47) by Erwan Jahier> *) +(* Time-stamp: <modified the 05/05/2022 (at 13:39) by Erwan Jahier> *) (* Le manager d'argument adapté de celui de lutin, plus joli N.B. solution un peu batarde : les options sont stockées, comme avant, dans Global, @@ -27,7 +27,6 @@ type t = { mutable compile_all_items : bool; mutable run_unit_test : bool; mutable print_interface : bool; - mutable inline_iterator : bool; mutable expand_nodes : bool; mutable expand_node_call : string list; mutable expand_arrays : bool; @@ -56,6 +55,7 @@ type global_opt = { mutable ec : bool; mutable gen_autotest : bool; mutable expand_enums : enum_mode; + mutable inline_iterator : bool; mutable one_op_per_equation : bool; mutable when_on_ident : bool; mutable no_when_not : bool; @@ -82,6 +82,7 @@ let (global_opt:global_opt) = kcg = false; ec = false; one_op_per_equation = false; + inline_iterator = false; when_on_ident = false; no_when_not = false; no_prefix = false; @@ -114,7 +115,6 @@ let (make_opt : unit -> t) = compile_all_items = true; run_unit_test = false; print_interface = false; - inline_iterator = false; expand_nodes = false; expand_node_call = []; expand_arrays = false; @@ -245,7 +245,7 @@ let set_v4_options opt = (match global_opt.expand_enums with | AsEnum -> global_opt.expand_enums <- AsConst; (* only override the default *) | AsInt | AsConst | AsBool -> ()); - opt.inline_iterator <- true; + global_opt.inline_iterator <- true; global_opt.when_on_ident <- true; opt.expand_arrays <- true (* ; opt.expand_nodes <- true (* because expand_arrays is true *) *) @@ -350,7 +350,7 @@ let mkoptab (opt:t) : unit = ( ; mkopt opt ~doc_level:Advanced ["-ei"; "--expand-iterators"] - (Arg.Unit (fun _ -> opt.inline_iterator <- true)) + (Arg.Unit (fun _ -> global_opt.inline_iterator <- true)) ["Expand array iterators (i.e., generate iterator-free code)"] ; mkopt opt ~doc_level:Advanced @@ -373,12 +373,13 @@ let mkoptab (opt:t) : unit = ( (Arg.Unit (fun _ -> opt.expand_arrays <- true; (* opt.expand_nodes <- true; *) - opt.inline_iterator <- true)) + global_opt.inline_iterator <- true)) ["Expand structures and arrays (force '-ei' and '-en')"] ; mkopt opt ~doc_level:Advanced ["-en"; "--expand-nodes"] - (Arg.Unit (fun _ -> opt.expand_nodes <- true; opt.inline_iterator <- true (* an iterator is a kind of node *))) + (Arg.Unit (fun _ -> opt.expand_nodes <- true; + global_opt.inline_iterator <- true (* an iterator is a kind of node *))) ["Expand all node calls in the main node"] ; mkopt opt diff --git a/lib/lv6MainArgs.mli b/lib/lv6MainArgs.mli index 1ffcf1edacbc92a79fe580e199953ba57cedd798..dfe02759533e1228c81afe780fd8e468b120adb3 100644 --- a/lib/lv6MainArgs.mli +++ b/lib/lv6MainArgs.mli @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 22/09/2021 (at 11:18) by Erwan Jahier> *) +(* Time-stamp: <modified the 05/05/2022 (at 13:38) by Erwan Jahier> *) type enum_mode = AsInt (* translate enums into int (for rif-friendlyness *) @@ -32,7 +32,6 @@ type t = { mutable compile_all_items : bool; mutable run_unit_test : bool; mutable print_interface : bool; - mutable inline_iterator : bool; mutable expand_nodes : bool; mutable expand_node_call : string list; mutable expand_arrays : bool; @@ -61,6 +60,7 @@ type global_opt = { mutable ec : bool; mutable gen_autotest : bool; mutable expand_enums : enum_mode; + mutable inline_iterator : bool; mutable one_op_per_equation : bool; mutable when_on_ident : bool; mutable no_when_not : bool; diff --git a/test/lus2lic.sum b/test/lus2lic.sum index 364ce3069b495e64d1df306efb5ce6df6fffcdbd..1e3cd80515619439f79aad137e6070e349c2326e 100644 --- a/test/lus2lic.sum +++ b/test/lus2lic.sum @@ -1,5 +1,5 @@ ==> lus2lic0.sum <== -Test run by jahier on Thu May 5 08:47:41 +Test run by jahier on Thu May 5 15:59:53 Native configuration is x86_64-pc-linux-gnu === lus2lic0 tests === @@ -66,7 +66,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 Thu May 5 08:47:43 +Test run by jahier on Thu May 5 15:59:54 Native configuration is x86_64-pc-linux-gnu === lus2lic1 tests === @@ -621,7 +621,7 @@ PASS: /home/jahier/lus2lic/test/../utils/compare_exec_and_2c multipar.lus {} PASS: /home/jahier/lus2lic/test/../utils/compare_lv6_and_lv6_en multipar.lus {} ==> lus2lic2.sum <== -Test run by jahier on Thu May 5 08:53:53 +Test run by jahier on Thu May 5 16:04:08 Native configuration is x86_64-pc-linux-gnu === lus2lic2 tests === @@ -1165,7 +1165,7 @@ PASS: /home/jahier/lus2lic/test/../utils/compare_lv6_and_lv6_en zzz2.lus {} PASS: /home/jahier/lus2lic/test/../utils/compare_gcc_and_clang zzz2.lus {} ==> lus2lic3.sum <== -Test run by jahier on Thu May 5 09:01:28 +Test run by jahier on Thu May 5 16:08:58 Native configuration is x86_64-pc-linux-gnu === lus2lic3 tests === @@ -1677,7 +1677,7 @@ PASS: /home/jahier/lus2lic/test/../utils/test_lus2lic_no_node multipar.lus {} ==> lus2lic4.sum <== -Test run by jahier on Thu May 5 09:02:37 +Test run by jahier on Thu May 5 16:09:55 Native configuration is x86_64-pc-linux-gnu === lus2lic4 tests === @@ -2200,11 +2200,11 @@ PASS: /home/jahier/lus2lic/test/../utils/compare_gcc_and_clang multipar.lus {} =============================== # Total number of failures: 19 lus2lic0.log:testcase ./lus2lic.tests/test0.exp completed in 1 seconds -lus2lic1.log:testcase ./lus2lic.tests/test1.exp completed in 369 seconds -lus2lic2.log:testcase ./lus2lic.tests/test2.exp completed in 455 seconds -lus2lic3.log:testcase ./lus2lic.tests/test3.exp completed in 69 seconds -lus2lic4.log:testcase ./lus2lic.tests/test4.exp completed in 59 seconds +lus2lic1.log:testcase ./lus2lic.tests/test1.exp completed in 254 seconds +lus2lic2.log:testcase ./lus2lic.tests/test2.exp completed in 290 seconds +lus2lic3.log:testcase ./lus2lic.tests/test3.exp completed in 57 seconds +lus2lic4.log:testcase ./lus2lic.tests/test4.exp completed in 40 seconds * Ref time: -331.43user 98.32system 15:55.64elapsed 44%CPU (0avgtext+0avgdata 76876maxresident)k -46544inputs+449472outputs (111major+19306350minor)pagefaults 0swaps +221.42user 66.79system 10:42.45elapsed 44%CPU (0avgtext+0avgdata 77980maxresident)k +24336inputs+449736outputs (52major+19311559minor)pagefaults 0swaps * Quick time (-j 4):