Project

General

Profile

Download (1.73 KB) Statistics
| Branch: | Tag: | Revision:
1
open Format
2
open Lustre_types
3

    
4
let salsa_enabled = ref false
5

    
6
(* "-salsa", Arg.Set salsa_enabled, "activate Salsa optimization <default>"; *)
7
(* "-no-salsa", Arg.Clear salsa_enabled, "deactivate Salsa optimization"; *)
8

    
9
module Plugin : PluginType.S = struct
10
  include PluginType.Default
11

    
12
  let name = "salsa"
13

    
14
  let options =
15
    [
16
      "-debug", Arg.Set SalsaDatatypes.debug, "debug salsa plugin";
17
      ( "-verbose",
18
        Arg.Set_int Salsa.Log.verbose_level,
19
        "salsa plugin verbose level (default is 0)" );
20
      ( "-slice-depth",
21
        Arg.Set_int Salsa.Prelude.sliceSize,
22
        "salsa slice depth (default is 5)" );
23
      "-disable", Arg.Clear salsa_enabled, "disable salsa";
24
    ]
25

    
26
  let activate () = salsa_enabled := true
27

    
28
  let init () =
29
    if !salsa_enabled then if !SalsaDatatypes.debug then Salsa.Log.debug := true
30

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

    
57
let () =
58
  PluginList.registered :=
59
    (module Plugin : PluginType.S) :: !PluginList.registered
(4-4/4)