![Cédric Pasteur](/assets/img/avatar_default.png)
- Many changes to make Hept2mls, mls2obc, etc compile with the api changes - Added Callgraph_mapfold: starting from a main program, generates the list of instances of each node necessary and creates them. - Mls2seq deals with giving to the code generators the correct source (mls or obc, wit or without static parameters) It is now possible to use parametrized nodes that are defined in other files. For that to work, the first file has to be compiled to an object file: heptc -c mylib.ept which creates a mylib.epo file. Compiling the main file will then generate all the instances of parametrized nodes from the lib (only the called nodes will be compiled, but all the nodes in the main file are compiled).
74 lines
2.5 KiB
OCaml
74 lines
2.5 KiB
OCaml
(**************************************************************************)
|
|
(* *)
|
|
(* Heptagon *)
|
|
(* *)
|
|
(* Author : Marc Pouzet *)
|
|
(* Organization : Demons, LRI, University of Paris-Sud, Orsay *)
|
|
(* *)
|
|
(**************************************************************************)
|
|
|
|
open Compiler_utils
|
|
open Obc
|
|
open Minils
|
|
open Misc
|
|
|
|
type target_source =
|
|
| Obc
|
|
| Obc_no_params
|
|
| Minils
|
|
| Minils_no_params
|
|
|
|
type convert_fun =
|
|
| Obc_fun of (Obc.program -> unit)
|
|
| Mls_fun of (Minils.program -> unit)
|
|
|
|
let write_object_file p =
|
|
let filename = (filename_of_name p.Minils.p_modname)^".epo" in
|
|
let epoc = open_out_bin filename in
|
|
comment "Generating of object file";
|
|
output_value epoc p;
|
|
close_out epoc
|
|
|
|
let write_obc_file p =
|
|
let obc_name = (filename_of_name p.Obc.p_modname)^".obc" in
|
|
let obc = open_out obc_name in
|
|
comment "Generation of Obc code";
|
|
Obc_printer.print obc p;
|
|
close_out obc
|
|
|
|
let targets = [ ("obc", (Obc, Obc_fun write_obc_file));
|
|
("epo", (Minils, Mls_fun write_object_file));
|
|
("c", (Obc_no_params, Obc_fun Cmain.program));
|
|
(* ("java", (Obc, Javamain.program));
|
|
("vhdl", (Minils_no_params, Vhdl.program)) *)]
|
|
|
|
let generate_target p s =
|
|
try
|
|
let source, convert_fun = List.assoc s targets in
|
|
match source, convert_fun with
|
|
| Minils, Mls_fun convert_fun ->
|
|
convert_fun p
|
|
| Obc, Obc_fun convert_fun ->
|
|
let o = Mls2obc.program p in
|
|
convert_fun o
|
|
| Minils_no_params, Mls_fun convert_fun ->
|
|
let p_list = Callgraph_mapfold.program p in
|
|
List.iter convert_fun p_list
|
|
| Obc_no_params, Obc_fun convert_fun ->
|
|
let p_list = Callgraph_mapfold.program p in
|
|
let o_list = List.map Mls2obc.program p_list in
|
|
List.iter convert_fun o_list
|
|
with
|
|
| Not_found -> language_error s
|
|
|
|
let program p =
|
|
(* Translation into dataflow and sequential languages *)
|
|
let targets =
|
|
if !create_object_file then
|
|
["epo"]
|
|
else
|
|
match !target_languages with
|
|
| [] -> ["obc"];
|
|
| l -> l
|
|
in
|
|
List.iter (generate_target p) targets;
|