This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[lto] Introduce nth_tree_value.
- From: Kazu Hirata <kazu at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sat, 17 Jun 2006 18:53:37 -0700
- Subject: [lto] Introduce nth_tree_value.
Hi,
Attached is a patch to introduce nth_tree_value.
Since we eventually want to convert TYPE_ARG_TYPES to use TREE_VEC, we
have to deal with indexes into a TREE_VEC. In order to make the
conversion process easier, especially in the C++ frontend, this patch
introduces a new function nth_tree_value. This patch itself does not
add any use of the new function. I'm planning to remove this function
after we start using a TREE_VEC for TYPE_ARG_TYPES.
Tested on x86_64-pc-linux-gnu. OK to apply to the LTO branch?
Kazu Hirata
2006-06-18 Kazu Hirata <kazu@codesourcery.com>
* tree.c (nth_tree_value): New.
* tree.h: Add a prototype for nth_tree_value.
Index: tree.c
===================================================================
--- tree.c (revision 114740)
+++ tree.c (working copy)
@@ -1563,6 +1563,21 @@ list_length (tree t)
return len;
}
+/* Return TREE_VALUE of the Nth TREE_LIST object. */
+
+tree
+nth_tree_value (tree list, int n)
+{
+ while (n--)
+ {
+ gcc_assert (list);
+ list = TREE_CHAIN (list);
+ }
+
+ gcc_assert (list);
+ return TREE_VALUE (list);
+}
+
/* Returns the number of FIELD_DECLs in TYPE. */
int
Index: tree.h
===================================================================
--- tree.h (revision 114740)
+++ tree.h (working copy)
@@ -3911,6 +3911,10 @@ extern tree nreverse (tree);
extern int list_length (tree);
+/* Return TREE_VALUE of the Nth TREE_LIST object. */
+
+extern tree nth_tree_value (tree, int);
+
/* Returns the number of FIELD_DECLs in a type. */
extern int fields_length (tree);