OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [tree-ssa-operands.h] - Blame information for rev 816

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 38 julius
/* SSA operand management for trees.
2
   Copyright (C) 2003, 2005, 2007 Free Software Foundation, Inc.
3
 
4
This file is part of GCC.
5
 
6
GCC is free software; you can redistribute it and/or modify it under
7
the terms of the GNU General Public License as published by the Free
8
Software Foundation; either version 3, or (at your option) any later
9
version.
10
 
11
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12
WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14
for more details.
15
 
16
You should have received a copy of the GNU General Public License
17
along with GCC; see the file COPYING3.  If not see
18
<http://www.gnu.org/licenses/>.  */
19
 
20
#ifndef GCC_TREE_SSA_OPERANDS_H
21
#define GCC_TREE_SSA_OPERANDS_H
22
 
23
/* Interface to SSA operands.  */
24
 
25
 
26
/* This represents a pointer to a DEF operand.  */
27
typedef tree *def_operand_p;
28
 
29
/* This represents a pointer to a USE operand.  */
30
typedef ssa_use_operand_t *use_operand_p;
31
 
32
/* NULL operand types.  */
33
#define NULL_USE_OPERAND_P              NULL
34
#define NULL_DEF_OPERAND_P              NULL
35
 
36
/* This represents the DEF operands of a stmt.  */
37
struct def_optype_d
38
{
39
  struct def_optype_d *next;
40
  tree *def_ptr;
41
};
42
typedef struct def_optype_d *def_optype_p;
43
 
44
/* This represents the USE operands of a stmt.  */
45
struct use_optype_d
46
{
47
  struct use_optype_d *next;
48
  struct ssa_use_operand_d use_ptr;
49
};
50
typedef struct use_optype_d *use_optype_p;
51
 
52
/* This represents the MAY_DEFS for a stmt.  */
53
struct maydef_optype_d
54
{
55
  struct maydef_optype_d *next;
56
  tree def_var;
57
  tree use_var;
58
  struct ssa_use_operand_d use_ptr;
59
};
60
typedef struct maydef_optype_d *maydef_optype_p;
61
 
62
/* This represents the VUSEs for a stmt.  */
63
struct vuse_optype_d
64
{
65
  struct vuse_optype_d *next;
66
  tree use_var;
67
  struct ssa_use_operand_d use_ptr;
68
};
69
typedef struct vuse_optype_d *vuse_optype_p;
70
 
71
/* This represents the V_MUST_DEFS for a stmt.  */
72
struct mustdef_optype_d
73
{
74
  struct mustdef_optype_d *next;
75
  tree def_var;
76
  tree kill_var;
77
  struct ssa_use_operand_d use_ptr;
78
};
79
typedef struct mustdef_optype_d *mustdef_optype_p;
80
 
81
 
82
#define SSA_OPERAND_MEMORY_SIZE         (2048 - sizeof (void *))
83
 
84
struct ssa_operand_memory_d GTY((chain_next("%h.next")))
85
{
86
  struct ssa_operand_memory_d *next;
87
  char mem[SSA_OPERAND_MEMORY_SIZE];
88
};
89
 
90
 
91
/* This represents the operand cache for a stmt.  */
92
struct stmt_operands_d
93
{
94
  /* Statement operands.  */
95
  struct def_optype_d * def_ops;
96
  struct use_optype_d * use_ops;
97
 
98
  /* Virtual operands (V_MAY_DEF, VUSE, and V_MUST_DEF).  */
99
  struct maydef_optype_d * maydef_ops;
100
  struct vuse_optype_d * vuse_ops;
101
  struct mustdef_optype_d * mustdef_ops;
102
};
103
 
104
typedef struct stmt_operands_d *stmt_operands_p;
105
 
106
#define USE_FROM_PTR(PTR)       get_use_from_ptr (PTR)
107
#define DEF_FROM_PTR(PTR)       get_def_from_ptr (PTR)
108
#define SET_USE(USE, V)         set_ssa_use_from_ptr (USE, V)
109
#define SET_DEF(DEF, V)         ((*(DEF)) = (V))
110
 
111
#define USE_STMT(USE)           (USE)->stmt
112
 
113
#define DEF_OPS(STMT)           (stmt_ann (STMT)->operands.def_ops)
114
#define USE_OPS(STMT)           (stmt_ann (STMT)->operands.use_ops)
115
#define VUSE_OPS(STMT)          (stmt_ann (STMT)->operands.vuse_ops)
116
#define MAYDEF_OPS(STMT)        (stmt_ann (STMT)->operands.maydef_ops)
117
#define MUSTDEF_OPS(STMT)       (stmt_ann (STMT)->operands.mustdef_ops)
118
 
119
#define USE_OP_PTR(OP)          (&((OP)->use_ptr))
120
#define USE_OP(OP)              (USE_FROM_PTR (USE_OP_PTR (OP)))
121
 
122
#define DEF_OP_PTR(OP)          ((OP)->def_ptr)
123
#define DEF_OP(OP)              (DEF_FROM_PTR (DEF_OP_PTR (OP)))
124
 
125
#define VUSE_OP_PTR(OP)         USE_OP_PTR(OP)
126
#define VUSE_OP(OP)             ((OP)->use_var)
127
 
128
#define MAYDEF_RESULT_PTR(OP)   (&((OP)->def_var))
129
#define MAYDEF_RESULT(OP)       ((OP)->def_var)
130
#define MAYDEF_OP_PTR(OP)       USE_OP_PTR (OP)
131
#define MAYDEF_OP(OP)           ((OP)->use_var)
132
 
133
#define MUSTDEF_RESULT_PTR(OP)  (&((OP)->def_var))
134
#define MUSTDEF_RESULT(OP)      ((OP)->def_var)
135
#define MUSTDEF_KILL_PTR(OP)    USE_OP_PTR (OP)
136
#define MUSTDEF_KILL(OP)        ((OP)->kill_var)
137
 
138
#define PHI_RESULT_PTR(PHI)     get_phi_result_ptr (PHI)
139
#define PHI_RESULT(PHI)         DEF_FROM_PTR (PHI_RESULT_PTR (PHI))
140
#define SET_PHI_RESULT(PHI, V)  SET_DEF (PHI_RESULT_PTR (PHI), (V))
141
 
142
#define PHI_ARG_DEF_PTR(PHI, I) get_phi_arg_def_ptr ((PHI), (I))
143
#define PHI_ARG_DEF(PHI, I)     USE_FROM_PTR (PHI_ARG_DEF_PTR ((PHI), (I)))
144
#define SET_PHI_ARG_DEF(PHI, I, V)                                      \
145
                                SET_USE (PHI_ARG_DEF_PTR ((PHI), (I)), (V))
146
#define PHI_ARG_DEF_FROM_EDGE(PHI, E)                                   \
147
                                PHI_ARG_DEF ((PHI), (E)->dest_idx)
148
#define PHI_ARG_DEF_PTR_FROM_EDGE(PHI, E)                               \
149
                                PHI_ARG_DEF_PTR ((PHI), (E)->dest_idx)
150
#define PHI_ARG_INDEX_FROM_USE(USE)   phi_arg_index_from_use (USE)
151
 
152
 
153
extern void init_ssa_operands (void);
154
extern void fini_ssa_operands (void);
155
extern void free_ssa_operands (stmt_operands_p);
156
extern void update_stmt_operands (tree);
157
extern bool verify_imm_links (FILE *f, tree var);
158
 
159
extern void copy_virtual_operands (tree, tree);
160
extern void create_ssa_artficial_load_stmt (tree, tree);
161
 
162
extern void dump_immediate_uses (FILE *file);
163
extern void dump_immediate_uses_for (FILE *file, tree var);
164
extern void debug_immediate_uses (void);
165
extern void debug_immediate_uses_for (tree var);
166
 
167
extern bool ssa_operands_active (void);
168
 
169
extern void add_to_addressable_set (tree, bitmap *);
170
 
171
enum ssa_op_iter_type {
172
  ssa_op_iter_none = 0,
173
  ssa_op_iter_tree,
174
  ssa_op_iter_use,
175
  ssa_op_iter_def,
176
  ssa_op_iter_maymustdef
177
};
178
/* This structure is used in the operand iterator loops.  It contains the
179
   items required to determine which operand is retrieved next.  During
180
   optimization, this structure is scalarized, and any unused fields are
181
   optimized away, resulting in little overhead.  */
182
 
183
typedef struct ssa_operand_iterator_d
184
{
185
  def_optype_p defs;
186
  use_optype_p uses;
187
  vuse_optype_p vuses;
188
  maydef_optype_p maydefs;
189
  maydef_optype_p mayuses;
190
  mustdef_optype_p mustdefs;
191
  mustdef_optype_p mustkills;
192
  enum ssa_op_iter_type iter_type;
193
  int phi_i;
194
  int num_phi;
195
  tree phi_stmt;
196
  bool done;
197
} ssa_op_iter;
198
 
199
/* These flags are used to determine which operands are returned during
200
   execution of the loop.  */
201
#define SSA_OP_USE              0x01    /* Real USE operands.  */
202
#define SSA_OP_DEF              0x02    /* Real DEF operands.  */
203
#define SSA_OP_VUSE             0x04    /* VUSE operands.  */
204
#define SSA_OP_VMAYUSE          0x08    /* USE portion of V_MAY_DEFS.  */
205
#define SSA_OP_VMAYDEF          0x10    /* DEF portion of V_MAY_DEFS.  */
206
#define SSA_OP_VMUSTDEF         0x20    /* V_MUST_DEF definitions.  */
207
#define SSA_OP_VMUSTKILL        0x40    /* V_MUST_DEF kills.  */
208
 
209
/* These are commonly grouped operand flags.  */
210
#define SSA_OP_VIRTUAL_USES     (SSA_OP_VUSE | SSA_OP_VMAYUSE)
211
#define SSA_OP_VIRTUAL_DEFS     (SSA_OP_VMAYDEF | SSA_OP_VMUSTDEF)
212
#define SSA_OP_VIRTUAL_KILLS    (SSA_OP_VMUSTKILL)
213
#define SSA_OP_ALL_VIRTUALS     (SSA_OP_VIRTUAL_USES | SSA_OP_VIRTUAL_KILLS \
214
                                 | SSA_OP_VIRTUAL_DEFS)
215
#define SSA_OP_ALL_USES         (SSA_OP_VIRTUAL_USES | SSA_OP_USE)
216
#define SSA_OP_ALL_DEFS         (SSA_OP_VIRTUAL_DEFS | SSA_OP_DEF)
217
#define SSA_OP_ALL_KILLS        (SSA_OP_VIRTUAL_KILLS)
218
#define SSA_OP_ALL_OPERANDS     (SSA_OP_ALL_USES | SSA_OP_ALL_DEFS      \
219
                                 | SSA_OP_ALL_KILLS)
220
 
221
/* This macro executes a loop over the operands of STMT specified in FLAG,
222
   returning each operand as a 'tree' in the variable TREEVAR.  ITER is an
223
   ssa_op_iter structure used to control the loop.  */
224
#define FOR_EACH_SSA_TREE_OPERAND(TREEVAR, STMT, ITER, FLAGS)   \
225
  for (TREEVAR = op_iter_init_tree (&(ITER), STMT, FLAGS);      \
226
       !op_iter_done (&(ITER));                                 \
227
       TREEVAR = op_iter_next_tree (&(ITER)))
228
 
229
/* This macro executes a loop over the operands of STMT specified in FLAG,
230
   returning each operand as a 'use_operand_p' in the variable USEVAR.
231
   ITER is an ssa_op_iter structure used to control the loop.  */
232
#define FOR_EACH_SSA_USE_OPERAND(USEVAR, STMT, ITER, FLAGS)     \
233
  for (USEVAR = op_iter_init_use (&(ITER), STMT, FLAGS);        \
234
       !op_iter_done (&(ITER));                                 \
235
       USEVAR = op_iter_next_use (&(ITER)))
236
 
237
/* This macro executes a loop over the operands of STMT specified in FLAG,
238
   returning each operand as a 'def_operand_p' in the variable DEFVAR.
239
   ITER is an ssa_op_iter structure used to control the loop.  */
240
#define FOR_EACH_SSA_DEF_OPERAND(DEFVAR, STMT, ITER, FLAGS)     \
241
  for (DEFVAR = op_iter_init_def (&(ITER), STMT, FLAGS);        \
242
       !op_iter_done (&(ITER));                                 \
243
       DEFVAR = op_iter_next_def (&(ITER)))
244
 
245
/* This macro executes a loop over the V_MAY_DEF operands of STMT.  The def
246
   and use for each V_MAY_DEF is returned in DEFVAR and USEVAR.
247
   ITER is an ssa_op_iter structure used to control the loop.  */
248
#define FOR_EACH_SSA_MAYDEF_OPERAND(DEFVAR, USEVAR, STMT, ITER) \
249
  for (op_iter_init_maydef (&(ITER), STMT, &(USEVAR), &(DEFVAR));       \
250
       !op_iter_done (&(ITER));                                 \
251
       op_iter_next_maymustdef (&(USEVAR), &(DEFVAR), &(ITER)))
252
 
253
/* This macro executes a loop over the V_MUST_DEF operands of STMT.  The def
254
   and kill for each V_MUST_DEF is returned in DEFVAR and KILLVAR.
255
   ITER is an ssa_op_iter structure used to control the loop.  */
256
#define FOR_EACH_SSA_MUSTDEF_OPERAND(DEFVAR, KILLVAR, STMT, ITER)       \
257
  for (op_iter_init_mustdef (&(ITER), STMT, &(KILLVAR), &(DEFVAR));     \
258
       !op_iter_done (&(ITER));                                 \
259
       op_iter_next_maymustdef (&(KILLVAR), &(DEFVAR), &(ITER)))
260
 
261
/* This macro executes a loop over the V_{MUST,MAY}_DEF of STMT.  The def
262
   and kill for each V_{MUST,MAY}_DEF is returned in DEFVAR and KILLVAR.
263
   ITER is an ssa_op_iter structure used to control the loop.  */
264
#define FOR_EACH_SSA_MUST_AND_MAY_DEF_OPERAND(DEFVAR, KILLVAR, STMT, ITER)\
265
  for (op_iter_init_must_and_may_def (&(ITER), STMT, &(KILLVAR), &(DEFVAR));\
266
       !op_iter_done (&(ITER));                                 \
267
       op_iter_next_maymustdef (&(KILLVAR), &(DEFVAR), &(ITER)))
268
 
269
/* This macro will execute a loop over all the arguments of a PHI which
270
   match FLAGS.   A use_operand_p is always returned via USEVAR.  FLAGS
271
   can be either SSA_OP_USE or SSA_OP_VIRTUAL_USES or SSA_OP_ALL_USES.  */
272
#define FOR_EACH_PHI_ARG(USEVAR, STMT, ITER, FLAGS)             \
273
  for ((USEVAR) = op_iter_init_phiuse (&(ITER), STMT, FLAGS);   \
274
       !op_iter_done (&(ITER));                                 \
275
       (USEVAR) = op_iter_next_use (&(ITER)))
276
 
277
 
278
/* This macro will execute a loop over a stmt, regardless of whether it is
279
   a real stmt or a PHI node, looking at the USE nodes matching FLAGS.  */
280
#define FOR_EACH_PHI_OR_STMT_USE(USEVAR, STMT, ITER, FLAGS)     \
281
  for ((USEVAR) = (TREE_CODE (STMT) == PHI_NODE                 \
282
                   ? op_iter_init_phiuse (&(ITER), STMT, FLAGS) \
283
                   : op_iter_init_use (&(ITER), STMT, FLAGS));  \
284
       !op_iter_done (&(ITER));                                 \
285
       (USEVAR) = op_iter_next_use (&(ITER)))
286
 
287
/* This macro will execute a loop over a stmt, regardless of whether it is
288
   a real stmt or a PHI node, looking at the DEF nodes matching FLAGS.  */
289
#define FOR_EACH_PHI_OR_STMT_DEF(DEFVAR, STMT, ITER, FLAGS)     \
290
  for ((DEFVAR) = (TREE_CODE (STMT) == PHI_NODE                 \
291
                   ? op_iter_init_phidef (&(ITER), STMT, FLAGS) \
292
                   : op_iter_init_def (&(ITER), STMT, FLAGS));  \
293
       !op_iter_done (&(ITER));                                 \
294
       (DEFVAR) = op_iter_next_def (&(ITER)))
295
 
296
/* This macro returns an operand in STMT as a tree if it is the ONLY
297
   operand matching FLAGS.  If there are 0 or more than 1 operand matching
298
   FLAGS, then NULL_TREE is returned.  */
299
#define SINGLE_SSA_TREE_OPERAND(STMT, FLAGS)                    \
300
  single_ssa_tree_operand (STMT, FLAGS)
301
 
302
/* This macro returns an operand in STMT as a use_operand_p if it is the ONLY
303
   operand matching FLAGS.  If there are 0 or more than 1 operand matching
304
   FLAGS, then NULL_USE_OPERAND_P is returned.  */
305
#define SINGLE_SSA_USE_OPERAND(STMT, FLAGS)                     \
306
  single_ssa_use_operand (STMT, FLAGS)
307
 
308
/* This macro returns an operand in STMT as a def_operand_p if it is the ONLY
309
   operand matching FLAGS.  If there are 0 or more than 1 operand matching
310
   FLAGS, then NULL_DEF_OPERAND_P is returned.  */
311
#define SINGLE_SSA_DEF_OPERAND(STMT, FLAGS)                     \
312
  single_ssa_def_operand (STMT, FLAGS)
313
 
314
/* This macro returns TRUE if there are no operands matching FLAGS in STMT.  */
315
#define ZERO_SSA_OPERANDS(STMT, FLAGS)  zero_ssa_operands (STMT, FLAGS)
316
 
317
/* This macro counts the number of operands in STMT matching FLAGS.  */
318
#define NUM_SSA_OPERANDS(STMT, FLAGS)   num_ssa_operands (STMT, FLAGS)
319
 
320
#endif  /* GCC_TREE_SSA_OPERANDS_H  */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.