This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] c-common.c: Stop using TREE_LIST for registered_builtin_types.
- From: Kazu Hirata <kazu at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: joseph at codesourcery dot com
- Date: Fri, 2 Jun 2006 06:52:41 -0700
- Subject: [patch] c-common.c: Stop using TREE_LIST for registered_builtin_types.
Hi,
Attached is a patch to stop using TREE_LIST for
registered_builtin_types and use the VEC API instead.
Note that this patch does not change the order of the traversal in
c_common_type_for_mode because I traverse registered_builtin_types
backward. I am not sure if that's important here though.
Tested on x86_64-pc-linux-gnu. OK to apply to the LTO branch (and 4.3
once in Stage 1)?
Kazu Hirata
2006-06-02 Kazu Hirata <kazu@codesourcery.com>
* c-common.c (registered_builtin_types): Change the type to
VEC(tree,gc) *.
(c_common_type_for_mode, c_register_builtin_type): Update the
uses of registered_builtin_types.
Index: c-common.c
===================================================================
--- c-common.c (revision 114291)
+++ c-common.c (working copy)
@@ -1640,7 +1640,7 @@ c_common_type_for_size (unsigned int bit
/* Used for communication between c_common_type_for_mode and
c_register_builtin_type. */
-static GTY(()) tree registered_builtin_types;
+static GTY(()) VEC(tree,gc) *registered_builtin_types;
/* Return a data type that has machine mode MODE.
If the mode is an integer,
@@ -1650,6 +1650,7 @@ tree
c_common_type_for_mode (enum machine_mode mode, int unsignedp)
{
tree t;
+ int i;
if (mode == TYPE_MODE (integer_type_node))
return unsignedp ? unsigned_type_node : integer_type_node;
@@ -1744,9 +1745,11 @@ c_common_type_for_mode (enum machine_mod
if (mode == TYPE_MODE (dfloat128_type_node))
return dfloat128_type_node;
- for (t = registered_builtin_types; t; t = TREE_CHAIN (t))
- if (TYPE_MODE (TREE_VALUE (t)) == mode)
- return TREE_VALUE (t);
+ for (i = VEC_length (tree, registered_builtin_types);
+ VEC_iterate (tree, registered_builtin_types, i, t);
+ i--)
+ if (TYPE_MODE (t) == mode)
+ return t;
return 0;
}
@@ -1913,7 +1916,7 @@ c_register_builtin_type (tree type, cons
TYPE_NAME (type) = decl;
pushdecl (decl);
- registered_builtin_types = tree_cons (0, type, registered_builtin_types);
+ VEC_safe_push (tree, gc, registered_builtin_types, type);
}