1 /* Iterator routines for manipulating GENERIC and GIMPLE tree statements.
2 Copyright (C) 2003, 2004 Free Software Foundation, Inc.
3 Contributed by Andrew MacLeod <amacleod@redhat.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 2, 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 COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
23 /* This file is dependent upon the implementation of tree's. It provides an
24 abstract interface to the tree objects such that if all tree creation and
25 manipulations are done through this interface, we can easily change the
26 implementation of tree's, and not impact other code. */
28 #ifndef GCC_TREE_ITERATOR_H
29 #define GCC_TREE_ITERATOR_H 1
31 /* Iterator object for GENERIC or GIMPLE TREE statements. */
34 struct tree_statement_list_node
*ptr
;
38 static inline tree_stmt_iterator
43 i
.ptr
= STATEMENT_LIST_HEAD (t
);
49 static inline tree_stmt_iterator
54 i
.ptr
= STATEMENT_LIST_TAIL (t
);
61 tsi_end_p (tree_stmt_iterator i
)
67 tsi_one_before_end_p (tree_stmt_iterator i
)
69 return i
.ptr
!= NULL
&& i
.ptr
->next
== NULL
;
73 tsi_next (tree_stmt_iterator
*i
)
75 i
->ptr
= i
->ptr
->next
;
79 tsi_prev (tree_stmt_iterator
*i
)
81 i
->ptr
= i
->ptr
->prev
;
85 tsi_stmt_ptr (tree_stmt_iterator i
)
91 tsi_stmt (tree_stmt_iterator i
)
96 enum tsi_iterator_update
98 TSI_NEW_STMT
, /* Leave the iterator at the same statement. */
99 TSI_SAME_STMT
, /* Only valid when single statement is added, move
101 TSI_CHAIN_START
, /* Only valid when chain of statements is added, move
102 iterator to the first statement in the chain. */
103 TSI_CHAIN_END
, /* Only valid when chain of statements is added, move
104 iterator to the last statement in the chain. */
105 TSI_CONTINUE_LINKING
/* Move iterator to whatever position is suitable for
106 linking other statements/chains of statements in
107 the same direction. */
110 extern void tsi_link_before (tree_stmt_iterator
*, tree
,
111 enum tsi_iterator_update
);
112 extern void tsi_link_after (tree_stmt_iterator
*, tree
,
113 enum tsi_iterator_update
);
115 void tsi_delink (tree_stmt_iterator
*);
117 tree
tsi_split_statement_list_after (const tree_stmt_iterator
*);
118 tree
tsi_split_statement_list_before (tree_stmt_iterator
*);
120 void append_to_statement_list (tree
, tree
*);
121 void append_to_statement_list_force (tree
, tree
*);
123 #endif /* GCC_TREE_ITERATOR_H */