This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: common tree nodes question
- From: Aldy Hernandez <aldyh at redhat dot com>
- To: Richard Henderson <rth at redhat dot com>
- Cc: gcc at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org, ezannoni at redhat dot com
- Date: Tue, 26 Feb 2002 17:26:26 +1100
- Subject: Re: common tree nodes question
On Tuesday, February 26, 2002, at 01:20 PM, Richard Henderson wrote:
> On Tue, Feb 26, 2002 at 01:17:13PM +1100, Aldy Hernandez wrote:
>> been there done that. i tried making a copy of the node with
>> copy_node and then doing magic on that. didn't work because then
>> the FE gets all confused because of type inequality.
>
> Did you try build_type_copy instead of copy_node?
vewy intewesting.
ok, did that, but now additional tweaks are needed in gen_type_die
because it insists on looking up the main variant, which clearly
won't have the correct debugging information.
...and i can't just set the main variant to my newly created type
because then expr.c will die all over, thinking that types mismatch.
i've fixed everything.
is this one ok?
2002-02-26 Aldy Hernandez <aldyh@redhat.com>
* dwarf2out.c (modified_type_die): Do not call type_main_variant
for vectors.
(gen_type_die): Same.
* attribs.c (handle_vector_size_attribute): Set debug information.
Index: attribs.c
===================================================================
RCS file: /cvs/uberbaum/gcc/attribs.c,v
retrieving revision 1.13
diff -c -p -r1.13 attribs.c
*** attribs.c 2002/02/25 22:38:52 1.13
--- attribs.c 2002/02/26 06:23:05
*************** handle_vector_size_attribute (node, name
*** 1307,1318 ****
error ("no vector mode with the size and type specified could be
found");
else
{
new_type = type_for_mode (new_mode, TREE_UNSIGNED (type));
if (!new_type)
! error ("no vector mode with the size and type specified could be
found");
! else
! /* Build back pointers if needed. */
! *node = vector_size_helper (*node, new_type);
}
return NULL_TREE;
--- 1307,1339 ----
error ("no vector mode with the size and type specified could be
found");
else
{
+ tree index, array, rt;
+
new_type = type_for_mode (new_mode, TREE_UNSIGNED (type));
+
if (!new_type)
! {
! error ("no vector mode with the size and type specified could be
found");
! return NULL_TREE;
! }
!
! new_type = build_type_copy (new_type);
!
! /* Set the debug information here, because this is the only
! place where we know the underlying type for a vector made
! with vector_size. For debugging purposes we pretend a vector
! is an array within a structure. */
! index = build_int_2 (TYPE_VECTOR_SUBPARTS (new_type) - 1, 0);
! array = build_array_type (type, build_index_type (index));
! rt = make_node (RECORD_TYPE);
!
! TYPE_FIELDS (rt) = build_decl (FIELD_DECL, get_identifier ("f"),
array);
! DECL_CONTEXT (TYPE_FIELDS (rt)) = rt;
! layout_type (rt);
! TYPE_DEBUG_REPRESENTATION_TYPE (new_type) = rt;
!
! /* Build back pointers if needed. */
! *node = vector_size_helper (*node, new_type);
}
return NULL_TREE;
Index: dwarf2out.c
===================================================================
RCS file: /cvs/uberbaum/gcc/dwarf2out.c,v
retrieving revision 1.356
diff -c -p -r1.356 dwarf2out.c
*** dwarf2out.c 2002/02/21 23:03:14 1.356
--- dwarf2out.c 2002/02/26 06:23:11
*************** modified_type_die (type, is_const_type,
*** 7565,7571 ****
copy was created to help us keep track of typedef names) and
that copy might have a different TYPE_UID from the original
..._TYPE node. */
! mod_type_die = lookup_type_die (type_main_variant (type));
if (mod_type_die == NULL)
abort ();
}
--- 7565,7576 ----
copy was created to help us keep track of typedef names) and
that copy might have a different TYPE_UID from the original
..._TYPE node. */
! if (TREE_CODE (type) != VECTOR_TYPE)
! mod_type_die = lookup_type_die (type_main_variant (type));
! else
! /* Vectors have the debugging information in the type,
! not the main variant. */
! mod_type_die = lookup_type_die (type);
if (mod_type_die == NULL)
abort ();
}
*************** gen_type_die (type, context_die)
*** 10976,10985 ****
if (type == NULL_TREE || type == error_mark_node)
return;
! /* We are going to output a DIE to represent the unqualified version
of
! this type (i.e. without any const or volatile qualifiers) so get
the
! main variant (i.e. the unqualified version) of this type now. */
! type = type_main_variant (type);
if (TREE_ASM_WRITTEN (type))
return;
--- 10981,10993 ----
if (type == NULL_TREE || type == error_mark_node)
return;
! /* We are going to output a DIE to represent the unqualified version
! of this type (i.e. without any const or volatile qualifiers) so
! get the main variant (i.e. the unqualified version) of this type
! now. (Vectors are special because the debugging info is in the
! cloned type itself). */
! if (TREE_CODE (type) != VECTOR_TYPE)
! type = type_main_variant (type);
if (TREE_ASM_WRITTEN (type))
return;