source: arduino-1-6-7/trunk/fuentes/arduino-ide-amd64/hardware/tools/avr/lib/gcc/avr/4.9.2/plugin/include/gimple-iterator.h @ 4837

Last change on this file since 4837 was 4837, checked in by daduve, 2 years ago

Adding new version

File size: 7.6 KB
Line 
1/* Header file for gimple iterators.
2   Copyright (C) 2013-2014 Free Software Foundation, Inc.
3
4This file is part of GCC.
5
6GCC is free software; you can redistribute it and/or modify it under
7the terms of the GNU General Public License as published by the Free
8Software Foundation; either version 3, or (at your option) any later
9version.
10
11GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12WARRANTY; without even the implied warranty of MERCHANTABILITY or
13FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 for more details.
15
16You should have received a copy of the GNU General Public License
17along with GCC; see the file COPYING3.  If not see
18<http://www.gnu.org/licenses/>.  */
19
20#ifndef GCC_GIMPLE_ITERATOR_H
21#define GCC_GIMPLE_ITERATOR_H
22
23/* Iterator object for GIMPLE statement sequences.  */
24
25struct gimple_stmt_iterator
26{
27  /* Sequence node holding the current statement.  */
28  gimple_seq_node ptr;
29
30  /* Sequence and basic block holding the statement.  These fields
31     are necessary to handle edge cases such as when statement is
32     added to an empty basic block or when the last statement of a
33     block/sequence is removed.  */
34  gimple_seq *seq;
35  basic_block bb;
36};
37 
38enum gsi_iterator_update
39{
40  GSI_NEW_STMT,         /* Only valid when single statement is added, move
41                           iterator to it.  */
42  GSI_SAME_STMT,        /* Leave the iterator at the same statement.  */
43  GSI_CONTINUE_LINKING  /* Move iterator to whatever position is suitable
44                           for linking other statements in the same
45                           direction.  */
46};
47
48extern void gsi_insert_seq_before_without_update (gimple_stmt_iterator *,
49                                                  gimple_seq,
50                                                  enum gsi_iterator_update);
51extern void gsi_insert_seq_before (gimple_stmt_iterator *, gimple_seq,
52                                   enum gsi_iterator_update);
53extern void gsi_insert_seq_after_without_update (gimple_stmt_iterator *,
54                                                 gimple_seq,
55                                                 enum gsi_iterator_update);
56extern void gsi_insert_seq_after (gimple_stmt_iterator *, gimple_seq,
57                                  enum gsi_iterator_update);
58extern gimple_seq gsi_split_seq_after (gimple_stmt_iterator);
59extern void gsi_set_stmt (gimple_stmt_iterator *, gimple);
60extern void gsi_split_seq_before (gimple_stmt_iterator *, gimple_seq *);
61extern void gsi_replace (gimple_stmt_iterator *, gimple, bool);
62extern void gsi_replace_with_seq (gimple_stmt_iterator *, gimple_seq, bool);
63extern void gsi_insert_before_without_update (gimple_stmt_iterator *, gimple,
64                                              enum gsi_iterator_update);
65extern void gsi_insert_before (gimple_stmt_iterator *, gimple,
66                               enum gsi_iterator_update);
67extern void gsi_insert_after_without_update (gimple_stmt_iterator *, gimple,
68                                             enum gsi_iterator_update);
69extern void gsi_insert_after (gimple_stmt_iterator *, gimple,
70                              enum gsi_iterator_update);
71extern bool gsi_remove (gimple_stmt_iterator *, bool);
72extern gimple_stmt_iterator gsi_for_stmt (gimple);
73extern void gsi_move_after (gimple_stmt_iterator *, gimple_stmt_iterator *);
74extern void gsi_move_before (gimple_stmt_iterator *, gimple_stmt_iterator *);
75extern void gsi_move_to_bb_end (gimple_stmt_iterator *, basic_block);
76extern void gsi_insert_on_edge (edge, gimple);
77extern void gsi_insert_seq_on_edge (edge, gimple_seq);
78extern basic_block gsi_insert_on_edge_immediate (edge, gimple);
79extern basic_block gsi_insert_seq_on_edge_immediate (edge, gimple_seq);
80extern void gsi_commit_edge_inserts (void);
81extern void gsi_commit_one_edge_insert (edge, basic_block *);
82extern gimple_stmt_iterator gsi_start_phis (basic_block);
83
84/* Return a new iterator pointing to GIMPLE_SEQ's first statement.  */
85
86static inline gimple_stmt_iterator
87gsi_start_1 (gimple_seq *seq)
88{
89  gimple_stmt_iterator i;
90
91  i.ptr = gimple_seq_first (*seq);
92  i.seq = seq;
93  i.bb = i.ptr ? gimple_bb (i.ptr) : NULL;
94
95  return i;
96}
97
98#define gsi_start(x) gsi_start_1 (&(x))
99
100static inline gimple_stmt_iterator
101gsi_none (void)
102{
103  gimple_stmt_iterator i;
104  i.ptr = NULL;
105  i.seq = NULL;
106  i.bb = NULL;
107  return i;
108}
109
110/* Return a new iterator pointing to the first statement in basic block BB.  */
111
112static inline gimple_stmt_iterator
113gsi_start_bb (basic_block bb)
114{
115  gimple_stmt_iterator i;
116  gimple_seq *seq;
117
118  seq = bb_seq_addr (bb);
119  i.ptr = gimple_seq_first (*seq);
120  i.seq = seq;
121  i.bb = bb;
122
123  return i;
124}
125
126/* Return a new iterator initially pointing to GIMPLE_SEQ's last statement.  */
127
128static inline gimple_stmt_iterator
129gsi_last_1 (gimple_seq *seq)
130{
131  gimple_stmt_iterator i;
132
133  i.ptr = gimple_seq_last (*seq);
134  i.seq = seq;
135  i.bb = i.ptr ? gimple_bb (i.ptr) : NULL;
136
137  return i;
138}
139
140#define gsi_last(x) gsi_last_1 (&(x))
141
142/* Return a new iterator pointing to the last statement in basic block BB.  */
143
144static inline gimple_stmt_iterator
145gsi_last_bb (basic_block bb)
146{
147  gimple_stmt_iterator i;
148  gimple_seq *seq;
149
150  seq = bb_seq_addr (bb);
151  i.ptr = gimple_seq_last (*seq);
152  i.seq = seq;
153  i.bb = bb;
154
155  return i;
156}
157
158/* Return true if I is at the end of its sequence.  */
159
160static inline bool
161gsi_end_p (gimple_stmt_iterator i)
162{
163  return i.ptr == NULL;
164}
165
166/* Return true if I is one statement before the end of its sequence.  */
167
168static inline bool
169gsi_one_before_end_p (gimple_stmt_iterator i)
170{
171  return i.ptr != NULL && i.ptr->next == NULL;
172}
173
174/* Advance the iterator to the next gimple statement.  */
175
176static inline void
177gsi_next (gimple_stmt_iterator *i)
178{
179  i->ptr = i->ptr->next;
180}
181
182/* Advance the iterator to the previous gimple statement.  */
183
184static inline void
185gsi_prev (gimple_stmt_iterator *i)
186{
187  gimple prev = i->ptr->prev;
188  if (prev->next)
189    i->ptr = prev;
190  else
191    i->ptr = NULL;
192}
193
194/* Return the current stmt.  */
195
196static inline gimple
197gsi_stmt (gimple_stmt_iterator i)
198{
199  return i.ptr;
200}
201
202/* Return a block statement iterator that points to the first non-label
203   statement in block BB.  */
204
205static inline gimple_stmt_iterator
206gsi_after_labels (basic_block bb)
207{
208  gimple_stmt_iterator gsi = gsi_start_bb (bb);
209
210  while (!gsi_end_p (gsi) && gimple_code (gsi_stmt (gsi)) == GIMPLE_LABEL)
211    gsi_next (&gsi);
212
213  return gsi;
214}
215
216/* Advance the iterator to the next non-debug gimple statement.  */
217
218static inline void
219gsi_next_nondebug (gimple_stmt_iterator *i)
220{
221  do
222    {
223      gsi_next (i);
224    }
225  while (!gsi_end_p (*i) && is_gimple_debug (gsi_stmt (*i)));
226}
227
228/* Advance the iterator to the next non-debug gimple statement.  */
229
230static inline void
231gsi_prev_nondebug (gimple_stmt_iterator *i)
232{
233  do
234    {
235      gsi_prev (i);
236    }
237  while (!gsi_end_p (*i) && is_gimple_debug (gsi_stmt (*i)));
238}
239
240/* Return a new iterator pointing to the first non-debug statement in
241   basic block BB.  */
242
243static inline gimple_stmt_iterator
244gsi_start_nondebug_bb (basic_block bb)
245{
246  gimple_stmt_iterator i = gsi_start_bb (bb);
247
248  if (!gsi_end_p (i) && is_gimple_debug (gsi_stmt (i)))
249    gsi_next_nondebug (&i);
250
251  return i;
252}
253
254/* Return a new iterator pointing to the first non-debug non-label statement in
255   basic block BB.  */
256
257static inline gimple_stmt_iterator
258gsi_start_nondebug_after_labels_bb (basic_block bb)
259{
260  gimple_stmt_iterator i = gsi_after_labels (bb);
261
262  if (!gsi_end_p (i) && is_gimple_debug (gsi_stmt (i)))
263    gsi_next_nondebug (&i);
264
265  return i;
266}
267
268/* Return a new iterator pointing to the last non-debug statement in
269   basic block BB.  */
270
271static inline gimple_stmt_iterator
272gsi_last_nondebug_bb (basic_block bb)
273{
274  gimple_stmt_iterator i = gsi_last_bb (bb);
275
276  if (!gsi_end_p (i) && is_gimple_debug (gsi_stmt (i)))
277    gsi_prev_nondebug (&i);
278
279  return i;
280}
281
282/* Return the basic block associated with this iterator.  */
283
284static inline basic_block
285gsi_bb (gimple_stmt_iterator i)
286{
287  return i.bb;
288}
289
290/* Return the sequence associated with this iterator.  */
291
292static inline gimple_seq
293gsi_seq (gimple_stmt_iterator i)
294{
295  return *i.seq;
296}
297
298#endif /* GCC_GIMPLE_ITERATOR_H */
Note: See TracBrowser for help on using the repository browser.