Project

General

Profile

« Previous | Next » 

Revision ca7ff3f7

Added by LĂ©lio Brun 7 months ago

reformatting

View differences:

src/plugins/salsa/salsa_plugin.ml
1
open Format 
1
open Format
2 2
open Lustre_types
3 3

  
4 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 5

  
8
  
9
  
10
module Plugin =
11
(struct
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
12 10
  include PluginType.Default
11

  
13 12
  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";
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";
20 24
    ]
21 25

  
22
  let activate () =
23
    salsa_enabled := true
24
    
26
  let activate () = salsa_enabled := true
27

  
25 28
  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)
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
57 56

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

Also available in: Unified diff