diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 588bb2c50111d4da974a10732d28be26c9ed1ed2..e0c3a7059ecf503f13155545cc750e3781dd514a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -14,11 +14,11 @@ lv6-man: allow_failure: true script: - cd lv6-ref-man - - make + - make artifacts: paths: - doc - + build: stage: build script: @@ -45,7 +45,7 @@ test_opam_test: # can only be updated if the whole pipeline succeeds (to be able te get # the release number). The idea is to rerun this job manually when it # is the case. - + .test_opam_on_mac: stage: test tags: @@ -60,7 +60,7 @@ test_opam_test: # automating version numbering release: - image: node:14-buster-slim + image: node:19-buster-slim stage: release before_script: - apt-get update && apt-get install -y --no-install-recommends git-core ca-certificates diff --git a/lib/soc2c.ml b/lib/soc2c.ml index e65779b5e741c79f7b4b3d49b0793d35b047448a..6897cfd2fd640a7e49dddbad6d064dafa1cfb066 100644 --- a/lib/soc2c.ml +++ b/lib/soc2c.ml @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 24/10/2022 (at 17:38) by Erwan Jahier> *) +(* Time-stamp: <modified the 25/01/2023 (at 17:39) by Erwan Jahier> *) (* let put (os: out_channel) (fmt:('a, unit, string, unit) format4) : 'a = *) @@ -9,8 +9,8 @@ open Soc2cIdent open Data -let rec (type_to_string_rif : Data.t -> string) = - fun v -> +let rec (type_to_string_rif : Data.t -> string) = + fun v -> let str = match v with | String -> "string" @@ -20,8 +20,8 @@ let rec (type_to_string_rif : Data.t -> string) = | Extern _s -> (* view extern type as strings *) "string" (*id2s s*) | Enum (s, _sl) -> id2s s | Struct (sid,_) -> (id2s sid) - | Array (ty, sz) -> Printf.sprintf "%s_%d" (type_to_string_rif ty) sz - | Alpha nb -> "alpha_"^(string_of_int nb) + | Array (ty, sz) -> Printf.sprintf "%s_%d" (type_to_string_rif ty) sz + | Alpha nb -> "alpha_"^(string_of_int nb) | Alias(n,_) -> n in str @@ -30,7 +30,7 @@ let inlined_soc = Soc2cDep.inlined_soc (****************************************************************************) (* returns the pointer of lv6 generated C ident *) - + let pointer_of_ident c_ident = let i_p = try Str.search_forward (Str.regexp "[.]") c_ident 0 with Not_found -> -1 in let i_cb = try Str.search_forward (Str.regexp "[\\[]") c_ident 0 with Not_found -> -1 in @@ -74,32 +74,32 @@ exception Delete_C_files let var_expr_is_not_a_slice = function Slice _ -> false | _ -> true let (gao2c : Soc.tbl -> 'a soc_pp -> Soc.gao -> unit) = - fun stbl sp gao -> - let rec gao2str gao = + fun stbl sp gao -> + let rec gao2str gao = match gao with - | Case(id, id_gao_l,_) -> ( + | Case(id, id_gao_l,_) -> ( let to_case_str (v,gaol) = let gaol_str = (List.map gao2str gaol) in let gaol_block = String.concat "" gaol_str in (id2s v), gaol_block in let cases = List.map to_case_str id_gao_l in - let ctx_opt = + let ctx_opt = let il,ol = sp.soc.profile in if List.mem_assoc id il || List.mem_assoc id ol then - (if SocUtils.ctx_is_global sp.soc - then Soc2cUtil.ML_IO sp.soc.key + (if SocUtils.ctx_is_global sp.soc + then Soc2cUtil.ML_IO sp.soc.key else Soc2cUtil.M_IO) - else Soc2cUtil.Local + else Soc2cUtil.Local in let str = Soc2cUtil.gen_c_switch (Soc2cDep.ctx_var ctx_opt sp.soc id) cases in str ) | Call(vel_out, Assign, vel_in,_) -> ( let l = List.map2 (Soc2cDep.gen_assign_var_expr sp.soc) vel_out vel_in in - String.concat "" l + String.concat "" l ) - | Call(vel_out, Method((inst_name,sk),sname), vel_in,lxm) -> ( + | Call(vel_out, Method((inst_name,sk),sname), vel_in,lxm) -> ( let called_soc = SocUtils.find lxm sk stbl in let _, get_index = Soc2cInstances.to_array (sp.soc).instances in let index = get_index (inst_name,sk) in @@ -116,19 +116,19 @@ let (gao2c : Soc.tbl -> 'a soc_pp -> Soc.gao -> unit) = (try List.iter (fun ve -> assert(var_expr_is_not_a_slice ve)) vel_in; List.iter (fun ve -> assert(var_expr_is_not_a_slice ve)) vel_out; - with _ -> + with _ -> print_string "*** Error. Slices in left part not yet supported in the C code generator, sorry\n"; flush stdout; raise Delete_C_files - ); + ); Soc2cDep.gen_step_call sp.soc called_soc vel_out vel_in ctx "step" "" ) in sp.cput (gao2str gao) let (step2c : Soc.tbl -> 'a soc_pp -> Soc.step_method -> unit) = - fun stbl sp sm -> + 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 @@ -140,36 +140,36 @@ let (step2c : Soc.tbl -> 'a soc_pp -> Soc.step_method -> unit) = | Extern -> () | Predef -> (match sp.soc.key with - | ("Lustre::eq",(Array _)::_,_) -> + | ("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 _)::_,_) -> + 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 + 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 + 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 + sp.cput str | n -> sp.cput (Soc2cDep.get_predef_op n) ) | Gaol(vl, gaol) -> ( - if Lv6MainArgs.global_opt.Lv6MainArgs.gen_wcet then + 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"; + sp.cput "\n"; List.iter (gao2c stbl sp) gaol ) | Iterator(it,it_soc_key,s) -> ( @@ -179,7 +179,7 @@ let (step2c : Soc.tbl -> 'a soc_pp -> Soc.step_method -> unit) = | _, (Array (Array _,_))::_, _ | _, (Array (Struct _,_))::_, _ -> ( match it_soc_key with - | _,(Alpha _::_),_ -> + | _,(Alpha _::_),_ -> let msg = Printf.sprintf "%s\nIterating on polymorphic nodes over arrays of structures %s" (Lxm.details sm.lxm) @@ -189,12 +189,12 @@ let (step2c : Soc.tbl -> 'a soc_pp -> Soc.step_method -> unit) = | _ -> () ) | _,_,_ -> () - ); + ); 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) -> + | Boolred(i,j,k) -> sp.cput (Soc2cDep.get_boolred sp.soc i j k) - | Condact(k,el) -> + | Condact(k,el) -> sp.cput (Soc2cDep.get_condact sp.soc (SocUtils.find sm.lxm k stbl) el) ); let assertions = (SocMap.find sp.soc.key stbl).assertions in @@ -211,7 +211,7 @@ let (step2c : Soc.tbl -> 'a soc_pp -> Soc.step_method -> unit) = ) let (gen_instance_init_call : 'a soc_pp -> Soc.key * int -> unit) = - fun sp (key,i) -> + fun sp (key,i) -> let ctx_name = get_ctx_name key in if Lv6MainArgs.global_opt.Lv6MainArgs.soc2c_inline_loops || i<4 then for k=0 to i-1 do @@ -244,9 +244,9 @@ let (get_used_soc : Soc.t -> KeySet.t) = let rec get_soc_of_gao acc = function | Case(_,l,_) -> List.fold_left - (fun acc (_,gaol) -> List.fold_left get_soc_of_gao acc gaol) acc l + (fun acc (_,gaol) -> List.fold_left get_soc_of_gao acc gaol) acc l | Call(_,Assign,_,_) -> acc - | Call(_,Method((_,sk),_),_,_) + | Call(_,Method((_,sk),_),_,_) | Call(_,Procedure sk,_,_) -> KeySet.add sk acc in let get_soc_of_step acc sm = @@ -257,15 +257,15 @@ let (get_used_soc : Soc.t -> KeySet.t) = | _ -> acc in List.fold_left get_soc_of_step KeySet.empty soc.step - + let one_file() = Lv6MainArgs.global_opt.Lv6MainArgs.soc2c_one_file (* soc2c -- creates c and h file(s) +- creates c and h file(s) - updates/returns the list of created C files *) let (soc2c : int -> out_channel -> out_channel -> Soc.tbl -> Soc.key -> - string list -> Soc.t -> string list) = - fun pass hfile_main_oc cfile_main_oc stbl msoc_key cfiles_acc soc -> + string list -> Soc.t -> string list) = + fun pass hfile_main_oc cfile_main_oc stbl msoc_key cfiles_acc soc -> if inlined_soc soc.key then cfiles_acc (* don't generate code if inlined *) else let ctx_name = get_ctx_name soc.key in let ctx_name_type = ctx_name^"_type" in @@ -335,7 +335,7 @@ let (soc2c : int -> out_channel -> out_channel -> Soc.tbl -> Soc.key -> cfmt "\n}\n"; if SocUtils.is_memory_less soc - then () (*no ctx at all in this case ! *) + then () (*no ctx at all in this case ! *) else if Lv6MainArgs.global_opt.Lv6MainArgs.soc2c_global_ctx then @@ -347,8 +347,8 @@ let (soc2c : int -> out_channel -> out_channel -> Soc.tbl -> Soc.key -> // ctx->client_data = cdata; %s_reset(ctx); } -" ctx_name - ) +" ctx_name + ) else ( cfmt "// Memory allocation for %s\n" ctx_name; @@ -361,7 +361,7 @@ let (soc2c : int -> out_channel -> out_channel -> Soc.tbl -> Soc.key -> %s_reset(ctx); return ctx; } -" ctx_name ctx_name ctx_name ctx_name) +" ctx_name ctx_name ctx_name ctx_name) ); cfmt "// Step function(s) for %s\n" ctx_name; List.iter (step2c stbl sp) soc.step; @@ -386,54 +386,54 @@ module ItemKeySet = Set.Make(struct type t = Lic.item_key let compare = compare fixpoint", that should be done by the caller. it is recursive just to deal with array of arrays *) let (find_typedep_nf : Lic.type_ -> Lic.item_key list) = - fun t -> + fun t -> let rec aux top = function | Lic.Bool_type_eff | Lic.Int_type_eff | Lic.Real_type_eff - | Lic.External_type_eff _ | Lic.TypeVar _ + | Lic.External_type_eff _ | Lic.TypeVar _ -> [] - | Lic.Abstract_type_eff(name,_) - | Lic.Enum_type_eff(name,_) -> if top then [] (* avoid self dep *) else [name] + | Lic.Abstract_type_eff(name,_) + | Lic.Enum_type_eff(name,_) -> if top then [] (* avoid self dep *) else [name] | Lic.Array_type_eff(t,_) -> aux false t - | Lic.Struct_type_eff(name, fl) -> + | Lic.Struct_type_eff(name, fl) -> if not top then [name] else List.flatten(List.map (fun (_,(t,_)) -> aux false t) fl) in aux true t let (is_extern_type: Lic.type_ -> bool) = - function + function | Lic.External_type_eff _ -> true | _ -> false (* returns the typedef *) -let user_typedef licprg = +let user_typedef licprg = let to_c k t = Printf.sprintf "typedef %s;\n" (Soc2cUtil.lic_type_to_c t (long2s k)) in - let rec (typedef_to_string : Lic.item_key -> Lic.type_ -> string * ItemKeySet.t -> + let rec (typedef_to_string : Lic.item_key -> Lic.type_ -> string * ItemKeySet.t -> string * ItemKeySet.t) = fun k t acc -> (* topological sort according to type dep *) if is_extern_type t then acc else if ItemKeySet.mem k (snd acc) then acc else let type_list = find_typedep_nf t in - let acc = List.fold_left - (fun acc k -> + let acc = List.fold_left + (fun acc k -> match LicPrg.find_type licprg k with | Some t -> typedef_to_string k t acc | None -> acc (* occurs ? *) - ) - acc type_list + ) + acc type_list in ((fst acc)^(to_c k t), ItemKeySet.add k (snd acc)) in fst (LicPrg.fold_types typedef_to_string licprg ("",ItemKeySet.empty)) - + let (typedef_all : LicPrg.t -> Soc.tbl -> Soc.t -> string) = fun _licprg soc_tbl main_soc -> (* We need to print the ctx typedef in a good order (w.r.t. typedef dependencies). To do that, we traverse - the tree of soc instances which root is the main soc. + the tree of soc instances which root is the main soc. *) (* Soc with memory can be used several times; hence we mark via this @@ -463,25 +463,25 @@ let (typedef_all : LicPrg.t -> Soc.tbl -> Soc.t -> string) = acc,visited in - let soc_ctx_typedef_with_mem = + let soc_ctx_typedef_with_mem = if SocUtils.ctx_is_global main_soc then "" else fst (soc_with_mem ("",visited) main_soc) in (* Then we still have to print memoryless soc that can not appear - as a soc instance + as a soc instance let soc_ctx_typedef_without_mem = let socs = Soc.SocMap.bindings soc_tbl in let socs = snd (List.split socs) in let memless_soc_to_string acc soc = if SocUtils.is_memory_less soc then acc^(Soc2cDep.typedef_of_soc soc) else acc - in + in List.fold_left memless_soc_to_string "" socs - in + in "// Memoryless soc ctx typedef \n"^soc_ctx_typedef_without_mem ^ *) "// Memoryfull soc ctx typedef \n"^soc_ctx_typedef_with_mem - + @@ -497,9 +497,9 @@ let rec (const_to_c: Lic.const -> string) = | Lic.Enum_const_eff (s,Lic.Enum_type_eff(_,ll)) -> Lic.enum_to_string s ll | Lic.Enum_const_eff _ -> assert false (* SNO *) | Lic.Struct_const_eff (fl, _t) -> ( - let string_of_field = - function (id, veff) -> - (Lv6Id.to_string id)^" = "^ (const_to_c veff) + let string_of_field = + function (id, veff) -> + (Lv6Id.to_string id)^" = "^ (const_to_c veff) in let flst = List.map string_of_field fl in (* (string_of_type_eff t)^ *) @@ -514,7 +514,7 @@ let rec (const_to_c: Lic.const -> string) = (* returns a pair: the lhs for the .h, the rhs for the .c Indeed, arrays constant need to be defined in a .c *) -let (constdef : LicPrg.t -> string*string) = +let (constdef : LicPrg.t -> string*string) = fun licprg -> let rec (array_type_to_c: string -> string -> int -> Lic.type_ -> string) = fun name acc s t -> match t with @@ -526,7 +526,7 @@ let (constdef : LicPrg.t -> string*string) = | Lic.External_type_eff _ -> assert false | Lic.Abstract_type_eff _ -> assert false | Lic.Enum_type_eff _ -> assert false - | Lic.Struct_type_eff _ -> assert false + | Lic.Struct_type_eff _ -> assert false | Lic.TypeVar _ -> assert false in let to_c k = function @@ -537,9 +537,9 @@ let (constdef : LicPrg.t -> string*string) = let s = List.length vl in let tab_exp = "{"^(String.concat ", " vl)^"}" in Printf.sprintf "extern const %s;\n" (array_type_to_c (long2s k) "" s t), - Printf.sprintf "const %s = %s;\n" (array_type_to_c (long2s k) "" s t) tab_exp - ) - | c -> + Printf.sprintf "const %s = %s;\n" (array_type_to_c (long2s k) "" s t) tab_exp + ) + | c -> Printf.sprintf "#define %s %s\n" (long2s k) (const_to_c c),"" @@ -557,17 +557,17 @@ let (constdef : LicPrg.t -> string*string) = (****************************************************************************) let (gen_memoryless_ctx : Soc.tbl -> string) = - fun stbl -> + fun stbl -> let do_soc _sk soc acc = - if (SocUtils.ctx_is_global soc) && not (inlined_soc soc.key) then + if (SocUtils.ctx_is_global soc) && not (inlined_soc soc.key) then let ctx_name = get_ctx_name soc.key in - let ctx_name_type = ctx_name^"_type" in - Printf.sprintf "%sextern %s %s;\n" acc ctx_name_type ctx_name + let ctx_name_type = ctx_name^"_type" in + Printf.sprintf "%sextern %s %s;\n" acc ctx_name_type ctx_name else acc in let acc = Soc.SocMap.fold do_soc stbl "" in - if acc = "" then "" else + if acc = "" then "" else Printf.sprintf "\n// Allocation of memoryless ctx\n%s" acc (* a shortcut *) @@ -583,7 +583,7 @@ let gen_main_loop_body inputs outputs soc ctx = let outputs_t = List.map to_c_decl outputs in let inputs_decl = Printf.sprintf "\n %s" (String.concat "" inputs_t) in let outputs_decl = Printf.sprintf "%s" (String.concat "" outputs_t) in - let ctx_decl = if SocUtils.is_memory_less soc then "" else + let ctx_decl = if SocUtils.is_memory_less soc then "" else " "^ctx^"_type* ctx = "^ ctx^"_new_ctx(NULL);\n" in inputs_decl ^ outputs_decl ^ ctx_decl @@ -597,7 +597,7 @@ let gen_main_loop_body inputs outputs soc ctx = " ^ (if SocUtils.is_memory_less soc then ctx^"" else ctx^"_type* ctx ;\n"^ ctx^"_reset(ctx);") ) - ) + ) else (match io_transmit_mode () with | Lv6MainArgs.Stack -> @@ -606,7 +606,7 @@ let gen_main_loop_body inputs outputs soc ctx = let outputs_t = List.map to_c_decl outputs in let inputs_decl = Printf.sprintf "\n %s" (String.concat "" inputs_t) in let outputs_decl = Printf.sprintf "%s" (String.concat "" outputs_t) in - let ctx_decl = if SocUtils.is_memory_less soc then "" else + let ctx_decl = if SocUtils.is_memory_less soc then "" else ctx^"_type ctx_struct;\n "^ ctx^"_type* ctx = &ctx_struct;\n "^ ctx^"_init(ctx);" @@ -614,12 +614,12 @@ let gen_main_loop_body inputs outputs soc ctx = inputs_decl ^ outputs_decl ^ ctx_decl | Lv6MainArgs.Heap -> (" /* Context allocation */ -" ^ (if SocUtils.is_memory_less soc then +" ^ (if SocUtils.is_memory_less soc then ctx^"_type* ctx = &"^ctx^";\n" else ( ctx^"_type ctx_struct; "^ctx^"_type* ctx = & ctx_struct; - "^ctx^"_init(ctx); + "^ctx^"_init(ctx); ") ) ) @@ -629,7 +629,7 @@ let gen_main_loop_body inputs outputs soc ctx = else ctx^"_type* ctx ;\n"^ ctx^"_reset(ctx);") ) ) - + (****************************************************************************) let (gen_main_wcet_file : Soc.t -> string -> Soc.tbl -> unit) = fun soc base _stbl -> @@ -644,7 +644,7 @@ let (gen_main_wcet_file : Soc.t -> string -> Soc.tbl -> unit) = Lv6util.entete oc "/*" "*/"; putc (" #include <stdlib.h> -#include \""^base0 ^".h\" +#include \""^base0 ^".h\" int main(){" ^ (gen_main_loop_body inputs outputs soc ctx)); (match io_transmit_mode () with | Lv6MainArgs.Stack -> @@ -653,7 +653,7 @@ int main(){" ^ (gen_main_loop_body inputs outputs soc ctx)); let io = String.concat "," (i@o) in let io = if SocUtils.is_memory_less soc then io else if io = "" then "ctx" else io^",ctx" in putc (" " ^ step^"("^io^"); - return 0; + return 0; } " ); @@ -661,7 +661,7 @@ int main(){" ^ (gen_main_loop_body inputs outputs soc ctx)); | Lv6MainArgs.Heap -> let io = if SocUtils.is_memory_less soc then "" else "ctx" in putc (" " ^ step^"("^io^"); - return 0; + return 0; } " ); @@ -841,7 +841,8 @@ void _put_string(char* n, char* _V){ /* I/O functions for the main loop **********************/ void get_inputs ("^ - (if SocUtils.is_memory_less soc then "" else ctx^"_type* ctx, ")^ + (if SocUtils.is_memory_less soc then "" else ctx^"_type* ctx")^ + (if inputs = [] then "" else "," ) ^ (String.concat "," (List.map (fun (id,t) -> @@ -910,7 +911,8 @@ static int ISATTY; /* I/O functions for the main loop **********************/ void print_rif_declaration(); void get_inputs ("^ - (if SocUtils.is_memory_less soc then "" else ctx^"_type*, ")^ + (if SocUtils.is_memory_less soc then "" else ctx^"_type*")^ + (if inputs = [] then "" else "," ) ^ (String.concat "," (List.map (fun (_id,t) -> @@ -942,7 +944,8 @@ int main(){ fflush(stdout); ++_s; - get_inputs("^(if SocUtils.is_memory_less soc then "" else "ctx,")^ + get_inputs("^(if SocUtils.is_memory_less soc then "" else "ctx")^ + (if inputs = [] then "" else "," ) ^ (String.concat "," (List.map (fun (id,t) -> match t with | Array(_,_) -> id @@ -963,7 +966,7 @@ int main(){ in putc (" " ^ step^"("^io^"); print_outputs("^(String.concat "," (List.map fst (outputs_exp)))^"); - // printf(\"" ^ (String.concat " " inputs_fmt)^ " #outs " ^ + // printf(\"" ^ (String.concat " " inputs_fmt)^ " #outs " ^ (String.concat " " outputs_fmt)^ "\\n\"," ^ (String.concat "," (List.map (fun (id,_) -> ""^id ) (inputs_exp@outputs_exp)))^ @@ -971,7 +974,7 @@ int main(){ }" ) else ( putc (" " ^ step^"(ctx); - // printf(\"" ^ (String.concat " " inputs_fmt)^ " #outs " ^ + // printf(\"" ^ (String.concat " " inputs_fmt)^ " #outs " ^ (String.concat " " outputs_fmt)^ "\\n\"," ^ (String.concat "," (List.map (fun (id,_) -> "ctx->"^id ) (inputs_exp@outputs_exp)))^ @@ -986,7 +989,7 @@ int main(){ let (gen_loop_file4ogensim : Soc.t -> string -> out_channel -> Soc.tbl -> unit) = - fun soc base oc _stbl -> + fun soc base oc _stbl -> let putc s = output_string oc s in let ctx = get_ctx_name soc.key in let step = Soc2cDep.step_name soc.key "step" in @@ -1002,11 +1005,11 @@ let (gen_loop_file4ogensim : Soc.t -> string -> out_channel -> Soc.tbl -> unit) Lv6util.entete oc "/*" "*/"; putc ("#include \""^base0 ^".h\" - + #define tickBegin 0xe0000000 "); List.iteri define_define (inputs_io@ outputs_io); - + putc ("\n int main(){\n" ^ gen_main_loop_body inputs outputs soc ctx); putc (" /* Main loop */ @@ -1016,14 +1019,14 @@ let (gen_loop_file4ogensim : Soc.t -> string -> out_channel -> Soc.tbl -> unit) *((unsigned int*)tickBegin) = 0; // load inputs from the memory locations "); - List.iter2 - (fun (id,t) (id_flat,_) -> + List.iter2 + (fun (id,t) (id_flat,_) -> let t = Soc2cUtil.data_type_to_c t "" in - let str = + let str = Printf.sprintf " %s = *((%s*)_%s);\n" id t id_flat in putc str - ) + ) inputs_exp inputs_io; assert (io_transmit_mode () = Lv6MainArgs.Stack); @@ -1037,29 +1040,29 @@ let (gen_loop_file4ogensim : Soc.t -> string -> out_channel -> Soc.tbl -> unit) // now write the output to the memory which will be output to Lurette "); List.iter2 - (fun (id,t) (id_flat,_) -> + (fun (id,t) (id_flat,_) -> let t = Soc2cUtil.data_type_to_c t "" in let str = Printf.sprintf " *((%s*)_%s) = %s;\n" t id id_flat in putc str - ) + ) outputs_io outputs_exp; - putc "}\n return 1; - } + putc "}\n return 1; + } " (****************************************************************************) (* The entry point for lv6 --to-c *) let (f : Lv6MainArgs.t -> Soc.key -> Soc.tbl -> LicPrg.t -> unit) = - fun args msoc stbl licprg -> + fun args msoc stbl licprg -> let socs = Soc.SocMap.bindings stbl in - let socs = snd (List.split socs) in + let socs = snd (List.split socs) in (* XXX que fait-on pour les soc predef ? *) (* let _, socs = List.partition is_predef socs in *) let dir = Lv6MainArgs.global_opt.Lv6MainArgs.dir in - let base0 = + let base0 = if args.Lv6MainArgs.outfile = "" then - string_of_soc_key msoc + string_of_soc_key msoc else Filename.basename ( try Filename.chop_extension args.Lv6MainArgs.outfile @@ -1089,7 +1092,7 @@ let (f : Lv6MainArgs.t -> Soc.key -> Soc.tbl -> LicPrg.t -> unit) = let assign_ext_types_list = (Soc2cGenAssign.gen_used_types socs) in let main_soc = SocUtils.find_no_exc msoc stbl in (* Generate ext files if necessary *) - let needs_cfile, needs_hfile = + let needs_cfile, needs_hfile = Soc2cExtern.gen_files main_soc stbl licprg ext_cfile ext_hfile hfile in Lv6util.entete consts_h_oc "/*" "*/" ; @@ -1123,7 +1126,7 @@ typedef float _float; puth "#include \"lustre_consts.h\""; output_string och (" -// User typedef +// User typedef #ifndef _"^base0^"_TYPES #define _"^base0^"_TYPES\n"); @@ -1154,7 +1157,7 @@ typedef float _float; putc (Printf.sprintf "#include \"%s\"\n" hfile0); (* putc (Soc2cExtern.cpy_declaration licprg); *) putc (Soc2cExtern.const_declaration licprg); - let cfiles_acc = + let cfiles_acc = if io_transmit_mode () = Lv6MainArgs.Heap then ( if socs = [] then [] else ( putc "/////////////////////////////////////////////////\n"; @@ -1258,7 +1261,7 @@ struct dro_desc_t DRO_DESC_NAME = { puth "/////////////////////////////////////////////////\n"; if assign_ext_types_list <> [] then ( output_string och "\n// Defining array and extern types assignments \n"; - if Lv6MainArgs.global_opt.Lv6MainArgs.gen_wcet then + if Lv6MainArgs.global_opt.Lv6MainArgs.gen_wcet then List.iter (fun t -> output_string och (Soc2cGenAssign.f_forloop t)) assign_ext_types_list else @@ -1286,14 +1289,14 @@ struct dro_desc_t DRO_DESC_NAME = { Filename.basename (Filename.chop_extension (List.hd args.Lv6MainArgs.infiles)) in let execfile = if args.Lv6MainArgs.outfile = "" then (node^".exec") - else args.Lv6MainArgs.outfile + else args.Lv6MainArgs.outfile in let cflags = try Sys.getenv "CFLAGS" with Not_found -> "" in let ocsh = open_out (Filename.concat dir (node ^".sh")) in let main_files, ogensim_main_file, gcc = - if Lv6MainArgs.global_opt.Lv6MainArgs.gen_wcet then - base^"_main.c",base^"_loop.c","gcc --specs=linux.specs -g" - else + if Lv6MainArgs.global_opt.Lv6MainArgs.gen_wcet then + base^"_main.c",base^"_loop.c","gcc --specs=linux.specs -g" + else loop_readinput_cfile, "I am a dead string...", "$C_COMPILER" in let ogensim_exe = node^"4ogensim.exec" in @@ -1376,8 +1379,8 @@ $fixffx $ARM_LOOPLOC -i $n_n.ff > $n_n.fixed.ffx "$OTAWA $execfile $main_step -f $n_n.fixed.ffx -f $n_n.ffx --add-prop otawa::ilp::OUTPUT_PATH=$main_step.lp \\\n\t>"^ "$n_n.owcet.arm.log 2>&1 && \n"^ "grep WCET $n_n.owcet.arm.log | cut -d \"=\" -f 2 > "^ - "$n.wcet &&\n\n" ^ - "WCET=`cat $n.wcet` \n\n" ^ + "$n.wcet &&\n\n" ^ + "WCET=`cat $n.wcet` \n\n" ^ "# Let's compile the c files for ogensim \n" ^ " fi @@ -1405,7 +1408,7 @@ fi ) else gcc in - output_string ocsh (gcc^"\n\n"); + output_string ocsh (gcc^"\n\n"); flush ocsh; close_out types_h_oc; @@ -1427,7 +1430,7 @@ fi print_string ("you can compile those files calling: "^call_script^"\n"); flush stdout with - | Delete_C_files -> + | Delete_C_files -> close_out types_h_oc; close_out occ; close_out och;