Added a generic onfiguration for backends
Each backend gives a function used to enable/disable passes, executed before the beginning of the compilation
This commit is contained in:
parent
2f346f873c
commit
57bc9f210b
|
@ -51,6 +51,8 @@ let compile_program modname source_f =
|
||||||
let close_all_files () = close_in source_c; close_out epci_c; close_out mls_c in
|
let close_all_files () = close_in source_c; close_out epci_c; close_out mls_c in
|
||||||
|
|
||||||
try
|
try
|
||||||
|
(* Activates passes according to the backend used *)
|
||||||
|
Mls2seq.load_conf ();
|
||||||
(* Process the [lexbuf] to an Heptagon AST *)
|
(* Process the [lexbuf] to an Heptagon AST *)
|
||||||
let p = Hept_parser_scoper.parse_program modname lexbuf in
|
let p = Hept_parser_scoper.parse_program modname lexbuf in
|
||||||
(* Process the Heptagon AST *)
|
(* Process the Heptagon AST *)
|
||||||
|
|
|
@ -19,7 +19,6 @@ open Misc
|
||||||
type target =
|
type target =
|
||||||
| Obc of (Obc.program -> unit)
|
| Obc of (Obc.program -> unit)
|
||||||
| Obc_no_params of (Obc.program -> unit)
|
| Obc_no_params of (Obc.program -> unit)
|
||||||
| Obc_scalar of (Obc.program ->unit)
|
|
||||||
| Minils of (Minils.program -> unit)
|
| Minils of (Minils.program -> unit)
|
||||||
| Minils_no_params of (Minils.program -> unit)
|
| Minils_no_params of (Minils.program -> unit)
|
||||||
|
|
||||||
|
@ -39,12 +38,13 @@ let write_obc_file p =
|
||||||
close_out obc;
|
close_out obc;
|
||||||
comment "Generation of Obc code"
|
comment "Generation of Obc code"
|
||||||
|
|
||||||
|
let no_conf () = ()
|
||||||
|
|
||||||
let targets = [ "c", Obc_no_params Cmain.program;
|
let targets = [ "c",(Obc_no_params Cmain.program, no_conf);
|
||||||
"java", Obc_scalar Java_main.program;
|
"java", (Obc_scalar Java_main.program, java_conf);
|
||||||
"obc", Obc write_obc_file;
|
"obc", (Obc write_obc_file, no_conf;
|
||||||
"obc_np", Obc_no_params write_obc_file;
|
"obc_np", (Obc_no_params write_obc_file, no_conf);
|
||||||
"epo", Minils write_object_file ]
|
"epo", (Minils write_object_file, no_conf) ]
|
||||||
|
|
||||||
let generate_target p s =
|
let generate_target p s =
|
||||||
let print_unfolded p_list =
|
let print_unfolded p_list =
|
||||||
|
@ -52,7 +52,7 @@ let generate_target p s =
|
||||||
if !Compiler_options.verbose
|
if !Compiler_options.verbose
|
||||||
then List.iter (Mls_printer.print stderr) p_list in
|
then List.iter (Mls_printer.print stderr) p_list in
|
||||||
let target =
|
let target =
|
||||||
(try List.assoc s targets
|
(try fst (List.assoc s targets)
|
||||||
with Not_found -> language_error s; raise Errors.Error) in
|
with Not_found -> language_error s; raise Errors.Error) in
|
||||||
match target with
|
match target with
|
||||||
| Minils convert_fun ->
|
| Minils convert_fun ->
|
||||||
|
@ -69,10 +69,16 @@ let generate_target p s =
|
||||||
let o_list = List.map Mls2obc.program p_list in
|
let o_list = List.map Mls2obc.program p_list in
|
||||||
let o_list = List.map Obc_compiler.program o_list in
|
let o_list = List.map Obc_compiler.program o_list in
|
||||||
List.iter convert_fun o_list
|
List.iter convert_fun o_list
|
||||||
| Obc_scalar convert_fun ->
|
|
||||||
let p = p |> Mls2obc.program |> Scalarize.program in
|
|
||||||
convert_fun p
|
|
||||||
|
|
||||||
|
let load_conf () =
|
||||||
|
let target_conf s =
|
||||||
|
try
|
||||||
|
let conf = snd (List.assoc s targets) in
|
||||||
|
conf ()
|
||||||
|
with
|
||||||
|
Not_found -> language_error s; raise Errors.Error
|
||||||
|
in
|
||||||
|
List.iter target_conf !target_languages
|
||||||
|
|
||||||
(** Translation into dataflow and sequential languages, defaults to obc. *)
|
(** Translation into dataflow and sequential languages, defaults to obc. *)
|
||||||
let program p =
|
let program p =
|
||||||
|
|
|
@ -3,6 +3,8 @@ open Signature
|
||||||
open Java
|
open Java
|
||||||
open Java_printer
|
open Java_printer
|
||||||
|
|
||||||
|
let java_conf () =
|
||||||
|
Compiler_options.do_scalarize := true
|
||||||
|
|
||||||
(** returns the vd and the pat of a fresh ident from [name] *)
|
(** returns the vd and the pat of a fresh ident from [name] *)
|
||||||
let mk_var ty name =
|
let mk_var ty name =
|
||||||
|
|
|
@ -97,6 +97,8 @@ let add_tomato_check s = tomato_check := s :: !tomato_check
|
||||||
|
|
||||||
let do_iterator_fusion = ref false
|
let do_iterator_fusion = ref false
|
||||||
|
|
||||||
|
let do_scalarize = ref false
|
||||||
|
|
||||||
let doc_verbose = "\t\t\tSet verbose mode"
|
let doc_verbose = "\t\t\tSet verbose mode"
|
||||||
and doc_version = "\t\tThe version of the compiler"
|
and doc_version = "\t\tThe version of the compiler"
|
||||||
and doc_print_types = "\t\t\tPrint types"
|
and doc_print_types = "\t\t\tPrint types"
|
||||||
|
|
Loading…
Reference in a new issue