diff options
author | dnovillo <dnovillo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-05-13 06:41:07 +0000 |
---|---|---|
committer | dnovillo <dnovillo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-05-13 06:41:07 +0000 |
commit | 4ee9c6840ad3fc92a9034343278a1e476ad6872a (patch) | |
tree | a2568888a519c077427b133de9ece5879a8484a5 /gcc/tree-iterator.h | |
parent | ebb338380ab170c91e64d38038e6b5ce930d69a1 (diff) | |
download | gcc-4ee9c6840ad3fc92a9034343278a1e476ad6872a.tar.gz |
Merge tree-ssa-20020619-branch into mainline.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@81764 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-iterator.h')
-rw-r--r-- | gcc/tree-iterator.h | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/gcc/tree-iterator.h b/gcc/tree-iterator.h new file mode 100644 index 00000000000..9008b1b1d00 --- /dev/null +++ b/gcc/tree-iterator.h @@ -0,0 +1,120 @@ +/* Iterator routines for manipulating GENERIC and GIMPLE tree statements. + Copyright (C) 2003, 2004 Free Software Foundation, Inc. + Contributed by Andrew MacLeod <amacleod@redhat.com> + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + + +/* This file is dependent upon the implementation of tree's. It provides an + abstract interface to the tree objects such that if all tree creation and + manipulations are done through this interface, we can easily change the + implementation of tree's, and not impact other code. */ + +#ifndef GCC_TREE_ITERATOR_H +#define GCC_TREE_ITERATOR_H 1 + +/* Iterator object for GENERIC or GIMPLE TREE statements. */ + +typedef struct { + struct tree_statement_list_node *ptr; + tree container; +} tree_stmt_iterator; + +static inline tree_stmt_iterator +tsi_start (tree t) +{ + tree_stmt_iterator i; + + i.ptr = STATEMENT_LIST_HEAD (t); + i.container = t; + + return i; +} + +static inline tree_stmt_iterator +tsi_last (tree t) +{ + tree_stmt_iterator i; + + i.ptr = STATEMENT_LIST_TAIL (t); + i.container = t; + + return i; +} + +static inline bool +tsi_end_p (tree_stmt_iterator i) +{ + return i.ptr == NULL; +} + +static inline bool +tsi_one_before_end_p (tree_stmt_iterator i) +{ + return i.ptr != NULL && i.ptr->next == NULL; +} + +static inline void +tsi_next (tree_stmt_iterator *i) +{ + i->ptr = i->ptr->next; +} + +static inline void +tsi_prev (tree_stmt_iterator *i) +{ + i->ptr = i->ptr->prev; +} + +static inline tree * +tsi_stmt_ptr (tree_stmt_iterator i) +{ + return &i.ptr->stmt; +} + +static inline tree +tsi_stmt (tree_stmt_iterator i) +{ + return i.ptr->stmt; +} + +enum tsi_iterator_update +{ + TSI_NEW_STMT, /* Leave the iterator at the same statement. */ + TSI_SAME_STMT, /* Only valid when single statement is added, move + iterator to it. */ + TSI_CHAIN_START, /* Only valid when chain of statements is added, move + iterator to the first statement in the chain. */ + TSI_CHAIN_END, /* Only valid when chain of statements is added, move + iterator to the last statement in the chain. */ + TSI_CONTINUE_LINKING /* Move iterator to whatever position is suitable for + linking other statements/chains of statements in + the same direction. */ +}; + +extern void tsi_link_before (tree_stmt_iterator *, tree, + enum tsi_iterator_update); +extern void tsi_link_after (tree_stmt_iterator *, tree, + enum tsi_iterator_update); + +void tsi_delink (tree_stmt_iterator *); + +tree tsi_split_statement_list_after (const tree_stmt_iterator *); +tree tsi_split_statement_list_before (tree_stmt_iterator *); + +#endif /* GCC_TREE_ITERATOR_H */ |