Project

General

Profile

Download (1.27 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
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 ".. @[<v 0>salsa machines optimization@ ");
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
	let res =
36
	  List.map 
37
	    (Machine_salsa_opt.machine_t2machine_t_optimized_by_salsa constEnv) 
38
	    machine_code
39
	in
40
	Log.report ~level:1 (fun fmt -> fprintf fmt "@]@ ");
41
	res
42
      end
43
    else
44
      machine_code
45
  
46
  
47
 end: PluginType.PluginType)
(3-3/3)