1 
2    /**-------------------------------------------------------------------**
3     **                              CLooG                                **
4     **-------------------------------------------------------------------**
5     **                             block.h                               **
6     **-------------------------------------------------------------------**
7     **                    First version: June 11th 2005                  **
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, [email protected]                         *
34  *                                                                            *
35  ******************************************************************************/
36 
37 
38 #ifndef CLOOG_BLOCK_H
39 #define CLOOG_BLOCK_H
40 #if defined(__cplusplus)
41 extern "C"
42   {
43 #endif
44 
45 
46 /**
47  * CloogBlock structure:
48  * this structure contains the informations of a statement block. It may happen
49  * that users are lazy enough to ask CLooG to generate the code for statements
50  * with exactly the same domain/scattering pair (possibly differing by only one
51  * constant) instead of giving only one pair. CLooG provides them a last chance
52  * to save time and memory by trying to find these blocks itself. The block
53  * contains the statement list and the common informations of the statements.
54  * This structure contains also the number of existing active references to it:
55  * because CLooG uses many copies of blocks there is no need to actually copy
56  * these blocks but just to return a pointer to them and to increment the number
57  * of active references. Each time a CloogBlock will be freed, we will decrement
58  * the active reference counter and actually free it if its value is zero.
59  */
60 struct cloogblock
61 {
62   CloogState *state;            /**< State. */
63   CloogStatement * statement ;  /**< The list of statements in the block. */
64   int  nb_scaldims ;            /**< Number of scalar dimensions. */
65   cloog_int_t *scaldims;        /**< Scalar dimension values. */
66   int depth ;                   /**< Original block depth (outer loop number).*/
67   int references ;              /**< Number of references to this structure. */
68   void * usr;		        /**< User field, for library user convenience.
69 				 *   This pointer is not freed when the
70 				 *   CloogBlock structure is freed.
71 			         */
72 } ;
73 typedef struct cloogblock CloogBlock ;
74 
75 
76 /**
77  * CloogBlockList structure:
78  * this structure reprensents a node of a linked list of CloogBlock structures.
79  */
80 struct cloogblocklist
81 { CloogBlock * block ;          /**< An element of the list. */
82   struct cloogblocklist * next ;/**< Pointer to the next element of the list.*/
83 } ;
84 typedef struct cloogblocklist CloogBlockList ;
85 
86 
87 /******************************************************************************
88  *                          Structure display function                        *
89  ******************************************************************************/
90 void cloog_block_print_structure(FILE *, CloogBlock *, int) ;
91 void cloog_block_print(FILE *, CloogBlock *) ;
92 void cloog_block_list_print(FILE *, CloogBlockList *) ;
93 
94 
95 /******************************************************************************
96  *                         Memory deallocation function                       *
97  ******************************************************************************/
98 void cloog_block_free(CloogBlock *) ;
99 void cloog_block_list_free(CloogBlockList *) ;
100 
101 
102 /******************************************************************************
103  *                            Processing functions                            *
104  ******************************************************************************/
105 CloogBlock     * cloog_block_malloc(CloogState *state);
106 CloogBlock     * cloog_block_alloc(CloogStatement *statement, int nb_scaldims,
107 				    cloog_int_t *scaldims, int depth);
108 CloogBlockList * cloog_block_list_malloc(void);
109 CloogBlockList * cloog_block_list_alloc(CloogBlock *) ;
110 CloogBlock     * cloog_block_copy(CloogBlock * block) ;
111 void             cloog_block_merge(CloogBlock *, CloogBlock *) ;
112 
113 #if defined(__cplusplus)
114   }
115 #endif
116 #endif /* define _H */
117 
118