Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

lustrec / src / plugins / salsa / salsa_plugin.ml @ 29eebf22

History | View | Annotate | Download (1.33 KB)

1 f6acf47b ploc
open Format 
2 8446bf03 ploc
open Lustre_types
3 f6acf47b ploc
4
let salsa_enabled = ref false
5
    (* "-salsa", Arg.Set salsa_enabled, "activate Salsa optimization <default>"; *)
6
    (* "-no-salsa", Arg.Clear salsa_enabled, "deactivate Salsa optimization"; *)
7
8
9
module Plugin =
10
(struct
11
  include PluginType.Default
12
  let name = "salsa"
13
  
14
  let options = [
15 94c457b7 ploc
        "-debug", Arg.Set SalsaDatatypes.debug, "debug salsa plugin";
16 151117f7 ploc
        "-slice-depth", Arg.Set_int Salsa.Prelude.sliceSize, "salsa slice depth (default is 5)";
17 29eebf22 ploc
        "-disable", Arg.Clear salsa_enabled, "disable salsa";
18
    ]
19 f6acf47b ploc
20
  let activate () = salsa_enabled := true
21
22
  let refine_machine_code prog machine_code = 
23
    if !salsa_enabled then
24
      begin
25
	Compiler_common.check_main ();
26 8e6cab20 ploc
	Log.report ~level:1 (fun fmt -> fprintf fmt ".. @[<v 0>salsa machines optimization@ ");
27 f6acf47b ploc
	(* Selecting float constants for Salsa *)
28
	let constEnv = List.fold_left (
29
	  fun accu c_topdecl ->
30
	    match c_topdecl.top_decl_desc with
31
	    | Const c when Types.is_real_type c.const_type  ->
32
	      (c.const_id, c.const_value) :: accu
33
	    | _ -> accu
34
	) [] (Corelang.get_consts prog) 
35
	in
36 8e6cab20 ploc
	let res =
37
	  List.map 
38
	    (Machine_salsa_opt.machine_t2machine_t_optimized_by_salsa constEnv) 
39
	    machine_code
40
	in
41
	Log.report ~level:1 (fun fmt -> fprintf fmt "@]@ ");
42
	res
43 f6acf47b ploc
      end
44
    else
45
      machine_code
46
  
47
  
48
 end: PluginType.PluginType)