2012-06-27 18:09:30 +02:00
|
|
|
(***********************************************************************)
|
|
|
|
(* *)
|
|
|
|
(* Heptagon *)
|
|
|
|
(* *)
|
|
|
|
(* Gwenael Delaval, LIG/INRIA, UJF *)
|
|
|
|
(* Leonard Gerard, Parkas, ENS *)
|
|
|
|
(* Adrien Guatto, Parkas, ENS *)
|
|
|
|
(* Cedric Pasteur, Parkas, ENS *)
|
2012-06-29 01:43:15 +02:00
|
|
|
(* Marc Pouzet, Parkas, ENS *)
|
2012-06-27 18:09:30 +02:00
|
|
|
(* *)
|
|
|
|
(* Copyright 2012 ENS, INRIA, UJF *)
|
|
|
|
(* *)
|
|
|
|
(* This file is part of the Heptagon compiler. *)
|
|
|
|
(* *)
|
|
|
|
(* Heptagon is free software: you can redistribute it and/or modify it *)
|
|
|
|
(* under the terms of the GNU General Public License as published by *)
|
|
|
|
(* the Free Software Foundation, either version 3 of the License, or *)
|
|
|
|
(* (at your option) any later version. *)
|
|
|
|
(* *)
|
|
|
|
(* Heptagon is distributed in the hope that it will be useful, *)
|
|
|
|
(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)
|
|
|
|
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)
|
|
|
|
(* GNU General Public License for more details. *)
|
|
|
|
(* *)
|
|
|
|
(* You should have received a copy of the GNU General Public License *)
|
|
|
|
(* along with Heptagon. If not, see <http://www.gnu.org/licenses/> *)
|
|
|
|
(* *)
|
|
|
|
(***********************************************************************)
|
|
|
|
|
2010-09-15 09:38:52 +02:00
|
|
|
(* Compiler options *)
|
|
|
|
|
2010-09-30 21:40:04 +02:00
|
|
|
open Names
|
|
|
|
|
2010-09-15 09:38:52 +02:00
|
|
|
(* version of the compiler *)
|
2014-02-21 18:12:07 +01:00
|
|
|
let version = "1.00.06"
|
2010-09-15 09:38:52 +02:00
|
|
|
let date = "DATE"
|
|
|
|
|
|
|
|
(* standard module *)
|
2011-02-07 14:24:17 +01:00
|
|
|
let pervasives_module = Pervasives
|
2010-09-15 09:38:52 +02:00
|
|
|
let standard_lib = "STDLIB"
|
|
|
|
let standard_lib = try Sys.getenv "HEPTLIB" with Not_found -> standard_lib
|
|
|
|
|
|
|
|
(* list of modules initially opened *)
|
|
|
|
let default_used_modules = ref [pervasives_module]
|
|
|
|
let set_no_pervasives () = default_used_modules := []
|
|
|
|
|
|
|
|
(* load paths *)
|
|
|
|
let load_path = ref ([standard_lib])
|
|
|
|
|
|
|
|
|
|
|
|
let set_stdlib p =
|
|
|
|
load_path := [p]
|
|
|
|
and add_include d =
|
|
|
|
load_path := d :: !load_path;;
|
|
|
|
|
|
|
|
(* where is the standard library *)
|
|
|
|
let locate_stdlib () =
|
2011-05-12 16:18:03 +02:00
|
|
|
print_string (try Sys.getenv "HEPTLIB" with Not_found -> standard_lib);
|
2014-10-28 16:34:58 +01:00
|
|
|
print_newline ();
|
|
|
|
exit 0
|
2010-09-15 09:38:52 +02:00
|
|
|
|
|
|
|
let show_version () =
|
|
|
|
Format.printf "The Heptagon compiler, version %s (%s)@."
|
|
|
|
version date;
|
2013-08-04 22:38:03 +02:00
|
|
|
Format.printf
|
2012-06-27 18:09:30 +02:00
|
|
|
"This program is free software and comes with ABSOLUTELY NO WARRANTY.@.";
|
2010-09-15 09:38:52 +02:00
|
|
|
locate_stdlib ()
|
|
|
|
|
|
|
|
|
|
|
|
(* other options of the compiler *)
|
|
|
|
let verbose = ref false
|
|
|
|
let print_types = ref false
|
|
|
|
|
2010-10-04 00:33:05 +02:00
|
|
|
let assert_nodes : name list ref = ref []
|
2010-09-15 09:38:52 +02:00
|
|
|
let add_assert nd = assert_nodes := nd :: !assert_nodes
|
|
|
|
|
|
|
|
let simulation = ref false
|
2011-02-14 15:21:57 +01:00
|
|
|
let simulation_node : name ref = ref ""
|
2010-09-15 09:38:52 +02:00
|
|
|
let set_simulation_node s =
|
|
|
|
simulation := true;
|
2011-02-14 15:21:57 +01:00
|
|
|
simulation_node := s
|
2010-09-15 09:38:52 +02:00
|
|
|
|
2011-05-12 10:08:13 +02:00
|
|
|
let hepts_simulation = ref false
|
|
|
|
|
2010-09-15 09:38:52 +02:00
|
|
|
let create_object_file = ref false
|
|
|
|
|
2011-05-05 11:54:38 +02:00
|
|
|
let boolean = ref false
|
|
|
|
|
2012-11-23 12:23:17 +01:00
|
|
|
let nosink = ref false
|
|
|
|
|
2010-09-15 09:38:52 +02:00
|
|
|
(* Target languages list for code generation *)
|
|
|
|
let target_languages : string list ref = ref []
|
|
|
|
|
|
|
|
let add_target_language s =
|
2011-11-21 01:37:15 +01:00
|
|
|
if s = "z3z" then boolean := true; (* TODO use load_conf instead *)
|
2010-09-15 09:38:52 +02:00
|
|
|
target_languages := s :: !target_languages
|
|
|
|
|
|
|
|
(* Optional path for generated files (C or Java) *)
|
|
|
|
let target_path : string option ref = ref None
|
|
|
|
|
|
|
|
let set_target_path path =
|
|
|
|
target_path := Some path
|
|
|
|
|
|
|
|
let full_type_info = ref false
|
|
|
|
|
2011-11-02 13:14:07 +01:00
|
|
|
let stateful_info = ref false
|
|
|
|
|
2010-12-14 19:34:09 +01:00
|
|
|
let full_name = ref false
|
|
|
|
|
2012-11-26 09:44:23 +01:00
|
|
|
let nbvars = ref false
|
|
|
|
|
2010-12-08 17:31:16 +01:00
|
|
|
let causality = ref true
|
2010-09-15 09:38:52 +02:00
|
|
|
let init = ref true
|
|
|
|
|
2010-09-30 21:40:04 +02:00
|
|
|
let inline : qualname list ref = ref []
|
2010-09-15 09:38:52 +02:00
|
|
|
let add_inlined_node s = inline := s :: !inline
|
|
|
|
|
|
|
|
let flatten = ref false
|
|
|
|
|
2011-03-10 23:00:18 +01:00
|
|
|
let deadcode = ref false
|
|
|
|
|
2010-09-30 21:44:18 +02:00
|
|
|
let tomato = ref false
|
|
|
|
|
|
|
|
let tomato_nodes : qualname list ref = ref []
|
|
|
|
|
|
|
|
let add_tomato_node s = tomato_nodes := s :: !tomato_nodes
|
|
|
|
|
|
|
|
let tomato_check : qualname list ref = ref []
|
|
|
|
|
|
|
|
let add_tomato_check s = tomato_check := s :: !tomato_check
|
2010-09-15 09:43:28 +02:00
|
|
|
|
2010-09-15 09:53:20 +02:00
|
|
|
let do_iterator_fusion = ref false
|
2010-09-15 09:43:28 +02:00
|
|
|
|
2011-04-14 13:53:30 +02:00
|
|
|
let do_scalarize = ref false
|
2011-11-17 15:28:46 +01:00
|
|
|
let do_simplify = ref true
|
2011-04-14 13:53:30 +02:00
|
|
|
|
2011-04-20 15:47:05 +02:00
|
|
|
let do_mem_alloc = ref false
|
2011-09-09 16:05:44 +02:00
|
|
|
let do_linear_typing = ref false
|
|
|
|
|
|
|
|
let do_mem_alloc_and_typing () =
|
|
|
|
do_mem_alloc := true;
|
|
|
|
do_linear_typing := true
|
2011-04-20 15:47:05 +02:00
|
|
|
|
2011-10-23 17:41:50 +02:00
|
|
|
let use_old_scheduler = ref false
|
2011-05-02 16:37:50 +02:00
|
|
|
|
2011-11-21 01:37:15 +01:00
|
|
|
let strict_ssa = ref false
|
2013-08-04 22:38:03 +02:00
|
|
|
(* if this option is on, generate code that first copies the whole
|
|
|
|
array and then modifies one element. Otherwise, generate two loops
|
|
|
|
so that each element in the array is only assigned once. *)
|
2012-06-20 09:17:13 +02:00
|
|
|
let memcpy_array_and_struct = ref true
|
|
|
|
|
|
|
|
let set_strict_ssa () =
|
|
|
|
strict_ssa := true;
|
|
|
|
memcpy_array_and_struct := false
|
2011-11-21 01:37:15 +01:00
|
|
|
|
2012-02-08 16:16:41 +01:00
|
|
|
let unroll_loops = ref false
|
2011-11-21 01:37:15 +01:00
|
|
|
|
2011-11-02 17:23:23 +01:00
|
|
|
let optim = ref false
|
|
|
|
let do_optim () =
|
2013-08-04 22:38:03 +02:00
|
|
|
(* do_iterator_fusion := true; *)(*TODO reset when itfusion is fixed *)
|
2011-11-02 17:23:23 +01:00
|
|
|
do_mem_alloc_and_typing ();
|
|
|
|
tomato := true;
|
2011-11-18 11:55:52 +01:00
|
|
|
deadcode := true
|
|
|
|
|
2011-11-02 17:23:23 +01:00
|
|
|
|
2011-11-21 01:37:15 +01:00
|
|
|
let check_options () =
|
|
|
|
let err m = raise (Arg.Bad m) in
|
|
|
|
if !strict_ssa
|
|
|
|
then (
|
|
|
|
if !do_mem_alloc then err "Unable to activate memory allocation with strict SSA activated.";
|
|
|
|
if !do_linear_typing then err "Unable to activate linear typing with strict SSA activated."
|
|
|
|
)
|
|
|
|
|
2012-01-23 13:36:24 +01:00
|
|
|
let interf_all = ref false
|
2011-11-21 01:37:15 +01:00
|
|
|
|
2012-03-07 17:44:57 +01:00
|
|
|
let time_passes = ref false
|
|
|
|
|
2010-09-15 09:43:28 +02:00
|
|
|
let doc_verbose = "\t\t\tSet verbose mode"
|
|
|
|
and doc_version = "\t\tThe version of the compiler"
|
|
|
|
and doc_print_types = "\t\t\tPrint types"
|
|
|
|
and doc_include = "<dir>\t\tAdd <dir> to the list of include directories"
|
|
|
|
and doc_stdlib = "<dir>\t\tDirectory for the standard library"
|
2011-10-23 17:41:50 +02:00
|
|
|
and doc_object_file = "\t\t\tOnly generate a .epo object file"
|
2010-09-15 09:43:28 +02:00
|
|
|
and doc_sim = "<node>\t\tCreate simulation for node <node>"
|
2011-05-12 10:08:13 +02:00
|
|
|
and doc_hepts = "\t\tSimulation for hepts (graphical simulator)"
|
2010-09-15 09:43:28 +02:00
|
|
|
and doc_locate_stdlib = "\t\tLocate standard libray"
|
|
|
|
and doc_no_pervasives = "\tDo not load the pervasives module"
|
|
|
|
and doc_flatten = "\t\tInline everything."
|
|
|
|
and doc_target =
|
|
|
|
"<lang>\tGenerate code in language <lang>\n\t\t\t(with <lang>=c,"
|
|
|
|
^ " java or z3z)"
|
|
|
|
and doc_full_type_info = "\t\t\tPrint full type information"
|
2012-02-08 16:16:41 +01:00
|
|
|
and doc_stateful_info = "\t\tPrint stateful information"
|
2011-10-23 17:41:50 +02:00
|
|
|
and doc_full_name = "\t\tPrint full variable name information"
|
2012-11-26 09:44:23 +01:00
|
|
|
and doc_nbvars = "\t\tPrint information about number of variables"
|
2010-09-15 09:43:28 +02:00
|
|
|
and doc_target_path =
|
|
|
|
"<path>\tGenerated files will be placed in <path>\n\t\t\t(the directory is"
|
|
|
|
^ " cleaned)"
|
2011-03-10 23:00:18 +01:00
|
|
|
and doc_boolean = "\t\tTranslate enumerated values towards boolean vectors"
|
2012-11-23 12:23:17 +01:00
|
|
|
and doc_nosink = "\t\tSuppress the sink state in sigali equations"
|
2011-03-10 23:00:18 +01:00
|
|
|
and doc_deadcode = "\t\tDeadcode removal"
|
2010-12-08 17:31:16 +01:00
|
|
|
and doc_nocaus = "\t\tDisable causality analysis"
|
2010-09-15 09:43:28 +02:00
|
|
|
and doc_noinit = "\t\tDisable initialization analysis"
|
2011-10-23 17:41:50 +02:00
|
|
|
and doc_assert = "<node>\tInsert run-time assertions for boolean node <node>"
|
|
|
|
and doc_inline = "<node>\tInline node <node>"
|
2010-09-15 09:53:20 +02:00
|
|
|
and doc_itfusion = "\t\tEnable iterator fusion."
|
2010-09-30 21:44:18 +02:00
|
|
|
and doc_tomato = "\t\tEnable automata minimization."
|
2011-11-21 01:37:15 +01:00
|
|
|
and doc_strict_ssa = "\t\tEnsure that the generated code is SSA, even for array elements."
|
2011-09-09 16:05:44 +02:00
|
|
|
and doc_memalloc = "\t\tEnable memory allocation and linear annotations"
|
2011-10-23 17:41:50 +02:00
|
|
|
and doc_memalloc_only = "\tEnable memory allocation"
|
2011-09-09 16:05:44 +02:00
|
|
|
and doc_linear_only = "\t\tEnable linear annotations"
|
2011-10-23 17:41:50 +02:00
|
|
|
and doc_interf_scheduler = "\tUse the old scheduler"
|
2011-11-02 17:23:23 +01:00
|
|
|
and doc_optim = "\t\t\tOptimize with deadcode, tomato, itfusion and memalloc"
|
2012-01-23 13:36:24 +01:00
|
|
|
and doc_interf_all = "\t\tPerform memory allocation on all types"
|
2012-02-08 16:16:41 +01:00
|
|
|
and doc_unroll = "\t\tUnroll all loops"
|
2012-03-07 17:44:57 +01:00
|
|
|
and doc_time_passes = "\t\tTime compilation passes"
|