1
2   /**-------------------------------------------------------------------**
3    **                              CLooG                                **
4    **-------------------------------------------------------------------**
5    **                             cloog.c                               **
6    **-------------------------------------------------------------------**
7    **       First version: october 25th 2001, CLooG's birth date !      **
8    **-------------------------------------------------------------------**/
9
10
11/******************************************************************************
12 *               CLooG : the Chunky Loop Generator (experimental)             *
13 ******************************************************************************
14 *                                                                            *
15 * Copyright (C) 2001-2005 Cedric Bastoul                                     *
16 *                                                                            *
17 * This library is free software; you can redistribute it and/or              *
18 * modify it under the terms of the GNU Lesser General Public                 *
19 * License as published by the Free Software Foundation; either               *
20 * version 2.1 of the License, or (at your option) any later version.         *
21 *                                                                            *
22 * This library is distributed in the hope that it will be useful,            *
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU          *
25 * Lesser General Public License for more details.                            *
26 *                                                                            *
27 * You should have received a copy of the GNU Lesser General Public           *
28 * License along with this library; if not, write to the Free Software        *
29 * Foundation, Inc., 51 Franklin Street, Fifth Floor,                         *
30 * Boston, MA  02110-1301  USA                                                *
31 *                                                                            *
32 * CLooG, the Chunky Loop Generator                                           *
33 * Written by Cedric Bastoul, Cedric.Bastoul@inria.fr                         *
34 *                                                                            *
35 ******************************************************************************/
36
37
38# include <stdlib.h>
39# include <stdio.h>
40# include "../include/cloog/cloog.h"
41
42
43int main(int argv, char * argc[])
44{ CloogProgram * program ;
45  CloogOptions * options ;
46  CloogState *state;
47  FILE * input, * output ;
48
49  state = cloog_state_malloc();
50
51  /* Options and input/output file setting. */
52  cloog_options_read(state, argv, argc, &input, &output, &options);
53
54  /* Reading the program informations. */
55  program = cloog_program_read(input,options) ;
56  fclose(input) ;
57
58  /* Generating and printing the code. */
59  program = cloog_program_generate(program,options) ;
60  if (options->structure)
61  cloog_program_print(stdout,program) ;
62  cloog_program_pprint(output,program,options) ;
63  cloog_program_free(program) ;
64
65  /* Printing the allocation statistics if asked. */
66  if (options->leaks) {
67    fprintf(output,"/* Domains    : allocated=%5d, freed=%5d, max=%5d. */\n",
68           state->domain_allocated, state->domain_freed, state->domain_max);
69    fprintf(output,"/* Loops      : allocated=%5d, freed=%5d, max=%5d. */\n",
70           state->loop_allocated, state->loop_freed, state->loop_max);
71    fprintf(output,"/* Statements : allocated=%5d, freed=%5d, max=%5d. */\n",
72           state->statement_allocated, state->statement_freed, state->statement_max);
73    fprintf(output,"/* Blocks     : allocated=%5d, freed=%5d, max=%5d. */\n",
74           state->block_allocated, state->block_freed, state->block_max);
75  }
76
77  /* Inform the user in case of a problem with the allocation statistics. */
78  if ((state->domain_allocated    != state->domain_freed)    ||
79      (state->loop_allocated      != state->loop_freed)      ||
80      (state->statement_allocated != state->statement_freed) ||
81      (state->block_allocated     != state->block_freed))
82  {
83    cloog_msg(options, CLOOG_INFO,
84            "an internal problem has been detected (it should have"
85	    " no\n             consequence on the correctness of the output)."
86	    " Please send (if\n	     you can) your input file, the first line "
87	    "given by typing 'cloog -v'\n	     and your full command "
88            "line call to CLooG including options to\n	     <cedric.bastoul"
89	    "@inria.fr>. Thank you for your participation to get\n"
90	    "	     CLooG better and safer.\n") ;
91  }
92
93  cloog_options_free(options) ;
94  cloog_state_free(state);
95  fclose(output) ;
96  return 0;
97}
98
99