]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/tree-ssa-operands.h
Update Copyright years for files modified in 2011 and/or 2012.
[thirdparty/gcc.git] / gcc / tree-ssa-operands.h
CommitLineData
4ee9c684 1/* SSA operand management for trees.
71e45bc2 2 Copyright (C) 2003, 2005, 2006, 2007, 2008, 2010, 2011, 2012
4081d362 3 Free Software Foundation, Inc.
4ee9c684 4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify it under
8the terms of the GNU General Public License as published by the Free
8c4c00c1 9Software Foundation; either version 3, or (at your option) any later
4ee9c684 10version.
11
12GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13WARRANTY; without even the implied warranty of MERCHANTABILITY or
14FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15for more details.
16
17You should have received a copy of the GNU General Public License
8c4c00c1 18along with GCC; see the file COPYING3. If not see
19<http://www.gnu.org/licenses/>. */
4ee9c684 20
21#ifndef GCC_TREE_SSA_OPERANDS_H
22#define GCC_TREE_SSA_OPERANDS_H
23
24/* Interface to SSA operands. */
25
56004dc5 26
27/* This represents a pointer to a DEF operand. */
b66731e8 28typedef tree *def_operand_p;
56004dc5 29
30/* This represents a pointer to a USE operand. */
b66731e8 31typedef ssa_use_operand_t *use_operand_p;
56004dc5 32
b66731e8 33/* NULL operand types. */
dd277d48 34#define NULL_USE_OPERAND_P ((use_operand_p)NULL)
35#define NULL_DEF_OPERAND_P ((def_operand_p)NULL)
56004dc5 36
56004dc5 37/* This represents the USE operands of a stmt. */
48e1416a 38struct use_optype_d
5b110d39 39{
b66731e8 40 struct use_optype_d *next;
41 struct ssa_use_operand_d use_ptr;
42};
43typedef struct use_optype_d *use_optype_p;
5b110d39 44
dadb7503 45/* This structure represents a variable sized buffer which is allocated by the
d819917f 46 operand memory manager. Operands are suballocated out of this block. The
dadb7503 47 MEM array varies in size. */
48e1416a 48
ba72912a 49struct GTY((chain_next("%h.next"), variable_size)) ssa_operand_memory_d {
b66731e8 50 struct ssa_operand_memory_d *next;
dadb7503 51 char mem[1];
b66731e8 52};
2cf24776 53
fcbe34ba 54/* Per-function operand caches. */
fb1e4f4a 55struct GTY(()) ssa_operands {
fcbe34ba 56 struct ssa_operand_memory_d *operand_memory;
57 unsigned operand_memory_index;
363d040e 58 /* Current size of the operand memory buffer. */
59 unsigned int ssa_operand_mem_size;
fcbe34ba 60
61 bool ops_active;
62
fcbe34ba 63 struct use_optype_d * GTY ((skip (""))) free_uses;
b66731e8 64};
48e1416a 65
b66731e8 66#define USE_FROM_PTR(PTR) get_use_from_ptr (PTR)
67#define DEF_FROM_PTR(PTR) get_def_from_ptr (PTR)
68#define SET_USE(USE, V) set_ssa_use_from_ptr (USE, V)
69#define SET_DEF(DEF, V) ((*(DEF)) = (V))
70
75a70cf9 71#define USE_STMT(USE) (USE)->loc.stmt
b66731e8 72
73#define USE_OP_PTR(OP) (&((OP)->use_ptr))
74#define USE_OP(OP) (USE_FROM_PTR (USE_OP_PTR (OP)))
75
75a70cf9 76#define PHI_RESULT_PTR(PHI) gimple_phi_result_ptr (PHI)
56004dc5 77#define PHI_RESULT(PHI) DEF_FROM_PTR (PHI_RESULT_PTR (PHI))
78#define SET_PHI_RESULT(PHI, V) SET_DEF (PHI_RESULT_PTR (PHI), (V))
79
75a70cf9 80#define PHI_ARG_DEF_PTR(PHI, I) gimple_phi_arg_imm_use_ptr ((PHI), (I))
56004dc5 81#define PHI_ARG_DEF(PHI, I) USE_FROM_PTR (PHI_ARG_DEF_PTR ((PHI), (I)))
82#define SET_PHI_ARG_DEF(PHI, I, V) \
83 SET_USE (PHI_ARG_DEF_PTR ((PHI), (I)), (V))
84#define PHI_ARG_DEF_FROM_EDGE(PHI, E) \
77ae8b0f 85 PHI_ARG_DEF ((PHI), (E)->dest_idx)
56004dc5 86#define PHI_ARG_DEF_PTR_FROM_EDGE(PHI, E) \
77ae8b0f 87 PHI_ARG_DEF_PTR ((PHI), (E)->dest_idx)
22aa74c4 88#define PHI_ARG_INDEX_FROM_USE(USE) phi_arg_index_from_use (USE)
56004dc5 89
2cf24776 90
5084b2e4 91extern void init_ssa_operands (struct function *fn);
4ee9c684 92extern void fini_ssa_operands (void);
75a70cf9 93extern void update_stmt_operands (gimple);
94extern void free_stmt_operands (gimple);
22aa74c4 95extern bool verify_imm_links (FILE *f, tree var);
85f3d834 96extern bool verify_ssa_operands (gimple stmt);
22aa74c4 97
22aa74c4 98extern void dump_immediate_uses (FILE *file);
99extern void dump_immediate_uses_for (FILE *file, tree var);
100extern void debug_immediate_uses (void);
101extern void debug_immediate_uses_for (tree var);
4fb5e5ca 102extern void dump_decl_set (FILE *, bitmap);
103extern void debug_decl_set (bitmap);
22aa74c4 104
8d672d12 105extern bool ssa_operands_active (struct function *);
b66731e8 106
0087edc6 107extern bool virtual_operand_p (tree);
dd277d48 108extern void unlink_stmt_vdef (gimple);
260e7e11 109
b66731e8 110enum ssa_op_iter_type {
111 ssa_op_iter_none = 0,
112 ssa_op_iter_tree,
113 ssa_op_iter_use,
dd277d48 114 ssa_op_iter_def
b66731e8 115};
4fb5e5ca 116
48e1416a 117/* This structure is used in the operand iterator loops. It contains the
91275768 118 items required to determine which operand is retrieved next. During
48e1416a 119 optimization, this structure is scalarized, and any unused fields are
43daa21e 120 optimized away, resulting in little overhead. */
121
122typedef struct ssa_operand_iterator_d
123{
dd277d48 124 enum ssa_op_iter_type iter_type;
5bb6976b 125 bool done;
126 int flags;
127 unsigned i;
128 unsigned numops;
b66731e8 129 use_optype_p uses;
5bb6976b 130 gimple stmt;
43daa21e 131} ssa_op_iter;
132
48e1416a 133/* These flags are used to determine which operands are returned during
43daa21e 134 execution of the loop. */
135#define SSA_OP_USE 0x01 /* Real USE operands. */
136#define SSA_OP_DEF 0x02 /* Real DEF operands. */
137#define SSA_OP_VUSE 0x04 /* VUSE operands. */
dd277d48 138#define SSA_OP_VDEF 0x08 /* VDEF operands. */
43daa21e 139
140/* These are commonly grouped operand flags. */
dd277d48 141#define SSA_OP_VIRTUAL_USES (SSA_OP_VUSE)
4fb5e5ca 142#define SSA_OP_VIRTUAL_DEFS (SSA_OP_VDEF)
143#define SSA_OP_ALL_VIRTUALS (SSA_OP_VIRTUAL_USES | SSA_OP_VIRTUAL_DEFS)
43daa21e 144#define SSA_OP_ALL_USES (SSA_OP_VIRTUAL_USES | SSA_OP_USE)
145#define SSA_OP_ALL_DEFS (SSA_OP_VIRTUAL_DEFS | SSA_OP_DEF)
4fb5e5ca 146#define SSA_OP_ALL_OPERANDS (SSA_OP_ALL_USES | SSA_OP_ALL_DEFS)
43daa21e 147
48e1416a 148/* This macro executes a loop over the operands of STMT specified in FLAG,
43daa21e 149 returning each operand as a 'tree' in the variable TREEVAR. ITER is an
150 ssa_op_iter structure used to control the loop. */
151#define FOR_EACH_SSA_TREE_OPERAND(TREEVAR, STMT, ITER, FLAGS) \
152 for (TREEVAR = op_iter_init_tree (&(ITER), STMT, FLAGS); \
153 !op_iter_done (&(ITER)); \
4081d362 154 (void) (TREEVAR = op_iter_next_tree (&(ITER))))
43daa21e 155
48e1416a 156/* This macro executes a loop over the operands of STMT specified in FLAG,
157 returning each operand as a 'use_operand_p' in the variable USEVAR.
43daa21e 158 ITER is an ssa_op_iter structure used to control the loop. */
159#define FOR_EACH_SSA_USE_OPERAND(USEVAR, STMT, ITER, FLAGS) \
160 for (USEVAR = op_iter_init_use (&(ITER), STMT, FLAGS); \
161 !op_iter_done (&(ITER)); \
162 USEVAR = op_iter_next_use (&(ITER)))
163
48e1416a 164/* This macro executes a loop over the operands of STMT specified in FLAG,
165 returning each operand as a 'def_operand_p' in the variable DEFVAR.
43daa21e 166 ITER is an ssa_op_iter structure used to control the loop. */
167#define FOR_EACH_SSA_DEF_OPERAND(DEFVAR, STMT, ITER, FLAGS) \
168 for (DEFVAR = op_iter_init_def (&(ITER), STMT, FLAGS); \
169 !op_iter_done (&(ITER)); \
170 DEFVAR = op_iter_next_def (&(ITER)))
171
d15713f9 172/* This macro will execute a loop over all the arguments of a PHI which
173 match FLAGS. A use_operand_p is always returned via USEVAR. FLAGS
174 can be either SSA_OP_USE or SSA_OP_VIRTUAL_USES or SSA_OP_ALL_USES. */
0a227ed5 175#define FOR_EACH_PHI_ARG(USEVAR, STMT, ITER, FLAGS) \
b66731e8 176 for ((USEVAR) = op_iter_init_phiuse (&(ITER), STMT, FLAGS); \
177 !op_iter_done (&(ITER)); \
178 (USEVAR) = op_iter_next_use (&(ITER)))
179
180
181/* This macro will execute a loop over a stmt, regardless of whether it is
182 a real stmt or a PHI node, looking at the USE nodes matching FLAGS. */
183#define FOR_EACH_PHI_OR_STMT_USE(USEVAR, STMT, ITER, FLAGS) \
75a70cf9 184 for ((USEVAR) = (gimple_code (STMT) == GIMPLE_PHI \
b66731e8 185 ? op_iter_init_phiuse (&(ITER), STMT, FLAGS) \
186 : op_iter_init_use (&(ITER), STMT, FLAGS)); \
187 !op_iter_done (&(ITER)); \
188 (USEVAR) = op_iter_next_use (&(ITER)))
189
190/* This macro will execute a loop over a stmt, regardless of whether it is
191 a real stmt or a PHI node, looking at the DEF nodes matching FLAGS. */
192#define FOR_EACH_PHI_OR_STMT_DEF(DEFVAR, STMT, ITER, FLAGS) \
75a70cf9 193 for ((DEFVAR) = (gimple_code (STMT) == GIMPLE_PHI \
b66731e8 194 ? op_iter_init_phidef (&(ITER), STMT, FLAGS) \
195 : op_iter_init_def (&(ITER), STMT, FLAGS)); \
196 !op_iter_done (&(ITER)); \
197 (DEFVAR) = op_iter_next_def (&(ITER)))
48e1416a 198
b66731e8 199/* This macro returns an operand in STMT as a tree if it is the ONLY
200 operand matching FLAGS. If there are 0 or more than 1 operand matching
201 FLAGS, then NULL_TREE is returned. */
202#define SINGLE_SSA_TREE_OPERAND(STMT, FLAGS) \
203 single_ssa_tree_operand (STMT, FLAGS)
48e1416a 204
b66731e8 205/* This macro returns an operand in STMT as a use_operand_p if it is the ONLY
206 operand matching FLAGS. If there are 0 or more than 1 operand matching
207 FLAGS, then NULL_USE_OPERAND_P is returned. */
208#define SINGLE_SSA_USE_OPERAND(STMT, FLAGS) \
209 single_ssa_use_operand (STMT, FLAGS)
48e1416a 210
b66731e8 211/* This macro returns an operand in STMT as a def_operand_p if it is the ONLY
212 operand matching FLAGS. If there are 0 or more than 1 operand matching
213 FLAGS, then NULL_DEF_OPERAND_P is returned. */
214#define SINGLE_SSA_DEF_OPERAND(STMT, FLAGS) \
215 single_ssa_def_operand (STMT, FLAGS)
0a227ed5 216
217/* This macro returns TRUE if there are no operands matching FLAGS in STMT. */
b66731e8 218#define ZERO_SSA_OPERANDS(STMT, FLAGS) zero_ssa_operands (STMT, FLAGS)
219
d15713f9 220/* This macro counts the number of operands in STMT matching FLAGS. */
b66731e8 221#define NUM_SSA_OPERANDS(STMT, FLAGS) num_ssa_operands (STMT, FLAGS)
222
4ee9c684 223#endif /* GCC_TREE_SSA_OPERANDS_H */