Project

General

Profile

Revision 3769b712 src/backends/C/c_backend_main.ml

View differences:

src/backends/C/c_backend_main.ml
9 9
(*                                                                  *)
10 10
(********************************************************************)
11 11

  
12
open Lustre_types
13
open Machine_code_types
14
open Corelang
15
open Machine_code_common
12
open Lustrec.Lustre_types
13
open Lustrec.Machine_code_types
14
open Lustrec.Corelang
15
open Lustrec.Machine_code_common
16 16
open Format
17 17
open C_backend_common
18
open Utils
18
open Lustrec.Utils
19 19

  
20 20
module type MODIFIERS_MAINSRC =
21 21
sig
......
65 65
  if not (fst (get_stateless_status m)) then
66 66
  begin  
67 67
    fprintf fmt "@ /* Main memory allocation */@ ";
68
    if (!Options.static_mem && !Options.main_node <> "")
68
    if (!Lustrec.Options.static_mem && !Lustrec.Options.main_node <> "")
69 69
    then (fprintf fmt "%a(static,main_mem);@ " pp_machine_static_alloc_name mname)
70 70
    else (fprintf fmt "%a *main_mem = %a();@ " pp_machine_memtype_name mname pp_machine_alloc_name mname);
71 71
    fprintf fmt "@ /* Initialize the main memory */@ ";
......
86 86
  if not (fst (get_stateless_status m))
87 87
  then
88 88
    fprintf fmt "@ /* Initialize inputs, outputs and memories */@ %a%t%a%t%a(%s);@ "
89
      (Utils.fprintf_list ~sep:"@ " (pp_initialize m main_mem (pp_c_var_read m))) m.mstep.step_inputs
90
      (Utils.pp_newline_if_non_empty m.mstep.step_inputs)
91
      (Utils.fprintf_list ~sep:"@ " (pp_initialize m main_mem (pp_c_var_read m))) m.mstep.step_outputs
92
      (Utils.pp_newline_if_non_empty m.mstep.step_inputs)
89
      (Lustrec.Utils.fprintf_list ~sep:"@ " (pp_initialize m main_mem (pp_c_var_read m))) m.mstep.step_inputs
90
      (Lustrec.Utils.pp_newline_if_non_empty m.mstep.step_inputs)
91
      (Lustrec.Utils.fprintf_list ~sep:"@ " (pp_initialize m main_mem (pp_c_var_read m))) m.mstep.step_outputs
92
      (Lustrec.Utils.pp_newline_if_non_empty m.mstep.step_inputs)
93 93
      pp_machine_init_name mname
94 94
      main_mem
95 95
  else
96 96
    fprintf fmt "@ /* Initialize inputs and outputs */@ %a%t%a@ "
97
      (Utils.fprintf_list ~sep:"@ " (pp_initialize m main_mem (pp_c_var_read m))) m.mstep.step_inputs
98
      (Utils.pp_newline_if_non_empty m.mstep.step_inputs)
99
      (Utils.fprintf_list ~sep:"@ " (pp_initialize m main_mem (pp_c_var_read m))) m.mstep.step_outputs
97
      (Lustrec.Utils.fprintf_list ~sep:"@ " (pp_initialize m main_mem (pp_c_var_read m))) m.mstep.step_inputs
98
      (Lustrec.Utils.pp_newline_if_non_empty m.mstep.step_inputs)
99
      (Lustrec.Utils.fprintf_list ~sep:"@ " (pp_initialize m main_mem (pp_c_var_read m))) m.mstep.step_outputs
100 100

  
101 101
let print_main_clear mname main_mem fmt m =
102 102
  if not (fst (get_stateless_status m))
103 103
  then
104 104
    fprintf fmt "@ /* Clear inputs, outputs and memories */@ %a%t%a%t%a(%s);@ "
105
      (Utils.fprintf_list ~sep:"@ " (pp_clear m main_mem (pp_c_var_read m))) m.mstep.step_inputs
106
      (Utils.pp_newline_if_non_empty m.mstep.step_inputs)
107
      (Utils.fprintf_list ~sep:"@ " (pp_clear m main_mem (pp_c_var_read m))) m.mstep.step_outputs
108
      (Utils.pp_newline_if_non_empty m.mstep.step_inputs)
105
      (Lustrec.Utils.fprintf_list ~sep:"@ " (pp_clear m main_mem (pp_c_var_read m))) m.mstep.step_inputs
106
      (Lustrec.Utils.pp_newline_if_non_empty m.mstep.step_inputs)
107
      (Lustrec.Utils.fprintf_list ~sep:"@ " (pp_clear m main_mem (pp_c_var_read m))) m.mstep.step_outputs
108
      (Lustrec.Utils.pp_newline_if_non_empty m.mstep.step_inputs)
109 109
      pp_machine_clear_name mname
110 110
      main_mem
111 111
  else
112 112
    fprintf fmt "@ /* Clear inputs and outputs */@ %a%t%a@ "
113
      (Utils.fprintf_list ~sep:"@ " (pp_clear m main_mem (pp_c_var_read m))) m.mstep.step_inputs
114
      (Utils.pp_newline_if_non_empty m.mstep.step_inputs)
115
      (Utils.fprintf_list ~sep:"@ " (pp_clear m main_mem (pp_c_var_read m))) m.mstep.step_outputs
113
      (Lustrec.Utils.fprintf_list ~sep:"@ " (pp_clear m main_mem (pp_c_var_read m))) m.mstep.step_inputs
114
      (Lustrec.Utils.pp_newline_if_non_empty m.mstep.step_inputs)
115
      (Lustrec.Utils.fprintf_list ~sep:"@ " (pp_clear m main_mem (pp_c_var_read m))) m.mstep.step_outputs
116 116

  
117 117
let print_main_loop mname main_mem fmt m =
118 118
  let input_values =
......
175 175
  let mname = if String.length mname > 50 then string_of_int (Hashtbl.hash mname) else mname in
176 176
  
177 177
  let main_mem =
178
    if (!Options.static_mem && !Options.main_node <> "")
178
    if (!Lustrec.Options.static_mem && !Lustrec.Options.main_node <> "")
179 179
    then "&main_mem"
180 180
    else "main_mem" in
181 181
  print_usage fmt;
......
185 185
  print_main_inout_declaration m fmt;
186 186
  Plugins.c_backend_main_loop_body_prefix basename mname fmt ();
187 187
  print_main_memory_allocation mname main_mem fmt m;
188
  if !Options.mpfr then
188
  if !Lustrec.Options.mpfr then
189 189
    begin
190 190
      print_global_initialize fmt basename;
191 191
      print_main_initialize mname main_mem fmt m;
......
194 194

  
195 195
  Plugins.c_backend_main_loop_body_suffix fmt ();
196 196
  fprintf fmt "@]@ }@ @ ";
197
  if !Options.mpfr then
197
  if !Lustrec.Options.mpfr then
198 198
    begin
199 199
      print_main_clear mname main_mem fmt m;
200 200
      print_global_clear fmt basename;
......
203 203
  fprintf fmt "@]@ }@."       
204 204

  
205 205
let print_main_header fmt =
206
  fprintf fmt (if !Options.cpp then "#include <stdio.h>@.#include <unistd.h>@.#include \"%s/io_frontend.hpp\"@." else "#include <stdio.h>@.#include <unistd.h>@.#include <string.h>@.#include \"%s/io_frontend.h\"@.")
207
    (Options_management.core_dependency "io_frontend")
206
  fprintf fmt (if !Lustrec.Options.cpp then "#include <stdio.h>@.#include <unistd.h>@.#include \"%s/io_frontend.hpp\"@." else "#include <stdio.h>@.#include <unistd.h>@.#include <string.h>@.#include \"%s/io_frontend.h\"@.")
207
    (Lustrec.Options_management.core_dependency "io_frontend")
208 208

  
209 209
let print_main_c main_fmt main_machine basename prog machines _ (*dependencies*) =
210 210
  print_main_header main_fmt;

Also available in: Unified diff