Commit e53071f4 authored by Erwan Jahier's avatar Erwan Jahier
Browse files

Update the lus2lic plugin.

parent 676421e4
(* Time-stamp: <modified the 10/04/2015 (at 17:42) by Erwan Jahier> *)
(* Time-stamp: <modified the 22/05/2015 (at 15:37) by Erwan Jahier> *)
(*
Le manager d'argument adapt de celui de lutin, plus joli
N.B. solution un peu batarde : les options sont stockes, comme avant, dans Global,
......@@ -19,6 +19,7 @@ type t = {
mutable opts : (string * Arg.spec * string) list; (* classical Arg option tab used by Arg.parse *)
mutable user_man : (string * string list) list; (* ad hoc tab for pretty prtting usage *)
mutable hidden_man: (string * string list) list; (* ad hoc tab for pretty prtting usage *)
mutable dev_man: (string * string list) list; (* ad hoc tab for pretty prtting usage *)
mutable others: string list;
mutable margin : int;
mutable outfile : string;
......@@ -86,6 +87,7 @@ let (make_opt : unit -> t) =
opts = [];
user_man = [];
hidden_man = [];
dev_man = [];
others = [];
margin = 12;
outfile = "";
......@@ -171,10 +173,22 @@ let full_usage os opt = (
let l = List.rev (opt.hidden_man) in
List.iter (pspec os opt) l
)
let dev_usage os opt = (
Printf.fprintf os "%s\n" usage_msg;
let l = List.rev (opt.dev_man) in
List.iter (pspec os opt) l
)
let full_help opt ()= (
full_usage stdout opt;
exit 0
)
let dev_help opt ()= (
dev_usage stdout opt;
exit 0
)
let unexpected s opt = (
prerr_string ("unexpected argument \""^s^"\"");
......@@ -189,20 +203,24 @@ let file_notfound f opt = (
exit 1
)
let (mkopt : t -> string list -> ?hide:bool -> ?arg:string -> Arg.spec -> string list -> unit) =
fun opt ol ?(hide=false) ?(arg="") se ml ->
type doc_level = Basic | Advanced | Dev
let (mkopt : t -> string list -> ?doc_level:doc_level -> ?arg:string -> Arg.spec ->
string list -> unit) =
fun opt ol ?(doc_level=Basic) ?(arg="") se ml ->
let treto o = opt.opts <- (o, se, "")::opt.opts in
List.iter treto ol ;
let col1 = (String.concat ", " ol)^arg in
if hide
then opt.hidden_man <- (col1, ml)::opt.hidden_man
else opt.user_man <- (col1, ml)::opt.user_man
(*
let tabs = String.make (col - (String.length o) - (String.length arg)) ' ' in
(* (o, se, arg^tabs^m) *)
(o, se, arg^"\n "^m)
*)
match doc_level with
| Basic -> opt.user_man <- (col1, ml)::opt.user_man
| Advanced -> opt.hidden_man <- (col1, ml)::opt.hidden_man
| Dev -> opt.dev_man <- (col1, ml)::opt.dev_man
(*
let tabs = String.make (col - (String.length o) - (String.length arg)) ' ' in
(* (o, se, arg^tabs^m) *)
(o, se, arg^"\n "^m)
*)
(* utils *)
let set_v4_options opt =
global_opt.lv4 <- true;
......@@ -235,101 +253,106 @@ let mkoptab (opt:t) : unit = (
["-exec"]
(Arg.Unit (fun _ ->
opt.exec <- true))
["interpret the program using RIF conventions for I/O."]
["interpret the program using RIF conventions for I/O"]
;
mkopt opt
["--to-c"; "-2c"]
["-2c";"--to-c"]
(Arg.Unit (fun _ -> opt.gen_c <- true))
["generate C code."]
["generate C code"]
;
mkopt opt ~hide:true
["--to-c-dont-inline-predef"]
(Arg.Unit (fun _ ->
global_opt.gen_c_inline_predef <- false))
["do not inline predef calls when generating C code."]
mkopt opt ~doc_level:Basic
["-cc"; "--compile-generated-c"]
(Arg.Unit (fun i -> opt.gen_c <- true; opt.launch_cc <- true))
["Try to compile the generated C files (force -2c)"]
;
mkopt opt
["-rif"]
(Arg.Unit(function s -> opt.rif <- true))
["behave as a rif input file (meaningless without -exec)"]
;
mkopt opt
mkopt opt ~doc_level:Advanced
["-ocaml"]
(Arg.Unit(function s -> opt.gen_ocaml <- true))
["generate ocaml glue code that makes it possible to call the lus2lic interpreter ";
"from ocaml with the current set of arguments (with Lus2licRun.make)."]
"from ocaml with the current set of arguments (with Lus2licRun.make)"]
;
mkopt opt
mkopt opt ~doc_level:Advanced
["-knc"; "--keep-nested-calls"]
(Arg.Unit (fun _ -> global_opt.one_op_per_equation <- false))
["Keep nested calls (inhibited by -en). By default, only one node ";
"per equation is generated (don't work with -exec or -2c)."]
"per equation is generated (don't work with -exec or -2c)"]
;
mkopt opt
mkopt opt ~doc_level:Advanced
["-ei"; "--expand-iterators"]
(Arg.Unit (fun _ -> opt.inline_iterator <- true))
["Expand array iterators (i.e., generate iterator-free code)."]
;
mkopt opt
["Expand array iterators (i.e., generate iterator-free code)"]
;
mkopt opt ~doc_level:Advanced
["-ee"; "--expand-enums"]
(Arg.Unit (fun _ -> global_opt.expand_enums <- AsConst))
[" Translate enums using extern types and consts (for lv4 and ec)."]
[" Translate enums using extern types and consts (for lv4 and ec)"]
;
mkopt opt
mkopt opt ~doc_level:Advanced
["-eei"; "--expand-enums-as-int"]
(Arg.Unit (fun _ -> global_opt.expand_enums <- AsInt))
[" Translate enums using integers (to be kind with data plotters)."]
[" Translate enums using integers (to be kind with data plotters)"]
;
mkopt opt
mkopt opt ~doc_level:Advanced
["-esa"; "--expand-structs-and-arrays"]
(Arg.Unit (fun _ ->
opt.expand_arrays <- true;
opt.inline_iterator <- true))
["Expand structures and arrays (force '-ei')"]
["Expand structures and arrays (forces '-ei')"]
;
mkopt opt
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 *)))
["Expand all node calls in the main node."]
["Expand all node calls in the main node"]
;
mkopt opt
mkopt opt ~doc_level:Advanced
["-et"; "--expand-io-type"]
(Arg.Unit (fun _ -> opt.expand_io_type <- true))
["Expand structured types of the main node (impact the simulation only)."]
["Expand structured types of the main node (impact the simulation only)"]
;
mkopt opt
mkopt opt ~doc_level:Advanced
["-enc"; "---expand-node-call"]
~arg:" <string> "
(Arg.String (fun str ->
opt.expand_node_call <- str::opt.expand_node_call
))
["Expand the call of the specified node (can be used for several nodes)."]
["Expand the call of the specified node (can be used for several nodes)"]
;
mkopt opt
mkopt opt ~doc_level:Advanced
["-oite"; "--optimize-ite"]
(Arg.Unit (fun _ -> opt.optim_ite <- true))
["Transform if/then/else into merge when possible."]
["Transform if/then/else into merge when possible"]
;
mkopt opt
["-lv4"; "--lustre-v4"]
(Arg.Unit (fun _ -> set_v4_options opt))
["Use Lustre V4 syntax (automatically impose '-ei -ee -esa')."]
["Use Lustre V4 syntax (automatically impose '-ei -ee -esa')"]
;
mkopt opt
["-ec"; "--expanded-code"]
(Arg.Unit (fun _ -> set_ec_options opt))
["Generate ec (actually just an alias for '-en -lv4 --no-prefix')."]
["Generate ec (actually just an alias for '-en -lv4 --no-prefix')"]
;
mkopt opt
mkopt opt ~doc_level:Advanced
["-np"; "--no-prefix"]
(Arg.Unit (fun () -> global_opt.no_prefix <- true))
["Do not prefix variable names by their module (beware: variable names may clash with this option)."]
["Do not prefix variable names by their module \n\t(beware: variable names may clash with this option)"]
;
mkopt opt
["--2c-inline-loop";"-2cil"]
mkopt opt ~doc_level:Advanced
["-2cdil";"--to-c-dont-inline-predef"]
(Arg.Unit (fun _ ->
global_opt.gen_c_inline_predef <- false))
["do not inline predef calls when generating C code"]
;
mkopt opt ~doc_level:Advanced
["-2cil";"--2c-inline-loop"]
(Arg.Unit (fun i -> global_opt.soc2c_inline_loops <- true; opt.gen_c <- true))
["inline loops (that comes from array iterators)."]
["inline loops (that come from array iterators)"]
;
mkopt opt
......@@ -352,18 +375,25 @@ let mkoptab (opt:t) : unit = (
mkopt opt
["-h";"-help";"--help"]
(Arg.Unit (help opt))
["Display this message."]
["Display this message"]
;
(* to show Hidden opt *)
mkopt opt
["-more"]
["-more";"--advanced-options"]
(* (Arg.Unit(fun _ -> opt.see_all_options <- true)) *)
(Arg.Unit (full_help opt))
["Show hidden options (for dev purposes)"];
["Show more options"]
;
(* to show Hidden opt *)
mkopt opt ~doc_level:Basic
["-dev";"--dev-options"]
(* (Arg.Unit(fun _ -> opt.see_all_options <- true)) *)
(Arg.Unit (dev_help opt))
["Show experimental/internal options"];
(* HIDDEN *)
(* test lexical *)
mkopt opt ~hide:true
mkopt opt ~doc_level:Dev
["-tlex"; "--test-lexer"]
(Arg.Unit (fun () -> opt.tlex <- true))
["Test the lexical analysis"]
......@@ -375,82 +405,77 @@ let mkoptab (opt:t) : unit = (
["Test the syntactic analysis"]
;
*)
mkopt opt ~hide:true
["-cc"]
(Arg.Unit (fun i -> opt.gen_c <- true; opt.launch_cc <- true))
["Try to compile the generated C files (forces -2c)"]
;
mkopt opt ~hide:true
["--2c-wcet";"-2cw7"]
mkopt opt ~doc_level:Advanced
["-2cw7";"--2c-wcet"]
(Arg.Unit (fun i -> opt.gen_c <- true; opt.gen_wcet <- true))
["generates a main file for computing the wcet. (forces -2c)"]
["generates a main file for computing the wcet (force -2c)"]
;
mkopt opt ~hide:true
["--2c-stack";"-2cs"]
mkopt opt ~doc_level:Dev
["-2cs";"--2c-stack"]
(Arg.Unit (fun i -> opt.gen_c <- true; global_opt.io_transmit_mode <- Stack))
["Soc I/O are transmitted as params of the step functions (forces -2c)"]
["Soc I/O are transmitted as params of the step functions (force -2c)"]
;
mkopt opt ~hide:true
["--2c-heap";"-2ch"]
mkopt opt ~doc_level:Dev
["-2ch";"--2c-heap"]
(Arg.Unit (fun i -> opt.gen_c <- true; global_opt.io_transmit_mode <- Heap))
["Soc I/O are transmitted via a ctx structure in the heap (forces -2c)"]
["Soc I/O are transmitted via a ctx structure in the heap (force -2c)"]
;
mkopt opt ~hide:true
["--2c-heap-and-stack";"-2chs"]
mkopt opt ~doc_level:Dev
["-2chs";"--2c-heap-and-stack"]
(Arg.Unit (fun i -> opt.gen_c <- true; global_opt.io_transmit_mode <- HeapStack))
["I/O of memoryless soc are transmitted via the stack, and the heap otherwise (forces -2c)"]
["I/O of memoryless soc are transmitted via the stack, and the heap otherwise (force -2c)"]
;
mkopt opt ~hide:true
mkopt opt ~doc_level:Dev
["--schedule-simple"]
(Arg.Unit (fun i -> global_opt.schedul_mode <- Simple))
["no re-ordering after topological sort"]
;
mkopt opt ~hide:true
mkopt opt ~doc_level:Dev
["--schedule-sort"]
(Arg.Unit (fun i -> global_opt.schedul_mode <- Sort))
["sort wrt guard before after topological sort"]
;
mkopt opt ~hide:true
mkopt opt ~doc_level:Dev
["--schedule-reorder"]
(Arg.Unit (fun i -> global_opt.schedul_mode <- Reorder))
["re-order Soc.gao after scheduling to increase the clock factorisation"]
;
mkopt opt ~hide:true
["--2c-no-switch"; "-2cns"]
mkopt opt ~doc_level:Advanced
["-2cns";"--2c-no-switch"]
(Arg.Unit (fun () -> global_opt.soc2c_no_switch <-true))
["Use if-then-else instead of switches when generating C codes"]
;
mkopt opt ~hide:true
mkopt opt ~doc_level:Dev
["-interface"]
(Arg.Unit (fun () -> opt.print_interface<-true))
["Print the node interface"]
;
mkopt opt ~hide:true
mkopt opt ~doc_level:Dev
["-unit"]
(Arg.Unit (fun () -> opt.run_unit_test<-true))
["Run embedded unit tests"]
;
mkopt opt ~hide:true
mkopt opt ~doc_level:Advanced
["--precision"]
(Arg.Int (fun i -> opt.precision <- Some i))
["Number of digits after ther dot used to print floats in -exec mode"]
;
mkopt opt ~hide:true
mkopt opt ~doc_level:Dev
["--nonreg-test"]
(Arg.Unit (fun () -> global_opt.nonreg_test <- true))
["Avoid printing full path error msgs to ease non-reg test decision"]
;
mkopt opt ~hide:true
mkopt opt ~doc_level:Dev
["--gen-autotest"]
(Arg.Unit (fun () -> opt.gen_autotest <- true))
["Generate a Lutin Stimulator and a Lustre oracle to compare the result of 2 Lustre compilers"]
;
(* misc debug flag *)
mkopt opt ~hide:true
mkopt opt ~doc_level:Advanced
["-dbg"; "--debug"]
(Arg.Symbol
( Verbose.flag_list (), fun s -> let f = Verbose.get_flag s in Verbose.set_flag f))
......
......@@ -21,6 +21,7 @@ type t = {
mutable opts : (string * Arg.spec * string) list; (* classical Arg option tab used by Arg.parse *)
mutable user_man : (string * string list) list; (* ad hoc tab for pretty prtting usage *)
mutable hidden_man: (string * string list) list; (* ad hoc tab for pretty prtting usage *)
mutable dev_man: (string * string list) list; (* ad hoc tab for pretty prtting usage *)
mutable others: string list;
mutable margin : int;
mutable outfile : string;
......
(** Automatically generated from Makefile *)
let tool = "lus2lic"
let branch = "master"
let commit = "582"
let sha_1 = "bd4b5c35780e03af5677b619bf56c9334eea9e85"
let commit = "583"
let sha_1 = "c07c641bc7ca4dd92038d0b5cc032c5e77615344"
let str = (branch ^ "." ^ commit ^ " (" ^ sha_1 ^ ")")
let maintainer = "jahier@imag.fr"
Supports Markdown
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