Commit db127044 authored by erwan's avatar erwan
Browse files

Update: refuse programs that iterates over array of structures using polymorphic nodes.

parent a5758195
Pipeline #62322 passed with stages
in 5 minutes and 8 seconds
(* Time-stamp: <modified the 13/03/2020 (at 11:44) by Erwan Jahier> *)
(* Time-stamp: <modified the 15/03/2021 (at 23:07) by Erwan Jahier> *)
(* let put (os: out_channel) (fmt:('a, unit, string, unit) format4) : 'a = *)
......@@ -107,59 +107,76 @@ 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 ->
if inlined_soc sp.soc.key then () (* don't generate code if inlined *) else
(* let sname = Soc2cDep.step_name sp.soc.key sm.name in *)
let sname = Soc2cDep.step_name sp.soc.key sm.name in
if sm.impl<>Extern then (
let decl, def, ctype = Soc2cDep.get_step_prototype sm sp.soc in
sp.hput (Printf.sprintf "%s\n" decl);
sp.cput (Printf.sprintf "%s" def);
(match sm.impl with
| Extern -> ()
| Predef ->
(match sp.soc.key with
| ("Lustre::eq",(Array _)::_,_) ->
let str = Printf.sprintf
" *out = memcmp((const void *) i1, (const void *) i2, %s)==0;\n"
ctype in
sp.cput str
| ("Lustre::eq",(Struct _)::_,_) ->
let str = Printf.sprintf
" *out = memcmp((const void *) &i1, (const void *) &i2, %s)==0;\n"
ctype in
sp.cput str
| ("Lustre::neq",(Array _)::_,_) ->
let str = Printf.sprintf
" *out = !memcmp((const void *) i1, (const void *) i2, %s)==0;\n"
ctype in
sp.cput str
| ("Lustre::neq",(Struct _)::_,_) ->
let str = Printf.sprintf
" *out = !memcmp((const void *) &i1, (const void *) &i2, %s)==0;\n"
ctype in
sp.cput str
| n -> sp.cput (Soc2cDep.get_predef_op n)
)
| Gaol(vl, gaol) -> (
if Lv6MainArgs.global_opt.Lv6MainArgs.gen_wcet then
List.iter
(fun v -> sp.cput (Soc2cUtil.string_of_flow_decl_w7annot gaol v))
vl
else
List.iter (fun v -> sp.cput (Soc2cUtil.string_of_flow_decl v)) vl;
sp.cput "\n";
List.iter (gao2c stbl sp) gaol
)
| Iterator(it,it_soc_key,s) ->
let it_soc = SocUtils.find sm.lxm it_soc_key stbl in
sp.cput (Soc2cDep.get_iterator sp.soc it it_soc s)
| Boolred(i,j,k) ->
sp.cput (Soc2cDep.get_boolred sp.soc i j k)
| Condact(k,el) ->
sp.cput (Soc2cDep.get_condact sp.soc (SocUtils.find sm.lxm k stbl) el)
);
sp.cput (sprintf "\n} // End of %s\n\n" sname)
)
if inlined_soc sp.soc.key then () (* don't generate code if inlined *) else
(* let sname = Soc2cDep.step_name sp.soc.key sm.name in *)
let sname = Soc2cDep.step_name sp.soc.key sm.name in
if sm.impl<>Extern then (
let decl, def, ctype = Soc2cDep.get_step_prototype sm sp.soc in
sp.hput (Printf.sprintf "%s\n" decl);
sp.cput (Printf.sprintf "%s" def);
(match sm.impl with
| Extern -> ()
| Predef ->
(match sp.soc.key with
| ("Lustre::eq",(Array _)::_,_) ->
let str = Printf.sprintf
" *out = memcmp((const void *) i1, (const void *) i2, %s)==0;\n"
ctype in
sp.cput str
| ("Lustre::eq",(Struct _)::_,_) ->
let str = Printf.sprintf
" *out = memcmp((const void *) &i1, (const void *) &i2, %s)==0;\n"
ctype in
sp.cput str
| ("Lustre::neq",(Array _)::_,_) ->
let str = Printf.sprintf
" *out = !memcmp((const void *) i1, (const void *) i2, %s)==0;\n"
ctype in
sp.cput str
| ("Lustre::neq",(Struct _)::_,_) ->
let str = Printf.sprintf
" *out = !memcmp((const void *) &i1, (const void *) &i2, %s)==0;\n"
ctype in
sp.cput str
| n -> sp.cput (Soc2cDep.get_predef_op n)
)
| Gaol(vl, gaol) -> (
if Lv6MainArgs.global_opt.Lv6MainArgs.gen_wcet then
List.iter
(fun v -> sp.cput (Soc2cUtil.string_of_flow_decl_w7annot gaol v))
vl
else
List.iter (fun v -> sp.cput (Soc2cUtil.string_of_flow_decl v)) vl;
sp.cput "\n";
List.iter (gao2c stbl sp) gaol
)
| Iterator(it,it_soc_key,s) -> (
(* iterating on Lustre::eq or neq currently does not work
Refuse such programs explicitly *)
match sp.soc.key with
| _, (Array (Array _,_))::_, _
| _, (Array (Struct _,_))::_, _ -> (
match it_soc_key with
| _,(Alpha _::_),_ ->
let msg = Printf.sprintf
"%s\nIterating on polymorphic nodes over arrays of structures %s"
(Lxm.details sm.lxm)
"is currently unsupported"
in
failwith msg
| _ -> ()
)
| _,_,_ -> ()
);
let it_soc = SocUtils.find sm.lxm it_soc_key stbl in
sp.cput (Soc2cDep.get_iterator sp.soc it it_soc s)
| Boolred(i,j,k) ->
sp.cput (Soc2cDep.get_boolred sp.soc i j k)
| Condact(k,el) ->
sp.cput (Soc2cDep.get_condact sp.soc (SocUtils.find sm.lxm k stbl) el)
);
sp.cput (sprintf "\n} // End of %s\n\n" sname)
)
let (gen_instance_init_call : 'a soc_pp -> Soc.key * int -> unit) =
fun sp (key,i) ->
let ctx_name = get_ctx_name key in
......
==> lus2lic0.sum <==
Test run by jahier on Thu Mar 11 17:05:43
Test run by jahier on Mon Mar 15 23:09:33
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 Mar 11 17:05:43
Test run by jahier on Mon Mar 15 23:09:34
Native configuration is x86_64-pc-linux-gnu
=== lus2lic1 tests ===
......@@ -413,7 +413,7 @@ PASS: ./lus2lic {-2c multipar.lus -n multipar}
PASS: sh multipar.sh
==> lus2lic2.sum <==
Test run by jahier on Thu Mar 11 17:06:11
Test run by jahier on Mon Mar 15 23:10:02
Native configuration is x86_64-pc-linux-gnu
=== lus2lic2 tests ===
......@@ -753,7 +753,7 @@ PASS: sh zzz2.sh
PASS: /home/jahier/lus2lic/test/../utils/compare_exec_and_2c zzz2.lus {}
==> lus2lic3.sum <==
Test run by jahier on Thu Mar 11 17:06:47
Test run by jahier on Mon Mar 15 23:10:38
Native configuration is x86_64-pc-linux-gnu
=== lus2lic3 tests ===
......@@ -1267,7 +1267,7 @@ PASS: /home/jahier/lus2lic/test/../utils/test_lus2lic_no_node multipar.lus {}
==> lus2lic4.sum <==
Test run by jahier on Thu Mar 11 17:07:30
Test run by jahier on Mon Mar 15 23:11:23
Native configuration is x86_64-pc-linux-gnu
=== lus2lic4 tests ===
......@@ -1759,7 +1759,7 @@ PASS: /home/jahier/lus2lic/test/../utils/test_lus2lic_no_node zzz2.lus {}
# of expected failures 54
==> lus2lic1.sum <==
PASS: /home/jahier/lus2lic/test/../utils/compare_exec_and_2c multipar.lus 36527 {}
PASS: /home/jahier/lus2lic/test/../utils/compare_exec_and_2c multipar.lus 34133 {}
=== lus2lic1 Summary ===
......@@ -1787,14 +1787,14 @@ PASS: /home/jahier/lus2lic/test/../utils/compare_exec_and_2c multipar.lus 36527
# of unexpected failures 6
===============================
# Total number of failures: 10
lus2lic0.log:testcase ./lus2lic.tests/test0.exp completed in 0 seconds
lus2lic1.log:testcase ./lus2lic.tests/test1.exp completed in 27 seconds
lus2lic0.log:testcase ./lus2lic.tests/test0.exp completed in 1 seconds
lus2lic1.log:testcase ./lus2lic.tests/test1.exp completed in 28 seconds
lus2lic2.log:testcase ./lus2lic.tests/test2.exp completed in 36 seconds
lus2lic3.log:testcase ./lus2lic.tests/test3.exp completed in 43 seconds
lus2lic4.log:testcase ./lus2lic.tests/test4.exp completed in 25 seconds
lus2lic3.log:testcase ./lus2lic.tests/test3.exp completed in 45 seconds
lus2lic4.log:testcase ./lus2lic.tests/test4.exp completed in 26 seconds
* Ref time:
80.22user 17.98system 2:12.40elapsed 74%CPU (0avgtext+0avgdata 42380maxresident)k
0inputs+151696outputs (0major+8412242minor)pagefaults 0swaps
85.81user 18.64system 2:16.24elapsed 76%CPU (0avgtext+0avgdata 42376maxresident)k
0inputs+150784outputs (0major+8408425minor)pagefaults 0swaps
* Quick time (-j 4):
96.17user 19.55system 1:26.54elapsed 133%CPU (0avgtext+0avgdata 42368maxresident)k
6672inputs+149632outputs (12major+8317848minor)pagefaults 0swaps
83.16user 16.25system 1:22.57elapsed 120%CPU (0avgtext+0avgdata 42428maxresident)k
6000inputs+148480outputs (8major+8310354minor)pagefaults 0swaps
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment