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-clast-to-gimple.c */
41 extern bool gloog (scop_p
, htab_t
);
42 extern cloog_prog_clast
scop_to_clast (scop_p
, CloogState
*);
43 extern void debug_clast_stmt (struct clast_stmt
*);
44 extern void print_clast_stmt (FILE *, struct clast_stmt
*);
45 extern void build_iv_mapping (VEC (tree
, heap
) *, sese
, VEC (tree
, heap
) *,
46 htab_t
, struct clast_user_stmt
*, htab_t
);
47 extern struct loop
*graphite_create_new_loop (sese
, edge
, struct clast_for
*,
48 loop_p
, VEC (tree
, heap
) **,
50 extern edge
graphite_create_new_loop_guard (sese
, edge
, struct clast_for
*,
51 VEC (tree
, heap
) *, htab_t
, htab_t
);
52 extern edge
graphite_create_new_guard (sese
, edge
, struct clast_guard
*,
53 VEC (tree
, heap
) *, htab_t
, htab_t
);
54 extern tree
clast_to_gcc_expression (tree
, struct clast_expr
*, sese
,
55 VEC (tree
, heap
) *, htab_t
, htab_t
);
56 extern tree
gcc_type_for_iv_of_clast_loop (struct clast_for
*, int, tree
, tree
);
58 extern tree
gcc_type_for_clast_expr (struct clast_expr
*, sese
,
59 VEC (tree
, heap
) *, htab_t
, htab_t
);
60 extern tree
clast_name_to_gcc (clast_name_p
, sese
, VEC (tree
, heap
) *,
62 extern void save_clast_name_index (htab_t
, const char *, int);
64 /* Hash function for data base element BB_PBB. */
66 static inline hashval_t
67 bb_pbb_map_hash (const void *bb_pbb
)
69 return (hashval_t
)(((const bb_pbb_def
*)bb_pbb
)->bb
->index
);
72 /* Compare data base element BB_PBB1 and BB_PBB2. */
75 eq_bb_pbb_map (const void *bb_pbb1
, const void *bb_pbb2
)
77 const bb_pbb_def
*bp1
= (const bb_pbb_def
*) bb_pbb1
;
78 const bb_pbb_def
*bp2
= (const bb_pbb_def
*) bb_pbb2
;
79 return (bp1
->bb
->index
== bp2
->bb
->index
);
82 /* Returns the scattering dimension for STMTFOR.
84 The relationship between dimension in scattering matrix
85 and the DEPTH of the loop is:
86 DIMENSION = 2*DEPTH - 1
89 static inline int get_scattering_level (int depth
)
94 /* Stores the INDEX in a vector for a given clast NAME. */
96 typedef struct clast_name_index
100 } *clast_name_index_p
;
102 /* Computes a hash function for database element ELT. */
104 static inline hashval_t
105 clast_name_index_elt_info (const void *elt
)
107 return htab_hash_pointer (((const struct clast_name_index
*) elt
)->name
);
110 /* Compares database elements E1 and E2. */
113 eq_clast_name_indexes (const void *e1
, const void *e2
)
115 const struct clast_name_index
*elt1
= (const struct clast_name_index
*) e1
;
116 const struct clast_name_index
*elt2
= (const struct clast_name_index
*) e2
;
118 return (elt1
->name
== elt2
->name
);
121 /* For a given clast NAME, returns -1 if it does not correspond to any
122 parameter, or otherwise, returns the index in the PARAMS or
123 SCATTERING_DIMENSIONS vector. */
126 clast_name_to_index (clast_name_p name
, htab_t index_table
)
128 struct clast_name_index tmp
;
131 tmp
.name
= clast_name_to_str (name
);
132 slot
= htab_find_slot (index_table
, &tmp
, NO_INSERT
);
135 return ((struct clast_name_index
*) *slot
)->index
;