1 /* Translation of CLAST (CLooG AST) to Gimple.
2 Copyright (C) 2009, 2010 Free Software Foundation, Inc.
3 Contributed by Sebastian Pop <sebastian.pop@amd.com>.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #ifndef GCC_GRAPHITE_CLAST_TO_GIMPLE_H
22 #define GCC_GRAPHITE_CLAST_TO_GIMPLE_H
24 #include "graphite-cloog-util.h"
25 /* Data structure for CLooG program representation. */
27 typedef struct cloog_prog_clast
{
29 struct clast_stmt
*stmt
;
32 /* Stores BB's related PBB. */
34 typedef struct bb_pbb_def
40 /* From graphite-opencl.c */
41 extern void opencl_transform_clast (struct clast_stmt
*, sese
, edge
,
43 extern void graphite_opencl_finalize (edge
);
44 extern void graphite_opencl_init (void);
46 /* From graphite-clast-to-gimple.c */
47 extern bool gloog (scop_p
, htab_t
);
48 extern cloog_prog_clast
scop_to_clast (scop_p
, CloogState
*);
49 extern void debug_clast_stmt (struct clast_stmt
*);
50 extern void print_clast_stmt (FILE *, struct clast_stmt
*);
51 extern void build_iv_mapping (VEC (tree
, heap
) *, sese
, VEC (tree
, heap
) *,
52 htab_t
, struct clast_user_stmt
*, htab_t
);
53 extern struct loop
*graphite_create_new_loop (sese
, edge
, struct clast_for
*,
54 loop_p
, VEC (tree
, heap
) **,
56 extern edge
graphite_create_new_loop_guard (sese
, edge
, struct clast_for
*,
57 VEC (tree
, heap
) *, htab_t
, htab_t
);
58 extern edge
graphite_create_new_guard (sese
, edge
, struct clast_guard
*,
59 VEC (tree
, heap
) *, htab_t
, htab_t
);
60 extern tree
clast_to_gcc_expression (tree
, struct clast_expr
*, sese
,
61 VEC (tree
, heap
) *, htab_t
, htab_t
);
62 extern tree
gcc_type_for_iv_of_clast_loop (struct clast_for
*, int, tree
, tree
);
64 extern tree
gcc_type_for_clast_expr (struct clast_expr
*, sese
,
65 VEC (tree
, heap
) *, htab_t
, htab_t
);
66 extern tree
clast_name_to_gcc (clast_name_p
, sese
, VEC (tree
, heap
) *,
68 extern void save_clast_name_index (htab_t
, const char *, int);
70 /* Hash function for data base element BB_PBB. */
72 static inline hashval_t
73 bb_pbb_map_hash (const void *bb_pbb
)
75 return (hashval_t
)(((const bb_pbb_def
*)bb_pbb
)->bb
->index
);
78 /* Compare data base element BB_PBB1 and BB_PBB2. */
81 eq_bb_pbb_map (const void *bb_pbb1
, const void *bb_pbb2
)
83 const bb_pbb_def
*bp1
= (const bb_pbb_def
*) bb_pbb1
;
84 const bb_pbb_def
*bp2
= (const bb_pbb_def
*) bb_pbb2
;
85 return (bp1
->bb
->index
== bp2
->bb
->index
);
88 /* Returns the scattering dimension for STMTFOR.
90 The relationship between dimension in scattering matrix
91 and the DEPTH of the loop is:
92 DIMENSION = 2*DEPTH - 1
95 static inline int get_scattering_level (int depth
)
100 /* Stores the INDEX in a vector for a given clast NAME. */
102 typedef struct clast_name_index
106 } *clast_name_index_p
;
108 /* Computes a hash function for database element ELT. */
110 static inline hashval_t
111 clast_name_index_elt_info (const void *elt
)
113 return htab_hash_pointer (((const struct clast_name_index
*) elt
)->name
);
116 /* Compares database elements E1 and E2. */
119 eq_clast_name_indexes (const void *e1
, const void *e2
)
121 const struct clast_name_index
*elt1
= (const struct clast_name_index
*) e1
;
122 const struct clast_name_index
*elt2
= (const struct clast_name_index
*) e2
;
124 return (elt1
->name
== elt2
->name
);
127 /* For a given clast NAME, returns -1 if it does not correspond to any
128 parameter, or otherwise, returns the index in the PARAMS or
129 SCATTERING_DIMENSIONS vector. */
132 clast_name_to_index (clast_name_p name
, htab_t index_table
)
134 struct clast_name_index tmp
;
137 tmp
.name
= clast_name_to_str (name
);
138 slot
= htab_find_slot (index_table
, &tmp
, NO_INSERT
);
141 return ((struct clast_name_index
*) *slot
)->index
;