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: gcc at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Cc: ezannoni at redhat dot com
- Date: Tue, 26 Feb 2002 12:56:50 +1100
- Subject: Re: common tree nodes question
- References: <20020225082638.GA6899@redhat.com>
On Mon, Feb 25, 2002 at 07:26:38PM +1100, Aldy Hernandez wrote:
> as yall might recall, for dwarf, vectors are treated as a structure
> containing an array. so:
>
> vector int foo;
>
> will really be passed to gdb as:
>
> struct {
> int xxx[4];
> } foo;
>
> elena pointed out that type of the base type for the array elements (xxx)
> comes out with unknown:
i thought about this long and hard, and it turns out the only place
where we know the underlying type (not type size) is in the attribute
code. this is obviously, for vectors created with the "vector_size"
attribute. for vectors created with the "mode" attribute, there's
no way to determine a type (ala, int, short, etc).
...but for vectors created with "vector_size", we know exactly the
underlying type, and can use this to build the debug information.
the patch below does exactly that.
ok?
2002-02-26 Aldy Hernandez <aldyh@redhat.com>
* attribs.c (handle_vector_size_attribute): Set debug information.
Index: attribs.c
===================================================================
RCS file: /cvs/uberbaum/gcc/attribs.c,v
retrieving revision 1.12
diff -c -p -r1.12 attribs.c
*** attribs.c 2002/02/22 00:08:59 1.12
--- attribs.c 2002/02/26 01:55:06
*************** handle_vector_size_attribute (node, name
*** 1305,1316 ****
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;
--- 1305,1336 ----
error ("no vector mode with the size and type specified could be found");
else
{
+ tree index, array, rt, t;
+
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;
! }
!
! /* This is the only place where we know the underlying type for
! a vector made with vector_size, so set the debug information
! here. For debugging purposes we pretend a vector is an array
! within a structure. */
! t = TYPE_MAIN_VARIANT (new_type);
! index = build_int_2 (TYPE_VECTOR_SUBPARTS (t) - 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 (t) = rt;
!
! /* Build back pointers if needed. */
! *node = vector_size_helper (*node, new_type);
}
return NULL_TREE;