This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Prelude Patch to My Small AltiVec Patch...
- From: Aldy Hernandez <aldyh at redhat dot com>
- To: Ziemowit Laski <zlaski at apple dot com>
- Cc: gcc-patches at gcc dot gnu dot org, Zack Weinberg <zack at codesourcery dot com>
- Date: Tue, 10 Feb 2004 20:38:02 -0400
- Subject: Re: Prelude Patch to My Small AltiVec Patch...
- References: <74184206-5C24-11D8-8014-000393673036@apple.com>
On Tue, Feb 10, 2004 at 03:54:24PM -0800, Ziemowit Laski wrote:
> Here it is. I'm doing a bootstrap now. Does this look
> reasonable? I took the liberty of renaming 'vector_size_helper'
> to 'reconstruct_complex_type', but other suggestions are
> welcome...
Perfect.
Zack, you mind reviewing this? Makes it easier to get this in
piecemeal.
Aldy
> --Zem
>
>
> [gcc/ChangeLog]
> 2004-02-10 Ziemowit Laski <zlaski@apple.com>
>
> * c-common.c (vector_size_helper): Remove; call
> reconstruct_complex_type() instead.
> * tree.c (reconstruct_complex_type): New function
> (formerly vector_size_helper() in c-common.c).
> (make_vector): Make externally visible.
> * tree.h (reconstruct_complex_type, make_vector): Add prototypes.
>
>
> Index: gcc/c-common.c
> ===================================================================
> RCS file: /cvs/gcc/gcc/gcc/c-common.c,v
> retrieving revision 1.482
> diff -u -3 -p -r1.482 c-common.c
> --- gcc/c-common.c 9 Feb 2004 21:32:37 -0000 1.482
> +++ gcc/c-common.c 10 Feb 2004 23:48:02 -0000
> @@ -784,7 +784,6 @@ static tree handle_nothrow_attribute (tr
> static tree handle_cleanup_attribute (tree *, tree, tree, int, bool *);
> static tree handle_warn_unused_result_attribute (tree *, tree, tree,
> int,
> bool *);
> -static tree vector_size_helper (tree, tree);
>
> static void check_function_nonnull (tree, tree);
> static void check_nonnull_arg (void *, tree, unsigned HOST_WIDE_INT);
> @@ -5246,55 +5245,9 @@ handle_vector_size_attribute (tree *node
> }
>
> /* Build back pointers if needed. */
> - *node = vector_size_helper (*node, new_type);
> + *node = reconstruct_complex_type (*node, new_type);
>
> return NULL_TREE;
> -}
> -
> -/* HACK. GROSS. This is absolutely disgusting. I wish there was a
> - better way.
> -
> - If we requested a pointer to a vector, build up the pointers that
> - we stripped off while looking for the inner type. Similarly for
> - return values from functions.
> -
> - The argument "type" is the top of the chain, and "bottom" is the
> - new type which we will point to. */
> -
> -static tree
> -vector_size_helper (tree type, tree bottom)
> -{
> - tree inner, outer;
> -
> - if (POINTER_TYPE_P (type))
> - {
> - inner = vector_size_helper (TREE_TYPE (type), bottom);
> - outer = build_pointer_type (inner);
> - }
> - else if (TREE_CODE (type) == ARRAY_TYPE)
> - {
> - inner = vector_size_helper (TREE_TYPE (type), bottom);
> - outer = build_array_type (inner, TYPE_DOMAIN (type));
> - }
> - else if (TREE_CODE (type) == FUNCTION_TYPE)
> - {
> - inner = vector_size_helper (TREE_TYPE (type), bottom);
> - outer = build_function_type (inner, TYPE_ARG_TYPES (type));
> - }
> - else if (TREE_CODE (type) == METHOD_TYPE)
> - {
> - inner = vector_size_helper (TREE_TYPE (type), bottom);
> - outer = build_method_type_directly (TYPE_METHOD_BASETYPE (type),
> - inner,
> - TYPE_ARG_TYPES (type));
> - }
> - else
> - return bottom;
> -
> - TREE_READONLY (outer) = TREE_READONLY (type);
> - TREE_THIS_VOLATILE (outer) = TREE_THIS_VOLATILE (type);
> -
> - return outer;
> }
>
> /* Handle the "nonnull" attribute. */
> Index: gcc/tree.c
> ===================================================================
> RCS file: /cvs/gcc/gcc/gcc/tree.c,v
> retrieving revision 1.346
> diff -u -3 -p -r1.346 tree.c
> --- gcc/tree.c 5 Feb 2004 21:56:32 -0000 1.346
> +++ gcc/tree.c 10 Feb 2004 23:48:02 -0000
> @@ -106,7 +106,6 @@ static int type_hash_eq (const void *, c
> static hashval_t type_hash_hash (const void *);
> static void print_type_hash_statistics (void);
> static void finish_vector_type (tree);
> -static tree make_vector (enum machine_mode, tree, int);
> static int type_hash_marked_p (const void *);
>
> tree global_trees[TI_MAX];
> @@ -5030,10 +5029,56 @@ build_common_tree_nodes_2 (int short_dou
> V4DF_type_node = make_vector (V4DFmode, double_type_node, 0);
> }
>
> +/* HACK. GROSS. This is absolutely disgusting. I wish there was a
> + better way.
> +
> + If we requested a pointer to a vector, build up the pointers that
> + we stripped off while looking for the inner type. Similarly for
> + return values from functions.
> +
> + The argument TYPE is the top of the chain, and BOTTOM is the
> + new type which we will point to. */
> +
> +tree
> +reconstruct_complex_type (tree type, tree bottom)
> +{
> + tree inner, outer;
> +
> + if (POINTER_TYPE_P (type))
> + {
> + inner = reconstruct_complex_type (TREE_TYPE (type), bottom);
> + outer = build_pointer_type (inner);
> + }
> + else if (TREE_CODE (type) == ARRAY_TYPE)
> + {
> + inner = reconstruct_complex_type (TREE_TYPE (type), bottom);
> + outer = build_array_type (inner, TYPE_DOMAIN (type));
> + }
> + else if (TREE_CODE (type) == FUNCTION_TYPE)
> + {
> + inner = reconstruct_complex_type (TREE_TYPE (type), bottom);
> + outer = build_function_type (inner, TYPE_ARG_TYPES (type));
> + }
> + else if (TREE_CODE (type) == METHOD_TYPE)
> + {
> + inner = reconstruct_complex_type (TREE_TYPE (type), bottom);
> + outer = build_method_type_directly (TYPE_METHOD_BASETYPE (type),
> + inner,
> + TYPE_ARG_TYPES (type));
> + }
> + else
> + return bottom;
> +
> + TREE_READONLY (outer) = TREE_READONLY (type);
> + TREE_THIS_VOLATILE (outer) = TREE_THIS_VOLATILE (type);
> +
> + return outer;
> +}
> +
> /* Returns a vector tree node given a vector mode, the inner type, and
> the signness. */
>
> -static tree
> +tree
> make_vector (enum machine_mode mode, tree innertype, int unsignedp)
> {
> tree t;
> Index: gcc/tree.h
> ===================================================================
> RCS file: /cvs/gcc/gcc/gcc/tree.h,v
> retrieving revision 1.465
> diff -u -3 -p -r1.465 tree.h
> --- gcc/tree.h 10 Feb 2004 18:38:18 -0000 1.465
> +++ gcc/tree.h 10 Feb 2004 23:48:02 -0000
> @@ -2852,6 +2852,8 @@ extern void dump_tree_statistics (void);
> extern void expand_function_end (void);
> extern void expand_function_start (tree, int);
> extern void expand_pending_sizes (tree);
> +extern tree make_vector (enum machine_mode, tree, int);
> +extern tree reconstruct_complex_type (tree, tree);
>
> extern int real_onep (tree);
> extern int real_twop (tree);
>
> --------------------------------------------------------------
> Ziemowit Laski 1 Infinite Loop, MS 301-2K
> Mac OS X Compiler Group Cupertino, CA USA 95014-2083
> Apple Computer, Inc. +1.408.974.6229 Fax .5477