Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

lustrec / src / plugins / salsa / salsa_plugin.ml @ 151117f7

History | View | Annotate | Download (1.19 KB)

1
open Format 
2
open Lustre_types
3

    
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
        "-debug", Arg.Set SalsaDatatypes.debug, "debug salsa plugin";
16
        "-slice-depth", Arg.Set_int Salsa.Prelude.sliceSize, "salsa slice depth (default is 5)";
17
      ]
18

    
19
  let activate () = salsa_enabled := true
20

    
21
  let refine_machine_code prog machine_code = 
22
    if !salsa_enabled then
23
      begin
24
	Compiler_common.check_main ();
25
	Log.report ~level:1 (fun fmt -> fprintf fmt ".. salsa machines optimization (phase 3)@ ");
26
	(* Selecting float constants for Salsa *)
27
	let constEnv = List.fold_left (
28
	  fun accu c_topdecl ->
29
	    match c_topdecl.top_decl_desc with
30
	    | Const c when Types.is_real_type c.const_type  ->
31
	      (c.const_id, c.const_value) :: accu
32
	    | _ -> accu
33
	) [] (Corelang.get_consts prog) 
34
	in
35
	List.map 
36
	  (Machine_salsa_opt.machine_t2machine_t_optimized_by_salsa constEnv) 
37
	  machine_code 
38
      end
39
    else
40
      machine_code
41
  
42
  
43
 end: PluginType.PluginType)