Project

General

Profile

Revision cd670fe1 src/backends/C/c_backend_common.ml

View differences:

src/backends/C/c_backend_common.ml
4 4
open Machine_code
5 5

  
6 6

  
7
let print_version fmt =
8
  Format.fprintf fmt 
9
    "/* @[<v>C code generated by %s@,SVN version number %s@,Code is %s compliant */@,@]@."
10
    (Filename.basename Sys.executable_name) 
11
    Version.number 
12
    (if !Options.ansi then "ANSI C90" else "C99")
13

  
14

  
7 15
(* Generation of a non-clashing name for the self memory variable (for step and reset functions) *)
8 16
let mk_self m =
9 17
  mk_new_name (m.mstep.step_inputs@m.mstep.step_outputs@m.mstep.step_locals@m.mmemory) "self"
......
207 215
let pp_c_checks self fmt m =
208 216
  Utils.fprintf_list ~sep:"" (fun fmt (loc, check) -> fprintf fmt "@[<v>%a@,assert (%a);@]@," Location.pp_c_loc loc (pp_c_val self (pp_c_var_read m)) check) fmt m.mstep.step_checks
209 217

  
218

  
219
(********************************************************************************************)
220
(*                      Prototype Printing functions                                        *)
221
(********************************************************************************************)
222

  
223
let print_alloc_prototype fmt (name, static) =
224
  fprintf fmt "%a * %a (%a)"
225
    pp_machine_memtype_name name
226
    pp_machine_alloc_name name
227
    (Utils.fprintf_list ~sep:",@ " pp_c_decl_input_var) static
228

  
229
let print_reset_prototype self fmt (name, static) =
230
  fprintf fmt "void %a (@[<v>%a%t%a *%s@])"
231
    pp_machine_reset_name name
232
    (Utils.fprintf_list ~sep:",@ " pp_c_decl_input_var) static
233
    (Utils.pp_final_char_if_non_empty ",@," static) 
234
    pp_machine_memtype_name name
235
    self
236

  
237
let print_stateless_prototype fmt (name, inputs, outputs) =
238
  fprintf fmt "void %a (@[<v>@[%a%t@]@,@[%a@]@,@])"
239
    pp_machine_step_name name
240
    (Utils.fprintf_list ~sep:",@ " pp_c_decl_input_var) inputs
241
    (Utils.pp_final_char_if_non_empty ",@ " inputs) 
242
    (Utils.fprintf_list ~sep:",@ " pp_c_decl_output_var) outputs
243

  
244
let print_step_prototype self fmt (name, inputs, outputs) =
245
  fprintf fmt "void %a (@[<v>@[%a%t@]@,@[%a@]%t@[%a *%s@]@])"
246
    pp_machine_step_name name
247
    (Utils.fprintf_list ~sep:",@ " pp_c_decl_input_var) inputs
248
    (Utils.pp_final_char_if_non_empty ",@ " inputs) 
249
    (Utils.fprintf_list ~sep:",@ " pp_c_decl_output_var) outputs
250
    (Utils.pp_final_char_if_non_empty ",@," outputs) 
251
    pp_machine_memtype_name name
252
    self
253

  
254
let print_import_prototype fmt (s, _, _) =
255
  fprintf fmt "#include \"%s.h\"@," s
256

  
210 257
(* Local Variables: *)
211
(* compile-command:"make -C .." *)
258
(* compile-command:"make -C ../../.." *)
212 259
(* End: *)

Also available in: Unified diff