Project

General

Profile

Download (1.54 KB) Statistics
| Branch: | Tag: | Revision:
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
  
10
module Plugin =
11
(struct
12
  include PluginType.Default
13
  let name = "salsa"
14
  
15
  let options = [
16
        "-debug", Arg.Set SalsaDatatypes.debug, "debug salsa plugin";
17
        "-verbose", Arg.Set_int Salsa.Log.verbose_level, "salsa plugin verbose level (default is 0)";
18
        "-slice-depth", Arg.Set_int Salsa.Prelude.sliceSize, "salsa slice depth (default is 5)";
19
        "-disable", Arg.Clear salsa_enabled, "disable salsa";
20
    ]
21

    
22
  let activate () =
23
    salsa_enabled := true
24
    
25
  let init () =
26
    if !salsa_enabled then
27
      if  !SalsaDatatypes.debug then
28
        Salsa.Log.debug := true
29
  
30
  let refine_machine_code prog machine_code = 
31
    if !salsa_enabled then
32
      begin
33
	Compiler_common.check_main ();
34
	Log.report ~level:1 (fun fmt -> fprintf fmt ".. @[<v 0>salsa machines optimization@ ");
35
	(* Selecting float constants for Salsa *)
36
	let constEnv = List.fold_left (
37
	  fun accu c_topdecl ->
38
	    match c_topdecl.top_decl_desc with
39
	    | Const c when Types.is_real_type c.const_type  ->
40
	      (c.const_id, c.const_value) :: accu
41
	    | _ -> accu
42
	) [] (Corelang.get_consts prog) 
43
	in
44
	let res =
45
	  List.map 
46
	    (Machine_salsa_opt.machine_t2machine_t_optimized_by_salsa constEnv) 
47
	    machine_code
48
	in
49
	Log.report ~level:1 (fun fmt -> fprintf fmt "@]@ ");
50
	res
51
      end
52
    else
53
      machine_code
54
  
55
  
56
 end: PluginType.S)
(4-4/4)