Project

General

Profile

Revision 01d48bb0 src/backends/C/c_backend_src.ml

View differences:

src/backends/C/c_backend_src.ml
293 293
    pp_machine_alloc_name (node_name m)
294 294
    (Utils.fprintf_list ~sep:", " Dimension.pp_dimension) static
295 295

  
296
let print_alloc_const fmt m =
297
  let const_locals = List.filter (fun vdecl -> vdecl.var_dec_const) m.mstep.step_locals in
298
  fprintf fmt "%a%t"
299
    (Utils.fprintf_list ~sep:";@," (pp_c_decl_local_var m)) const_locals
300
    (Utils.pp_final_char_if_non_empty ";@," const_locals)
301

  
296 302
let print_alloc_array fmt vdecl =
297 303
  let base_type = Types.array_base_type vdecl.var_type in
298 304
  let size_types = Types.array_type_multi_dimension vdecl.var_type in
......
321 327
    fprintf fmt "@[<v 2>%a {@,%a%t@,%a%a%t%t@]@,}@.@."
322 328
      print_stateless_prototype (m.mname.node_id, m.mstep.step_inputs, m.mstep.step_outputs)
323 329
      (* locals *)
324
      (Utils.fprintf_list ~sep:";@," pp_c_decl_local_var) m.mstep.step_locals
330
      (Utils.fprintf_list ~sep:";@," (pp_c_decl_local_var m)) m.mstep.step_locals
325 331
      (Utils.pp_final_char_if_non_empty ";@," m.mstep.step_locals)
326 332
      (* check assertions *)
327 333
      (pp_c_checks self) m
......
336 342
    fprintf fmt "@[<v 2>%a {@,%a%t@,%a%a%t%t@]@,}@.@."
337 343
      print_stateless_prototype (m.mname.node_id, (m.mstep.step_inputs@gen_locals@gen_calls), m.mstep.step_outputs)
338 344
      (* locals *)
339
      (Utils.fprintf_list ~sep:";@," pp_c_decl_local_var) base_locals
345
      (Utils.fprintf_list ~sep:";@," (pp_c_decl_local_var m)) base_locals
340 346
      (Utils.pp_final_char_if_non_empty ";" base_locals)
341 347
      (* check assertions *)
342 348
      (pp_c_checks self) m
......
346 352
      (fun fmt -> fprintf fmt "return;")
347 353

  
348 354
let print_reset_code dependencies fmt m self =
349
  fprintf fmt "@[<v 2>%a {@,%a%treturn;@]@,}@.@."
355
  let const_locals = List.filter (fun vdecl -> vdecl.var_dec_const) m.mstep.step_locals in
356
  fprintf fmt "@[<v 2>%a {@,%a%t@,%a%treturn;@]@,}@.@."
350 357
    (print_reset_prototype self) (m.mname.node_id, m.mstatic)
358
    (* constant locals decl *)
359
    (Utils.fprintf_list ~sep:";@," (pp_c_decl_local_var m)) const_locals
360
    (Utils.pp_final_char_if_non_empty ";" const_locals)
361
    (* instrs *)
351 362
    (Utils.fprintf_list ~sep:"@," (pp_machine_instr dependencies m self)) m.minit
352 363
    (Utils.pp_newline_if_non_empty m.minit)
353 364

  
......
359 370
    fprintf fmt "@[<v 2>%a {@,%a%t%a%t@,%a%a%t%t@]@,}@.@."
360 371
      (print_step_prototype self) (m.mname.node_id, m.mstep.step_inputs, m.mstep.step_outputs)
361 372
      (* locals *)
362
      (Utils.fprintf_list ~sep:";@," pp_c_decl_local_var) m.mstep.step_locals
373
      (Utils.fprintf_list ~sep:";@," (pp_c_decl_local_var m)) m.mstep.step_locals
363 374
      (Utils.pp_final_char_if_non_empty ";@," m.mstep.step_locals)
364 375
      (* array mems *)
365 376
      (Utils.fprintf_list ~sep:";@," (pp_c_decl_array_mem self)) array_mems
......
377 388
    fprintf fmt "@[<v 2>%a {@,%a%t@,%a%a%t%t@]@,}@.@."
378 389
      (print_step_prototype self) (m.mname.node_id, (m.mstep.step_inputs@gen_locals@gen_calls), m.mstep.step_outputs)
379 390
      (* locals *)
380
      (Utils.fprintf_list ~sep:";@," pp_c_decl_local_var) base_locals
391
      (Utils.fprintf_list ~sep:";@," (pp_c_decl_local_var m)) base_locals
381 392
      (Utils.pp_final_char_if_non_empty ";" base_locals)
382 393
      (* check assertions *)
383 394
      (pp_c_checks self) m
......
402 413
      (* Alloc function, only if non static mode *)
403 414
      if (not !Options.static_mem) then  
404 415
	begin
405
	  fprintf fmt "@[<v 2>%a {@,%a@]@,}@.@."
416
	  fprintf fmt "@[<v 2>%a {@,%a%a@]@,}@.@."
406 417
	    print_alloc_prototype (m.mname.node_id, m.mstatic)
418
	    print_alloc_const m
407 419
	    print_alloc_code m;
408 420
	end;
409 421
      let self = mk_self m in
......
435 447
  fprintf source_fmt "@[<v>";
436 448
  List.iter (fun c -> print_const_def source_fmt (const_of_top c)) (get_consts prog);
437 449
  fprintf source_fmt "@]@.";
450

  
438 451
  if not !Options.static_mem then
439 452
    begin
440 453
      fprintf source_fmt "/* External allocation function prototypes */@.";
......
446 459
      List.iter (fun m -> fprintf source_fmt "%a;@." print_alloc_prototype (m.mname.node_id, m.mstatic)) machines;
447 460
      fprintf source_fmt "@]@.";
448 461
    end;
462

  
449 463
  (* Print the struct definitions of all machines. *)
450 464
  fprintf source_fmt "/* Struct definitions */@.";
451 465
  fprintf source_fmt "@[<v>";

Also available in: Unified diff