From: Elena Zannoni <ezannoni@redhat.com>
To: gdb-patches@sources.redhat.com
Subject: [RFA] gdbtypes.c: rewrite init_simd_type
Date: Fri, 19 Apr 2002 15:51:00 -0000 [thread overview]
Message-ID: <15552.40803.992918.193570@localhost.redhat.com> (raw)
I rewrote init_simd_type to use the new functions that Andrew
introduced about a month ago in
http://sources.redhat.com/ml/gdb-patches/2002-03/msg00267.html.
I also rewrote the way the altivec vectors are built.
And fixed a wrong calculation of the size of the composite type.
Tested on powerpc w/altivec support and on Linux/i386.
Elena
2002-04-19 Elena Zannoni <ezannoni@redhat.com>
* gdbtypes.c (init_simd_type): Rewrite using new functions.
(build_builtin_type_vec128): Ditto.
(append_composite_type_field): Fix calculation of type length in
union case.
Index: gdbtypes.c
===================================================================
RCS file: /cvs/uberbaum/gdb/gdbtypes.c,v
retrieving revision 1.42
diff -u -p -r1.42 gdbtypes.c
--- gdbtypes.c 23 Mar 2002 01:24:54 -0000 1.42
+++ gdbtypes.c 19 Apr 2002 22:48:14 -0000
@@ -777,7 +777,6 @@ create_set_type (struct type *result_typ
return (result_type);
}
-
/* Construct and return a type of the form:
struct NAME { ELT_TYPE ELT_NAME[N]; }
We use these types for SIMD registers. For example, the type of
@@ -793,25 +792,15 @@ init_simd_type (char *name,
char *elt_name,
int n)
{
- struct type *t;
- struct field *f;
-
- /* Build the field structure. */
- f = xmalloc (sizeof (*f));
- memset (f, 0, sizeof (*f));
- f->loc.bitpos = 0;
- f->type = create_array_type (0, elt_type,
- create_range_type (0, builtin_type_int,
- 0, n-1));
- f->name = elt_name;
-
- /* Build a struct type with that field. */
- t = init_type (TYPE_CODE_STRUCT, n * TYPE_LENGTH (elt_type), 0, 0, 0);
- t->nfields = 1;
- t->fields = f;
- TYPE_TAG_NAME (t) = name;
-
- return t;
+ struct type *simd_type;
+ struct type *array_type;
+
+ simd_type = init_composite_type (name, TYPE_CODE_STRUCT);
+ array_type = create_array_type (0, elt_type,
+ create_range_type (0, builtin_type_int,
+ 0, n-1));
+ append_composite_type_field (simd_type, elt_name, array_type);
+ return simd_type;
}
static struct type *
@@ -831,30 +820,13 @@ build_builtin_type_vec128 (void)
#endif
struct type *t;
- struct field *f;
-
- f = (struct field *) xcalloc (5, sizeof (*f));
-
- FIELD_TYPE (f[0]) = builtin_type_int128;
- FIELD_NAME (f[0]) = "uint128";
-
- FIELD_TYPE (f[1]) = builtin_type_v4sf;
- FIELD_NAME (f[1]) = "v4sf";
-
- FIELD_TYPE (f[2]) = builtin_type_v4si;
- FIELD_NAME (f[2]) = "v4si";
-
- FIELD_TYPE (f[3]) = builtin_type_v8hi;
- FIELD_NAME (f[3]) = "v8hi";
-
- FIELD_TYPE (f[4]) = builtin_type_v16qi;
- FIELD_NAME (f[4]) = "v16qi";
- /* Build a union type with those fields. */
- t = init_type (TYPE_CODE_UNION, 16, 0, 0, 0);
- TYPE_NFIELDS (t) = 5;
- TYPE_FIELDS (t) = f;
- TYPE_TAG_NAME (t) = "__gdb_builtin_type_vec128";
+ t = init_composite_type ("__gdb_builtin_type_vec128", TYPE_CODE_UNION);
+ append_composite_type_field (t, "uint128", builtin_type_int128);
+ append_composite_type_field (t, "v4sf", builtin_type_v4sf);
+ append_composite_type_field (t, "v4si", builtin_type_v4si);
+ append_composite_type_field (t, "v8hi", builtin_type_v8hi);
+ append_composite_type_field (t, "v16qi", builtin_type_v16qi);
return t;
}
@@ -1781,7 +1753,7 @@ append_composite_type_field (struct type
FIELD_NAME (f[0]) = name;
if (TYPE_CODE (t) == TYPE_CODE_UNION)
{
- if (TYPE_LENGTH (t) > TYPE_LENGTH (field))
+ if (TYPE_LENGTH (t) < TYPE_LENGTH (field))
TYPE_LENGTH (t) = TYPE_LENGTH (field);
}
else if (TYPE_CODE (t) == TYPE_CODE_STRUCT)
next reply other threads:[~2002-04-19 22:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-04-19 15:51 Elena Zannoni [this message]
2002-04-19 16:37 ` Andrew Cagney
2002-04-19 17:31 ` Elena Zannoni
2002-04-19 18:12 ` Elena Zannoni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=15552.40803.992918.193570@localhost.redhat.com \
--to=ezannoni@redhat.com \
--cc=gdb-patches@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox